Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java

Issue 2662103003: Always get device conditions from Java for every attempt. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8b0f7eb04a03b42317e0444325e4ebc3358ea15b 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
@@ -236,11 +236,37 @@ public class OfflinePageUtils {
};
}
+ /**
+ * Returns a class encapsulating the current power, battery, and network conditions.
+ */
public static DeviceConditions getDeviceConditions(Context context) {
return getInstance().getDeviceConditionsImpl(context);
}
/**
+ * Return true if the device is plugged into wall power.
+ */
+ public static boolean getPowerConditions(Context context) {
+ // 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();
+ }
+
+ /**
+ * Get the percentage of battery remaining
+ */
+ public static int getBatteryConditions(Context context) {
+ return getInstance().getDeviceConditionsImpl(context).getBatteryPercentage();
+ }
+
+ /**
+ * Returns an enum representing the type of the network connection.
+ */
+ 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
*/

Powered by Google App Engine
This is Rietveld 408576698