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

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

Issue 2237943002: Remove now-unnecessary .obj() in Java method calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@switch-context
Patch Set: Rebase *again* :( Created 4 years, 4 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 #include "device/bluetooth/bluetooth_device_android.h" 5 #include "device/bluetooth/bluetooth_device_android.h"
6 6
7 #include "base/android/context_utils.h" 7 #include "base/android/context_utils.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/android/jni_array.h" 9 #include "base/android/jni_array.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 30 matching lines...) Expand all
41 41
42 device->j_device_.Reset(Java_ChromeBluetoothDevice_create( 42 device->j_device_.Reset(Java_ChromeBluetoothDevice_create(
43 AttachCurrentThread(), reinterpret_cast<intptr_t>(device), 43 AttachCurrentThread(), reinterpret_cast<intptr_t>(device),
44 bluetooth_device_wrapper)); 44 bluetooth_device_wrapper));
45 45
46 return device; 46 return device;
47 } 47 }
48 48
49 BluetoothDeviceAndroid::~BluetoothDeviceAndroid() { 49 BluetoothDeviceAndroid::~BluetoothDeviceAndroid() {
50 Java_ChromeBluetoothDevice_onBluetoothDeviceAndroidDestruction( 50 Java_ChromeBluetoothDevice_onBluetoothDeviceAndroidDestruction(
51 AttachCurrentThread(), j_device_.obj()); 51 AttachCurrentThread(), j_device_);
52 } 52 }
53 53
54 void BluetoothDeviceAndroid::UpdateAdvertisedUUIDs( 54 void BluetoothDeviceAndroid::UpdateAdvertisedUUIDs(
55 jobjectArray advertised_uuids) { 55 jobjectArray advertised_uuids) {
56 JNIEnv* env = AttachCurrentThread(); 56 JNIEnv* env = AttachCurrentThread();
57 std::vector<std::string> uuid_strings; 57 std::vector<std::string> uuid_strings;
58 AppendJavaStringArrayToStringVector(env, advertised_uuids, &uuid_strings); 58 AppendJavaStringArrayToStringVector(env, advertised_uuids, &uuid_strings);
59 59
60 advertised_uuids_ = UUIDList(uuid_strings.begin(), uuid_strings.end()); 60 advertised_uuids_ = UUIDList(uuid_strings.begin(), uuid_strings.end());
61 } 61 }
62 62
63 // static 63 // static
64 bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) { 64 bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) {
65 return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h 65 return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h
66 } 66 }
67 67
68 base::android::ScopedJavaLocalRef<jobject> 68 base::android::ScopedJavaLocalRef<jobject>
69 BluetoothDeviceAndroid::GetJavaObject() { 69 BluetoothDeviceAndroid::GetJavaObject() {
70 return base::android::ScopedJavaLocalRef<jobject>(j_device_); 70 return base::android::ScopedJavaLocalRef<jobject>(j_device_);
71 } 71 }
72 72
73 uint32_t BluetoothDeviceAndroid::GetBluetoothClass() const { 73 uint32_t BluetoothDeviceAndroid::GetBluetoothClass() const {
74 return Java_ChromeBluetoothDevice_getBluetoothClass(AttachCurrentThread(), 74 return Java_ChromeBluetoothDevice_getBluetoothClass(AttachCurrentThread(),
75 j_device_.obj()); 75 j_device_);
76 } 76 }
77 77
78 std::string BluetoothDeviceAndroid::GetAddress() const { 78 std::string BluetoothDeviceAndroid::GetAddress() const {
79 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getAddress( 79 return ConvertJavaStringToUTF8(
80 AttachCurrentThread(), j_device_.obj())); 80 Java_ChromeBluetoothDevice_getAddress(AttachCurrentThread(), j_device_));
81 } 81 }
82 82
83 BluetoothDevice::VendorIDSource BluetoothDeviceAndroid::GetVendorIDSource() 83 BluetoothDevice::VendorIDSource BluetoothDeviceAndroid::GetVendorIDSource()
84 const { 84 const {
85 // Android API does not provide Vendor ID. 85 // Android API does not provide Vendor ID.
86 return VENDOR_ID_UNKNOWN; 86 return VENDOR_ID_UNKNOWN;
87 } 87 }
88 88
89 uint16_t BluetoothDeviceAndroid::GetVendorID() const { 89 uint16_t BluetoothDeviceAndroid::GetVendorID() const {
90 // Android API does not provide Vendor ID. 90 // Android API does not provide Vendor ID.
(...skipping 11 matching lines...) Expand all
102 } 102 }
103 103
104 uint16_t BluetoothDeviceAndroid::GetAppearance() const { 104 uint16_t BluetoothDeviceAndroid::GetAppearance() const {
105 // TODO(crbug.com/588083): Implementing GetAppearance() 105 // TODO(crbug.com/588083): Implementing GetAppearance()
106 // on mac, win, and android platforms for chrome 106 // on mac, win, and android platforms for chrome
107 NOTIMPLEMENTED(); 107 NOTIMPLEMENTED();
108 return 0; 108 return 0;
109 } 109 }
110 110
111 base::Optional<std::string> BluetoothDeviceAndroid::GetName() const { 111 base::Optional<std::string> BluetoothDeviceAndroid::GetName() const {
112 auto name = Java_ChromeBluetoothDevice_getName(AttachCurrentThread(), 112 auto name =
113 j_device_.obj()); 113 Java_ChromeBluetoothDevice_getName(AttachCurrentThread(), j_device_);
114 if (name.is_null()) 114 if (name.is_null())
115 return base::nullopt; 115 return base::nullopt;
116 return ConvertJavaStringToUTF8(name); 116 return ConvertJavaStringToUTF8(name);
117 } 117 }
118 118
119 bool BluetoothDeviceAndroid::IsPaired() const { 119 bool BluetoothDeviceAndroid::IsPaired() const {
120 return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(), 120 return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(), j_device_);
121 j_device_.obj());
122 } 121 }
123 122
124 bool BluetoothDeviceAndroid::IsConnected() const { 123 bool BluetoothDeviceAndroid::IsConnected() const {
125 return IsGattConnected(); 124 return IsGattConnected();
126 } 125 }
127 126
128 bool BluetoothDeviceAndroid::IsGattConnected() const { 127 bool BluetoothDeviceAndroid::IsGattConnected() const {
129 return gatt_connected_; 128 return gatt_connected_;
130 } 129 }
131 130
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 instance_id_string, j_device_.obj())); 275 instance_id_string, j_device_.obj()));
277 276
278 adapter_->NotifyGattServiceAdded(service_iterator->second); 277 adapter_->NotifyGattServiceAdded(service_iterator->second);
279 } 278 }
280 279
281 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) 280 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter)
282 : BluetoothDevice(adapter) {} 281 : BluetoothDevice(adapter) {}
283 282
284 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { 283 void BluetoothDeviceAndroid::CreateGattConnectionImpl() {
285 Java_ChromeBluetoothDevice_createGattConnectionImpl( 284 Java_ChromeBluetoothDevice_createGattConnectionImpl(
286 AttachCurrentThread(), j_device_.obj(), 285 AttachCurrentThread(), j_device_, base::android::GetApplicationContext());
287 base::android::GetApplicationContext());
288 } 286 }
289 287
290 void BluetoothDeviceAndroid::DisconnectGatt() { 288 void BluetoothDeviceAndroid::DisconnectGatt() {
291 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), 289 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_);
292 j_device_.obj());
293 } 290 }
294 291
295 } // namespace device 292 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_android.cc ('k') | device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698