diff --git a/core/api/current.txt b/core/api/current.txt index 4ab172d98d351..cd0bd86997943 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -40754,8 +40754,9 @@ package android.telecom { method public String getDefaultDialerPackage(); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public android.telecom.PhoneAccountHandle getDefaultOutgoingPhoneAccount(String); method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.READ_SMS, android.Manifest.permission.READ_PHONE_NUMBERS}, conditional=true) public String getLine1Number(android.telecom.PhoneAccountHandle); + method @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_OWN_CALLS) public java.util.List getOwnSelfManagedPhoneAccounts(); method public android.telecom.PhoneAccount getPhoneAccount(android.telecom.PhoneAccountHandle); - method @RequiresPermission(anyOf={"android.permission.READ_PRIVILEGED_PHONE_STATE", android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.MANAGE_OWN_CALLS}) public java.util.List getSelfManagedPhoneAccounts(); + method @NonNull @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public java.util.List getSelfManagedPhoneAccounts(); method public android.telecom.PhoneAccountHandle getSimCallManager(); method @Nullable public android.telecom.PhoneAccountHandle getSimCallManagerForSubscription(int); method @Nullable public String getSystemDialerPackage(); diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index f43e5aacad335..df114dbabe5b8 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -1292,31 +1292,22 @@ public class TelecomManager { } /** - * Returns a list of {@link PhoneAccountHandle}s for self-managed {@link ConnectionService}s. + * Returns a list of {@link PhoneAccountHandle}s for all self-managed + * {@link ConnectionService}s owned by the calling {@link UserHandle}. *

* Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with * {@link PhoneAccount#CAPABILITY_SELF_MANAGED}. *

* Requires permission {@link android.Manifest.permission#READ_PHONE_STATE}, or that the caller - * is the default dialer app to get all phone account handles. - *

- * If the caller doesn't meet any of the above requirements and has {@link - * android.Manifest.permission#MANAGE_OWN_CALLS}, the caller can get only the phone account - * handles they have registered. + * is the default dialer app. *

- * A {@link SecurityException} will be thrown if the caller is not the default dialer - * or the caller does not have at least one of the following permissions: - * {@link android.Manifest.permission#READ_PHONE_STATE} permission, - * {@link android.Manifest.permission#MANAGE_OWN_CALLS} permission + * A {@link SecurityException} will be thrown if a called is not the default dialer, or lacks + * the {@link android.Manifest.permission#READ_PHONE_STATE} permission. * * @return A list of {@code PhoneAccountHandle} objects. */ - @RequiresPermission(anyOf = { - READ_PRIVILEGED_PHONE_STATE, - android.Manifest.permission.READ_PHONE_STATE, - android.Manifest.permission.MANAGE_OWN_CALLS - }) - public List getSelfManagedPhoneAccounts() { + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) + public @NonNull List getSelfManagedPhoneAccounts() { ITelecomService service = getTelecomService(); if (service != null) { try { @@ -1329,6 +1320,34 @@ public class TelecomManager { return new ArrayList<>(); } + /** + * Returns a list of {@link PhoneAccountHandle}s owned by the calling self-managed + * {@link ConnectionService}. + *

+ * Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with + * {@link PhoneAccount#CAPABILITY_SELF_MANAGED}. + *

+ * Requires permission {@link android.Manifest.permission#MANAGE_OWN_CALLS} + *

+ * A {@link SecurityException} will be thrown if a caller lacks the + * {@link android.Manifest.permission#MANAGE_OWN_CALLS} permission. + * + * @return A list of {@code PhoneAccountHandle} objects. + */ + @RequiresPermission(Manifest.permission.MANAGE_OWN_CALLS) + public @NonNull List getOwnSelfManagedPhoneAccounts() { + ITelecomService service = getTelecomService(); + if (service != null) { + try { + return service.getOwnSelfManagedPhoneAccounts(mContext.getOpPackageName(), + mContext.getAttributionTag()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + throw new IllegalStateException("Telecom is not available"); + } + /** * Returns a list of {@link PhoneAccountHandle}s including those which have not been enabled * by the user. diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl index b9936ce2e1b26..9999c897d1b69 100644 --- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl +++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl @@ -65,6 +65,12 @@ interface ITelecomService { List getSelfManagedPhoneAccounts(String callingPackage, String callingFeatureId); + /** + * @see TelecomServiceImpl#getOwnSelfManagedPhoneAccounts + */ + List getOwnSelfManagedPhoneAccounts(String callingPackage, + String callingFeatureId); + /** * @see TelecomManager#getPhoneAccountsSupportingScheme */