Better flow for SIM PIN/ SIM PUK screens in keyguard.

We now fade between security screens when not coming from selection view.
In the case of SIM PIN/PUK screens, this means we show the user's security
screen without going back to the selector view.

This change also adds a fade animation for when we go between security screens
without going back to the selector view.

This also fixes a bug where we were invoking two checks for the SIM
state - one for ACTION_DOWN and another for ACTION_UP.

Change-Id: I260f9a2e0316cbf26ec7621f774bfdf9956ca488
This commit is contained in:
Jim Miller
2012-09-04 14:27:25 -07:00
parent d2a8df9541
commit 4b09dd31fb
7 changed files with 155 additions and 67 deletions

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@interpolator/decelerate_quad"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@integer/kg_security_fade_duration" />

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<alpha xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@interpolator/accelerate_quad"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:duration="@integer/kg_security_fade_duration"
/>

View File

@@ -18,4 +18,5 @@
-->
<resources>
<integer name="kg_security_flip_duration">150</integer>
<integer name="kg_security_fade_duration">150</integer>
</resources>

View File

@@ -1211,6 +1211,8 @@
<java-symbol type="anim" name="dock_right_exit" />
<java-symbol type="anim" name="keyguard_security_animate_in" />
<java-symbol type="anim" name="keyguard_security_animate_out" />
<java-symbol type="anim" name="keyguard_security_fade_in" />
<java-symbol type="anim" name="keyguard_security_fade_out" />
<java-symbol type="array" name="config_keyboardTapVibePattern" />
<java-symbol type="array" name="config_longPressVibePattern" />
<java-symbol type="array" name="config_safeModeDisabledVibePattern" />

View File

@@ -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

View File

@@ -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) {

View File

@@ -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;