Update phone account APIs for work profile split mode
Bug: 296067229
Test: atest CtsTelecomTestCases
Test: manual with test app
Change-Id: I9e0e4785ef400000661fa74259d477ca60d0c493
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index b167f1b..d05eb5c 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -1349,6 +1349,24 @@
}
/**
+ * Returns a list of {@link PhoneAccountHandle}s which can be used to make and receive phone
+ * calls. The returned list includes those accounts which have been explicitly enabled by
+ * the user or other users visible to the user.
+ *
+ * @see #EXTRA_PHONE_ACCOUNT_HANDLE
+ * @return A list of {@code PhoneAccountHandle} objects.
+ *
+ * @throws IllegalStateException if telecom service is null.
+ */
+ @FlaggedApi(com.android.internal.telephony.flags.Flags.FLAG_WORK_PROFILE_API_SPLIT)
+ @RequiresPermission(allOf = {android.Manifest.permission.READ_PHONE_STATE,
+ android.Manifest.permission.INTERACT_ACROSS_PROFILES})
+ public @NonNull List<PhoneAccountHandle> getCallCapablePhoneAccountsAcrossProfiles() {
+ return getCallCapablePhoneAccountsAcrossProfiles(false);
+ }
+
+
+ /**
* Returns a list of {@link PhoneAccountHandle}s for all self-managed
* {@link ConnectionService}s owned by the calling {@link UserHandle}.
* <p>
@@ -1423,7 +1441,7 @@
if (service != null) {
try {
return service.getCallCapablePhoneAccounts(includeDisabledAccounts,
- mContext.getOpPackageName(), mContext.getAttributionTag()).getList();
+ mContext.getOpPackageName(), mContext.getAttributionTag(), false).getList();
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts("
+ includeDisabledAccounts + ")", e);
@@ -1433,6 +1451,37 @@
}
/**
+ * Returns a list of {@link PhoneAccountHandle}s visible to current user including those which
+ * have not been enabled by the user.
+ *
+ * @param includeDisabledAccounts When {@code true}, disabled phone accounts will be included,
+ * when {@code false}, only enabled phone accounts will be
+ * included.
+ * @return A list of {@code PhoneAccountHandle} objects.
+ *
+ * @throws IllegalStateException if telecom service is null.
+ * @hide
+ */
+ @SystemApi
+ @FlaggedApi(com.android.internal.telephony.flags.Flags.FLAG_WORK_PROFILE_API_SPLIT)
+ @RequiresPermission(allOf = {android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
+ android.Manifest.permission.INTERACT_ACROSS_PROFILES})
+ public @NonNull List<PhoneAccountHandle> getCallCapablePhoneAccountsAcrossProfiles(
+ boolean includeDisabledAccounts) {
+ ITelecomService service = getTelecomService();
+ if (service == null) {
+ throw new IllegalStateException("telecom service is null.");
+ }
+
+ try {
+ return service.getCallCapablePhoneAccounts(includeDisabledAccounts,
+ mContext.getOpPackageName(), mContext.getAttributionTag(), true).getList();
+ } catch (RemoteException e) {
+ throw e.rethrowAsRuntimeException();
+ }
+ }
+
+ /**
* Returns a list of all {@link PhoneAccount}s registered for the calling package.
*
* @deprecated Use {@link #getSelfManagedPhoneAccounts()} instead to get only self-managed