Add a new UEventObserver subclass to broadcast an Intent whe USB state changes.
We now broadcast Usb.ACTION_USB_CONNECTED and Usb.ACTION_USB_DISCONNECTED
when USB is connected or disconnected.
The ACTION_USB_CONNECTED extras indicate the enabled/disabled state of
all USB functions.
Change-Id: I919fcd5aa8d640d051cec87053f474a9843ed545
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index e511d1f..43a87f2 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -93,6 +93,7 @@
BluetoothA2dpService bluetoothA2dp = null;
HeadsetObserver headset = null;
DockObserver dock = null;
+ UsbObserver usb = null;
UiModeManagerService uiMode = null;
RecognitionManagerService recognition = null;
ThrottleService throttle = null;
@@ -365,8 +366,16 @@
}
try {
+ Slog.i(TAG, "USB Observer");
+ // Listen for USB changes
+ usb = new UsbObserver(context);
+ } catch (Throwable e) {
+ Slog.e(TAG, "Failure starting UsbObserver", e);
+ }
+
+ try {
Slog.i(TAG, "UI Mode Manager Service");
- // Listen for dock station changes
+ // Listen for UI mode changes
uiMode = new UiModeManagerService(context);
} catch (Throwable e) {
Slog.e(TAG, "Failure starting UiModeManagerService", e);
@@ -465,6 +474,7 @@
final BatteryService batteryF = battery;
final ConnectivityService connectivityF = connectivity;
final DockObserver dockF = dock;
+ final UsbObserver usbF = usb;
final ThrottleService throttleF = throttle;
final UiModeManagerService uiModeF = uiMode;
final AppWidgetService appWidgetF = appWidget;
@@ -487,6 +497,7 @@
if (batteryF != null) batteryF.systemReady();
if (connectivityF != null) connectivityF.systemReady();
if (dockF != null) dockF.systemReady();
+ if (usbF != null) usbF.systemReady();
if (uiModeF != null) uiModeF.systemReady();
if (recognitionF != null) recognitionF.systemReady();
Watchdog.getInstance().start();