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

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

Issue 2171053002: Scan through Nearby when listing PW URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update a comment Created 4 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
Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java
index 233bbb74999a37d2813f9a383cceab805cabbe78..e87b72abb0032a06818ab0fdd93aad0d3c216b77 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java
@@ -6,10 +6,17 @@ package org.chromium.chrome.browser.physicalweb;
import android.app.Activity;
+import com.google.android.gms.common.api.GoogleApiClient;
+import com.google.android.gms.nearby.Nearby;
+import com.google.android.gms.nearby.messages.Message;
+import com.google.android.gms.nearby.messages.MessageFilter;
+import com.google.android.gms.nearby.messages.MessageListener;
+
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.chrome.browser.ChromeApplication;
+
/**
* The Client that harvests URLs from BLE signals.
* This class is designed to scan URSs from Bluetooth Low Energy beacons.
@@ -20,10 +27,16 @@ public class PhysicalWebBleClient {
private static PhysicalWebBleClient sInstance = null;
private static final String TAG = "PhysicalWeb";
+ // We don't actually listen to any of the onFound or onLost events in the foreground.
+ // The background listener will get these.
+ protected static class ForegroundMessageListener extends MessageListener {
+ @Override
+ public void onFound(Message message) {}
+ }
+
/**
* Get a singleton instance of this class.
- * @return an instance of this class (or subclass) as decided by the
- * application parameter
+ * @return an instance of this class (or subclass).
*/
public static PhysicalWebBleClient getInstance() {
if (sInstance == null) {
@@ -91,4 +104,30 @@ public class PhysicalWebBleClient {
void foregroundUnsubscribe() {
Log.d(TAG, "foreground unsubscribing in empty client");
}
+
+ /**
+ * Create a MessageListener that listens during a foreground scan.
+ * @return the MessageListener.
+ */
+ MessageListener createForegroundMessageListener() {
+ return new ForegroundMessageListener();
+ }
+
+ /**
+ * Modify a GoogleApiClient.Builder as necessary for doing Physical Web scanning.
+ * @param builder The builder to be modified.
+ * @return The Builder.
+ */
+ GoogleApiClient.Builder modifyGoogleApiClientBuilder(GoogleApiClient.Builder builder) {
+ return builder.addApi(Nearby.MESSAGES_API);
+ }
+
+ /**
+ * Modify a MessageFilter.Builder as necessary for doing Physical Web scanning.
+ * @param builder The builder to be modified.
+ * @return The Builder.
+ */
+ MessageFilter.Builder modifyMessageFilterBuilder(MessageFilter.Builder builder) {
+ return builder.includeAllMyTypes();
+ }
}

Powered by Google App Engine
This is Rietveld 408576698