OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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; |
| 8 import android.bluetooth.BluetoothAdapter; |
| 9 import android.bluetooth.BluetoothManager; |
| 10 import android.content.Context; |
7 import android.content.Intent; | 11 import android.content.Intent; |
8 import android.content.SharedPreferences; | 12 import android.content.SharedPreferences; |
9 import android.net.Uri; | 13 import android.net.Uri; |
10 import android.os.Build; | 14 import android.os.Build; |
11 | 15 |
12 import org.chromium.base.ContextUtils; | 16 import org.chromium.base.ContextUtils; |
13 import org.chromium.chrome.browser.ChromeFeatureList; | 17 import org.chromium.chrome.browser.ChromeFeatureList; |
14 import org.chromium.chrome.browser.IntentHandler; | 18 import org.chromium.chrome.browser.IntentHandler; |
15 import org.chromium.chrome.browser.UrlConstants; | 19 import org.chromium.chrome.browser.UrlConstants; |
16 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager
; | 20 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager
; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 150 } |
147 | 151 |
148 /** | 152 /** |
149 * Starts the Activity that shows the list of Physical Web URLs. | 153 * Starts the Activity that shows the list of Physical Web URLs. |
150 */ | 154 */ |
151 public static void showUrlList() { | 155 public static void showUrlList() { |
152 IntentHandler.startChromeLauncherActivityForTrustedIntent( | 156 IntentHandler.startChromeLauncherActivityForTrustedIntent( |
153 new Intent(Intent.ACTION_VIEW, Uri.parse(UrlConstants.PHYSICAL_W
EB_URL)) | 157 new Intent(Intent.ACTION_VIEW, Uri.parse(UrlConstants.PHYSICAL_W
EB_URL)) |
154 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); | 158 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); |
155 } | 159 } |
| 160 |
| 161 /** |
| 162 * Check if bluetooth is on and enabled. |
| 163 */ |
| 164 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 165 public static boolean bluetoothIsEnabled() { |
| 166 Context context = ContextUtils.getApplicationContext(); |
| 167 BluetoothManager bluetoothManager = |
| 168 (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SE
RVICE); |
| 169 BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter(); |
| 170 return bluetoothAdapter != null && bluetoothAdapter.isEnabled(); |
| 171 } |
| 172 |
| 173 /** |
| 174 * Check if the device bluetooth hardware supports BLE advertisements. |
| 175 */ |
| 176 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 177 public static boolean hasBleAdvertiseCapability() { |
| 178 Context context = ContextUtils.getApplicationContext(); |
| 179 BluetoothManager bluetoothManager = |
| 180 (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SE
RVICE); |
| 181 BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter(); |
| 182 return bluetoothAdapter != null && bluetoothAdapter.getBluetoothLeAdvert
iser() != null; |
| 183 } |
156 } | 184 } |
OLD | NEW |