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