From b6ce026fd1c4d27f3d36b361262f8c043573d801 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Fri, 7 Apr 2017 14:57:37 -0700 Subject: [PATCH] Add getSelfManagedPhoneAccounts() TelecomManager API. This is consistent with the existing getCallCapablePhoneAccounts API which is used to get the phone accounts capable of placing phone calls. Test: CTS Bug: 34159263 Merged-In: I1396c63a6882947cd66721528e53b6964a9091e0 Change-Id: I1396c63a6882947cd66721528e53b6964a9091e0 --- api/current.txt | 1 + api/system-current.txt | 1 + api/test-current.txt | 1 + .../java/android/telecom/TelecomManager.java | 26 +++++++++++++++++++ .../internal/telecom/ITelecomService.aidl | 5 ++++ 5 files changed, 34 insertions(+) diff --git a/api/current.txt b/api/current.txt index 1a6ae5ca4220a..dc2daecc25d1b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -37459,6 +37459,7 @@ package android.telecom { method public android.telecom.PhoneAccountHandle getDefaultOutgoingPhoneAccount(java.lang.String); method public java.lang.String getLine1Number(android.telecom.PhoneAccountHandle); method public android.telecom.PhoneAccount getPhoneAccount(android.telecom.PhoneAccountHandle); + method public java.util.List getSelfManagedPhoneAccounts(); method public android.telecom.PhoneAccountHandle getSimCallManager(); method public java.lang.String getVoiceMailNumber(android.telecom.PhoneAccountHandle); method public boolean handleMmi(java.lang.String); diff --git a/api/system-current.txt b/api/system-current.txt index 12a0b0ede129e..9271c721a2440 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -40625,6 +40625,7 @@ package android.telecom { method public android.telecom.PhoneAccount getPhoneAccount(android.telecom.PhoneAccountHandle); method public java.util.List getPhoneAccountsForPackage(); method public java.util.List getPhoneAccountsSupportingScheme(java.lang.String); + method public java.util.List getSelfManagedPhoneAccounts(); method public android.telecom.PhoneAccountHandle getSimCallManager(); method public java.lang.String getVoiceMailNumber(android.telecom.PhoneAccountHandle); method public boolean handleMmi(java.lang.String); diff --git a/api/test-current.txt b/api/test-current.txt index a0362b42e8fd1..70e097f2b84bb 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -37558,6 +37558,7 @@ package android.telecom { method public android.telecom.PhoneAccountHandle getDefaultOutgoingPhoneAccount(java.lang.String); method public java.lang.String getLine1Number(android.telecom.PhoneAccountHandle); method public android.telecom.PhoneAccount getPhoneAccount(android.telecom.PhoneAccountHandle); + method public java.util.List getSelfManagedPhoneAccounts(); method public android.telecom.PhoneAccountHandle getSimCallManager(); method public java.lang.String getVoiceMailNumber(android.telecom.PhoneAccountHandle); method public boolean handleMmi(java.lang.String); diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 5093a6122b0cd..94c3dfe593115 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -754,6 +754,32 @@ public class TelecomManager { return getCallCapablePhoneAccounts(false); } + /** + * Returns a list of {@link PhoneAccountHandle}s for self-managed {@link ConnectionService}s. + *

+ * 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. + *

+ * 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(android.Manifest.permission.READ_PHONE_STATE) + public List getSelfManagedPhoneAccounts() { + try { + if (isServiceConnected()) { + return getTelecomService().getSelfManagedPhoneAccounts(mContext.getOpPackageName()); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelecomService#getSelfManagedPhoneAccounts()", e); + } + return new ArrayList<>(); + } + /** * 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 c044742a1b0b8..86f7d7dfb61f9 100644 --- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl +++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl @@ -58,6 +58,11 @@ interface ITelecomService { List getCallCapablePhoneAccounts( boolean includeDisabledAccounts, String callingPackage); + /** + * @see TelecomServiceImpl#getSelfManagedPhoneAccounts + */ + List getSelfManagedPhoneAccounts(String callingPackage); + /** * @see TelecomManager#getPhoneAccountsSupportingScheme */