Chromium Code Reviews| 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..a55feefaeae65ff7bc0a52001f606256698ed5da 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) {} |
| + }; |
|
mattreynolds
2016/07/22 00:48:42
remove semicolon
cco3
2016/07/22 17:37:19
Done.
|
| + |
| /** |
| * 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 The builder to be modified. |
|
mattreynolds
2016/07/22 00:48:41
nit: @param builder The builder... (here and below
cco3
2016/07/22 17:37:19
Done.
|
| + * @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 The builder to be modified. |
| + * @return The Builder. |
| + */ |
| + MessageFilter.Builder modifyMessageFilterBuilder(MessageFilter.Builder builder) { |
| + return builder.includeAllMyTypes(); |
| + } |
| } |