Make sync not start until setup wizard is done.

This commit is contained in:
Joe Onorato
2009-07-15 16:08:44 -07:00
parent f3ea3e0968
commit 8294fadb15
2 changed files with 17 additions and 8 deletions

View File

@@ -1588,7 +1588,7 @@ class SyncManager implements OnAccountsUpdatedListener {
ContentResolver.SYNC_EXTRAS_MANUAL, false);
final boolean syncAutomatically =
mSyncStorageEngine.getSyncAutomatically(op.account, op.authority)
|| mSyncStorageEngine.getMasterSyncAutomatically();
&& mSyncStorageEngine.getMasterSyncAutomatically();
boolean syncAllowed =
manualSync || (backgroundDataUsageAllowed && syncAutomatically);
if (!syncAllowed) {

View File

@@ -110,6 +110,8 @@ public class SyncStorageEngine extends Handler {
private static final int MSG_WRITE_STATISTICS = 2;
private static final long WRITE_STATISTICS_DELAY = 1000*60*30; // 1/2 hour
private static final boolean SYNC_ENABLED_DEFAULT = false;
public static class PendingOperation {
final Account account;
@@ -158,7 +160,7 @@ public class SyncStorageEngine extends Handler {
this.account = account;
this.authority = authority;
this.ident = ident;
enabled = true;
enabled = SYNC_ENABLED_DEFAULT;
}
}
@@ -376,23 +378,30 @@ public class SyncStorageEngine extends Handler {
}
public void setSyncAutomatically(Account account, String providerName, boolean sync) {
boolean wasEnabled;
synchronized (mAuthorities) {
AuthorityInfo authority = getAuthorityLocked(account, providerName,
"setSyncAutomatically");
if (authority != null) {
authority.enabled = sync;
}
AuthorityInfo authority = getOrCreateAuthorityLocked(account, providerName, -1, false);
wasEnabled = authority.enabled;
authority.enabled = sync;
writeAccountInfoLocked();
}
if (!wasEnabled && sync) {
mContext.getContentResolver().requestSync(account, providerName, new Bundle());
}
reportChange(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS);
}
public void setMasterSyncAutomatically(boolean flag) {
boolean old;
synchronized (mAuthorities) {
old = mMasterSyncAutomatically;
mMasterSyncAutomatically = flag;
writeAccountInfoLocked();
}
if (!old && flag) {
mContext.getContentResolver().requestSync(null, null, new Bundle());
}
reportChange(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS);
mContext.sendBroadcast(SYNC_CONNECTION_SETTING_CHANGED_INTENT);
}