public class SyncStorageEngine extends Handler
Modifier and Type | Class and Description |
---|---|
static class |
SyncStorageEngine.AuthorityInfo |
static class |
SyncStorageEngine.DayStats |
static class |
SyncStorageEngine.PendingOperation |
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 String[] |
EVENTS
String names for the sync event types.
|
static int |
MAX_HISTORY |
static String |
MESG_CANCELED |
static String |
MESG_SUCCESS |
static long |
NOT_IN_BACKOFF_MODE |
static int |
PENDING_OPERATION_VERSION |
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 |
static Intent |
SYNC_CONNECTION_SETTING_CHANGED_INTENT |
Modifier and Type | Method and Description |
---|---|
SyncInfo |
addActiveSync(android.content.SyncManager.ActiveSyncContext activeSyncContext)
Called when a sync is starting.
|
void |
addPeriodicSync(Account account,
int userId,
String providerName,
Bundle extras,
long pollFrequency) |
void |
addStatusChangeListener(int mask,
ISyncStatusObserver callback) |
void |
clearAllBackoffs(SyncQueue syncQueue) |
void |
clearAndReadState()
public for testing
|
boolean |
deleteFromPending(SyncStorageEngine.PendingOperation op) |
void |
doDatabaseCleanup(Account[] accounts,
int userId)
Called when the set of account has changed, given the new array of
active accounts.
|
static boolean |
equals(Bundle b1,
Bundle b2) |
ArrayList<SyncStorageEngine.AuthorityInfo> |
getAuthorities()
Return an array of the current authorities.
|
SyncStorageEngine.AuthorityInfo |
getAuthority(int authorityId) |
Pair<Long,Long> |
getBackoff(Account account,
int userId,
String providerName) |
List<SyncInfo> |
getCurrentSyncs(int userId)
Return a list of the currently active syncs.
|
SyncStorageEngine.DayStats[] |
getDayStatistics()
Return an array of the current per-day statistics.
|
long |
getDelayUntilTime(Account account,
int userId,
String providerName) |
int |
getIsSyncable(Account account,
int userId,
String providerName) |
boolean |
getMasterSyncAutomatically(int userId) |
SyncStorageEngine.AuthorityInfo |
getOrCreateAuthority(Account account,
int userId,
String authority) |
SyncStatusInfo |
getOrCreateSyncStatus(SyncStorageEngine.AuthorityInfo authority) |
int |
getPendingOperationCount()
Return the number of currently pending operations.
|
ArrayList<SyncStorageEngine.PendingOperation> |
getPendingOperations()
Return a copy of the current array of pending operations.
|
List<PeriodicSync> |
getPeriodicSyncs(Account account,
int userId,
String providerName) |
static SyncStorageEngine |
getSingleton() |
SyncStatusInfo |
getStatusByAccountAndAuthority(Account account,
int userId,
String authority)
Returns the status that matches the authority and account.
|
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() |
ArrayList<SyncStatusInfo> |
getSyncStatus()
Return an array of the current sync status for all authorities.
|
void |
handleMessage(Message msg)
Subclasses must implement this to receive messages.
|
static void |
init(Context context) |
SyncStorageEngine.PendingOperation |
insertIntoPending(SyncStorageEngine.PendingOperation op) |
long |
insertStartSyncEvent(Account accountName,
int userId,
String authorityName,
long now,
int source,
boolean initialization)
Note that sync has started for the given account and authority.
|
boolean |
isSyncActive(Account account,
int userId,
String authority)
Returns true if there is currently a sync operation for the given
account or authority actively being processed.
|
boolean |
isSyncPending(Account account,
int userId,
String authority)
Return true if the pending status is true of any matching authorities.
|
static SyncStorageEngine |
newTestInstance(Context context) |
void |
removeActiveSync(SyncInfo syncInfo,
int userId)
Called to indicate that a previously active sync is no longer active.
|
void |
removeAuthority(Account account,
int userId,
String authority) |
void |
removePeriodicSync(Account account,
int userId,
String providerName,
Bundle extras) |
void |
removeStatusChangeListener(ISyncStatusObserver callback) |
void |
reportActiveChange()
To allow others to send active change reports, to poke clients.
|
void |
setBackoff(Account account,
int userId,
String providerName,
long nextSyncTime,
long nextDelay) |
void |
setDelayUntilTime(Account account,
int userId,
String providerName,
long delayUntil) |
void |
setIsSyncable(Account account,
int userId,
String providerName,
int syncable) |
void |
setMasterSyncAutomatically(boolean flag,
int userId) |
protected void |
setOnSyncRequestListener(android.content.SyncStorageEngine.OnSyncRequestListener listener) |
void |
setSyncAutomatically(Account account,
int userId,
String providerName,
boolean sync) |
void |
stopSyncEvent(long historyId,
long elapsedTime,
String resultMessage,
long downstreamActivity,
long upstreamActivity) |
void |
writeAllState() |
dispatchMessage, dump, getLooper, getMessageName, 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 String[] EVENTS
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 Intent SYNC_CONNECTION_SETTING_CHANGED_INTENT
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 PENDING_OPERATION_VERSION
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(android.content.SyncStorageEngine.OnSyncRequestListener 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 boolean getSyncAutomatically(Account account, int userId, String providerName)
public void setSyncAutomatically(Account account, int userId, String providerName, boolean sync)
public void setIsSyncable(Account account, int userId, String providerName, int syncable)
public void setBackoff(Account account, int userId, String providerName, long nextSyncTime, long nextDelay)
public void clearAllBackoffs(SyncQueue syncQueue)
public void setDelayUntilTime(Account account, int userId, String providerName, long delayUntil)
public void addPeriodicSync(Account account, int userId, String providerName, Bundle extras, long pollFrequency)
public void removePeriodicSync(Account account, int userId, String providerName, Bundle extras)
public List<PeriodicSync> getPeriodicSyncs(Account account, int userId, String providerName)
public void setMasterSyncAutomatically(boolean flag, int userId)
public boolean getMasterSyncAutomatically(int userId)
public SyncStorageEngine.AuthorityInfo getOrCreateAuthority(Account account, int userId, String authority)
public SyncStorageEngine.AuthorityInfo getAuthority(int authorityId)
public boolean isSyncActive(Account account, int userId, String authority)
public SyncStorageEngine.PendingOperation insertIntoPending(SyncStorageEngine.PendingOperation op)
public boolean deleteFromPending(SyncStorageEngine.PendingOperation op)
public ArrayList<SyncStorageEngine.PendingOperation> getPendingOperations()
public int getPendingOperationCount()
public void doDatabaseCleanup(Account[] accounts, int userId)
public SyncInfo addActiveSync(android.content.SyncManager.ActiveSyncContext activeSyncContext)
public void removeActiveSync(SyncInfo syncInfo, int userId)
public void reportActiveChange()
public long insertStartSyncEvent(Account accountName, int userId, String authorityName, long now, int source, boolean initialization)
public void stopSyncEvent(long historyId, long elapsedTime, String resultMessage, long downstreamActivity, long upstreamActivity)
public List<SyncInfo> getCurrentSyncs(int userId)
public ArrayList<SyncStatusInfo> getSyncStatus()
public ArrayList<SyncStorageEngine.AuthorityInfo> getAuthorities()
public SyncStatusInfo getStatusByAccountAndAuthority(Account account, int userId, String authority)
account
- the account we want to checkauthority
- the authority whose row should be selectedpublic boolean isSyncPending(Account account, int userId, String authority)
public ArrayList<SyncStorageEngine.SyncHistoryItem> getSyncHistory()
public SyncStorageEngine.DayStats[] getDayStatistics()
public SyncStatusInfo getOrCreateSyncStatus(SyncStorageEngine.AuthorityInfo authority)
public void writeAllState()
public void clearAndReadState()