diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 2192b8c03c968..07e11938c9032 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -59,6 +59,8 @@ import android.view.WindowManagerPolicy; import android.view.animation.Animation; import android.view.animation.AnimationUtils; +import com.android.internal.logging.MetricsLogger; +import com.android.internal.logging.nano.MetricsProto; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.policy.IKeyguardDrawnCallback; import com.android.internal.policy.IKeyguardExitCallback; @@ -325,6 +327,7 @@ public class KeyguardViewMediator extends SystemUI { private boolean mWakeAndUnlocking; private IKeyguardDrawnCallback mDrawnCallback; + private boolean mLockWhenSimRemoved; KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { @@ -415,7 +418,7 @@ public class KeyguardViewMediator extends SystemUI { case ABSENT: // only force lock screen in case of missing sim if user hasn't // gone through setup wizard - synchronized (this) { + synchronized (KeyguardViewMediator.this) { if (shouldWaitForProvisioning()) { if (!mShowing) { if (DEBUG_SIM_STATES) Log.d(TAG, "ICC_ABSENT isn't showing," @@ -426,11 +429,12 @@ public class KeyguardViewMediator extends SystemUI { resetStateLocked(); } } + onSimNotReadyLocked(); } break; case PIN_REQUIRED: case PUK_REQUIRED: - synchronized (this) { + synchronized (KeyguardViewMediator.this) { if (!mShowing) { if (DEBUG_SIM_STATES) Log.d(TAG, "INTENT_VALUE_ICC_LOCKED and keygaurd isn't " @@ -442,7 +446,7 @@ public class KeyguardViewMediator extends SystemUI { } break; case PERM_DISABLED: - synchronized (this) { + synchronized (KeyguardViewMediator.this) { if (!mShowing) { if (DEBUG_SIM_STATES) Log.d(TAG, "PERM_DISABLED and " + "keygaurd isn't showing."); @@ -452,21 +456,40 @@ public class KeyguardViewMediator extends SystemUI { + "show permanently disabled message in lockscreen."); resetStateLocked(); } + onSimNotReadyLocked(); } break; case READY: - synchronized (this) { + synchronized (KeyguardViewMediator.this) { if (mShowing) { resetStateLocked(); } + mLockWhenSimRemoved = true; } break; default: - if (DEBUG_SIM_STATES) Log.v(TAG, "Ignoring state: " + simState); + if (DEBUG_SIM_STATES) Log.v(TAG, "Unspecific state: " + simState); + synchronized (KeyguardViewMediator.this) { + onSimNotReadyLocked(); + } break; } } + private void onSimNotReadyLocked() { + if (isSecure() && mLockWhenSimRemoved) { + mLockWhenSimRemoved = false; + MetricsLogger.action(mContext, + MetricsProto.MetricsEvent.ACTION_LOCK_BECAUSE_SIM_REMOVED, mShowing); + if (!mShowing) { + if (DEBUG_SIM_STATES) Log.d(TAG, "SIM removed, showing keyguard"); + doKeyguardLocked(null); + } else { + resetStateLocked(); + } + } + } + @Override public void onFingerprintAuthFailed() { final int currentUser = KeyguardUpdateMonitor.getCurrentUser(); diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto index fc8c67507bf5a..f08408bb695da 100644 --- a/proto/src/metrics_constants.proto +++ b/proto/src/metrics_constants.proto @@ -2232,6 +2232,14 @@ message MetricsEvent { // ---- End N-MR1 Constants, all N-MR1 constants go above this line ---- + // ACTION: The lockscreen gets shown because the SIM card was removed + // SUBTYPE: false: device was previously unlocked, true: device was previously locked + // CATEGORY: GLOBAL_SYSTEM_UI + // OS: N-MR2 + ACTION_LOCK_BECAUSE_SIM_REMOVED = 496; + + // ---- End N-MR2 Constants, all N-MR2 constants go above this line ---- + // ------- Begin N Keyboard Shortcuts Helper ----- // Keyboard Shortcuts Helper is opened/closed. KEYBOARD_SHORTCUTS_HELPER = 500;