blob: 39ce269c0c1f5a20a8401c08ef77aa654a656716 [file] [log] [blame]
Alan Viverette3da604b2020-06-10 18:34:39 +00001/*
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;
18
19import android.compat.annotation.UnsupportedAppUsage;
20import android.os.AsyncResult;
21import android.os.Handler;
22import android.os.Message;
23
24import com.android.internal.telephony.IccCardConstants.State;
25import com.android.internal.telephony.uicc.IccCardApplicationStatus;
26import com.android.internal.telephony.uicc.IccCardApplicationStatus.PersoSubState;
27import com.android.internal.telephony.uicc.IccRecords;
28
29/**
30 * {@hide}
31 * @Deprecated use UiccController.getUiccCard instead.
32 *
33 * Integrated Circuit Card (ICC) interface
34 * An object of a class implementing this interface is used by external
35 * apps (specifically PhoneApp) to perform icc card related functionality.
36 *
37 * Apps (those that have access to Phone object) can retrieve this object
38 * by calling phone.getIccCard()
39 *
40 * This interface is implemented by UiccProfile and the object PhoneApp
41 * gets when it calls getIccCard is UiccProfile.
42 */
43public class IccCard {
44 private State mIccCardState = State.UNKNOWN;
45
46 /**
47 * Empty constructor.
48 */
49 public IccCard() {}
50
51 /**
52 * Set the state of the IccCard to be returned in {@link getState}.
53 */
54 public IccCard(State state) {
55 mIccCardState = state;
56 }
57
58 /**
59 * @return combined Card and current App state
60 */
61 @UnsupportedAppUsage
62 public State getState() {
63 return mIccCardState;
64 }
65
66 // todo: delete
67 /**
68 * @return IccRecords object belonging to current UiccCardApplication
69 */
70 public IccRecords getIccRecords() {
71 return null;
72 }
73
74 /**
75 * Notifies handler of any transition into IccCardConstants.State.NETWORK_LOCKED
76 */
77 @UnsupportedAppUsage
78 public void registerForNetworkLocked(Handler h, int what, Object obj) {
79 return;
80 }
81 /**
82 * Unregister for networkLocked state change.
83 */
84 public void unregisterForNetworkLocked(Handler h) {
85 return;
86 }
87
88 /**
89 * Supply the ICC PIN to the ICC
90 *
91 * When the operation is complete, onComplete will be sent to its
92 * Handler.
93 *
94 * onComplete.obj will be an AsyncResult
95 *
96 * ((AsyncResult)onComplete.obj).exception == null on success
97 * ((AsyncResult)onComplete.obj).exception != null on fail
98 *
99 * If the supplied PIN is incorrect:
100 * ((AsyncResult)onComplete.obj).exception != null
101 * && ((AsyncResult)onComplete.obj).exception
102 * instanceof com.android.internal.telephony.gsm.CommandException)
103 * && ((CommandException)(((AsyncResult)onComplete.obj).exception))
104 * .getCommandError() == CommandException.Error.PASSWORD_INCORRECT
105 */
106 @UnsupportedAppUsage
107 public void supplyPin(String pin, Message onComplete) {
108 sendMessageWithCardAbsentException(onComplete);
109 }
110
111 /**
112 * Supply the ICC PUK to the ICC
113 */
114 @UnsupportedAppUsage
115 public void supplyPuk(String puk, String newPin, Message onComplete) {
116 sendMessageWithCardAbsentException(onComplete);
117 }
118
119 /**
120 * Supply the ICC PIN2 to the ICC
121 */
122 public void supplyPin2(String pin2, Message onComplete) {
123 sendMessageWithCardAbsentException(onComplete);
124 }
125
126 /**
127 * Supply the ICC PUK2 to the ICC
128 */
129 public void supplyPuk2(String puk2, String newPin2, Message onComplete) {
130 sendMessageWithCardAbsentException(onComplete);
131 }
132
133 /**
134 * Supply Network depersonalization code to the RIL
135 */
136 @UnsupportedAppUsage
137 public void supplyNetworkDepersonalization(String pin, Message onComplete) {
138 sendMessageWithCardAbsentException(onComplete);
139 }
140
141 /**
142 * Supply Sim depersonalization code to the RIL
143 */
144 public void supplySimDepersonalization(PersoSubState persoType,
145 String controlKey, Message onComplete) {
146 sendMessageWithCardAbsentException(onComplete);
147 }
148
149 /**
150 * Check whether ICC pin lock is enabled
151 * This is a sync call which returns the cached pin enabled state
152 *
153 * @return true for ICC locked enabled
154 * false for ICC locked disabled
155 */
156 public boolean getIccLockEnabled() {
157 return false;
158 }
159
160 /**
161 * Check whether fdn (fixed dialing number) service is available.
162 * @return true if ICC fdn service available
163 * false if ICC fdn service not available
164 */
165 public boolean getIccFdnAvailable() {
166 return false;
167 }
168
169 /**
170 * Check whether ICC fdn (fixed dialing number) is enabled
171 * This is a sync call which returns the cached pin enabled state
172 *
173 * @return true for ICC fdn enabled
174 * false for ICC fdn disabled
175 */
176 public boolean getIccFdnEnabled() {
177 return false;
178 }
179
180 /**
181 * Set the ICC pin lock enabled or disabled
182 * When the operation is complete, onComplete will be sent to its handler
183 *
184 * @param enabled "true" for locked "false" for unlocked.
185 * @param password needed to change the ICC pin state, aka. Pin1
186 * @param onComplete
187 * onComplete.obj will be an AsyncResult
188 * ((AsyncResult)onComplete.obj).exception == null on success
189 * ((AsyncResult)onComplete.obj).exception != null on fail
190 */
191 public void setIccLockEnabled(boolean enabled,
192 String password, Message onComplete) {
193 sendMessageWithCardAbsentException(onComplete);
194 }
195
196 /**
197 * Set the ICC fdn enabled or disabled
198 * When the operation is complete, onComplete will be sent to its handler
199 *
200 * @param enabled "true" for locked "false" for unlocked.
201 * @param password needed to change the ICC fdn enable, aka Pin2
202 * @param onComplete
203 * onComplete.obj will be an AsyncResult
204 * ((AsyncResult)onComplete.obj).exception == null on success
205 * ((AsyncResult)onComplete.obj).exception != null on fail
206 */
207 public void setIccFdnEnabled(boolean enabled,
208 String password, Message onComplete) {
209 sendMessageWithCardAbsentException(onComplete);
210 }
211
212 /**
213 * Change the ICC password used in ICC pin lock
214 * When the operation is complete, onComplete will be sent to its handler
215 *
216 * @param oldPassword is the old password
217 * @param newPassword is the new password
218 * @param onComplete
219 * onComplete.obj will be an AsyncResult
220 * ((AsyncResult)onComplete.obj).exception == null on success
221 * ((AsyncResult)onComplete.obj).exception != null on fail
222 */
223 public void changeIccLockPassword(String oldPassword, String newPassword,
224 Message onComplete) {
225 sendMessageWithCardAbsentException(onComplete);
226 }
227
228 /**
229 * Change the ICC password used in ICC fdn enable
230 * When the operation is complete, onComplete will be sent to its handler
231 *
232 * @param oldPassword is the old password
233 * @param newPassword is the new password
234 * @param onComplete
235 * onComplete.obj will be an AsyncResult
236 * ((AsyncResult)onComplete.obj).exception == null on success
237 * ((AsyncResult)onComplete.obj).exception != null on fail
238 */
239 public void changeIccFdnPassword(String oldPassword, String newPassword,
240 Message onComplete) {
241 sendMessageWithCardAbsentException(onComplete);
242 }
243
244 /**
245 * Returns service provider name stored in ICC card.
246 * If there is no service provider name associated or the record is not
247 * yet available, null will be returned <p>
248 *
249 * Please use this value when display Service Provider Name in idle mode <p>
250 *
251 * Usage of this provider name in the UI is a common carrier requirement.
252 *
253 * Also available via Android property "gsm.sim.operator.alpha"
254 *
255 * @return Service Provider Name stored in ICC card
256 * null if no service provider name associated or the record is not
257 * yet available
258 *
259 */
260 public String getServiceProviderName() {
261 return null;
262 }
263
264 /**
265 * Checks if an Application of specified type present on the card
266 * @param type is AppType to look for
267 */
268 public boolean isApplicationOnIcc(IccCardApplicationStatus.AppType type) {
269 return false;
270 }
271
272 /**
273 * @return true if a ICC card is present
274 */
275 public boolean hasIccCard() {
276 return false;
277 }
278
279 /**
280 * @return true if ICC card is PIN2 blocked
281 */
282 public boolean getIccPin2Blocked() {
283 return false;
284 }
285
286 /**
287 * @return true if ICC card is PUK2 blocked
288 */
289 public boolean getIccPuk2Blocked() {
290 return false;
291 }
292
293 /**
294 * @return whether the card is an empty profile, meaning there's no UiccCardApplication,
295 * and that we don't need to wait for LOADED state.
296 */
297 public boolean isEmptyProfile() {
298 return false;
299 }
300
301 private void sendMessageWithCardAbsentException(Message onComplete) {
302 AsyncResult ret = AsyncResult.forMessage(onComplete);
303 ret.exception = new RuntimeException("No valid IccCard");
304 onComplete.sendToTarget();
305 }
306}