Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.java |
| index 563f62a6ecaf343a62f8ee5390e478fcdf373296..935b9005f8a0b61f8856780e344dc5e368a32869 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.java |
| @@ -4,7 +4,10 @@ |
| package org.chromium.chrome.browser.offlinepages; |
| +import android.annotation.TargetApi; |
| +import android.os.Build; |
| import android.os.Bundle; |
| +import android.os.PersistableBundle; |
| import org.chromium.chrome.browser.ChromeBackgroundService; |
| @@ -20,10 +23,20 @@ public class TaskExtrasPacker { |
| private static final String BATTERY_PERCENTAGE_TAG = "BatteryPercentage"; |
| private static final String UNMETERED_NETWORK_TAG = "UnmeteredNetwork"; |
| + /** Puts requirement to hold a wakelock in the bundle. */ |
| + public static void packHoldWakelock(Bundle bundle) { |
|
nyquist
2017/02/16 23:49:32
SELF: Who reads this?
fgorski
2017/02/17 22:31:15
https://cs.chromium.org/chromium/src/chrome/androi
|
| + bundle.putBoolean(ChromeBackgroundService.HOLD_WAKELOCK, true); |
| + } |
| + |
| /** Puts current time into the input bundle. */ |
| public static void packTimeInBundle(Bundle bundle) { |
| bundle.putLong(SCHEDULED_TIME_TAG, System.currentTimeMillis()); |
| - bundle.putBoolean(ChromeBackgroundService.HOLD_WAKELOCK, true); |
| + } |
| + |
| + /** Puts current time into the input bundle. */ |
| + @TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1) |
| + public static void packTimeInBundle(PersistableBundle bundle) { |
| + bundle.putLong(SCHEDULED_TIME_TAG, System.currentTimeMillis()); |
| } |
| /** Extracts the time we put into the bundle. */ |
| @@ -31,6 +44,12 @@ public class TaskExtrasPacker { |
| return bundle.getLong(SCHEDULED_TIME_TAG); |
| } |
| + /** Extracts the time we put into the bundle. */ |
| + @TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1) |
| + public static long unpackTimeFromBundle(PersistableBundle bundle) { |
| + return bundle.getLong(SCHEDULED_TIME_TAG); |
| + } |
| + |
| /** Puts trigger conditions into the input bundle. */ |
| public static void packTriggerConditionsInBundle(Bundle bundle, TriggerConditions conditions) { |
| bundle.putBoolean(POWER_CONNECTED_TAG, conditions.requirePowerConnected()); |
| @@ -38,6 +57,15 @@ public class TaskExtrasPacker { |
| bundle.putBoolean(UNMETERED_NETWORK_TAG, conditions.requireUnmeteredNetwork()); |
| } |
| + /** Puts trigger conditions into the input bundle. */ |
| + @TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1) |
| + public static void packTriggerConditionsInBundle( |
| + PersistableBundle bundle, TriggerConditions conditions) { |
| + bundle.putBoolean(POWER_CONNECTED_TAG, conditions.requirePowerConnected()); |
| + bundle.putInt(BATTERY_PERCENTAGE_TAG, conditions.getMinimumBatteryPercentage()); |
| + bundle.putBoolean(UNMETERED_NETWORK_TAG, conditions.requireUnmeteredNetwork()); |
| + } |
| + |
| /** Extracts the trigger conditions we put into the bundle. */ |
| public static TriggerConditions unpackTriggerConditionsFromBundle(Bundle bundle) { |
| boolean requirePowerConnected = bundle.getBoolean(POWER_CONNECTED_TAG, true); |
| @@ -46,4 +74,14 @@ public class TaskExtrasPacker { |
| return new TriggerConditions( |
| requirePowerConnected, minimumBatteryPercentage, requireUnmeteredNetwork); |
| } |
| + |
| + /** Extracts the trigger conditions we put into the bundle. */ |
| + @TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1) |
| + public static TriggerConditions unpackTriggerConditionsFromBundle(PersistableBundle bundle) { |
| + boolean requirePowerConnected = bundle.getBoolean(POWER_CONNECTED_TAG, true); |
| + int minimumBatteryPercentage = bundle.getInt(BATTERY_PERCENTAGE_TAG, 100); |
| + boolean requireUnmeteredNetwork = bundle.getBoolean(UNMETERED_NETWORK_TAG, true); |
| + return new TriggerConditions( |
| + requirePowerConnected, minimumBatteryPercentage, requireUnmeteredNetwork); |
| + } |
| } |