summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Thomas Stuart <tjstuart@google.com> 2024-01-04 16:03:34 -0800
committer Thomas Stuart <tjstuart@google.com> 2024-02-16 17:55:58 +0000
commit1a9c30a46554f6dc970dbea08e51a3b1e8b2f8c8 (patch)
treecbf420fcdaab5f6b720559b8c5bb9df60b1f0e86
parentcb27fa5a3c50283eaab05e5dbca790278ceb0388 (diff)
add API for getRegisteredPhoneAccounts
currently there is no way for VoIP applications to fetch their registered PhoneAccounts with Telecom. TelecomManager#getPhoneAccount is gated by the READ_PHONE_STATE permission which is a highly privileged permission that VoIP apps will not be granted. This API will not only allow VoIP apps to get all registered PhoneAccounts with Telecom but Managed apps (like system Dialers) can use it. This is helpful to know what calling capabilities are currently registered and know the state of Telecom. Bug: 307609763 Test: CTS coverage Change-Id: I73ace8cd766369f877c7fc0ef985f6a0c575e097
-rw-r--r--core/api/current.txt1
-rw-r--r--telecomm/java/android/telecom/TelecomManager.java25
-rw-r--r--telecomm/java/com/android/internal/telecom/ITelecomService.aidl6
3 files changed, 32 insertions, 0 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index c141490e6202..25765cfadcf0 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -43248,6 +43248,7 @@ package android.telecom {
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<android.telecom.PhoneAccountHandle> getOwnSelfManagedPhoneAccounts();
method public android.telecom.PhoneAccount getPhoneAccount(android.telecom.PhoneAccountHandle);
+ method @FlaggedApi("com.android.server.telecom.flags.get_registered_phone_accounts") @NonNull public java.util.List<android.telecom.PhoneAccount> getRegisteredPhoneAccounts();
method @NonNull @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public java.util.List<android.telecom.PhoneAccountHandle> getSelfManagedPhoneAccounts();
method public android.telecom.PhoneAccountHandle getSimCallManager();
method @Nullable public android.telecom.PhoneAccountHandle getSimCallManagerForSubscription(int);
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 15a978d167e1..08c76af70511 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -1434,6 +1434,31 @@ public class TelecomManager {
}
/**
+ * This API will return all {@link PhoneAccount}s registered via
+ * {@link TelecomManager#registerPhoneAccount(PhoneAccount)}. If a {@link PhoneAccount} appears
+ * to be missing from the list, Telecom has either unregistered the {@link PhoneAccount}
+ * or the caller registered the {@link PhoneAccount} under a different user and does not
+ * have the {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
+ *
+ * @return all the {@link PhoneAccount}s registered by the caller.
+ */
+ @SuppressLint("RequiresPermission")
+ @FlaggedApi(Flags.FLAG_GET_REGISTERED_PHONE_ACCOUNTS)
+ public @NonNull List<PhoneAccount> getRegisteredPhoneAccounts() {
+ ITelecomService service = getTelecomService();
+ if (service != null) {
+ try {
+ return service.getRegisteredPhoneAccounts(
+ mContext.getOpPackageName(),
+ mContext.getAttributionTag()).getList();
+ } 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 7dba799e1057..302a472b77e4 100644
--- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
+++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
@@ -93,6 +93,12 @@ interface ITelecomService {
PhoneAccount getPhoneAccount(in PhoneAccountHandle account, String callingPackage);
/**
+ * @see TelecomManager#getPhoneAccount
+ */
+ ParceledListSlice<PhoneAccount> getRegisteredPhoneAccounts(String callingPackage,
+ String callingFeatureId);
+
+ /**
* @see TelecomManager#getAllPhoneAccountsCount
*/
int getAllPhoneAccountsCount();