blob: 876d170e08cdd391fa6480855617fca81596bedd [file] [log] [blame]
Jim Millerdcb3d842012-08-23 19:18:12 -07001/*
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 */
Jim Millerdcb3d842012-08-23 19:18:12 -070016
Jim Miller5ecd8112013-01-09 18:50:26 -080017package com.android.keyguard;
18
Jim Miller5ecd8112013-01-09 18:50:26 -080019import android.content.Context;
Jorim Jaggid05064b2014-11-20 21:35:33 +010020import android.content.res.ColorStateList;
Jim Miller52a61332014-11-12 19:29:51 -080021import android.content.res.Resources;
Jim Millerdcb3d842012-08-23 19:18:12 -070022import android.app.Activity;
Wink Savilleb896b9f2013-10-23 15:44:26 -070023import android.app.AlertDialog;
Jim Millerdcb3d842012-08-23 19:18:12 -070024import android.app.Dialog;
25import android.app.ProgressDialog;
Jorim Jaggid05064b2014-11-20 21:35:33 +010026import android.graphics.Color;
Jim Millerdcb3d842012-08-23 19:18:12 -070027import android.os.RemoteException;
28import android.os.ServiceManager;
Jim Miller52a61332014-11-12 19:29:51 -080029import android.telephony.SubscriptionInfo;
30import android.telephony.SubscriptionManager;
31import android.telephony.TelephonyManager;
qingxi3d768742017-04-12 11:07:11 -070032import android.telephony.euicc.EuiccManager;
Jim Millerdcb3d842012-08-23 19:18:12 -070033import android.util.AttributeSet;
Wink Savilleb896b9f2013-10-23 15:44:26 -070034import android.util.Log;
qingxi12f2de42017-05-24 15:33:13 -070035import android.view.View;
Jim Millerdcb3d842012-08-23 19:18:12 -070036import android.view.WindowManager;
Jorim Jaggid05064b2014-11-20 21:35:33 +010037import android.widget.ImageView;
Jim Millerdcb3d842012-08-23 19:18:12 -070038
Wink Savilleb896b9f2013-10-23 15:44:26 -070039import com.android.internal.telephony.ITelephony;
Jim Miller52a61332014-11-12 19:29:51 -080040import com.android.internal.telephony.IccCardConstants;
Wink Savilleb896b9f2013-10-23 15:44:26 -070041import com.android.internal.telephony.PhoneConstants;
Jim Miller52a61332014-11-12 19:29:51 -080042import com.android.internal.telephony.IccCardConstants.State;
Wink Savilleb896b9f2013-10-23 15:44:26 -070043
44
Daniel Sandler23d7a6e2012-11-02 00:21:07 -040045/**
46 * Displays a PIN pad for entering a PUK (Pin Unlock Kode) provided by a carrier.
47 */
Selim Cinek4e8b9ed2014-06-20 16:37:04 -070048public class KeyguardSimPukView extends KeyguardPinBasedInputView {
Wink Savilleb896b9f2013-10-23 15:44:26 -070049 private static final String LOG_TAG = "KeyguardSimPukView";
Jorim Jaggi5cf17872014-03-26 18:31:48 +010050 private static final boolean DEBUG = KeyguardConstants.DEBUG;
Jim Miller4fc2b012013-11-04 16:47:48 -080051 public static final String TAG = "KeyguardSimPukView";
Jim Millerdcb3d842012-08-23 19:18:12 -070052
53 private ProgressDialog mSimUnlockProgressDialog = null;
Jim Miller4fc2b012013-11-04 16:47:48 -080054 private CheckSimPuk mCheckSimPukThread;
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +053055
56 // Below flag is set to true during power-up or when a new SIM card inserted on device.
57 // When this is true and when SIM card is PUK locked state, on PIN lock screen, message would
58 // be displayed to inform user about the number of remaining PUK attempts left.
59 private boolean mShowDefaultMessage = true;
60 private int mRemainingAttempts = -1;
Jim Miller3efe1062012-09-28 16:59:31 -070061 private String mPukText;
Jim Miller3efe1062012-09-28 16:59:31 -070062 private String mPinText;
63 private StateMachine mStateMachine = new StateMachine();
Wink Savilleb896b9f2013-10-23 15:44:26 -070064 private AlertDialog mRemainingAttemptsDialog;
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +053065 private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
Jorim Jaggid05064b2014-11-20 21:35:33 +010066 private ImageView mSimImageView;
Jim Miller52a61332014-11-12 19:29:51 -080067
68 KeyguardUpdateMonitorCallback mUpdateMonitorCallback = new KeyguardUpdateMonitorCallback() {
69 @Override
70 public void onSimStateChanged(int subId, int slotId, State simState) {
Brad Ebinger4cd3bdc2017-08-21 14:58:52 -070071 if (DEBUG) Log.v(TAG, "onSimStateChanged(subId=" + subId + ",state=" + simState + ")");
72 switch(simState) {
73 // If the SIM is removed, then we must remove the keyguard. It will be put up
74 // again when the PUK locked SIM is re-entered.
75 case ABSENT:
76 // intentional fall-through
77 // If the SIM is unlocked via a key sequence through the emergency dialer, it will
78 // move into the READY state and the PUK lock keyguard should be removed.
79 case READY: {
80 KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked(mSubId);
Brad Ebinger71306752017-10-05 11:39:06 -070081 // mCallback can be null if onSimStateChanged callback is called when keyguard
82 // isn't active.
83 if (mCallback != null) {
84 mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser());
85 }
Brad Ebinger4cd3bdc2017-08-21 14:58:52 -070086 break;
87 }
88 default:
89 resetState();
90 }
91 }
Jim Miller52a61332014-11-12 19:29:51 -080092 };
93
94 public KeyguardSimPukView(Context context) {
95 this(context, null);
96 }
97
98 public KeyguardSimPukView(Context context, AttributeSet attrs) {
99 super(context, attrs);
100 }
Jim Miller3efe1062012-09-28 16:59:31 -0700101
102 private class StateMachine {
103 final int ENTER_PUK = 0;
104 final int ENTER_PIN = 1;
105 final int CONFIRM_PIN = 2;
106 final int DONE = 3;
107 private int state = ENTER_PUK;
108
109 public void next() {
110 int msg = 0;
111 if (state == ENTER_PUK) {
112 if (checkPuk()) {
113 state = ENTER_PIN;
114 msg = R.string.kg_puk_enter_pin_hint;
115 } else {
116 msg = R.string.kg_invalid_sim_puk_hint;
117 }
118 } else if (state == ENTER_PIN) {
119 if (checkPin()) {
120 state = CONFIRM_PIN;
121 msg = R.string.kg_enter_confirm_pin_hint;
122 } else {
123 msg = R.string.kg_invalid_sim_pin_hint;
124 }
125 } else if (state == CONFIRM_PIN) {
126 if (confirmPin()) {
127 state = DONE;
Jim Miller5ecd8112013-01-09 18:50:26 -0800128 msg = R.string.keyguard_sim_unlock_progress_dialog_message;
Jim Miller3efe1062012-09-28 16:59:31 -0700129 updateSim();
130 } else {
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400131 state = ENTER_PIN; // try again?
Jim Miller3efe1062012-09-28 16:59:31 -0700132 msg = R.string.kg_invalid_confirm_pin_hint;
133 }
134 }
Jim Miller4db942c2016-05-16 18:06:50 -0700135 resetPasswordText(true /* animate */, true /* announce */);
Jim Miller3efe1062012-09-28 16:59:31 -0700136 if (msg != 0) {
Adrian Roosdb327e92016-10-12 16:41:28 -0700137 mSecurityMessageDisplay.setMessage(msg);
Jim Miller3efe1062012-09-28 16:59:31 -0700138 }
139 }
140
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530141
Jim Miller3efe1062012-09-28 16:59:31 -0700142 void reset() {
143 mPinText="";
144 mPukText="";
145 state = ENTER_PUK;
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530146 handleSubInfoChangeIfNeeded();
147 if (mShowDefaultMessage) {
148 showDefaultMessage();
Jim Miller52a61332014-11-12 19:29:51 -0800149 }
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530150 boolean isEsimLocked = KeyguardEsimArea.isEsimLocked(mContext, mSubId);
151
qingxi12f2de42017-05-24 15:33:13 -0700152 KeyguardEsimArea esimButton = findViewById(R.id.keyguard_esim_area);
153 esimButton.setVisibility(isEsimLocked ? View.VISIBLE : View.GONE);
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400154 mPasswordEntry.requestFocus();
Jim Miller3efe1062012-09-28 16:59:31 -0700155 }
qingxi12f2de42017-05-24 15:33:13 -0700156
157
Jim Miller3efe1062012-09-28 16:59:31 -0700158 }
159
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530160 private void showDefaultMessage() {
161 if (mRemainingAttempts >= 0) {
162 mSecurityMessageDisplay.setMessage(getPukPasswordErrorMessage(
163 mRemainingAttempts, true));
164 return;
165 }
166
167 boolean isEsimLocked = KeyguardEsimArea.isEsimLocked(mContext, mSubId);
168 int count = TelephonyManager.getDefault().getSimCount();
169 Resources rez = getResources();
170 String msg;
171 int color = Color.WHITE;
172 if (count < 2) {
173 msg = rez.getString(R.string.kg_puk_enter_puk_hint);
174 } else {
175 SubscriptionInfo info = KeyguardUpdateMonitor.getInstance(mContext).
176 getSubscriptionInfoForSubId(mSubId);
177 CharSequence displayName = info != null ? info.getDisplayName() : "";
178 msg = rez.getString(R.string.kg_puk_enter_puk_hint_multi, displayName);
179 if (info != null) {
180 color = info.getIconTint();
181 }
182 }
183 if (isEsimLocked) {
184 msg = msg + " " + rez.getString(R.string.kg_sim_lock_instructions_esim);
185 }
186 mSecurityMessageDisplay.setMessage(msg);
187 mSimImageView.setImageTintList(ColorStateList.valueOf(color));
188
189 // Sending empty PUK here to query the number of remaining PIN attempts
190 new CheckSimPuk("", "", mSubId) {
191 void onSimLockChangedResponse(final int result, final int attemptsRemaining) {
192 Log.d(LOG_TAG, "onSimCheckResponse " + " dummy One result" + result +
193 " attemptsRemaining=" + attemptsRemaining);
194 if (attemptsRemaining >= 0) {
195 mRemainingAttempts = attemptsRemaining;
196 mSecurityMessageDisplay.setMessage(
197 getPukPasswordErrorMessage(attemptsRemaining, true));
198 }
199 }
200 }.start();
201 }
202
203 private void handleSubInfoChangeIfNeeded() {
204 KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
205 int subId = monitor.getNextSubIdForState(IccCardConstants.State.PUK_REQUIRED);
206 if (subId != mSubId && SubscriptionManager.isValidSubscriptionId(subId)) {
207 mSubId = subId;
208 mShowDefaultMessage = true;
209 mRemainingAttempts = -1;
210 }
211 }
212
Selim Cinek3122fa82015-06-18 01:38:59 -0700213 @Override
214 protected int getPromtReasonStringRes(int reason) {
215 // No message on SIM Puk
216 return 0;
217 }
218
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530219 private String getPukPasswordErrorMessage(int attemptsRemaining, boolean isDefault) {
Wink Savilleb896b9f2013-10-23 15:44:26 -0700220 String displayMessage;
221
222 if (attemptsRemaining == 0) {
223 displayMessage = getContext().getString(R.string.kg_password_wrong_puk_code_dead);
224 } else if (attemptsRemaining > 0) {
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530225 int msgId = isDefault ? R.plurals.kg_password_default_puk_message :
226 R.plurals.kg_password_wrong_puk_code;
Wink Savilleb896b9f2013-10-23 15:44:26 -0700227 displayMessage = getContext().getResources()
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530228 .getQuantityString(msgId, attemptsRemaining, attemptsRemaining);
Wink Savilleb896b9f2013-10-23 15:44:26 -0700229 } else {
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530230 int msgId = isDefault ? R.string.kg_puk_enter_puk_hint :
231 R.string.kg_password_puk_failed;
232 displayMessage = getContext().getString(msgId);
Wink Savilleb896b9f2013-10-23 15:44:26 -0700233 }
234 if (DEBUG) Log.d(LOG_TAG, "getPukPasswordErrorMessage:"
235 + " attemptsRemaining=" + attemptsRemaining + " displayMessage=" + displayMessage);
236 return displayMessage;
237 }
238
Jim Miller4db942c2016-05-16 18:06:50 -0700239 @Override
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400240 public void resetState() {
Selim Cinek4e8b9ed2014-06-20 16:37:04 -0700241 super.resetState();
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400242 mStateMachine.reset();
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400243 }
244
245 @Override
Jim Miller7d5e00a2013-10-11 22:45:57 -0700246 protected boolean shouldLockout(long deadline) {
247 // SIM PUK doesn't have a timed lockout
248 return false;
249 }
250
251 @Override
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400252 protected int getPasswordTextViewId() {
Jorim Jaggifa9189f2014-04-17 20:17:30 +0200253 return R.id.pukEntry;
Jim Millerdcb3d842012-08-23 19:18:12 -0700254 }
255
256 @Override
257 protected void onFinishInflate() {
258 super.onFinishInflate();
Jim Miller0b728242012-10-28 19:42:30 -0700259
Jorim Jaggi40a0b382014-05-27 21:12:27 +0200260 if (mEcaView instanceof EmergencyCarrierArea) {
261 ((EmergencyCarrierArea) mEcaView).setCarrierTextVisible(true);
262 }
Alan Viverette51efddb2017-04-05 10:00:01 -0400263 mSimImageView = findViewById(R.id.keyguard_sim);
Jim Millerdcb3d842012-08-23 19:18:12 -0700264 }
265
Adam Cohen6fb841f2012-10-24 13:15:38 -0700266 @Override
Jim Miller52a61332014-11-12 19:29:51 -0800267 protected void onAttachedToWindow() {
268 super.onAttachedToWindow();
269 KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback);
270 }
271
272 @Override
273 protected void onDetachedFromWindow() {
274 super.onDetachedFromWindow();
275 KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitorCallback);
276 }
277
278 @Override
Adam Cohen6fb841f2012-10-24 13:15:38 -0700279 public void showUsabilityHint() {
280 }
281
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400282 @Override
283 public void onPause() {
Jim Millerdcb3d842012-08-23 19:18:12 -0700284 // dismiss the dialog.
285 if (mSimUnlockProgressDialog != null) {
286 mSimUnlockProgressDialog.dismiss();
287 mSimUnlockProgressDialog = null;
288 }
289 }
290
291 /**
292 * Since the IPC can block, we want to run the request in a separate thread
293 * with a callback.
294 */
295 private abstract class CheckSimPuk extends Thread {
296
297 private final String mPin, mPuk;
Jim Miller52a61332014-11-12 19:29:51 -0800298 private final int mSubId;
Jim Millerdcb3d842012-08-23 19:18:12 -0700299
Jim Miller52a61332014-11-12 19:29:51 -0800300 protected CheckSimPuk(String puk, String pin, int subId) {
Jim Millerdcb3d842012-08-23 19:18:12 -0700301 mPuk = puk;
302 mPin = pin;
Jim Miller52a61332014-11-12 19:29:51 -0800303 mSubId = subId;
Jim Millerdcb3d842012-08-23 19:18:12 -0700304 }
305
Wink Savilleb896b9f2013-10-23 15:44:26 -0700306 abstract void onSimLockChangedResponse(final int result, final int attemptsRemaining);
Jim Millerdcb3d842012-08-23 19:18:12 -0700307
308 @Override
309 public void run() {
310 try {
Jim Miller52a61332014-11-12 19:29:51 -0800311 if (DEBUG) Log.v(TAG, "call supplyPukReportResult()");
Wink Savilleb896b9f2013-10-23 15:44:26 -0700312 final int[] result = ITelephony.Stub.asInterface(ServiceManager
Jim Miller52a61332014-11-12 19:29:51 -0800313 .checkService("phone")).supplyPukReportResultForSubscriber(mSubId, mPuk, mPin);
314 if (DEBUG) {
315 Log.v(TAG, "supplyPukReportResult returned: " + result[0] + " " + result[1]);
316 }
Jim Millerdcb3d842012-08-23 19:18:12 -0700317 post(new Runnable() {
Jim Miller4db942c2016-05-16 18:06:50 -0700318 @Override
Jim Millerdcb3d842012-08-23 19:18:12 -0700319 public void run() {
Wink Savilleb896b9f2013-10-23 15:44:26 -0700320 onSimLockChangedResponse(result[0], result[1]);
Jim Millerdcb3d842012-08-23 19:18:12 -0700321 }
322 });
323 } catch (RemoteException e) {
Jim Miller4fc2b012013-11-04 16:47:48 -0800324 Log.e(TAG, "RemoteException for supplyPukReportResult:", e);
Jim Millerdcb3d842012-08-23 19:18:12 -0700325 post(new Runnable() {
Jim Miller4db942c2016-05-16 18:06:50 -0700326 @Override
Jim Millerdcb3d842012-08-23 19:18:12 -0700327 public void run() {
Wink Savilleb896b9f2013-10-23 15:44:26 -0700328 onSimLockChangedResponse(PhoneConstants.PIN_GENERAL_FAILURE, -1);
Jim Millerdcb3d842012-08-23 19:18:12 -0700329 }
330 });
331 }
332 }
333 }
334
Jim Millerdcb3d842012-08-23 19:18:12 -0700335 private Dialog getSimUnlockProgressDialog() {
336 if (mSimUnlockProgressDialog == null) {
337 mSimUnlockProgressDialog = new ProgressDialog(mContext);
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400338 mSimUnlockProgressDialog.setMessage(
339 mContext.getString(R.string.kg_sim_unlock_progress_dialog_message));
Jim Millerdcb3d842012-08-23 19:18:12 -0700340 mSimUnlockProgressDialog.setIndeterminate(true);
341 mSimUnlockProgressDialog.setCancelable(false);
342 if (!(mContext instanceof Activity)) {
343 mSimUnlockProgressDialog.getWindow().setType(
344 WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
345 }
346 }
347 return mSimUnlockProgressDialog;
348 }
349
Wink Savilleb896b9f2013-10-23 15:44:26 -0700350 private Dialog getPukRemainingAttemptsDialog(int remaining) {
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530351 String msg = getPukPasswordErrorMessage(remaining, false);
Wink Savilleb896b9f2013-10-23 15:44:26 -0700352 if (mRemainingAttemptsDialog == null) {
353 AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
354 builder.setMessage(msg);
355 builder.setCancelable(false);
356 builder.setNeutralButton(R.string.ok, null);
357 mRemainingAttemptsDialog = builder.create();
358 mRemainingAttemptsDialog.getWindow().setType(
359 WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
360 } else {
361 mRemainingAttemptsDialog.setMessage(msg);
362 }
363 return mRemainingAttemptsDialog;
364 }
365
Jim Miller3efe1062012-09-28 16:59:31 -0700366 private boolean checkPuk() {
Jim Millerdcb3d842012-08-23 19:18:12 -0700367 // make sure the puk is at least 8 digits long.
Rakesh Pallerlab8b7bd32014-01-08 15:49:34 +0530368 if (mPasswordEntry.getText().length() == 8) {
Selim Cinek4e8b9ed2014-06-20 16:37:04 -0700369 mPukText = mPasswordEntry.getText();
Jim Miller3efe1062012-09-28 16:59:31 -0700370 return true;
Jim Millerdcb3d842012-08-23 19:18:12 -0700371 }
Jim Miller3efe1062012-09-28 16:59:31 -0700372 return false;
373 }
Jim Millerdcb3d842012-08-23 19:18:12 -0700374
Jim Miller3efe1062012-09-28 16:59:31 -0700375 private boolean checkPin() {
Jim Millerdcb3d842012-08-23 19:18:12 -0700376 // make sure the PIN is between 4 and 8 digits
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400377 int length = mPasswordEntry.getText().length();
Jim Miller3efe1062012-09-28 16:59:31 -0700378 if (length >= 4 && length <= 8) {
Selim Cinek4e8b9ed2014-06-20 16:37:04 -0700379 mPinText = mPasswordEntry.getText();
Jim Miller3efe1062012-09-28 16:59:31 -0700380 return true;
Jim Millerdcb3d842012-08-23 19:18:12 -0700381 }
Jim Miller3efe1062012-09-28 16:59:31 -0700382 return false;
383 }
Jim Millerdcb3d842012-08-23 19:18:12 -0700384
Jim Miller3efe1062012-09-28 16:59:31 -0700385 public boolean confirmPin() {
Selim Cinek4e8b9ed2014-06-20 16:37:04 -0700386 return mPinText.equals(mPasswordEntry.getText());
Jim Miller3efe1062012-09-28 16:59:31 -0700387 }
388
389 private void updateSim() {
Jim Millerdcb3d842012-08-23 19:18:12 -0700390 getSimUnlockProgressDialog().show();
391
Jim Miller4fc2b012013-11-04 16:47:48 -0800392 if (mCheckSimPukThread == null) {
Jim Miller52a61332014-11-12 19:29:51 -0800393 mCheckSimPukThread = new CheckSimPuk(mPukText, mPinText, mSubId) {
Jim Miller4db942c2016-05-16 18:06:50 -0700394 @Override
Wink Savilleb896b9f2013-10-23 15:44:26 -0700395 void onSimLockChangedResponse(final int result, final int attemptsRemaining) {
Jim Miller3efe1062012-09-28 16:59:31 -0700396 post(new Runnable() {
Jim Miller4db942c2016-05-16 18:06:50 -0700397 @Override
Jim Miller4b09dd32012-09-04 14:27:25 -0700398 public void run() {
399 if (mSimUnlockProgressDialog != null) {
400 mSimUnlockProgressDialog.hide();
401 }
Jim Miller4db942c2016-05-16 18:06:50 -0700402 resetPasswordText(true /* animate */,
403 result != PhoneConstants.PIN_RESULT_SUCCESS /* announce */);
Wink Savilleb896b9f2013-10-23 15:44:26 -0700404 if (result == PhoneConstants.PIN_RESULT_SUCCESS) {
Jim Miller52a61332014-11-12 19:29:51 -0800405 KeyguardUpdateMonitor.getInstance(getContext())
406 .reportSimUnlocked(mSubId);
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530407 mRemainingAttempts = -1;
408 mShowDefaultMessage = true;
409 if (mCallback != null) {
410 mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser());
411 }
Jim Miller4b09dd32012-09-04 14:27:25 -0700412 } else {
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530413 mShowDefaultMessage = false;
Wink Savilleb896b9f2013-10-23 15:44:26 -0700414 if (result == PhoneConstants.PIN_PASSWORD_INCORRECT) {
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530415 // show message
416 mSecurityMessageDisplay.setMessage(getPukPasswordErrorMessage(
417 attemptsRemaining, false));
Wink Savilleb896b9f2013-10-23 15:44:26 -0700418 if (attemptsRemaining <= 2) {
419 // this is getting critical - show dialog
420 getPukRemainingAttemptsDialog(attemptsRemaining).show();
421 } else {
422 // show message
423 mSecurityMessageDisplay.setMessage(
Ruthwar Kumar Ambeer118e5742017-03-09 18:46:17 +0530424 getPukPasswordErrorMessage(
425 attemptsRemaining, false));
Wink Savilleb896b9f2013-10-23 15:44:26 -0700426 }
427 } else {
428 mSecurityMessageDisplay.setMessage(getContext().getString(
Adrian Roosdb327e92016-10-12 16:41:28 -0700429 R.string.kg_password_puk_failed));
Wink Savilleb896b9f2013-10-23 15:44:26 -0700430 }
431 if (DEBUG) Log.d(LOG_TAG, "verifyPasswordAndUnlock "
432 + " UpdateSim.onSimCheckResponse: "
433 + " attemptsRemaining=" + attemptsRemaining);
Jim Miller3efe1062012-09-28 16:59:31 -0700434 mStateMachine.reset();
Jim Miller4b09dd32012-09-04 14:27:25 -0700435 }
Jim Miller4fc2b012013-11-04 16:47:48 -0800436 mCheckSimPukThread = null;
Jim Millerdcb3d842012-08-23 19:18:12 -0700437 }
Jim Miller4b09dd32012-09-04 14:27:25 -0700438 });
439 }
Jim Miller4fc2b012013-11-04 16:47:48 -0800440 };
441 mCheckSimPukThread.start();
Jim Miller4b09dd32012-09-04 14:27:25 -0700442 }
Jim Millerdcb3d842012-08-23 19:18:12 -0700443 }
444
445 @Override
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400446 protected void verifyPasswordAndUnlock() {
447 mStateMachine.next();
Jim Miller9cf2c522012-10-04 22:02:29 -0700448 }
Jorim Jaggic14f8292014-05-27 02:25:45 +0200449
450 @Override
451 public void startAppearAnimation() {
452 // noop.
453 }
Jorim Jaggi76a16232014-08-08 17:00:47 +0200454
455 @Override
456 public boolean startDisappearAnimation(Runnable finishRunnable) {
457 return false;
458 }
Jim Millerdcb3d842012-08-23 19:18:12 -0700459}
Daniel Sandler23d7a6e2012-11-02 00:21:07 -0400460
461