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

Unified Diff: device/bluetooth/bluetooth_adapter_android.cc

Issue 1150833002: bluetooth: android: Initial Low Energy Discovery Sessions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-manifest-
Patch Set: Add tests Created 5 years, 6 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/bluetooth_adapter_android.cc
diff --git a/device/bluetooth/bluetooth_adapter_android.cc b/device/bluetooth/bluetooth_adapter_android.cc
index 4a7a15039dbf292b8e06e1c08dae4c57e57db0fb..489050c005e34178f2e3256f2d6bd9cf7ff90d5b 100644
--- a/device/bluetooth/bluetooth_adapter_android.cc
+++ b/device/bluetooth/bluetooth_adapter_android.cc
@@ -31,7 +31,8 @@ base::WeakPtr<BluetoothAdapterAndroid> BluetoothAdapterAndroid::Create(
BluetoothAdapterAndroid* adapter = new BluetoothAdapterAndroid();
adapter->j_adapter_.Reset(Java_ChromeBluetoothAdapter_create(
- AttachCurrentThread(), java_bluetooth_adapter_wrapper));
+ AttachCurrentThread(), reinterpret_cast<intptr_t>(adapter),
+ java_bluetooth_adapter_wrapper));
return adapter->weak_ptr_factory_.GetWeakPtr();
}
@@ -126,30 +127,49 @@ void BluetoothAdapterAndroid::RegisterAdvertisement(
error_callback.Run(BluetoothAdvertisement::ERROR_UNSUPPORTED_PLATFORM);
}
+void BluetoothAdapterAndroid::OnScanFailed(JNIEnv* env, jobject obj) {
+ MarkDiscoverySessionsAsInactive();
+}
+
BluetoothAdapterAndroid::BluetoothAdapterAndroid() : weak_ptr_factory_(this) {
}
BluetoothAdapterAndroid::~BluetoothAdapterAndroid() {
+ Java_ChromeBluetoothAdapter_onBluetoothAdapterAndroidDestruction(
+ AttachCurrentThread(), j_adapter_.obj());
}
void BluetoothAdapterAndroid::AddDiscoverySession(
BluetoothDiscoveryFilter* discovery_filter,
const base::Closure& callback,
const ErrorCallback& error_callback) {
- error_callback.Run();
+ // TODO(scheib): Support filters crbug.com/490401
+ if (Java_ChromeBluetoothAdapter_addDiscoverySession(AttachCurrentThread(),
+ j_adapter_.obj())) {
+ callback.Run();
+ } else {
+ error_callback.Run();
+ }
}
void BluetoothAdapterAndroid::RemoveDiscoverySession(
BluetoothDiscoveryFilter* discovery_filter,
const base::Closure& callback,
const ErrorCallback& error_callback) {
- error_callback.Run();
+ if (Java_ChromeBluetoothAdapter_removeDiscoverySession(AttachCurrentThread(),
+ j_adapter_.obj())) {
+ callback.Run();
+ } else {
+ error_callback.Run();
+ }
}
void BluetoothAdapterAndroid::SetDiscoveryFilter(
scoped_ptr<BluetoothDiscoveryFilter> discovery_filter,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ // TODO(scheib): Support filters crbug.com/490401
+ NOTIMPLEMENTED();
error_callback.Run();
}

Powered by Google App Engine
This is Rietveld 408576698