Merge "Separate TelecomManager#isInSelfManagedCall APIs" into main
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index aa721d4..f3d91f1 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -2563,8 +2563,9 @@
* @param packageName the package name of the app to check calls for.
* @param userHandle the user handle on which to check for calls.
* @param callingPackage The caller's package name.
- * @param detectForAllUsers indicates if calls should be detected across all users. If it is
- * set to true, the userHandle parameter is disregarded.
+ * @param detectForAllUsers indicates if calls should be detected across all users. If the
+ * caller does not have the ability to interact across users, get
+ * managed calls for the caller instead.
* @return {@code true} if there are ongoing calls, {@code false} otherwise.
*/
@Override
@@ -2575,8 +2576,13 @@
"READ_PRIVILEGED_PHONE_STATE required.");
// Ensure that the caller has the INTERACT_ACROSS_USERS permission if it's trying
// to access calls that don't belong to it.
- if (detectForAllUsers || !Binder.getCallingUserHandle().equals(userHandle)) {
+ if (detectForAllUsers || (userHandle != null
+ && !Binder.getCallingUserHandle().equals(userHandle))) {
enforceInAppCrossUserPermission();
+ } else {
+ // If INTERACT_ACROSS_USERS doesn't need to be enforced, ensure that the user
+ // being checked is the caller.
+ userHandle = Binder.getCallingUserHandle();
}
Log.startSession("TSI.iISMC", Log.getPackageAbbreviation(callingPackage));