diff --git a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java index bcd8be7b63e03..2f8b5130edb0d 100644 --- a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +++ b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java @@ -1171,7 +1171,8 @@ public class AppStandbyController implements AppStandbyInternal { private void fetchCarrierPrivilegedAppsLocked() { TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class); - mCarrierPrivilegedApps = telephonyManager.getPackagesWithCarrierPrivilegesForAllPhones(); + mCarrierPrivilegedApps = + telephonyManager.getCarrierPrivilegedPackagesForAllActiveSubscriptions(); mHaveCarrierPrivilegedApps = true; if (DEBUG) { Slog.d(TAG, "apps with carrier privilege " + mCarrierPrivilegedApps); diff --git a/api/system-current.txt b/api/system-current.txt index fb7ec01661702..f2e08de9e8742 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9384,6 +9384,7 @@ package android.telephony { method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int); method public java.util.List getCarrierPackageNamesForIntent(android.content.Intent); method public java.util.List getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int); + method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List getCarrierPrivilegedPackagesForAllActiveSubscriptions(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.CarrierRestrictionRules getCarrierRestrictionRules(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String getCdmaMdn(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String getCdmaMdn(int); diff --git a/services/tests/servicestests/AndroidManifest.xml b/services/tests/servicestests/AndroidManifest.xml index fb42507f87c23..3a07a692ecdd2 100644 --- a/services/tests/servicestests/AndroidManifest.xml +++ b/services/tests/servicestests/AndroidManifest.xml @@ -40,6 +40,7 @@ + diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index fc26122912dc4..d1f10e78d771c 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -8172,17 +8172,25 @@ public class TelephonyManager { return Collections.EMPTY_LIST; } - /** @hide */ - public List getPackagesWithCarrierPrivilegesForAllPhones() { + /** + * Get the names of packages with carrier privileges for all the active subscriptions. + * + * @hide + */ + @SystemApi + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @NonNull + public List getCarrierPrivilegedPackagesForAllActiveSubscriptions() { try { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.getPackagesWithCarrierPrivilegesForAllPhones(); } } catch (RemoteException ex) { - Rlog.e(TAG, "getPackagesWithCarrierPrivilegesForAllPhones RemoteException", ex); + Rlog.e(TAG, "getCarrierPrivilegedPackagesForAllActiveSubscriptions RemoteException", + ex); } catch (NullPointerException ex) { - Rlog.e(TAG, "getPackagesWithCarrierPrivilegesForAllPhones NPE", ex); + Rlog.e(TAG, "getCarrierPrivilegedPackagesForAllActiveSubscriptions NPE", ex); } return Collections.EMPTY_LIST; }