summaryrefslogtreecommitdiff
path: root/telecomm/java/android
diff options
context:
space:
mode:
author Thomas Stuart <tjstuart@google.com> 2022-01-28 23:06:57 +0000
committer Thomas Stuart <tjstuart@google.com> 2022-02-28 16:39:38 +0000
commit4e1184dc2698209e7885cb37ff5eaec75ce804b2 (patch)
treec3a854a1e1d481878c8ae52ef39cb01378cd0b79 /telecomm/java/android
parent09076f0af2715438fd5ceeb052424f1ee0c936cf (diff)
decouple TelecomManager#getSelfManagedPhoneAccounts (2/3)
Recently TelecomManager#getSelfManagedPhoneAccounts was updated to allow callingPackages to get their PA's. However, API council noted there was ambiguity with what was returned from the method. Thus the method has been decoupled into 2 methods. bug: 216640181 Test: CTS Change-Id: Idbcb4740f5a5d7fdf5bedb9d9f6173eef0cb3f17
Diffstat (limited to 'telecomm/java/android')
-rw-r--r--telecomm/java/android/telecom/TelecomManager.java51
1 files changed, 35 insertions, 16 deletions
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index f43e5aacad33..df114dbabe5b 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}.
* <p>
* Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with
* {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
* <p>
* Requires permission {@link android.Manifest.permission#READ_PHONE_STATE}, or that the caller
- * is the default dialer app to get all phone account handles.
- * <P>
- * 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.
* <p>
- * 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<PhoneAccountHandle> getSelfManagedPhoneAccounts() {
+ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
+ public @NonNull List<PhoneAccountHandle> getSelfManagedPhoneAccounts() {
ITelecomService service = getTelecomService();
if (service != null) {
try {
@@ -1330,6 +1321,34 @@ public class TelecomManager {
}
/**
+ * Returns a list of {@link PhoneAccountHandle}s owned by the calling self-managed
+ * {@link ConnectionService}.
+ * <p>
+ * Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with
+ * {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
+ * <p>
+ * Requires permission {@link android.Manifest.permission#MANAGE_OWN_CALLS}
+ * <p>
+ * 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<PhoneAccountHandle> 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.
*