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