Resolve API feedback TelecomManager#isInSelfManagedCall

As part of the mainline work, feedback has given to change the
hasCrossUserAccess param to better match the description. The
INTERACT_ACROSS_USERS permission has also been made an optional
parameter which is enforced when the user handle passed in doesn't match
the calling user or when the detectForAllUsers parameter is set to true.

Bug: 323958718
Bug: 311773409
Test: atest SelfManagedConnectionServiceTest
Change-Id: I96c04249e6320bde355a1efeddf0374048b84198
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index e62bd90..3daa014 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -2753,23 +2753,25 @@
      *
      * @param packageName the package name of the app to check calls for.
      * @param userHandle the user handle on which to check for calls.
-     * @param hasCrossUserAccess indicates if calls should be detected across all users.
+     * @param detectForAllUsers indicates if calls should be detected across all users. If it is
+     *                          set to {@code true}, and the caller has the ability to interact
+     *                          across users, the userHandle parameter is disregarded.
      * @return {@code true} if there are ongoing calls, {@code false} otherwise.
+     * @throws SecurityException if detectForAllUsers is true or userHandle is not the calling user
+     * and the caller does not grant the ability to interact across users.
      * @hide
      */
     @SystemApi
     @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES)
-    @RequiresPermission(allOf = {
-            android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
-            Manifest.permission.INTERACT_ACROSS_USERS
-    })
+    @RequiresPermission(allOf = {Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
+            Manifest.permission.INTERACT_ACROSS_USERS}, conditional = true)
     public boolean isInSelfManagedCall(@NonNull String packageName,
-            @NonNull UserHandle userHandle, boolean hasCrossUserAccess) {
+            @NonNull UserHandle userHandle, boolean detectForAllUsers) {
         ITelecomService service = getTelecomService();
         if (service != null) {
             try {
                 return service.isInSelfManagedCall(packageName, userHandle,
-                        mContext.getOpPackageName(), hasCrossUserAccess);
+                        mContext.getOpPackageName(), detectForAllUsers);
             } catch (RemoteException e) {
                 Log.e(TAG, "RemoteException isInSelfManagedCall: " + e);
                 e.rethrowFromSystemServer();