Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4dc98dcc authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Separate TelecomManager#isInSelfManagedCall APIs

Instead of consolidating the TelecomManager#isInSelfManagedCall APIs
which combine the cross user logic with the ability to also specifiy a
user handle, create two separate APIs to handle this. One will allow the
caller to specify a user handle while the other will allow them to
specify if calls should be verified across all users.

Ensure that if the user handle specified isn't the caller or that
interacting across users is defined in the parameter, that the
permission check is enforced properly. Otherwise, ensure that the user
handle being verified is always the caller.

Bug: 323958718
Bug: 311773409
Test: atest SelfManagedConnectionServiceTest
Change-Id: I8fe3d8ca77898d98e92cf86b9a5fb3df0811a5fc
parent 11318e56
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -2509,8 +2509,9 @@ public class TelecomServiceImpl {
         * @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
@@ -2521,8 +2522,13 @@ public class TelecomServiceImpl {
                        "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));