TelecomManager consolidate isInSelfManagedCall.
As per API feedback, consolidate TelecomManager#isInSelfManagedCall into
a single API which only takes a UserHandle and disregard the
hasCrossUserAccess parameter. Instead, the caller can specify
UserHandle.ALL in order to indicate that self managed calls across all
users should be checked.
Bug: 327029478
Bug: 311773409
Test: atest SelfManagedConnectionServiceTest
Change-Id: Icbffaf8d2a507f519eb2fda34106a359f1bddaf4
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 9792cdd..744b48a 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -2794,7 +2794,9 @@
/**
* Determines whether there are any ongoing {@link PhoneAccount#CAPABILITY_SELF_MANAGED}
- * calls for a given {@code packageName} and {@code userHandle}.
+ * calls for a given {@code packageName} and {@code userHandle}. If UserHandle.ALL or a user
+ * that isn't the calling user is passed in, the caller will need to have granted the ability
+ * to interact across users.
*
* @param packageName the package name of the app to check calls for.
* @param userHandle the user handle to check calls for.
@@ -2813,41 +2815,7 @@
if (service != null) {
try {
return service.isInSelfManagedCall(packageName, userHandle,
- mContext.getOpPackageName(), false);
- } catch (RemoteException e) {
- Log.e(TAG, "RemoteException isInSelfManagedCall: " + e);
- e.rethrowFromSystemServer();
- return false;
- }
- } else {
- throw new IllegalStateException("Telecom service is not present");
- }
- }
-
- /**
- * Determines whether there are any ongoing {@link PhoneAccount#CAPABILITY_SELF_MANAGED}
- * calls for a given {@code packageName} amongst all users, given that detectForAllUsers is true
- * and the caller has the ability to interact across users. If detectForAllUsers isn't enabled,
- * the calls will be checked against the caller.
- *
- * @param packageName the package name of the app to check calls for.
- * @param detectForAllUsers indicates if calls should be detected across all users.
- * @return {@code true} if there are ongoing calls, {@code false} otherwise.
- * @throws SecurityException if detectForAllUsers is true and the caller does not grant the
- * ability to interact across users.
- * @hide
- */
- @SystemApi
- @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES)
- @RequiresPermission(allOf = {Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
- Manifest.permission.INTERACT_ACROSS_USERS}, conditional = true)
- public boolean isInSelfManagedCall(@NonNull String packageName,
- boolean detectForAllUsers) {
- ITelecomService service = getTelecomService();
- if (service != null) {
- try {
- return service.isInSelfManagedCall(packageName, null,
- mContext.getOpPackageName(), detectForAllUsers);
+ mContext.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "RemoteException isInSelfManagedCall: " + e);
e.rethrowFromSystemServer();