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

Unified Diff: device/bluetooth/bluetooth_device_android.cc

Issue 1215303006: bluetooth: android: Initial BluetoothDeviceAndroid implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-discovery-
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_device_android.cc
diff --git a/device/bluetooth/bluetooth_device_android.cc b/device/bluetooth/bluetooth_device_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7c4728ae959f8a1e9d772fcefa0a0106f0dee508
--- /dev/null
+++ b/device/bluetooth/bluetooth_device_android.cc
@@ -0,0 +1,198 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "device/bluetooth/bluetooth_device_android.h"
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_string.h"
+#include "jni/ChromeBluetoothDevice_jni.h"
+
+using base::android::AttachCurrentThread;
+
+namespace device {
+
+BluetoothDeviceAndroid* BluetoothDeviceAndroid::Create(
+ jobject java_bluetooth_device_wrapper) {
+ BluetoothDeviceAndroid* device = new BluetoothDeviceAndroid();
+
+ device->j_device_.Reset(Java_ChromeBluetoothDevice_create(
+ AttachCurrentThread(), java_bluetooth_device_wrapper));
+
+ return device;
+}
+
+BluetoothDeviceAndroid::~BluetoothDeviceAndroid() {
+}
+
+bool BluetoothDeviceAndroid::UpdateAdvertisedUUIDs(jobject advertised_uuids) {
+ return Java_ChromeBluetoothDevice_updateAdvertisedUUIDs(
+ AttachCurrentThread(), j_device_.obj(), advertised_uuids);
+}
+
+// static
+bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) {
+ return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h
+}
+
+uint32 BluetoothDeviceAndroid::GetBluetoothClass() const {
+ return Java_ChromeBluetoothDevice_getBluetoothClass(AttachCurrentThread(),
+ j_device_.obj());
+}
+
+std::string BluetoothDeviceAndroid::GetAddress() const {
+ return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getAddress(
+ AttachCurrentThread(), j_device_.obj()));
+}
+
+BluetoothDevice::VendorIDSource BluetoothDeviceAndroid::GetVendorIDSource()
+ const {
+ // Android API does not provide Vendor ID.
+ return VENDOR_ID_UNKNOWN;
+}
+
+uint16 BluetoothDeviceAndroid::GetVendorID() const {
+ // Android API does not provide Vendor ID.
+ return 0;
+}
+
+uint16 BluetoothDeviceAndroid::GetProductID() const {
+ // Android API does not provide Product ID.
+ return 0;
+}
+
+uint16 BluetoothDeviceAndroid::GetDeviceID() const {
+ // Android API does not provide Device ID.
+ return 0;
+}
+
+bool BluetoothDeviceAndroid::IsPaired() const {
+ return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(),
+ j_device_.obj());
+}
+
+bool BluetoothDeviceAndroid::IsConnected() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool BluetoothDeviceAndroid::IsConnectable() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool BluetoothDeviceAndroid::IsConnecting() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+BluetoothDevice::UUIDList BluetoothDeviceAndroid::GetUUIDs() const {
+ int number_of_uuids = Java_ChromeBluetoothDevice_getUuidsCount(
+ AttachCurrentThread(), j_device_.obj());
+ BluetoothDevice::UUIDList uuids;
+ uuids.reserve(number_of_uuids);
+ for (int i = 0; i < number_of_uuids; i++) {
scheib 2015/07/06 23:10:43 Use AppendJavaStringArrayToStringVector instead.
scheib 2015/07/08 00:49:10 Done.
+ std::string uuid_string =
+ ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getUuid(
+ AttachCurrentThread(), j_device_.obj(), i));
+ uuids.push_back(BluetoothUUID(uuid_string));
+ }
+ return uuids;
+}
+
+int16 BluetoothDeviceAndroid::GetInquiryRSSI() const {
+ NOTIMPLEMENTED();
+ return kUnknownPower;
+}
+
+int16 BluetoothDeviceAndroid::GetInquiryTxPower() const {
+ NOTIMPLEMENTED();
+ return kUnknownPower;
+}
+
+bool BluetoothDeviceAndroid::ExpectingPinCode() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool BluetoothDeviceAndroid::ExpectingPasskey() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool BluetoothDeviceAndroid::ExpectingConfirmation() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+void BluetoothDeviceAndroid::GetConnectionInfo(
+ const ConnectionInfoCallback& callback) {
+ NOTIMPLEMENTED();
+ callback.Run(ConnectionInfo());
+}
+
+void BluetoothDeviceAndroid::Connect(
+ PairingDelegate* pairing_delegate,
+ const base::Closure& callback,
+ const ConnectErrorCallback& error_callback) {
+ NOTIMPLEMENTED();
+}
+
+void BluetoothDeviceAndroid::SetPinCode(const std::string& pincode) {
+ NOTIMPLEMENTED();
+}
+
+void BluetoothDeviceAndroid::SetPasskey(uint32 passkey) {
+ NOTIMPLEMENTED();
+}
+
+void BluetoothDeviceAndroid::ConfirmPairing() {
+ NOTIMPLEMENTED();
+}
+
+void BluetoothDeviceAndroid::RejectPairing() {
+ NOTIMPLEMENTED();
+}
+
+void BluetoothDeviceAndroid::CancelPairing() {
+ NOTIMPLEMENTED();
+}
+
+void BluetoothDeviceAndroid::Disconnect(const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ NOTIMPLEMENTED();
+}
+
+void BluetoothDeviceAndroid::Forget(const ErrorCallback& error_callback) {
+ NOTIMPLEMENTED();
+}
+
+void BluetoothDeviceAndroid::ConnectToService(
+ const BluetoothUUID& uuid,
+ const ConnectToServiceCallback& callback,
+ const ConnectToServiceErrorCallback& error_callback) {
+ NOTIMPLEMENTED();
+}
+
+void BluetoothDeviceAndroid::ConnectToServiceInsecurely(
+ const BluetoothUUID& uuid,
+ const ConnectToServiceCallback& callback,
+ const ConnectToServiceErrorCallback& error_callback) {
+ NOTIMPLEMENTED();
+}
+
+void BluetoothDeviceAndroid::CreateGattConnection(
+ const GattConnectionCallback& callback,
+ const ConnectErrorCallback& error_callback) {
+ NOTIMPLEMENTED();
+}
+
+BluetoothDeviceAndroid::BluetoothDeviceAndroid() {
+}
+
+std::string BluetoothDeviceAndroid::GetDeviceName() const {
+ return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName(
+ AttachCurrentThread(), j_device_.obj()));
+}
+
+} // namespace device

Powered by Google App Engine
This is Rietveld 408576698