Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7d2d43b authored by Kenny Root's avatar Kenny Root
Browse files

WindowManagerService: add some defensive checks

Add checks before posting a message to the handler thread where
exceptions will crash the service.

Also make KeyguardLock fields final.

Bug: 14564617
Change-Id: I147d579d942f5fa555714d204cde52e2cd5f6154
parent c4bfcc12
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -44,8 +44,8 @@ public class KeyguardManager {
     * you to disable / reenable the keyguard.
     */
    public class KeyguardLock {
        private IBinder mToken = new Binder();
        private String mTag;
        private final IBinder mToken = new Binder();
        private final String mTag;

        KeyguardLock(String tag) {
            mTag = tag;
+13 −0
Original line number Diff line number Diff line
@@ -5038,6 +5038,10 @@ public class WindowManagerService extends IWindowManager.Stub
            throw new SecurityException("Requires DISABLE_KEYGUARD permission");
        }

        if (token == null) {
            throw new IllegalArgumentException("token == null");
        }

        mKeyguardDisableHandler.sendMessage(mKeyguardDisableHandler.obtainMessage(
                KeyguardDisableHandler.KEYGUARD_DISABLE, new Pair<IBinder, String>(token, tag)));
    }
@@ -5049,6 +5053,10 @@ public class WindowManagerService extends IWindowManager.Stub
            throw new SecurityException("Requires DISABLE_KEYGUARD permission");
        }

        if (token == null) {
            throw new IllegalArgumentException("token == null");
        }

        mKeyguardDisableHandler.sendMessage(mKeyguardDisableHandler.obtainMessage(
                KeyguardDisableHandler.KEYGUARD_REENABLE, token));
    }
@@ -5062,6 +5070,11 @@ public class WindowManagerService extends IWindowManager.Stub
            != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Requires DISABLE_KEYGUARD permission");
        }

        if (callback == null) {
            throw new IllegalArgumentException("callback == null");
        }

        mPolicy.exitKeyguardSecurely(new WindowManagerPolicy.OnKeyguardExitResult() {
            @Override
            public void onKeyguardExitResult(boolean success) {