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

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: Merge TOT 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
« no previous file with comments | « device/bluetooth/bluetooth_device_android.h ('k') | device/bluetooth/bluetooth_device_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..890244a9f3c755a61d83c1e3f947080bcbd81b3d
--- /dev/null
+++ b/device/bluetooth/bluetooth_device_android.cc
@@ -0,0 +1,200 @@
+// 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_array.h"
+#include "base/android/jni_string.h"
+#include "jni/ChromeBluetoothDevice_jni.h"
+
+using base::android::AttachCurrentThread;
+using base::android::AppendJavaStringArrayToStringVector;
+
+namespace device {
+
+BluetoothDeviceAndroid* BluetoothDeviceAndroid::Create(
+ jobject bluetooth_device_wrapper) { // Java Type: bluetoothDeviceWrapper
+ BluetoothDeviceAndroid* device = new BluetoothDeviceAndroid();
+
+ device->j_device_.Reset(Java_ChromeBluetoothDevice_create(
+ AttachCurrentThread(), 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 {
+ JNIEnv* env = AttachCurrentThread();
+ std::vector<std::string> uuid_strings;
+ AppendJavaStringArrayToStringVector(
+ env, Java_ChromeBluetoothDevice_getUuids(env, j_device_.obj()).obj(),
+ &uuid_strings);
+ BluetoothDevice::UUIDList uuids;
+ uuids.reserve(uuid_strings.size());
+ for (auto uuid_string : uuid_strings) {
+ 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
« no previous file with comments | « device/bluetooth/bluetooth_device_android.h ('k') | device/bluetooth/bluetooth_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698