diff options
-rw-r--r-- | res/values/arrays.xml | 3 | ||||
-rw-r--r-- | src/com/android/settings/DevelopmentSettings.java | 25 |
2 files changed, 8 insertions, 20 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 23d0582..6c1f68b 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -1329,6 +1329,7 @@ <!-- USB configuration names for Developer Settings. This can be overridden by devices with additional USB configurations. --> <string-array name="usb_configuration_titles"> + <item>@string/usb_use_charging_only</item> <item>MTP (Media Transfer Protocol)</item> <item>PTP (Picture Transfer Protocol)</item> <item>RNDIS (USB Ethernet)</item> @@ -1342,6 +1343,8 @@ Do not translate. --> <string-array name="usb_configuration_values" translatable="false"> <!-- Do not translate. --> + <item>none</item> + <!-- Do not translate. --> <item>mtp</item> <!-- Do not translate. --> <item>ptp</item> diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index 759c2a5..89b081a 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -149,18 +149,15 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices"; private static final String ENABLE_MULTI_WINDOW_KEY = "enable_multi_window"; private static final String DEBUG_DEBUGGING_CATEGORY_KEY = "debug_debugging_category"; - private static final String DEBUG_APPLICATIONS_CATEGORY_KEY = "debug_applications_category"; private static final String SELECT_LOGD_SIZE_KEY = "select_logd_size"; private static final String SELECT_LOGD_SIZE_PROPERTY = "persist.logd.size"; private static final String SELECT_LOGD_DEFAULT_SIZE_PROPERTY = "ro.logd.size"; - private static final String DEBUG_NETWORKING_CATEGORY_KEY = "debug_networking_category"; private static final String WIFI_DISPLAY_CERTIFICATION_KEY = "wifi_display_certification"; private static final String WIFI_VERBOSE_LOGGING_KEY = "wifi_verbose_logging"; private static final String WIFI_AGGRESSIVE_HANDOVER_KEY = "wifi_aggressive_handover"; private static final String WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY = "wifi_allow_scan_with_traffic"; private static final String USB_CONFIGURATION_KEY = "select_usb_configuration"; - private static final String SELECT_USB_CONFIGURATION_PROPERTY = "sys.usb.config"; private static final String WIFI_LEGACY_DHCP_CLIENT_KEY = "legacy_dhcp_client"; private static final String MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on"; @@ -1336,31 +1333,19 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private void updateUsbConfigurationValues() { if (mUsbConfiguration != null) { - String currentValue = SystemProperties.get(SELECT_USB_CONFIGURATION_PROPERTY); - - // Ignore adb interface. The USB Manager adds or removes adb automatically - // depending on if USB debugging is enabled. - int adbIndex = currentValue.indexOf(",adb"); - if (adbIndex > 0) { - currentValue = currentValue.substring(0, adbIndex); - } + UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE); String[] values = getResources().getStringArray(R.array.usb_configuration_values); String[] titles = getResources().getStringArray(R.array.usb_configuration_titles); - int index = 1; // punt to second entry if not found + int index = 0; for (int i = 0; i < titles.length; i++) { - if (currentValue.equals(values[i])) { + if (manager.isFunctionEnabled(values[i])) { index = i; break; } } - if (index >= 0) { - mUsbConfiguration.setValue(values[index]); - mUsbConfiguration.setSummary(titles[index]); - } else { - mUsbConfiguration.setValue(""); - mUsbConfiguration.setSummary(""); - } + mUsbConfiguration.setValue(values[index]); + mUsbConfiguration.setSummary(titles[index]); mUsbConfiguration.setOnPreferenceChangeListener(this); } } |