1 /* 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 package com.android.keyguard; 18 19 import static com.android.systemui.util.PluralMessageFormaterKt.icuMessageFormat; 20 21 import android.content.Context; 22 import android.util.AttributeSet; 23 import android.util.Log; 24 25 import com.android.systemui.R; 26 27 28 /** 29 * Displays a PIN pad for entering a PUK (Pin Unlock Kode) provided by a carrier. 30 */ 31 public class KeyguardSimPukView extends KeyguardSimInputView { 32 private static final boolean DEBUG = KeyguardConstants.DEBUG; 33 public static final String TAG = "KeyguardSimPukView"; 34 KeyguardSimPukView(Context context)35 public KeyguardSimPukView(Context context) { 36 this(context, null); 37 } 38 KeyguardSimPukView(Context context, AttributeSet attrs)39 public KeyguardSimPukView(Context context, AttributeSet attrs) { 40 super(context, attrs); 41 } 42 43 @Override getPromptReasonStringRes(int reason)44 protected int getPromptReasonStringRes(int reason) { 45 // No message on SIM Puk 46 return 0; 47 } 48 getPukPasswordErrorMessage( int attemptsRemaining, boolean isDefault, boolean isEsimLocked)49 String getPukPasswordErrorMessage( 50 int attemptsRemaining, boolean isDefault, boolean isEsimLocked) { 51 String displayMessage; 52 53 if (attemptsRemaining == 0) { 54 displayMessage = getContext().getString(R.string.kg_password_wrong_puk_code_dead); 55 } else if (attemptsRemaining > 0) { 56 int msgId = isDefault ? R.string.kg_password_default_puk_message : 57 R.string.kg_password_wrong_puk_code; 58 displayMessage = icuMessageFormat(getResources(), msgId, attemptsRemaining); 59 } else { 60 int msgId = isDefault ? R.string.kg_puk_enter_puk_hint : 61 R.string.kg_password_puk_failed; 62 displayMessage = getContext().getString(msgId); 63 } 64 if (isEsimLocked) { 65 displayMessage = getResources() 66 .getString(R.string.kg_sim_lock_esim_instructions, displayMessage); 67 } 68 if (DEBUG) { 69 Log.d(TAG, "getPukPasswordErrorMessage:" 70 + " attemptsRemaining=" + attemptsRemaining 71 + " displayMessage=" + displayMessage); 72 } 73 return displayMessage; 74 } 75 76 @Override getPasswordTextViewId()77 protected int getPasswordTextViewId() { 78 return R.id.pukEntry; 79 } 80 81 @Override onFinishInflate()82 protected void onFinishInflate() { 83 super.onFinishInflate(); 84 85 if (mEcaView instanceof EmergencyCarrierArea) { 86 ((EmergencyCarrierArea) mEcaView).setCarrierTextVisible(true); 87 } 88 } 89 90 @Override startAppearAnimation()91 public void startAppearAnimation() { 92 // noop. 93 } 94 95 @Override getTitle()96 public CharSequence getTitle() { 97 return getContext().getString( 98 com.android.internal.R.string.keyguard_accessibility_sim_puk_unlock); 99 } 100 } 101