OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.content.Context; | 7 import android.content.Context; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.content.res.Resources; | 9 import android.content.res.Resources; |
10 import android.os.Build; | 10 import android.os.Build; |
11 import android.text.Html; | 11 import android.text.Html; |
12 import android.text.util.Linkify; | 12 import android.text.util.Linkify; |
13 import android.view.LayoutInflater; | 13 import android.view.LayoutInflater; |
14 import android.view.View; | 14 import android.view.View; |
15 import android.widget.Button; | 15 import android.widget.Button; |
16 import android.widget.TextView; | 16 import android.widget.TextView; |
17 | 17 |
18 import org.chromium.base.ApiCompatibilityUtils; | 18 import org.chromium.base.ApiCompatibilityUtils; |
19 import org.chromium.chrome.R; | 19 import org.chromium.chrome.R; |
20 import org.chromium.chrome.browser.NativePage; | 20 import org.chromium.chrome.browser.NativePage; |
21 import org.chromium.chrome.browser.UrlConstants; | 21 import org.chromium.chrome.browser.UrlConstants; |
| 22 import org.chromium.components.location.LocationUtils; |
22 | 23 |
23 import java.util.HashSet; | 24 import java.util.HashSet; |
24 import java.util.Set; | 25 import java.util.Set; |
25 | 26 |
26 /** | 27 /** |
27 * Provides diagnostic information about the Physical Web feature. | 28 * Provides diagnostic information about the Physical Web feature. |
28 */ | 29 */ |
29 public class PhysicalWebDiagnosticsPage implements NativePage { | 30 public class PhysicalWebDiagnosticsPage implements NativePage { |
30 private final Context mContext; | 31 private final Context mContext; |
31 private final int mBackgroundColor; | 32 private final int mBackgroundColor; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 return; | 94 return; |
94 } | 95 } |
95 | 96 |
96 sb.append(String.format("<font color=\"%s\">%s</font><br/>", color, mess
age)); | 97 sb.append(String.format("<font color=\"%s\">%s</font><br/>", color, mess
age)); |
97 } | 98 } |
98 | 99 |
99 private void appendPrerequisitesReport(StringBuilder sb) { | 100 private void appendPrerequisitesReport(StringBuilder sb) { |
100 boolean isSdkVersionCorrect = isSdkVersionCorrect(); | 101 boolean isSdkVersionCorrect = isSdkVersionCorrect(); |
101 boolean isDataConnectionActive = Utils.isDataConnectionActive(mContext); | 102 boolean isDataConnectionActive = Utils.isDataConnectionActive(mContext); |
102 int bluetoothStatus = Utils.getBluetoothEnabledStatus(mContext); | 103 int bluetoothStatus = Utils.getBluetoothEnabledStatus(mContext); |
103 boolean isLocationServicesEnabled = Utils.isLocationServicesEnabled(mCon
text); | 104 LocationUtils locationUtils = LocationUtils.getInstance(); |
104 boolean isLocationPermissionGranted = Utils.isLocationPermissionGranted(
mContext); | 105 boolean isLocationServicesEnabled = locationUtils.isSystemLocationSettin
gEnabled(mContext); |
| 106 boolean isLocationPermissionGranted = locationUtils.hasAndroidLocationPe
rmission(mContext); |
105 boolean isPreferenceEnabled = PhysicalWeb.isPhysicalWebPreferenceEnabled
(mContext); | 107 boolean isPreferenceEnabled = PhysicalWeb.isPhysicalWebPreferenceEnabled
(mContext); |
106 boolean isOnboarding = PhysicalWeb.isOnboarding(mContext); | 108 boolean isOnboarding = PhysicalWeb.isOnboarding(mContext); |
107 | 109 |
108 int prerequisitesResult = Utils.RESULT_SUCCESS; | 110 int prerequisitesResult = Utils.RESULT_SUCCESS; |
109 if (!isSdkVersionCorrect | 111 if (!isSdkVersionCorrect |
110 || !isDataConnectionActive | 112 || !isDataConnectionActive |
111 || bluetoothStatus == Utils.RESULT_FAILURE | 113 || bluetoothStatus == Utils.RESULT_FAILURE |
112 || !isLocationServicesEnabled | 114 || !isLocationServicesEnabled |
113 || !isLocationPermissionGranted | 115 || !isLocationPermissionGranted |
114 || !isPreferenceEnabled) { | 116 || !isPreferenceEnabled) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 @Override | 240 @Override |
239 public String getHost() { | 241 public String getHost() { |
240 return UrlConstants.PHYSICAL_WEB_HOST; | 242 return UrlConstants.PHYSICAL_WEB_HOST; |
241 } | 243 } |
242 | 244 |
243 @Override | 245 @Override |
244 public void updateForUrl(String url) { | 246 public void updateForUrl(String url) { |
245 // nothing to do | 247 // nothing to do |
246 } | 248 } |
247 } | 249 } |
OLD | NEW |