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

Commit 85d7336d authored by Evan Severson's avatar Evan Severson
Browse files

Update the sensor use dialog if more sensors are accessed

If another sensor is accessed after the dialog has been shown we now
update the dialog to reflect all accessed sensors.

Test: Wrote app which opens mic/cam at different times
Fixes: 187139024
Fixes: 187132341
Change-Id: I178bb4f6ea1913e3ee0e2153cf8ac3b2f24e4623
parent 576c548b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -46,6 +46,6 @@ interface ISensorPrivacyManager {
    void setIndividualSensorPrivacyForProfileGroup(int userId, int source, int sensor, boolean enable);
    // =============== End of transactions used on native side as well ============================

    void suppressIndividualSensorPrivacyReminders(int userId, String packageName, IBinder token,
    void suppressIndividualSensorPrivacyReminders(int userId, int sensor, IBinder token,
            boolean suppress);
}
 No newline at end of file
+4 −4
Original line number Diff line number Diff line
@@ -461,9 +461,9 @@ public final class SensorPrivacyManager {
     * @hide
     */
    @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY)
    public void suppressSensorPrivacyReminders(@NonNull String packageName,
    public void suppressSensorPrivacyReminders(int sensor,
            boolean suppress) {
        suppressSensorPrivacyReminders(packageName, suppress, mContext.getUserId());
        suppressSensorPrivacyReminders(sensor, suppress, mContext.getUserId());
    }

    /**
@@ -476,10 +476,10 @@ public final class SensorPrivacyManager {
     * @hide
     */
    @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY)
    public void suppressSensorPrivacyReminders(@NonNull String packageName,
    public void suppressSensorPrivacyReminders(int sensor,
            boolean suppress, @UserIdInt int userId) {
        try {
            mService.suppressIndividualSensorPrivacyReminders(userId, packageName,
            mService.suppressIndividualSensorPrivacyReminders(userId, sensor,
                    token, suppress);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
+1 −0
Original line number Diff line number Diff line
@@ -451,6 +451,7 @@
        <!-- started from SensoryPrivacyService -->
        <activity android:name=".sensorprivacy.SensorUseStartedActivity"
                  android:exported="true"
                  android:launchMode="singleTop"
                  android:permission="android.permission.MANAGE_SENSOR_PRIVACY"
                  android:theme="@style/Theme.SystemUI.Dialog.Alert"
                  android:finishOnCloseSystemDialogs="true">
+21 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.sensorprivacy

import android.content.DialogInterface
import android.content.Intent
import android.content.Intent.EXTRA_PACKAGE_NAME
import android.content.pm.PackageManager
import android.content.res.Resources
@@ -174,7 +175,7 @@ class SensorUseStartedActivity @Inject constructor(
    override fun onStart() {
        super.onStart()

        sensorPrivacyController.suppressSensorPrivacyReminders(sensorUsePackageName, true)
        setSuppressed(true)
        unsuppressImmediately = false
    }

@@ -205,12 +206,10 @@ class SensorUseStartedActivity @Inject constructor(
        super.onStop()

        if (unsuppressImmediately) {
            sensorPrivacyController
                    .suppressSensorPrivacyReminders(sensorUsePackageName, false)
            setSuppressed(false)
        } else {
            bgHandler.postDelayed({
                sensorPrivacyController
                        .suppressSensorPrivacyReminders(sensorUsePackageName, false)
                setSuppressed(false)
            }, SUPPRESS_REMINDERS_REMOVAL_DELAY_MILLIS)
        }
    }
@@ -224,6 +223,11 @@ class SensorUseStartedActivity @Inject constructor(
        // do not allow backing out
    }

    override fun onNewIntent(intent: Intent?) {
        setIntent(intent)
        recreate()
    }

    private fun disableSensorPrivacy() {
        if (sensor == ALL_SENSORS) {
            sensorPrivacyController.setSensorBlocked(DIALOG, MICROPHONE, false)
@@ -234,4 +238,16 @@ class SensorUseStartedActivity @Inject constructor(
        unsuppressImmediately = true
        setResult(RESULT_OK)
    }

    private fun setSuppressed(suppressed: Boolean) {
        if (sensor == ALL_SENSORS) {
            sensorPrivacyController
                    .suppressSensorPrivacyReminders(MICROPHONE, suppressed)
            sensorPrivacyController
                    .suppressSensorPrivacyReminders(CAMERA, suppressed)
        } else {
            sensorPrivacyController
                    .suppressSensorPrivacyReminders(sensor, suppressed)
        }
    }
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ public interface IndividualSensorPrivacyController extends

    void setSensorBlocked(@Source int source, @Sensor int sensor, boolean blocked);

    void suppressSensorPrivacyReminders(String packageName, boolean suppress);
    void suppressSensorPrivacyReminders(int sensor, boolean suppress);

    interface Callback {
        void onSensorBlockedChanged(@Sensor int sensor, boolean blocked);
Loading