Merge "add a command to list all bonded devices" into klp-modular-dev

This commit is contained in:
Guang Zhu
2014-05-20 04:36:47 +00:00
committed by Android (Google) Code Review

View File

@ -20,6 +20,8 @@ import android.app.Instrumentation;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import java.util.Set;
public class BluetoothInstrumentation extends Instrumentation { public class BluetoothInstrumentation extends Instrumentation {
private BluetoothTestUtils mUtils = null; private BluetoothTestUtils mUtils = null;
@ -66,6 +68,8 @@ public class BluetoothInstrumentation extends Instrumentation {
getName(); getName();
} else if ("getAddress".equals(command)) { } else if ("getAddress".equals(command)) {
getAddress(); getAddress();
} else if ("getBondedDevices".equals(command)) {
getBondedDevices();
} else { } else {
finish(null); finish(null);
} }
@ -98,6 +102,16 @@ public class BluetoothInstrumentation extends Instrumentation {
finish(mSuccessResult); finish(mSuccessResult);
} }
public void getBondedDevices() {
Set<BluetoothDevice> devices = getBluetoothAdapter().getBondedDevices();
int i = 0;
for (BluetoothDevice device : devices) {
mSuccessResult.putString(String.format("device-%02d", i), device.getAddress());
i++;
}
finish(mSuccessResult);
}
public void finish(Bundle result) { public void finish(Bundle result) {
if (result == null) { if (result == null) {
result = new Bundle(); result = new Bundle();