Loading services/core/java/com/android/server/TelephonyRegistry.java +8 −4 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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; } Loading Loading @@ -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; } } Loading telephony/java/android/telephony/SubscriptionManager.java +33 −4 Original line number Diff line number Diff line Loading @@ -17,9 +17,11 @@ package android.telephony; import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SystemApi; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SuppressAutoDoc; import android.annotation.SystemApi; import android.annotation.SystemService; import android.content.Context; import android.content.Intent; Loading Loading @@ -47,9 +49,6 @@ import java.util.List; /** * SubscriptionManager is the application interface to SubscriptionController * and provides information about the current Telephony Subscriptions. * <p> * All SDK public methods require android.Manifest.permission.READ_PHONE_STATE unless otherwise * specified. */ @SystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) public class SubscriptionManager { Loading Loading @@ -542,6 +541,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() : "<unknown>"; if (DBG) { Loading Loading @@ -590,9 +591,15 @@ public class SubscriptionManager { /** * Get the active SubscriptionInfo with the input subId. * * <p>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)) { Loading Loading @@ -646,9 +653,16 @@ public class SubscriptionManager { /** * Get the active SubscriptionInfo associated with the slotIndex * * <p>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)) { Loading Loading @@ -700,6 +714,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}. * * <p>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. * <ul> * <li> Loading @@ -716,6 +735,8 @@ public class SubscriptionManager { * </li> * </ul> */ @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public List<SubscriptionInfo> getActiveSubscriptionInfoList() { List<SubscriptionInfo> result = null; Loading Loading @@ -858,10 +879,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; Loading Loading
services/core/java/com/android/server/TelephonyRegistry.java +8 −4 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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; } Loading Loading @@ -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; } } Loading
telephony/java/android/telephony/SubscriptionManager.java +33 −4 Original line number Diff line number Diff line Loading @@ -17,9 +17,11 @@ package android.telephony; import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SystemApi; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SuppressAutoDoc; import android.annotation.SystemApi; import android.annotation.SystemService; import android.content.Context; import android.content.Intent; Loading Loading @@ -47,9 +49,6 @@ import java.util.List; /** * SubscriptionManager is the application interface to SubscriptionController * and provides information about the current Telephony Subscriptions. * <p> * All SDK public methods require android.Manifest.permission.READ_PHONE_STATE unless otherwise * specified. */ @SystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) public class SubscriptionManager { Loading Loading @@ -542,6 +541,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() : "<unknown>"; if (DBG) { Loading Loading @@ -590,9 +591,15 @@ public class SubscriptionManager { /** * Get the active SubscriptionInfo with the input subId. * * <p>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)) { Loading Loading @@ -646,9 +653,16 @@ public class SubscriptionManager { /** * Get the active SubscriptionInfo associated with the slotIndex * * <p>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)) { Loading Loading @@ -700,6 +714,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}. * * <p>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. * <ul> * <li> Loading @@ -716,6 +735,8 @@ public class SubscriptionManager { * </li> * </ul> */ @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public List<SubscriptionInfo> getActiveSubscriptionInfoList() { List<SubscriptionInfo> result = null; Loading Loading @@ -858,10 +879,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; Loading