Merge "Update SyncManager min period to match JobScheduler" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
166b0abf13
@@ -22,6 +22,7 @@ import android.annotation.Nullable;
|
|||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManagerNative;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
|
import android.app.job.JobInfo;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.ContentProvider;
|
import android.content.ContentProvider;
|
||||||
@@ -512,6 +513,16 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
syncAsUser(request, UserHandle.getCallingUserId());
|
syncAsUser(request, UserHandle.getCallingUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long clampPeriod(long period) {
|
||||||
|
long minPeriod = JobInfo.getMinPeriodMillis() / 1000;
|
||||||
|
if (period < minPeriod) {
|
||||||
|
Slog.w(TAG, "Requested poll frequency of " + period
|
||||||
|
+ " seconds being rounded up to " + minPeriod + "s.");
|
||||||
|
period = minPeriod;
|
||||||
|
}
|
||||||
|
return period;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the user id supplied is different to the calling user, the caller must hold the
|
* If the user id supplied is different to the calling user, the caller must hold the
|
||||||
* INTERACT_ACROSS_USERS_FULL permission.
|
* INTERACT_ACROSS_USERS_FULL permission.
|
||||||
@@ -539,11 +550,8 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
SyncStorageEngine.EndPoint info;
|
SyncStorageEngine.EndPoint info;
|
||||||
info = new SyncStorageEngine.EndPoint(
|
info = new SyncStorageEngine.EndPoint(
|
||||||
request.getAccount(), request.getProvider(), userId);
|
request.getAccount(), request.getProvider(), userId);
|
||||||
if (runAtTime < 3600) {
|
|
||||||
Slog.w(TAG, "Requested poll frequency of " + runAtTime
|
runAtTime = clampPeriod(runAtTime);
|
||||||
+ " seconds being rounded up to 1 hour.");
|
|
||||||
runAtTime = 3600;
|
|
||||||
}
|
|
||||||
// Schedule periodic sync.
|
// Schedule periodic sync.
|
||||||
getSyncManager().updateOrAddPeriodicSync(info, runAtTime,
|
getSyncManager().updateOrAddPeriodicSync(info, runAtTime,
|
||||||
flextime, extras);
|
flextime, extras);
|
||||||
@@ -761,11 +769,8 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
"no permission to write the sync settings");
|
"no permission to write the sync settings");
|
||||||
|
|
||||||
int userId = UserHandle.getCallingUserId();
|
int userId = UserHandle.getCallingUserId();
|
||||||
if (pollFrequency < 3600) {
|
|
||||||
Slog.w(TAG, "Requested poll frequency of " + pollFrequency
|
pollFrequency = clampPeriod(pollFrequency);
|
||||||
+ " seconds being rounded up to 1 hour.");
|
|
||||||
pollFrequency = 3600;
|
|
||||||
}
|
|
||||||
long defaultFlex = SyncStorageEngine.calculateDefaultFlexTime(pollFrequency);
|
long defaultFlex = SyncStorageEngine.calculateDefaultFlexTime(pollFrequency);
|
||||||
|
|
||||||
long identityToken = clearCallingIdentity();
|
long identityToken = clearCallingIdentity();
|
||||||
|
|||||||
Reference in New Issue
Block a user