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/core/api/current.txt b/core/api/current.txt
index d46d07e..dc6f379 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -42778,6 +42778,7 @@
method @Deprecated @RequiresPermission(android.Manifest.permission.ANSWER_PHONE_CALLS) public boolean endCall();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.net.Uri getAdnUriForPhoneAccount(android.telecom.PhoneAccountHandle);
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public java.util.List<android.telecom.PhoneAccountHandle> getCallCapablePhoneAccounts();
+ method @FlaggedApi("com.android.internal.telephony.flags.work_profile_api_split") @NonNull @RequiresPermission(allOf={android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.INTERACT_ACROSS_PROFILES}) public java.util.List<android.telecom.PhoneAccountHandle> getCallCapablePhoneAccountsAcrossProfiles();
method public String getDefaultDialerPackage();
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public android.telecom.PhoneAccountHandle getDefaultOutgoingPhoneAccount(String);
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);
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index a1465df..3d23c520 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -13505,6 +13505,7 @@
method public java.util.List<android.telecom.PhoneAccount> getAllPhoneAccounts();
method public int getAllPhoneAccountsCount();
method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.telecom.PhoneAccountHandle> getCallCapablePhoneAccounts(boolean);
+ method @FlaggedApi("com.android.internal.telephony.flags.work_profile_api_split") @NonNull @RequiresPermission(allOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.INTERACT_ACROSS_PROFILES}) public java.util.List<android.telecom.PhoneAccountHandle> getCallCapablePhoneAccountsAcrossProfiles(boolean);
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}, conditional=true) public int getCallState();
method public android.telecom.PhoneAccountHandle getConnectionManager();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getCurrentTtyMode();
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
diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
index 53154e6..f1bfd22 100644
--- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
+++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
@@ -61,7 +61,8 @@
* @see TelecomServiceImpl#getCallCapablePhoneAccounts
*/
ParceledListSlice<PhoneAccountHandle> getCallCapablePhoneAccounts(
- boolean includeDisabledAccounts, String callingPackage, String callingFeatureId);
+ boolean includeDisabledAccounts, String callingPackage,
+ String callingFeatureId, boolean acrossProfiles);
/**
* @see TelecomServiceImpl#getSelfManagedPhoneAccounts