OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "device/bluetooth/bluetooth_adapter_android.h" | 5 #include "device/bluetooth/bluetooth_adapter_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 Java_BluetoothAdapter_createWithoutPermissionForTesting( | 39 Java_BluetoothAdapter_createWithoutPermissionForTesting( |
40 AttachCurrentThread(), base::android::GetApplicationContext())); | 40 AttachCurrentThread(), base::android::GetApplicationContext())); |
41 return adapter->weak_ptr_factory_.GetWeakPtr(); | 41 return adapter->weak_ptr_factory_.GetWeakPtr(); |
42 } | 42 } |
43 | 43 |
44 // static | 44 // static |
45 bool BluetoothAdapterAndroid::RegisterJNI(JNIEnv* env) { | 45 bool BluetoothAdapterAndroid::RegisterJNI(JNIEnv* env) { |
46 return RegisterNativesImpl(env); // Generated in BluetoothAdapter_jni.h | 46 return RegisterNativesImpl(env); // Generated in BluetoothAdapter_jni.h |
47 } | 47 } |
48 | 48 |
49 bool BluetoothAdapterAndroid::HasBluetoothPermission() const { | 49 bool BluetoothAdapterAndroid::HasBluetoothCapability() const { |
50 return Java_BluetoothAdapter_hasBluetoothPermission( | 50 return Java_BluetoothAdapter_hasBluetoothCapability( |
51 AttachCurrentThread(), j_bluetooth_adapter_.obj()); | 51 AttachCurrentThread(), j_bluetooth_adapter_.obj()); |
52 } | 52 } |
53 | 53 |
54 std::string BluetoothAdapterAndroid::GetAddress() const { | 54 std::string BluetoothAdapterAndroid::GetAddress() const { |
55 return ConvertJavaStringToUTF8(Java_BluetoothAdapter_getAddress( | 55 return ConvertJavaStringToUTF8(Java_BluetoothAdapter_getAddress( |
56 AttachCurrentThread(), j_bluetooth_adapter_.obj())); | 56 AttachCurrentThread(), j_bluetooth_adapter_.obj())); |
57 } | 57 } |
58 | 58 |
59 std::string BluetoothAdapterAndroid::GetName() const { | 59 std::string BluetoothAdapterAndroid::GetName() const { |
60 return ConvertJavaStringToUTF8(Java_BluetoothAdapter_getName( | 60 return ConvertJavaStringToUTF8(Java_BluetoothAdapter_getName( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 BluetoothAdapterAndroid::BluetoothAdapterAndroid() : weak_ptr_factory_(this) { | 139 BluetoothAdapterAndroid::BluetoothAdapterAndroid() : weak_ptr_factory_(this) { |
140 } | 140 } |
141 | 141 |
142 BluetoothAdapterAndroid::~BluetoothAdapterAndroid() { | 142 BluetoothAdapterAndroid::~BluetoothAdapterAndroid() { |
143 } | 143 } |
144 | 144 |
145 void BluetoothAdapterAndroid::AddDiscoverySession( | 145 void BluetoothAdapterAndroid::AddDiscoverySession( |
146 BluetoothDiscoveryFilter* discovery_filter, | 146 BluetoothDiscoveryFilter* discovery_filter, |
147 const base::Closure& callback, | 147 const base::Closure& callback, |
148 const ErrorCallback& error_callback) { | 148 const ErrorCallback& error_callback) { |
149 error_callback.Run(); | 149 // TODO(scheib): Support filters crbug.com/490401 |
| 150 if (Java_BluetoothAdapter_addDiscoverySession(AttachCurrentThread(), |
| 151 j_bluetooth_adapter_.obj())) { |
| 152 callback.Run(); |
| 153 } else { |
| 154 error_callback.Run(); |
| 155 } |
150 } | 156 } |
151 | 157 |
152 void BluetoothAdapterAndroid::RemoveDiscoverySession( | 158 void BluetoothAdapterAndroid::RemoveDiscoverySession( |
153 BluetoothDiscoveryFilter* discovery_filter, | 159 BluetoothDiscoveryFilter* discovery_filter, |
154 const base::Closure& callback, | 160 const base::Closure& callback, |
155 const ErrorCallback& error_callback) { | 161 const ErrorCallback& error_callback) { |
156 error_callback.Run(); | 162 if (Java_BluetoothAdapter_removeDiscoverySession( |
| 163 AttachCurrentThread(), j_bluetooth_adapter_.obj())) { |
| 164 callback.Run(); |
| 165 } else { |
| 166 error_callback.Run(); |
| 167 } |
157 } | 168 } |
158 | 169 |
159 void BluetoothAdapterAndroid::SetDiscoveryFilter( | 170 void BluetoothAdapterAndroid::SetDiscoveryFilter( |
160 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, | 171 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, |
161 const base::Closure& callback, | 172 const base::Closure& callback, |
162 const ErrorCallback& error_callback) { | 173 const ErrorCallback& error_callback) { |
| 174 NOTIMPLEMENTED(); |
163 error_callback.Run(); | 175 error_callback.Run(); |
164 } | 176 } |
165 | 177 |
166 void BluetoothAdapterAndroid::RemovePairingDelegateInternal( | 178 void BluetoothAdapterAndroid::RemovePairingDelegateInternal( |
167 device::BluetoothDevice::PairingDelegate* pairing_delegate) { | 179 device::BluetoothDevice::PairingDelegate* pairing_delegate) { |
168 } | 180 } |
169 | 181 |
170 } // namespace device | 182 } // namespace device |
OLD | NEW |