Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +24 −4 Original line number Diff line number Diff line Loading @@ -2507,8 +2507,18 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, String message = ""; switch (msg.what) { case SHOW: // There is a potential race condition when SysUI starts up. CentralSurfaces // must invoke #registerCentralSurfaces on this class before any messages can be // processed. If this happens, repost the message with a small delay and try // again. if (mCentralSurfaces == null) { message = "DELAYING SHOW"; Message newMsg = mHandler.obtainMessage(SHOW, (Bundle) msg.obj); mHandler.sendMessageDelayed(newMsg, 100); } else { message = "SHOW"; handleShow((Bundle) msg.obj); } break; case HIDE: message = "HIDE"; Loading Loading @@ -2595,8 +2605,18 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, Trace.endSection(); break; case SYSTEM_READY: // There is a potential race condition when SysUI starts up. CentralSurfaces // must invoke #registerCentralSurfaces on this class before any messages can be // processed. If this happens, repost the message with a small delay and try // again. if (mCentralSurfaces == null) { message = "DELAYING SYSTEM_READY"; Message newMsg = mHandler.obtainMessage(SYSTEM_READY); mHandler.sendMessageDelayed(newMsg, 100); } else { message = "SYSTEM_READY"; handleSystemReady(); } break; } Log.d(TAG, "KeyguardViewMediator queue processing message: " + message); Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -307,6 +307,28 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { } } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void testRaceCondition_doNotRegisterCentralSurfacesImmediately() { create(false); // GIVEN central surfaces is not registered with KeyguardViewMediator, but a call to enable // keyguard comes in mViewMediator.onSystemReady(); mViewMediator.setKeyguardEnabled(true); TestableLooper.get(this).processAllMessages(); // If this step has been reached, then system ui has not crashed. Now register // CentralSurfaces assertFalse(mViewMediator.isShowingAndNotOccluded()); register(); TestableLooper.get(this).moveTimeForward(100); TestableLooper.get(this).processAllMessages(); // THEN keyguard is shown assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void onLockdown_showKeyguard_evenIfKeyguardIsNotEnabledExternally() { Loading Loading @@ -1139,6 +1161,11 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { } private void createAndStartViewMediator(boolean orderUnlockAndWake) { create(orderUnlockAndWake); register(); } private void create(boolean orderUnlockAndWake) { mContext.getOrCreateTestableResources().addOverride( com.android.internal.R.bool.config_orderUnlockAndWake, orderUnlockAndWake); Loading Loading @@ -1189,7 +1216,9 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { mSelectedUserInteractor, mKeyguardInteractor); mViewMediator.start(); } private void register() { mViewMediator.registerCentralSurfaces(mCentralSurfaces, null, null, null, null, null); } Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +24 −4 Original line number Diff line number Diff line Loading @@ -2507,8 +2507,18 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, String message = ""; switch (msg.what) { case SHOW: // There is a potential race condition when SysUI starts up. CentralSurfaces // must invoke #registerCentralSurfaces on this class before any messages can be // processed. If this happens, repost the message with a small delay and try // again. if (mCentralSurfaces == null) { message = "DELAYING SHOW"; Message newMsg = mHandler.obtainMessage(SHOW, (Bundle) msg.obj); mHandler.sendMessageDelayed(newMsg, 100); } else { message = "SHOW"; handleShow((Bundle) msg.obj); } break; case HIDE: message = "HIDE"; Loading Loading @@ -2595,8 +2605,18 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, Trace.endSection(); break; case SYSTEM_READY: // There is a potential race condition when SysUI starts up. CentralSurfaces // must invoke #registerCentralSurfaces on this class before any messages can be // processed. If this happens, repost the message with a small delay and try // again. if (mCentralSurfaces == null) { message = "DELAYING SYSTEM_READY"; Message newMsg = mHandler.obtainMessage(SYSTEM_READY); mHandler.sendMessageDelayed(newMsg, 100); } else { message = "SYSTEM_READY"; handleSystemReady(); } break; } Log.d(TAG, "KeyguardViewMediator queue processing message: " + message); Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -307,6 +307,28 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { } } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void testRaceCondition_doNotRegisterCentralSurfacesImmediately() { create(false); // GIVEN central surfaces is not registered with KeyguardViewMediator, but a call to enable // keyguard comes in mViewMediator.onSystemReady(); mViewMediator.setKeyguardEnabled(true); TestableLooper.get(this).processAllMessages(); // If this step has been reached, then system ui has not crashed. Now register // CentralSurfaces assertFalse(mViewMediator.isShowingAndNotOccluded()); register(); TestableLooper.get(this).moveTimeForward(100); TestableLooper.get(this).processAllMessages(); // THEN keyguard is shown assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void onLockdown_showKeyguard_evenIfKeyguardIsNotEnabledExternally() { Loading Loading @@ -1139,6 +1161,11 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { } private void createAndStartViewMediator(boolean orderUnlockAndWake) { create(orderUnlockAndWake); register(); } private void create(boolean orderUnlockAndWake) { mContext.getOrCreateTestableResources().addOverride( com.android.internal.R.bool.config_orderUnlockAndWake, orderUnlockAndWake); Loading Loading @@ -1189,7 +1216,9 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { mSelectedUserInteractor, mKeyguardInteractor); mViewMediator.start(); } private void register() { mViewMediator.registerCentralSurfaces(mCentralSurfaces, null, null, null, null, null); } Loading