Commit 88be3883 authored by Alice Wang's avatar Alice Wang Committed by Chromium LUCI CQ

[Android][ChildAccount] Remove SignOutAllowed pref usage for child account

Remove the usage of setSignOutAllowedPreferenceValue when there is
child account on device as child account is already handled with
Profile.isChild() in AccountManagementFragment. Setting this pref here
doesn't have any impact on code when there is child account.

Bug: 1162231
Change-Id: I36fc4a30fbbd3ea05b260e2f2e714aa731f737bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617819Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842510}
parent f69438d4
......@@ -13,7 +13,6 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.services.IdentityServicesProvider;
import org.chromium.chrome.browser.signin.services.SigninManager;
import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.chrome.browser.sync.settings.AccountManagementFragment;
import org.chromium.components.externalauth.ExternalAuthUtils;
import org.chromium.components.externalauth.UserRecoverableErrorHandler;
import org.chromium.components.signin.AccountManagerFacadeProvider;
......@@ -47,9 +46,7 @@ public final class ForcedSigninProcessor {
*/
public static void start() {
ChildAccountService.checkChildAccountStatus(status -> {
boolean hasChildAccount = ChildAccountStatus.isChild(status);
AccountManagementFragment.setSignOutAllowedPreferenceValue(!hasChildAccount);
if (hasChildAccount) {
if (ChildAccountStatus.isChild(status)) {
// Account cache is already available when child account status is ready.
final List<Account> accounts =
AccountManagerFacadeProvider.getInstance().tryGetGoogleAccounts();
......
......@@ -24,9 +24,7 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.profiles.ProfileAccountManagementMetrics;
import org.chromium.chrome.browser.settings.ChromeManagedPreferenceDelegate;
......@@ -205,11 +203,10 @@ public class AccountManagementFragment extends PreferenceFragmentCompat
signOutPreference.setIcon(R.drawable.ic_signout_40dp);
}
signOutPreference.setTitle(getSignOutPreferenceText());
signOutPreference.setEnabled(getSignOutAllowedPreferenceValue());
signOutPreference.setOnPreferenceClickListener(preference -> {
if (!isVisible() || !isResumed()) return false;
if (mSignedInAccountName != null && getSignOutAllowedPreferenceValue()) {
if (mSignedInAccountName != null) {
SigninMetricsUtils.logProfileAccountManagementMenu(
ProfileAccountManagementMetrics.TOGGLE_SIGNOUT, mGaiaServiceType);
......@@ -462,22 +459,4 @@ public class AccountManagementFragment extends PreferenceFragmentCompat
settingsLauncher.launchSettingsActivity(
ContextUtils.getApplicationContext(), AccountManagementFragment.class, arguments);
}
/**
* @return Whether the sign out is not disabled due to a child/EDU account.
*/
private static boolean getSignOutAllowedPreferenceValue() {
return SharedPreferencesManager.getInstance().readBoolean(
ChromePreferenceKeys.SETTINGS_SYNC_SIGN_OUT_ALLOWED, true);
}
/**
* Sets the sign out allowed preference value.
*
* @param isAllowed True if the sign out is not disabled due to a child/EDU account
*/
public static void setSignOutAllowedPreferenceValue(boolean isAllowed) {
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.SETTINGS_SYNC_SIGN_OUT_ALLOWED, isAllowed);
}
}
......@@ -614,13 +614,6 @@ public final class ChromePreferenceKeys {
public static final String SETTINGS_DEVELOPER_TRACING_CATEGORIES = "tracing_categories";
public static final String SETTINGS_DEVELOPER_TRACING_MODE = "tracing_mode";
/**
* SharedPreference name for the preference that disables signing out of Chrome.
* Signing out is forever disabled once Chrome signs the user in automatically
* if the device has a child account or if the device is an Android EDU device.
*/
public static final String SETTINGS_SYNC_SIGN_OUT_ALLOWED = "auto_signed_in_school_account";
public static final String SETTINGS_PRIVACY_OTHER_FORMS_OF_HISTORY_DIALOG_SHOWN =
"org.chromium.chrome.browser.settings.privacy."
+ "PREF_OTHER_FORMS_OF_HISTORY_DIALOG_SHOWN";
......
......@@ -146,7 +146,6 @@ public class GrandfatheredChromePreferenceKeys {
ChromePreferenceKeys.SETTINGS_DEVELOPER_TRACING_CATEGORIES,
ChromePreferenceKeys.SETTINGS_DEVELOPER_TRACING_MODE,
ChromePreferenceKeys.SETTINGS_PRIVACY_OTHER_FORMS_OF_HISTORY_DIALOG_SHOWN,
ChromePreferenceKeys.SETTINGS_SYNC_SIGN_OUT_ALLOWED,
ChromePreferenceKeys.SETTINGS_WEBSITE_FAILED_BUILD_VERSION,
ChromePreferenceKeys.SHARING_LAST_SHARED_CLASS_NAME,
ChromePreferenceKeys.SHARING_LAST_SHARED_PACKAGE_NAME,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment