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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java

Issue 2737393003: Add Bluetooth Checks to Service (Closed)
Patch Set: fixing teds comments Created 3 years, 9 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 | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
index 20e2d4291d621dc1488cbb111da62d97837685b5..0b0f6c277c1a962b4385776f762850a499d29c6a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java
@@ -4,6 +4,10 @@
package org.chromium.chrome.browser.physicalweb;
+import android.annotation.TargetApi;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
@@ -153,4 +157,28 @@ public class PhysicalWeb {
new Intent(Intent.ACTION_VIEW, Uri.parse(UrlConstants.PHYSICAL_WEB_URL))
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
+
+ /**
+ * Check if bluetooth is on and enabled.
+ */
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public static boolean bluetoothIsEnabled() {
+ Context context = ContextUtils.getApplicationContext();
+ BluetoothManager bluetoothManager =
+ (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
+ BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
+ return bluetoothAdapter != null && bluetoothAdapter.isEnabled();
+ }
+
+ /**
+ * Check if the device bluetooth hardware supports BLE advertisements.
+ */
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public static boolean hasBleAdvertiseCapability() {
+ Context context = ContextUtils.getApplicationContext();
+ BluetoothManager bluetoothManager =
+ (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
+ BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
+ return bluetoothAdapter != null && bluetoothAdapter.getBluetoothLeAdvertiser() != null;
+ }
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698