Check for accounts when enabling sync features.
Bug:19895917 Change-Id: I2f2f535f5a5c17c5642a5c44d2fd20a520ccfd73main
parent
13271bfde8
commit
bb2773176f
|
@ -118,11 +118,17 @@ public final class AccountsSettingsFragment extends SubScreenFragment {
|
|||
if (!ProductionFlags.ENABLE_USER_HISTORY_DICTIONARY_SYNC) {
|
||||
removeSyncPreferences();
|
||||
} else {
|
||||
// Temporarily disable the preferences till we can
|
||||
// check that we don't have a work profile.
|
||||
disableSyncPreferences();
|
||||
new ManagedProfileCheckerTask(this).execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Task to check work profile. If found, it removes the sync prefs. If not,
|
||||
* it enables them.
|
||||
*/
|
||||
private static class ManagedProfileCheckerTask extends AsyncTask<Void, Void, Void> {
|
||||
private final AccountsSettingsFragment mFragment;
|
||||
|
||||
|
@ -132,10 +138,11 @@ public final class AccountsSettingsFragment extends SubScreenFragment {
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
if (ManagedProfileUtils.getInstance().hasManagedWorkProfile(mFragment.getActivity())) {
|
||||
if (ManagedProfileUtils.getInstance().hasWorkProfile(mFragment.getActivity())) {
|
||||
mFragment.removeSyncPreferences();
|
||||
} else {
|
||||
mFragment.enableSyncPreferences();
|
||||
mFragment.refreshAccountAndDependentPreferences(
|
||||
mFragment.getSignedInAccountName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue