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