summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-06-29 05:32:37 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-06-29 05:32:37 -0700
commit1eb86d8b8d61f66b6ef211af9e902e8a84a5efd0 (patch)
treedb59a0fef00bdf392170d8ba682fdc41879e8f35 /services/java
parent9593b2ac9c865bd0b7de4ad0f1dc1776e0f0b686 (diff)
parent9be487ce6be705d210d42f8cbe6468226eeb544e (diff)
downloadframeworks_base-1eb86d8b8d61f66b6ef211af9e902e8a84a5efd0.zip
frameworks_base-1eb86d8b8d61f66b6ef211af9e902e8a84a5efd0.tar.gz
frameworks_base-1eb86d8b8d61f66b6ef211af9e902e8a84a5efd0.tar.bz2
am 9be487ce: am 606d591a: Merge "Add new Usb.ACTION_USB_STATE sticky broadcast for monitoring USB connect state" into gingerbread
Merge commit '9be487ce6be705d210d42f8cbe6468226eeb544e' * commit '9be487ce6be705d210d42f8cbe6468226eeb544e': Add new Usb.ACTION_USB_STATE sticky broadcast for monitoring USB connect state
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/UsbObserver.java32
1 files changed, 21 insertions, 11 deletions
diff --git a/services/java/com/android/server/UsbObserver.java b/services/java/com/android/server/UsbObserver.java
index 3993a7f..d08fe9b 100644
--- a/services/java/com/android/server/UsbObserver.java
+++ b/services/java/com/android/server/UsbObserver.java
@@ -159,6 +159,16 @@ class UsbObserver extends UEventObserver {
}
private final Handler mHandler = new Handler() {
+ private void addEnabledFunctions(Intent intent) {
+ // include state of all USB functions in our extras
+ for (int i = 0; i < mEnabledFunctions.size(); i++) {
+ intent.putExtra(mEnabledFunctions.get(i), Usb.USB_FUNCTION_ENABLED);
+ }
+ for (int i = 0; i < mDisabledFunctions.size(); i++) {
+ intent.putExtra(mDisabledFunctions.get(i), Usb.USB_FUNCTION_DISABLED);
+ }
+ }
+
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
@@ -174,21 +184,21 @@ class UsbObserver extends UEventObserver {
// Send an Intent containing connected/disconnected state
// and the enabled/disabled state of all USB functions
Intent intent;
- if (mUsbConfig != 0) {
+ boolean usbConnected = (mUsbConfig != 0);
+ if (usbConnected) {
intent = new Intent(Usb.ACTION_USB_CONNECTED);
-
- // include state of all USB functions in our extras
- for (int i = 0; i < mEnabledFunctions.size(); i++) {
- intent.putExtra(mEnabledFunctions.get(i), Usb.USB_FUNCTION_ENABLED);
- }
- for (int i = 0; i < mDisabledFunctions.size(); i++) {
- intent.putExtra(mDisabledFunctions.get(i), Usb.USB_FUNCTION_DISABLED);
- }
+ addEnabledFunctions(intent);
} else {
intent = new Intent(Usb.ACTION_USB_DISCONNECTED);
}
-
- mContext.sendBroadcast(intent, android.Manifest.permission.ACCESS_USB);
+ mContext.sendBroadcast(intent);
+
+ // send a sticky broadcast for clients interested in both connect and disconnect
+ intent = new Intent(Usb.ACTION_USB_STATE);
+ intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
+ intent.putExtra(Usb.USB_CONNECTED, usbConnected);
+ addEnabledFunctions(intent);
+ mContext.sendStickyBroadcast(intent);
}
break;
}