diff --git a/core/res/res/anim/keyguard_security_fade_in.xml b/core/res/res/anim/keyguard_security_fade_in.xml new file mode 100644 index 0000000000000..7d5516ad4703c --- /dev/null +++ b/core/res/res/anim/keyguard_security_fade_in.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/core/res/res/anim/keyguard_security_fade_out.xml b/core/res/res/anim/keyguard_security_fade_out.xml new file mode 100644 index 0000000000000..caf896e0f30ee --- /dev/null +++ b/core/res/res/anim/keyguard_security_fade_out.xml @@ -0,0 +1,20 @@ + + + diff --git a/core/res/res/values/integers.xml b/core/res/res/values/integers.xml index 859eefcf83c57..7834997c6c29b 100644 --- a/core/res/res/values/integers.xml +++ b/core/res/res/values/integers.xml @@ -18,4 +18,5 @@ --> 150 + 150 diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 8e0eb155056fb..2430ae9b92c61 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1211,6 +1211,8 @@ + + diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java index 2551c04e271fc..f6f5dc6be25dc 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java @@ -130,10 +130,6 @@ public class KeyguardHostView extends KeyguardViewBase { // View Flipper mViewFlipper = (ViewFlipper) findViewById(R.id.view_flipper); - mViewFlipper.setInAnimation(AnimationUtils.loadAnimation(mContext, - R.anim.keyguard_security_animate_in)); - mViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(mContext, - R.anim.keyguard_security_animate_out)); // Initialize all security views for (int i = 0; i < mViewIds.length; i++) { @@ -381,11 +377,28 @@ public class KeyguardHostView extends KeyguardViewBase { showSecurityScreen(realSecurityId); // switch to the "real" security view } } else if (authenticated) { - if (mCurrentSecurityId == SECURITY_PATTERN_ID - || mCurrentSecurityId == SECURITY_PASSWORD_ID - || mCurrentSecurityId == SECURITY_ACCOUNT_ID - || mCurrentSecurityId == SECURITY_BIOMETRIC_ID) { - finish = true; + switch (mCurrentSecurityId) { + case SECURITY_PATTERN_ID: + case SECURITY_PASSWORD_ID: + case SECURITY_ACCOUNT_ID: + case SECURITY_BIOMETRIC_ID: + finish = true; + break; + + case SECURITY_SIM_PIN_ID: + case SECURITY_SIM_PUK_ID: + // Shortcut for SIM PIN/PUK to go to directly to user's security screen or home + SecurityMode securityMode = mSecurityModel.getSecurityMode(); + if (securityMode != SecurityMode.None) { + showSecurityScreen(getSecurityViewIdForMode(securityMode)); + } else { + finish = true; + } + break; + + default: + showSecurityScreen(SECURITY_SELECTOR_ID); + break; } } else { // Not authenticated but we were asked to dismiss so go back to selector screen. @@ -480,10 +493,20 @@ public class KeyguardHostView extends KeyguardViewBase { newView.onResume(); mViewMediatorCallback.setNeedsInput(newView.needsInput()); - mCurrentSecurityId = securityViewId; // Find and show this child. final int childCount = mViewFlipper.getChildCount(); + + // If we're go to/from the selector view, do flip animation, otherwise use fade animation. + final boolean doFlip = mCurrentSecurityId == SECURITY_SELECTOR_ID + || securityViewId == SECURITY_SELECTOR_ID; + final int inAnimation = doFlip ? R.anim.keyguard_security_animate_in + : R.anim.keyguard_security_fade_in; + final int outAnimation = doFlip ? R.anim.keyguard_security_animate_out + : R.anim.keyguard_security_fade_out; + + mViewFlipper.setInAnimation(AnimationUtils.loadAnimation(mContext, inAnimation)); + mViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(mContext, outAnimation)); for (int i = 0; i < childCount; i++) { if (securityViewId == mViewFlipper.getChildAt(i).getId()) { mViewFlipper.setDisplayedChild(i); @@ -495,6 +518,8 @@ public class KeyguardHostView extends KeyguardViewBase { if (securityViewId == SECURITY_SELECTOR_ID) { setOnDismissRunnable(null); } + + mCurrentSecurityId = securityViewId; } @Override diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java index 294ea5ca8fe5a..ad81f3beff544 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java @@ -32,6 +32,7 @@ import com.android.internal.R; import android.util.AttributeSet; import android.view.KeyEvent; +import android.view.MotionEvent; import android.view.View; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; @@ -56,6 +57,8 @@ public class KeyguardSimPinView extends LinearLayout private LockPatternUtils mLockPatternUtils; private KeyguardNavigationManager mNavigationManager; + private volatile boolean mSimCheckInProgress; + public KeyguardSimPinView(Context context) { this(context, null); } @@ -131,7 +134,7 @@ public class KeyguardSimPinView extends LinearLayout mPin = pin; } - abstract void onSimLockChangedResponse(boolean success); + abstract void onSimCheckResponse(boolean success); @Override public void run() { @@ -140,13 +143,13 @@ public class KeyguardSimPinView extends LinearLayout .checkService("phone")).supplyPin(mPin); post(new Runnable() { public void run() { - onSimLockChangedResponse(result); + onSimCheckResponse(result); } }); } catch (RemoteException e) { post(new Runnable() { public void run() { - onSimLockChangedResponse(false); + onSimCheckResponse(false); } }); } @@ -156,8 +159,10 @@ public class KeyguardSimPinView extends LinearLayout public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // Check if this was the result of hitting the enter key mCallback.userActivity(DIGIT_PRESS_WAKE_MILLIS); - if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE - || actionId == EditorInfo.IME_ACTION_NEXT) { + if (event.getAction() == MotionEvent.ACTION_DOWN && ( + actionId == EditorInfo.IME_NULL + || actionId == EditorInfo.IME_ACTION_DONE + || actionId == EditorInfo.IME_ACTION_NEXT)) { checkPin(); return true; } @@ -190,27 +195,31 @@ public class KeyguardSimPinView extends LinearLayout getSimUnlockProgressDialog().show(); - new CheckSimPin(mPinEntry.getText().toString()) { - void onSimLockChangedResponse(final boolean success) { - post(new Runnable() { - public void run() { - if (mSimUnlockProgressDialog != null) { - mSimUnlockProgressDialog.hide(); + if (!mSimCheckInProgress) { + mSimCheckInProgress = true; // there should be only one + new CheckSimPin(mPinEntry.getText().toString()) { + void onSimCheckResponse(final boolean success) { + post(new Runnable() { + public void run() { + if (mSimUnlockProgressDialog != null) { + mSimUnlockProgressDialog.hide(); + } + if (success) { + // before closing the keyguard, report back that the sim is unlocked + // so it knows right away. + KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked(); + mCallback.dismiss(true); + } else { + mNavigationManager.setMessage(R.string.kg_password_wrong_pin_code); + mPinEntry.setText(""); + } + mCallback.userActivity(0); + mSimCheckInProgress = false; } - if (success) { - // before closing the keyguard, report back that the sim is unlocked - // so it knows right away. - KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked(); - mCallback.dismiss(false); // - } else { - mNavigationManager.setMessage(R.string.kg_password_wrong_pin_code); - mPinEntry.setText(""); - } - mCallback.userActivity(0); - } - }); - } - }.start(); + }); + } + }.start(); + } } public void setLockPatternUtils(LockPatternUtils utils) { diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java index 801dfc3a3b26f..e04bff9759011 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java @@ -27,6 +27,7 @@ import android.text.Editable; import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; +import android.view.MotionEvent; import android.view.View; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; @@ -63,6 +64,8 @@ public class KeyguardSimPukView extends LinearLayout implements View.OnClickList private LockPatternUtils mLockPatternUtils; + private volatile boolean mCheckInProgress; + public KeyguardSimPukView(Context context) { this(context, null); } @@ -233,48 +236,54 @@ public class KeyguardSimPukView extends LinearLayout implements View.OnClickList getSimUnlockProgressDialog().show(); - new CheckSimPuk(mPukText.getText().toString(), - mPinText.getText().toString()) { - void onSimLockChangedResponse(final boolean success) { - mPinText.post(new Runnable() { - public void run() { - if (mSimUnlockProgressDialog != null) { - mSimUnlockProgressDialog.hide(); + if (!mCheckInProgress) { + mCheckInProgress = true; + new CheckSimPuk(mPukText.getText().toString(), + mPinText.getText().toString()) { + void onSimLockChangedResponse(final boolean success) { + mPinText.post(new Runnable() { + public void run() { + if (mSimUnlockProgressDialog != null) { + mSimUnlockProgressDialog.hide(); + } + if (success) { + mCallback.dismiss(true); + } else { + mNavigationManager.setMessage(R.string.kg_invalid_puk); + mPukText.setText(""); + mPinText.setText(""); + } + mCheckInProgress = false; } - if (success) { - mCallback.dismiss(true); - } else { - mNavigationManager.setMessage(R.string.kg_invalid_puk); - mPukText.setText(""); - mPinText.setText(""); - } - } - }); - } - }.start(); + }); + } + }.start(); + } } @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { // Check if this was the result of hitting the enter key mCallback.userActivity(DIGIT_PRESS_WAKE_MILLIS); - if (actionId == EditorInfo.IME_NULL + if (event.getAction() == MotionEvent.ACTION_DOWN) { + if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT) { - if (view == mPukText && mPukText.getText().length() < 8) { - mNavigationManager.setMessage(R.string.kg_invalid_sim_puk_hint); - mPukText.setText(""); - mPukText.requestFocus(); - return true; - } else if (view == mPinText) { - if (mPinText.getText().length() < 4 || mPinText.getText().length() > 8) { - mNavigationManager.setMessage(R.string.kg_invalid_sim_pin_hint); - mPinText.setText(""); - mPinText.requestFocus(); - } else { - checkPuk(); + if (view == mPukText && mPukText.getText().length() < 8) { + mNavigationManager.setMessage(R.string.kg_invalid_sim_puk_hint); + mPukText.setText(""); + mPukText.requestFocus(); + return true; + } else if (view == mPinText) { + if (mPinText.getText().length() < 4 || mPinText.getText().length() > 8) { + mNavigationManager.setMessage(R.string.kg_invalid_sim_pin_hint); + mPinText.setText(""); + mPinText.requestFocus(); + } else { + checkPuk(); + } + return true; } - return true; } } return false;