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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_descriptor_android.cc

Issue 1574773002: bluetooth: android: Initial basic Descriptors implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-code-cleanup-
Patch Set: addressed j again Created 4 years, 11 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
(Empty)
1 // Copyright 2016 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.
4
5 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_android.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h"
10 #include "base/bind.h"
11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h"
13 #include "device/bluetooth/bluetooth_gatt_notify_session_android.h"
14 #include "device/bluetooth/bluetooth_remote_gatt_service_android.h"
15 #include "jni/ChromeBluetoothRemoteGattDescriptor_jni.h"
16
17 using base::android::AttachCurrentThread;
18
19 namespace device {
20
21 // static
22 scoped_ptr<BluetoothRemoteGattDescriptorAndroid>
23 BluetoothRemoteGattDescriptorAndroid::Create(
24 const std::string& instance_id,
25 jobject /* BluetoothGattDescriptorWrapper */
26 bluetooth_gatt_descriptor_wrapper,
27 jobject /* chromeBluetoothDevice */
28 chrome_bluetooth_device) {
29 scoped_ptr<BluetoothRemoteGattDescriptorAndroid> descriptor(
30 new BluetoothRemoteGattDescriptorAndroid(instance_id));
31
32 descriptor->j_descriptor_.Reset(
33 Java_ChromeBluetoothRemoteGattDescriptor_create(
34 AttachCurrentThread(),
35 // TODO(scheib) Will eventually need to pass c++ pointer:
36 // reinterpret_cast<intptr_t>(descriptor.get()),
37 bluetooth_gatt_descriptor_wrapper, chrome_bluetooth_device));
38
39 return descriptor;
40 }
41
42 BluetoothRemoteGattDescriptorAndroid::~BluetoothRemoteGattDescriptorAndroid() {
43 Java_ChromeBluetoothRemoteGattDescriptor_onBluetoothRemoteGattDescriptorAndroi dDestruction(
44 AttachCurrentThread(), j_descriptor_.obj());
45 }
46
47 // static
48 bool BluetoothRemoteGattDescriptorAndroid::RegisterJNI(JNIEnv* env) {
49 return RegisterNativesImpl(
50 env); // Generated in ChromeBluetoothRemoteGattDescriptor_jni.h
51 }
52
53 base::android::ScopedJavaLocalRef<jobject>
54 BluetoothRemoteGattDescriptorAndroid::GetJavaObject() {
55 return base::android::ScopedJavaLocalRef<jobject>(j_descriptor_);
56 }
57
58 std::string BluetoothRemoteGattDescriptorAndroid::GetIdentifier() const {
59 return instance_id_;
60 }
61
62 BluetoothUUID BluetoothRemoteGattDescriptorAndroid::GetUUID() const {
63 return device::BluetoothUUID(
64 ConvertJavaStringToUTF8(Java_ChromeBluetoothRemoteGattDescriptor_getUUID(
65 AttachCurrentThread(), j_descriptor_.obj())));
66 }
67
68 bool BluetoothRemoteGattDescriptorAndroid::IsLocal() const {
69 return false;
70 }
71
72 const std::vector<uint8_t>& BluetoothRemoteGattDescriptorAndroid::GetValue()
73 const {
74 NOTIMPLEMENTED();
75 static std::vector<uint8_t> empty_value;
76 return empty_value;
77 }
78
79 BluetoothGattCharacteristic*
80 BluetoothRemoteGattDescriptorAndroid::GetCharacteristic() const {
81 NOTIMPLEMENTED();
82 return nullptr;
83 }
84
85 BluetoothGattCharacteristic::Permissions
86 BluetoothRemoteGattDescriptorAndroid::GetPermissions() const {
87 NOTIMPLEMENTED();
88 return 0;
89 }
90
91 void BluetoothRemoteGattDescriptorAndroid::ReadRemoteDescriptor(
92 const ValueCallback& callback,
93 const ErrorCallback& error_callback) {
94 NOTIMPLEMENTED();
95 base::MessageLoop::current()->PostTask(
96 FROM_HERE,
97 base::Bind(error_callback, BluetoothGattService::GATT_ERROR_FAILED));
98 }
99
100 void BluetoothRemoteGattDescriptorAndroid::WriteRemoteDescriptor(
101 const std::vector<uint8_t>& new_value,
102 const base::Closure& callback,
103 const ErrorCallback& error_callback) {
104 NOTIMPLEMENTED();
105 base::MessageLoop::current()->PostTask(
106 FROM_HERE,
107 base::Bind(error_callback, BluetoothGattService::GATT_ERROR_FAILED));
108 }
109
110 BluetoothRemoteGattDescriptorAndroid::BluetoothRemoteGattDescriptorAndroid(
111 const std::string& instance_id)
112 : instance_id_(instance_id) {}
113
114 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_descriptor_android.h ('k') | device/bluetooth/bluetooth_remote_gatt_service_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698