Skip to content

Commit 4b09dd3

Browse files
author
Jim Miller
committed
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
1 parent d2a8df9 commit 4b09dd3

7 files changed

Lines changed: 155 additions & 67 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2012 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:interpolator="@interpolator/decelerate_quad"
19+
android:fromAlpha="0.0" android:toAlpha="1.0"
20+
android:duration="@integer/kg_security_fade_duration" />
21+
22+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2012 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<alpha xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@interpolator/accelerate_quad"
17+
android:fromAlpha="1.0"
18+
android:toAlpha="0.0"
19+
android:duration="@integer/kg_security_fade_duration"
20+
/>

core/res/res/values/integers.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
-->
1919
<resources>
2020
<integer name="kg_security_flip_duration">150</integer>
21+
<integer name="kg_security_fade_duration">150</integer>
2122
</resources>

core/res/res/values/public.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,8 @@
12111211
<java-symbol type="anim" name="dock_right_exit" />
12121212
<java-symbol type="anim" name="keyguard_security_animate_in" />
12131213
<java-symbol type="anim" name="keyguard_security_animate_out" />
1214+
<java-symbol type="anim" name="keyguard_security_fade_in" />
1215+
<java-symbol type="anim" name="keyguard_security_fade_out" />
12141216
<java-symbol type="array" name="config_keyboardTapVibePattern" />
12151217
<java-symbol type="array" name="config_longPressVibePattern" />
12161218
<java-symbol type="array" name="config_safeModeDisabledVibePattern" />

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ protected void onFinishInflate() {
130130

131131
// View Flipper
132132
mViewFlipper = (ViewFlipper) findViewById(R.id.view_flipper);
133-
mViewFlipper.setInAnimation(AnimationUtils.loadAnimation(mContext,
134-
R.anim.keyguard_security_animate_in));
135-
mViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(mContext,
136-
R.anim.keyguard_security_animate_out));
137133

