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

Commit 47c6514e authored by Guang Zhu's avatar Guang Zhu Committed by Android Git Automerger
Browse files

am cd98ecc6: am 6071e45a: Merge "add a command to list all bonded devices" into klp-modular-dev

* commit 'cd98ecc6':
  add a command to list all bonded devices
parents 05ee0414 cd98ecc6
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.app.Instrumentation;
import android.content.Context;
import android.os.Bundle;

import java.util.Set;

public class BluetoothInstrumentation extends Instrumentation {

    private BluetoothTestUtils mUtils = null;
@@ -66,6 +68,8 @@ public class BluetoothInstrumentation extends Instrumentation {
            getName();
        } else if ("getAddress".equals(command)) {
            getAddress();
        } else if ("getBondedDevices".equals(command)) {
            getBondedDevices();
        } else {
            finish(null);
        }
@@ -98,6 +102,16 @@ public class BluetoothInstrumentation extends Instrumentation {
        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) {
        if (result == null) {
            result = new Bundle();