Surface: Leave object in unlocked state when unlockCanvasAndPost fails
If nativeUnlockCanvasAndPost() throws, Surface was maintaining a reference to the native Surface, and assuming it was still locked. That would cause future lockCanvas() calls to throw without even trying to lock the native Surface, even though in some cases the native lock was actually released before the exception was thrown. Now Surface treats the native object as unlocked even if nativeUnlockCanvasAndPost() throws, so it will attempt the native lock on lockCanvas() rather than assuming it would fail. This change also changes an IllegalStateException to IllegalArgumentException in unlockCanvasAndPost(). That exception was added in KitKat, and was never documented or added to the throws declaration. This was essentially a silent public API change. Quite a bit of code in the framework (and likely in applications) catches IAE from this method, but didn't attempt to handle ISE. Although ISE is more correct here, it's not worth breaking code (and it did -- in this bug it changed a problem that should have been silently and perfectly recovered from into a fatal exception in system_server.) Bug: 17684556 Change-Id: Ia8d3e5d33eaa690d16c7d0f557390c7bb4e1e32e
Loading
Please register or sign in to comment