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

Commit 618fa6ff authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Add USB_HOST_CONNECTED extra to ACTION_USB_STATE sticky intent.

Previously UsbModeChooser activity is automatically closed when Android
is connected to another Android and works as host. This is because
ACTION_USB_STATE intent does not include the information whether Android
is connected as host and UsbModeChooser regards Android is not connected
USB devices.

The CL introduce the HOST_CONNECTED extra to ACTION_USB_STATE so that
UsbModeChooser can refer it.

BUG=27535640

Change-Id: Ie29583b78319078430f6d9a8390787780410ac8c
parent 62006a72
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ public class UsbManager {
     * This is a sticky broadcast for clients that includes USB connected/disconnected state,
     * <ul>
     * <li> {@link #USB_CONNECTED} boolean indicating whether USB is connected or disconnected.
     * <li> {@link #USB_HOST_CONNECTED} boolean indicating whether USB is connected or
     *     disconnected as host.
     * <li> {@link #USB_CONFIGURED} boolean indicating whether USB is configured.
     * currently zero if not configured, one for configured.
     * <li> {@link #USB_FUNCTION_ADB} boolean extra indicating whether the
@@ -151,6 +153,14 @@ public class UsbManager {
     */
    public static final String USB_CONNECTED = "connected";

    /**
     * Boolean extra indicating whether USB is connected or disconnected as host.
     * Used in extras for the {@link #ACTION_USB_STATE} broadcast.
     *
     * {@hide}
     */
    public static final String USB_HOST_CONNECTED = "host_connected";

    /**
     * Boolean extra indicating whether USB is configured.
     * Used in extras for the {@link #ACTION_USB_STATE} broadcast.
+4 −0
Original line number Diff line number Diff line
@@ -608,6 +608,7 @@ public class UsbDeviceManager {
            intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING
                    | Intent.FLAG_RECEIVER_FOREGROUND);
            intent.putExtra(UsbManager.USB_CONNECTED, mConnected);
            intent.putExtra(UsbManager.USB_HOST_CONNECTED, mHostConnected);
            intent.putExtra(UsbManager.USB_CONFIGURED, mConfigured);
            intent.putExtra(UsbManager.USB_DATA_UNLOCKED, isUsbTransferAllowed() && mUsbDataUnlocked);

@@ -717,6 +718,9 @@ public class UsbDeviceManager {
                case MSG_UPDATE_HOST_STATE:
                    mHostConnected = (msg.arg1 == 1);
                    updateUsbNotification();
                    if (mBootCompleted) {
                        updateUsbStateBroadcastIfNeeded();
                    }
                    break;
                case MSG_ENABLE_ADB:
                    setAdbEnabled(msg.arg1 == 1);