Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java |
| index ca4de080c807cea4c26b2de94f42ef0fb3c980f8..cfc8f4b6afa194b93d0e75de581f9808522e190f 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java |
| @@ -239,7 +239,17 @@ public class OfflinePageUtils { |
| public static DeviceConditions getDeviceConditions(Context context) { |
| return getInstance().getDeviceConditionsImpl(context); |
| } |
| - |
| + public static boolean getPowerConditions(Context context) { |
|
dewittj
2017/01/30 19:18:02
Lack of whitespace between these functions doesn't
Pete Williamson
2017/01/30 21:35:23
Done.
|
| + // TODO(petewil): refactor to get power, network, and battery directly from both here and |
| + // getDeviceConditionsImpl instead of always making a DeviceConditions object. |
| + return getInstance().getDeviceConditionsImpl(context).isPowerConnected(); |
| + } |
| + public static int getBatteryConditions(Context context) { |
| + return getInstance().getDeviceConditionsImpl(context).getBatteryPercentage(); |
| + } |
| + public static int getNetworkConditions(Context context) { |
| + return getInstance().getDeviceConditionsImpl(context).getNetConnectionType(); |
| + } |
| /** |
| * Records UMA data when the Offline Pages Background Load service awakens. |
| * @param context android context |
| @@ -609,7 +619,7 @@ public class OfflinePageUtils { |
| tab.loadUrl(params); |
| } |
| - private static boolean isPowerConnected(Intent batteryStatus) { |
| + public static boolean isPowerConnected(Intent batteryStatus) { |
|
dewittj
2017/01/30 19:18:02
needs javadoc now that it's public
Pete Williamson
2017/01/30 21:35:23
Oops, this didn't need to be public, changed back
|
| int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1); |
| boolean isConnected = (status == BatteryManager.BATTERY_STATUS_CHARGING |
| || status == BatteryManager.BATTERY_STATUS_FULL); |
| @@ -617,7 +627,7 @@ public class OfflinePageUtils { |
| return isConnected; |
| } |
| - private static int batteryPercentage(Intent batteryStatus) { |
| + public static int batteryPercentage(Intent batteryStatus) { |
|
dewittj
2017/01/30 19:18:02
same
Pete Williamson
2017/01/30 21:35:23
same
|
| int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); |
| int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1); |
| if (scale == 0) return 0; |