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

Commit b401e0a8 authored by Joshua Duong's avatar Joshua Duong
Browse files

Add AdbTransportType.aidl. Add AdbWifi internal API stubs.

Since wireless debugging can be enabled without usb debugging enabled,
we'll need to differentiate between which transport is enabled.

Also added the internal AdbManager stubs for wireless debugging. Adding
implementation in separate CL to get around merge conflict with a SysUI
CL in the stack.

BUG: b/111434128

Test: make
Exempt-From-Owner-Approval: already approved
Change-Id: I4e1ae6398f291f321e61e7eb119564ebd5e54c2e
parent ecd7c440
Loading
Loading
Loading
Loading
+108 −0
Original line number Diff line number Diff line
@@ -31,6 +31,114 @@ import android.os.RemoteException;
public class AdbManager {
    private static final String TAG = "AdbManager";

    /**
     * Action indicating the state change of wireless debugging. Can be either
     *   STATUS_CONNECTED
     *   STATUS_DISCONNECTED
     *
     * @hide
     */
    public static final String WIRELESS_DEBUG_STATE_CHANGED_ACTION =
            "com.android.server.adb.WIRELESS_DEBUG_STATUS";

    /**
     * Contains the list of paired devices.
     *
     * @hide
     */
    public static final String WIRELESS_DEBUG_PAIRED_DEVICES_ACTION =
            "com.android.server.adb.WIRELESS_DEBUG_PAIRED_DEVICES";

    /**
     * Action indicating the status of a pairing. Can be either
     *   WIRELESS_STATUS_FAIL
     *   WIRELESS_STATUS_SUCCESS
     *   WIRELESS_STATUS_CANCELLED
     *   WIRELESS_STATUS_PAIRING_CODE
     *   WIRELESS_STATUS_CONNECTED
     *
     * @hide
     */
    public static final String WIRELESS_DEBUG_PAIRING_RESULT_ACTION =
            "com.android.server.adb.WIRELESS_DEBUG_PAIRING_RESULT";

    /**
     * Extra containing the PairDevice map of paired/pairing devices.
     *
     * @hide
     */
    public static final String WIRELESS_DEVICES_EXTRA = "devices_map";

    /**
     * The status of the pairing/unpairing.
     *
     * @hide
     */
    public static final String WIRELESS_STATUS_EXTRA = "status";

    /**
     * The PairDevice.
     *
     * @hide
     */
    public static final String WIRELESS_PAIR_DEVICE_EXTRA = "pair_device";

    /**
     * The six-digit pairing code.
     *
     * @hide
     */
    public static final String WIRELESS_PAIRING_CODE_EXTRA = "pairing_code";

    /**
     * The adb connection/pairing port that was opened.
     *
     * @hide
     */
    public static final String WIRELESS_DEBUG_PORT_EXTRA = "adb_port";

    /**
     * Status indicating the pairing/unpairing failed.
     *
     * @hide
     */
    public static final int WIRELESS_STATUS_FAIL = 0;

    /**
     * Status indicating the pairing/unpairing succeeded.
     *
     * @hide
     */
    public static final int WIRELESS_STATUS_SUCCESS = 1;

    /**
     * Status indicating the pairing/unpairing was cancelled.
     *
     * @hide
     */
    public static final int WIRELESS_STATUS_CANCELLED = 2;

    /**
     * Status indicating the pairing code for pairing.
     *
     * @hide
     */
    public static final int WIRELESS_STATUS_PAIRING_CODE = 3;

    /**
     * Status indicating wireless debugging is connected.
     *
     * @hide
     */
    public static final int WIRELESS_STATUS_CONNECTED = 4;

    /**
     * Status indicating wireless debugging is disconnected.
     *
     * @hide
     */
    public static final int WIRELESS_STATUS_DISCONNECTED = 5;

    private final Context mContext;
    private final IAdbManager mService;

+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public abstract class AdbManagerInternal {
    /**
     * Returns {@code true} if ADB debugging is enabled.
     */
    public abstract boolean isAdbEnabled();
    public abstract boolean isAdbEnabled(byte transportType);

    /**
     * Returns the file that contains all of the ADB keys used by the device.
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.debug;

/** @hide */
@Backing(type="byte")
enum AdbTransportType {
    USB,
    WIFI,
}
+56 −0
Original line number Diff line number Diff line
@@ -42,6 +42,62 @@ interface IAdbManager {
     */
    void clearDebuggingKeys();

    /**
     * Allow ADB wireless debugging on the connected network. If {@code alwaysAllow}
     * is {@code true}, add {@code bssid} to list of networks that the user has
     * approved.
     *
     * @param alwaysAllow if true, add permanently to list of allowed networks
     * @param bssid BSSID of the network
     */
    void allowWirelessDebugging(boolean alwaysAllow, String bssid);

    /**
     * Deny ADB wireless debugging on the connected network.
     */
    void denyWirelessDebugging();

    /**
     * Returns a Map<String, PairDevice> with the key fingerprint mapped to the device information.
     */
    Map getPairedDevices();

    /**
     * Unpair the device identified by the key fingerprint it uses.
     *
     * @param fingerprint fingerprint of the key the device is using.
     */
    void unpairDevice(String fingerprint);

    /**
     * Enables pairing by pairing code. The result of the enable will be sent via intent action
     * {@link android.debug.AdbManager#WIRELESS_DEBUG_ENABLE_DISCOVER_ACTION}. Furthermore, the
     * pairing code will also be sent in the intent as an extra
     * @{link android.debug.AdbManager#WIRELESS_PAIRING_CODE_EXTRA}. Note that only one
     * pairing method can be enabled at a time, either by pairing code, or by QR code.
     */
    void enablePairingByPairingCode();

    /**
     * Enables pairing by QR code. The result of the enable will be sent via intent action
     * {@link android.debug.AdbManager#WIRELESS_DEBUG_ENABLE_DISCOVER_ACTION}. Note that only one
     * pairing method can be enabled at a time, either by pairing code, or by QR code.
     *
     * @param serviceName The MDNS service name parsed from the QR code.
     * @param password The password parsed from the QR code.
     */
    void enablePairingByQrCode(String serviceName, String password);

    /**
     * Returns the network port that adb wireless server is running on.
     */
    int getAdbWirelessPort();

    /**
     * Disables pairing.
     */
    void disablePairing();

    /**
     * Returns true if device supports secure Adb over Wi-Fi.
     */
+3 −1
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

package android.debug;

import android.debug.AdbTransportType;

/** @hide */
interface IAdbTransport {
    void onAdbEnabled(boolean enabled);
    void onAdbEnabled(boolean enabled, in AdbTransportType type);
}
Loading