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

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

Issue 2032273002: If location services are turned off, have the BT chooser prompt the user to turn them on. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Created 4 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
Index: device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothAdapter.java
diff --git a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothAdapter.java b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothAdapter.java
index a7751f75fab24955e4642b3ad2cca6efb4924bbe..b298f74f81b909dbe176b4b5262c9b1c337151f8 100644
--- a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothAdapter.java
+++ b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothAdapter.java
@@ -12,6 +12,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.location.LocationManager;
import android.os.Build;
import android.os.ParcelUuid;
@@ -186,12 +187,20 @@ final class ChromeBluetoothAdapter extends BroadcastReceiver {
// Implementation details:
/**
- * @return true if Chromium has permission to scan for Bluetooth devices.
+ * @return true if Chromium has permission to scan for Bluetooth devices and location services
+ * are on.
*/
private boolean canScan() {
Wrappers.ContextWrapper context = mAdapter.getContext();
- return context.checkPermission(Manifest.permission.ACCESS_COARSE_LOCATION)
+ boolean havePermission = context.checkPermission(Manifest.permission.ACCESS_COARSE_LOCATION)
|| context.checkPermission(Manifest.permission.ACCESS_FINE_LOCATION);
+
+ Wrappers.LocationManagerWrapper locationManager = context.getLocationManager();
+ boolean locationServicesOn =
+ locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
Jeffrey Yasskin 2016/06/03 01:52:48 https://developer.android.com/reference/android/lo
+ || locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ return havePermission && locationServicesOn;
}
private void registerBroadcastReceiver() {

Powered by Google App Engine
This is Rietveld 408576698