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

Commit 5d272d0a authored by Kenneth Ford's avatar Kenneth Ford
Browse files

Update cancel device state request to require foreground for cts compat

Previous change in ag/28368952 made the requirements to cancel
a device state request too open, which caused cts compat issues.
This change reduces the ability to cancel a state request, to
requiring that a process is in the foreground while not being
required to be the top app. This allows a process in Picture in
Picture to be able to cancel the state request.

Test: DeviceStateManagerTests
Test: ExtensionRearDisplayPresentationTest
Bug: 358004667
Flag: android.hardware.devicestate.feature.flags.device_state_requester_cancel_state
Change-Id: I435a2f6b2910abd54e85c3bc0a5424deee67d67a
parent 94abf8c1
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1002,9 +1002,9 @@ public final class DeviceStateManagerService extends SystemService {

    /**
     * Checks if the process can cancel a device state request. If the calling process ID is not
     * both the top app and foregrounded nor does the process ID and userID match the IDs that made
     * the device state request, then check if this process holds the CONTROL_DEVICE_STATE
     * permission.
     * both the top app and foregrounded, verify that the calling process is in the foreground and
     * that it matches the process ID and user ID that made the device state request. If neither are
     * true, then check if this process holds the CONTROL_DEVICE_STATE permission.
     *
     * @param callingPid Process ID that is requesting this state change
     * @param callingUid UID that is requesting this state change
@@ -1018,8 +1018,8 @@ public final class DeviceStateManagerService extends SystemService {
        if (Flags.deviceStateRequesterCancelState()) {
            synchronized (mLock) {
                isAllowedToControlState =
                        isAllowedToControlState || doCallingIdsMatchOverrideRequestIdsLocked(
                                callingPid, callingUid);
                        isTopApp || (isForegroundApp && doCallingIdsMatchOverrideRequestIdsLocked(
                                callingPid, callingUid));
            }
        }