Loading AndroidManifest.xml +11 −0 Original line number Diff line number Diff line Loading @@ -2971,6 +2971,17 @@ </intent-filter> </service> <service android:name=".development.qstile.DevelopmentTiles$SensorsOff" android:label="@string/sensors_off_quick_settings_title" android:icon="@drawable/tile_icon_sensors_off" android:permission="android.permission.BIND_QUICK_SETTINGS_TILE" android:enabled="false"> <intent-filter> <action android:name="android.service.quicksettings.action.QS_TILE" /> </intent-filter> </service> <activity android:name=".HelpTrampoline" android:exported="true" Loading res/drawable/tile_icon_sensors_off.xml 0 → 100644 +39 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2019 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.0" android:viewportHeight="24.0"> <path android:pathData="M21.966,2 L2,22" android:strokeLineCap="round" android:strokeColor="#000000" android:fillColor="#00000000" android:strokeWidth="1.6521436" android:strokeLineJoin="miter" android:strokeAlpha="1"/> <path android:pathData="M0.752,12L4.496,12l2.496,-6.25 2.496,12.5 2.496,-15 2.496,12.5 2.496,-7.5 1.248,3.75h4.992" android:strokeLineCap="round" android:strokeColor="#000000" android:fillColor="#00000000" android:strokeWidth="1.25090861" android:strokeLineJoin="round" android:strokeAlpha="1"/> </vector> res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -9801,6 +9801,9 @@ <!-- [CHAR LIMIT=25] Title of developer tile to toggle winscope trace --> <string name="winscope_trace_quick_settings_title">Winscope Trace</string> <!-- [CHAR LIMIT=25] Title of developer tile to toggle sensors --> <string name="sensors_off_quick_settings_title">Sensors Off</string> <!-- [CHAR LIMIT=60] Title of work profile setting page --> <string name="managed_profile_settings_title">Work profile settings</string> <!-- [CHAR LIMIT=60] The preference title for enabling cross-profile remote contact search --> src/com/android/settings/development/qstile/DevelopmentTiles.java +47 −1 Original line number Diff line number Diff line Loading @@ -16,9 +16,12 @@ package com.android.settings.development.qstile; import android.app.settings.SettingsEnums; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.hardware.SensorPrivacyManager; import android.app.KeyguardManager; import android.os.IBinder; import android.os.Parcel; import android.os.RemoteException; Loading @@ -38,6 +41,8 @@ import androidx.annotation.VisibleForTesting; import com.android.internal.app.LocalePicker; import com.android.internal.statusbar.IStatusBarService; import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.development.DevelopmentSettingsEnabler; import com.android.settingslib.development.SystemPropPoker; Loading Loading @@ -273,4 +278,45 @@ public abstract class DevelopmentTiles extends TileService { } } } /** * Tile to toggle sensors off to control camera, mic, and sensors managed by the SensorManager. */ public static class SensorsOff extends DevelopmentTiles { private Context mContext; private SensorPrivacyManager mSensorPrivacyManager; private KeyguardManager mKeyguardManager; private MetricsFeatureProvider mMetricsFeatureProvider; private boolean mIsEnabled; @Override public void onCreate() { super.onCreate(); mContext = getApplicationContext(); mSensorPrivacyManager = (SensorPrivacyManager) mContext.getSystemService( Context.SENSOR_PRIVACY_SERVICE); mIsEnabled = mSensorPrivacyManager.isSensorPrivacyEnabled(); mMetricsFeatureProvider = FeatureFactory.getFactory( mContext).getMetricsFeatureProvider(); mKeyguardManager = (KeyguardManager) mContext.getSystemService( Context.KEYGUARD_SERVICE); } @Override protected boolean isEnabled() { return mIsEnabled; } @Override public void setIsEnabled(boolean isEnabled) { // Don't allow sensors to be reenabled from the lock screen. if (mIsEnabled && mKeyguardManager.isKeyguardLocked()) { return; } mMetricsFeatureProvider.action(getApplicationContext(), SettingsEnums.QS_SENSOR_PRIVACY, isEnabled); mIsEnabled = isEnabled; mSensorPrivacyManager.setSensorPrivacy(isEnabled); } } } Loading
AndroidManifest.xml +11 −0 Original line number Diff line number Diff line Loading @@ -2971,6 +2971,17 @@ </intent-filter> </service> <service android:name=".development.qstile.DevelopmentTiles$SensorsOff" android:label="@string/sensors_off_quick_settings_title" android:icon="@drawable/tile_icon_sensors_off" android:permission="android.permission.BIND_QUICK_SETTINGS_TILE" android:enabled="false"> <intent-filter> <action android:name="android.service.quicksettings.action.QS_TILE" /> </intent-filter> </service> <activity android:name=".HelpTrampoline" android:exported="true" Loading
res/drawable/tile_icon_sensors_off.xml 0 → 100644 +39 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2019 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.0" android:viewportHeight="24.0"> <path android:pathData="M21.966,2 L2,22" android:strokeLineCap="round" android:strokeColor="#000000" android:fillColor="#00000000" android:strokeWidth="1.6521436" android:strokeLineJoin="miter" android:strokeAlpha="1"/> <path android:pathData="M0.752,12L4.496,12l2.496,-6.25 2.496,12.5 2.496,-15 2.496,12.5 2.496,-7.5 1.248,3.75h4.992" android:strokeLineCap="round" android:strokeColor="#000000" android:fillColor="#00000000" android:strokeWidth="1.25090861" android:strokeLineJoin="round" android:strokeAlpha="1"/> </vector>
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -9801,6 +9801,9 @@ <!-- [CHAR LIMIT=25] Title of developer tile to toggle winscope trace --> <string name="winscope_trace_quick_settings_title">Winscope Trace</string> <!-- [CHAR LIMIT=25] Title of developer tile to toggle sensors --> <string name="sensors_off_quick_settings_title">Sensors Off</string> <!-- [CHAR LIMIT=60] Title of work profile setting page --> <string name="managed_profile_settings_title">Work profile settings</string> <!-- [CHAR LIMIT=60] The preference title for enabling cross-profile remote contact search -->
src/com/android/settings/development/qstile/DevelopmentTiles.java +47 −1 Original line number Diff line number Diff line Loading @@ -16,9 +16,12 @@ package com.android.settings.development.qstile; import android.app.settings.SettingsEnums; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.hardware.SensorPrivacyManager; import android.app.KeyguardManager; import android.os.IBinder; import android.os.Parcel; import android.os.RemoteException; Loading @@ -38,6 +41,8 @@ import androidx.annotation.VisibleForTesting; import com.android.internal.app.LocalePicker; import com.android.internal.statusbar.IStatusBarService; import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.development.DevelopmentSettingsEnabler; import com.android.settingslib.development.SystemPropPoker; Loading Loading @@ -273,4 +278,45 @@ public abstract class DevelopmentTiles extends TileService { } } } /** * Tile to toggle sensors off to control camera, mic, and sensors managed by the SensorManager. */ public static class SensorsOff extends DevelopmentTiles { private Context mContext; private SensorPrivacyManager mSensorPrivacyManager; private KeyguardManager mKeyguardManager; private MetricsFeatureProvider mMetricsFeatureProvider; private boolean mIsEnabled; @Override public void onCreate() { super.onCreate(); mContext = getApplicationContext(); mSensorPrivacyManager = (SensorPrivacyManager) mContext.getSystemService( Context.SENSOR_PRIVACY_SERVICE); mIsEnabled = mSensorPrivacyManager.isSensorPrivacyEnabled(); mMetricsFeatureProvider = FeatureFactory.getFactory( mContext).getMetricsFeatureProvider(); mKeyguardManager = (KeyguardManager) mContext.getSystemService( Context.KEYGUARD_SERVICE); } @Override protected boolean isEnabled() { return mIsEnabled; } @Override public void setIsEnabled(boolean isEnabled) { // Don't allow sensors to be reenabled from the lock screen. if (mIsEnabled && mKeyguardManager.isKeyguardLocked()) { return; } mMetricsFeatureProvider.action(getApplicationContext(), SettingsEnums.QS_SENSOR_PRIVACY, isEnabled); mIsEnabled = isEnabled; mSensorPrivacyManager.setSensorPrivacy(isEnabled); } } }