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.os.Handler;
20 import android.os.Message;
21 
22 import com.android.internal.telephony.IccCardConstants.State;
23 import com.android.internal.telephony.uicc.IccCardApplicationStatus;
24 import com.android.internal.telephony.uicc.IccFileHandler;
25 import com.android.internal.telephony.uicc.IccRecords;
26 
27 /**
28  * {@hide}
29  * @Deprecated use UiccController.getUiccCard instead.
30  *
31  * Integrated Circuit Card (ICC) interface
32  * An object of a class implementing this interface is used by external
33  * apps (specifically PhoneApp) to perform icc card related functionality.
34  *
35  * Apps (those that have access to Phone object) can retrieve this object
36  * by calling phone.getIccCard()
37  *
38  * This interface is implemented by IccCardProxy and the object PhoneApp
39  * gets when it calls getIccCard is IccCardProxy.
40  */
41 public interface IccCard {
42     /**
43      * @return combined Card and current App state
44      */
getState()45     public State getState();
46 
47     /**
48      * @return IccRecords object belonging to current UiccCardApplication
49      */
getIccRecords()50     public IccRecords getIccRecords();
51 
52     /**
53      * @return IccFileHandler object belonging to current UiccCardApplication
54      */
getIccFileHandler()55     public IccFileHandler getIccFileHandler();
56 
57     /**
58      * Notifies handler of any transition into IccCardConstants.State.ABSENT
59      */
registerForAbsent(Handler h, int what, Object obj)60     public void registerForAbsent(Handler h, int what, Object obj);
unregisterForAbsent(Handler h)61     public void unregisterForAbsent(Handler h);
62 
63     /**
64      * Notifies handler of any transition into IccCardConstants.State.NETWORK_LOCKED
65      */
registerForNetworkLocked(Handler h, int what, Object obj)66     public void registerForNetworkLocked(Handler h, int what, Object obj);
unregisterForNetworkLocked(Handler h)67     public void unregisterForNetworkLocked(Handler h);
68 
69     /**
70      * Notifies handler of any transition into IccCardConstants.State.isPinLocked()
71      */
registerForLocked(Handler h, int what, Object obj)72     public void registerForLocked(Handler h, int what, Object obj);
unregisterForLocked(Handler h)73     public void unregisterForLocked(Handler h);
74 
75     /**
76      * Supply the ICC PIN to the ICC
77      *
78      * When the operation is complete, onComplete will be sent to its
79      * Handler.
80      *
81      * onComplete.obj will be an AsyncResult
82      *
83      * ((AsyncResult)onComplete.obj).exception == null on success
84      * ((AsyncResult)onComplete.obj).exception != null on fail
85      *
86      * If the supplied PIN is incorrect:
87      * ((AsyncResult)onComplete.obj).exception != null
88      * && ((AsyncResult)onComplete.obj).exception
89      *       instanceof com.android.internal.telephony.gsm.CommandException)
90      * && ((CommandException)(((AsyncResult)onComplete.obj).exception))
91      *          .getCommandError() == CommandException.Error.PASSWORD_INCORRECT
92      */
supplyPin(String pin, Message onComplete)93     public void supplyPin (String pin, Message onComplete);
94 
95     /**
96      * Supply the ICC PUK to the ICC
97      */
supplyPuk(String puk, String newPin, Message onComplete)98     public void supplyPuk (String puk, String newPin, Message onComplete);
99 
100     /**
101      * Supply the ICC PIN2 to the ICC
102      */
supplyPin2(String pin2, Message onComplete)103     public void supplyPin2 (String pin2, Message onComplete);
104 
105     /**
106      * Supply the ICC PUK2 to the ICC
107      */
supplyPuk2(String puk2, String newPin2, Message onComplete)108     public void supplyPuk2 (String puk2, String newPin2, Message onComplete);
109 
110     /**
111      * Check whether fdn (fixed dialing number) service is available.
112      * @return true if ICC fdn service available
113      *         false if ICC fdn service not available
114     */
getIccFdnAvailable()115     public boolean getIccFdnAvailable();
116 
117     /**
118      * Supply Network depersonalization code to the RIL
119      */
supplyNetworkDepersonalization(String pin, Message onComplete)120     public void supplyNetworkDepersonalization (String pin, Message onComplete);
121 
122     /**
123      * Check whether ICC pin lock is enabled
124      * This is a sync call which returns the cached pin enabled state
125      *
126      * @return true for ICC locked enabled
127      *         false for ICC locked disabled
128      */
getIccLockEnabled()129     public boolean getIccLockEnabled();
130 
131     /**
132      * Check whether ICC fdn (fixed dialing number) is enabled
133      * This is a sync call which returns the cached pin enabled state
134      *
135      * @return true for ICC fdn enabled
136      *         false for ICC fdn disabled
137      */
getIccFdnEnabled()138     public boolean getIccFdnEnabled();
139 
140      /**
141       * Set the ICC pin lock enabled or disabled
142       * When the operation is complete, onComplete will be sent to its handler
143       *
144       * @param enabled "true" for locked "false" for unlocked.
145       * @param password needed to change the ICC pin state, aka. Pin1
146       * @param onComplete
147       *        onComplete.obj will be an AsyncResult
148       *        ((AsyncResult)onComplete.obj).exception == null on success
149       *        ((AsyncResult)onComplete.obj).exception != null on fail
150       */
setIccLockEnabled(boolean enabled, String password, Message onComplete)151      public void setIccLockEnabled (boolean enabled,
152              String password, Message onComplete);
153 
154      /**
155       * Set the ICC fdn enabled or disabled
156       * When the operation is complete, onComplete will be sent to its handler
157       *
158       * @param enabled "true" for locked "false" for unlocked.
159       * @param password needed to change the ICC fdn enable, aka Pin2
160       * @param onComplete
161       *        onComplete.obj will be an AsyncResult
162       *        ((AsyncResult)onComplete.obj).exception == null on success
163       *        ((AsyncResult)onComplete.obj).exception != null on fail
164       */
setIccFdnEnabled(boolean enabled, String password, Message onComplete)165      public void setIccFdnEnabled (boolean enabled,
166              String password, Message onComplete);
167 
168      /**
169       * Change the ICC password used in ICC pin lock
170       * When the operation is complete, onComplete will be sent to its handler
171       *
172       * @param oldPassword is the old password
173       * @param newPassword is the new password
174       * @param onComplete
175       *        onComplete.obj will be an AsyncResult
176       *        ((AsyncResult)onComplete.obj).exception == null on success
177       *        ((AsyncResult)onComplete.obj).exception != null on fail
178       */
changeIccLockPassword(String oldPassword, String newPassword, Message onComplete)179      public void changeIccLockPassword(String oldPassword, String newPassword,
180              Message onComplete);
181 
182      /**
183       * Change the ICC password used in ICC fdn enable
184       * When the operation is complete, onComplete will be sent to its handler
185       *
186       * @param oldPassword is the old password
187       * @param newPassword is the new password
188       * @param onComplete
189       *        onComplete.obj will be an AsyncResult
190       *        ((AsyncResult)onComplete.obj).exception == null on success
191       *        ((AsyncResult)onComplete.obj).exception != null on fail
192       */
changeIccFdnPassword(String oldPassword, String newPassword, Message onComplete)193      public void changeIccFdnPassword(String oldPassword, String newPassword,
194              Message onComplete);
195 
196     /**
197      * Returns service provider name stored in ICC card.
198      * If there is no service provider name associated or the record is not
199      * yet available, null will be returned <p>
200      *
201      * Please use this value when display Service Provider Name in idle mode <p>
202      *
203      * Usage of this provider name in the UI is a common carrier requirement.
204      *
205      * Also available via Android property "gsm.sim.operator.alpha"
206      *
207      * @return Service Provider Name stored in ICC card
208      *         null if no service provider name associated or the record is not
209      *         yet available
210      *
211      */
getServiceProviderName()212     public String getServiceProviderName ();
213 
214     /**
215      * Checks if an Application of specified type present on the card
216      * @param type is AppType to look for
217      */
isApplicationOnIcc(IccCardApplicationStatus.AppType type)218     public boolean isApplicationOnIcc(IccCardApplicationStatus.AppType type);
219 
220     /**
221      * @return true if a ICC card is present
222      */
hasIccCard()223     public boolean hasIccCard();
224 
225     /**
226      * @return true if ICC card is PIN2 blocked
227      */
getIccPin2Blocked()228     public boolean getIccPin2Blocked();
229 
230     /**
231      * @return true if ICC card is PUK2 blocked
232      */
getIccPuk2Blocked()233     public boolean getIccPuk2Blocked();
234 }
235