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