OSDN Git Service

Add Developer menu entry to disable Bluetooth absolute volume
authorAndre Eisenbach <eisenbach@google.com>
Mon, 8 Feb 2016 23:40:23 +0000 (15:40 -0800)
committerAndre Eisenbach <eisenbach@google.com>
Tue, 9 Feb 2016 01:20:07 +0000 (17:20 -0800)
Bug: 27078729
Change-Id: I8a029baeb25b449446ae9bcc8cb220d5ec8e44a9

res/values/strings.xml
res/xml/development_prefs.xml
src/com/android/settings/DevelopmentSettings.java

index ddc8ded..1c093f7 100644 (file)
     <string name="legacy_dhcp_client">Use legacy DHCP client</string>
     <!-- Setting Checkbox title whether to always keep cellular data active. [CHAR LIMIT=80] -->
     <string name="mobile_data_always_on">Cellular data always active</string>
+    <!-- Setting Checkbox title for disabling Bluetooth absolute volume -->
+    <string name="bluetooth_disable_absolute_volume">Disable absolute volume</string>
 
     <!-- setting Checkbox summary whether to show options for wireless display certification  -->
     <string name="wifi_display_certification_summary">Show options for wireless display certification</string>
     <string name="verify_apps_over_usb_title">Verify apps over USB</string>
     <!-- Summary of checkbox setting to perform package verification on apps installed over USB/ADT/ADB [CHAR LIMIT=NONE] -->
     <string name="verify_apps_over_usb_summary">Check apps installed via ADB/ADT for harmful behavior.</string>
+    <!-- Summary of checkbox for disabling Bluetooth absolute volume -->
+    <string name="bluetooth_disable_absolute_volume_summary">Disables the Bluetooth absolute volume feature in case of volume issues with remote devices such as unacceptably loud volume or lack of control.</string>
 
     <!-- Title of checkbox setting that protects external storage. [CHAR LIMIT=32] -->
     <string name="enforce_read_external_title" product="nosdcard">Protect USB storage</string>
index c74d335..a88e91f 100644 (file)
             android:entries="@array/usb_configuration_titles"
             android:entryValues="@array/usb_configuration_values" />
 
+        <SwitchPreference
+            android:key="bluetooth_disable_absolute_volume"
+            android:title="@string/bluetooth_disable_absolute_volume"
+            android:summary="@string/bluetooth_disable_absolute_volume_summary"/>
     </PreferenceCategory>
 
     <PreferenceCategory android:key="debug_input_category"
index f237a7d..f21cce0 100644 (file)
@@ -168,6 +168,11 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
     private static final String MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on";
     private static final String KEY_COLOR_MODE = "color_mode";
 
+    private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY =
+                                    "bluetooth_disable_absolute_volume";
+    private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY =
+                                    "persist.bluetooth.disableabsvol";
+
     private static final String INACTIVE_APPS_KEY = "inactive_apps";
 
     private static final String OPENGL_TRACES_KEY = "enable_opengl_traces";
@@ -227,6 +232,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
     private SwitchPreference mWifiAggressiveHandover;
     private SwitchPreference mLegacyDhcpClient;
     private SwitchPreference mMobileDataAlwaysOn;
+    private SwitchPreference mBluetoothDisableAbsVolume;
 
     private SwitchPreference mWifiAllowScansWithTraffic;
     private SwitchPreference mStrictMode;
@@ -380,6 +386,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
         mMobileDataAlwaysOn = findAndInitSwitchPref(MOBILE_DATA_ALWAYS_ON);
         mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
         mUsbConfiguration = addListPreference(USB_CONFIGURATION_KEY);
+        mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
 
         mWindowAnimationScale = addListPreference(WINDOW_ANIMATION_SCALE_KEY);
         mTransitionAnimationScale = addListPreference(TRANSITION_ANIMATION_SCALE_KEY);
@@ -632,6 +639,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
         updateMobileDataAlwaysOnOptions();
         updateSimulateColorSpace();
         updateUSBAudioOptions();
+        updateBluetoothDisableAbsVolumeOptions();
     }
 
     private void resetDangerousOptions() {
@@ -1252,6 +1260,16 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
                 mLegacyDhcpClient.isChecked() ? 1 : 0);
     }
 
+    private void updateBluetoothDisableAbsVolumeOptions() {
+        updateSwitchPreference(mBluetoothDisableAbsVolume,
+                SystemProperties.getBoolean(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY, false));
+    }
+
+    private void writeBluetoothDisableAbsVolumeOptions() {
+        SystemProperties.set(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY,
+                mBluetoothDisableAbsVolume.isChecked() ? "true" : "false");
+    }
+
     private void updateMobileDataAlwaysOnOptions() {
         updateSwitchPreference(mMobileDataAlwaysOn, Settings.Global.getInt(
                 getActivity().getContentResolver(),
@@ -1750,6 +1768,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
             writeUSBAudioOptions();
         } else if (INACTIVE_APPS_KEY.equals(preference.getKey())) {
             startInactiveAppsFragment();
+        } else if (preference == mBluetoothDisableAbsVolume) {
+            writeBluetoothDisableAbsVolumeOptions();
         } else {
             return super.onPreferenceTreeClick(preferenceScreen, preference);
         }