Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e96c3b7e authored by Shreyas Basarge's avatar Shreyas Basarge
Browse files

Updated Javadoc to reflect min period

Javadoc updated and logging added for
min period and min flex enforcements
in JobScheduler and SyncManager.

Bug: 26874152
Change-Id: Ifdd248b776a1bd04df21b7b9f0ac96bdef0f8bb6
parent bc0ce990
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.PersistableBundle;
import android.util.Log;

import java.util.ArrayList;

@@ -35,6 +36,7 @@ import java.util.ArrayList;
 * 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 @@ public class JobInfo implements Parcelable {
        /**
         * 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 @@ public class JobInfo implements Parcelable {
                        " 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;
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -2053,7 +2053,8 @@ public abstract class ContentResolver {
     * @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.
     */
+3 −2
Original line number Diff line number Diff line
@@ -303,10 +303,11 @@ public class SyncRequest implements Parcelable {
         * 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) {
+6 −6
Original line number Diff line number Diff line
@@ -400,10 +400,10 @@ public final class ContentService extends IContentService.Stub {
                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().getSyncStorageEngine()
@@ -620,10 +620,10 @@ public final class ContentService extends IContentService.Stub {
                "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);