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

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

Issue 2664053002: Add PhysicalWeb.hasPrerequisites()
Patch Set: Add javadoc Created 3 years, 11 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/preferences/privacy/PhysicalWebPreferenceFragment.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 6a9f4c3bc4b9df7dfb9ce2b63dce12f80b479347..44fb86996238524872c4e2e7e081f23701d9d2ab 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
@@ -40,6 +40,17 @@ public class PhysicalWeb {
}
/**
+ * Checks Physical Web prerequisites.
+ * @return whether we have the necessary permissions to begin Physical Web scanning.
+ */
+ public static boolean hasPrerequisites() {
+ LocationUtils locationUtils = LocationUtils.getInstance();
+ return featureIsEnabled()
+ && locationUtils.hasAndroidLocationPermission()
+ && locationUtils.isSystemLocationSettingEnabled();
+ }
+
+ /**
* Checks whether the Physical Web preference is switched to On.
*
* @return boolean {@code true} if the preference is On.
@@ -63,12 +74,7 @@ public class PhysicalWeb {
* At the moment, this only enables URL discovery over BLE.
*/
public static void startPhysicalWeb() {
- // Only subscribe to Nearby if we have the location permission.
- LocationUtils locationUtils = LocationUtils.getInstance();
- if (locationUtils.hasAndroidLocationPermission()
- && locationUtils.isSystemLocationSettingEnabled()) {
- new NearbyBackgroundSubscription(NearbySubscription.SUBSCRIBE).run();
- }
+ new NearbyBackgroundSubscription(NearbySubscription.SUBSCRIBE).run();
}
/**
@@ -117,7 +123,7 @@ public class PhysicalWeb {
* Performs various Physical Web operations that should happen on startup.
*/
public static void onChromeStart() {
- if (!featureIsEnabled()) {
+ if (!hasPrerequisites()) {
stopPhysicalWeb();
return;
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PhysicalWebPreferenceFragment.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698