Merge "Don't call setKeyguardGoingAway on background thread" into rvc-dev am: 0bea141717 am: 15dce34600

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12013463

Change-Id: Id55a513d9ebba4592baf48d677610cec2cb0f863
This commit is contained in:
TreeHugger Robot
2020-06-27 02:15:39 +00:00
committed by Automerger Merge Worker
3 changed files with 21 additions and 3 deletions

View File

@@ -177,6 +177,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private static final int MSG_TIMEZONE_UPDATE = 339; private static final int MSG_TIMEZONE_UPDATE = 339;
private static final int MSG_USER_STOPPED = 340; private static final int MSG_USER_STOPPED = 340;
private static final int MSG_USER_REMOVED = 341; private static final int MSG_USER_REMOVED = 341;
private static final int MSG_KEYGUARD_GOING_AWAY = 342;
/** Biometric authentication state: Not listening. */ /** Biometric authentication state: Not listening. */
private static final int BIOMETRIC_STATE_STOPPED = 0; private static final int BIOMETRIC_STATE_STOPPED = 0;
@@ -532,7 +533,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
/** /**
* Updates KeyguardUpdateMonitor's internal state to know if keyguard is goingAway * Updates KeyguardUpdateMonitor's internal state to know if keyguard is going away.
*/ */
public void setKeyguardGoingAway(boolean goingAway) { public void setKeyguardGoingAway(boolean goingAway) {
mKeyguardGoingAway = goingAway; mKeyguardGoingAway = goingAway;
@@ -1522,6 +1523,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
mUserTrustIsUsuallyManaged.delete(userId); mUserTrustIsUsuallyManaged.delete(userId);
} }
private void handleKeyguardGoingAway(boolean goingAway) {
Assert.isMainThread();
setKeyguardGoingAway(goingAway);
}
@VisibleForTesting @VisibleForTesting
protected void setStrongAuthTracker(@NonNull StrongAuthTracker tracker) { protected void setStrongAuthTracker(@NonNull StrongAuthTracker tracker) {
if (mStrongAuthTracker != null) { if (mStrongAuthTracker != null) {
@@ -1662,6 +1668,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
case MSG_TELEPHONY_CAPABLE: case MSG_TELEPHONY_CAPABLE:
updateTelephonyCapable((boolean) msg.obj); updateTelephonyCapable((boolean) msg.obj);
break; break;
case MSG_KEYGUARD_GOING_AWAY:
handleKeyguardGoingAway((boolean) msg.obj);
break;
default: default:
super.handleMessage(msg); super.handleMessage(msg);
break; break;
@@ -2814,6 +2823,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
mHandler.sendMessage(mHandler.obtainMessage(MSG_DREAMING_STATE_CHANGED, 0, 0)); mHandler.sendMessage(mHandler.obtainMessage(MSG_DREAMING_STATE_CHANGED, 0, 0));
} }
/**
* Sends a message to update the keyguard going away state on the main thread.
*
* @param goingAway Whether the keyguard is going away.
*/
public void dispatchKeyguardGoingAway(boolean goingAway) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_KEYGUARD_GOING_AWAY, goingAway));
}
public boolean isDeviceInteractive() { public boolean isDeviceInteractive() {
return mDeviceInteractive; return mDeviceInteractive;
} }

View File

@@ -876,7 +876,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable {
// explicitly DO NOT want to call // explicitly DO NOT want to call
// mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(false) // mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(false)
// here, since that will mess with the device lock state. // here, since that will mess with the device lock state.
mUpdateMonitor.setKeyguardGoingAway(false); mUpdateMonitor.dispatchKeyguardGoingAway(false);
// Lock immediately based on setting if secure (user has a pin/pattern/password). // Lock immediately based on setting if secure (user has a pin/pattern/password).
// This also "locks" the device when not secure to provide easy access to the // This also "locks" the device when not secure to provide easy access to the

View File

@@ -95,7 +95,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
@Test @Test
public void testOnGoingToSleep_UpdatesKeyguardGoingAway() { public void testOnGoingToSleep_UpdatesKeyguardGoingAway() {
mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER); mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER);
verify(mUpdateMonitor).setKeyguardGoingAway(false); verify(mUpdateMonitor).dispatchKeyguardGoingAway(false);
verify(mStatusBarKeyguardViewManager, never()).setKeyguardGoingAwayState(anyBoolean()); verify(mStatusBarKeyguardViewManager, never()).setKeyguardGoingAwayState(anyBoolean());
} }