Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb277317 authored by Jatin Matani's avatar Jatin Matani
Browse files

Check for accounts when enabling sync features.

Bug:19895917
Change-Id: I2f2f535f5a5c17c5642a5c44d2fd20a520ccfd73
parent 13271bfd
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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;
        }