From 8931707058c2680878aacc5e6b4150a9aedc0f4d 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 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 317c8ff9ae05c..6a101a29f308e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -39360,6 +39360,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 139a39d00a2bd..9457309574f26 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -42750,6 +42750,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 53666d5b1475e..d2fd35619e30d 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -39565,6 +39565,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 8bfe4131d7cbc..1874d8d04723e 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 87402243a4523..8ebac2c6273a7 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 */