diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 3927ebd593bd0..62e82a064db22 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -394,8 +394,10 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { + " callback.asBinder=" + callback.asBinder()); } + // TODO(b/70041899): Find a way to make this work for carrier-privileged callers. if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( - mContext, callingPackage, "addOnSubscriptionsChangedListener")) { + mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage, + "addOnSubscriptionsChangedListener")) { return; } @@ -686,8 +688,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { private boolean canReadPhoneState(String callingPackage, String message) { try { + // TODO(b/70041899): Find a way to make this work for carrier-privileged callers. return TelephonyPermissions.checkCallingOrSelfReadPhoneState( - mContext, callingPackage, message); + mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage, message); } catch (SecurityException e) { return false; } @@ -1735,8 +1738,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) { - if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( - mContext, callingPackage, message)) { + // TODO(b/70041899): Find a way to make this work for carrier-privileged callers. + if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, + SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage, message)) { return false; } } diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 4a6143788cc1b..ef66ed7ae064e 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -25,6 +25,7 @@ import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.annotation.SuppressAutoDoc; import android.annotation.SystemApi; import android.annotation.SystemService; import android.app.BroadcastOptions; @@ -42,7 +43,6 @@ import android.os.Looper; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; -import android.os.ServiceManager.ServiceNotFoundException; import android.util.DisplayMetrics; import com.android.internal.telephony.IOnSubscriptionsChangedListener; @@ -59,9 +59,6 @@ import java.util.concurrent.TimeUnit; /** * SubscriptionManager is the application interface to SubscriptionController * and provides information about the current Telephony Subscriptions. - *

