summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/deviceinfo
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2015-06-10 09:39:26 -0700
committerNick Kralevich <nnk@google.com>2015-06-10 10:24:05 -0700
commit5eba30289a708d92f152d998c05bea3866316b3b (patch)
treed8904b42add7e3993ce87023cd6ae85039521366 /src/com/android/settings/deviceinfo
parent0bd18745cff354f6994b70e71f3ab6b7e98fe004 (diff)
downloadpackages_apps_Settings-5eba30289a708d92f152d998c05bea3866316b3b.zip
packages_apps_Settings-5eba30289a708d92f152d998c05bea3866316b3b.tar.gz
packages_apps_Settings-5eba30289a708d92f152d998c05bea3866316b3b.tar.bz2
Fix USB access control when adb is disabled.
When adb is disabled, the default usb mode would be "none", which would turn off the driver and prevent UsbDeviceManager from receiving any new USB connect / disconnect messages. This prevents the user from ever enabling MTP and sharing data when adb is turned off. As discussed in bug 21429947, we work around this problem by keeping the USB driver in MTP mode most of the time, so that we continue to receive USB connect / disconnect messages. To avoid leaking confidential user photos, we now explicitly unlock USB data after switching into MTP/PTP mode. Enabling MTP mode is now decoupled from exposing data on the USB connection. Bug: 21429947 Change-Id: Id8e9df4ac42fdcf22cc5b75b838bf46f6c225081
Diffstat (limited to 'src/com/android/settings/deviceinfo')
-rw-r--r--src/com/android/settings/deviceinfo/UsbModeChooserActivity.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java b/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java
index e0369d6..a6af01a 100644
--- a/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java
+++ b/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java
@@ -76,7 +76,9 @@ public class UsbModeChooserActivity extends Activity {
* so that everything matches.
*/
private int getCurrentFunction() {
- if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_MTP)) {
+ if (!mUsbManager.isUsbDataUnlocked()) {
+ return 0;
+ } else if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_MTP)) {
return 1;
} else if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_PTP)) {
return 2;
@@ -93,16 +95,20 @@ public class UsbModeChooserActivity extends Activity {
private void setCurrentFunction(int which) {
switch (which) {
case 0:
- mUsbManager.setCurrentFunction("none");
+ mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MTP);
+ mUsbManager.setUsbDataUnlocked(false);
break;
case 1:
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MTP);
+ mUsbManager.setUsbDataUnlocked(true);
break;
case 2:
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_PTP);
+ mUsbManager.setUsbDataUnlocked(true);
break;
case 3:
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MIDI);
+ mUsbManager.setUsbDataUnlocked(true);
break;
}
}