On device lockdown, always show the keyguard

Manual test steps:
1. Enable app pinning and disable "Ask for PIN before unpinning" setting
2. Pin an app (ie: Settings)
3. Lockdown from the power menu
Observe: user is brought to the keyguard, primary auth is required
to enter the device. After entering credential, the device is still in
app pinning mode.

Test: atest KeyguardViewMediatorTest
Test: manual steps outlined above
Bug: 218495634
Change-Id: I9a7c5e1acadabd4484e58573331f98dba895f2a2
Merged-In: I9a7c5e1acadabd4484e58573331f98dba895f2a2
This commit is contained in:
Beverly
2023-05-08 16:33:12 +00:00
committed by Beverly Tai
parent 4bd98b45b6
commit c851ef6d27
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());
}
}