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

Commit 40d0f547 authored by Atneya Nair's avatar Atneya Nair
Browse files

[RESTRICT AUTOMERGE] Fix recording config mic indicator suppression

We should suppress the indicator when AllOf the configs are silenced,
instead of AnyOf.

Bug: 293603271
Bug: 325912429
Test: CtsMediaAudioPermissionTestCases
Test: AppOpsControllerTest
Flag: EXEMPT security
Change-Id: I8b1fe0bc2a4474467a1ef2510b29c5164e32aad8
parent 6a31645b
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon
            if (item == null && active) {
                item = new AppOpItem(code, uid, packageName, mClock.elapsedRealtime());
                if (isOpMicrophone(code)) {
                    item.setDisabled(isAnyRecordingPausedLocked(uid));
                    item.setDisabled(isAllRecordingPausedLocked(uid));
                } else if (isOpCamera(code)) {
                    item.setDisabled(mCameraDisabled);
                }
@@ -472,18 +472,21 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon

    }

    private boolean isAnyRecordingPausedLocked(int uid) {
    // TODO(b/365843152) remove AudioRecordingConfiguration listening
    private boolean isAllRecordingPausedLocked(int uid) {
        if (mMicMuted) {
            return true;
        }
        List<AudioRecordingConfiguration> configs = mRecordingsByUid.get(uid);
        if (configs == null) return false;
        // If we are aware of AudioRecordConfigs, suppress the indicator if all of them are known
        // to be silenced.
        int configsNum = configs.size();
        for (int i = 0; i < configsNum; i++) {
            AudioRecordingConfiguration config = configs.get(i);
            if (config.isClientSilenced()) return true;
            if (!config.isClientSilenced()) return false;
        }
        return false;
        return true;
    }

    private void updateSensorDisabledStatus() {
@@ -494,7 +497,7 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon

                boolean paused = false;
                if (isOpMicrophone(item.getCode())) {
                    paused = isAnyRecordingPausedLocked(item.getUid());
                    paused = isAllRecordingPausedLocked(item.getUid());
                } else if (isOpCamera(item.getCode())) {
                    paused = mCameraDisabled;
                }