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

Commit 41ff39a1 authored by Evan Severson's avatar Evan Severson Committed by Android (Google) Code Review
Browse files

Merge "Update the sensor use dialog if more sensors are accessed" into sc-dev

parents 4de5e908 85d7336d
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
@@ -178,7 +179,7 @@ class SensorUseStartedActivity @Inject constructor(
    override fun onStart() {
        super.onStart()

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

@@ -218,12 +219,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)
        }
    }
@@ -237,6 +236,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)
@@ -247,4 +251,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