Merge "Disable mic/cam quicksettings tiles when admin disallows" into sc-dev am: 0473e3a8e0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15084815

Change-Id: If9c9234021c0044c168eadf61ec9ff36926fb167
This commit is contained in:
TreeHugger Robot
2021-07-16 01:58:08 +00:00
committed by Automerger Merge Worker
3 changed files with 21 additions and 2 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -22,6 +22,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;
@@ -63,6 +64,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,
@@ -103,6 +109,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;
@@ -112,7 +120,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();
}
@@ -124,7 +131,7 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS
@Override
public Intent getLongClickIntent() {
return null;
return new Intent(Settings.ACTION_PRIVACY_SETTINGS);
}
@Override