Loading res/xml/privacy_dashboard_settings.xml +2 −2 Original line number Diff line number Diff line Loading @@ -64,14 +64,14 @@ </Preference> <!-- Camera toggle --> <SwitchPreference <com.android.settingslib.RestrictedSwitchPreference android:key="privacy_camera_toggle" android:title="@string/camera_toggle_title" android:summary="@string/sensor_toggle_description" settings:controller="com.android.settings.privacy.CameraToggleController"/> <!-- Microphone toggle --> <SwitchPreference <com.android.settingslib.RestrictedSwitchPreference android:key="privacy_mic_toggle" android:title="@string/mic_toggle_title" android:summary="@string/sensor_toggle_description" Loading src/com/android/settings/privacy/CameraToggleController.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settings.privacy; import static android.os.UserManager.DISALLOW_CAMERA_TOGGLE; import static com.android.settings.utils.SensorPrivacyManagerHelper.CAMERA; import android.content.Context; Loading @@ -40,4 +42,9 @@ public class CameraToggleController extends SensorToggleController { && DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, "camera_toggle_enabled", true) ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE; } @Override protected String getRestriction() { return DISALLOW_CAMERA_TOGGLE; } } src/com/android/settings/privacy/MicToggleController.java +6 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settings.privacy; import static android.os.UserManager.DISALLOW_MICROPHONE_TOGGLE; import static com.android.settings.utils.SensorPrivacyManagerHelper.MICROPHONE; import android.content.Context; Loading @@ -41,4 +43,8 @@ public class MicToggleController extends SensorToggleController { true) ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE; } @Override protected String getRestriction() { return DISALLOW_MICROPHONE_TOGGLE; } } src/com/android/settings/privacy/SensorToggleController.java +14 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import androidx.preference.PreferenceScreen; import com.android.settings.core.TogglePreferenceController; import com.android.settings.utils.SensorPrivacyManagerHelper; import com.android.settingslib.RestrictedLockUtilsInternal; import com.android.settingslib.RestrictedSwitchPreference; import java.util.concurrent.Executor; Loading @@ -46,6 +48,10 @@ public abstract class SensorToggleController extends TogglePreferenceController */ public abstract int getSensor(); protected String getRestriction() { return null; } @Override public boolean isChecked() { return !mSensorPrivacyManagerHelper.isSensorBlocked(getSensor()); Loading @@ -60,6 +66,14 @@ public abstract class SensorToggleController extends TogglePreferenceController @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); RestrictedSwitchPreference preference = (RestrictedSwitchPreference) screen.findPreference(getPreferenceKey()); if (preference != null) { preference.setDisabledByAdmin(RestrictedLockUtilsInternal .checkIfRestrictionEnforced(mContext, getRestriction(), mContext.getUserId())); } mSensorPrivacyManagerHelper.addSensorBlockedListener( getSensor(), (sensor, blocked) -> updateState(screen.findPreference(mPreferenceKey)), Loading Loading
res/xml/privacy_dashboard_settings.xml +2 −2 Original line number Diff line number Diff line Loading @@ -64,14 +64,14 @@ </Preference> <!-- Camera toggle --> <SwitchPreference <com.android.settingslib.RestrictedSwitchPreference android:key="privacy_camera_toggle" android:title="@string/camera_toggle_title" android:summary="@string/sensor_toggle_description" settings:controller="com.android.settings.privacy.CameraToggleController"/> <!-- Microphone toggle --> <SwitchPreference <com.android.settingslib.RestrictedSwitchPreference android:key="privacy_mic_toggle" android:title="@string/mic_toggle_title" android:summary="@string/sensor_toggle_description" Loading
src/com/android/settings/privacy/CameraToggleController.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settings.privacy; import static android.os.UserManager.DISALLOW_CAMERA_TOGGLE; import static com.android.settings.utils.SensorPrivacyManagerHelper.CAMERA; import android.content.Context; Loading @@ -40,4 +42,9 @@ public class CameraToggleController extends SensorToggleController { && DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, "camera_toggle_enabled", true) ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE; } @Override protected String getRestriction() { return DISALLOW_CAMERA_TOGGLE; } }
src/com/android/settings/privacy/MicToggleController.java +6 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settings.privacy; import static android.os.UserManager.DISALLOW_MICROPHONE_TOGGLE; import static com.android.settings.utils.SensorPrivacyManagerHelper.MICROPHONE; import android.content.Context; Loading @@ -41,4 +43,8 @@ public class MicToggleController extends SensorToggleController { true) ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE; } @Override protected String getRestriction() { return DISALLOW_MICROPHONE_TOGGLE; } }
src/com/android/settings/privacy/SensorToggleController.java +14 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import androidx.preference.PreferenceScreen; import com.android.settings.core.TogglePreferenceController; import com.android.settings.utils.SensorPrivacyManagerHelper; import com.android.settingslib.RestrictedLockUtilsInternal; import com.android.settingslib.RestrictedSwitchPreference; import java.util.concurrent.Executor; Loading @@ -46,6 +48,10 @@ public abstract class SensorToggleController extends TogglePreferenceController */ public abstract int getSensor(); protected String getRestriction() { return null; } @Override public boolean isChecked() { return !mSensorPrivacyManagerHelper.isSensorBlocked(getSensor()); Loading @@ -60,6 +66,14 @@ public abstract class SensorToggleController extends TogglePreferenceController @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); RestrictedSwitchPreference preference = (RestrictedSwitchPreference) screen.findPreference(getPreferenceKey()); if (preference != null) { preference.setDisabledByAdmin(RestrictedLockUtilsInternal .checkIfRestrictionEnforced(mContext, getRestriction(), mContext.getUserId())); } mSensorPrivacyManagerHelper.addSensorBlockedListener( getSensor(), (sensor, blocked) -> updateState(screen.findPreference(mPreferenceKey)), Loading