Chromium Code Reviews| 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..f8b91d7ff70b637cd5a0c69063630a06f6766089 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,30 +138,48 @@ 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_BluetoothAdapter_onBluetoothAdapterAndroidDestruction( |
| + AttachCurrentThread(), j_bluetooth_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_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) { |
|
armansito
2015/05/28 04:04:11
Add TODO about filters (and link to the bug) here.
scheib
2015/06/30 17:55:14
Done.
|
| + NOTIMPLEMENTED(); |
| error_callback.Run(); |
| } |