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

Commit 06a6055a authored by Evan Severson's avatar Evan Severson
Browse files

Disable mic/cam quicksettings tiles when admin disallows

Also add longpressing sends to privacy settings

Test: Use test DPC app
Bug: 184927615
Change-Id: I7a1a8e9601baeb59723999031e0171b896540491
parent 79bbe49b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.qs.tiles;

import static android.hardware.SensorPrivacyManager.Sensors.CAMERA;
import static android.os.UserManager.DISALLOW_CAMERA_TOGGLE;

import static com.android.systemui.DejankUtils.whitelistIpcs;

@@ -86,4 +87,9 @@ public class CameraToggleTile extends SensorPrivacyToggleTile {
    public @Sensor int getSensorId() {
        return CAMERA;
    }

    @Override
    public String getRestriction() {
        return DISALLOW_CAMERA_TOGGLE;
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.qs.tiles;

import static android.hardware.SensorPrivacyManager.Sensors.MICROPHONE;
import static android.os.UserManager.DISALLOW_MICROPHONE_TOGGLE;

import static com.android.systemui.DejankUtils.whitelistIpcs;

@@ -86,4 +87,9 @@ public class MicrophoneToggleTile extends SensorPrivacyToggleTile {
    public @Sensor int getSensorId() {
        return MICROPHONE;
    }

    @Override
    public String getRestriction() {
        return DISALLOW_MICROPHONE_TOGGLE;
    }
}
+9 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Intent;
import android.hardware.SensorPrivacyManager.Sensors.Sensor;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.service.quicksettings.Tile;
import android.view.View;
import android.widget.Switch;
@@ -61,6 +62,11 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS
     */
    public abstract @DrawableRes int getIconRes(boolean isBlocked);

    /**
     * @return the user restriction name
     */
    public abstract String getRestriction();

    protected SensorPrivacyToggleTile(QSHost host,
            @Background Looper backgroundLooper,
            @Main Handler mainHandler,
@@ -101,6 +107,8 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS
        boolean isBlocked = arg == null ? mSensorPrivacyController.isSensorBlocked(getSensorId())
                : (boolean) arg;

        checkIfRestrictionEnforcedByAdminOnly(state, getRestriction());

        state.icon = ResourceIcon.get(getIconRes(isBlocked));
        state.state = isBlocked ? Tile.STATE_INACTIVE : Tile.STATE_ACTIVE;
        state.value = !isBlocked;
@@ -110,7 +118,6 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS
        } else {
            state.secondaryLabel = mContext.getString(R.string.quick_settings_camera_mic_available);
        }
        state.handlesLongClick = false;
        state.contentDescription = state.label;
        state.expandedAccessibilityClassName = Switch.class.getName();
    }
@@ -122,7 +129,7 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS

    @Override
    public Intent getLongClickIntent() {
        return null;
        return new Intent(Settings.ACTION_PRIVACY_SETTINGS);
    }

    @Override