Loading api/current.txt +7 −6 Original line number Diff line number Diff line Loading @@ -5356,13 +5356,13 @@ package android.app.task { method public int describeContents(); method public int getBackoffPolicy(); method public android.os.Bundle getExtras(); method public int getId(); method public long getInitialBackoffMillis(); method public long getIntervalMillis(); method public long getMaxExecutionDelayMillis(); method public long getMinLatencyMillis(); method public int getNetworkCapabilities(); method public android.content.ComponentName getService(); method public int getTaskId(); method public boolean isPeriodic(); method public boolean isRequireCharging(); method public boolean isRequireDeviceIdle(); Loading @@ -5375,7 +5375,7 @@ package android.app.task { field public static final int LINEAR = 0; // 0x0 } public final class Task.Builder { public static final class Task.Builder { ctor public Task.Builder(int, android.content.ComponentName); method public android.app.task.Task build(); method public android.app.task.Task.Builder setBackoffCriteria(long, int); Loading @@ -5389,8 +5389,9 @@ package android.app.task { } public static abstract interface Task.NetworkType { field public static final int ANY = 0; // 0x0 field public static final int UNMETERED = 1; // 0x1 field public static final int ANY = 1; // 0x1 field public static final int NONE = 0; // 0x0 field public static final int UNMETERED = 2; // 0x2 } public abstract class TaskManager { Loading @@ -5399,8 +5400,8 @@ package android.app.task { method public abstract void cancelAll(); method public abstract java.util.List<android.app.task.Task> getAllPendingTasks(); method public abstract int schedule(android.app.task.Task); field public static final int RESULT_INVALID_PARAMETERS = -1; // 0xffffffff field public static final int RESULT_OVER_QUOTA = -2; // 0xfffffffe field public static final int RESULT_FAILURE = 0; // 0x0 field public static final int RESULT_SUCCESS = 1; // 0x1 } public class TaskParams implements android.os.Parcelable { core/java/android/app/task/Task.java +46 −25 Original line number Diff line number Diff line Loading @@ -27,10 +27,13 @@ import android.os.Parcelable; * using the {@link Task.Builder}. */ public class Task implements Parcelable { public interface NetworkType { public final int ANY = 0; public final int UNMETERED = 1; /** Default. */ public final int NONE = 0; /** This task requires network connectivity. */ public final int ANY = 1; /** This task requires network connectivity that is unmetered. */ public final int UNMETERED = 2; } /** Loading @@ -48,6 +51,8 @@ public class Task implements Parcelable { private final ComponentName service; private final boolean requireCharging; private final boolean requireDeviceIdle; private final boolean hasEarlyConstraint; private final boolean hasLateConstraint; private final int networkCapabilities; private final long minLatencyMillis; private final long maxExecutionDelayMillis; Loading @@ -59,7 +64,7 @@ public class Task implements Parcelable { /** * Unique task id associated with this class. This is assigned to your task by the scheduler. */ public int getTaskId() { public int getId() { return taskId; } Loading Loading @@ -146,6 +151,24 @@ public class Task implements Parcelable { return backoffPolicy; } /** * User can specify an early constraint of 0L, which is valid, so we keep track of whether the * function was called at all. * @hide */ public boolean hasEarlyConstraint() { return hasEarlyConstraint; } /** * User can specify a late constraint of 0L, which is valid, so we keep track of whether the * function was called at all. * @hide */ public boolean hasLateConstraint() { return hasLateConstraint; } private Task(Parcel in) { taskId = in.readInt(); extras = in.readBundle(); Loading @@ -159,6 +182,8 @@ public class Task implements Parcelable { intervalMillis = in.readLong(); initialBackoffMillis = in.readLong(); backoffPolicy = in.readInt(); hasEarlyConstraint = in.readInt() == 1; hasLateConstraint = in.readInt() == 1; } private Task(Task.Builder b) { Loading @@ -174,6 +199,8 @@ public class Task implements Parcelable { intervalMillis = b.mIntervalMillis; initialBackoffMillis = b.mInitialBackoffMillis; backoffPolicy = b.mBackoffPolicy; hasEarlyConstraint = b.mHasEarlyConstraint; hasLateConstraint = b.mHasLateConstraint; } @Override Loading @@ -195,6 +222,8 @@ public class Task implements Parcelable { out.writeLong(intervalMillis); out.writeLong(initialBackoffMillis); out.writeInt(backoffPolicy); out.writeInt(hasEarlyConstraint ? 1 : 0); out.writeInt(hasLateConstraint ? 1 : 0); } public static final Creator<Task> CREATOR = new Creator<Task>() { Loading @@ -212,7 +241,7 @@ public class Task implements Parcelable { /** * Builder class for constructing {@link Task} objects. */ public final class Builder { public static final class Builder { private int mTaskId; private Bundle mExtras; private ComponentName mTaskService; Loading @@ -225,6 +254,8 @@ public class Task implements Parcelable { private long mMaxExecutionDelayMillis; // Periodic parameters. private boolean mIsPeriodic; private boolean mHasEarlyConstraint; private boolean mHasLateConstraint; private long mIntervalMillis; // Back-off parameters. private long mInitialBackoffMillis = 5000L; Loading Loading @@ -307,6 +338,7 @@ public class Task implements Parcelable { public Builder setPeriodic(long intervalMillis) { mIsPeriodic = true; mIntervalMillis = intervalMillis; mHasEarlyConstraint = mHasLateConstraint = true; return this; } Loading @@ -320,6 +352,7 @@ public class Task implements Parcelable { */ public Builder setMinimumLatency(long minLatencyMillis) { mMinLatencyMillis = minLatencyMillis; mHasEarlyConstraint = true; return this; } Loading @@ -332,6 +365,7 @@ public class Task implements Parcelable { */ public Builder setOverrideDeadline(long maxExecutionDelayMillis) { mMaxExecutionDelayMillis = maxExecutionDelayMillis; mHasLateConstraint = true; return this; } Loading Loading @@ -360,31 +394,18 @@ public class Task implements Parcelable { * @return The task object to hand to the TaskManager. This object is immutable. */ public Task build() { // Check that extras bundle only contains primitive types. try { for (String key : extras.keySet()) { Object value = extras.get(key); if (value == null) continue; if (value instanceof Long) continue; if (value instanceof Integer) continue; if (value instanceof Boolean) continue; if (value instanceof Float) continue; if (value instanceof Double) continue; if (value instanceof String) continue; throw new IllegalArgumentException("Unexpected value type: " + value.getClass().getName()); } } catch (IllegalArgumentException e) { throw e; } catch (RuntimeException exc) { throw new IllegalArgumentException("error unparcelling Bundle", exc); if (mExtras == null) { mExtras = Bundle.EMPTY; } if (mTaskId < 0) { throw new IllegalArgumentException("Task id must be greater than 0."); } // Check that a deadline was not set on a periodic task. if (mIsPeriodic && (mMaxExecutionDelayMillis != 0L)) { if (mIsPeriodic && mHasLateConstraint) { throw new IllegalArgumentException("Can't call setOverrideDeadline() on a " + "periodic task."); } if (mIsPeriodic && (mMinLatencyMillis != 0L)) { if (mIsPeriodic && mHasEarlyConstraint) { throw new IllegalArgumentException("Can't call setMinimumLatency() on a " + "periodic task"); } Loading core/java/android/app/task/TaskManager.java +2 −3 Original line number Diff line number Diff line Loading @@ -34,14 +34,13 @@ public abstract class TaskManager { * if the run-time for your task is too short, or perhaps the system can't resolve the * requisite {@link TaskService} in your package. */ public static final int RESULT_INVALID_PARAMETERS = -1; public static final int RESULT_FAILURE = 0; /** * Returned from {@link #schedule(Task)} if this application has made too many requests for * work over too short a time. */ // TODO: Determine if this is necessary. public static final int RESULT_OVER_QUOTA = -2; public static final int RESULT_SUCCESS = 1; /** * @param task The task you wish scheduled. See Loading services/core/java/com/android/server/task/StateChangedListener.java +1 −2 Original line number Diff line number Diff line Loading @@ -27,9 +27,8 @@ public interface StateChangedListener { /** * Called by the controller to notify the TaskManager that it should check on the state of a * task. * @param taskStatus The state of the task which has changed. */ public void onTaskStateChanged(TaskStatus taskStatus); public void onControllerStateChanged(); /** * Called by the controller to notify the TaskManager that regardless of the state of the task, Loading services/core/java/com/android/server/task/TaskCompletedListener.java +3 −9 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.task; import com.android.server.task.controllers.TaskStatus; /** * Used for communication between {@link com.android.server.task.TaskServiceContext} and the * {@link com.android.server.task.TaskManagerService}. Loading @@ -26,13 +28,5 @@ public interface TaskCompletedListener { * Callback for when a task is completed. * @param needsReschedule Whether the implementing class should reschedule this task. */ public void onTaskCompleted(int serviceToken, int taskId, boolean needsReschedule); /** * Callback for when the implementing class needs to clean up the * {@link com.android.server.task.TaskServiceContext}. The scheduler can get this callback * several times if the TaskServiceContext got into a bad state (for e.g. the client crashed * and it needs to clean up). */ public void onAllTasksCompleted(int serviceToken); public void onTaskCompleted(TaskStatus taskStatus, boolean needsReschedule); } Loading
api/current.txt +7 −6 Original line number Diff line number Diff line Loading @@ -5356,13 +5356,13 @@ package android.app.task { method public int describeContents(); method public int getBackoffPolicy(); method public android.os.Bundle getExtras(); method public int getId(); method public long getInitialBackoffMillis(); method public long getIntervalMillis(); method public long getMaxExecutionDelayMillis(); method public long getMinLatencyMillis(); method public int getNetworkCapabilities(); method public android.content.ComponentName getService(); method public int getTaskId(); method public boolean isPeriodic(); method public boolean isRequireCharging(); method public boolean isRequireDeviceIdle(); Loading @@ -5375,7 +5375,7 @@ package android.app.task { field public static final int LINEAR = 0; // 0x0 } public final class Task.Builder { public static final class Task.Builder { ctor public Task.Builder(int, android.content.ComponentName); method public android.app.task.Task build(); method public android.app.task.Task.Builder setBackoffCriteria(long, int); Loading @@ -5389,8 +5389,9 @@ package android.app.task { } public static abstract interface Task.NetworkType { field public static final int ANY = 0; // 0x0 field public static final int UNMETERED = 1; // 0x1 field public static final int ANY = 1; // 0x1 field public static final int NONE = 0; // 0x0 field public static final int UNMETERED = 2; // 0x2 } public abstract class TaskManager { Loading @@ -5399,8 +5400,8 @@ package android.app.task { method public abstract void cancelAll(); method public abstract java.util.List<android.app.task.Task> getAllPendingTasks(); method public abstract int schedule(android.app.task.Task); field public static final int RESULT_INVALID_PARAMETERS = -1; // 0xffffffff field public static final int RESULT_OVER_QUOTA = -2; // 0xfffffffe field public static final int RESULT_FAILURE = 0; // 0x0 field public static final int RESULT_SUCCESS = 1; // 0x1 } public class TaskParams implements android.os.Parcelable {
core/java/android/app/task/Task.java +46 −25 Original line number Diff line number Diff line Loading @@ -27,10 +27,13 @@ import android.os.Parcelable; * using the {@link Task.Builder}. */ public class Task implements Parcelable { public interface NetworkType { public final int ANY = 0; public final int UNMETERED = 1; /** Default. */ public final int NONE = 0; /** This task requires network connectivity. */ public final int ANY = 1; /** This task requires network connectivity that is unmetered. */ public final int UNMETERED = 2; } /** Loading @@ -48,6 +51,8 @@ public class Task implements Parcelable { private final ComponentName service; private final boolean requireCharging; private final boolean requireDeviceIdle; private final boolean hasEarlyConstraint; private final boolean hasLateConstraint; private final int networkCapabilities; private final long minLatencyMillis; private final long maxExecutionDelayMillis; Loading @@ -59,7 +64,7 @@ public class Task implements Parcelable { /** * Unique task id associated with this class. This is assigned to your task by the scheduler. */ public int getTaskId() { public int getId() { return taskId; } Loading Loading @@ -146,6 +151,24 @@ public class Task implements Parcelable { return backoffPolicy; } /** * User can specify an early constraint of 0L, which is valid, so we keep track of whether the * function was called at all. * @hide */ public boolean hasEarlyConstraint() { return hasEarlyConstraint; } /** * User can specify a late constraint of 0L, which is valid, so we keep track of whether the * function was called at all. * @hide */ public boolean hasLateConstraint() { return hasLateConstraint; } private Task(Parcel in) { taskId = in.readInt(); extras = in.readBundle(); Loading @@ -159,6 +182,8 @@ public class Task implements Parcelable { intervalMillis = in.readLong(); initialBackoffMillis = in.readLong(); backoffPolicy = in.readInt(); hasEarlyConstraint = in.readInt() == 1; hasLateConstraint = in.readInt() == 1; } private Task(Task.Builder b) { Loading @@ -174,6 +199,8 @@ public class Task implements Parcelable { intervalMillis = b.mIntervalMillis; initialBackoffMillis = b.mInitialBackoffMillis; backoffPolicy = b.mBackoffPolicy; hasEarlyConstraint = b.mHasEarlyConstraint; hasLateConstraint = b.mHasLateConstraint; } @Override Loading @@ -195,6 +222,8 @@ public class Task implements Parcelable { out.writeLong(intervalMillis); out.writeLong(initialBackoffMillis); out.writeInt(backoffPolicy); out.writeInt(hasEarlyConstraint ? 1 : 0); out.writeInt(hasLateConstraint ? 1 : 0); } public static final Creator<Task> CREATOR = new Creator<Task>() { Loading @@ -212,7 +241,7 @@ public class Task implements Parcelable { /** * Builder class for constructing {@link Task} objects. */ public final class Builder { public static final class Builder { private int mTaskId; private Bundle mExtras; private ComponentName mTaskService; Loading @@ -225,6 +254,8 @@ public class Task implements Parcelable { private long mMaxExecutionDelayMillis; // Periodic parameters. private boolean mIsPeriodic; private boolean mHasEarlyConstraint; private boolean mHasLateConstraint; private long mIntervalMillis; // Back-off parameters. private long mInitialBackoffMillis = 5000L; Loading Loading @@ -307,6 +338,7 @@ public class Task implements Parcelable { public Builder setPeriodic(long intervalMillis) { mIsPeriodic = true; mIntervalMillis = intervalMillis; mHasEarlyConstraint = mHasLateConstraint = true; return this; } Loading @@ -320,6 +352,7 @@ public class Task implements Parcelable { */ public Builder setMinimumLatency(long minLatencyMillis) { mMinLatencyMillis = minLatencyMillis; mHasEarlyConstraint = true; return this; } Loading @@ -332,6 +365,7 @@ public class Task implements Parcelable { */ public Builder setOverrideDeadline(long maxExecutionDelayMillis) { mMaxExecutionDelayMillis = maxExecutionDelayMillis; mHasLateConstraint = true; return this; } Loading Loading @@ -360,31 +394,18 @@ public class Task implements Parcelable { * @return The task object to hand to the TaskManager. This object is immutable. */ public Task build() { // Check that extras bundle only contains primitive types. try { for (String key : extras.keySet()) { Object value = extras.get(key); if (value == null) continue; if (value instanceof Long) continue; if (value instanceof Integer) continue; if (value instanceof Boolean) continue; if (value instanceof Float) continue; if (value instanceof Double) continue; if (value instanceof String) continue; throw new IllegalArgumentException("Unexpected value type: " + value.getClass().getName()); } } catch (IllegalArgumentException e) { throw e; } catch (RuntimeException exc) { throw new IllegalArgumentException("error unparcelling Bundle", exc); if (mExtras == null) { mExtras = Bundle.EMPTY; } if (mTaskId < 0) { throw new IllegalArgumentException("Task id must be greater than 0."); } // Check that a deadline was not set on a periodic task. if (mIsPeriodic && (mMaxExecutionDelayMillis != 0L)) { if (mIsPeriodic && mHasLateConstraint) { throw new IllegalArgumentException("Can't call setOverrideDeadline() on a " + "periodic task."); } if (mIsPeriodic && (mMinLatencyMillis != 0L)) { if (mIsPeriodic && mHasEarlyConstraint) { throw new IllegalArgumentException("Can't call setMinimumLatency() on a " + "periodic task"); } Loading
core/java/android/app/task/TaskManager.java +2 −3 Original line number Diff line number Diff line Loading @@ -34,14 +34,13 @@ public abstract class TaskManager { * if the run-time for your task is too short, or perhaps the system can't resolve the * requisite {@link TaskService} in your package. */ public static final int RESULT_INVALID_PARAMETERS = -1; public static final int RESULT_FAILURE = 0; /** * Returned from {@link #schedule(Task)} if this application has made too many requests for * work over too short a time. */ // TODO: Determine if this is necessary. public static final int RESULT_OVER_QUOTA = -2; public static final int RESULT_SUCCESS = 1; /** * @param task The task you wish scheduled. See Loading
services/core/java/com/android/server/task/StateChangedListener.java +1 −2 Original line number Diff line number Diff line Loading @@ -27,9 +27,8 @@ public interface StateChangedListener { /** * Called by the controller to notify the TaskManager that it should check on the state of a * task. * @param taskStatus The state of the task which has changed. */ public void onTaskStateChanged(TaskStatus taskStatus); public void onControllerStateChanged(); /** * Called by the controller to notify the TaskManager that regardless of the state of the task, Loading
services/core/java/com/android/server/task/TaskCompletedListener.java +3 −9 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.task; import com.android.server.task.controllers.TaskStatus; /** * Used for communication between {@link com.android.server.task.TaskServiceContext} and the * {@link com.android.server.task.TaskManagerService}. Loading @@ -26,13 +28,5 @@ public interface TaskCompletedListener { * Callback for when a task is completed. * @param needsReschedule Whether the implementing class should reschedule this task. */ public void onTaskCompleted(int serviceToken, int taskId, boolean needsReschedule); /** * Callback for when the implementing class needs to clean up the * {@link com.android.server.task.TaskServiceContext}. The scheduler can get this callback * several times if the TaskServiceContext got into a bad state (for e.g. the client crashed * and it needs to clean up). */ public void onAllTasksCompleted(int serviceToken); public void onTaskCompleted(TaskStatus taskStatus, boolean needsReschedule); }