Merge "Disable mic/cam quicksettings tiles when admin disallows" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0473e3a8e0
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.qs.tiles;
|
package com.android.systemui.qs.tiles;
|
||||||
|
|
||||||
import static android.hardware.SensorPrivacyManager.Sensors.CAMERA;
|
import static android.hardware.SensorPrivacyManager.Sensors.CAMERA;
|
||||||
|
import static android.os.UserManager.DISALLOW_CAMERA_TOGGLE;
|
||||||
|
|
||||||
import static com.android.systemui.DejankUtils.whitelistIpcs;
|
import static com.android.systemui.DejankUtils.whitelistIpcs;
|
||||||
|
|
||||||
@@ -86,4 +87,9 @@ public class CameraToggleTile extends SensorPrivacyToggleTile {
|
|||||||
public @Sensor int getSensorId() {
|
public @Sensor int getSensorId() {
|
||||||
return CAMERA;
|
return CAMERA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRestriction() {
|
||||||
|
return DISALLOW_CAMERA_TOGGLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.qs.tiles;
|
package com.android.systemui.qs.tiles;
|
||||||
|
|
||||||
import static android.hardware.SensorPrivacyManager.Sensors.MICROPHONE;
|
import static android.hardware.SensorPrivacyManager.Sensors.MICROPHONE;
|
||||||
|
import static android.os.UserManager.DISALLOW_MICROPHONE_TOGGLE;
|
||||||
|
|
||||||
import static com.android.systemui.DejankUtils.whitelistIpcs;
|
import static com.android.systemui.DejankUtils.whitelistIpcs;
|
||||||
|
|
||||||
@@ -86,4 +87,9 @@ public class MicrophoneToggleTile extends SensorPrivacyToggleTile {
|
|||||||
public @Sensor int getSensorId() {
|
public @Sensor int getSensorId() {
|
||||||
return MICROPHONE;
|
return MICROPHONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRestriction() {
|
||||||
|
return DISALLOW_MICROPHONE_TOGGLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.content.Intent;
|
|||||||
import android.hardware.SensorPrivacyManager.Sensors.Sensor;
|
import android.hardware.SensorPrivacyManager.Sensors.Sensor;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.service.quicksettings.Tile;
|
import android.service.quicksettings.Tile;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
@@ -63,6 +64,11 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS
|
|||||||
*/
|
*/
|
||||||
public abstract @DrawableRes int getIconRes(boolean isBlocked);
|
public abstract @DrawableRes int getIconRes(boolean isBlocked);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the user restriction name
|
||||||
|
*/
|
||||||
|
public abstract String getRestriction();
|
||||||
|
|
||||||
protected SensorPrivacyToggleTile(QSHost host,
|
protected SensorPrivacyToggleTile(QSHost host,
|
||||||
@Background Looper backgroundLooper,
|
@Background Looper backgroundLooper,
|
||||||
@Main Handler mainHandler,
|
@Main Handler mainHandler,
|
||||||
@@ -103,6 +109,8 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS
|
|||||||
boolean isBlocked = arg == null ? mSensorPrivacyController.isSensorBlocked(getSensorId())
|
boolean isBlocked = arg == null ? mSensorPrivacyController.isSensorBlocked(getSensorId())
|
||||||
: (boolean) arg;
|
: (boolean) arg;
|
||||||
|
|
||||||
|
checkIfRestrictionEnforcedByAdminOnly(state, getRestriction());
|
||||||
|
|
||||||
state.icon = ResourceIcon.get(getIconRes(isBlocked));
|
state.icon = ResourceIcon.get(getIconRes(isBlocked));
|
||||||
state.state = isBlocked ? Tile.STATE_INACTIVE : Tile.STATE_ACTIVE;
|
state.state = isBlocked ? Tile.STATE_INACTIVE : Tile.STATE_ACTIVE;
|
||||||
state.value = !isBlocked;
|
state.value = !isBlocked;
|
||||||
@@ -112,7 +120,6 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS
|
|||||||
} else {
|
} else {
|
||||||
state.secondaryLabel = mContext.getString(R.string.quick_settings_camera_mic_available);
|
state.secondaryLabel = mContext.getString(R.string.quick_settings_camera_mic_available);
|
||||||
}
|
}
|
||||||
state.handlesLongClick = false;
|
|
||||||
state.contentDescription = state.label;
|
state.contentDescription = state.label;
|
||||||
state.expandedAccessibilityClassName = Switch.class.getName();
|
state.expandedAccessibilityClassName = Switch.class.getName();
|
||||||
}
|
}
|
||||||
@@ -124,7 +131,7 @@ public abstract class SensorPrivacyToggleTile extends QSTileImpl<QSTile.BooleanS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent getLongClickIntent() {
|
public Intent getLongClickIntent() {
|
||||||
return null;
|
return new Intent(Settings.ACTION_PRIVACY_SETTINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user