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

Commit e9beb8dd authored by Joshua Duong's avatar Joshua Duong Committed by Gerrit Code Review
Browse files

Merge "Add SystemApis isAdbWifiSupported(), isAdbWifiQRSupported() to AdbManager."

parents 7790a360 a5cbda47
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2092,6 +2092,15 @@ package android.content.rollback {
}
package android.debug {
  public class AdbManager {
    method @RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING) public boolean isAdbWifiQrSupported();
    method @RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING) public boolean isAdbWifiSupported();
  }
}
package android.hardware {
  public final class Sensor {
+34 −3
Original line number Diff line number Diff line
@@ -16,15 +16,17 @@

package android.debug;

import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
import android.os.RemoteException;

/**
 * This class allows the control of ADB-related functions. Currently only ADB over USB is
 * supported, and none of the API is public.
 *
 * This class allows the control of ADB-related functions.
 * @hide
 */
@SystemApi
@SystemService(Context.ADB_SERVICE)
public class AdbManager {
    private static final String TAG = "AdbManager";
@@ -39,4 +41,33 @@ public class AdbManager {
        mContext = context;
        mService = service;
    }

    /**
     * @return true if the device supports secure ADB over Wi-Fi.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING)
    public boolean isAdbWifiSupported() {
        try {
            return mService.isAdbWifiSupported();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @return true if the device supports secure ADB over Wi-Fi and device pairing by
     * QR code.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING)
    public boolean isAdbWifiQrSupported() {
        try {
            return mService.isAdbWifiQrSupported();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -41,4 +41,15 @@ interface IAdbManager {
     * Clear all public keys installed for secure ADB debugging.
     */
    void clearDebuggingKeys();

    /**
     * Returns true if device supports secure Adb over Wi-Fi.
     */
    boolean isAdbWifiSupported();

    /**
     * Returns true if device supports secure Adb over Wi-Fi and device pairing by
     * QR code.
     */
    boolean isAdbWifiQrSupported();
}
+25 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.server.adb;

import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
import android.database.ContentObserver;
import android.debug.AdbManagerInternal;
import android.debug.IAdbManager;
@@ -260,6 +261,30 @@ public class AdbService extends IAdbManager.Stub {
        }
    }

    /**
     * @return true if the device supports secure ADB over Wi-Fi.
     * @hide
     */
    @Override
    public boolean isAdbWifiSupported() {
        mContext.enforceCallingPermission(
                android.Manifest.permission.MANAGE_DEBUGGING, "AdbService");
        return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI);
    }

    /**
     * @return true if the device supports secure ADB over Wi-Fi and device pairing by
     * QR code.
     * @hide
     */
    @Override
    public boolean isAdbWifiQrSupported() {
        mContext.enforceCallingPermission(
                android.Manifest.permission.MANAGE_DEBUGGING, "AdbService");
        return isAdbWifiSupported() && mContext.getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_CAMERA_ANY);
    }

    private void setAdbEnabled(boolean enable) {
        if (DEBUG) Slog.d(TAG, "setAdbEnabled(" + enable + "), mAdbEnabled=" + mAdbEnabled);