1 /*
2  * Copyright (C) 2014 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.telephony.SubscriptionInfo;
20 import android.os.ParcelUuid;
21 import com.android.internal.telephony.ISetOpportunisticDataCallback;
22 
23 interface ISub {
24     /**
25      * @param callingPackage The package maing the call.
26      * @param callingFeatureId The feature in the package
27      * @return a list of all subscriptions in the database, this includes
28      * all subscriptions that have been seen.
29      */
getAllSubInfoList(String callingPackage, String callingFeatureId)30     List<SubscriptionInfo> getAllSubInfoList(String callingPackage, String callingFeatureId);
31 
32     /**
33      * @param callingPackage The package maing the call.
34      * @param callingFeatureId The feature in the package
35      * @return the count of all subscriptions in the database, this includes
36      * all subscriptions that have been seen.
37      */
getAllSubInfoCount(String callingPackage, String callingFeatureId)38     int getAllSubInfoCount(String callingPackage, String callingFeatureId);
39 
40     /**
41      * Get the active SubscriptionInfo with the subId key
42      * @param subId The unique SubscriptionInfo key in database
43      * @param callingPackage The package maing the call.
44      * @param callingFeatureId The feature in the package
45      * @return SubscriptionInfo, maybe null if its not active
46      */
getActiveSubscriptionInfo(int subId, String callingPackage, String callingFeatureId)47     SubscriptionInfo getActiveSubscriptionInfo(int subId, String callingPackage,
48             String callingFeatureId);
49 
50     /**
51      * Get the active SubscriptionInfo associated with the iccId
52      * @param iccId the IccId of SIM card
53      * @param callingPackage The package maing the call.
54      * @param callingFeatureId The feature in the package
55      * @return SubscriptionInfo, maybe null if its not active
56      */
getActiveSubscriptionInfoForIccId(String iccId, String callingPackage, String callingFeatureId)57     SubscriptionInfo getActiveSubscriptionInfoForIccId(String iccId, String callingPackage,
58             String callingFeatureId);
59 
60     /**
61      * Get the active SubscriptionInfo associated with the slotIndex
62      * @param slotIndex the slot which the subscription is inserted
63      * @param callingPackage The package making the call.
64      * @param callingFeatureId The feature in the package
65      * @return SubscriptionInfo, null for Remote-SIMs or non-active slotIndex.
66      */
getActiveSubscriptionInfoForSimSlotIndex(int slotIndex, String callingPackage, String callingFeatureId)67     SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIndex, String callingPackage,
68             String callingFeatureId);
69 
70     /**
71      * Get the SubscriptionInfo(s) of the active subscriptions. The records will be sorted
72      * by {@link SubscriptionInfo#getSimSlotIndex} then by {@link SubscriptionInfo#getSubscriptionId}.
73      *
74      * @param callingPackage The package maing the call.
75      * @param callingFeatureId The feature in the package
76      * @return Sorted list of the currently {@link SubscriptionInfo} records available on the device.
77      * <ul>
78      * <li>
79      * If null is returned the current state is unknown but if a {@link OnSubscriptionsChangedListener}
80      * has been registered {@link OnSubscriptionsChangedListener#onSubscriptionsChanged} will be
81      * invoked in the future.
82      * </li>
83      * <li>
84      * If the list is empty then there are no {@link SubscriptionInfo} records currently available.
85      * </li>
86      * <li>
87      * if the list is non-empty the list is sorted by {@link SubscriptionInfo#getSimSlotIndex}
88      * then by {@link SubscriptionInfo#getSubscriptionId}.
89      * </li>
90      * </ul>
91      */
getActiveSubscriptionInfoList(String callingPackage, String callingFeatureId)92     List<SubscriptionInfo> getActiveSubscriptionInfoList(String callingPackage,
93             String callingFeatureId);
94 
95     /**
96      * @param callingPackage The package making the call.
97      * @param callingFeatureId The feature in the package.
98      * @return the number of active subscriptions
99      */
getActiveSubInfoCount(String callingPackage, String callingFeatureId)100     int getActiveSubInfoCount(String callingPackage, String callingFeatureId);
101 
102     /**
103      * @return the maximum number of subscriptions this device will support at any one time.
104      */
getActiveSubInfoCountMax()105     int getActiveSubInfoCountMax();
106 
107     /**
108      * @see android.telephony.SubscriptionManager#getAvailableSubscriptionInfoList
109      */
getAvailableSubscriptionInfoList(String callingPackage, String callingFeatureId)110     List<SubscriptionInfo> getAvailableSubscriptionInfoList(String callingPackage,
111             String callingFeatureId);
112 
113     /**
114      * @see android.telephony.SubscriptionManager#getAccessibleSubscriptionInfoList
115      */
getAccessibleSubscriptionInfoList(String callingPackage)116     List<SubscriptionInfo> getAccessibleSubscriptionInfoList(String callingPackage);
117 
118     /**
119      * @see android.telephony.SubscriptionManager#requestEmbeddedSubscriptionInfoListRefresh
120      */
requestEmbeddedSubscriptionInfoListRefresh(int cardId)121     oneway void requestEmbeddedSubscriptionInfoListRefresh(int cardId);
122 
123     /**
124      * Add a new SubscriptionInfo to subinfo database if needed
125      * @param iccId the IccId of the SIM card
126      * @param slotIndex the slot which the SIM is inserted
127      * @return the URL of the newly created row or the updated row
128      */
addSubInfoRecord(String iccId, int slotIndex)129     int addSubInfoRecord(String iccId, int slotIndex);
130 
131     /**
132      * Add a new subscription info record, if needed
133      * @param uniqueId This is the unique identifier for the subscription within the specific
134      *                 subscription type.
135      * @param displayName human-readable name of the device the subscription corresponds to.
136      * @param slotIndex the slot assigned to this device
137      * @param subscriptionType the type of subscription to be added.
138      * @return 0 if success, < 0 on error.
139      */
addSubInfo(String uniqueId, String displayName, int slotIndex, int subscriptionType)140     int addSubInfo(String uniqueId, String displayName, int slotIndex, int subscriptionType);
141 
142     /**
143      * Remove subscription info record for the given device.
144      * @param uniqueId This is the unique identifier for the subscription within the specific
145      *                      subscription type.
146      * @param subscriptionType the type of subscription to be removed
147      * @return 0 if success, < 0 on error.
148      */
removeSubInfo(String uniqueId, int subscriptionType)149     int removeSubInfo(String uniqueId, int subscriptionType);
150 
151     /**
152      * Set SIM icon tint color by simInfo index
153      * @param tint the icon tint color of the SIM
154      * @param subId the unique SubscriptionInfo index in database
155      * @return the number of records updated
156      */
setIconTint(int tint, int subId)157     int setIconTint(int tint, int subId);
158 
159     /**
160      * Set display name by simInfo index with name source
161      * @param displayName the display name of SIM card
162      * @param subId the unique SubscriptionInfo index in database
163      * @param nameSource, 0: DEFAULT_SOURCE, 1: SIM_SOURCE, 2: USER_INPUT
164      * @return the number of records updated
165      */
setDisplayNameUsingSrc(String displayName, int subId, int nameSource)166     int setDisplayNameUsingSrc(String displayName, int subId, int nameSource);
167 
168     /**
169      * Set phone number by subId
170      * @param number the phone number of the SIM
171      * @param subId the unique SubscriptionInfo index in database
172      * @return the number of records updated
173      */
setDisplayNumber(String number, int subId)174     int setDisplayNumber(String number, int subId);
175 
176     /**
177      * Set data roaming by simInfo index
178      * @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming
179      * @param subId the unique SubscriptionInfo index in database
180      * @return the number of records updated
181      */
setDataRoaming(int roaming, int subId)182     int setDataRoaming(int roaming, int subId);
183 
184     /**
185      * Switch to a certain subscription
186      *
187      * @param opportunistic whether it’s opportunistic subscription.
188      * @param subId the unique SubscriptionInfo index in database
189      * @return the number of records updated
190      */
setOpportunistic(boolean opportunistic, int subId, String callingPackage)191     int setOpportunistic(boolean opportunistic, int subId, String callingPackage);
192 
193     /**
194      * Inform SubscriptionManager that subscriptions in the list are bundled
195      * as a group. Typically it's a primary subscription and an opportunistic
196      * subscription. It should only affect multi-SIM scenarios where primary
197      * and opportunistic subscriptions can be activated together.
198      * Being in the same group means they might be activated or deactivated
199      * together, some of them may be invisible to the users, etc.
200      *
201      * Caller will either have {@link android.Manifest.permission.MODIFY_PHONE_STATE}
202      * permission or can manage all subscriptions in the list, according to their
203      * acess rules.
204      *
205      * @param subIdList list of subId that will be in the same group
206      * @return groupUUID a UUID assigned to the subscription group. It returns
207      * null if fails.
208      *
209      */
createSubscriptionGroup(in int[] subIdList, String callingPackage)210     ParcelUuid createSubscriptionGroup(in int[] subIdList, String callingPackage);
211 
212     /**
213      * Set which subscription is preferred for cellular data. It's
214      * designed to overwrite default data subscription temporarily.
215      *
216      * @param subId which subscription is preferred to for cellular data.
217      * @param needValidation whether validation is needed before switching.
218      * @param callback callback upon request completion.
219      *
220      * @hide
221      *
222      */
setPreferredDataSubscriptionId(int subId, boolean needValidation, ISetOpportunisticDataCallback callback)223     void setPreferredDataSubscriptionId(int subId, boolean needValidation,
224                      ISetOpportunisticDataCallback callback);
225 
226     /**
227      * Get which subscription is preferred for cellular data.
228      *
229      * @hide
230      *
231      */
getPreferredDataSubscriptionId()232     int getPreferredDataSubscriptionId();
233 
234     /**
235      * Get User downloaded Profiles.
236      *
237      * Return opportunistic subscriptions that can be visible to the caller.
238      * @return the list of opportunistic subscription info. If none exists, an empty list.
239      */
getOpportunisticSubscriptions(String callingPackage, String callingFeatureId)240     List<SubscriptionInfo> getOpportunisticSubscriptions(String callingPackage,
241             String callingFeatureId);
242 
removeSubscriptionsFromGroup(in int[] subIdList, in ParcelUuid groupUuid, String callingPackage)243     void removeSubscriptionsFromGroup(in int[] subIdList, in ParcelUuid groupUuid,
244         String callingPackage);
245 
addSubscriptionsIntoGroup(in int[] subIdList, in ParcelUuid groupUuid, String callingPackage)246     void addSubscriptionsIntoGroup(in int[] subIdList, in ParcelUuid groupUuid,
247         String callingPackage);
248 
getSubscriptionsInGroup(in ParcelUuid groupUuid, String callingPackage, String callingFeatureId)249     List<SubscriptionInfo> getSubscriptionsInGroup(in ParcelUuid groupUuid, String callingPackage,
250             String callingFeatureId);
251 
getSlotIndex(int subId)252     int getSlotIndex(int subId);
253 
getSubId(int slotIndex)254     int[] getSubId(int slotIndex);
255 
getDefaultSubId()256     int getDefaultSubId();
257 
clearSubInfo()258     int clearSubInfo();
259 
getPhoneId(int subId)260     int getPhoneId(int subId);
261 
262     /**
263      * Get the default data subscription
264      * @return Id of the data subscription
265      */
getDefaultDataSubId()266     int getDefaultDataSubId();
267 
setDefaultDataSubId(int subId)268     void setDefaultDataSubId(int subId);
269 
getDefaultVoiceSubId()270     int getDefaultVoiceSubId();
271 
setDefaultVoiceSubId(int subId)272     void setDefaultVoiceSubId(int subId);
273 
getDefaultSmsSubId()274     int getDefaultSmsSubId();
275 
setDefaultSmsSubId(int subId)276     void setDefaultSmsSubId(int subId);
277 
getActiveSubIdList(boolean visibleOnly)278     int[] getActiveSubIdList(boolean visibleOnly);
279 
setSubscriptionProperty(int subId, String propKey, String propValue)280     int setSubscriptionProperty(int subId, String propKey, String propValue);
281 
getSubscriptionProperty(int subId, String propKey, String callingPackage, String callingFeatureId)282     String getSubscriptionProperty(int subId, String propKey, String callingPackage,
283             String callingFeatureId);
284 
setSubscriptionEnabled(boolean enable, int subId)285     boolean setSubscriptionEnabled(boolean enable, int subId);
286 
isSubscriptionEnabled(int subId)287     boolean isSubscriptionEnabled(int subId);
288 
getEnabledSubscriptionId(int slotIndex)289     int getEnabledSubscriptionId(int slotIndex);
290     /**
291      * Get the SIM state for the slot index
292      * @return SIM state as the ordinal of IccCardConstants.State
293      */
getSimStateForSlotIndex(int slotIndex)294     int getSimStateForSlotIndex(int slotIndex);
295 
isActiveSubId(int subId, String callingPackage, String callingFeatureId)296     boolean isActiveSubId(int subId, String callingPackage, String callingFeatureId);
297 
getActiveDataSubscriptionId()298     int getActiveDataSubscriptionId();
299 
canDisablePhysicalSubscription()300     boolean canDisablePhysicalSubscription();
301 
setUiccApplicationsEnabled(boolean enabled, int subscriptionId)302     int setUiccApplicationsEnabled(boolean enabled, int subscriptionId);
303 }
304