Merge "On device lockdown, always show the keyguard" into udc-dev

This commit is contained in:
Beverly Tai
2023-05-09 17:04:08 +00:00
committed by Android (Google) Code Review
2 changed files with 37 additions and 2 deletions

View File

@@ -726,6 +726,13 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
}
}
}
@Override
public void onStrongAuthStateChanged(int userId) {
if (mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) {
doKeyguardLocked(null);
}
}
};
ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() {
@@ -1949,8 +1956,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
* Enable the keyguard if the settings are appropriate.
*/
private void doKeyguardLocked(Bundle options) {
// if another app is disabling us, don't show
if (!mExternallyEnabled) {
// if another app is disabling us, don't show unless we're in lockdown mode
if (!mExternallyEnabled
&& !mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) {
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled");
mNeedToReshowWhenReenabled = true;

View File

@@ -58,6 +58,7 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardDisplayManager;
import com.android.keyguard.KeyguardSecurityView;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.mediator.ScreenOnCoordinator;
import com.android.systemui.DejankUtils;
import com.android.systemui.SysuiTestCase;
@@ -98,6 +99,8 @@ import com.android.systemui.util.time.FakeSystemClock;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -141,6 +144,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
private @Mock AuthController mAuthController;
private @Mock ShadeExpansionStateManager mShadeExpansionStateManager;
private @Mock ShadeWindowLogger mShadeWindowLogger;
private @Captor ArgumentCaptor<KeyguardUpdateMonitorCallback>
mKeyguardUpdateMonitorCallbackCaptor;
private DeviceConfigProxy mDeviceConfig = new DeviceConfigProxyFake();
private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
@@ -178,6 +183,24 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
createAndStartViewMediator();
}
@Test
public void onLockdown_showKeyguard_evenIfKeyguardIsNotEnabledExternally() {
// GIVEN keyguard is not enabled and isn't showing
mViewMediator.onSystemReady();
mViewMediator.setKeyguardEnabled(false);
TestableLooper.get(this).processAllMessages();
captureKeyguardUpdateMonitorCallback();
assertFalse(mViewMediator.isShowingAndNotOccluded());
// WHEN lockdown occurs
when(mLockPatternUtils.isUserInLockdown(anyInt())).thenReturn(true);
mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(0);
// THEN keyguard is shown
TestableLooper.get(this).processAllMessages();
assertTrue(mViewMediator.isShowingAndNotOccluded());
}
@Test
public void testOnGoingToSleep_UpdatesKeyguardGoingAway() {
mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER);
@@ -602,4 +625,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mViewMediator.registerCentralSurfaces(mCentralSurfaces, null, null, null, null, null);
}
private void captureKeyguardUpdateMonitorCallback() {
verify(mUpdateMonitor).registerCallback(mKeyguardUpdateMonitorCallbackCaptor.capture());
}
}