diff options
| author | 2020-03-18 01:41:45 +0000 | |
|---|---|---|
| committer | 2020-03-18 01:41:45 +0000 | |
| commit | 1324df73de4703eb39f32d14d9d117e00394b71b (patch) | |
| tree | c19801c8055b054ae61b428e060ec7a342491e04 | |
| parent | 377e812389d80def772ae2df49e4b4f27ee7d193 (diff) | |
| parent | e177e7bd428d520d4aa1752a5875fd657d06e986 (diff) | |
Merge "Fix function setting failed in Developer options" into rvc-dev
| -rw-r--r-- | services/usb/java/com/android/server/usb/UsbDeviceManager.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java index 8e85bb23b5c7..747c8d9d0890 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -445,7 +445,6 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser abstract static class UsbHandler extends Handler { // current USB state - private boolean mConnected; private boolean mHostConnected; private boolean mSourcePower; private boolean mSinkPower; @@ -473,6 +472,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser private final UsbPermissionManager mPermissionManager; private NotificationManager mNotificationManager; + protected boolean mConnected; protected long mScreenUnlockedFunctions; protected boolean mBootCompleted; protected boolean mCurrentFunctionsApplied; @@ -1794,7 +1794,8 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser case MSG_SET_FUNCTIONS_TIMEOUT: Slog.e(TAG, "Set functions timed out! no reply from usb hal"); if (msg.arg1 != 1) { - setEnabledFunctions(UsbManager.FUNCTION_NONE, false); + // Set this since default function may be selected from Developer options + setEnabledFunctions(mScreenUnlockedFunctions, false); } break; case MSG_GET_CURRENT_USB_FUNCTIONS: @@ -1816,7 +1817,8 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser * Dont force to default when the configuration is already set to default. */ if (msg.arg1 != 1) { - setEnabledFunctions(UsbManager.FUNCTION_NONE, !isAdbEnabled()); + // Set this since default function may be selected from Developer options + setEnabledFunctions(mScreenUnlockedFunctions, false); } break; case MSG_GADGET_HAL_REGISTERED: @@ -1936,8 +1938,11 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser SET_FUNCTIONS_TIMEOUT_MS - SET_FUNCTIONS_LEEWAY_MS); sendMessageDelayed(MSG_SET_FUNCTIONS_TIMEOUT, chargingFunctions, SET_FUNCTIONS_TIMEOUT_MS); - sendMessageDelayed(MSG_FUNCTION_SWITCH_TIMEOUT, chargingFunctions, - SET_FUNCTIONS_TIMEOUT_MS + ENUMERATION_TIME_OUT_MS); + if (mConnected) { + // Only queue timeout of enumeration when the USB is connected + sendMessageDelayed(MSG_FUNCTION_SWITCH_TIMEOUT, chargingFunctions, + SET_FUNCTIONS_TIMEOUT_MS + ENUMERATION_TIME_OUT_MS); + } if (DEBUG) Slog.d(TAG, "timeout message queued"); } catch (RemoteException e) { Slog.e(TAG, "Remoteexception while calling setCurrentUsbFunctions", e); |