Adds missing per-user calls for displaying and syncing accounts

Bug: 15466880
Change-Id: Ifa96af782adc8485f925dc45d5c71b1c28a075d2
This commit is contained in:
Alexandra Gherghina
2014-07-01 15:24:45 +01:00
parent 1eb3f316bd
commit 024ba5e4d9
2 changed files with 6 additions and 4 deletions

View File

@@ -284,7 +284,9 @@ public class AccountSyncSettings extends AccountPreferenceBase {
SyncStateCheckBoxPreference syncPref = (SyncStateCheckBoxPreference) preference; SyncStateCheckBoxPreference syncPref = (SyncStateCheckBoxPreference) preference;
String authority = syncPref.getAuthority(); String authority = syncPref.getAuthority();
Account account = syncPref.getAccount(); Account account = syncPref.getAccount();
boolean syncAutomatically = ContentResolver.getSyncAutomatically(account, authority); final int userId = mUserHandle.getIdentifier();
boolean syncAutomatically = ContentResolver.getSyncAutomaticallyAsUser(account,
authority, userId);
if (syncPref.isOneTimeSyncMode()) { if (syncPref.isOneTimeSyncMode()) {
requestOrCancelSync(account, authority, true); requestOrCancelSync(account, authority, true);
} else { } else {
@@ -292,11 +294,11 @@ public class AccountSyncSettings extends AccountPreferenceBase {
boolean oldSyncState = syncAutomatically; boolean oldSyncState = syncAutomatically;
if (syncOn != oldSyncState) { if (syncOn != oldSyncState) {
// if we're enabling sync, this will request a sync as well // if we're enabling sync, this will request a sync as well
ContentResolver.setSyncAutomatically(account, authority, syncOn); ContentResolver.setSyncAutomaticallyAsUser(account, authority, syncOn, userId);
// if the master sync switch is off, the request above will // if the master sync switch is off, the request above will
// get dropped. when the user clicks on this toggle, // get dropped. when the user clicks on this toggle,
// we want to force the sync, however. // we want to force the sync, however.
if (!ContentResolver.getMasterSyncAutomatically() || !syncOn) { if (!ContentResolver.getMasterSyncAutomaticallyAsUser(userId) || !syncOn) {
requestOrCancelSync(account, authority, syncOn); requestOrCancelSync(account, authority, syncOn);
} }
} }

View File

@@ -174,7 +174,7 @@ final public class AuthenticatorHelper extends BroadcastReceiver {
// See http://b/15819268 // See http://b/15819268
updateAuthDescriptions(mContext); updateAuthDescriptions(mContext);
if (accounts == null) { if (accounts == null) {
accounts = AccountManager.get(mContext).getAccounts(); accounts = AccountManager.get(mContext).getAccountsAsUser(mUserHandle.getIdentifier());
} }
mEnabledAccountTypes.clear(); mEnabledAccountTypes.clear();
mAccTypeIconCache.clear(); mAccTypeIconCache.clear();