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

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

Issue 1765773002: bluetooth: Refactor GetDescriptorForUUID to GetDescriptorsForUUID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-notify-tommyt-
Patch Set: GetDescriptorsForUUID split from other changes. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.device.bluetooth; 5 package org.chromium.device.bluetooth;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.os.Build; 8 import android.os.Build;
9 9
10 import org.chromium.base.Log; 10 import org.chromium.base.Log;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 private boolean setCharacteristicNotification(boolean enabled) { 141 private boolean setCharacteristicNotification(boolean enabled) {
142 return mChromeDevice.mBluetoothGatt.setCharacteristicNotification(mChara cteristic, enabled); 142 return mChromeDevice.mBluetoothGatt.setCharacteristicNotification(mChara cteristic, enabled);
143 } 143 }
144 144
145 // Creates objects for all descriptors. Designed only to be called by 145 // Creates objects for all descriptors. Designed only to be called by
146 // BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated. 146 // BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated.
147 @CalledByNative 147 @CalledByNative
148 private void createDescriptors() { 148 private void createDescriptors() {
149 List<Wrappers.BluetoothGattDescriptorWrapper> descriptors = 149 List<Wrappers.BluetoothGattDescriptorWrapper> descriptors =
150 mCharacteristic.getDescriptors(); 150 mCharacteristic.getDescriptors();
151 // descriptorInstanceId ensures duplicate UUIDs have unique instance
152 // IDs. BluetoothGattDescriptor does not offer getInstanceId the way
153 // BluetoothGattCharacteristic does.
154 //
155 // TODO(crbug.com/576906) Do not reuse IDs upon onServicesDiscovered.
156 int instanceIdCounter = 0;
151 for (Wrappers.BluetoothGattDescriptorWrapper descriptor : descriptors) { 157 for (Wrappers.BluetoothGattDescriptorWrapper descriptor : descriptors) {
152 // Create an adapter unique descriptor ID. 158 String descriptorInstanceId = mInstanceId + "/" + instanceIdCounter+ +;
ortuno 2016/03/13 20:41:44 Hmm I wonder if we should include the UUID. I thin
scheib 2016/03/25 00:13:57 Done: Including the UUID.
153 // TODO(crbug.com/576900) Unique descriptorInstanceId duplicate UUID values.
154 String descriptorInstanceId = mInstanceId + "/" + descriptor.getUuid ().toString();
155 nativeCreateGattRemoteDescriptor(mNativeBluetoothRemoteGattCharacter isticAndroid, 159 nativeCreateGattRemoteDescriptor(mNativeBluetoothRemoteGattCharacter isticAndroid,
156 descriptorInstanceId, descriptor, mChromeDevice); 160 descriptorInstanceId, descriptor, mChromeDevice);
157 } 161 }
158 } 162 }
159 163
160 // ------------------------------------------------------------------------- -------------------- 164 // ------------------------------------------------------------------------- --------------------
161 // BluetoothAdapterDevice C++ methods declared for access from java: 165 // BluetoothAdapterDevice C++ methods declared for access from java:
162 166
163 // Binds to BluetoothRemoteGattCharacteristicAndroid::OnChanged. 167 // Binds to BluetoothRemoteGattCharacteristicAndroid::OnChanged.
164 native void nativeOnChanged(long nativeBluetoothRemoteGattCharacteristicAndr oid, byte[] value); 168 native void nativeOnChanged(long nativeBluetoothRemoteGattCharacteristicAndr oid, byte[] value);
165 169
166 // Binds to BluetoothRemoteGattCharacteristicAndroid::OnRead. 170 // Binds to BluetoothRemoteGattCharacteristicAndroid::OnRead.
167 native void nativeOnRead( 171 native void nativeOnRead(
168 long nativeBluetoothRemoteGattCharacteristicAndroid, int status, byt e[] value); 172 long nativeBluetoothRemoteGattCharacteristicAndroid, int status, byt e[] value);
169 173
170 // Binds to BluetoothRemoteGattCharacteristicAndroid::OnWrite. 174 // Binds to BluetoothRemoteGattCharacteristicAndroid::OnWrite.
171 native void nativeOnWrite(long nativeBluetoothRemoteGattCharacteristicAndroi d, int status); 175 native void nativeOnWrite(long nativeBluetoothRemoteGattCharacteristicAndroi d, int status);
172 176
173 // Binds to BluetoothRemoteGattCharacteristicAndroid::CreateGattRemoteDescri ptor. 177 // Binds to BluetoothRemoteGattCharacteristicAndroid::CreateGattRemoteDescri ptor.
174 // TODO(http://crbug.com/505554): Replace 'Object' with specific type when J NI fixed. 178 // TODO(http://crbug.com/505554): Replace 'Object' with specific type when J NI fixed.
175 private native void nativeCreateGattRemoteDescriptor( 179 private native void nativeCreateGattRemoteDescriptor(
176 long nativeBluetoothRemoteGattCharacteristicAndroid, String instance Id, 180 long nativeBluetoothRemoteGattCharacteristicAndroid, String instance Id,
177 Object bluetoothGattDescriptorWrapper, Object chromeBluetoothDevice) ; 181 Object bluetoothGattDescriptorWrapper, Object chromeBluetoothDevice) ;
178 } 182 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698