Loading core/java/android/content/pm/PackageManager.java +11 −0 Original line number Diff line number Diff line Loading @@ -3512,6 +3512,17 @@ public abstract class PackageManager { @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_TUNER = "android.hardware.tv.tuner"; /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device supports a enabling/disabling sensor privacy for * camera. When sensory privacy for the camera is enabled no camera data is send to clients, * e.g. the view finder in a camera app would appear blank. * * @hide */ @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_CAMERA_TOGGLE = "android.hardware.camera.toggle"; /** * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has * the necessary changes to support app enumeration. Loading packages/SystemUI/res/drawable/ic_camera_blocked.xml 0 → 100644 +29 −0 Original line number Diff line number Diff line <!-- ~ Copyright (C) 2021 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> <path android:pathData="m18,12c-2.75,0 -5,2.25 -5,5 0,2.75 2.25,5 5,5 2.75,0 5,-2.25 5,-5 0,-2.75 -2.1667,-5 -5,-5zM15.5,17.8333h5v-1.6666h-5z" android:fillColor="#30302a" android:fillType="evenOdd"/> <path android:pathData="m16.4,5.5004h-2.536l-1.464,-1.6H7.6l-1.464,1.6H3.6c-0.88,0 -1.6,0.72 -1.6,1.6v9.6c0,0.88 0.72,1.6 1.6,1.6h8.5413C12.0488,17.8817 12,17.4465 12,17c0,-0.1005 0.0025,-0.2004 0.0073,-0.2996H3.6V7.1004H16.4V11.2157C16.9094,11.0751 17.4459,11 18,11V7.1004c0,-0.88 -0.72,-1.6 -1.6,-1.6zM6.8,11.9004c0,-1.768 1.432,-3.2 3.2,-3.2 1.768,0 3.2,1.432 3.2,3.2 0,1.768 -1.432,3.2 -3.2,3.2 -1.768,0 -3.2,-1.432 -3.2,-3.2z" android:fillColor="#30302a" android:fillType="evenOdd"/> </vector> packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -821,6 +821,8 @@ <string name="quick_settings_location_label">Location</string> <!-- QuickSettings: Location (Off) [CHAR LIMIT=NONE] --> <string name="quick_settings_location_off_label">Location Off</string> <!-- QuickSettings: Camera [CHAR LIMIT=NONE] --> <string name="quick_settings_camera_label">Block Camera</string> <!-- QuickSettings: Media device [CHAR LIMIT=NONE] --> <string name="quick_settings_media_device_label">Media device</string> <!-- QuickSettings: RSSI [CHAR LIMIT=NONE] --> Loading packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +12 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME; import android.content.Context; import android.hardware.SensorPrivacyManager; import android.os.Handler; import android.os.PowerManager; Loading Loading @@ -62,6 +63,8 @@ import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.DeviceProvisionedControllerImpl; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.SensorPrivacyController; import com.android.systemui.statusbar.policy.SensorPrivacyControllerImpl; import javax.inject.Named; Loading Loading @@ -116,6 +119,15 @@ public abstract class SystemUIDefaultModule { return bC; } @Provides @SysUISingleton static SensorPrivacyController provideSensorPrivacyController( SensorPrivacyManager sensorPrivacyManager) { SensorPrivacyController spC = new SensorPrivacyControllerImpl(sensorPrivacyManager); spC.init(); return spC; } @Binds @SysUISingleton public abstract QSFactory bindQSFactory(QSFactoryImpl qsFactoryImpl); Loading packages/SystemUI/src/com/android/systemui/qs/tiles/CameraToggleTile.java +26 −22 Original line number Diff line number Diff line Loading @@ -16,11 +16,12 @@ package com.android.systemui.qs.tiles; import android.content.Context; import static com.android.systemui.DejankUtils.whitelistIpcs; import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Looper; import android.provider.DeviceConfig; import android.service.quicksettings.Tile; import android.widget.Switch; Loading @@ -38,7 +39,8 @@ import com.android.systemui.statusbar.policy.CameraToggleController; import javax.inject.Inject; public class CameraToggleTile extends QSTileImpl<QSTile.BooleanState> { public class CameraToggleTile extends QSTileImpl<QSTile.BooleanState> implements CameraToggleController.Callback { private CameraToggleController mCameraToggleController; Loading @@ -54,7 +56,15 @@ public class CameraToggleTile extends QSTileImpl<QSTile.BooleanState> { super(host, backgroundLooper, mainHandler, metricsLogger, statusBarStateController, activityStarter, qsLogger); mCameraToggleController = cameraToggleController; mCameraToggleController.addCallback((b) -> refreshState()); mCameraToggleController.observe(getLifecycle(), this); } @Override public boolean isAvailable() { return /*getHost().getContext().getPackageManager().hasSystemFeature(FEATURE_CAMERA_TOGGLE) && */whitelistIpcs(() -> DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, "camera_toggle_enabled", false)); } @Override Loading @@ -64,21 +74,18 @@ public class CameraToggleTile extends QSTileImpl<QSTile.BooleanState> { @Override protected void handleClick() { mCameraToggleController.setCameraEnabled(!mCameraToggleController.isCameraEnabled()); mCameraToggleController.setCameraBlocked(!mCameraToggleController.isCameraBlocked()); } @Override protected void handleUpdateState(BooleanState state, Object arg) { state.icon = new CameraToggleTileIcon(); state.state = mCameraToggleController.isCameraEnabled() ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; state.value = mCameraToggleController.isCameraEnabled(); state.label = "Camera"; if (!mCameraToggleController.isCameraAvailable()) { state.secondaryLabel = "Currently in use"; } else { state.secondaryLabel = null; } boolean isBlocked = arg == null ? mCameraToggleController.setCameraBlocked() : (boolean) arg; state.icon = ResourceIcon.get(R.drawable.ic_camera_blocked); state.state = isBlocked ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; state.value = isBlocked; state.label = getTileLabel(); state.handlesLongClick = false; state.contentDescription = state.label; state.expandedAccessibilityClassName = Switch.class.getName(); Loading @@ -96,14 +103,11 @@ public class CameraToggleTile extends QSTileImpl<QSTile.BooleanState> { @Override public CharSequence getTileLabel() { return "Camera"; return mContext.getString(R.string.quick_settings_camera_label); } class CameraToggleTileIcon extends Icon { @Override public Drawable getDrawable(Context context) { return context.getDrawable(R.drawable.ic_camera); } public void onCameraBlockedChanged(boolean enable) { refreshState(enable); } } Loading
core/java/android/content/pm/PackageManager.java +11 −0 Original line number Diff line number Diff line Loading @@ -3512,6 +3512,17 @@ public abstract class PackageManager { @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_TUNER = "android.hardware.tv.tuner"; /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device supports a enabling/disabling sensor privacy for * camera. When sensory privacy for the camera is enabled no camera data is send to clients, * e.g. the view finder in a camera app would appear blank. * * @hide */ @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_CAMERA_TOGGLE = "android.hardware.camera.toggle"; /** * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has * the necessary changes to support app enumeration. Loading
packages/SystemUI/res/drawable/ic_camera_blocked.xml 0 → 100644 +29 −0 Original line number Diff line number Diff line <!-- ~ Copyright (C) 2021 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> <path android:pathData="m18,12c-2.75,0 -5,2.25 -5,5 0,2.75 2.25,5 5,5 2.75,0 5,-2.25 5,-5 0,-2.75 -2.1667,-5 -5,-5zM15.5,17.8333h5v-1.6666h-5z" android:fillColor="#30302a" android:fillType="evenOdd"/> <path android:pathData="m16.4,5.5004h-2.536l-1.464,-1.6H7.6l-1.464,1.6H3.6c-0.88,0 -1.6,0.72 -1.6,1.6v9.6c0,0.88 0.72,1.6 1.6,1.6h8.5413C12.0488,17.8817 12,17.4465 12,17c0,-0.1005 0.0025,-0.2004 0.0073,-0.2996H3.6V7.1004H16.4V11.2157C16.9094,11.0751 17.4459,11 18,11V7.1004c0,-0.88 -0.72,-1.6 -1.6,-1.6zM6.8,11.9004c0,-1.768 1.432,-3.2 3.2,-3.2 1.768,0 3.2,1.432 3.2,3.2 0,1.768 -1.432,3.2 -3.2,3.2 -1.768,0 -3.2,-1.432 -3.2,-3.2z" android:fillColor="#30302a" android:fillType="evenOdd"/> </vector>
packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -821,6 +821,8 @@ <string name="quick_settings_location_label">Location</string> <!-- QuickSettings: Location (Off) [CHAR LIMIT=NONE] --> <string name="quick_settings_location_off_label">Location Off</string> <!-- QuickSettings: Camera [CHAR LIMIT=NONE] --> <string name="quick_settings_camera_label">Block Camera</string> <!-- QuickSettings: Media device [CHAR LIMIT=NONE] --> <string name="quick_settings_media_device_label">Media device</string> <!-- QuickSettings: RSSI [CHAR LIMIT=NONE] --> Loading
packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +12 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME; import android.content.Context; import android.hardware.SensorPrivacyManager; import android.os.Handler; import android.os.PowerManager; Loading Loading @@ -62,6 +63,8 @@ import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.DeviceProvisionedControllerImpl; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.SensorPrivacyController; import com.android.systemui.statusbar.policy.SensorPrivacyControllerImpl; import javax.inject.Named; Loading Loading @@ -116,6 +119,15 @@ public abstract class SystemUIDefaultModule { return bC; } @Provides @SysUISingleton static SensorPrivacyController provideSensorPrivacyController( SensorPrivacyManager sensorPrivacyManager) { SensorPrivacyController spC = new SensorPrivacyControllerImpl(sensorPrivacyManager); spC.init(); return spC; } @Binds @SysUISingleton public abstract QSFactory bindQSFactory(QSFactoryImpl qsFactoryImpl); Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/CameraToggleTile.java +26 −22 Original line number Diff line number Diff line Loading @@ -16,11 +16,12 @@ package com.android.systemui.qs.tiles; import android.content.Context; import static com.android.systemui.DejankUtils.whitelistIpcs; import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Looper; import android.provider.DeviceConfig; import android.service.quicksettings.Tile; import android.widget.Switch; Loading @@ -38,7 +39,8 @@ import com.android.systemui.statusbar.policy.CameraToggleController; import javax.inject.Inject; public class CameraToggleTile extends QSTileImpl<QSTile.BooleanState> { public class CameraToggleTile extends QSTileImpl<QSTile.BooleanState> implements CameraToggleController.Callback { private CameraToggleController mCameraToggleController; Loading @@ -54,7 +56,15 @@ public class CameraToggleTile extends QSTileImpl<QSTile.BooleanState> { super(host, backgroundLooper, mainHandler, metricsLogger, statusBarStateController, activityStarter, qsLogger); mCameraToggleController = cameraToggleController; mCameraToggleController.addCallback((b) -> refreshState()); mCameraToggleController.observe(getLifecycle(), this); } @Override public boolean isAvailable() { return /*getHost().getContext().getPackageManager().hasSystemFeature(FEATURE_CAMERA_TOGGLE) && */whitelistIpcs(() -> DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, "camera_toggle_enabled", false)); } @Override Loading @@ -64,21 +74,18 @@ public class CameraToggleTile extends QSTileImpl<QSTile.BooleanState> { @Override protected void handleClick() { mCameraToggleController.setCameraEnabled(!mCameraToggleController.isCameraEnabled()); mCameraToggleController.setCameraBlocked(!mCameraToggleController.isCameraBlocked()); } @Override protected void handleUpdateState(BooleanState state, Object arg) { state.icon = new CameraToggleTileIcon(); state.state = mCameraToggleController.isCameraEnabled() ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; state.value = mCameraToggleController.isCameraEnabled(); state.label = "Camera"; if (!mCameraToggleController.isCameraAvailable()) { state.secondaryLabel = "Currently in use"; } else { state.secondaryLabel = null; } boolean isBlocked = arg == null ? mCameraToggleController.setCameraBlocked() : (boolean) arg; state.icon = ResourceIcon.get(R.drawable.ic_camera_blocked); state.state = isBlocked ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; state.value = isBlocked; state.label = getTileLabel(); state.handlesLongClick = false; state.contentDescription = state.label; state.expandedAccessibilityClassName = Switch.class.getName(); Loading @@ -96,14 +103,11 @@ public class CameraToggleTile extends QSTileImpl<QSTile.BooleanState> { @Override public CharSequence getTileLabel() { return "Camera"; return mContext.getString(R.string.quick_settings_camera_label); } class CameraToggleTileIcon extends Icon { @Override public Drawable getDrawable(Context context) { return context.getDrawable(R.drawable.ic_camera); } public void onCameraBlockedChanged(boolean enable) { refreshState(enable); } }