Merge "Add SystemApis isAdbWifiSupported(), isAdbWifiQRSupported() to AdbManager."
This commit is contained in:
@@ -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 {
|
package android.hardware {
|
||||||
|
|
||||||
public final class Sensor {
|
public final class Sensor {
|
||||||
|
|||||||
@@ -16,15 +16,17 @@
|
|||||||
|
|
||||||
package android.debug;
|
package android.debug;
|
||||||
|
|
||||||
|
import android.annotation.RequiresPermission;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
import android.annotation.SystemService;
|
import android.annotation.SystemService;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.RemoteException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class allows the control of ADB-related functions. Currently only ADB over USB is
|
* This class allows the control of ADB-related functions.
|
||||||
* supported, and none of the API is public.
|
|
||||||
*
|
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi
|
||||||
@SystemService(Context.ADB_SERVICE)
|
@SystemService(Context.ADB_SERVICE)
|
||||||
public class AdbManager {
|
public class AdbManager {
|
||||||
private static final String TAG = "AdbManager";
|
private static final String TAG = "AdbManager";
|
||||||
@@ -39,4 +41,33 @@ public class AdbManager {
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
mService = service;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,4 +41,15 @@ interface IAdbManager {
|
|||||||
* Clear all public keys installed for secure ADB debugging.
|
* Clear all public keys installed for secure ADB debugging.
|
||||||
*/
|
*/
|
||||||
void clearDebuggingKeys();
|
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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package com.android.server.adb;
|
|||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.debug.AdbManagerInternal;
|
import android.debug.AdbManagerInternal;
|
||||||
import android.debug.IAdbManager;
|
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) {
|
private void setAdbEnabled(boolean enable) {
|
||||||
if (DEBUG) Slog.d(TAG, "setAdbEnabled(" + enable + "), mAdbEnabled=" + mAdbEnabled);
|
if (DEBUG) Slog.d(TAG, "setAdbEnabled(" + enable + "), mAdbEnabled=" + mAdbEnabled);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user