IccCardStatus.java revision d720945f2be5ea5fe0faf67e67d9ea0e184eba67
1/* 2 * Copyright (C) 2006 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 17package com.android.internal.telephony.uicc; 18 19 20import java.util.ArrayList; 21 22/** 23 * See also RIL_CardStatus in include/telephony/ril.h 24 * 25 * {@hide} 26 */ 27public class IccCardStatus { 28 public static final int CARD_MAX_APPS = 8; 29 30 public enum CardState { 31 CARDSTATE_ABSENT, 32 CARDSTATE_PRESENT, 33 CARDSTATE_ERROR; 34 35 boolean isCardPresent() { 36 return this == CARDSTATE_PRESENT; 37 } 38 } 39 40 public enum PinState { 41 PINSTATE_UNKNOWN, 42 PINSTATE_ENABLED_NOT_VERIFIED, 43 PINSTATE_ENABLED_VERIFIED, 44 PINSTATE_DISABLED, 45 PINSTATE_ENABLED_BLOCKED, 46 PINSTATE_ENABLED_PERM_BLOCKED; 47 48 boolean isPermBlocked() { 49 return this == PINSTATE_ENABLED_PERM_BLOCKED; 50 } 51 52 boolean isPinRequired() { 53 return this == PINSTATE_ENABLED_NOT_VERIFIED; 54 } 55 56 boolean isPukRequired() { 57 return this == PINSTATE_ENABLED_BLOCKED; 58 } 59 } 60 61 public CardState mCardState; 62 public PinState mUniversalPinState; 63 public int mGsmUmtsSubscriptionAppIndex; 64 public int mCdmaSubscriptionAppIndex; 65 public int mImsSubscriptionAppIndex; 66 67 public IccCardApplicationStatus[] mApplications; 68 69 public void setCardState(int state) { 70 switch(state) { 71 case 0: 72 mCardState = CardState.CARDSTATE_ABSENT; 73 break; 74 case 1: 75 mCardState = CardState.CARDSTATE_PRESENT; 76 break; 77 case 2: 78 mCardState = CardState.CARDSTATE_ERROR; 79 break; 80 default: 81 throw new RuntimeException("Unrecognized RIL_CardState: " + state); 82 } 83 } 84 85 public void setUniversalPinState(int state) { 86 switch(state) { 87 case 0: 88 mUniversalPinState = PinState.PINSTATE_UNKNOWN; 89 break; 90 case 1: 91 mUniversalPinState = PinState.PINSTATE_ENABLED_NOT_VERIFIED; 92 break; 93 case 2: 94 mUniversalPinState = PinState.PINSTATE_ENABLED_VERIFIED; 95 break; 96 case 3: 97 mUniversalPinState = PinState.PINSTATE_DISABLED; 98 break; 99 case 4: 100 mUniversalPinState = PinState.PINSTATE_ENABLED_BLOCKED; 101 break; 102 case 5: 103 mUniversalPinState = PinState.PINSTATE_ENABLED_PERM_BLOCKED; 104 break; 105 default: 106 throw new RuntimeException("Unrecognized RIL_PinState: " + state); 107 } 108 } 109 110 @Override 111 public String toString() { 112 IccCardApplicationStatus app; 113 114 StringBuilder sb = new StringBuilder(); 115 sb.append("IccCardState {").append(mCardState).append(",") 116 .append(mUniversalPinState) 117 .append(",num_apps=").append(mApplications.length) 118 .append(",gsm_id=").append(mGsmUmtsSubscriptionAppIndex); 119 if (mGsmUmtsSubscriptionAppIndex >=0 120 && mGsmUmtsSubscriptionAppIndex <CARD_MAX_APPS) { 121 app = mApplications[mGsmUmtsSubscriptionAppIndex]; 122 sb.append(app == null ? "null" : app); 123 } 124 125 sb.append(",cmda_id=").append(mCdmaSubscriptionAppIndex); 126 if (mCdmaSubscriptionAppIndex >=0 127 && mCdmaSubscriptionAppIndex <CARD_MAX_APPS) { 128 app = mApplications[mCdmaSubscriptionAppIndex]; 129 sb.append(app == null ? "null" : app); 130 } 131 132 sb.append(",ims_id=").append(mImsSubscriptionAppIndex); 133 if (mImsSubscriptionAppIndex >=0 134 && mImsSubscriptionAppIndex <CARD_MAX_APPS) { 135 app = mApplications[mImsSubscriptionAppIndex]; 136 sb.append(app == null ? "null" : app); 137 } 138 139 sb.append("}"); 140 141 return sb.toString(); 142 } 143 144} 145