Skip to content

Commit 38796fe

Browse files
Amith YamasaniAndroid (Google) Code Review
authored andcommitted
Merge "Fix sync problems when setting up a new user and account" into jb-mr1-dev
2 parents eed8f06 + d648a60 commit 38796fe

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

core/java/android/content/SyncManager.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ public void onReceive(Context context, Intent intent) {
203203
}
204204
};
205205

206+
private BroadcastReceiver mAccountsUpdatedReceiver = new BroadcastReceiver() {
207+
public void onReceive(Context context, Intent intent) {
208+
onAccountsUpdated(null);
209+
}
210+
};
211+
206212
private final PowerManager mPowerManager;
207213

208214
// Use this as a random offset to seed all periodic syncs
@@ -456,8 +462,11 @@ public void onStatusChanged(int which) {
456462
});
457463

458464
if (!factoryTest) {
459-
AccountManager.get(mContext).addOnAccountsUpdatedListener(SyncManager.this,
460-
mSyncHandler, false /* updateImmediately */);
465+
// Register for account list updates for all users
466+
mContext.registerReceiverAsUser(mAccountsUpdatedReceiver,
467+
UserHandle.ALL,
468+
new IntentFilter(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION),
469+
null, null);
461470
// do this synchronously to ensure we have the accounts before this call returns
462471
onAccountsUpdated(null);
463472
}

0 commit comments

Comments
 (0)