DO NOT MERGE Show keyguard when SIM is removed

If the device has a secure lockscreen and the device'
SIM card is removed, lock the device.

Change-Id: I0369af81297169d65254b85bc9a056e4f4a02b7b
Merged-In: I5b0deea8851b38781059732a3cf6fa0a4a00e3ca
Fixes: 30997251
This commit is contained in:
Adrian Roos
2016-11-28 15:46:06 -08:00
parent 873c99c30b
commit fd61f22210
2 changed files with 36 additions and 5 deletions

View File

@@ -63,6 +63,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.MetricsProto.MetricsEvent;
import com.android.internal.policy.IKeyguardDrawnCallback;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardStateCallback;
@@ -335,6 +337,7 @@ public class KeyguardViewMediator extends SystemUI {
private boolean mWakeAndUnlocking;
private IKeyguardDrawnCallback mDrawnCallback;
private boolean mLockWhenSimRemoved;
private boolean mIsPerUserLock;
@@ -429,7 +432,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,"
@@ -440,11 +443,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 "
@@ -456,7 +460,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.");
@@ -466,21 +470,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,
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();

View File

@@ -2213,6 +2213,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 = 497;
// ---- End N-MR2 Constants, all N-MR2 constants go above this line ----
// Add new aosp constants above this line.
// END OF AOSP CONSTANTS
}