138134
// Initialize all security views
139135
for (int i = 0; i < mViewIds.length; i++) {
@@ -381,11 +377,28 @@ private void showNextSecurityScreenOrFinish(boolean authenticated) {
381377
showSecurityScreen(realSecurityId); // switch to the "real" security view
382378
}
383379
} else if (authenticated) {
384-
if (mCurrentSecurityId == SECURITY_PATTERN_ID
385-
|| mCurrentSecurityId == SECURITY_PASSWORD_ID
386-
|| mCurrentSecurityId == SECURITY_ACCOUNT_ID
387-
|| mCurrentSecurityId == SECURITY_BIOMETRIC_ID) {
388-
finish = true;
380+
switch (mCurrentSecurityId) {
381+
case SECURITY_PATTERN_ID:
382+
case SECURITY_PASSWORD_ID:
383+
case SECURITY_ACCOUNT_ID:
384+
case SECURITY_BIOMETRIC_ID:
385+
finish = true;
386+
break;
387+
388+
case SECURITY_SIM_PIN_ID:
389+
case SECURITY_SIM_PUK_ID:
390+
// Shortcut for SIM PIN/PUK to go to directly to user's security screen or home
391+
SecurityMode securityMode = mSecurityModel.getSecurityMode();
392+
if (securityMode != SecurityMode.None) {
393+
showSecurityScreen(getSecurityViewIdForMode(securityMode));
394+
} else {
395+
finish = true;
396+
}
397+
break;
398+
399+
default:
400+
showSecurityScreen(SECURITY_SELECTOR_ID);
401+
break;
389402
}
390403
} else {
391404
// Not authenticated but we were asked to dismiss so go back to selector screen.
@@ -480,10 +493,20 @@ private void showSecurityScreen(int securityViewId) {
480493
newView.onResume();
481494

482495
mViewMediatorCallback.setNeedsInput(newView.needsInput());
483-
mCurrentSecurityId = securityViewId;
484496

485497
// Find and show this child.
486498
final int childCount = mViewFlipper.getChildCount();
499+
500+
// If we're go to/from the selector view, do flip animation, otherwise use fade animation.
501+
final boolean doFlip = mCurrentSecurityId == SECURITY_SELECTOR_ID
502+
|| securityViewId == SECURITY_SELECTOR_ID;
503+
final int inAnimation = doFlip ? R.anim.keyguard_security_animate_in
504+
: R.anim.keyguard_security_fade_in;
505+
final int outAnimation = doFlip ? R.anim.keyguard_security_animate_out
506+
: R.anim.keyguard_security_fade_out;
507+
508+
mViewFlipper.setInAnimation(AnimationUtils.loadAnimation(mContext, inAnimation));
509+
mViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(mContext, outAnimation));
487510
for (int i = 0; i < childCount; i++) {
488511
if (securityViewId == mViewFlipper.getChildAt(i).getId()) {
489512
mViewFlipper.setDisplayedChild(i);
@@ -495,6 +518,8 @@ private void showSecurityScreen(int securityViewId) {
495518
if (securityViewId == SECURITY_SELECTOR_ID) {
496519
setOnDismissRunnable(null);
497520
}
521+
522+
mCurrentSecurityId = securityViewId;
498523
}
499524

500525
@Override

policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import android.util.AttributeSet;
3434
import android.view.KeyEvent;
35+
import android.view.MotionEvent;
3536
import android.view.View;
3637
import android.view.WindowManager;
3738
import android.view.inputmethod.EditorInfo;
@@ -56,6 +57,8 @@ public class KeyguardSimPinView extends LinearLayout
5657
private LockPatternUtils mLockPatternUtils;
5758
private KeyguardNavigationManager mNavigationManager;
5859

60+
private volatile boolean mSimCheckInProgress;
61+
5962
public KeyguardSimPinView(Context context) {
6063
this(context, null);
6164
}
@@ -131,7 +134,7 @@ protected CheckSimPin(String pin) {
131134
mPin = pin;
132135
}
133136

134-
abstract void onSimLockChangedResponse(boolean success);
137+
abstract void onSimCheckResponse(boolean success);
135138

136139
@Override
137140
public void run() {
@@ -140,13 +143,13 @@ public void run() {
140143
.checkService("phone")).supplyPin(mPin);
141144
post(new Runnable() {
142145
public void run() {
143-
onSimLockChangedResponse(result);
146+
onSimCheckResponse(result);
144147
}
145148
});
146149
} catch (RemoteException e) {
147150
post(new Runnable() {
148151
public void run() {
149-
onSimLockChangedResponse(false);
152+
onSimCheckResponse(false);
150153
}
151154
});
152155
}
@@ -156,8 +159,10 @@ public void run() {
156159
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
157160
// Check if this was the result of hitting the enter key
158161
mCallback.userActivity(DIGIT_PRESS_WAKE_MILLIS);
159-
if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE
160-
|| actionId == EditorInfo.IME_ACTION_NEXT) {
162+
if (event.getAction() == MotionEvent.ACTION_DOWN && (
163+
actionId == EditorInfo.IME_NULL
164+
|| actionId == EditorInfo.IME_ACTION_DONE
165+
|| actionId == EditorInfo.IME_ACTION_NEXT)) {
161166
checkPin();
162167
return true;
163168
}
@@ -190,27 +195,31 @@ private void checkPin() {
190195

191196
getSimUnlockProgressDialog().show();
192197

193-
new CheckSimPin(mPinEntry.getText().toString()) {
194-
void onSimLockChangedResponse(final boolean success) {
195-
post(new Runnable() {
196-
public void run() {
197-
if (mSimUnlockProgressDialog != null) {
198-
mSimUnlockProgressDialog.hide();
198+
if (!mSimCheckInProgress) {
199+
mSimCheckInProgress = true; // there should be only one
200+
new CheckSimPin(mPinEntry.getText().toString()) {
201+
void onSimCheckResponse(final boolean success) {
202+
post(new Runnable() {
203+
public void run() {
204+
if (mSimUnlockProgressDialog != null) {
205+
mSimUnlockProgressDialog.hide();
206+
}
207+
if (success) {
208+
// before closing the keyguard, report back that the sim is unlocked
209+
// so it knows right away.
210+
KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked();
211+
mCallback.dismiss(true);
212+
} else {
213+
mNavigationManager.setMessage(R.string.kg_password_wrong_pin_code);
214+
mPinEntry.setText("");
215+
}
216+
mCallback.userActivity(0);
217+
mSimCheckInProgress = false;
199218
}
200-
if (success) {
201-
// before closing the keyguard, report back that the sim is unlocked
202-
// so it knows right away.
203-
KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked();
204-
mCallback.dismiss(false); //
205-
} else {
206-
mNavigationManager.setMessage(R.string.kg_password_wrong_pin_code);
207-
mPinEntry.setText("");
208-
}
209-
mCallback.userActivity(0);
210-
}
211-
});
212-
}
213-
}.start();
219+
});
220+
}
221+
}.start();
222+
}
214223
}
215224

216225
public void setLockPatternUtils(LockPatternUtils utils) {

policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.util.AttributeSet;
2828
import android.util.Log;
2929
import android.view.KeyEvent;
30+
import android.view.MotionEvent;
3031
import android.view.View;
3132
import android.view.WindowManager;
3233
import android.view.inputmethod.EditorInfo;
@@ -63,6 +64,8 @@ public class KeyguardSimPukView extends LinearLayout implements View.OnClickList
6364

6465
private LockPatternUtils mLockPatternUtils;
6566

67+
private volatile boolean mCheckInProgress;
68+
6669
public KeyguardSimPukView(Context context) {
6770
this(context, null);
6871
}
@@ -233,48 +236,54 @@ private void checkPuk() {
233236

234237
getSimUnlockProgressDialog().show();
235238

236-
new CheckSimPuk(mPukText.getText().toString(),
237-
mPinText.getText().toString()) {
238-
void onSimLockChangedResponse(final boolean success) {
239-
mPinText.post(new Runnable() {
240-
public void run() {
241-
if (mSimUnlockProgressDialog != null) {
242-
mSimUnlockProgressDialog.hide();
243-
}
244-
if (success) {
245-
mCallback.dismiss(true);
246-
} else {
247-
mNavigationManager.setMessage(R.string.kg_invalid_puk);
248-
mPukText.setText("");
249-
mPinText.setText("");
239+
if (!mCheckInProgress) {
240+
mCheckInProgress = true;
241+
new CheckSimPuk(mPukText.getText().toString(),
242+
mPinText.getText().toString()) {
243+
void onSimLockChangedResponse(final boolean success) {
244+
mPinText.post(new Runnable() {
245+
public void run() {
246+
if (mSimUnlockProgressDialog != null) {
247+
mSimUnlockProgressDialog.hide();
248+
}
249+
if (success) {
250+
mCallback.dismiss(true);
251+
} else {
252+
mNavigationManager.setMessage(R.string.kg_invalid_puk);
253+
mPukText.setText("");
254+
mPinText.setText("");
255+
}
256+
mCheckInProgress = false;
250257
}
251-
}
252-
});
253-
}
254-
}.start();
258+
});
259+
}
260+
}.start();
261+
}
255262
}
256263

257264
@Override
258265
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
259266
// Check if this was the result of hitting the enter key
260267
mCallback.userActivity(DIGIT_PRESS_WAKE_MILLIS);
261-
if (actionId == EditorInfo.IME_NULL
268+
if (event.getAction() == MotionEvent.ACTION_DOWN) {
269+
if (actionId == EditorInfo.IME_NULL
262270
|| actionId == EditorInfo.IME_ACTION_DONE
263271
|| actionId == EditorInfo.IME_ACTION_NEXT) {
264-
if (view == mPukText && mPukText.getText().length() < 8) {
265-
mNavigationManager.setMessage(R.string.kg_invalid_sim_puk_hint);
266-
mPukText.setText("");
267-
mPukText.requestFocus();
268-
return true;
269-
} else if (view == mPinText) {
270-
if (mPinText.getText().length() < 4 || mPinText.getText().length() > 8) {
271-
mNavigationManager.setMessage(R.string.kg_invalid_sim_pin_hint);
272-
mPinText.setText("");
273-
mPinText.requestFocus();
274-
} else {
275-
checkPuk();
272+
if (view == mPukText && mPukText.getText().length() < 8) {
273+
mNavigationManager.setMessage(R.string.kg_invalid_sim_puk_hint);
274+
mPukText.setText("");
275+
mPukText.requestFocus();
276+
return true;
277+
} else if (view == mPinText) {
278+
if (mPinText.getText().length() < 4 || mPinText.getText().length() > 8) {
279+
mNavigationManager.setMessage(R.string.kg_invalid_sim_pin_hint);
280+
mPinText.setText("");
281+
mPinText.requestFocus();
282+
} else {
283+
checkPuk();
284+
}
285+
return true;
276286
}
277-
return true;
278287
}
279288
}
280289
return false;

0 commit comments

Comments
 (0)