- * All SDK public methods require android.Manifest.permission.READ_PHONE_STATE unless otherwise - * specified. */ @SystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) public class SubscriptionManager { @@ -612,6 +609,8 @@ public class SubscriptionManager { * @param listener an instance of {@link OnSubscriptionsChangedListener} with * onSubscriptionsChanged overridden. */ + // TODO(b/70041899): Find a way to extend this to carrier-privileged apps. + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public void addOnSubscriptionsChangedListener(OnSubscriptionsChangedListener listener) { String pkgName = mContext != null ? mContext.getOpPackageName() : ""; if (DBG) { @@ -660,9 +659,15 @@ public class SubscriptionManager { /** * Get the active SubscriptionInfo with the input subId. * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see + * {@link TelephonyManager#hasCarrierPrivileges}). + * * @param subId The unique SubscriptionInfo key in database. * @return SubscriptionInfo, maybe null if its not active. */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public SubscriptionInfo getActiveSubscriptionInfo(int subId) { if (VDBG) logd("[getActiveSubscriptionInfo]+ subId=" + subId); if (!isValidSubscriptionId(subId)) { @@ -716,9 +721,16 @@ public class SubscriptionManager { /** * Get the active SubscriptionInfo associated with the slotIndex + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see + * {@link TelephonyManager#hasCarrierPrivileges}). + * * @param slotIndex the slot which the subscription is inserted * @return SubscriptionInfo, maybe null if its not active */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIndex) { if (VDBG) logd("[getActiveSubscriptionInfoForSimSlotIndex]+ slotIndex=" + slotIndex); if (!isValidSlotIndex(slotIndex)) { @@ -770,6 +782,11 @@ public class SubscriptionManager { * Get the SubscriptionInfo(s) of the currently inserted SIM(s). The records will be sorted * by {@link SubscriptionInfo#getSimSlotIndex} then by {@link SubscriptionInfo#getSubscriptionId}. * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see + * {@link TelephonyManager#hasCarrierPrivileges}). In the latter case, only records accessible + * to the calling app are returned. + * * @return Sorted list of the currently {@link SubscriptionInfo} records available on the device. *

*/ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public List getActiveSubscriptionInfoList() { List result = null; @@ -928,10 +947,18 @@ public class SubscriptionManager { } /** + * + * Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see + * {@link TelephonyManager#hasCarrierPrivileges}). In the latter case, the count will include + * only those subscriptions accessible to the caller. + * * @return the current number of active subscriptions. There is no guarantee the value * returned by this method will be the same as the length of the list returned by * {@link #getActiveSubscriptionInfoList}. */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getActiveSubscriptionInfoCount() { int result = 0; diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 5329613cebf47..2432268f14924 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -23,6 +23,7 @@ import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.annotation.SuppressAutoDoc; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemService; @@ -53,7 +54,6 @@ import android.telephony.ims.aidl.IImsConfig; import android.telephony.ims.aidl.IImsMmTelFeature; import android.telephony.ims.aidl.IImsRcsFeature; import android.telephony.ims.aidl.IImsRegistration; -import android.telephony.ims.feature.ImsFeature; import android.telephony.ims.stub.ImsRegistrationImplBase; import android.util.Log; @@ -1114,7 +1114,11 @@ public class TelephonyManager { * Returns the software version number for the device, for example, * the IMEI/SV for GSM phones. Return null if the software version is * not available. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getDeviceSoftwareVersion() { return getDeviceSoftwareVersion(getSlotIndex()); @@ -1146,10 +1150,14 @@ public class TelephonyManager { * Returns the unique device ID, for example, the IMEI for GSM and the MEID * or ESN for CDMA phones. Return null if device ID is not available. * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * * @deprecated Use (@link getImei} which returns IMEI for GSM or (@link getMeid} which returns * MEID for CDMA. */ @Deprecated + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getDeviceId() { try { @@ -1168,12 +1176,16 @@ public class TelephonyManager { * Returns the unique device ID of a subscription, for example, the IMEI for * GSM and the MEID for CDMA phones. Return null if device ID is not available. * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * * @param slotIndex of which deviceID is returned * * @deprecated Use (@link getImei} which returns IMEI for GSM or (@link getMeid} which returns * MEID for CDMA. */ @Deprecated + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getDeviceId(int slotIndex) { // FIXME this assumes phoneId == slotIndex @@ -1192,7 +1204,11 @@ public class TelephonyManager { /** * Returns the IMEI (International Mobile Equipment Identity). Return null if IMEI is not * available. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getImei() { return getImei(getSlotIndex()); @@ -1202,8 +1218,12 @@ public class TelephonyManager { * Returns the IMEI (International Mobile Equipment Identity). Return null if IMEI is not * available. * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * * @param slotIndex of which IMEI is returned */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getImei(int slotIndex) { ITelephony telephony = getITelephony(); @@ -1220,7 +1240,11 @@ public class TelephonyManager { /** * Returns the MEID (Mobile Equipment Identifier). Return null if MEID is not available. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getMeid() { return getMeid(getSlotIndex()); @@ -1229,8 +1253,12 @@ public class TelephonyManager { /** * Returns the MEID (Mobile Equipment Identifier). Return null if MEID is not available. * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * * @param slotIndex of which MEID is returned */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getMeid(int slotIndex) { ITelephony telephony = getITelephony(); @@ -1247,10 +1275,11 @@ public class TelephonyManager { /** * Returns the Network Access Identifier (NAI). Return null if NAI is not available. - *

- * Requires Permission: - * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getNai() { return getNaiBySubscriberId(getSubId()); @@ -1751,6 +1780,7 @@ public class TelephonyManager { * @see #createForSubscriptionId(int) * @see #createForPhoneAccountHandle(PhoneAccountHandle) */ + // TODO(b/73136824, b/70041899): Permit carrier-privileged callers as well. @WorkerThread @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public PersistableBundle getCarrierConfig() { @@ -1949,6 +1979,9 @@ public class TelephonyManager { * If this object has been created with {@link #createForSubscriptionId}, applies to the given * subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()} * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * * @return the network type * * @see #NETWORK_TYPE_UNKNOWN @@ -1968,6 +2001,7 @@ public class TelephonyManager { * @see #NETWORK_TYPE_EHRPD * @see #NETWORK_TYPE_HSPAP */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getDataNetworkType() { return getDataNetworkType(getSubId(SubscriptionManager.getDefaultDataSubscriptionId())); @@ -2002,7 +2036,11 @@ public class TelephonyManager { /** * Returns the NETWORK_TYPE_xxxx for voice + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getVoiceNetworkType() { return getVoiceNetworkType(getSubId()); @@ -2588,7 +2626,11 @@ public class TelephonyManager { /** * Returns the serial number of the SIM, if applicable. Return null if it is * unavailable. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getSimSerialNumber() { return getSimSerialNumber(getSubId()); @@ -2713,7 +2755,11 @@ public class TelephonyManager { /** * Returns the unique subscriber ID, for example, the IMSI for a GSM phone. * Return null if it is unavailable. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getSubscriberId() { return getSubscriberId(getSubId()); @@ -2881,7 +2927,11 @@ public class TelephonyManager { /** * Returns the Group Identifier Level1 for a GSM phone. * Return null if it is unavailable. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getGroupIdLevel1() { try { @@ -2922,9 +2972,15 @@ public class TelephonyManager { /** * Returns the phone number string for line 1, for example, the MSISDN * for a GSM phone. Return null if it is unavailable. - *

- * The default SMS app can also use this. + * + *

Requires Permission: + * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}, + * {@link android.Manifest.permission#READ_SMS READ_SMS}, + * {@link android.Manifest.permission#READ_PHONE_NUMBERS READ_PHONE_NUMBERS}, + * that the caller is the default SMS app, + * or that the caller has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges or default SMS app @RequiresPermission(anyOf = { android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.READ_SMS, @@ -2979,8 +3035,7 @@ public class TelephonyManager { * change the actual MSISDN/MDN. To unset alphatag or number, pass in a null * value. * - *

Requires that the calling app has carrier privileges. - * @see #hasCarrierPrivileges + *

Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param alphaTag alpha-tagging of the dailing nubmer * @param number The dialing number @@ -2996,8 +3051,7 @@ public class TelephonyManager { * change the actual MSISDN/MDN. To unset alphatag or number, pass in a null * value. * - *

Requires that the calling app has carrier privileges. - * @see #hasCarrierPrivileges + *

Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId the subscriber that the alphatag and dialing number belongs to. * @param alphaTag alpha-tagging of the dailing nubmer @@ -3116,7 +3170,11 @@ public class TelephonyManager { /** * Returns the voice mail number. Return null if it is unavailable. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVoiceMailNumber() { return getVoiceMailNumber(getSubId()); @@ -3177,8 +3235,7 @@ public class TelephonyManager { /** * Sets the voice mail number. * - *

Requires that the calling app has carrier privileges. - * @see #hasCarrierPrivileges + *

Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param alphaTag The alpha tag to display. * @param number The voicemail number. @@ -3190,8 +3247,7 @@ public class TelephonyManager { /** * Sets the voicemail number for the given subscriber. * - *

Requires that the calling app has carrier privileges. - * @see #hasCarrierPrivileges + *

Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription id. * @param alphaTag The alpha tag to display. @@ -3212,9 +3268,9 @@ public class TelephonyManager { /** * Enables or disables the visual voicemail client for a phone account. * - *

Requires that the calling app is the default dialer, or has carrier privileges, or - * has permission {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. - * @see #hasCarrierPrivileges + *

Requires that the calling app is the default dialer, or has carrier privileges (see + * {@link #hasCarrierPrivileges}), or has permission + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. * * @param phoneAccountHandle the phone account to change the client state * @param enabled the new state of the client @@ -3277,11 +3333,15 @@ public class TelephonyManager { * to the TelephonyManager. Returns {@code null} when there is no package responsible for * processing visual voicemail for the subscription. * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * * @see #createForSubscriptionId(int) * @see #createForPhoneAccountHandle(PhoneAccountHandle) * @see VisualVoicemailService */ @Nullable + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVisualVoicemailPackageName() { try { @@ -3524,15 +3584,14 @@ public class TelephonyManager { * Sets the voice activation state * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the + * calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param activationState The voice activation state * @see #SIM_ACTIVATION_STATE_UNKNOWN * @see #SIM_ACTIVATION_STATE_ACTIVATING * @see #SIM_ACTIVATION_STATE_ACTIVATED * @see #SIM_ACTIVATION_STATE_DEACTIVATED - * @see #hasCarrierPrivileges * @hide */ @SystemApi @@ -3545,8 +3604,8 @@ public class TelephonyManager { * Sets the voice activation state for the given subscriber. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the + * calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription id. * @param activationState The voice activation state of the given subscriber. @@ -3554,7 +3613,6 @@ public class TelephonyManager { * @see #SIM_ACTIVATION_STATE_ACTIVATING * @see #SIM_ACTIVATION_STATE_ACTIVATED * @see #SIM_ACTIVATION_STATE_DEACTIVATED - * @see #hasCarrierPrivileges * @hide */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) @@ -3572,8 +3630,8 @@ public class TelephonyManager { * Sets the data activation state * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the + * calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param activationState The data activation state * @see #SIM_ACTIVATION_STATE_UNKNOWN @@ -3581,7 +3639,6 @@ public class TelephonyManager { * @see #SIM_ACTIVATION_STATE_ACTIVATED * @see #SIM_ACTIVATION_STATE_DEACTIVATED * @see #SIM_ACTIVATION_STATE_RESTRICTED - * @see #hasCarrierPrivileges * @hide */ @SystemApi @@ -3594,8 +3651,8 @@ public class TelephonyManager { * Sets the data activation state for the given subscriber. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the + * calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription id. * @param activationState The data activation state of the given subscriber. @@ -3604,7 +3661,6 @@ public class TelephonyManager { * @see #SIM_ACTIVATION_STATE_ACTIVATED * @see #SIM_ACTIVATION_STATE_DEACTIVATED * @see #SIM_ACTIVATION_STATE_RESTRICTED - * @see #hasCarrierPrivileges * @hide */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) @@ -3622,15 +3678,14 @@ public class TelephonyManager { * Returns the voice activation state * *

Requires Permission: - * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} - * Or the calling app has carrier privileges. + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @return voiceActivationState * @see #SIM_ACTIVATION_STATE_UNKNOWN * @see #SIM_ACTIVATION_STATE_ACTIVATING * @see #SIM_ACTIVATION_STATE_ACTIVATED * @see #SIM_ACTIVATION_STATE_DEACTIVATED - * @see #hasCarrierPrivileges * @hide */ @SystemApi @@ -3643,8 +3698,8 @@ public class TelephonyManager { * Returns the voice activation state for the given subscriber. * *

Requires Permission: - * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} - * Or the calling app has carrier privileges. + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription id. * @@ -3653,7 +3708,6 @@ public class TelephonyManager { * @see #SIM_ACTIVATION_STATE_ACTIVATING * @see #SIM_ACTIVATION_STATE_ACTIVATED * @see #SIM_ACTIVATION_STATE_DEACTIVATED - * @see #hasCarrierPrivileges * @hide */ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @@ -3672,8 +3726,8 @@ public class TelephonyManager { * Returns the data activation state * *

Requires Permission: - * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} - * Or the calling app has carrier privileges. + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @return dataActivationState for the given subscriber * @see #SIM_ACTIVATION_STATE_UNKNOWN @@ -3681,7 +3735,6 @@ public class TelephonyManager { * @see #SIM_ACTIVATION_STATE_ACTIVATED * @see #SIM_ACTIVATION_STATE_DEACTIVATED * @see #SIM_ACTIVATION_STATE_RESTRICTED - * @see #hasCarrierPrivileges * @hide */ @SystemApi @@ -3694,8 +3747,8 @@ public class TelephonyManager { * Returns the data activation state for the given subscriber. * *

Requires Permission: - * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} - * Or the calling app has carrier privileges. + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription id. * @@ -3705,7 +3758,6 @@ public class TelephonyManager { * @see #SIM_ACTIVATION_STATE_ACTIVATED * @see #SIM_ACTIVATION_STATE_DEACTIVATED * @see #SIM_ACTIVATION_STATE_RESTRICTED - * @see #hasCarrierPrivileges * @hide */ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @@ -3753,7 +3805,11 @@ public class TelephonyManager { /** * Retrieves the alphabetic identifier associated with the voice * mail number. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVoiceMailAlphaTag() { return getVoiceMailAlphaTag(getSubId()); @@ -3782,9 +3838,8 @@ public class TelephonyManager { } /** - * Send the special dialer code. The IPC caller must be the current default dialer or has - * carrier privileges. - * @see #hasCarrierPrivileges + * Send the special dialer code. The IPC caller must be the current default dialer or have + * carrier privileges (see {@link #hasCarrierPrivileges}). * * @param inputCode The special dialer code to send * @@ -4312,8 +4367,8 @@ public class TelephonyManager { * Input parameters equivalent to TS 27.007 AT+CCHO command. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param AID Application id. See ETSI 102.221 and 101.220. * @return an IccOpenLogicalChannelResponse object. @@ -4330,8 +4385,8 @@ public class TelephonyManager { * Input parameters equivalent to TS 27.007 AT+CCHO command. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param AID Application id. See ETSI 102.221 and 101.220. * @param p2 P2 parameter (described in ISO 7816-4). @@ -4347,8 +4402,8 @@ public class TelephonyManager { * Input parameters equivalent to TS 27.007 AT+CCHO command. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription to use. * @param AID Application id. See ETSI 102.221 and 101.220. @@ -4373,8 +4428,8 @@ public class TelephonyManager { * Input parameters equivalent to TS 27.007 AT+CCHC command. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param channel is the channel id to be closed as retruned by a successful * iccOpenLogicalChannel. @@ -4390,8 +4445,8 @@ public class TelephonyManager { * Input parameters equivalent to TS 27.007 AT+CCHC command. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription to use. * @param channel is the channel id to be closed as retruned by a successful @@ -4416,8 +4471,8 @@ public class TelephonyManager { * Input parameters equivalent to TS 27.007 AT+CGLA command. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param channel is the channel id to be closed as returned by a successful * iccOpenLogicalChannel. @@ -4443,8 +4498,8 @@ public class TelephonyManager { * Input parameters equivalent to TS 27.007 AT+CGLA command. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription to use. * @param channel is the channel id to be closed as returned by a successful @@ -4479,8 +4534,8 @@ public class TelephonyManager { * Input parameters equivalent to TS 27.007 AT+CSIM command. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param cla Class of the APDU command. * @param instruction Instruction of the APDU command. @@ -4504,8 +4559,8 @@ public class TelephonyManager { * Input parameters equivalent to TS 27.007 AT+CSIM command. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription to use. * @param cla Class of the APDU command. @@ -4536,8 +4591,8 @@ public class TelephonyManager { * Returns the response APDU for a command APDU sent through SIM_IO. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param fileID * @param command @@ -4556,8 +4611,8 @@ public class TelephonyManager { * Returns the response APDU for a command APDU sent through SIM_IO. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription to use. * @param fileID @@ -4585,8 +4640,8 @@ public class TelephonyManager { * Send ENVELOPE to the SIM and return the response. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param content String containing SAT/USAT response in hexadecimal * format starting with command tag. See TS 102 223 for @@ -4603,8 +4658,8 @@ public class TelephonyManager { * Send ENVELOPE to the SIM and return the response. * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription to use. * @param content String containing SAT/USAT response in hexadecimal @@ -4629,10 +4684,10 @@ public class TelephonyManager { /** * Read one of the NV items defined in com.android.internal.telephony.RadioNVItems. * Used for device configuration by some CDMA operators. - *

- * Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param itemID the ID of the item to read. * @return the NV item as a String, or null on any failure. @@ -4655,10 +4710,10 @@ public class TelephonyManager { /** * Write one of the NV items defined in com.android.internal.telephony.RadioNVItems. * Used for device configuration by some CDMA operators. - *

- * Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param itemID the ID of the item to read. * @param itemValue the value to write, as a String. @@ -4682,10 +4737,10 @@ public class TelephonyManager { /** * Update the CDMA Preferred Roaming List (PRL) in the radio NV storage. * Used for device configuration by some CDMA operators. - *

- * Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param preferredRoamingList byte array containing the new PRL. * @return true on success; false on any failure. @@ -4709,10 +4764,10 @@ public class TelephonyManager { * Perform the specified type of NV config reset. The radio will be taken offline * and the device must be rebooted after the operation. Used for device * configuration by some CDMA operators. - *

- * Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param resetType reset type: 1: reload NV reset, 2: erase NV reset, 3: factory NV reset * @return true on success; false on any failure. @@ -5060,8 +5115,8 @@ public class TelephonyManager { * Returns the response of authentication for the default subscription. * Returns null if the authentication hasn't been successful * - *

Requires that the calling app has carrier privileges or READ_PRIVILEGED_PHONE_STATE - * permission. + *

Requires Permission: READ_PRIVILEGED_PHONE_STATE or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param appType the icc application type, like {@link #APPTYPE_USIM} * @param authType the authentication type, {@link #AUTHTYPE_EAP_AKA} or @@ -5069,9 +5124,10 @@ public class TelephonyManager { * @param data authentication challenge data, base64 encoded. * See 3GPP TS 31.102 7.1.2 for more details. * @return the response of authentication, or null if not available - * - * @see #hasCarrierPrivileges */ + // TODO(b/73660190): This should probably require MODIFY_PHONE_STATE, not + // READ_PRIVILEGED_PHONE_STATE. It certainly shouldn't reference the permission in Javadoc since + // it's not public API. public String getIccAuthentication(int appType, int authType, String data) { return getIccAuthentication(getSubId(), appType, authType, data); } @@ -5080,7 +5136,7 @@ public class TelephonyManager { * Returns the response of USIM Authentication for specified subId. * Returns null if the authentication hasn't been successful * - *

Requires that the calling app has carrier privileges. + *

Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId subscription ID used for authentication * @param appType the icc application type, like {@link #APPTYPE_USIM} @@ -5089,8 +5145,6 @@ public class TelephonyManager { * @param data authentication challenge data, base64 encoded. * See 3GPP TS 31.102 7.1.2 for more details. * @return the response of authentication, or null if not available - * - * @see #hasCarrierPrivileges * @hide */ public String getIccAuthentication(int subId, int appType, int authType, String data) { @@ -5111,8 +5165,12 @@ public class TelephonyManager { * Returns an array of Forbidden PLMNs from the USIM App * Returns null if the query fails. * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * * @return an array of forbidden PLMNs or null if not available */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String[] getForbiddenPlmns() { return getForbiddenPlmns(getSubId(), APPTYPE_USIM); @@ -5318,10 +5376,10 @@ public class TelephonyManager { /** * Get the preferred network type. * Used for device configuration by some CDMA operators. - *

- * Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @return the preferred network type, defined in RILConstants.java. * @hide @@ -5341,11 +5399,12 @@ public class TelephonyManager { /** * Sets the network selection mode to automatic. - *

- * Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setNetworkSelectionModeAutomatic() { try { @@ -5361,15 +5420,14 @@ public class TelephonyManager { } /** - * Perform a radio scan and return the list of avialble networks. + * Perform a radio scan and return the list of available networks. * * The return value is a list of the OperatorInfo of the networks found. Note that this * scan can take a long time (sometimes minutes) to happen. * - *

- * Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @hide * TODO: Add an overload that takes no args. @@ -5393,17 +5451,16 @@ public class TelephonyManager { * This method is asynchronous, so the network scan results will be returned by callback. * The returned NetworkScan will contain a callback method which can be used to stop the scan. * - *

- * Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. - * @see #hasCarrierPrivileges() + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param request Contains all the RAT with bands/channels that need to be scanned. * @param executor The executor through which the callback should be invoked. * @param callback Returns network scan results or errors. * @return A NetworkScan obj which contains a callback which can be used to stop the scan. */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public NetworkScan requestNetworkScan( NetworkScanRequest request, Executor executor, @@ -5431,10 +5488,9 @@ public class TelephonyManager { /** * Ask the radio to connect to the input network and change selection mode to manual. * - *

- * Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param operatorNumeric the PLMN ID of the network to select. * @param persistSelection whether the selection will persist until reboot. If true, only allows @@ -5442,6 +5498,7 @@ public class TelephonyManager { * normal network selection next time. * @return true on success; false on any failure. */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setNetworkSelectionModeManual(String operatorNumeric, boolean persistSelection) { try { @@ -5461,10 +5518,10 @@ public class TelephonyManager { /** * Set the preferred network type. * Used for device configuration by some CDMA operators. - *

- * Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} - * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId the id of the subscription to set the preferred network type for. * @param networkType the preferred network type, defined in RILConstants.java. @@ -5488,9 +5545,7 @@ public class TelephonyManager { /** * Set the preferred network type to global mode which includes LTE, CDMA, EvDo and GSM/WCDMA. * - *

- * Requires that the calling app has carrier privileges. - * @see #hasCarrierPrivileges + *

Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @return true on success; false on any failure. */ @@ -5501,9 +5556,7 @@ public class TelephonyManager { /** * Set the preferred network type to global mode which includes LTE, CDMA, EvDo and GSM/WCDMA. * - *

- * Requires that the calling app has carrier privileges. - * @see #hasCarrierPrivileges + *

Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @return true on success; false on any failure. * @hide @@ -5593,8 +5646,7 @@ public class TelephonyManager { * brand value input. To unset the value, the same function should be * called with a null brand value. * - *

Requires that the calling app has carrier privileges. - * @see #hasCarrierPrivileges + *

Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param brand The brand name to display/set. * @return true if the operation was executed correctly. @@ -5611,8 +5663,7 @@ public class TelephonyManager { * brand value input. To unset the value, the same function should be * called with a null brand value. * - *

Requires that the calling app has carrier privileges. - * @see #hasCarrierPrivileges + *

Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param subId The subscription to use. * @param brand The brand name to display/set. @@ -6266,15 +6317,15 @@ public class TelephonyManager { * subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()} * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the - * calling app has carrier privileges. + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param enable Whether to enable mobile data. * - * @see #hasCarrierPrivileges * @deprecated use {@link #setUserMobileDataEnabled(boolean)} instead. */ @Deprecated + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataEnabled(boolean enable) { setUserMobileDataEnabled(enable); @@ -6311,7 +6362,7 @@ public class TelephonyManager { *

Requires one of the following permissions: * {@link android.Manifest.permission#ACCESS_NETWORK_STATE ACCESS_NETWORK_STATE}, * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}, or that the - * calling app has carrier privileges. + * calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * *

Note that this does not take into account any data restrictions that may be present on the * calling app. Such restrictions may be inspected with @@ -6319,7 +6370,6 @@ public class TelephonyManager { * * @return true if mobile data is enabled. * - * @see #hasCarrierPrivileges * @deprecated use {@link #isUserMobileDataEnabled()} instead. */ @Deprecated @@ -7090,7 +7140,11 @@ public class TelephonyManager { /** * Returns the current {@link ServiceState} information. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). */ + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public ServiceState getServiceState() { return getServiceStateForSubscriber(getSubId()); @@ -7136,14 +7190,14 @@ public class TelephonyManager { /** * Sets the per-account voicemail ringtone. * - *

Requires that the calling app is the default dialer, or has carrier privileges, or has - * permission {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. + *

Requires that the calling app is the default dialer, or has carrier privileges (see + * {@link #hasCarrierPrivileges}, or has permission + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. * * @param phoneAccountHandle The handle for the {@link PhoneAccount} for which to set the * voicemail ringtone. * @param uri The URI for the ringtone to play when receiving a voicemail from a specific * PhoneAccount. - * @see #hasCarrierPrivileges * * @deprecated Use {@link android.provider.Settings#ACTION_CHANNEL_NOTIFICATION_SETTINGS} * instead. @@ -7181,14 +7235,14 @@ public class TelephonyManager { /** * Sets the per-account preference whether vibration is enabled for voicemail notifications. * - *

Requires that the calling app is the default dialer, or has carrier privileges, or has - * permission {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. + *

Requires that the calling app is the default dialer, or has carrier privileges (see + * {@link #hasCarrierPrivileges}, or has permission + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. * * @param phoneAccountHandle The handle for the {@link PhoneAccount} for which to set the * voicemail vibration setting. * @param enabled Whether to enable or disable vibration for voicemail notifications from a * specific PhoneAccount. - * @see #hasCarrierPrivileges * * @deprecated Use {@link android.provider.Settings#ACTION_CHANNEL_NOTIFICATION_SETTINGS} * instead. @@ -7611,12 +7665,10 @@ public class TelephonyManager { * Otherwise, it applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()} * *

Requires Permission: - * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the - * calling app has carrier privileges. + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}. * * @param enable Whether to enable mobile data. - * - * @see #hasCarrierPrivileges */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setUserMobileDataEnabled(boolean enable) { @@ -7634,15 +7686,13 @@ public class TelephonyManager { *

Requires one of the following permissions: * {@link android.Manifest.permission#ACCESS_NETWORK_STATE ACCESS_NETWORK_STATE}, * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}, or that the - * calling app has carrier privileges. + * calling app has carrier privileges (see {@link #hasCarrierPrivileges}. * *

Note that this does not take into account any data restrictions that may be present on the * calling app. Such restrictions may be inspected with * {@link ConnectivityManager#getRestrictBackgroundStatus}. * * @return true if mobile data is enabled. - * - * @see #hasCarrierPrivileges */ @RequiresPermission(anyOf = { android.Manifest.permission.ACCESS_NETWORK_STATE, diff --git a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java b/telephony/java/com/android/internal/telephony/TelephonyPermissions.java index da8471fa19eda..a182f2be421fc 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java +++ b/telephony/java/com/android/internal/telephony/TelephonyPermissions.java @@ -26,7 +26,8 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.telephony.ITelephony; + +import java.util.function.Supplier; /** Utility class for Telephony permission enforcement. */ public final class TelephonyPermissions { @@ -34,6 +35,9 @@ public final class TelephonyPermissions { private static final boolean DBG = false; + private static final Supplier TELEPHONY_SUPPLIER = () -> + ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE)); + private TelephonyPermissions() {} /** @@ -41,8 +45,8 @@ public final class TelephonyPermissions { * *

This method behaves in one of the following ways: *

+ * + *

Note: for simplicity, this method always returns false for callers using legacy + * permissions and who have had READ_PHONE_STATE revoked, even if they are carrier-privileged. + * Such apps should migrate to runtime permissions or stop requiring READ_PHONE_STATE on P+ + * devices. + * + * @param subId the subId of the relevant subscription; used to check carrier privileges. May be + * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID} to skip this check for cases + * where it isn't relevant (hidden APIs, or APIs which are otherwise okay to leave + * inaccesible to carrier-privileged apps). */ public static boolean checkCallingOrSelfReadPhoneState( - Context context, String callingPackage, String message) { - return checkReadPhoneState(context, Binder.getCallingPid(), Binder.getCallingUid(), + Context context, int subId, String callingPackage, String message) { + return checkReadPhoneState(context, subId, Binder.getCallingPid(), Binder.getCallingUid(), callingPackage, message); } /** * Check whether the app with the given pid/uid can read phone state. * - *

This method behaves in one of the following ways: + *

This method behaves in one of the following ways: *

+ * + *

Note: for simplicity, this method always returns false for callers using legacy + * permissions and who have had READ_PHONE_STATE revoked, even if they are carrier-privileged. + * Such apps should migrate to runtime permissions or stop requiring READ_PHONE_STATE on P+ + * devices. */ public static boolean checkReadPhoneState( - Context context, int pid, int uid, String callingPackage, String message) { + Context context, int subId, int pid, int uid, String callingPackage, String message) { + return checkReadPhoneState( + context, TELEPHONY_SUPPLIER, subId, pid, uid, callingPackage, message); + } + + @VisibleForTesting + public static boolean checkReadPhoneState( + Context context, Supplier telephonySupplier, int subId, int pid, int uid, + String callingPackage, String message) { try { context.enforcePermission( android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, pid, uid, message); @@ -83,8 +110,18 @@ public final class TelephonyPermissions { // SKIP checking for run-time permission since caller has PRIVILEGED permission return true; } catch (SecurityException privilegedPhoneStateException) { - context.enforcePermission( - android.Manifest.permission.READ_PHONE_STATE, pid, uid, message); + try { + context.enforcePermission( + android.Manifest.permission.READ_PHONE_STATE, pid, uid, message); + } catch (SecurityException phoneStateException) { + // If we don't have the runtime permission, but do have carrier privileges, that + // suffices for reading phone state. + if (SubscriptionManager.isValidSubscriptionId(subId)) { + enforceCarrierPrivilege(telephonySupplier, subId, uid, message); + return true; + } + throw phoneStateException; + } } // We have READ_PHONE_STATE permission, so return true as long as the AppOps bit hasn't been @@ -101,14 +138,16 @@ public final class TelephonyPermissions { * default SMS app and apps with READ_SMS or READ_PHONE_NUMBERS can also read phone numbers. */ public static boolean checkCallingOrSelfReadPhoneNumber( - Context context, String callingPackage, String message) { + Context context, int subId, String callingPackage, String message) { return checkReadPhoneNumber( - context, Binder.getCallingPid(), Binder.getCallingUid(), callingPackage, message); + context, TELEPHONY_SUPPLIER, subId, Binder.getCallingPid(), Binder.getCallingUid(), + callingPackage, message); } @VisibleForTesting public static boolean checkReadPhoneNumber( - Context context, int pid, int uid, String callingPackage, String message) { + Context context, Supplier telephonySupplier, int subId, int pid, int uid, + String callingPackage, String message) { // Default SMS app can always read it. AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); if (appOps.noteOp(AppOpsManager.OP_WRITE_SMS, uid, callingPackage) == @@ -121,7 +160,8 @@ public final class TelephonyPermissions { // First, check if we can read the phone state. try { - return checkReadPhoneState(context, pid, uid, callingPackage, message); + return checkReadPhoneState( + context, telephonySupplier, subId, pid, uid, callingPackage, message); } catch (SecurityException readPhoneStateSecurityException) { } // Can be read with READ_SMS too. @@ -186,16 +226,21 @@ public final class TelephonyPermissions { } private static void enforceCarrierPrivilege(int subId, int uid, String message) { - if (getCarrierPrivilegeStatus(subId, uid) != + enforceCarrierPrivilege(TELEPHONY_SUPPLIER, subId, uid, message); + } + + private static void enforceCarrierPrivilege( + Supplier telephonySupplier, int subId, int uid, String message) { + if (getCarrierPrivilegeStatus(telephonySupplier, subId, uid) != TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { if (DBG) Rlog.e(LOG_TAG, "No Carrier Privilege."); throw new SecurityException(message); } } - private static int getCarrierPrivilegeStatus(int subId, int uid) { - ITelephony telephony = - ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE)); + private static int getCarrierPrivilegeStatus( + Supplier telephonySupplier, int subId, int uid) { + ITelephony telephony = telephonySupplier.get(); try { if (telephony != null) { return telephony.getCarrierPrivilegeStatusForUid(subId, uid);