Merge "Make sure SIM PIN screen shows" into sc-dev
This commit is contained in:
@@ -398,6 +398,12 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
|
||||
*/
|
||||
private boolean mPendingLock;
|
||||
|
||||
/**
|
||||
* When starting to go away, flag a need to show the PIN lock so the keyguard can be brought
|
||||
* back.
|
||||
*/
|
||||
private boolean mPendingPinLock = false;
|
||||
|
||||
/**
|
||||
* Whether a power button gesture (such as double tap for camera) has been detected. This is
|
||||
* delivered directly from {@link KeyguardService}, immediately upon the gesture being detected.
|
||||
@@ -471,6 +477,19 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
|
||||
|
||||
KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
|
||||
|
||||
@Override
|
||||
public void onKeyguardVisibilityChanged(boolean showing) {
|
||||
synchronized (KeyguardViewMediator.this) {
|
||||
if (!showing && mPendingPinLock) {
|
||||
Log.i(TAG, "PIN lock requested, starting keyguard");
|
||||
|
||||
// Bring the keyguard back in order to show the PIN lock
|
||||
mPendingPinLock = false;
|
||||
doKeyguardLocked(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserSwitching(int userId) {
|
||||
if (DEBUG) Log.d(TAG, String.format("onUserSwitching %d", userId));
|
||||
@@ -591,6 +610,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
|
||||
+ "showing; need to show keyguard so user can enter sim pin");
|
||||
doKeyguardLocked(null);
|
||||
} else {
|
||||
mPendingPinLock = true;
|
||||
resetStateLocked();
|
||||
}
|
||||
}
|
||||
@@ -739,6 +759,9 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
|
||||
@Override
|
||||
public void onBouncerVisiblityChanged(boolean shown) {
|
||||
synchronized (KeyguardViewMediator.this) {
|
||||
if (shown) {
|
||||
mPendingPinLock = false;
|
||||
}
|
||||
adjustStatusBarLocked(shown, false);
|
||||
}
|
||||
}
|
||||
@@ -2783,7 +2806,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
|
||||
}
|
||||
}
|
||||
|
||||
private void setShowingLocked(boolean showing) {
|
||||
void setShowingLocked(boolean showing) {
|
||||
setShowingLocked(showing, false /* forceCallbacks */);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -33,8 +34,9 @@ import android.app.admin.DevicePolicyManager;
|
||||
import android.app.trust.TrustManager;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper.RunWithLooper;
|
||||
import android.testing.TestableLooper;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
@@ -65,7 +67,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@RunWithLooper
|
||||
@TestableLooper.RunWithLooper(setAsMainLooper = true)
|
||||
@SmallTest
|
||||
public class KeyguardViewMediatorTest extends SysuiTestCase {
|
||||
private KeyguardViewMediator mViewMediator;
|
||||
@@ -124,6 +126,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
|
||||
mUnlockedScreenOffAnimationController,
|
||||
() -> mNotificationShadeDepthController);
|
||||
mViewMediator.start();
|
||||
mViewMediator.onSystemReady();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,4 +163,27 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
|
||||
mViewMediator.onDozeAmountChanged(1f, 1f);
|
||||
assertFalse(mViewMediator.isAnimatingScreenOff());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restoreBouncerWhenSimLockedAndKeyguardIsGoingAway() {
|
||||
// When showing and provisioned
|
||||
when(mUpdateMonitor.isDeviceProvisioned()).thenReturn(true);
|
||||
mViewMediator.setShowingLocked(true);
|
||||
|
||||
// and a SIM becomes locked and requires a PIN
|
||||
mViewMediator.mUpdateCallback.onSimStateChanged(
|
||||
1 /* subId */,
|
||||
0 /* slotId */,
|
||||
TelephonyManager.SIM_STATE_PIN_REQUIRED);
|
||||
|
||||
// and the keyguard goes away
|
||||
mViewMediator.setShowingLocked(false);
|
||||
when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false);
|
||||
mViewMediator.mUpdateCallback.onKeyguardVisibilityChanged(false);
|
||||
|
||||
TestableLooper.get(this).processAllMessages();
|
||||
|
||||
// then make sure it comes back
|
||||
verify(mStatusBarKeyguardViewManager, atLeast(1)).show(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user