Chromium Code Reviews| 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..c8c07e055ccd72f873e1537ce474317ddbf48cf8 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,11 @@ final class ChromeBluetoothRemoteGattCharacteristic { |
| @CalledByNative |
| private static ChromeBluetoothRemoteGattCharacteristic create( |
| long nativeBluetoothRemoteGattCharacteristicAndroid, |
| - Object bluetoothGattCarachteristicWrapper, Object chromeDevice) { |
| + Object bluetoothGattCharacteristicWrapper, String instanceId, Object chromeDevice) { |
| return new ChromeBluetoothRemoteGattCharacteristic( |
| nativeBluetoothRemoteGattCharacteristicAndroid, |
| - (Wrappers.BluetoothGattCharacteristicWrapper) bluetoothGattCarachteristicWrapper, |
| - (ChromeBluetoothDevice) chromeDevice); |
| + (Wrappers.BluetoothGattCharacteristicWrapper) bluetoothGattCharacteristicWrapper, |
| + instanceId, (ChromeBluetoothDevice) chromeDevice); |
| } |
| // Implements BluetoothRemoteGattCharacteristicAndroid::GetUUID. |
| @@ -127,6 +131,19 @@ final class ChromeBluetoothRemoteGattCharacteristic { |
| return true; |
| } |
| + // Implements BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated. |
| + @CalledByNative |
| + private void ensureDescriptorsCreated() { |
|
Jeffrey Yasskin
2016/01/12 21:53:53
I'm not sure 'ensure' is the right word here. It l
scheib
2016/01/12 23:16:55
Done.
|
| + List<Wrappers.BluetoothGattDescriptorWrapper> descriptors = |
| + mCharacteristic.getDescriptors(); |
| + for (Wrappers.BluetoothGattDescriptorWrapper descriptor : descriptors) { |
| + // Create an adapter unique descriptor ID. |
| + String descriptorInstanceId = mInstanceId + "/" + descriptor.getUuid().toString(); |
| + nativeCreateGattRemoteDescriptor(mNativeBluetoothRemoteGattCharacteristicAndroid, |
| + descriptorInstanceId, descriptor, mChromeDevice); |
| + } |
| + } |
| + |
| // --------------------------------------------------------------------------------------------- |
| // BluetoothAdapterDevice C++ methods declared for access from java: |
| @@ -136,4 +153,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); |
| } |