public class SyncStorageEngine extends Handler
Modifier and Type | Class and Description |
---|---|
static class |
SyncStorageEngine.AuthorityInfo |
static class |
SyncStorageEngine.DayStats |
static class |
SyncStorageEngine.EndPoint
Bare bones representation of a sync target.
|
static class |
SyncStorageEngine.SyncHistoryItem |
Handler.Callback
Modifier and Type | Field and Description |
---|---|
static int |
EVENT_START
Enum value for a sync start event.
|
static int |
EVENT_STOP
Enum value for a sync stop event.
|
static int |
MAX_HISTORY |
static String |
MESG_CANCELED |
static String |
MESG_SUCCESS |
static long |
NOT_IN_BACKOFF_MODE |
static int |
SOURCE_LOCAL
Enum value for a local-initiated sync.
|
static int |
SOURCE_PERIODIC
Enum value for a periodic sync.
|
static int |
SOURCE_POLL
Enum value for a poll-based sync (e.g., upon connection to network)
|
static int |
SOURCE_SERVER
Enum value for a server-initiated sync.
|
static int |
SOURCE_USER
Enum value for a user-initiated sync.
|
static String[] |
SOURCES
String names for the sync source types.
|
static int |
STATISTICS_FILE_END |
static int |
STATISTICS_FILE_ITEM |
static int |
STATISTICS_FILE_ITEM_OLD |
static int |
STATUS_FILE_END |
static int |
STATUS_FILE_ITEM |
Modifier and Type | Method and Description |
---|---|
SyncInfo |
addActiveSync(com.android.server.content.SyncManager.ActiveSyncContext activeSyncContext)
Called when a sync is starting.
|
void |
addStatusChangeListener(int mask,
ISyncStatusObserver callback) |
static long |
calculateDefaultFlexTime(long syncTimeSeconds)
Figure out a reasonable flex time for cases where none is provided (old api calls).
|
void |
clearAllBackoffsLocked() |
void |
clearAndReadState()
public for testing
|
void |
doDatabaseCleanup(Account[] accounts,
int userId)
Called when the set of account has changed, given the new array of
active accounts.
|
SyncStorageEngine.AuthorityInfo |
getAuthority(int authorityId) |
Pair<Long,Long> |
getBackoff(SyncStorageEngine.EndPoint info) |
Pair<SyncStorageEngine.AuthorityInfo,SyncStatusInfo> |
getCopyOfAuthorityWithSyncStatus(SyncStorageEngine.EndPoint info)
Return a copy of the specified target with the corresponding sync status
|
List<SyncInfo> |
getCurrentSyncsCopy(int userId,
boolean canAccessAccounts) |
SyncStorageEngine.DayStats[] |
getDayStatistics()
Return an array of the current per-day statistics.
|
long |
getDelayUntilTime(SyncStorageEngine.EndPoint info) |
int |
getIsSyncable(Account account,
int userId,
String providerName) |
boolean |
getMasterSyncAutomatically(int userId) |
static SyncStorageEngine |
getSingleton() |
SyncStatusInfo |
getStatusByAuthority(SyncStorageEngine.EndPoint info)
Returns the status that matches the target.
|
boolean |
getSyncAutomatically(Account account,
int userId,
String providerName) |
ArrayList<SyncStorageEngine.SyncHistoryItem> |
getSyncHistory()
Return an array of the current sync status for all authorities.
|
int |
getSyncRandomOffset() |
void |
handleMessage(Message msg)
Subclasses must implement this to receive messages.
|
static void |
init(Context context) |
long |
insertStartSyncEvent(SyncOperation op,
long now)
Note that sync has started for the given operation.
|
boolean |
isSyncActive(SyncStorageEngine.EndPoint info)
Returns true if there is currently a sync operation being actively processed for the given
target.
|
boolean |
isSyncPending(SyncStorageEngine.EndPoint info)
Return true if the pending status is true of any matching authorities.
|
void |
markPending(SyncStorageEngine.EndPoint info,
boolean pendingValue) |
static SyncStorageEngine |
newTestInstance(Context context) |
void |
queueBackup()
Let the BackupManager know that account sync settings have changed.
|
void |
removeActiveSync(SyncInfo syncInfo,
int userId)
Called to indicate that a previously active sync is no longer active.
|
void |
removeAuthority(SyncStorageEngine.EndPoint info) |
void |
removeStatusChangeListener(ISyncStatusObserver callback) |
void |
reportActiveChange()
To allow others to send active change reports, to poke clients.
|
void |
setBackoff(SyncStorageEngine.EndPoint info,
long nextSyncTime,
long nextDelay)
Update the backoff for the given endpoint.
|
void |
setDelayUntilTime(SyncStorageEngine.EndPoint info,
long delayUntil) |
void |
setIsSyncable(Account account,
int userId,
String providerName,
int syncable) |
void |
setMasterSyncAutomatically(boolean flag,
int userId) |
protected void |
setOnAuthorityRemovedListener(com.android.server.content.SyncStorageEngine.OnAuthorityRemovedListener listener) |
protected void |
setOnSyncRequestListener(com.android.server.content.SyncStorageEngine.OnSyncRequestListener listener) |
protected void |
setPeriodicSyncAddedListener(com.android.server.content.SyncStorageEngine.PeriodicSyncAddedListener listener) |
void |
setSyncAutomatically(Account account,
int userId,
String providerName,
boolean sync) |
boolean |
shouldGrantSyncAdaptersAccountAccess() |
void |
stopSyncEvent(long historyId,
long elapsedTime,
String resultMessage,
long downstreamActivity,
long upstreamActivity) |
void |
writeAllState() |
dispatchMessage, dump, getLooper, getMessageName, getTraceName, hasCallbacks, hasMessages, hasMessages, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, post, postAtFrontOfQueue, postAtTime, postAtTime, postDelayed, removeCallbacks, removeCallbacks, removeCallbacksAndMessages, removeMessages, removeMessages, runWithScissors, sendEmptyMessage, sendEmptyMessageAtTime, sendEmptyMessageDelayed, sendMessage, sendMessageAtFrontOfQueue, sendMessageAtTime, sendMessageDelayed, toString
public static final int EVENT_START
public static final int EVENT_STOP
public static final int SOURCE_SERVER
public static final int SOURCE_LOCAL
public static final int SOURCE_POLL
public static final int SOURCE_USER
public static final int SOURCE_PERIODIC
public static final long NOT_IN_BACKOFF_MODE
public static final String[] SOURCES
public static final String MESG_SUCCESS
public static final String MESG_CANCELED
public static final int MAX_HISTORY
public static final int STATUS_FILE_END
public static final int STATUS_FILE_ITEM
public static final int STATISTICS_FILE_END
public static final int STATISTICS_FILE_ITEM_OLD
public static final int STATISTICS_FILE_ITEM
public static SyncStorageEngine newTestInstance(Context context)
public static void init(Context context)
public static SyncStorageEngine getSingleton()
protected void setOnSyncRequestListener(com.android.server.content.SyncStorageEngine.OnSyncRequestListener listener)
protected void setOnAuthorityRemovedListener(com.android.server.content.SyncStorageEngine.OnAuthorityRemovedListener listener)
protected void setPeriodicSyncAddedListener(com.android.server.content.SyncStorageEngine.PeriodicSyncAddedListener listener)
public void handleMessage(Message msg)
Handler
handleMessage
in class Handler
public int getSyncRandomOffset()
public void addStatusChangeListener(int mask, ISyncStatusObserver callback)
public void removeStatusChangeListener(ISyncStatusObserver callback)
public static long calculateDefaultFlexTime(long syncTimeSeconds)
syncTimeSeconds
- requested sync time from now.DEFAULT_POLL_FREQUENCY_SECONDS
.public boolean getSyncAutomatically(Account account, int userId, String providerName)
public void setSyncAutomatically(Account account, int userId, String providerName, boolean sync)
public int getIsSyncable(Account account, int userId, String providerName)
public void setIsSyncable(Account account, int userId, String providerName, int syncable)
public Pair<Long,Long> getBackoff(SyncStorageEngine.EndPoint info)
public void setBackoff(SyncStorageEngine.EndPoint info, long nextSyncTime, long nextDelay)
public void clearAllBackoffsLocked()
public long getDelayUntilTime(SyncStorageEngine.EndPoint info)
public void setDelayUntilTime(SyncStorageEngine.EndPoint info, long delayUntil)
public void setMasterSyncAutomatically(boolean flag, int userId)
public boolean getMasterSyncAutomatically(int userId)
public SyncStorageEngine.AuthorityInfo getAuthority(int authorityId)
public boolean isSyncActive(SyncStorageEngine.EndPoint info)
public void markPending(SyncStorageEngine.EndPoint info, boolean pendingValue)
public void doDatabaseCleanup(Account[] accounts, int userId)
public SyncInfo addActiveSync(com.android.server.content.SyncManager.ActiveSyncContext activeSyncContext)
public void removeActiveSync(SyncInfo syncInfo, int userId)
public void reportActiveChange()
public long insertStartSyncEvent(SyncOperation op, long now)
public void stopSyncEvent(long historyId, long elapsedTime, String resultMessage, long downstreamActivity, long upstreamActivity)
public List<SyncInfo> getCurrentSyncsCopy(int userId, boolean canAccessAccounts)
userId
- Id of user to return current sync info.canAccessAccounts
- Determines whether to redact Account information from the result.public Pair<SyncStorageEngine.AuthorityInfo,SyncStatusInfo> getCopyOfAuthorityWithSyncStatus(SyncStorageEngine.EndPoint info)
public SyncStatusInfo getStatusByAuthority(SyncStorageEngine.EndPoint info)
info
- the endpoint target we are querying status info for.public boolean isSyncPending(SyncStorageEngine.EndPoint info)
public ArrayList<SyncStorageEngine.SyncHistoryItem> getSyncHistory()
public SyncStorageEngine.DayStats[] getDayStatistics()
public void removeAuthority(SyncStorageEngine.EndPoint info)
public void writeAllState()
public boolean shouldGrantSyncAdaptersAccountAccess()
public void clearAndReadState()
public void queueBackup()
SystemBackupAgent
to run.