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

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

Issue 1414553004: bluetooth: android: Accumulate advertised UUIDs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-i541710-
Patch Set: Fix armansito request, and only report update if UUIDs changed. Created 5 years, 2 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
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_adapter_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
diff --git a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
index c55fb4565696d056c314ce2a9c8062094d9aaba1..4c078a7faac573a07e5bb70dd9b0d77224be5a7f 100644
--- a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
+++ b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
@@ -15,6 +15,7 @@ import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
+import java.util.HashSet;
import java.util.List;
/**
@@ -30,7 +31,7 @@ final class ChromeBluetoothDevice {
private long mNativeBluetoothDeviceAndroid;
final Wrappers.BluetoothDeviceWrapper mDevice;
- private List<ParcelUuid> mUuidsFromScan;
+ private HashSet<String> mUuidsFromScan;
Wrappers.BluetoothGattWrapper mBluetoothGatt;
private final BluetoothGattCallbackImpl mBluetoothGattCallbackImpl;
@@ -38,6 +39,7 @@ final class ChromeBluetoothDevice {
long nativeBluetoothDeviceAndroid, Wrappers.BluetoothDeviceWrapper deviceWrapper) {
mNativeBluetoothDeviceAndroid = nativeBluetoothDeviceAndroid;
mDevice = deviceWrapper;
+ mUuidsFromScan = new HashSet<String>();
mBluetoothGattCallbackImpl = new BluetoothGattCallbackImpl();
Log.v(TAG, "ChromeBluetoothDevice created.");
}
@@ -67,12 +69,14 @@ final class ChromeBluetoothDevice {
// Implements BluetoothDeviceAndroid::UpdateAdvertisedUUIDs.
@CalledByNative
private boolean updateAdvertisedUUIDs(List<ParcelUuid> uuidsFromScan) {
- if ((mUuidsFromScan == null && uuidsFromScan == null)
- || (mUuidsFromScan != null && mUuidsFromScan.equals(uuidsFromScan))) {
+ if (uuidsFromScan == null) {
return false;
}
- mUuidsFromScan = uuidsFromScan;
- return true;
+ boolean uuidsUpdated = false;
+ for (ParcelUuid uuid : uuidsFromScan) {
+ uuidsUpdated |= mUuidsFromScan.add(uuid.toString());
+ }
+ return uuidsUpdated;
}
// Implements BluetoothDeviceAndroid::GetBluetoothClass.
@@ -96,16 +100,9 @@ final class ChromeBluetoothDevice {
// Implements BluetoothDeviceAndroid::GetUUIDs.
@CalledByNative
private String[] getUuids() {
- int uuidCount = (mUuidsFromScan != null) ? mUuidsFromScan.size() : 0;
- String[] string_array = new String[uuidCount];
- for (int i = 0; i < uuidCount; i++) {
- string_array[i] = mUuidsFromScan.get(i).toString();
- }
-
// TODO(scheib): return merged list of UUIDs from scan results and,
// after a device is connected, discoverServices. crbug.com/508648
-
- return string_array;
+ return mUuidsFromScan.toArray(new String[mUuidsFromScan.size()]);
}
// Implements BluetoothDeviceAndroid::CreateGattConnectionImpl.
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_adapter_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698