public class SyncRequest implements android.os.Parcelable {
method public int describeContents();
- method public boolean isExpedited();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator CREATOR;
}
method public android.content.SyncRequest.Builder setIgnoreSettings(boolean);
method public android.content.SyncRequest.Builder setManual(boolean);
method public android.content.SyncRequest.Builder setNoRetry(boolean);
- method public android.content.SyncRequest.Builder setPriority(int);
method public android.content.SyncRequest.Builder setSyncAdapter(android.accounts.Account, java.lang.String);
method public android.content.SyncRequest.Builder syncOnce();
method public android.content.SyncRequest.Builder syncPeriodic(long, long);
import android.os.Parcel;
import android.os.Parcelable;
+/**
+ * Convenience class to construct sync requests. See {@link android.content.SyncRequest.Builder}
+ * for an explanation of the various functions. The resulting object is passed through to the
+ * framework via {@link android.content.ContentResolver#requestSync(SyncRequest)}.
+ */
public class SyncRequest implements Parcelable {
private static final String TAG = "SyncRequest";
/** Account to pass to the sync adapter. Can be null. */
return mIsPeriodic;
}
+ /**
+ * {@hide}
+ * @return whether this sync is expedited.
+ */
public boolean isExpedited() {
return mIsExpedited;
}
* discriminate between equivalent syncs.
*/
private Bundle mSyncConfigExtras;
- /** Expected upload transfer in bytes. */
- private long mTxBytes = -1L;
- /** Expected download transfer in bytes. */
- private long mRxBytes = -1L;
/** Whether or not this sync can occur on metered networks. Default false. */
private boolean mDisallowMetered;
- /** Priority of this sync relative to others from calling app [-2, 2]. Default 0. */
- private int mPriority = 0;
/**
* Whether this builder is building a periodic sync, or a one-time sync.
*/
return this;
}
- /** {@hide} */
private void setupInterval(long at, long before) {
if (before > at) {
throw new IllegalArgumentException("Specified run time for the sync must be" +
}
/**
- * @param priority the priority of this request among all requests from the calling app.
- * Range of [-2,2] similar to how this is done with notifications.
- */
- public Builder setPriority(int priority) {
- if (priority < -2 || priority > 2) {
- throw new IllegalArgumentException("Priority must be within range [-2, 2]");
- }
- mPriority = priority;
- return this;
- }
-
- /**
* Performs validation over the request and throws the runtime exception
* <code>IllegalArgumentException</code> if this validation fails.
*
mSyncConfigExtras.putBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, true);
mSyncConfigExtras.putBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_SETTINGS, true);
}
- mSyncConfigExtras.putLong(ContentResolver.SYNC_EXTRAS_EXPECTED_UPLOAD, mTxBytes);
- mSyncConfigExtras.putLong(ContentResolver.SYNC_EXTRAS_EXPECTED_DOWNLOAD, mRxBytes);
- mSyncConfigExtras.putInt(ContentResolver.SYNC_EXTRAS_PRIORITY, mPriority);
if (mSyncType == SYNC_TYPE_PERIODIC) {
// If this is a periodic sync ensure than invalid extras were not set.
if (ContentResolver.invalidPeriodicExtras(mCustomExtras) ||