| 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();
|
| }
|
|
|
|
|