OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.physicalweb; | 5 package org.chromium.chrome.browser.physicalweb; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.app.NotificationManager; | 8 import android.app.NotificationManager; |
9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
10 import android.app.Service; | 10 import android.app.Service; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 Log.e(TAG, "Given null display URL"); | 88 Log.e(TAG, "Given null display URL"); |
89 stopSelf(); | 89 stopSelf(); |
90 return START_STICKY; | 90 return START_STICKY; |
91 } | 91 } |
92 | 92 |
93 IntentFilter filter = new IntentFilter(); | 93 IntentFilter filter = new IntentFilter(); |
94 filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); | 94 filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); |
95 filter.addAction(STOP_SERVICE); | 95 filter.addAction(STOP_SERVICE); |
96 registerReceiver(mBroadcastReceiver, filter); | 96 registerReceiver(mBroadcastReceiver, filter); |
97 | 97 |
98 // TODO(iankc): implement parsing, broadcasting, Url Shortener. | 98 // TODO(iankc): implement broadcasting, Url Shortener. |
99 createBroadcastNotification(displayUrl); | 99 createBroadcastNotification(displayUrl); |
100 return START_STICKY; | 100 return START_STICKY; |
101 } | 101 } |
102 | 102 |
103 @Override | 103 @Override |
104 public void onDestroy() { | 104 public void onDestroy() { |
105 unregisterReceiver(mBroadcastReceiver); | 105 unregisterReceiver(mBroadcastReceiver); |
106 disableUrlBroadcasting(); | 106 disableUrlBroadcasting(); |
107 super.onDestroy(); | 107 super.onDestroy(); |
108 } | 108 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 notificationManager.notify( | 154 notificationManager.notify( |
155 NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB, notification
Builder.build()); | 155 NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB, notification
Builder.build()); |
156 } | 156 } |
157 | 157 |
158 /** Turns off URL broadcasting. */ | 158 /** Turns off URL broadcasting. */ |
159 private void disableUrlBroadcasting() { | 159 private void disableUrlBroadcasting() { |
160 NotificationManagerProxy notificationManager = new NotificationManagerPr
oxyImpl( | 160 NotificationManagerProxy notificationManager = new NotificationManagerPr
oxyImpl( |
161 (NotificationManager) getSystemService(NOTIFICATION_SERVICE)); | 161 (NotificationManager) getSystemService(NOTIFICATION_SERVICE)); |
162 notificationManager.cancel(NotificationConstants.NOTIFICATION_ID_PHYSICA
L_WEB); | 162 notificationManager.cancel(NotificationConstants.NOTIFICATION_ID_PHYSICA
L_WEB); |
163 } | 163 } |
| 164 |
| 165 private native byte[] nativeEncodeUrl(String url); |
164 } | 166 } |
OLD | NEW |