Merge "Updated Javadoc to reflect min period"
diff --git a/core/java/android/app/job/JobInfo.java b/core/java/android/app/job/JobInfo.java
index 0143797..b2ca023 100644
--- a/core/java/android/app/job/JobInfo.java
+++ b/core/java/android/app/job/JobInfo.java
@@ -23,6 +23,7 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.os.PersistableBundle;
+import android.util.Log;
import java.util.ArrayList;
@@ -35,6 +36,7 @@
* accomplish. Doing otherwise with throw an exception in your app.
*/
public class JobInfo implements Parcelable {
+ private static String TAG = "JobInfo";
/** Default. */
public static final int NETWORK_TYPE_NONE = 0;
/** This job requires network connectivity. */
@@ -526,7 +528,8 @@
/**
* Specify that this job should recur with the provided interval and flex. The job can
* execute at any time in a window of flex length at the end of the period.
- * @param intervalMillis Millisecond interval for which this job will repeat.
+ * @param intervalMillis Millisecond interval for which this job will repeat. A minimum
+ * value of {@link #MIN_PERIOD_MILLIS} is enforced.
* @param flexMillis Millisecond flex for this job. Flex is clamped to be at least
* {@link #MIN_FLEX_MILLIS} or 5 percent of the period, whichever is
* higher.
@@ -635,7 +638,16 @@
" back-off policy, so calling setBackoffCriteria with" +
" setRequiresDeviceIdle is an error.");
}
- return new JobInfo(this);
+ JobInfo job = new JobInfo(this);
+ if (job.intervalMillis != job.getIntervalMillis()) {
+ Log.w(TAG, "Specified interval is less than minimum interval. Clamped to "
+ + job.getIntervalMillis());
+ }
+ if (job.flexMillis != job.getFlexMillis()) {
+ Log.w(TAG, "Specified flex is less than minimum flex. Clamped to "
+ + job.getFlexMillis());
+ }
+ return job;
}
}
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java
index 0172408..4e1b6e0 100644
--- a/core/java/android/content/ContentResolver.java
+++ b/core/java/android/content/ContentResolver.java
@@ -2060,7 +2060,8 @@
* @param account the account to specify in the sync
* @param authority the provider to specify in the sync request
* @param extras extra parameters to go along with the sync request
- * @param pollFrequency how frequently the sync should be performed, in seconds.
+ * @param pollFrequency how frequently the sync should be performed, in seconds. A minimum value
+ * of 1 hour is enforced.
* @throws IllegalArgumentException if an illegal extra was set or if any of the parameters
* are null.
*/
diff --git a/core/java/android/content/SyncRequest.java b/core/java/android/content/SyncRequest.java
index 4f7d20d..f793d76 100644
--- a/core/java/android/content/SyncRequest.java
+++ b/core/java/android/content/SyncRequest.java
@@ -307,10 +307,11 @@
* be thrown.
*
* @param pollFrequency the amount of time in seconds that you wish
- * to elapse between periodic syncs.
+ * to elapse between periodic syncs. A minimum period of 1 hour is enforced.
* @param beforeSeconds the amount of flex time in seconds before
* {@code pollFrequency} that you permit for the sync to take
- * place. Must be less than {@code pollFrequency}.
+ * place. Must be less than {@code pollFrequency} and greater than
+ * MAX(5% of {@code pollFrequency}, 5 minutes)
*/
public Builder syncPeriodic(long pollFrequency, long beforeSeconds) {
if (mSyncType != SYNC_TYPE_UNKNOWN) {
diff --git a/services/core/java/com/android/server/content/ContentService.java b/services/core/java/com/android/server/content/ContentService.java
index 1968c8c..212e077 100644
--- a/services/core/java/com/android/server/content/ContentService.java
+++ b/services/core/java/com/android/server/content/ContentService.java
@@ -400,10 +400,10 @@
SyncStorageEngine.EndPoint info;
info = new SyncStorageEngine.EndPoint(
request.getAccount(), request.getProvider(), userId);
- if (runAtTime < 60) {
+ if (runAtTime < 3600) {
Slog.w(TAG, "Requested poll frequency of " + runAtTime
- + " seconds being rounded up to 60 seconds.");
- runAtTime = 60;
+ + " seconds being rounded up to 1 hour.");
+ runAtTime = 3600;
}
// Schedule periodic sync.
getSyncManager().updateOrAddPeriodicSync(info, runAtTime,
@@ -620,10 +620,10 @@
"no permission to write the sync settings");
int userId = UserHandle.getCallingUserId();
- if (pollFrequency < 60) {
+ if (pollFrequency < 3600) {
Slog.w(TAG, "Requested poll frequency of " + pollFrequency
- + " seconds being rounded up to 60 seconds.");
- pollFrequency = 60;
+ + " seconds being rounded up to 1 hour.");
+ pollFrequency = 3600;
}
long defaultFlex = SyncStorageEngine.calculateDefaultFlexTime(pollFrequency);