From 8369df095a73a77b3715f8ae7ba06089cebca4ce Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Wed, 3 May 2017 10:27:13 -0700 Subject: This change reflects the Dialer V10 RC00 branch. RC00 is based on: branch: dialer-android_release_branch/153304843.1 synced to: 153304843 following the instructions at go/dialer-aosp-release. In this release: * Removes final apache sources. * Uses native lite compilation. More drops will follow with subsequent release candidates until we reach our final v10 release, in cadence with our prebuilt drops. Test: TreeHugger, on device Change-Id: Ic9684057230f9b579c777820c746cd21bf45ec0f --- .../android/voicemail/impl/scheduling/Task.java | 38 +++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'java/com/android/voicemail/impl/scheduling/Task.java') diff --git a/java/com/android/voicemail/impl/scheduling/Task.java b/java/com/android/voicemail/impl/scheduling/Task.java index 2d08f5b03..447a9db7b 100644 --- a/java/com/android/voicemail/impl/scheduling/Task.java +++ b/java/com/android/voicemail/impl/scheduling/Task.java @@ -17,26 +17,24 @@ package com.android.voicemail.impl.scheduling; import android.content.Context; -import android.content.Intent; +import android.os.Bundle; import android.support.annotation.MainThread; import android.support.annotation.WorkerThread; import android.telecom.PhoneAccountHandle; import java.util.Objects; /** - * A task for {@link TaskSchedulerService} to execute. Since the task is sent through a intent to - * the scheduler, The task must be constructable with the intent. Specifically, It must have a - * constructor with zero arguments, and have all relevant data packed inside the intent. Use {@link - * TaskSchedulerService#createIntent(Context, Class)} to create a intent that will construct the - * Task. + * A task for {@link TaskSchedulerService} to execute. Since the task is sent through a bundle to + * the scheduler, The task must be constructable with the bundle. Specifically, It must have a + * constructor with zero arguments, and have all relevant data packed inside the bundle. Use {@link + * Tasks#createIntent(Context, Class)} to create a intent that will construct the Task. * *

Only {@link #onExecuteInBackgroundThread()} is run on the worker thread. */ public interface Task { - /** * TaskId to indicate it has not be set. If a task does not provide a default TaskId it should be - * set before {@link Task#onCreate(Context, Intent, int, int) returns} + * set before {@link Task#onCreate(Context, Bundle)} returns */ int TASK_INVALID = -1; @@ -49,6 +47,7 @@ public interface Task { int TASK_UPLOAD = 1; int TASK_SYNC = 2; int TASK_ACTIVATION = 3; + int TASK_STATUS_CHECK = 4; /** * Used to differentiate between types of tasks. If a task with the same TaskId is already in the @@ -87,8 +86,29 @@ public interface Task { TaskId getId(); + /** + * Serializes the task into a bundle, which will be stored in a {@link android.app.job.JobInfo} + * and used to reconstruct the task even if the app is terminated. The task will be initialized + * with {@link #onCreate(Context, Bundle)}. + */ + Bundle toBundle(); + + /** + * A task object is created through reflection, calling the default constructor. The actual + * initialization is done in this method. If the task is not a new instance, but being restored + * from a bundle, {@link #onRestore(Bundle)} will be called afterwards. + */ + @MainThread + void onCreate(Context context, Bundle extras); + + /** + * Called after {@link #onCreate(Context, Bundle)} if the task is being restored from a Bundle + * instead creating a new instance. For example, if the task is stored in {@link + * TaskSchedulerJobService} during a long sleep, this will be called when the job is ran again and + * the tasks are being restored from the saved state. + */ @MainThread - void onCreate(Context context, Intent intent, int flags, int startId); + void onRestore(Bundle extras); /** * @return number of milliSeconds the scheduler should wait before running this task. A value less -- cgit v1.2.3