Fix bug where dismiss() was being called from the wrong thread
One-way calls to binder do not guarantee the call will always
occur on the originating thread. This fixes a rare case where
keyguard would crash due to dismiss() being called from the wrong
thread.
Fixes bug 11065316
Change-Id: Iddd281964231a152e3342e21b6b88527eab94caf
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
index ec3eb157..dc28bd0 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
@@ -124,6 +124,7 @@
private static final int SHOW_ASSISTANT = 14;
private static final int DISPATCH_EVENT = 15;
private static final int LAUNCH_CAMERA = 16;
+ private static final int DISMISS = 17;
/**
* The default amount of time we stay awake (used for all key input)
@@ -910,12 +911,16 @@
/**
* Dismiss the keyguard through the security layers.
*/
- public void dismiss() {
+ public void handleDismiss() {
if (mShowing && !mHidden) {
mKeyguardViewManager.dismiss();
}
}
+ public void dismiss() {
+ mHandler.sendEmptyMessage(DISMISS);
+ }
+
/**
* Send message to keyguard telling it to reset its state.
* @param options options about how to show the keyguard
@@ -1014,14 +1019,13 @@
};
public void keyguardDone(boolean authenticated, boolean wakeup) {
- mKeyguardDonePending = false;
+ if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated + ")");
+ EventLog.writeEvent(70000, 2);
synchronized (this) {
- EventLog.writeEvent(70000, 2);
- if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated + ")");
- Message msg = mHandler.obtainMessage(KEYGUARD_DONE, authenticated ? 1 : 0,
- wakeup ? 1 : 0);
- mHandler.sendMessage(msg);
+ mKeyguardDonePending = false;
}
+ Message msg = mHandler.obtainMessage(KEYGUARD_DONE, authenticated ? 1 : 0, wakeup ? 1 : 0);
+ mHandler.sendMessage(msg);
}
/**
@@ -1037,31 +1041,31 @@
switch (msg.what) {
case SHOW:
handleShow((Bundle) msg.obj);
- return ;
+ break;
case HIDE:
handleHide();
- return ;
+ break;
case RESET:
handleReset((Bundle) msg.obj);
- return ;
+ break;
case VERIFY_UNLOCK:
handleVerifyUnlock();
- return;
+ break;
case NOTIFY_SCREEN_OFF:
handleNotifyScreenOff();
- return;
+ break;
case NOTIFY_SCREEN_ON:
handleNotifyScreenOn((IKeyguardShowCallback) msg.obj);
- return;
+ break;
case KEYGUARD_DONE:
handleKeyguardDone(msg.arg1 != 0, msg.arg2 != 0);
- return;
+ break;
case KEYGUARD_DONE_DRAWING:
handleKeyguardDoneDrawing();
- return;
+ break;
case KEYGUARD_DONE_AUTHENTICATING:
keyguardDone(true, true);
- return;
+ break;
case SET_HIDDEN:
handleSetHidden(msg.arg1 != 0);
break;
@@ -1079,6 +1083,9 @@
case LAUNCH_CAMERA:
handleLaunchCamera();
break;
+ case DISMISS:
+ handleDismiss();
+ break;
}
}
};
@@ -1178,8 +1185,7 @@
private void updateActivityLockScreenState() {
try {
- ActivityManagerNative.getDefault().setLockScreenShown(
- mShowing && !mHidden);
+ ActivityManagerNative.getDefault().setLockScreenShown(mShowing && !mHidden);
} catch (RemoteException e) {
}
}