mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 715794 - Adjust syncResult delay to implement client-count-based sync interval. r=rnewman
This commit is contained in:
parent
eda91a0a01
commit
026ab4e368
@ -52,7 +52,8 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter implements GlobalSe
|
|||||||
|
|
||||||
private static final int SHARED_PREFERENCES_MODE = 0;
|
private static final int SHARED_PREFERENCES_MODE = 0;
|
||||||
private static final int BACKOFF_PAD_SECONDS = 5;
|
private static final int BACKOFF_PAD_SECONDS = 5;
|
||||||
private static final int MINIMUM_SYNC_INTERVAL_MILLISECONDS = 5 * 60 * 1000; // 5 minutes.
|
public static final int MULTI_DEVICE_INTERVAL_MILLISECONDS = 5 * 60 * 1000; // 5 minutes.
|
||||||
|
public static final int SINGLE_DEVICE_INTERVAL_MILLISECONDS = 24 * 60 * 60 * 1000; // 24 hours.
|
||||||
|
|
||||||
private final AccountManager mAccountManager;
|
private final AccountManager mAccountManager;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@ -172,7 +173,7 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter implements GlobalSe
|
|||||||
public Object syncMonitor = new Object();
|
public Object syncMonitor = new Object();
|
||||||
private SyncResult syncResult;
|
private SyncResult syncResult;
|
||||||
|
|
||||||
private Account localAccount;
|
public Account localAccount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of milliseconds until we're allowed to sync again,
|
* Return the number of milliseconds until we're allowed to sync again,
|
||||||
@ -298,7 +299,7 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter implements GlobalSe
|
|||||||
Log.i(LOG_TAG, "Waiting on sync monitor.");
|
Log.i(LOG_TAG, "Waiting on sync monitor.");
|
||||||
try {
|
try {
|
||||||
syncMonitor.wait();
|
syncMonitor.wait();
|
||||||
long next = System.currentTimeMillis() + MINIMUM_SYNC_INTERVAL_MILLISECONDS;
|
long next = System.currentTimeMillis() + getSyncInterval();
|
||||||
Log.i(LOG_TAG, "Setting minimum next sync time to " + next);
|
Log.i(LOG_TAG, "Setting minimum next sync time to " + next);
|
||||||
extendEarliestNextSync(next);
|
extendEarliestNextSync(next);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -310,6 +311,15 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter implements GlobalSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSyncInterval() {
|
||||||
|
int clientsCount = this.getClientsCount();
|
||||||
|
if (clientsCount <= 1) {
|
||||||
|
return SINGLE_DEVICE_INTERVAL_MILLISECONDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MULTI_DEVICE_INTERVAL_MILLISECONDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Now that we have a sync key and password, go ahead and do the work.
|
* Now that we have a sync key and password, go ahead and do the work.
|
||||||
|
Loading…
Reference in New Issue
Block a user