3232
3333import android .util .AttributeSet ;
3434import android .view .KeyEvent ;
35+ import android .view .MotionEvent ;
3536import android .view .View ;
3637import android .view .WindowManager ;
3738import 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 }
@@ -129,7 +132,7 @@ protected CheckSimPin(String pin) {
129132 mPin = pin ;
130133 }
131134
132- abstract void onSimLockChangedResponse (boolean success );
135+ abstract void onSimCheckResponse (boolean success );
133136
134137 @ Override
135138 public void run () {
@@ -138,13 +141,13 @@ public void run() {
138141 .checkService ("phone" )).supplyPin (mPin );
139142 post (new Runnable () {
140143 public void run () {
141- onSimLockChangedResponse (result );
144+ onSimCheckResponse (result );
142145 }
143146 });
144147 } catch (RemoteException e ) {
145148 post (new Runnable () {
146149 public void run () {
147- onSimLockChangedResponse (false );
150+ onSimCheckResponse (false );
148151 }
149152 });
150153 }
@@ -154,8 +157,10 @@ public void run() {
154157 public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
155158 // Check if this was the result of hitting the enter key
156159 mCallback .userActivity (DIGIT_PRESS_WAKE_MILLIS );
157- if (actionId == EditorInfo .IME_NULL || actionId == EditorInfo .IME_ACTION_DONE
158- || actionId == EditorInfo .IME_ACTION_NEXT ) {
160+ if (event .getAction () == MotionEvent .ACTION_DOWN && (
161+ actionId == EditorInfo .IME_NULL
162+ || actionId == EditorInfo .IME_ACTION_DONE
163+ || actionId == EditorInfo .IME_ACTION_NEXT )) {
159164 checkPin ();
160165 return true ;
161166 }
@@ -188,27 +193,31 @@ private void checkPin() {
188193
189194 getSimUnlockProgressDialog ().show ();
190195
191- new CheckSimPin (mPinEntry .getText ().toString ()) {
192- void onSimLockChangedResponse (final boolean success ) {
193- post (new Runnable () {
194- public void run () {
195- if (mSimUnlockProgressDialog != null ) {
196- mSimUnlockProgressDialog .hide ();
196+ if (!mSimCheckInProgress ) {
197+ mSimCheckInProgress = true ; // there should be only one
198+ new CheckSimPin (mPinEntry .getText ().toString ()) {
199+ void onSimCheckResponse (final boolean success ) {
200+ post (new Runnable () {
201+ public void run () {
202+ if (mSimUnlockProgressDialog != null ) {
203+ mSimUnlockProgressDialog .hide ();
204+ }
205+ if (success ) {
206+ // before closing the keyguard, report back that the sim is unlocked
207+ // so it knows right away.
208+ KeyguardUpdateMonitor .getInstance (getContext ()).reportSimUnlocked ();
209+ mCallback .dismiss (true );
210+ } else {
211+ mNavigationManager .setMessage (R .string .kg_password_wrong_pin_code );
212+ mPinEntry .setText ("" );
213+ }
214+ mCallback .userActivity (0 );
215+ mSimCheckInProgress = false ;
197216 }
198- if (success ) {
199- // before closing the keyguard, report back that the sim is unlocked
200- // so it knows right away.
201- KeyguardUpdateMonitor .getInstance (getContext ()).reportSimUnlocked ();
202- mCallback .dismiss (false ); //
203- } else {
204- mNavigationManager .setMessage (R .string .kg_password_wrong_pin_code );
205- mPinEntry .setText ("" );
206- }
207- mCallback .userActivity (0 );
208- }
209- });
210- }
211- }.start ();
217+ });
218+ }
219+ }.start ();
220+ }
212221 }
213222
214223 public void setLockPatternUtils (LockPatternUtils utils ) {
0 commit comments