ContentResolver.addPeriodicSync interval round up

前端 未结 3 784
执念已碎
执念已碎 2020-12-06 20:53

My sync adapter does work perfectly well except for one little thing which bugs the sh*t out of me for the last few hours... For my app i want the sync adapter to run with a

3条回答
  •  青春惊慌失措
    2020-12-06 21:25

    It seems to be that it is not possible to add a period sync with an interval lesser than 60 seconds. (Or least from 4.4 and higher.)

    https://android.googlesource.com/platform/frameworks/base/+/kitkat-mr1-release/services/java/com/android/server/content/ContentService.java

    if (request.isPeriodic()) {
        mContext.enforceCallingOrSelfPermission(
            Manifest.permission.WRITE_SYNC_SETTINGS,
            "no permission to write the sync settings");
        if (runAtTime < 60) {
            Slog.w(TAG, "Requested poll frequency of " + runAtTime
                + " seconds being rounded up to 60 seconds.");
            runAtTime = 60;
        }
        PeriodicSync syncToAdd =
            new PeriodicSync(account, provider, extras, runAtTime, flextime);
        getSyncManager().getSyncStorageEngine().addPeriodicSync(syncToAdd, userId);
    }
    

提交回复
热议问题