Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: device/bluetooth/bluetooth_device_android.h

Issue 1394973003: bluetooth: android: Create BluetoothRemoteGattServiceAndroid objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-renames-
Patch Set: Address ortuno Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_DEVICE_ANDROID_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_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_android.h"
10 #include "device/bluetooth/bluetooth_device.h" 11 #include "device/bluetooth/bluetooth_device.h"
11 12
12 namespace device { 13 namespace device {
13 14
14 class BluetoothAdapterAndroid;
15
16 // BluetoothDeviceAndroid along with the Java class 15 // BluetoothDeviceAndroid along with the Java class
17 // org.chromium.device.bluetooth.ChromeBluetoothDevice implement 16 // org.chromium.device.bluetooth.ChromeBluetoothDevice implement
18 // BluetoothDevice. 17 // BluetoothDevice.
19 class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceAndroid final 18 class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceAndroid final
20 : public BluetoothDevice { 19 : public BluetoothDevice {
21 public: 20 public:
22 // Create a BluetoothDeviceAndroid instance and associated Java 21 // Create a BluetoothDeviceAndroid instance and associated Java
23 // ChromeBluetoothDevice using the provided |java_bluetooth_device_wrapper|. 22 // ChromeBluetoothDevice using the provided |java_bluetooth_device_wrapper|.
24 // 23 //
25 // The ChromeBluetoothDevice instance will hold a Java reference 24 // The ChromeBluetoothDevice instance will hold a Java reference
26 // to |bluetooth_device_wrapper|. 25 // to |bluetooth_device_wrapper|.
27 // 26 //
28 // TODO(scheib): Return a scoped_ptr<>, but then adapter will need to handle 27 // TODO(scheib): Return a scoped_ptr<>, but then adapter will need to handle
29 // this correctly. http://crbug.com/506416 28 // this correctly. http://crbug.com/506416
30 static BluetoothDeviceAndroid* Create( 29 static BluetoothDeviceAndroid* Create(
31 BluetoothAdapterAndroid* adapter, 30 BluetoothAdapterAndroid* adapter,
32 jobject bluetooth_device_wrapper); // Java Type: bluetoothDeviceWrapper 31 jobject bluetooth_device_wrapper); // Java Type: bluetoothDeviceWrapper
33 32
34 ~BluetoothDeviceAndroid() override; 33 ~BluetoothDeviceAndroid() override;
35 34
36 // Register C++ methods exposed to Java using JNI. 35 // Register C++ methods exposed to Java using JNI.
37 static bool RegisterJNI(JNIEnv* env); 36 static bool RegisterJNI(JNIEnv* env);
38 37
39 // Returns the associated ChromeBluetoothDevice Java object. 38 // Returns the associated ChromeBluetoothDevice Java object.
40 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); 39 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
41 40
41 // Get owning BluetoothAdapter cast to BluetoothAdapterAndroid.
42 BluetoothAdapterAndroid* GetAdapter() {
43 return static_cast<BluetoothAdapterAndroid*>(adapter_);
44 }
45
42 // Updates cached copy of advertised UUIDs discovered during a scan. 46 // Updates cached copy of advertised UUIDs discovered during a scan.
43 // Returns true if new UUIDs differed from cached values. 47 // Returns true if new UUIDs differed from cached values.
44 bool UpdateAdvertisedUUIDs( 48 bool UpdateAdvertisedUUIDs(
45 jobject advertised_uuids); // Java Type: List<ParcelUuid> 49 jobject advertised_uuids); // Java Type: List<ParcelUuid>
46 50
47 // BluetoothDevice: 51 // BluetoothDevice:
48 uint32 GetBluetoothClass() const override; 52 uint32 GetBluetoothClass() const override;
49 std::string GetAddress() const override; 53 std::string GetAddress() const override;
50 VendorIDSource GetVendorIDSource() const override; 54 VendorIDSource GetVendorIDSource() const override;
51 uint16 GetVendorID() const override; 55 uint16 GetVendorID() const override;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 const ConnectToServiceCallback& callback, 87 const ConnectToServiceCallback& callback,
84 const ConnectToServiceErrorCallback& error_callback) override; 88 const ConnectToServiceErrorCallback& error_callback) override;
85 89
86 // Callback indicating when GATT client has connected/disconnected. 90 // Callback indicating when GATT client has connected/disconnected.
87 // See android.bluetooth.BluetoothGattCallback.onConnectionStateChange. 91 // See android.bluetooth.BluetoothGattCallback.onConnectionStateChange.
88 void OnConnectionStateChange(JNIEnv* env, 92 void OnConnectionStateChange(JNIEnv* env,
89 jobject jcaller, 93 jobject jcaller,
90 int32_t status, 94 int32_t status,
91 bool connected); 95 bool connected);
92 96
97 // Creates Bluetooth GATT service objects and adds them to
98 // BluetoothDevice::gatt_services_ if they are not already there.
99 void CreateGattRemoteService(
100 JNIEnv* env,
101 jobject caller,
102 int32_t instanceId,
103 jobject bluetooth_gatt_service_wrapper); // Java Type:
104 // BluetoothGattServiceWrapper
105
93 protected: 106 protected:
94 BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter); 107 BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter);
95 108
96 // BluetoothDevice: 109 // BluetoothDevice:
97 std::string GetDeviceName() const override; 110 std::string GetDeviceName() const override;
98 void CreateGattConnectionImpl() override; 111 void CreateGattConnectionImpl() override;
99 void DisconnectGatt() override; 112 void DisconnectGatt() override;
100 113
101 // Java object org.chromium.device.bluetooth.ChromeBluetoothDevice. 114 // Java object org.chromium.device.bluetooth.ChromeBluetoothDevice.
102 base::android::ScopedJavaGlobalRef<jobject> j_device_; 115 base::android::ScopedJavaGlobalRef<jobject> j_device_;
103 116
104 bool gatt_connected_ = false; 117 bool gatt_connected_ = false;
105 118
106 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceAndroid); 119 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceAndroid);
107 }; 120 };
108 121
109 } // namespace device 122 } // namespace device
110 123
111 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_ 124 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_android.h ('k') | device/bluetooth/bluetooth_device_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698