Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1952)

Unified Diff: device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java

Issue 1574773002: bluetooth: android: Initial basic Descriptors implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-code-cleanup-
Patch Set: Defer c++ pointer to a later patch. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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:

Powered by Google App Engine
This is Rietveld 408576698