diff options
author | Ethan Chen <intervigil@gmail.com> | 2016-04-01 11:05:02 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-04-04 17:29:29 -0700 |
commit | d6098ce16fa4bc11b5a59d1228745357ffb3d72e (patch) | |
tree | a29ca22a5843da8cd3a9568d803c4c78e31d79dc /src | |
parent | ba09a13d6bfc772cce24bfa86eb146ec3839292e (diff) | |
download | packages_apps_Settings-d6098ce16fa4bc11b5a59d1228745357ffb3d72e.zip packages_apps_Settings-d6098ce16fa4bc11b5a59d1228745357ffb3d72e.tar.gz packages_apps_Settings-d6098ce16fa4bc11b5a59d1228745357ffb3d72e.tar.bz2 |
DevelopmentSettings: Synchronize USB connection data state
* UsbModeChooserActivity now takes into account whether the user has
unlocked USB data for the current composition mode, but the development
settings USB mode chooser dialog does not. This patchset makes it
aware.
* Assume if USB data hasn't been unlocked by the user, that USB charging
mode is the current composition mode. This patch makes assumptions
that the charging composition mode occurs at position 0 of the
resources however. Any devices which have custom USB composition modes
set in the overlay should be aware of this change.
REF: CYNGNOS-2322
Change-Id: I8789f23b1c58bfb6e23f4fcde2b2c10d5fd4adf2
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/DevelopmentSettings.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index d7a4145..10f650e 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -1576,14 +1576,15 @@ public class DevelopmentSettings extends SettingsPreferenceFragment updateLogdSizeValues(); } - private void updateUsbConfigurationValues() { + private void updateUsbConfigurationValues(boolean isUnlocked) { if (mUsbConfiguration != null) { 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 = 0; - for (int i = 0; i < titles.length; i++) { + // Assume if !isUnlocked -> charging, which should be at index 0 + for (int i = 0; i < titles.length && isUnlocked; i++) { if (manager.isFunctionEnabled(values[i])) { index = i; break; @@ -1598,10 +1599,11 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private void writeUsbConfigurationOption(Object newValue) { UsbManager manager = (UsbManager)getActivity().getSystemService(Context.USB_SERVICE); String function = newValue.toString(); - manager.setCurrentFunction(function); if (function.equals("none")) { + manager.setCurrentFunction(null); manager.setUsbDataUnlocked(false); } else { + manager.setCurrentFunction(function); manager.setUsbDataUnlocked(true); } } @@ -2263,7 +2265,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private BroadcastReceiver mUsbReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - updateUsbConfigurationValues(); + boolean isUnlocked = intent.getBooleanExtra(UsbManager.USB_DATA_UNLOCKED, false); + updateUsbConfigurationValues(isUnlocked); } }; |