| 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 55de9ccfb62fc54da0239fdbd926384f83bf738e..f9656e9182ac5f805b1da0f7009b861409a72e24 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
|
| @@ -429,15 +429,17 @@ class Fakes {
|
| final UUID mUuid;
|
| byte[] mValue;
|
| static FakeBluetoothGattCharacteristic sRememberedCharacteristic;
|
| + final ArrayList<Wrappers.BluetoothGattDescriptorWrapper> mDescriptors;
|
|
|
| public FakeBluetoothGattCharacteristic(
|
| FakeBluetoothGattService service, int instanceId, int properties, UUID uuid) {
|
| - super(null);
|
| + super(null, null);
|
| mService = service;
|
| mInstanceId = instanceId;
|
| mProperties = properties;
|
| mUuid = uuid;
|
| mValue = new byte[0];
|
| + mDescriptors = new ArrayList<Wrappers.BluetoothGattDescriptorWrapper>();
|
| }
|
|
|
| // Implements BluetoothTestAndroid::RememberCharacteristicForSubsequentAction.
|
| @@ -514,10 +516,35 @@ class Fakes {
|
| .mWriteCharacteristicWillFailSynchronouslyOnce = true;
|
| }
|
|
|
| + // Create a descriptor and add it to this characteristic.
|
| + @CalledByNative("FakeBluetoothGattCharacteristic")
|
| + private static void addDescriptor(
|
| + ChromeBluetoothRemoteGattCharacteristic chromeCharacteristic, String uuidString) {
|
| + FakeBluetoothGattCharacteristic fakeCharacteristic =
|
| + (FakeBluetoothGattCharacteristic) chromeCharacteristic.mCharacteristic;
|
| + UUID uuid = UUID.fromString(uuidString);
|
| +
|
| + // Check for duplicates
|
| + for (Wrappers.BluetoothGattDescriptorWrapper descriptor :
|
| + fakeCharacteristic.mDescriptors) {
|
| + if (descriptor.getUuid().equals(uuid)) {
|
| + throw new IllegalArgumentException(
|
| + "FakeBluetoothGattCharacteristic addDescriptor called with uuid '"
|
| + + uuidString + "' that has already been added to this characteristic.");
|
| + }
|
| + }
|
| + fakeCharacteristic.mDescriptors.add(new FakeBluetoothGattDescriptor(uuid));
|
| + }
|
| +
|
| // -----------------------------------------------------------------------------------------
|
| // Wrappers.BluetoothGattCharacteristicWrapper overrides:
|
|
|
| @Override
|
| + public List<Wrappers.BluetoothGattDescriptorWrapper> getDescriptors() {
|
| + return mDescriptors;
|
| + }
|
| +
|
| + @Override
|
| public int getInstanceId() {
|
| return mInstanceId;
|
| }
|
| @@ -544,6 +571,26 @@ class Fakes {
|
| }
|
| }
|
|
|
| + /**
|
| + * Fakes android.bluetooth.BluetoothGattDescriptor.
|
| + */
|
| + static class FakeBluetoothGattDescriptor extends Wrappers.BluetoothGattDescriptorWrapper {
|
| + final UUID mUuid;
|
| +
|
| + public FakeBluetoothGattDescriptor(UUID uuid) {
|
| + super(null);
|
| + mUuid = uuid;
|
| + }
|
| +
|
| + // -----------------------------------------------------------------------------------------
|
| + // Wrappers.BluetoothGattDescriptorWrapper overrides:
|
| +
|
| + @Override
|
| + public UUID getUuid() {
|
| + return mUuid;
|
| + }
|
| + }
|
| +
|
| // ---------------------------------------------------------------------------------------------
|
| // BluetoothTestAndroid C++ methods declared for access from java:
|
|
|
|
|