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