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

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: addressed tedchoc's comments Created 5 years, 7 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 007136d8c8d61734113e5e2bf0e561d49e113012..d192a09c9b1feff65ec9ee719080d043d8d314f8 100644
--- a/device/bluetooth/bluetooth_adapter_android.cc
+++ b/device/bluetooth/bluetooth_adapter_android.cc
@@ -28,7 +28,8 @@ base::WeakPtr<BluetoothAdapterAndroid>
BluetoothAdapterAndroid::CreateAdapter() {
BluetoothAdapterAndroid* adapter = new BluetoothAdapterAndroid();
adapter->j_bluetooth_adapter_.Reset(Java_BluetoothAdapter_create(
- AttachCurrentThread(), base::android::GetApplicationContext()));
+ AttachCurrentThread(), base::android::GetApplicationContext(),
+ reinterpret_cast<jlong>(adapter)));
return adapter->weak_ptr_factory_.GetWeakPtr();
}
@@ -37,7 +38,8 @@ BluetoothAdapterAndroid::CreateAdapterWithoutPermissionForTesting() {
BluetoothAdapterAndroid* adapter = new BluetoothAdapterAndroid();
adapter->j_bluetooth_adapter_.Reset(
Java_BluetoothAdapter_createWithoutPermissionForTesting(
- AttachCurrentThread(), base::android::GetApplicationContext()));
+ AttachCurrentThread(), base::android::GetApplicationContext(),
+ reinterpret_cast<jlong>(adapter)));
return adapter->weak_ptr_factory_.GetWeakPtr();
}
@@ -46,8 +48,8 @@ bool BluetoothAdapterAndroid::RegisterJNI(JNIEnv* env) {
return RegisterNativesImpl(env); // Generated in BluetoothAdapter_jni.h
}
-bool BluetoothAdapterAndroid::HasBluetoothPermission() const {
- return Java_BluetoothAdapter_hasBluetoothPermission(
+bool BluetoothAdapterAndroid::HasBluetoothCapability() const {
+ return Java_BluetoothAdapter_hasBluetoothCapability(
AttachCurrentThread(), j_bluetooth_adapter_.obj());
}
@@ -136,6 +138,10 @@ void BluetoothAdapterAndroid::RegisterAdvertisement(
error_callback.Run(BluetoothAdvertisement::ERROR_UNSUPPORTED_PLATFORM);
}
+void BluetoothAdapterAndroid::OnScanFailed(JNIEnv* env, jobject obj) {
+ MarkDiscoverySessionsAsInactive();
+}
+
BluetoothAdapterAndroid::BluetoothAdapterAndroid() : weak_ptr_factory_(this) {
}
@@ -146,20 +152,32 @@ 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_BluetoothAdapter_addDiscoverySession(AttachCurrentThread(),
+ j_bluetooth_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_BluetoothAdapter_removeDiscoverySession(
+ AttachCurrentThread(), j_bluetooth_adapter_.obj())) {
+ callback.Run();
+ } else {
+ error_callback.Run();
+ }
}
void BluetoothAdapterAndroid::SetDiscoveryFilter(
scoped_ptr<BluetoothDiscoveryFilter> discovery_filter,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ NOTIMPLEMENTED();
error_callback.Run();
}

Powered by Google App Engine
This is Rietveld 408576698