| Index: device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java
|
| diff --git a/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java b/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java
|
| index 998450a3a49b79e304583e73de3cb9a86d215947..6dce4463e001a2173778afa2667cd0c4553d8d42 100644
|
| --- a/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java
|
| +++ b/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java
|
| @@ -74,6 +74,53 @@ class Fakes {
|
| });
|
| }
|
|
|
| + static class FakeBluetoothManager extends Wrappers.BluetoothManagerWrapper {
|
| + final long mNativeBluetoothTestAndroid;
|
| + ArrayList<Wrappers.BluetoothDeviceWrapper> mConnectedDevices;
|
| +
|
| + @CalledByNative("FakeBluetoothManager")
|
| + public static FakeBluetoothManager create(long nativeBluetoothTestAndroid) {
|
| + return new FakeBluetoothManager(nativeBluetoothTestAndroid);
|
| + }
|
| +
|
| + private FakeBluetoothManager(long nativeBluetoothTestAndroid) {
|
| + super(null);
|
| + mNativeBluetoothTestAndroid = nativeBluetoothTestAndroid;
|
| + mConnectedDevices = new ArrayList<>();
|
| + }
|
| +
|
| + @CalledByNative("FakeBluetoothManager")
|
| + public void simulateConnectedLowEnergyDevice(
|
| + int deviceType /* c++ enum BluetoothTest::ConnectedDeviceType */) {
|
| + switch (deviceType) {
|
| + case 0: {
|
| + ParcelUuid[] uuids = new ParcelUuid[] {
|
| + ParcelUuid.fromString("00001800-0000-1000-8000-00805f9b34fb")};
|
| + mConnectedDevices.add(new FakeBluetoothDevice(
|
| + null /* adapter */, "01:00:00:90:1E:BE", "FakeBluetoothDevice", uuids));
|
| + break;
|
| + }
|
| + case 1: {
|
| + ParcelUuid[] uuids = new ParcelUuid[] {
|
| + ParcelUuid.fromString("00001800-0000-1000-8000-00805f9b34fb"),
|
| + ParcelUuid.fromString("0000180d-0000-1000-8000-00805f9b34fb")};
|
| + mConnectedDevices.add(new FakeBluetoothDevice(
|
| + null /* adapter */, "02:00:00:8B:74:63", "FakeBluetoothDevice", uuids));
|
| + break;
|
| + }
|
| + }
|
| + }
|
| +
|
| + // -----------------------------------------------------------------------------------------
|
| + // BluetoothManagerWrapper overrides:
|
| +
|
| + @Override
|
| + public List<Wrappers.BluetoothDeviceWrapper> getConnectedDevices(int profile) {
|
| + nativeOnFakeManagerGetConnectedDevices(mNativeBluetoothTestAndroid);
|
| + return mConnectedDevices;
|
| + }
|
| + }
|
| +
|
| /**
|
| * Fakes android.bluetooth.BluetoothAdapter.
|
| */
|
| @@ -326,16 +373,23 @@ class Fakes {
|
| final FakeBluetoothAdapter mAdapter;
|
| private String mAddress;
|
| private String mName;
|
| + private ParcelUuid[] mUuids;
|
| final FakeBluetoothGatt mGatt;
|
| private Wrappers.BluetoothGattCallbackWrapper mGattCallback;
|
|
|
| static FakeBluetoothDevice sRememberedDevice;
|
|
|
| public FakeBluetoothDevice(FakeBluetoothAdapter adapter, String address, String name) {
|
| + this(adapter, address, name, null);
|
| + }
|
| +
|
| + public FakeBluetoothDevice(
|
| + FakeBluetoothAdapter adapter, String address, String name, ParcelUuid[] uuids) {
|
| super(null);
|
| mAdapter = adapter;
|
| mAddress = address;
|
| mName = name;
|
| + mUuids = uuids;
|
| mGatt = new FakeBluetoothGatt(this);
|
| }
|
|
|
| @@ -419,6 +473,11 @@ class Fakes {
|
| public String getName() {
|
| return mName;
|
| }
|
| +
|
| + @Override
|
| + public ParcelUuid[] getUuids() {
|
| + return mUuids;
|
| + }
|
| }
|
|
|
| /**
|
| @@ -838,6 +897,10 @@ class Fakes {
|
| // ---------------------------------------------------------------------------------------------
|
| // BluetoothTestAndroid C++ methods declared for access from java:
|
|
|
| + // Bind to BluetoothTestAndroid::OnFakeManagerGetConnectedDevices.
|
| + private static native void nativeOnFakeManagerGetConnectedDevices(
|
| + long nativeBluetoothTestAndroid);
|
| +
|
| // Binds to BluetoothTestAndroid::OnFakeAdapterStateChanged.
|
| private static native void nativeOnFakeAdapterStateChanged(
|
| long nativeBluetoothTestAndroid, boolean powered);
|
|
|