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 android.os.UserHandle; 22 import com.android.internal.telephony.ISetOpportunisticDataCallback; 23 24 interface ISub { 25 /** 26 * @param callingPackage The package maing the call. 27 * @param callingFeatureId The feature in the package 28 * @return a list of all subscriptions in the database, this includes 29 * all subscriptions that have been seen. 30 */ getAllSubInfoList(String callingPackage, String callingFeatureId)31 List<SubscriptionInfo> getAllSubInfoList(String callingPackage, String callingFeatureId); 32 33 /** 34 * Get the active SubscriptionInfo with the subId key 35 * @param subId The unique SubscriptionInfo key in database 36 * @param callingPackage The package maing the call. 37 * @param callingFeatureId The feature in the package 38 * @return SubscriptionInfo, maybe null if its not active 39 */ getActiveSubscriptionInfo(int subId, String callingPackage, String callingFeatureId)40 SubscriptionInfo getActiveSubscriptionInfo(int subId, String callingPackage, 41 String callingFeatureId); 42 43 /** 44 * Get the active SubscriptionInfo associated with the iccId 45 * @param iccId the IccId of SIM card 46 * @param callingPackage The package maing the call. 47 * @param callingFeatureId The feature in the package 48 * @return SubscriptionInfo, maybe null if its not active 49 */ getActiveSubscriptionInfoForIccId(String iccId, String callingPackage, String callingFeatureId)50 SubscriptionInfo getActiveSubscriptionInfoForIccId(String iccId, String callingPackage, 51 String callingFeatureId); 52 53 /** 54 * Get the active SubscriptionInfo associated with the slotIndex 55 * @param slotIndex the slot which the subscription is inserted 56 * @param callingPackage The package making the call. 57 * @param callingFeatureId The feature in the package 58 * @return SubscriptionInfo, null for Remote-SIMs or non-active slotIndex. 59 */ getActiveSubscriptionInfoForSimSlotIndex(int slotIndex, String callingPackage, String callingFeatureId)60 SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIndex, String callingPackage, 61 String callingFeatureId); 62 63 /** 64 * Get the SubscriptionInfo(s) of the active subscriptions. The records will be sorted 65 * by {@link SubscriptionInfo#getSimSlotIndex} then by {@link SubscriptionInfo#getSubscriptionId}. 66 * 67 * @param callingPackage The package maing the call. 68 * @param callingFeatureId The feature in the package 69 * @return Sorted list of the currently {@link SubscriptionInfo} records available on the device. 70 * <ul> 71 * <li> 72 * If null is returned the current state is unknown but if a {@link OnSubscriptionsChangedListener} 73 * has been registered {@link OnSubscriptionsChangedListener#onSubscriptionsChanged} will be 74 * invoked in the future. 75 * </li> 76 * <li> 77 * If the list is empty then there are no {@link SubscriptionInfo} records currently available. 78 * </li> 79 * <li> 80 * if the list is non-empty the list is sorted by {@link SubscriptionInfo#getSimSlotIndex} 81 * then by {@link SubscriptionInfo#getSubscriptionId}. 82 * </li> 83 * </ul> 84 */ getActiveSubscriptionInfoList(String callingPackage, String callingFeatureId)85 List<SubscriptionInfo> getActiveSubscriptionInfoList(String callingPackage, 86 String callingFeatureId); 87 88 /** 89 * @param callingPackage The package making the call. 90 * @param callingFeatureId The feature in the package. 91 * @return the number of active subscriptions 92 */ getActiveSubInfoCount(String callingPackage, String callingFeatureId)93 int getActiveSubInfoCount(String callingPackage, String callingFeatureId); 94 95 /** 96 * @return the maximum number of subscriptions this device will support at any one time. 97 */ getActiveSubInfoCountMax()98 int getActiveSubInfoCountMax(); 99 100 /** 101 * @see android.telephony.SubscriptionManager#getAvailableSubscriptionInfoList 102 */ getAvailableSubscriptionInfoList(String callingPackage, String callingFeatureId)103 List<SubscriptionInfo> getAvailableSubscriptionInfoList(String callingPackage, 104 String callingFeatureId); 105 106 /** 107 * @see android.telephony.SubscriptionManager#getAccessibleSubscriptionInfoList 108 */ getAccessibleSubscriptionInfoList(String callingPackage)109 List<SubscriptionInfo> getAccessibleSubscriptionInfoList(String callingPackage); 110 111 /** 112 * @see android.telephony.SubscriptionManager#requestEmbeddedSubscriptionInfoListRefresh 113 */ requestEmbeddedSubscriptionInfoListRefresh(int cardId)114 oneway void requestEmbeddedSubscriptionInfoListRefresh(int cardId); 115 116 /** 117 * Add a new subscription info record, if needed 118 * @param uniqueId This is the unique identifier for the subscription within the specific 119 * subscription type. 120 * @param displayName human-readable name of the device the subscription corresponds to. 121 * @param slotIndex the slot assigned to this device 122 * @param subscriptionType the type of subscription to be added. 123 * @return 0 if success, < 0 on error. 124 */ addSubInfo(String uniqueId, String displayName, int slotIndex, int subscriptionType)125 int addSubInfo(String uniqueId, String displayName, int slotIndex, int subscriptionType); 126 127 /** 128 * Remove subscription info record for the given device. 129 * @param uniqueId This is the unique identifier for the subscription within the specific 130 * subscription type. 131 * @param subscriptionType the type of subscription to be removed 132 * @return true if success, false on error. 133 */ removeSubInfo(String uniqueId, int subscriptionType)134 boolean removeSubInfo(String uniqueId, int subscriptionType); 135 136 /** 137 * Set SIM icon tint color by simInfo index 138 * @param subId the unique SubscriptionInfo index in database 139 * @param tint the icon tint color of the SIM 140 * @return the number of records updated 141 */ setIconTint(int subId, int tint)142 int setIconTint(int subId, int tint); 143 144 /** 145 * Set display name by simInfo index with name source 146 * @param displayName the display name of SIM card 147 * @param subId the unique SubscriptionInfo index in database 148 * @param nameSource, 0: DEFAULT_SOURCE, 1: SIM_SOURCE, 2: USER_INPUT 149 * @return the number of records updated 150 */ setDisplayNameUsingSrc(String displayName, int subId, int nameSource)151 int setDisplayNameUsingSrc(String displayName, int subId, int nameSource); 152 153 /** 154 * Set phone number by subId 155 * @param number the phone number of the SIM 156 * @param subId the unique SubscriptionInfo index in database 157 * @return the number of records updated 158 */ setDisplayNumber(String number, int subId)159 int setDisplayNumber(String number, int subId); 160 161 /** 162 * Set data roaming by simInfo index 163 * @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming 164 * @param subId the unique SubscriptionInfo index in database 165 * @return the number of records updated 166 */ setDataRoaming(int roaming, int subId)167 int setDataRoaming(int roaming, int subId); 168 169 /** 170 * Switch to a certain subscription 171 * 172 * @param opportunistic whether it’s opportunistic subscription. 173 * @param subId the unique SubscriptionInfo index in database 174 * @return the number of records updated 175 */ setOpportunistic(boolean opportunistic, int subId, String callingPackage)176 int setOpportunistic(boolean opportunistic, int subId, String callingPackage); 177 178 /** 179 * Inform SubscriptionManager that subscriptions in the list are bundled 180 * as a group. Typically it's a primary subscription and an opportunistic 181 * subscription. It should only affect multi-SIM scenarios where primary 182 * and opportunistic subscriptions can be activated together. 183 * Being in the same group means they might be activated or deactivated 184 * together, some of them may be invisible to the users, etc. 185 * 186 * Caller will either have {@link android.Manifest.permission.MODIFY_PHONE_STATE} 187 * permission or can manage all subscriptions in the list, according to their 188 * acess rules. 189 * 190 * @param subIdList list of subId that will be in the same group 191 * @return groupUUID a UUID assigned to the subscription group. It returns 192 * null if fails. 193 * 194 */ createSubscriptionGroup(in int[] subIdList, String callingPackage)195 ParcelUuid createSubscriptionGroup(in int[] subIdList, String callingPackage); 196 197 /** 198 * Set which subscription is preferred for cellular data. It's 199 * designed to overwrite default data subscription temporarily. 200 * 201 * @param subId which subscription is preferred to for cellular data. 202 * @param needValidation whether validation is needed before switching. 203 * @param callback callback upon request completion. 204 * 205 * @hide 206 * 207 */ setPreferredDataSubscriptionId(int subId, boolean needValidation, ISetOpportunisticDataCallback callback)208 void setPreferredDataSubscriptionId(int subId, boolean needValidation, 209 ISetOpportunisticDataCallback callback); 210 211 /** 212 * Get which subscription is preferred for cellular data. 213 * 214 * @hide 215 * 216 */ getPreferredDataSubscriptionId()217 int getPreferredDataSubscriptionId(); 218 219 /** 220 * Get User downloaded Profiles. 221 * 222 * Return opportunistic subscriptions that can be visible to the caller. 223 * @return the list of opportunistic subscription info. If none exists, an empty list. 224 */ getOpportunisticSubscriptions(String callingPackage, String callingFeatureId)225 List<SubscriptionInfo> getOpportunisticSubscriptions(String callingPackage, 226 String callingFeatureId); 227 removeSubscriptionsFromGroup(in int[] subIdList, in ParcelUuid groupUuid, String callingPackage)228 void removeSubscriptionsFromGroup(in int[] subIdList, in ParcelUuid groupUuid, 229 String callingPackage); 230 addSubscriptionsIntoGroup(in int[] subIdList, in ParcelUuid groupUuid, String callingPackage)231 void addSubscriptionsIntoGroup(in int[] subIdList, in ParcelUuid groupUuid, 232 String callingPackage); 233 getSubscriptionsInGroup(in ParcelUuid groupUuid, String callingPackage, String callingFeatureId)234 List<SubscriptionInfo> getSubscriptionsInGroup(in ParcelUuid groupUuid, String callingPackage, 235 String callingFeatureId); 236 getSlotIndex(int subId)237 int getSlotIndex(int subId); 238 getSubId(int slotIndex)239 int getSubId(int slotIndex); 240 getDefaultSubId()241 int getDefaultSubId(); 242 getPhoneId(int subId)243 int getPhoneId(int subId); 244 245 /** 246 * Get the default data subscription 247 * @return Id of the data subscription 248 */ getDefaultDataSubId()249 int getDefaultDataSubId(); 250 setDefaultDataSubId(int subId)251 void setDefaultDataSubId(int subId); 252 getDefaultVoiceSubId()253 int getDefaultVoiceSubId(); 254 setDefaultVoiceSubId(int subId)255 void setDefaultVoiceSubId(int subId); 256 getDefaultSmsSubId()257 int getDefaultSmsSubId(); 258 setDefaultSmsSubId(int subId)259 void setDefaultSmsSubId(int subId); 260 getActiveSubIdList(boolean visibleOnly)261 int[] getActiveSubIdList(boolean visibleOnly); 262 setSubscriptionProperty(int subId, String propKey, String propValue)263 void setSubscriptionProperty(int subId, String propKey, String propValue); 264 getSubscriptionProperty(int subId, String propKey, String callingPackage, String callingFeatureId)265 String getSubscriptionProperty(int subId, String propKey, String callingPackage, 266 String callingFeatureId); 267 isSubscriptionEnabled(int subId)268 boolean isSubscriptionEnabled(int subId); 269 getEnabledSubscriptionId(int slotIndex)270 int getEnabledSubscriptionId(int slotIndex); 271 isActiveSubId(int subId, String callingPackage, String callingFeatureId)272 boolean isActiveSubId(int subId, String callingPackage, String callingFeatureId); 273 getActiveDataSubscriptionId()274 int getActiveDataSubscriptionId(); 275 canDisablePhysicalSubscription()276 boolean canDisablePhysicalSubscription(); 277 setUiccApplicationsEnabled(boolean enabled, int subscriptionId)278 void setUiccApplicationsEnabled(boolean enabled, int subscriptionId); 279 setDeviceToDeviceStatusSharing(int sharing, int subId)280 int setDeviceToDeviceStatusSharing(int sharing, int subId); 281 setDeviceToDeviceStatusSharingContacts(String contacts, int subscriptionId)282 int setDeviceToDeviceStatusSharingContacts(String contacts, int subscriptionId); 283 getPhoneNumber(int subId, int source, String callingPackage, String callingFeatureId)284 String getPhoneNumber(int subId, int source, 285 String callingPackage, String callingFeatureId); 286 getPhoneNumberFromFirstAvailableSource(int subId, String callingPackage, String callingFeatureId)287 String getPhoneNumberFromFirstAvailableSource(int subId, 288 String callingPackage, String callingFeatureId); 289 setPhoneNumber(int subId, int source, String number, String callingPackage, String callingFeatureId)290 void setPhoneNumber(int subId, int source, String number, 291 String callingPackage, String callingFeatureId); 292 293 /** 294 * Set the Usage Setting for this subscription. 295 * 296 * @param usageSetting the usage setting for this subscription 297 * @param subId the unique SubscriptionInfo index in database 298 * @param callingPackage The package making the IPC. 299 * 300 * @throws SecurityException if doesn't have MODIFY_PHONE_STATE or Carrier Privileges 301 */ setUsageSetting(int usageSetting, int subId, String callingPackage)302 int setUsageSetting(int usageSetting, int subId, String callingPackage); 303 304 /** 305 * Set userHandle for this subscription. 306 * 307 * @param userHandle the user handle for this subscription 308 * @param subId the unique SubscriptionInfo index in database 309 * 310 * @throws SecurityException if doesn't have MANAGE_SUBSCRIPTION_USER_ASSOCIATION 311 * @throws IllegalArgumentException if subId is invalid. 312 */ setSubscriptionUserHandle(in UserHandle userHandle, int subId)313 int setSubscriptionUserHandle(in UserHandle userHandle, int subId); 314 315 /** 316 * Get UserHandle for this subscription 317 * 318 * @param subId the unique SubscriptionInfo index in database 319 * @return userHandle associated with this subscription. 320 * 321 * @throws SecurityException if doesn't have MANAGE_SUBSCRIPTION_USER_ASSOCIATION 322 * @throws IllegalArgumentException if subId is invalid. 323 */ getSubscriptionUserHandle(int subId)324 UserHandle getSubscriptionUserHandle(int subId); 325 326 /** 327 * Check if subscription and user are associated with each other. 328 * 329 * @param subscriptionId the subId of the subscription 330 * @param userHandle user handle of the user 331 * @return {@code true} if subscription is associated with user 332 * {code true} if there are no subscriptions on device 333 * else {@code false} if subscription is not associated with user. 334 * 335 * @throws IllegalArgumentException if subscription is invalid. 336 * @throws SecurityException if the caller doesn't have permissions required. 337 * @throws IllegalStateException if subscription service is not available. 338 * 339 * @hide 340 */ isSubscriptionAssociatedWithUser(int subscriptionId, in UserHandle userHandle)341 boolean isSubscriptionAssociatedWithUser(int subscriptionId, in UserHandle userHandle); 342 343 /** 344 * Get list of subscriptions associated with user. 345 * 346 * @param userHandle user handle of the user 347 * @return list of subscriptionInfo associated with the user. 348 * 349 * @throws SecurityException if the caller doesn't have permissions required. 350 * @throws IllegalStateException if subscription service is not available. 351 * 352 * @hide 353 */ getSubscriptionInfoListAssociatedWithUser(in UserHandle userHandle)354 List<SubscriptionInfo> getSubscriptionInfoListAssociatedWithUser(in UserHandle userHandle); 355 356 /** 357 * Called during setup wizard restore flow to attempt to restore the backed up sim-specific 358 * configs to device for all existing SIMs in the subscription database 359 * {@link Telephony.SimInfo}. Internally, it will store the backup data in an internal file. 360 * This file will persist on device for device's lifetime and will be used later on when a SIM 361 * is inserted to restore that specific SIM's settings. End result is subscription database is 362 * modified to match any backed up configs for the appropriate inserted SIMs. 363 * 364 * <p> 365 * The {@link Uri} {@link #SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI} is notified if any 366 * {@link Telephony.SimInfo} entry is updated as the result of this method call. 367 * 368 * @param data with the sim specific configs to be backed up. 369 */ restoreAllSimSpecificSettingsFromBackup(in byte[] data)370 void restoreAllSimSpecificSettingsFromBackup(in byte[] data); 371 } 372