Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f9e88a4 authored by David Stevens's avatar David Stevens
Browse files

Exit accessory mode more aggressively

The debouncing of USB disconnects means that the disconnect caused
by resetting the connection without unplugging the device does not make
it to the handler, and thus doesn't exit accessory mode. Therefore we
must exit accessory mode even for connect events after we have left the
entering accessory mode state.

Test: Manual testing with desktop head unit
Change-Id: Ia028ff28783fa777a9f8bcd86b523d01f633a140
parent 41c4d379
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -599,8 +599,12 @@ public class UsbDeviceManager {
                } else {
                    Slog.e(TAG, "nativeGetAccessoryStrings failed");
                }
            } else if (!mConnected && !enteringAccessoryMode) {
            } else {
                if (!enteringAccessoryMode) {
                    notifyAccessoryModeExit();
                } else if (DEBUG) {
                    Slog.v(TAG, "Debouncing accessory mode exit");
                }
            }
        }

@@ -805,6 +809,9 @@ public class UsbDeviceManager {
                    break;
                }
                case MSG_ACCESSORY_MODE_ENTER_TIMEOUT: {
                    if (DEBUG) {
                        Slog.v(TAG, "Accessory mode enter timeout: " + mConnected);
                    }
                    if (!mConnected) {
                        notifyAccessoryModeExit();
                    }