OSDN Git Service

Revert "UsbDeviceManager: Fix race condition between accessory start and USB configur...
authorMike Lockwood <lockwood@google.com>
Wed, 19 Mar 2014 23:56:18 +0000 (16:56 -0700)
committerThe Android Automerger <android-build@android.com>
Fri, 21 Mar 2014 14:29:28 +0000 (07:29 -0700)
This reverts commit fbd5521fb5e94fad066e21b9f91f4782afe71660.

This change broke support for the 2011 ADK board, which never sends a "set configuration"
command before "accessory start".  So we revert this change and will replace it with a better fix.

Bug: 13535051
Bug: 13393825

Change-Id: Icd870d7ff6daff1567e04d93907f70f5d7e37884

services/java/com/android/server/usb/UsbDeviceManager.java

index 5622dc4..bb61e49 100644 (file)
@@ -89,7 +89,6 @@ public class UsbDeviceManager {
     private static final int MSG_SYSTEM_READY = 3;
     private static final int MSG_BOOT_COMPLETED = 4;
     private static final int MSG_USER_SWITCHED = 5;
-    private static final int MSG_START_ACCESSORY_MODE = 6;
 
     private static final int AUDIO_MODE_NONE = 0;
     private static final int AUDIO_MODE_SOURCE = 1;
@@ -152,7 +151,7 @@ public class UsbDeviceManager {
                 mHandler.updateState(state);
             } else if ("START".equals(accessory)) {
                 if (DEBUG) Slog.d(TAG, "got accessory start");
-                 mHandler.sendEmptyMessage(MSG_START_ACCESSORY_MODE);
+                startAccessoryMode();
             }
         }
     };
@@ -170,7 +169,7 @@ public class UsbDeviceManager {
 
         if (nativeIsStartRequested()) {
             if (DEBUG) Slog.d(TAG, "accessory attached at boot");
-             mHandler.sendEmptyMessage(MSG_START_ACCESSORY_MODE);
+            startAccessoryMode();
         }
 
         boolean secureAdbEnabled = SystemProperties.getBoolean("ro.adb.secure", false);
@@ -232,8 +231,6 @@ public class UsbDeviceManager {
             functions = UsbManager.USB_FUNCTION_AUDIO_SOURCE;
         }
 
-        if (DEBUG) Slog.d(TAG, "startAccessoryMode: " + functions);
-
         if (functions != null) {
             mAccessoryModeRequestTime = SystemClock.elapsedRealtime();
             setCurrentFunctions(functions, false);
@@ -313,7 +310,6 @@ public class UsbDeviceManager {
         // current USB state
         private boolean mConnected;
         private boolean mConfigured;
-        private boolean mAccessoryStartPending;
         private String mCurrentFunctions;
         private String mDefaultFunctions;
         private UsbAccessory mCurrentAccessory;
@@ -619,11 +615,6 @@ public class UsbDeviceManager {
                 case MSG_UPDATE_STATE:
                     mConnected = (msg.arg1 == 1);
                     mConfigured = (msg.arg2 == 1);
-
-                    if (!mConnected) {
-                        mAccessoryStartPending = false;
-                    }
-
                     updateUsbNotification();
                     updateAdbNotification();
                     if (containsFunction(mCurrentFunctions,
@@ -637,10 +628,6 @@ public class UsbDeviceManager {
                         updateUsbState();
                         updateAudioSourceFunction();
                     }
-                    if (mConnected && mConfigured && mAccessoryStartPending) {
-                        startAccessoryMode();
-                        mAccessoryStartPending = false;
-                    }
                     break;
                 case MSG_ENABLE_ADB:
                     setAdbEnabled(msg.arg1 == 1);
@@ -677,16 +664,6 @@ public class UsbDeviceManager {
                     mCurrentUser = msg.arg1;
                     break;
                 }
-                case MSG_START_ACCESSORY_MODE:
-                    if (mConnected && mConfigured) {
-                        startAccessoryMode();
-                    } else {
-                        // we sometimes receive the kernel "accessory start" uevent
-                        // before the "configured" uevent. In this case we need to defer
-                        // handling this event until after we received the configured event
-                        mAccessoryStartPending = true;
-                    }
-                    break;
             }
         }