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

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

Issue 1574773002: bluetooth: android: Initial basic Descriptors implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-code-cleanup-
Patch Set: addressed j again 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/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattCharacteristic.java
diff --git a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattCharacteristic.java b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattCharacteristic.java
index b02d0799277b4904d056eb9e23d305c1b4c2e4e7..696d8f71f0a25b3702caef586a928cfabc7d21b7 100644
--- a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattCharacteristic.java
+++ b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattCharacteristic.java
@@ -8,6 +8,8 @@ import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
+import java.util.List;
+
/**
* Exposes android.bluetooth.BluetoothGattCharacteristic as necessary
* for C++ device::BluetoothRemoteGattCharacteristicAndroid.
@@ -21,15 +23,17 @@ final class ChromeBluetoothRemoteGattCharacteristic {
private long mNativeBluetoothRemoteGattCharacteristicAndroid;
final Wrappers.BluetoothGattCharacteristicWrapper mCharacteristic;
+ final String mInstanceId;
final ChromeBluetoothDevice mChromeDevice;
private ChromeBluetoothRemoteGattCharacteristic(
long nativeBluetoothRemoteGattCharacteristicAndroid,
- Wrappers.BluetoothGattCharacteristicWrapper characteristicWrapper,
+ Wrappers.BluetoothGattCharacteristicWrapper characteristicWrapper, String instanceId,
ChromeBluetoothDevice chromeDevice) {
mNativeBluetoothRemoteGattCharacteristicAndroid =
nativeBluetoothRemoteGattCharacteristicAndroid;
mCharacteristic = characteristicWrapper;
+ mInstanceId = instanceId;
mChromeDevice = chromeDevice;
mChromeDevice.mWrapperToChromeCharacteristicsMap.put(characteristicWrapper, this);
@@ -72,11 +76,12 @@ final class ChromeBluetoothRemoteGattCharacteristic {
@CalledByNative
private static ChromeBluetoothRemoteGattCharacteristic create(
long nativeBluetoothRemoteGattCharacteristicAndroid,
- Object bluetoothGattCarachteristicWrapper, Object chromeDevice) {
+ Object bluetoothGattCharacteristicWrapper, String instanceId,
+ ChromeBluetoothDevice chromeDevice) {
return new ChromeBluetoothRemoteGattCharacteristic(
nativeBluetoothRemoteGattCharacteristicAndroid,
- (Wrappers.BluetoothGattCharacteristicWrapper) bluetoothGattCarachteristicWrapper,
- (ChromeBluetoothDevice) chromeDevice);
+ (Wrappers.BluetoothGattCharacteristicWrapper) bluetoothGattCharacteristicWrapper,
+ instanceId, chromeDevice);
}
// Implements BluetoothRemoteGattCharacteristicAndroid::GetUUID.
@@ -127,6 +132,21 @@ final class ChromeBluetoothRemoteGattCharacteristic {
return true;
}
+ // Creates objects for all descriptors. Designed only to be called by
+ // BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated.
+ @CalledByNative
+ private void createDescriptors() {
+ List<Wrappers.BluetoothGattDescriptorWrapper> descriptors =
+ mCharacteristic.getDescriptors();
+ for (Wrappers.BluetoothGattDescriptorWrapper descriptor : descriptors) {
+ // Create an adapter unique descriptor ID.
+ // TODO(crbug.com/576900) Unique descriptorInstanceId duplicate UUID values.
+ String descriptorInstanceId = mInstanceId + "/" + descriptor.getUuid().toString();
+ nativeCreateGattRemoteDescriptor(mNativeBluetoothRemoteGattCharacteristicAndroid,
+ descriptorInstanceId, descriptor, mChromeDevice);
+ }
+ }
+
// ---------------------------------------------------------------------------------------------
// BluetoothAdapterDevice C++ methods declared for access from java:
@@ -136,4 +156,10 @@ final class ChromeBluetoothRemoteGattCharacteristic {
// Binds to BluetoothRemoteGattCharacteristicAndroid::OnWrite.
native void nativeOnWrite(long nativeBluetoothRemoteGattCharacteristicAndroid, int status);
+
+ // Binds to BluetoothRemoteGattCharacteristicAndroid::CreateGattRemoteDescriptor.
+ // TODO(http://crbug.com/505554): Replace 'Object' with specific type when JNI fixed.
+ private native void nativeCreateGattRemoteDescriptor(
+ long nativeBluetoothRemoteGattCharacteristicAndroid, String instanceId,
+ Object bluetoothGattDescriptorWrapper, Object chromeBluetoothDevice);
}

Powered by Google App Engine
This is Rietveld 408576698