| 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "device/bluetooth/bluetooth_adapter.h" | 10 #include "device/bluetooth/bluetooth_adapter.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 static base::WeakPtr<BluetoothAdapterAndroid> CreateAdapter(); | 24 static base::WeakPtr<BluetoothAdapterAndroid> CreateAdapter(); |
| 25 | 25 |
| 26 // Create a BluetoothAdapterAndroid instance without Bluetooth permission. | 26 // Create a BluetoothAdapterAndroid instance without Bluetooth permission. |
| 27 static base::WeakPtr<BluetoothAdapterAndroid> | 27 static base::WeakPtr<BluetoothAdapterAndroid> |
| 28 CreateAdapterWithoutPermissionForTesting(); | 28 CreateAdapterWithoutPermissionForTesting(); |
| 29 | 29 |
| 30 // Register C++ methods exposed to Java using JNI. | 30 // Register C++ methods exposed to Java using JNI. |
| 31 static bool RegisterJNI(JNIEnv* env); | 31 static bool RegisterJNI(JNIEnv* env); |
| 32 | 32 |
| 33 // True if this app has android permissions necessary for Bluetooth. | 33 // True if this app has android permissions necessary for Bluetooth. |
| 34 bool HasBluetoothPermission() const; | 34 bool HasBluetoothCapability() const; |
| 35 | 35 |
| 36 // BluetoothAdapter: | 36 // BluetoothAdapter: |
| 37 std::string GetAddress() const override; | 37 std::string GetAddress() const override; |
| 38 std::string GetName() const override; | 38 std::string GetName() const override; |
| 39 void SetName(const std::string& name, | 39 void SetName(const std::string& name, |
| 40 const base::Closure& callback, | 40 const base::Closure& callback, |
| 41 const ErrorCallback& error_callback) override; | 41 const ErrorCallback& error_callback) override; |
| 42 bool IsInitialized() const override; | 42 bool IsInitialized() const override; |
| 43 bool IsPresent() const override; | 43 bool IsPresent() const override; |
| 44 bool IsPowered() const override; | 44 bool IsPowered() const override; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 62 const CreateServiceErrorCallback& error_callback) override; | 62 const CreateServiceErrorCallback& error_callback) override; |
| 63 void RegisterAudioSink( | 63 void RegisterAudioSink( |
| 64 const BluetoothAudioSink::Options& options, | 64 const BluetoothAudioSink::Options& options, |
| 65 const AcquiredCallback& callback, | 65 const AcquiredCallback& callback, |
| 66 const BluetoothAudioSink::ErrorCallback& error_callback) override; | 66 const BluetoothAudioSink::ErrorCallback& error_callback) override; |
| 67 void RegisterAdvertisement( | 67 void RegisterAdvertisement( |
| 68 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, | 68 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, |
| 69 const CreateAdvertisementCallback& callback, | 69 const CreateAdvertisementCallback& callback, |
| 70 const CreateAdvertisementErrorCallback& error_callback) override; | 70 const CreateAdvertisementErrorCallback& error_callback) override; |
| 71 | 71 |
| 72 // Handles a scan error event by invalidating all discovery sessions. |
| 73 void OnScanFailed(JNIEnv* env, jobject obj); |
| 74 |
| 72 protected: | 75 protected: |
| 73 BluetoothAdapterAndroid(); | 76 BluetoothAdapterAndroid(); |
| 74 ~BluetoothAdapterAndroid() override; | 77 ~BluetoothAdapterAndroid() override; |
| 75 | 78 |
| 76 // BluetoothAdapter: | 79 // BluetoothAdapter: |
| 77 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, | 80 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, |
| 78 const base::Closure& callback, | 81 const base::Closure& callback, |
| 79 const ErrorCallback& error_callback) override; | 82 const ErrorCallback& error_callback) override; |
| 80 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, | 83 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, |
| 81 const base::Closure& callback, | 84 const base::Closure& callback, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 95 // Note: This should remain the last member so it'll be destroyed and | 98 // Note: This should remain the last member so it'll be destroyed and |
| 96 // invalidate its weak pointers before any other members are destroyed. | 99 // invalidate its weak pointers before any other members are destroyed. |
| 97 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; | 100 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; |
| 98 | 101 |
| 99 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); | 102 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); |
| 100 }; | 103 }; |
| 101 | 104 |
| 102 } // namespace device | 105 } // namespace device |
| 103 | 106 |
| 104 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 107 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
| OLD | NEW |