Commit 8eb8e09f authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Signin][Android] Open all accounts settings page on O+

This CL fixes SigninUtils.openAccountSettingsPage behavior on Android O+
where android.settings.ACCOUNT_SYNC_SETTINGS action no longer works.
Also, openAccountSettingsPage is renamed to openSettingsForAccount and
openSettingsForAllAccounts is introduced, so subsequent CLs can use it
to specifically open settings page with all accounts.

Bug: 814441
Change-Id: I4c5e6469701ae31835426a204b2d4d07b0fb5cd7
Reviewed-on: https://chromium-review.googlesource.com/c/1494662Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636762}
parent 28586cfa
...@@ -366,7 +366,7 @@ public class AccountManagementFragment extends PreferenceFragment ...@@ -366,7 +366,7 @@ public class AccountManagementFragment extends PreferenceFragment
pref.setIcon(mProfileDataCache.getProfileDataOrDefault(account.name).getImage()); pref.setIcon(mProfileDataCache.getProfileDataOrDefault(account.name).getImage());
pref.setOnPreferenceClickListener( pref.setOnPreferenceClickListener(
preference -> SigninUtils.openAccountSettingsPage(getActivity(), account)); preference -> SigninUtils.openSettingsForAccount(getActivity(), account));
accountsCategory.addPreference(pref); accountsCategory.addPreference(pref);
} }
......
...@@ -7,6 +7,8 @@ package org.chromium.chrome.browser.signin; ...@@ -7,6 +7,8 @@ package org.chromium.chrome.browser.signin;
import android.accounts.Account; import android.accounts.Account;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
import org.chromium.chrome.browser.util.IntentUtils; import org.chromium.chrome.browser.util.IntentUtils;
...@@ -20,15 +22,29 @@ public class SigninUtils { ...@@ -20,15 +22,29 @@ public class SigninUtils {
private SigninUtils() {} private SigninUtils() {}
/** /**
* Opens account management page in Settings for a specific account. * Opens a Settings page to configure settings for a single account.
* Note: on Android O+, this method is identical to {@link #openSettingsForAllAccounts}.
* @param context Context to use when starting the Activity. * @param context Context to use when starting the Activity.
* @param account The account for which the Settings page should be opened. * @param account The account for which the Settings page should be opened.
* @return Whether or not Android accepted the Intent. * @return Whether or not Android accepted the Intent.
*/ */
public static boolean openAccountSettingsPage(Context context, Account account) { public static boolean openSettingsForAccount(Context context, Account account) {
// TODO(https://crbug.com/814441): Fix this on Android O+. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// ACCOUNT_SETTINGS_ACTION no longer works on Android O+, always open all accounts page.
return openSettingsForAllAccounts(context);
}
Intent intent = new Intent(ACCOUNT_SETTINGS_ACTION); Intent intent = new Intent(ACCOUNT_SETTINGS_ACTION);
intent.putExtra(ACCOUNT_SETTINGS_ACCOUNT_KEY, account); intent.putExtra(ACCOUNT_SETTINGS_ACCOUNT_KEY, account);
return IntentUtils.safeStartActivity(context, intent); return IntentUtils.safeStartActivity(context, intent);
} }
/**
* Opens a Settings page with all accounts on the device.
* @param context Context to use when starting the Activity.
* @return Whether or not Android accepted the Intent.
*/
private static boolean openSettingsForAllAccounts(Context context) {
Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
return IntentUtils.safeStartActivity(context, intent);
}
} }
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