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

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

Issue 1502833002: bluetooth: android: Enable characteristic change notification events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-check-null-
Patch Set: fix imports 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 56c950edf773b663fcd3481b7299b1f29b9296ff..09da34b73c374d8bb8c71e197ddfd5455fd7651c 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
@@ -454,6 +454,24 @@ class Fakes {
mDescriptors = new ArrayList<Wrappers.BluetoothGattDescriptorWrapper>();
}
+ // Simulate a characteristic value notified as changed.
+ @CalledByNative("FakeBluetoothGattCharacteristic")
+ private static void valueChanged(
+ ChromeBluetoothRemoteGattCharacteristic chromeCharacteristic, byte[] value) {
+ if (chromeCharacteristic == null && sRememberedCharacteristic == null) {
+ throw new IllegalArgumentException(
+ "rememberCharacteristic wasn't called previously.");
+ }
+
+ FakeBluetoothGattCharacteristic fakeCharacteristic = (chromeCharacteristic == null)
+ ? sRememberedCharacteristic
+ : (FakeBluetoothGattCharacteristic) chromeCharacteristic.mCharacteristic;
+
+ fakeCharacteristic.mValue = value;
+ fakeCharacteristic.mService.mDevice.mGattCallback.onCharacteristicChanged(
+ fakeCharacteristic);
+ }
+
// Implements BluetoothTestAndroid::RememberCharacteristicForSubsequentAction.
@CalledByNative("FakeBluetoothGattCharacteristic")
private static void rememberCharacteristicForSubsequentAction(
@@ -553,6 +571,16 @@ class Fakes {
// Wrappers.BluetoothGattCharacteristicWrapper overrides:
@Override
+ public Wrappers.BluetoothGattDescriptorWrapper getDescriptor(UUID uuid) {
+ for (Wrappers.BluetoothGattDescriptorWrapper descriptor : mDescriptors) {
+ if (descriptor.getUuid().equals(uuid)) {
+ return descriptor;
+ }
+ }
+ return null;
+ }
+
+ @Override
public List<Wrappers.BluetoothGattDescriptorWrapper> getDescriptors() {
return mDescriptors;
}
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc ('k') | device/bluetooth/test/bluetooth_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698