use of android.content.SyncStatusInfo in project platform_frameworks_base by android.
the class SyncStorageEngine method isSyncPending.
/** Return true if the pending status is true of any matching authorities. */
public boolean isSyncPending(EndPoint info) {
synchronized (mAuthorities) {
final int N = mSyncStatus.size();
for (int i = 0; i < N; i++) {
SyncStatusInfo cur = mSyncStatus.valueAt(i);
AuthorityInfo ainfo = mAuthorities.get(cur.authorityId);
if (ainfo == null) {
continue;
}
if (!ainfo.target.matchesSpec(info)) {
continue;
}
if (cur.pending) {
return true;
}
}
return false;
}
}
use of android.content.SyncStatusInfo in project platform_frameworks_base by android.
the class SyncStorageEngine method getOrCreateSyncStatusLocked.
private SyncStatusInfo getOrCreateSyncStatusLocked(int authorityId) {
SyncStatusInfo status = mSyncStatus.get(authorityId);
if (status == null) {
status = new SyncStatusInfo(authorityId);
mSyncStatus.put(authorityId, status);
}
return status;
}
use of android.content.SyncStatusInfo in project platform_frameworks_base by android.
the class SyncStorageEngine method markPending.
public void markPending(EndPoint info, boolean pendingValue) {
synchronized (mAuthorities) {
AuthorityInfo authority = getOrCreateAuthorityLocked(info, -1, /* desired identifier */
true);
if (authority == null) {
return;
}
SyncStatusInfo status = getOrCreateSyncStatusLocked(authority.ident);
status.pending = pendingValue;
}
reportChange(ContentResolver.SYNC_OBSERVER_TYPE_PENDING);
}
use of android.content.SyncStatusInfo in project platform_frameworks_base by android.
the class SyncStorageEngine method getStatusByAuthority.
/**
* Returns the status that matches the target.
*
* @param info the endpoint target we are querying status info for.
* @return the SyncStatusInfo for the endpoint.
*/
public SyncStatusInfo getStatusByAuthority(EndPoint info) {
if (info.account == null || info.provider == null) {
return null;
}
synchronized (mAuthorities) {
final int N = mSyncStatus.size();
for (int i = 0; i < N; i++) {
SyncStatusInfo cur = mSyncStatus.valueAt(i);
AuthorityInfo ainfo = mAuthorities.get(cur.authorityId);
if (ainfo != null && ainfo.target.matchesSpec(info)) {
return cur;
}
}
return null;
}
}
use of android.content.SyncStatusInfo in project android_frameworks_base by DirtyUnicorns.
the class SyncStorageEngine method readAndDeleteLegacyAccountInfoLocked.
/**
* Load sync engine state from the old syncmanager database, and then
* erase it. Note that we don't deal with pending operations, active
* sync, or history.
*/
private void readAndDeleteLegacyAccountInfoLocked() {
// Look for old database to initialize from.
File file = mContext.getDatabasePath("syncmanager.db");
if (!file.exists()) {
return;
}
String path = file.getPath();
SQLiteDatabase db = null;
try {
db = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READONLY);
} catch (SQLiteException e) {
}
if (db != null) {
final boolean hasType = db.getVersion() >= 11;
// Copy in all of the status information, as well as accounts.
if (Log.isLoggable(TAG_FILE, Log.VERBOSE)) {
Slog.v(TAG_FILE, "Reading legacy sync accounts db");
}
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables("stats, status");
HashMap<String, String> map = new HashMap<String, String>();
map.put("_id", "status._id as _id");
map.put("account", "stats.account as account");
if (hasType) {
map.put("account_type", "stats.account_type as account_type");
}
map.put("authority", "stats.authority as authority");
map.put("totalElapsedTime", "totalElapsedTime");
map.put("numSyncs", "numSyncs");
map.put("numSourceLocal", "numSourceLocal");
map.put("numSourcePoll", "numSourcePoll");
map.put("numSourceServer", "numSourceServer");
map.put("numSourceUser", "numSourceUser");
map.put("lastSuccessSource", "lastSuccessSource");
map.put("lastSuccessTime", "lastSuccessTime");
map.put("lastFailureSource", "lastFailureSource");
map.put("lastFailureTime", "lastFailureTime");
map.put("lastFailureMesg", "lastFailureMesg");
map.put("pending", "pending");
qb.setProjectionMap(map);
qb.appendWhere("stats._id = status.stats_id");
Cursor c = qb.query(db, null, null, null, null, null, null);
while (c.moveToNext()) {
String accountName = c.getString(c.getColumnIndex("account"));
String accountType = hasType ? c.getString(c.getColumnIndex("account_type")) : null;
if (accountType == null) {
accountType = "com.google";
}
String authorityName = c.getString(c.getColumnIndex("authority"));
AuthorityInfo authority = this.getOrCreateAuthorityLocked(new EndPoint(new Account(accountName, accountType), authorityName, 0), -1, false);
if (authority != null) {
int i = mSyncStatus.size();
boolean found = false;
SyncStatusInfo st = null;
while (i > 0) {
i--;
st = mSyncStatus.valueAt(i);
if (st.authorityId == authority.ident) {
found = true;
break;
}
}
if (!found) {
st = new SyncStatusInfo(authority.ident);
mSyncStatus.put(authority.ident, st);
}
st.totalElapsedTime = getLongColumn(c, "totalElapsedTime");
st.numSyncs = getIntColumn(c, "numSyncs");
st.numSourceLocal = getIntColumn(c, "numSourceLocal");
st.numSourcePoll = getIntColumn(c, "numSourcePoll");
st.numSourceServer = getIntColumn(c, "numSourceServer");
st.numSourceUser = getIntColumn(c, "numSourceUser");
st.numSourcePeriodic = 0;
st.lastSuccessSource = getIntColumn(c, "lastSuccessSource");
st.lastSuccessTime = getLongColumn(c, "lastSuccessTime");
st.lastFailureSource = getIntColumn(c, "lastFailureSource");
st.lastFailureTime = getLongColumn(c, "lastFailureTime");
st.lastFailureMesg = c.getString(c.getColumnIndex("lastFailureMesg"));
st.pending = getIntColumn(c, "pending") != 0;
}
}
c.close();
// Retrieve the settings.
qb = new SQLiteQueryBuilder();
qb.setTables("settings");
c = qb.query(db, null, null, null, null, null, null);
while (c.moveToNext()) {
String name = c.getString(c.getColumnIndex("name"));
String value = c.getString(c.getColumnIndex("value"));
if (name == null)
continue;
if (name.equals("listen_for_tickles")) {
setMasterSyncAutomatically(value == null || Boolean.parseBoolean(value), 0);
} else if (name.startsWith("sync_provider_")) {
String provider = name.substring("sync_provider_".length(), name.length());
int i = mAuthorities.size();
while (i > 0) {
i--;
AuthorityInfo authority = mAuthorities.valueAt(i);
if (authority.target.provider.equals(provider)) {
authority.enabled = value == null || Boolean.parseBoolean(value);
authority.syncable = 1;
}
}
}
}
c.close();
db.close();
(new File(path)).delete();
}
}
Aggregations