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

Commit ba21f251 authored by Alex Stetson's avatar Alex Stetson
Browse files

Use explicit user id for sensor privacy manager

Recent changes to the SensorPrivacyManager will cause it to default to
using the context user for these interactions, which will always be user
0 for SysUI. Therefore, the explicit user id needs to be specified.

Bug: 366660154
Test: atest CtsSensorPrivacyTestCases:android.sensorprivacy.cts.SensorPrivacyMicrophoneTest
Flag: NONE bugfix
Change-Id: I725b2fda806020bd21075364fa52fc302a841249
parent afde520f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import com.android.systemui.rotationlock.RotationLockNewModule;
import com.android.systemui.scene.SceneContainerFrameworkModule;
import com.android.systemui.screenshot.ReferenceScreenshotModule;
import com.android.systemui.settings.MultiUserUtilsModule;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.NotificationShadeWindowControllerImpl;
import com.android.systemui.shade.ShadeModule;
import com.android.systemui.startable.Dependencies;
@@ -176,9 +177,9 @@ public abstract class ReferenceSystemUIModule {
    @Provides
    @SysUISingleton
    static IndividualSensorPrivacyController provideIndividualSensorPrivacyController(
            SensorPrivacyManager sensorPrivacyManager) {
            SensorPrivacyManager sensorPrivacyManager, UserTracker userTracker) {
        IndividualSensorPrivacyController spC = new IndividualSensorPrivacyControllerImpl(
                sensorPrivacyManager);
                sensorPrivacyManager, userTracker);
        spC.init();
        return spC;
    }
+9 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.util.SparseBooleanArray;
import androidx.annotation.NonNull;

import com.android.internal.camera.flags.Flags;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.util.ListenerSet;

import java.util.Set;
@@ -41,14 +42,17 @@ public class IndividualSensorPrivacyControllerImpl implements IndividualSensorPr
    private static final int[] SENSORS = new int[] {CAMERA, MICROPHONE};

    private final @NonNull SensorPrivacyManager mSensorPrivacyManager;
    private final @NonNull UserTracker mUserTracker;
    private final SparseBooleanArray mSoftwareToggleState = new SparseBooleanArray();
    private final SparseBooleanArray mHardwareToggleState = new SparseBooleanArray();
    private Boolean mRequiresAuthentication;
    private final ListenerSet<Callback> mCallbacks = new ListenerSet<>();

    public IndividualSensorPrivacyControllerImpl(
            @NonNull SensorPrivacyManager sensorPrivacyManager) {
            @NonNull SensorPrivacyManager sensorPrivacyManager,
            @NonNull UserTracker userTracker) {
        mSensorPrivacyManager = sensorPrivacyManager;
        mUserTracker = userTracker;
    }

    @Override
@@ -94,12 +98,14 @@ public class IndividualSensorPrivacyControllerImpl implements IndividualSensorPr

    @Override
    public void setSensorBlocked(@Source int source, @Sensor int sensor, boolean blocked) {
        mSensorPrivacyManager.setSensorPrivacyForProfileGroup(source, sensor, blocked);
        mSensorPrivacyManager.setSensorPrivacyForProfileGroup(source, sensor, blocked,
                mUserTracker.getUserId());
    }

    @Override
    public void suppressSensorPrivacyReminders(int sensor, boolean suppress) {
        mSensorPrivacyManager.suppressSensorPrivacyReminders(sensor, suppress);
        mSensorPrivacyManager.suppressSensorPrivacyReminders(sensor, suppress,
                mUserTracker.getUserId());
    }

    @Override