Merge "IAdbManager.getPairDevices returns FingerprintAndPairDevice[]." am: e9e1f5afa7

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1780474

Change-Id: I848b4fa8b5ee660702ff1d630bab832d4da843d7
This commit is contained in:
Treehugger Robot
2021-08-10 03:07:39 +00:00
committed by Automerger Merge Worker
3 changed files with 47 additions and 6 deletions

View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2021 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;
import android.debug.PairDevice;
/**
* @see {@link android.debug.IAdbManager#getPairedDevices()}
* @hide
*/
parcelable FingerprintAndPairDevice {
String keyFingerprint;
PairDevice device;
}

View File

@@ -16,6 +16,8 @@
package android.debug;
import android.debug.FingerprintAndPairDevice;
/**
* Interface to communicate remotely with the {@code AdbService} in the system server.
*
@@ -58,9 +60,10 @@ interface IAdbManager {
void denyWirelessDebugging();
/**
* Returns a Map<String, PairDevice> with the key fingerprint mapped to the device information.
* Returns an array of NamedPairDevice with the key fingerprint mapped to the device
* information.
*/
Map getPairedDevices();
FingerprintAndPairDevice[] getPairedDevices();
/**
* Unpair the device identified by the key fingerprint it uses.

View File

@@ -27,6 +27,7 @@ import android.database.ContentObserver;
import android.debug.AdbManager;
import android.debug.AdbManagerInternal;
import android.debug.AdbTransportType;
import android.debug.FingerprintAndPairDevice;
import android.debug.IAdbManager;
import android.debug.IAdbTransport;
import android.debug.PairDevice;
@@ -348,12 +349,21 @@ public class AdbService extends IAdbManager.Stub {
}
@Override
public Map<String, PairDevice> getPairedDevices() {
public FingerprintAndPairDevice[] getPairedDevices() {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_DEBUGGING, null);
if (mDebuggingManager != null) {
return mDebuggingManager.getPairedDevices();
if (mDebuggingManager == null) {
return null;
}
return null;
Map<String, PairDevice> map = mDebuggingManager.getPairedDevices();
FingerprintAndPairDevice[] ret = new FingerprintAndPairDevice[map.size()];
int i = 0;
for (Map.Entry<String, PairDevice> entry : map.entrySet()) {
ret[i] = new FingerprintAndPairDevice();
ret[i].keyFingerprint = entry.getKey();
ret[i].device = entry.getValue();
i++;
}
return ret;
}
@Override