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

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

Merge "Make the authentication requirement configurable for toggles" into tm-dev

parents f58911cf 75821bfd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -50,5 +50,7 @@ interface ISensorPrivacyManager {
    void suppressToggleSensorPrivacyReminders(int userId, int sensor, IBinder token,
            boolean suppress);

    boolean requiresAuthentication();

    void showSensorUseDialog(int sensor);
}
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
@@ -327,6 +327,8 @@ public final class SensorPrivacyManager {
    @NonNull
    private boolean mToggleListenerRegistered = false;

    private Boolean mRequiresAuthentication = null;

    /**
     * Private constructor to ensure only a single instance is created.
     */
@@ -760,6 +762,23 @@ public final class SensorPrivacyManager {
        }
    }

    /**
     * @return whether the device is required to be unlocked to change software state.
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.OBSERVE_SENSOR_PRIVACY)
    public boolean requiresAuthentication() {
        if (mRequiresAuthentication == null) {
            try {
                mRequiresAuthentication = mService.requiresAuthentication();
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return mRequiresAuthentication;
    }

    /**
     * If sensor privacy for the provided sensor is enabled then this call will show the user the
     * dialog which is shown when an application attempts to use that sensor. If privacy isn't
+2 −0
Original line number Diff line number Diff line
@@ -5451,6 +5451,8 @@
    <bool name="config_supportsHardwareCamToggle">false</bool>
    <!-- Whether a camera intent is launched when the lens cover is toggled -->
    <bool name="config_launchCameraOnCameraLensCoverToggle">true</bool>
    <!-- Whether changing sensor privacy SW setting requires device to be unlocked -->
    <bool name="config_sensorPrivacyRequiresAuthentication">true</bool>

    <!-- List containing the allowed install sources for accessibility service. -->
    <string-array name="config_accessibility_allowed_install_source" translatable="false"/>
+1 −0
Original line number Diff line number Diff line
@@ -4661,6 +4661,7 @@
  <java-symbol type="bool" name="config_supportsHardwareMicToggle" />
  <java-symbol type="bool" name="config_supportsHardwareCamToggle" />
  <java-symbol type="bool" name="config_launchCameraOnCameraLensCoverToggle" />
  <java-symbol type="bool" name="config_sensorPrivacyRequiresAuthentication" />

  <java-symbol type="dimen" name="starting_surface_icon_size" />
  <java-symbol type="dimen" name="starting_surface_default_icon_size" />
+7 −7
Original line number Diff line number Diff line
@@ -92,15 +92,15 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS

    @Override
    protected void handleClick(@Nullable View view) {
        if (mKeyguard.isMethodSecure() && mKeyguard.isShowing()) {
            mActivityStarter.postQSRunnableDismissingKeyguard(() -> {
                mSensorPrivacyController.setSensorBlocked(QS_TILE, getSensorId(),
                        !mSensorPrivacyController.isSensorBlocked(getSensorId()));
            });
        boolean blocked = mSensorPrivacyController.isSensorBlocked(getSensorId());
        if (mSensorPrivacyController.requiresAuthentication()
                && mKeyguard.isMethodSecure()
                && mKeyguard.isShowing()) {
            mActivityStarter.postQSRunnableDismissingKeyguard(() ->
                    mSensorPrivacyController.setSensorBlocked(QS_TILE, getSensorId(), !blocked));
            return;
        }
        mSensorPrivacyController.setSensorBlocked(QS_TILE, getSensorId(),
                !mSensorPrivacyController.isSensorBlocked(getSensorId()));
        mSensorPrivacyController.setSensorBlocked(QS_TILE, getSensorId(), !blocked);
    }

    @Override
Loading