| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 public: | 38 public: |
| 39 // Create a BluetoothAdapterAndroid instance. | 39 // Create a BluetoothAdapterAndroid instance. |
| 40 // | 40 // |
| 41 // |java_bluetooth_adapter_wrapper| is optional. If it is NULL the adapter | 41 // |java_bluetooth_adapter_wrapper| is optional. If it is NULL the adapter |
| 42 // will return false for |IsPresent()| and not be functional. | 42 // will return false for |IsPresent()| and not be functional. |
| 43 // | 43 // |
| 44 // The BluetoothAdapterAndroid instance will indirectly hold a Java reference | 44 // The BluetoothAdapterAndroid instance will indirectly hold a Java reference |
| 45 // to |bluetooth_adapter_wrapper|. | 45 // to |bluetooth_adapter_wrapper|. |
| 46 static base::WeakPtr<BluetoothAdapterAndroid> Create( | 46 static base::WeakPtr<BluetoothAdapterAndroid> Create( |
| 47 const base::android::JavaRef<jobject>& | 47 const base::android::JavaRef<jobject>& |
| 48 bluetooth_adapter_wrapper); // Java Type: bluetoothAdapterWrapper | 48 bluetooth_adapter_wrapper, // Java Type: BluetoothAdapterWrapper |
| 49 const base::android::JavaRef<jobject>& |
| 50 bluetooth_manager_wrapper); // Java Type: BluetoothManagerWrapper |
| 49 | 51 |
| 50 // Register C++ methods exposed to Java using JNI. | 52 // Register C++ methods exposed to Java using JNI. |
| 51 static bool RegisterJNI(JNIEnv* env); | 53 static bool RegisterJNI(JNIEnv* env); |
| 52 | 54 |
| 53 // BluetoothAdapter: | 55 // BluetoothAdapter: |
| 54 std::string GetAddress() const override; | 56 std::string GetAddress() const override; |
| 55 std::string GetName() const override; | 57 std::string GetName() const override; |
| 56 void SetName(const std::string& name, | 58 void SetName(const std::string& name, |
| 57 const base::Closure& callback, | 59 const base::Closure& callback, |
| 58 const ErrorCallback& error_callback) override; | 60 const ErrorCallback& error_callback) override; |
| 59 bool IsInitialized() const override; | 61 bool IsInitialized() const override; |
| 60 bool IsPresent() const override; | 62 bool IsPresent() const override; |
| 61 bool IsPowered() const override; | 63 bool IsPowered() const override; |
| 62 void SetPowered(bool powered, | 64 void SetPowered(bool powered, |
| 63 const base::Closure& callback, | 65 const base::Closure& callback, |
| 64 const ErrorCallback& error_callback) override; | 66 const ErrorCallback& error_callback) override; |
| 65 bool IsDiscoverable() const override; | 67 bool IsDiscoverable() const override; |
| 66 void SetDiscoverable(bool discoverable, | 68 void SetDiscoverable(bool discoverable, |
| 67 const base::Closure& callback, | 69 const base::Closure& callback, |
| 68 const ErrorCallback& error_callback) override; | 70 const ErrorCallback& error_callback) override; |
| 69 bool IsDiscovering() const override; | 71 bool IsDiscovering() const override; |
| 72 std::unordered_map<BluetoothDevice*, BluetoothDevice::UUIDSet> |
| 73 RetrieveGattConnectedDevicesWithDiscoveryFilter( |
| 74 const BluetoothDiscoveryFilter& discovery_filter) override; |
| 70 UUIDList GetUUIDs() const override; | 75 UUIDList GetUUIDs() const override; |
| 71 void CreateRfcommService( | 76 void CreateRfcommService( |
| 72 const BluetoothUUID& uuid, | 77 const BluetoothUUID& uuid, |
| 73 const ServiceOptions& options, | 78 const ServiceOptions& options, |
| 74 const CreateServiceCallback& callback, | 79 const CreateServiceCallback& callback, |
| 75 const CreateServiceErrorCallback& error_callback) override; | 80 const CreateServiceErrorCallback& error_callback) override; |
| 76 void CreateL2capService( | 81 void CreateL2capService( |
| 77 const BluetoothUUID& uuid, | 82 const BluetoothUUID& uuid, |
| 78 const ServiceOptions& options, | 83 const ServiceOptions& options, |
| 79 const CreateServiceCallback& callback, | 84 const CreateServiceCallback& callback, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void RemovePairingDelegateInternal( | 132 void RemovePairingDelegateInternal( |
| 128 BluetoothDevice::PairingDelegate* pairing_delegate) override; | 133 BluetoothDevice::PairingDelegate* pairing_delegate) override; |
| 129 | 134 |
| 130 void PurgeTimedOutDevices(); | 135 void PurgeTimedOutDevices(); |
| 131 | 136 |
| 132 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 137 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
| 133 | 138 |
| 134 // Java object org.chromium.device.bluetooth.ChromeBluetoothAdapter. | 139 // Java object org.chromium.device.bluetooth.ChromeBluetoothAdapter. |
| 135 base::android::ScopedJavaGlobalRef<jobject> j_adapter_; | 140 base::android::ScopedJavaGlobalRef<jobject> j_adapter_; |
| 136 | 141 |
| 142 // Java object org.chromium.device.bluetooth.ChromeBluetoothManager. |
| 143 base::android::ScopedJavaGlobalRef<jobject> j_manager_; |
| 144 |
| 137 private: | 145 private: |
| 138 size_t num_discovery_sessions_ = 0; | 146 size_t num_discovery_sessions_ = 0; |
| 139 | 147 |
| 140 // Note: This should remain the last member so it'll be destroyed and | 148 // Note: This should remain the last member so it'll be destroyed and |
| 141 // invalidate its weak pointers before any other members are destroyed. | 149 // invalidate its weak pointers before any other members are destroyed. |
| 142 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; | 150 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; |
| 143 | 151 |
| 144 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); | 152 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); |
| 145 }; | 153 }; |
| 146 | 154 |
| 147 } // namespace device | 155 } // namespace device |
| 148 | 156 |
| 149 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 157 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
| OLD | NEW |