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: I11495d039429dbe22bd738067296e39ae415befa
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2010-06-23 17:36:36 -04:00
parent 9163d42a50
commit 2423607a32
4 changed files with 290 additions and 1 deletions

View File

@@ -96,6 +96,7 @@ class ServerThread extends Thread {
BluetoothA2dpService bluetoothA2dp = null;
HeadsetObserver headset = null;
DockObserver dock = null;
UsbObserver usb = null;
UiModeManagerService uiMode = null;
RecognitionManagerService recognition = null;
ThrottleService throttle = null;
@@ -372,9 +373,17 @@ class ServerThread extends Thread {
Slog.e(TAG, "Failure starting DockObserver", e);
}
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);
@@ -461,6 +470,7 @@ class ServerThread extends Thread {
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;
@@ -483,6 +493,7 @@ class ServerThread extends Thread {
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();