Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBroadcastService.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBroadcastService.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBroadcastService.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..34b238b2767056da6fc85f51fac8448362443ba7 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBroadcastService.java |
@@ -0,0 +1,51 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.chrome.browser.physicalweb; |
+ |
+import android.annotation.TargetApi; |
+import android.app.Service; |
+import android.content.Intent; |
+import android.os.Build; |
+import android.os.IBinder; |
+ |
+import org.chromium.base.Log; |
+ |
+/** |
+ * Broadcasts Physical Web URLs via BLE. |
+ **/ |
+// bluetooth.le.AdvertiseCallback and bluetooth.BluetoothAdapter require API level 21. |
+// This will only be run on M and above. |
+@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
+public class PhysicalWebBroadcastService extends Service { |
+ public static final String DISPLAY_URL_KEY = "display_url"; |
+ |
+ private static final String TAG = "PhysicalWeb"; |
cco3
2017/02/25 00:09:26
This tag isn't needed yet.
iankc
2017/03/02 18:53:31
Done.
|
+ |
+ @Override |
cco3
2017/02/25 00:09:25
Remove this method
iankc
2017/03/02 18:53:31
Done.
|
+ public void onCreate() { |
+ super.onCreate(); |
+ } |
+ |
+ @Override |
+ public int onStartCommand(Intent intent, int flags, int startId) { |
+ String displayUrl = intent.getStringExtra(DISPLAY_URL_KEY); |
+ if (displayUrl == null) { |
cco3
2017/02/25 00:09:25
Add a note that this should never happen.
iankc
2017/03/02 18:53:31
Done.
|
+ stopSelf(); |
+ return START_STICKY; |
+ } |
+ return START_STICKY; |
+ } |
+ |
+ @Override |
+ public void onDestroy() { |
+ Log.v(TAG, "On Destroy"); |
cco3
2017/02/25 00:09:25
Remove this log
iankc
2017/03/02 18:53:31
Done.
|
+ super.onDestroy(); |
+ } |
+ |
+ @Override |
+ public IBinder onBind(Intent intent) { |
+ return null; |
+ } |
+} |