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

Unified Diff: device/bluetooth/android/java/src/org/chromium/device/bluetooth/BluetoothAdapter.java

Issue 1119113002: bluetooth: Initial JNI setup for device/bluetooth. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Additional comment on RegisterBluetoothJni Created 5 years, 7 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/android/bluetooth_jni_registrar.cc ('k') | device/bluetooth/bluetooth.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/android/java/src/org/chromium/device/bluetooth/BluetoothAdapter.java
diff --git a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/BluetoothAdapter.java b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/BluetoothAdapter.java
new file mode 100644
index 0000000000000000000000000000000000000000..07f6349ddaaa8c6954e7e93511c10cccfb41b9be
--- /dev/null
+++ b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/BluetoothAdapter.java
@@ -0,0 +1,42 @@
+// 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.
+
+package org.chromium.device.bluetooth;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+import org.chromium.base.Log;
+
+/**
+ * Exposes android.bluetooth.BluetoothAdapter as necessary for C++
+ * device::BluetoothAdapterAndroid.
+ */
+@JNINamespace("device")
+final class BluetoothAdapter {
+ private static final String TAG = Log.makeTag("Bluetooth");
+
+ private final boolean mHasBluetoothPermission;
+
+ @CalledByNative
+ private static BluetoothAdapter create(Context context) {
+ return new BluetoothAdapter(context);
+ }
+
+ @CalledByNative
+ private boolean hasBluetoothPermission() {
+ return mHasBluetoothPermission;
+ }
+
+ private BluetoothAdapter(Context context) {
+ mHasBluetoothPermission =
+ context.checkCallingOrSelfPermission(android.Manifest.permission.BLUETOOTH)
+ == PackageManager.PERMISSION_GRANTED;
+ if (!mHasBluetoothPermission) {
+ Log.w(TAG, "Can not use bluetooth API, requires BLUETOOTH permission.");
+ }
+ }
+}
« no previous file with comments | « device/bluetooth/android/bluetooth_jni_registrar.cc ('k') | device/bluetooth/bluetooth.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698