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 package com.android.internal.telephony; 17 18 import android.compat.annotation.UnsupportedAppUsage; 19 import android.content.Intent; 20 import android.telephony.TelephonyManager; 21 22 /** 23 * {@hide} 24 */ 25 public class IccCardConstants { 26 27 /* The extra data for broadcasting intent INTENT_ICC_STATE_CHANGE */ 28 public static final String INTENT_KEY_ICC_STATE = Intent.EXTRA_SIM_STATE; 29 /* UNKNOWN means the ICC state is unknown */ 30 public static final String INTENT_VALUE_ICC_UNKNOWN = Intent.SIM_STATE_UNKNOWN; 31 /* NOT_READY means the ICC interface is not ready (eg, radio is off or powering on) */ 32 public static final String INTENT_VALUE_ICC_NOT_READY = Intent.SIM_STATE_NOT_READY; 33 /* ABSENT means ICC is missing */ 34 public static final String INTENT_VALUE_ICC_ABSENT = Intent.SIM_STATE_ABSENT; 35 /* PRESENT means ICC is present */ 36 public static final String INTENT_VALUE_ICC_PRESENT = Intent.SIM_STATE_PRESENT; 37 /* CARD_IO_ERROR means for three consecutive times there was SIM IO error */ 38 static public final String INTENT_VALUE_ICC_CARD_IO_ERROR = Intent.SIM_STATE_CARD_IO_ERROR; 39 /* CARD_RESTRICTED means card is present but not usable due to carrier restrictions */ 40 static public final String INTENT_VALUE_ICC_CARD_RESTRICTED = Intent.SIM_STATE_CARD_RESTRICTED; 41 /* LOCKED means ICC is locked by pin or by network */ 42 public static final String INTENT_VALUE_ICC_LOCKED = Intent.SIM_STATE_LOCKED; 43 /* READY means ICC is ready to access */ 44 public static final String INTENT_VALUE_ICC_READY = Intent.SIM_STATE_READY; 45 /* IMSI means ICC IMSI is ready in property */ 46 public static final String INTENT_VALUE_ICC_IMSI = Intent.SIM_STATE_IMSI; 47 /* LOADED means all ICC records, including IMSI, are loaded */ 48 public static final String INTENT_VALUE_ICC_LOADED = Intent.SIM_STATE_LOADED; 49 /* The extra data for broadcasting intent INTENT_ICC_STATE_CHANGE */ 50 public static final String INTENT_KEY_LOCKED_REASON = Intent.EXTRA_SIM_LOCKED_REASON; 51 /* PIN means ICC is locked on PIN1 */ 52 public static final String INTENT_VALUE_LOCKED_ON_PIN = Intent.SIM_LOCKED_ON_PIN; 53 /* PUK means ICC is locked on PUK1 */ 54 public static final String INTENT_VALUE_LOCKED_ON_PUK = Intent.SIM_LOCKED_ON_PUK; 55 /* NETWORK means ICC is locked on NETWORK PERSONALIZATION */ 56 public static final String INTENT_VALUE_LOCKED_NETWORK = Intent.SIM_LOCKED_NETWORK; 57 /* PERM_DISABLED means ICC is permanently disabled due to puk fails */ 58 public static final String INTENT_VALUE_ABSENT_ON_PERM_DISABLED = 59 Intent.SIM_ABSENT_ON_PERM_DISABLED; 60 61 /** 62 * This is combination of IccCardStatus.CardState and IccCardApplicationStatus.AppState 63 * for external apps (like PhoneApp) to use 64 * 65 * UNKNOWN is a transient state, for example, after user inputs ICC pin under 66 * PIN_REQUIRED state, the query for ICC status returns UNKNOWN before it 67 * turns to READY 68 * 69 * The ordinal values much match {@link TelephonyManager#SIM_STATE_UNKNOWN} ... 70 */ 71 @UnsupportedAppUsage(implicitMember = 72 "values()[Lcom/android/internal/telephony/IccCardConstants$State;") 73 public enum State { 74 @UnsupportedAppUsage 75 UNKNOWN, /** ordinal(0) == {@See TelephonyManager#SIM_STATE_UNKNOWN} */ 76 @UnsupportedAppUsage 77 ABSENT, /** ordinal(1) == {@See TelephonyManager#SIM_STATE_ABSENT} */ 78 @UnsupportedAppUsage 79 PIN_REQUIRED, /** ordinal(2) == {@See TelephonyManager#SIM_STATE_PIN_REQUIRED} */ 80 @UnsupportedAppUsage 81 PUK_REQUIRED, /** ordinal(3) == {@See TelephonyManager#SIM_STATE_PUK_REQUIRED} */ 82 @UnsupportedAppUsage 83 NETWORK_LOCKED, /** ordinal(4) == {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED} */ 84 @UnsupportedAppUsage 85 READY, /** ordinal(5) == {@See TelephonyManager#SIM_STATE_READY} */ 86 @UnsupportedAppUsage 87 NOT_READY, /** ordinal(6) == {@See TelephonyManager#SIM_STATE_NOT_READY} */ 88 @UnsupportedAppUsage 89 PERM_DISABLED, /** ordinal(7) == {@See TelephonyManager#SIM_STATE_PERM_DISABLED} */ 90 @UnsupportedAppUsage 91 CARD_IO_ERROR, /** ordinal(8) == {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR} */ 92 CARD_RESTRICTED,/** ordinal(9) == {@See TelephonyManager#SIM_STATE_CARD_RESTRICTED} */ 93 LOADED; /** ordinal(9) == {@See TelephonyManager#SIM_STATE_LOADED} */ 94 isPinLocked()95 public boolean isPinLocked() { 96 return ((this == PIN_REQUIRED) || (this == PUK_REQUIRED)); 97 } 98 iccCardExist()99 public boolean iccCardExist() { 100 return ((this == PIN_REQUIRED) || (this == PUK_REQUIRED) 101 || (this == NETWORK_LOCKED) || (this == READY) || (this == NOT_READY) 102 || (this == PERM_DISABLED) || (this == CARD_IO_ERROR) 103 || (this == CARD_RESTRICTED) || (this == LOADED)); 104 } 105 intToState(int state)106 public static State intToState(int state) throws IllegalArgumentException { 107 switch(state) { 108 case 0: return UNKNOWN; 109 case 1: return ABSENT; 110 case 2: return PIN_REQUIRED; 111 case 3: return PUK_REQUIRED; 112 case 4: return NETWORK_LOCKED; 113 case 5: return READY; 114 case 6: return NOT_READY; 115 case 7: return PERM_DISABLED; 116 case 8: return CARD_IO_ERROR; 117 case 9: return CARD_RESTRICTED; 118 case 10: return LOADED; 119 default: 120 throw new IllegalArgumentException(); 121 } 122 } 123 } 124 } 125