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

Commit fe39386a authored by Daichi Hirono's avatar Daichi Hirono Committed by Android (Google) Code Review
Browse files

Merge "Add USB_HOST_CONNECTED extra to ACTION_USB_STATE sticky intent." into nyc-dev

parents c469585c 618fa6ff
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line 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,
     * This is a sticky broadcast for clients that includes USB connected/disconnected state,
     * <ul>
     * <ul>
     * <li> {@link #USB_CONNECTED} boolean indicating whether USB is connected or disconnected.
     * <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.
     * <li> {@link #USB_CONFIGURED} boolean indicating whether USB is configured.
     * currently zero if not configured, one for configured.
     * currently zero if not configured, one for configured.
     * <li> {@link #USB_FUNCTION_ADB} boolean extra indicating whether the
     * <li> {@link #USB_FUNCTION_ADB} boolean extra indicating whether the
@@ -151,6 +153,14 @@ public class UsbManager {
     */
     */
    public static final String USB_CONNECTED = "connected";
    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.
     * Boolean extra indicating whether USB is configured.
     * Used in extras for the {@link #ACTION_USB_STATE} broadcast.
     * Used in extras for the {@link #ACTION_USB_STATE} broadcast.
+4 −0
Original line number Original line Diff line number Diff line
@@ -608,6 +608,7 @@ public class UsbDeviceManager {
            intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING
            intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING
                    | Intent.FLAG_RECEIVER_FOREGROUND);
                    | Intent.FLAG_RECEIVER_FOREGROUND);
            intent.putExtra(UsbManager.USB_CONNECTED, mConnected);
            intent.putExtra(UsbManager.USB_CONNECTED, mConnected);
            intent.putExtra(UsbManager.USB_HOST_CONNECTED, mHostConnected);
            intent.putExtra(UsbManager.USB_CONFIGURED, mConfigured);
            intent.putExtra(UsbManager.USB_CONFIGURED, mConfigured);
            intent.putExtra(UsbManager.USB_DATA_UNLOCKED, isUsbTransferAllowed() && mUsbDataUnlocked);
            intent.putExtra(UsbManager.USB_DATA_UNLOCKED, isUsbTransferAllowed() && mUsbDataUnlocked);


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