Loading policy/com/android/internal/policy/impl/GlobalActions.java +2 −1 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import com.android.internal.R; import com.android.internal.app.ShutdownThread; import com.google.android.collect.Lists; import java.util.ArrayList; Loading Loading @@ -176,7 +177,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac public void onPress() { // shutdown by making sure radio and power are handled accordingly. ShutdownThread.shutdownAfterDisablingRadio(mContext, true); ShutdownThread.shutdown(mContext, true); } public boolean showDuringKeyguard() { Loading policy/com/android/internal/policy/impl/KeyguardUpdateMonitor.java +30 −27 Original line number Diff line number Diff line Loading @@ -34,7 +34,9 @@ import static android.provider.Telephony.Intents.EXTRA_SHOW_PLMN; import static android.provider.Telephony.Intents.EXTRA_SHOW_SPN; import static android.provider.Telephony.Intents.EXTRA_SPN; import static android.provider.Telephony.Intents.SPN_STRINGS_UPDATED_ACTION; import com.android.internal.telephony.SimCard; import com.android.internal.app.ShutdownThread; import com.android.internal.telephony.IccCard; import com.android.internal.telephony.TelephonyIntents; import android.util.Log; import com.android.internal.R; Loading @@ -61,7 +63,7 @@ public class KeyguardUpdateMonitor { private final Context mContext; private SimCard.State mSimState = SimCard.State.READY; private IccCard.State mSimState = IccCard.State.READY; private boolean mInPortrait; private boolean mKeyboardOpen; Loading Loading @@ -94,38 +96,39 @@ public class KeyguardUpdateMonitor { /** * When we receive a {@link com.android.internal.telephony.TelephonyIntents#ACTION_SIM_STATE_CHANGED} broadcast, and * then pass a result via our handler to {@link KeyguardUpdateMonitor#handleSimStateChange}, * When we receive a * {@link com.android.internal.telephony.TelephonyIntents#ACTION_SIM_STATE_CHANGED} broadcast, * and then pass a result via our handler to {@link KeyguardUpdateMonitor#handleSimStateChange}, * we need a single object to pass to the handler. This class helps decode * the intent and provide a {@link SimCard.State} result. */ private static class SimArgs { public final SimCard.State simState; public final IccCard.State simState; private SimArgs(Intent intent) { if (!TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(intent.getAction())) { throw new IllegalArgumentException("only handles intent ACTION_SIM_STATE_CHANGED"); } String stateExtra = intent.getStringExtra(SimCard.INTENT_KEY_SIM_STATE); if (SimCard.INTENT_VALUE_SIM_ABSENT.equals(stateExtra)) { this.simState = SimCard.State.ABSENT; } else if (SimCard.INTENT_VALUE_SIM_READY.equals(stateExtra)) { this.simState = SimCard.State.READY; } else if (SimCard.INTENT_VALUE_SIM_LOCKED.equals(stateExtra)) { String stateExtra = intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE); if (IccCard.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) { this.simState = IccCard.State.ABSENT; } else if (IccCard.INTENT_VALUE_ICC_READY.equals(stateExtra)) { this.simState = IccCard.State.READY; } else if (IccCard.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) { final String lockedReason = intent .getStringExtra(SimCard.INTENT_KEY_LOCKED_REASON); if (SimCard.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) { this.simState = SimCard.State.PIN_REQUIRED; } else if (SimCard.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) { this.simState = SimCard.State.PUK_REQUIRED; .getStringExtra(IccCard.INTENT_KEY_LOCKED_REASON); if (IccCard.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) { this.simState = IccCard.State.PIN_REQUIRED; } else if (IccCard.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) { this.simState = IccCard.State.PUK_REQUIRED; } else { this.simState = SimCard.State.UNKNOWN; this.simState = IccCard.State.UNKNOWN; } } else if (SimCard.INTENT_VALUE_LOCKED_NETWORK.equals(stateExtra)) { this.simState = SimCard.State.NETWORK_LOCKED; } else if (IccCard.INTENT_VALUE_LOCKED_NETWORK.equals(stateExtra)) { this.simState = IccCard.State.NETWORK_LOCKED; } else { this.simState = SimCard.State.UNKNOWN; this.simState = IccCard.State.UNKNOWN; } } Loading Loading @@ -195,7 +198,7 @@ public class KeyguardUpdateMonitor { mKeyboardOpen = queryKeyboardOpen(); // take a guess to start mSimState = SimCard.State.READY; mSimState = IccCard.State.READY; mDevicePluggedIn = true; mBatteryLevel = 100; Loading Loading @@ -297,7 +300,7 @@ public class KeyguardUpdateMonitor { if (batteryLevel == 0 && pluggedInStatus != BATTERY_STATUS_CHARGING && pluggedInStatus != BATTERY_STATUS_UNKNOWN) { ShutdownThread.shutdownAfterDisablingRadio(mContext, false); ShutdownThread.shutdown(mContext, false); } } Loading @@ -317,14 +320,14 @@ public class KeyguardUpdateMonitor { * Handle {@link #MSG_SIM_STATE_CHANGE} */ private void handleSimStateChange(SimArgs simArgs) { final SimCard.State state = simArgs.simState; final IccCard.State state = simArgs.simState; if (DEBUG) { Log.d(TAG, "handleSimStateChange: intentValue = " + simArgs + " " + "state resolved to " + state.toString()); } if (state != SimCard.State.UNKNOWN && state != mSimState) { if (state != IccCard.State.UNKNOWN && state != mSimState) { mSimState = state; for (int i = 0; i < mSimStateCallbacks.size(); i++) { mSimStateCallbacks.get(i).onSimStateChanged(state); Loading Loading @@ -461,7 +464,7 @@ public class KeyguardUpdateMonitor { * Callback to notify of sim state change. */ interface SimStateCallback { void onSimStateChanged(SimCard.State simState); void onSimStateChanged(IccCard.State simState); } /** Loading Loading @@ -489,7 +492,7 @@ public class KeyguardUpdateMonitor { mSimStateCallbacks.add(callback); } public SimCard.State getSimState() { public IccCard.State getSimState() { return mSimState; } Loading @@ -499,7 +502,7 @@ public class KeyguardUpdateMonitor { * broadcast from the telephony code. */ public void reportSimPinUnlocked() { mSimState = SimCard.State.READY; mSimState = IccCard.State.READY; } public boolean isInPortrait() { Loading policy/com/android/internal/policy/impl/KeyguardViewBase.java +2 −2 Original line number Diff line number Diff line Loading @@ -132,8 +132,8 @@ public abstract class KeyguardViewBase extends FrameLayout { } /** * Allows the media keys to work when the keygaurd is showing. * The media keys should be of no interest to the actualy keygaurd view(s), * Allows the media keys to work when the keyguard is showing. * The media keys should be of no interest to the actual keyguard view(s), * so intercepting them here should not be of any harm. * @param event The key event * @return whether the event was consumed as a media key. Loading policy/com/android/internal/policy/impl/KeyguardViewMediator.java +15 −12 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package com.android.internal.policy.impl; import com.android.internal.telephony.SimCard; import com.android.internal.telephony.IccCard; import com.android.internal.widget.LockPatternUtils; import android.app.AlarmManager; Loading @@ -41,6 +41,7 @@ import android.view.KeyEvent; import android.view.WindowManagerImpl; import android.view.WindowManagerPolicy; /** * Mediates requests related to the keyguard. This includes queries about the * state of the keyguard, power management events that effect whether the keyguard Loading Loading @@ -89,7 +90,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, private final static String TAG = "KeyguardViewMediator"; private static final String DELAYED_KEYGUARD_ACTION = "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD"; private static final String DELAYED_KEYGUARD_ACTION = "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD"; // used for handler messages private static final int TIMEOUT = 1; Loading Loading @@ -301,7 +303,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender); if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " + mDelayedShowingSequence); if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " + mDelayedShowingSequence); } else { doKeyguard(); } Loading Loading @@ -461,8 +464,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, // if the setup wizard hasn't run yet, don't show final boolean provisioned = mUpdateMonitor.isDeviceProvisioned(); final SimCard.State state = mUpdateMonitor.getSimState(); final boolean lockedOrMissing = state.isPinLocked() || (state == SimCard.State.ABSENT); final IccCard.State state = mUpdateMonitor.getSimState(); final boolean lockedOrMissing = state.isPinLocked() || (state == IccCard.State.ABSENT); if (!lockedOrMissing && !provisioned) { if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned" + " and the sim is not locked or missing"); Loading Loading @@ -576,7 +579,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } /** {@inheritDoc} */ public void onSimStateChanged(SimCard.State simState) { public void onSimStateChanged(IccCard.State simState) { if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState); switch (simState) { Loading @@ -585,7 +588,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, // gone through setup wizard if (!mUpdateMonitor.isDeviceProvisioned()) { if (!isShowing()) { if (DEBUG) Log.d(TAG, "INTENT_VALUE_SIM_ABSENT and keygaurd isn't showing, we need " if (DEBUG) Log.d(TAG, "INTENT_VALUE_ICC_ABSENT and keygaurd isn't showing, we need " + "to show the keyguard since the device isn't provisioned yet."); doKeyguard(); } else { Loading @@ -596,7 +599,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, case PIN_REQUIRED: case PUK_REQUIRED: if (!isShowing()) { if (DEBUG) Log.d(TAG, "INTENT_VALUE_SIM_LOCKED and keygaurd isn't showing, we need " if (DEBUG) Log.d(TAG, "INTENT_VALUE_ICC_LOCKED and keygaurd isn't showing, we need " + "to show the keyguard so the user can enter their sim pin"); doKeyguard(); } else { Loading Loading @@ -759,10 +762,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, */ private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { public void handleMessage(Message msg) { switch (msg.what) { case TIMEOUT: handleTimeout(msg.arg1); return ; Loading Loading @@ -947,3 +948,5 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } } } policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +17 −13 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ import android.content.ServiceConnection; import android.os.IBinder; import android.os.RemoteException; import android.os.SystemProperties; import com.android.internal.telephony.SimCard; import com.android.internal.telephony.IccCard; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; Loading Loading @@ -142,7 +142,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { private boolean stuckOnLockScreenBecauseSimMissing() { return mRequiresSim && (!mUpdateMonitor.isDeviceProvisioned()) && (mUpdateMonitor.getSimState() == SimCard.State.ABSENT); && (mUpdateMonitor.getSimState() == IccCard.State.ABSENT); } /** Loading Loading @@ -184,9 +184,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase { } public void goToUnlockScreen() { final SimCard.State simState = mUpdateMonitor.getSimState(); final IccCard.State simState = mUpdateMonitor.getSimState(); if (stuckOnLockScreenBecauseSimMissing() || (simState == SimCard.State.PUK_REQUIRED)){ || (simState == IccCard.State.PUK_REQUIRED)){ // stuck on lock screen when sim missing or puk'd return; } Loading Loading @@ -365,7 +365,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { public void wakeWhenReadyTq(int keyCode) { if (DEBUG) Log.d(TAG, "onWakeKey"); if (keyCode == KeyEvent.KEYCODE_MENU && isSecure() && (mMode == Mode.LockScreen) && (mUpdateMonitor.getSimState() != SimCard.State.PUK_REQUIRED)) { && (mUpdateMonitor.getSimState() != IccCard.State.PUK_REQUIRED)) { if (DEBUG) Log.d(TAG, "switching screens to unlock screen because wake key was MENU"); updateScreen(Mode.UnlockScreen); getCallback().pokeWakelock(); Loading Loading @@ -403,8 +403,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase { if (unlockMode == UnlockMode.Pattern) { return mLockPatternUtils.isLockPatternEnabled(); } else if (unlockMode == UnlockMode.SimPin) { return mUpdateMonitor.getSimState() == SimCard.State.PIN_REQUIRED || mUpdateMonitor.getSimState() == SimCard.State.PUK_REQUIRED; return mUpdateMonitor.getSimState() == IccCard.State.PIN_REQUIRED || mUpdateMonitor.getSimState() == IccCard.State.PUK_REQUIRED; } else if (unlockMode == UnlockMode.Account) { return true; } else { Loading Loading @@ -522,8 +522,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase { * the lock screen (lock or unlock). */ private Mode getInitialMode() { final SimCard.State simState = mUpdateMonitor.getSimState(); if (stuckOnLockScreenBecauseSimMissing() || (simState == SimCard.State.PUK_REQUIRED)) { final IccCard.State simState = mUpdateMonitor.getSimState(); if (stuckOnLockScreenBecauseSimMissing() || (simState == IccCard.State.PUK_REQUIRED)) { return Mode.LockScreen; } else if (mUpdateMonitor.isKeyboardOpen() && isSecure()) { return Mode.UnlockScreen; Loading @@ -536,8 +536,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase { * Given the current state of things, what should the unlock screen be? */ private UnlockMode getUnlockMode() { final SimCard.State simState = mUpdateMonitor.getSimState(); if (simState == SimCard.State.PIN_REQUIRED || simState == SimCard.State.PUK_REQUIRED) { final IccCard.State simState = mUpdateMonitor.getSimState(); if (simState == IccCard.State.PIN_REQUIRED || simState == IccCard.State.PUK_REQUIRED) { return UnlockMode.SimPin; } else { return mLockPatternUtils.isPermanentlyLocked() ? Loading Loading @@ -568,7 +568,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase { int timeoutInSeconds = (int) LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS / 1000; String message = mContext.getString( R.string.lockscreen_failed_attempts_almost_glogin, LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, timeoutInSeconds); final AlertDialog dialog = new AlertDialog.Builder(mContext) Loading @@ -589,9 +590,11 @@ public class LockPatternKeyguardView extends KeyguardViewBase { */ static private class FastBitmapDrawable extends Drawable { private Bitmap mBitmap; private int mOpacity; private FastBitmapDrawable(Bitmap bitmap) { mBitmap = bitmap; mOpacity = mBitmap.hasAlpha() ? PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE; } @Override Loading @@ -605,7 +608,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { @Override public int getOpacity() { return PixelFormat.TRANSLUCENT; return mOpacity; } @Override Loading Loading @@ -637,3 +640,4 @@ public class LockPatternKeyguardView extends KeyguardViewBase { } } } Loading
policy/com/android/internal/policy/impl/GlobalActions.java +2 −1 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import com.android.internal.R; import com.android.internal.app.ShutdownThread; import com.google.android.collect.Lists; import java.util.ArrayList; Loading Loading @@ -176,7 +177,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac public void onPress() { // shutdown by making sure radio and power are handled accordingly. ShutdownThread.shutdownAfterDisablingRadio(mContext, true); ShutdownThread.shutdown(mContext, true); } public boolean showDuringKeyguard() { Loading
policy/com/android/internal/policy/impl/KeyguardUpdateMonitor.java +30 −27 Original line number Diff line number Diff line Loading @@ -34,7 +34,9 @@ import static android.provider.Telephony.Intents.EXTRA_SHOW_PLMN; import static android.provider.Telephony.Intents.EXTRA_SHOW_SPN; import static android.provider.Telephony.Intents.EXTRA_SPN; import static android.provider.Telephony.Intents.SPN_STRINGS_UPDATED_ACTION; import com.android.internal.telephony.SimCard; import com.android.internal.app.ShutdownThread; import com.android.internal.telephony.IccCard; import com.android.internal.telephony.TelephonyIntents; import android.util.Log; import com.android.internal.R; Loading @@ -61,7 +63,7 @@ public class KeyguardUpdateMonitor { private final Context mContext; private SimCard.State mSimState = SimCard.State.READY; private IccCard.State mSimState = IccCard.State.READY; private boolean mInPortrait; private boolean mKeyboardOpen; Loading Loading @@ -94,38 +96,39 @@ public class KeyguardUpdateMonitor { /** * When we receive a {@link com.android.internal.telephony.TelephonyIntents#ACTION_SIM_STATE_CHANGED} broadcast, and * then pass a result via our handler to {@link KeyguardUpdateMonitor#handleSimStateChange}, * When we receive a * {@link com.android.internal.telephony.TelephonyIntents#ACTION_SIM_STATE_CHANGED} broadcast, * and then pass a result via our handler to {@link KeyguardUpdateMonitor#handleSimStateChange}, * we need a single object to pass to the handler. This class helps decode * the intent and provide a {@link SimCard.State} result. */ private static class SimArgs { public final SimCard.State simState; public final IccCard.State simState; private SimArgs(Intent intent) { if (!TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(intent.getAction())) { throw new IllegalArgumentException("only handles intent ACTION_SIM_STATE_CHANGED"); } String stateExtra = intent.getStringExtra(SimCard.INTENT_KEY_SIM_STATE); if (SimCard.INTENT_VALUE_SIM_ABSENT.equals(stateExtra)) { this.simState = SimCard.State.ABSENT; } else if (SimCard.INTENT_VALUE_SIM_READY.equals(stateExtra)) { this.simState = SimCard.State.READY; } else if (SimCard.INTENT_VALUE_SIM_LOCKED.equals(stateExtra)) { String stateExtra = intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE); if (IccCard.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) { this.simState = IccCard.State.ABSENT; } else if (IccCard.INTENT_VALUE_ICC_READY.equals(stateExtra)) { this.simState = IccCard.State.READY; } else if (IccCard.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) { final String lockedReason = intent .getStringExtra(SimCard.INTENT_KEY_LOCKED_REASON); if (SimCard.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) { this.simState = SimCard.State.PIN_REQUIRED; } else if (SimCard.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) { this.simState = SimCard.State.PUK_REQUIRED; .getStringExtra(IccCard.INTENT_KEY_LOCKED_REASON); if (IccCard.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) { this.simState = IccCard.State.PIN_REQUIRED; } else if (IccCard.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) { this.simState = IccCard.State.PUK_REQUIRED; } else { this.simState = SimCard.State.UNKNOWN; this.simState = IccCard.State.UNKNOWN; } } else if (SimCard.INTENT_VALUE_LOCKED_NETWORK.equals(stateExtra)) { this.simState = SimCard.State.NETWORK_LOCKED; } else if (IccCard.INTENT_VALUE_LOCKED_NETWORK.equals(stateExtra)) { this.simState = IccCard.State.NETWORK_LOCKED; } else { this.simState = SimCard.State.UNKNOWN; this.simState = IccCard.State.UNKNOWN; } } Loading Loading @@ -195,7 +198,7 @@ public class KeyguardUpdateMonitor { mKeyboardOpen = queryKeyboardOpen(); // take a guess to start mSimState = SimCard.State.READY; mSimState = IccCard.State.READY; mDevicePluggedIn = true; mBatteryLevel = 100; Loading Loading @@ -297,7 +300,7 @@ public class KeyguardUpdateMonitor { if (batteryLevel == 0 && pluggedInStatus != BATTERY_STATUS_CHARGING && pluggedInStatus != BATTERY_STATUS_UNKNOWN) { ShutdownThread.shutdownAfterDisablingRadio(mContext, false); ShutdownThread.shutdown(mContext, false); } } Loading @@ -317,14 +320,14 @@ public class KeyguardUpdateMonitor { * Handle {@link #MSG_SIM_STATE_CHANGE} */ private void handleSimStateChange(SimArgs simArgs) { final SimCard.State state = simArgs.simState; final IccCard.State state = simArgs.simState; if (DEBUG) { Log.d(TAG, "handleSimStateChange: intentValue = " + simArgs + " " + "state resolved to " + state.toString()); } if (state != SimCard.State.UNKNOWN && state != mSimState) { if (state != IccCard.State.UNKNOWN && state != mSimState) { mSimState = state; for (int i = 0; i < mSimStateCallbacks.size(); i++) { mSimStateCallbacks.get(i).onSimStateChanged(state); Loading Loading @@ -461,7 +464,7 @@ public class KeyguardUpdateMonitor { * Callback to notify of sim state change. */ interface SimStateCallback { void onSimStateChanged(SimCard.State simState); void onSimStateChanged(IccCard.State simState); } /** Loading Loading @@ -489,7 +492,7 @@ public class KeyguardUpdateMonitor { mSimStateCallbacks.add(callback); } public SimCard.State getSimState() { public IccCard.State getSimState() { return mSimState; } Loading @@ -499,7 +502,7 @@ public class KeyguardUpdateMonitor { * broadcast from the telephony code. */ public void reportSimPinUnlocked() { mSimState = SimCard.State.READY; mSimState = IccCard.State.READY; } public boolean isInPortrait() { Loading
policy/com/android/internal/policy/impl/KeyguardViewBase.java +2 −2 Original line number Diff line number Diff line Loading @@ -132,8 +132,8 @@ public abstract class KeyguardViewBase extends FrameLayout { } /** * Allows the media keys to work when the keygaurd is showing. * The media keys should be of no interest to the actualy keygaurd view(s), * Allows the media keys to work when the keyguard is showing. * The media keys should be of no interest to the actual keyguard view(s), * so intercepting them here should not be of any harm. * @param event The key event * @return whether the event was consumed as a media key. Loading
policy/com/android/internal/policy/impl/KeyguardViewMediator.java +15 −12 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package com.android.internal.policy.impl; import com.android.internal.telephony.SimCard; import com.android.internal.telephony.IccCard; import com.android.internal.widget.LockPatternUtils; import android.app.AlarmManager; Loading @@ -41,6 +41,7 @@ import android.view.KeyEvent; import android.view.WindowManagerImpl; import android.view.WindowManagerPolicy; /** * Mediates requests related to the keyguard. This includes queries about the * state of the keyguard, power management events that effect whether the keyguard Loading Loading @@ -89,7 +90,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, private final static String TAG = "KeyguardViewMediator"; private static final String DELAYED_KEYGUARD_ACTION = "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD"; private static final String DELAYED_KEYGUARD_ACTION = "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD"; // used for handler messages private static final int TIMEOUT = 1; Loading Loading @@ -301,7 +303,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender); if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " + mDelayedShowingSequence); if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " + mDelayedShowingSequence); } else { doKeyguard(); } Loading Loading @@ -461,8 +464,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, // if the setup wizard hasn't run yet, don't show final boolean provisioned = mUpdateMonitor.isDeviceProvisioned(); final SimCard.State state = mUpdateMonitor.getSimState(); final boolean lockedOrMissing = state.isPinLocked() || (state == SimCard.State.ABSENT); final IccCard.State state = mUpdateMonitor.getSimState(); final boolean lockedOrMissing = state.isPinLocked() || (state == IccCard.State.ABSENT); if (!lockedOrMissing && !provisioned) { if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned" + " and the sim is not locked or missing"); Loading Loading @@ -576,7 +579,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } /** {@inheritDoc} */ public void onSimStateChanged(SimCard.State simState) { public void onSimStateChanged(IccCard.State simState) { if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState); switch (simState) { Loading @@ -585,7 +588,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, // gone through setup wizard if (!mUpdateMonitor.isDeviceProvisioned()) { if (!isShowing()) { if (DEBUG) Log.d(TAG, "INTENT_VALUE_SIM_ABSENT and keygaurd isn't showing, we need " if (DEBUG) Log.d(TAG, "INTENT_VALUE_ICC_ABSENT and keygaurd isn't showing, we need " + "to show the keyguard since the device isn't provisioned yet."); doKeyguard(); } else { Loading @@ -596,7 +599,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, case PIN_REQUIRED: case PUK_REQUIRED: if (!isShowing()) { if (DEBUG) Log.d(TAG, "INTENT_VALUE_SIM_LOCKED and keygaurd isn't showing, we need " if (DEBUG) Log.d(TAG, "INTENT_VALUE_ICC_LOCKED and keygaurd isn't showing, we need " + "to show the keyguard so the user can enter their sim pin"); doKeyguard(); } else { Loading Loading @@ -759,10 +762,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, */ private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { public void handleMessage(Message msg) { switch (msg.what) { case TIMEOUT: handleTimeout(msg.arg1); return ; Loading Loading @@ -947,3 +948,5 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } } }
policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +17 −13 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ import android.content.ServiceConnection; import android.os.IBinder; import android.os.RemoteException; import android.os.SystemProperties; import com.android.internal.telephony.SimCard; import com.android.internal.telephony.IccCard; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; Loading Loading @@ -142,7 +142,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { private boolean stuckOnLockScreenBecauseSimMissing() { return mRequiresSim && (!mUpdateMonitor.isDeviceProvisioned()) && (mUpdateMonitor.getSimState() == SimCard.State.ABSENT); && (mUpdateMonitor.getSimState() == IccCard.State.ABSENT); } /** Loading Loading @@ -184,9 +184,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase { } public void goToUnlockScreen() { final SimCard.State simState = mUpdateMonitor.getSimState(); final IccCard.State simState = mUpdateMonitor.getSimState(); if (stuckOnLockScreenBecauseSimMissing() || (simState == SimCard.State.PUK_REQUIRED)){ || (simState == IccCard.State.PUK_REQUIRED)){ // stuck on lock screen when sim missing or puk'd return; } Loading Loading @@ -365,7 +365,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { public void wakeWhenReadyTq(int keyCode) { if (DEBUG) Log.d(TAG, "onWakeKey"); if (keyCode == KeyEvent.KEYCODE_MENU && isSecure() && (mMode == Mode.LockScreen) && (mUpdateMonitor.getSimState() != SimCard.State.PUK_REQUIRED)) { && (mUpdateMonitor.getSimState() != IccCard.State.PUK_REQUIRED)) { if (DEBUG) Log.d(TAG, "switching screens to unlock screen because wake key was MENU"); updateScreen(Mode.UnlockScreen); getCallback().pokeWakelock(); Loading Loading @@ -403,8 +403,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase { if (unlockMode == UnlockMode.Pattern) { return mLockPatternUtils.isLockPatternEnabled(); } else if (unlockMode == UnlockMode.SimPin) { return mUpdateMonitor.getSimState() == SimCard.State.PIN_REQUIRED || mUpdateMonitor.getSimState() == SimCard.State.PUK_REQUIRED; return mUpdateMonitor.getSimState() == IccCard.State.PIN_REQUIRED || mUpdateMonitor.getSimState() == IccCard.State.PUK_REQUIRED; } else if (unlockMode == UnlockMode.Account) { return true; } else { Loading Loading @@ -522,8 +522,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase { * the lock screen (lock or unlock). */ private Mode getInitialMode() { final SimCard.State simState = mUpdateMonitor.getSimState(); if (stuckOnLockScreenBecauseSimMissing() || (simState == SimCard.State.PUK_REQUIRED)) { final IccCard.State simState = mUpdateMonitor.getSimState(); if (stuckOnLockScreenBecauseSimMissing() || (simState == IccCard.State.PUK_REQUIRED)) { return Mode.LockScreen; } else if (mUpdateMonitor.isKeyboardOpen() && isSecure()) { return Mode.UnlockScreen; Loading @@ -536,8 +536,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase { * Given the current state of things, what should the unlock screen be? */ private UnlockMode getUnlockMode() { final SimCard.State simState = mUpdateMonitor.getSimState(); if (simState == SimCard.State.PIN_REQUIRED || simState == SimCard.State.PUK_REQUIRED) { final IccCard.State simState = mUpdateMonitor.getSimState(); if (simState == IccCard.State.PIN_REQUIRED || simState == IccCard.State.PUK_REQUIRED) { return UnlockMode.SimPin; } else { return mLockPatternUtils.isPermanentlyLocked() ? Loading Loading @@ -568,7 +568,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase { int timeoutInSeconds = (int) LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS / 1000; String message = mContext.getString( R.string.lockscreen_failed_attempts_almost_glogin, LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, timeoutInSeconds); final AlertDialog dialog = new AlertDialog.Builder(mContext) Loading @@ -589,9 +590,11 @@ public class LockPatternKeyguardView extends KeyguardViewBase { */ static private class FastBitmapDrawable extends Drawable { private Bitmap mBitmap; private int mOpacity; private FastBitmapDrawable(Bitmap bitmap) { mBitmap = bitmap; mOpacity = mBitmap.hasAlpha() ? PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE; } @Override Loading @@ -605,7 +608,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { @Override public int getOpacity() { return PixelFormat.TRANSLUCENT; return mOpacity; } @Override Loading Loading @@ -637,3 +640,4 @@ public class LockPatternKeyguardView extends KeyguardViewBase { } } }