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
3 // found in the LICENSE file.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_
8 #include "base/android/jni_android.h"
9 #include "base/memory/weak_ptr.h"
10 #include "device/bluetooth/bluetooth_device.h"
14 // BluetoothDeviceAndroid along with the Java class
15 // org.chromium.device.bluetooth.BluetoothDevice implement BluetoothDevice.
16 class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceAndroid final
17 : public BluetoothDevice
{
19 // Create a BluetoothDeviceAndroid instance and associated Java
20 // ChromeBluetoothDevice using the provided |java_bluetooth_device_wrapper|.
22 // The ChromeBluetoothDevice instance will hold a Java reference
23 // to |bluetooth_device_wrapper|.
25 // TODO(scheib): Return a scoped_ptr<>, but then adapter will need to handle
26 // this correctly. http://crbug.com/506416
27 static BluetoothDeviceAndroid
* Create(
28 jobject bluetooth_device_wrapper
); // Java Type: bluetoothDeviceWrapper
30 ~BluetoothDeviceAndroid() override
;
32 // Register C++ methods exposed to Java using JNI.
33 static bool RegisterJNI(JNIEnv
* env
);
35 // Updates cached copy of advertised UUIDs discovered during a scan.
36 // Returns true if new UUIDs differed from cached values.
37 bool UpdateAdvertisedUUIDs(
38 jobject advertised_uuids
); // Java Type: List<ParcelUuid>
41 uint32
GetBluetoothClass() const override
;
42 std::string
GetAddress() const override
;
43 VendorIDSource
GetVendorIDSource() const override
;
44 uint16
GetVendorID() const override
;
45 uint16
GetProductID() const override
;
46 uint16
GetDeviceID() const override
;
47 bool IsPaired() const override
;
48 bool IsConnected() const override
;
49 bool IsConnectable() const override
;
50 bool IsConnecting() const override
;
51 UUIDList
GetUUIDs() const override
;
52 int16
GetInquiryRSSI() const override
;
53 int16
GetInquiryTxPower() const override
;
54 bool ExpectingPinCode() const override
;
55 bool ExpectingPasskey() const override
;
56 bool ExpectingConfirmation() const override
;
57 void GetConnectionInfo(const ConnectionInfoCallback
& callback
) override
;
58 void Connect(device::BluetoothDevice::PairingDelegate
* pairing_delegate
,
59 const base::Closure
& callback
,
60 const ConnectErrorCallback
& error_callback
) override
;
61 void SetPinCode(const std::string
& pincode
) override
;
62 void SetPasskey(uint32 passkey
) override
;
63 void ConfirmPairing() override
;
64 void RejectPairing() override
;
65 void CancelPairing() override
;
66 void Disconnect(const base::Closure
& callback
,
67 const ErrorCallback
& error_callback
) override
;
68 void Forget(const ErrorCallback
& error_callback
) override
;
69 void ConnectToService(
70 const device::BluetoothUUID
& uuid
,
71 const ConnectToServiceCallback
& callback
,
72 const ConnectToServiceErrorCallback
& error_callback
) override
;
73 void ConnectToServiceInsecurely(
74 const device::BluetoothUUID
& uuid
,
75 const ConnectToServiceCallback
& callback
,
76 const ConnectToServiceErrorCallback
& error_callback
) override
;
77 void CreateGattConnection(
78 const GattConnectionCallback
& callback
,
79 const ConnectErrorCallback
& error_callback
) override
;
82 BluetoothDeviceAndroid();
85 std::string
GetDeviceName() const override
;
87 // Java object org.chromium.device.bluetooth.ChromeBluetoothDevice.
88 base::android::ScopedJavaGlobalRef
<jobject
> j_device_
;
90 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceAndroid
);
95 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_