summaryrefslogtreecommitdiffstats
path: root/core/java/android/hardware/usb
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-03-09 12:05:20 -0500
committerMike Lockwood <lockwood@android.com>2011-03-09 12:33:00 -0500
commitc6f23e8521dedac7a07119031913235be3ca37c3 (patch)
tree0e25041664958b4f96b41475f25f95b13b8d6b6d /core/java/android/hardware/usb
parentea44c7c71431adbce348cf9ef3f22d9561bb7fc1 (diff)
downloadframeworks_base-c6f23e8521dedac7a07119031913235be3ca37c3.zip
frameworks_base-c6f23e8521dedac7a07119031913235be3ca37c3.tar.gz
frameworks_base-c6f23e8521dedac7a07119031913235be3ca37c3.tar.bz2
Change UsbManager.requestPermission to only grant permission temporarily
If the user approves an application to access a USB device or accessory without choosing it as the default application, then permission is granted only until the device or accessory is disconnected. Only applications chosen as the default choice have permissions assigned persistently. BUG: 4061035 Change-Id: Ic4f6271a91b2fc56bbeef82c579e26d88c63ae56 Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'core/java/android/hardware/usb')
-rw-r--r--core/java/android/hardware/usb/IUsbManager.aidl4
-rw-r--r--core/java/android/hardware/usb/UsbAccessory.java8
-rw-r--r--core/java/android/hardware/usb/UsbDevice.java5
-rw-r--r--core/java/android/hardware/usb/UsbManager.java16
4 files changed, 29 insertions, 4 deletions
diff --git a/core/java/android/hardware/usb/IUsbManager.aidl b/core/java/android/hardware/usb/IUsbManager.aidl
index c79a458..495fa21 100644
--- a/core/java/android/hardware/usb/IUsbManager.aidl
+++ b/core/java/android/hardware/usb/IUsbManager.aidl
@@ -77,8 +77,8 @@ interface IUsbManager
void grantAccessoryPermission(in UsbAccessory accessory, int uid);
/* Returns true if the USB manager has default preferences or permissions for the package */
- boolean hasDefaults(String packageName, int uid);
+ boolean hasDefaults(String packageName);
/* Clears default preferences and permissions for the package */
- oneway void clearDefaults(String packageName, int uid);
+ oneway void clearDefaults(String packageName);
}
diff --git a/core/java/android/hardware/usb/UsbAccessory.java b/core/java/android/hardware/usb/UsbAccessory.java
index 6cd9178..7d66caa 100644
--- a/core/java/android/hardware/usb/UsbAccessory.java
+++ b/core/java/android/hardware/usb/UsbAccessory.java
@@ -109,6 +109,14 @@ public class UsbAccessory implements Parcelable {
}
@Override
+ public int hashCode() {
+ return ((mManufacturer == null ? 0 : mManufacturer.hashCode()) ^
+ (mModel == null ? 0 : mModel.hashCode()) ^
+ (mType == null ? 0 : mType.hashCode()) ^
+ (mVersion == null ? 0 : mVersion.hashCode()));
+ }
+
+ @Override
public String toString() {
return "UsbAccessory[mManufacturer=" + mManufacturer +
", mModel=" + mModel +
diff --git a/core/java/android/hardware/usb/UsbDevice.java b/core/java/android/hardware/usb/UsbDevice.java
index 37bd82b..39254b38 100644
--- a/core/java/android/hardware/usb/UsbDevice.java
+++ b/core/java/android/hardware/usb/UsbDevice.java
@@ -270,6 +270,11 @@ public final class UsbDevice implements Parcelable {
}
@Override
+ public int hashCode() {
+ return mName.hashCode();
+ }
+
+ @Override
public String toString() {
return "UsbDevice[mName=" + mName + ",mVendorId=" + mVendorId +
",mProductId=" + mProductId + ",mClass=" + mClass +
diff --git a/core/java/android/hardware/usb/UsbManager.java b/core/java/android/hardware/usb/UsbManager.java
index 9f1b8ea..5df0ac7 100644
--- a/core/java/android/hardware/usb/UsbManager.java
+++ b/core/java/android/hardware/usb/UsbManager.java
@@ -281,6 +281,9 @@ public class UsbManager {
/**
* Returns true if the caller has permission to access the device.
+ * Permission might have been granted temporarily via
+ * {@link #requestPermission(android.hardware.usb.UsbDevice} or
+ * by the user choosing the caller as the default application for the device.
*
* @param device to check permissions for
* @return true if caller has permission
@@ -296,6 +299,9 @@ public class UsbManager {
/**
* Returns true if the caller has permission to access the accessory.
+ * Permission might have been granted temporarily via
+ * {@link #requestPermission(android.hardware.usb.UsbAccessory} or
+ * by the user choosing the caller as the default application for the accessory.
*
* @param accessory to check permissions for
* @return true if caller has permission
@@ -310,10 +316,13 @@ public class UsbManager {
}
/**
- * Requests permission for the given package to access the device.
+ * Requests temporary permission for the given package to access the device.
* This may result in a system dialog being displayed to the user
* if permission had not already been granted.
* Success or failure is returned via the {@link android.app.PendingIntent} pi.
+ * If successful, this grants the caller permission to access the device only
+ * until the device is disconnected.
+ *
* The following extras will be added to pi:
* <ul>
* <li> {@link #EXTRA_DEVICE} containing the device passed into this call
@@ -333,10 +342,13 @@ public class UsbManager {
}
/**
- * Requests permission for the given package to access the accessory.
+ * Requests temporary permission for the given package to access the accessory.
* This may result in a system dialog being displayed to the user
* if permission had not already been granted.
* Success or failure is returned via the {@link android.app.PendingIntent} pi.
+ * If successful, this grants the caller permission to access the device only
+ * until the device is disconnected.
+ *
* The following extras will be added to pi:
* <ul>
* <li> {@link #EXTRA_ACCESSORY} containing the accessory passed into this call