From bb2773176fc236fa6bc635de58ed48d7ec849b6c Mon Sep 17 00:00:00 2001 From: Jatin Matani Date: Tue, 24 Mar 2015 15:37:11 -0700 Subject: [PATCH] Check for accounts when enabling sync features. Bug:19895917 Change-Id: I2f2f535f5a5c17c5642a5c44d2fd20a520ccfd73 --- .../latin/settings/AccountsSettingsFragment.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java index 48361bf8c..a2ae0ef4e 100644 --- a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java @@ -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 { 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; }