Commit 192d5f8a authored by Alice Wang's avatar Alice Wang Committed by Chromium LUCI CQ

[Signin][Android] Use Activity instead of Context to open Settings

This CL changes Context to Activity as argument to open Settings on
android device.

Bug: 1163470
Change-Id: I5ef9b166f0168140510f163eb83a96805bda2898
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2621633Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842437}
parent d3703d2e
......@@ -524,7 +524,7 @@ public abstract class SigninFragmentBase
// AccountManagerFacade couldn't create intent, use SigninUtils to open settings
// instead.
SigninUtils.openSettingsForAllAccounts(getContext());
SigninUtils.openSettingsForAllAccounts(getActivity());
});
}
......
......@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.signin;
import android.accounts.Account;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
......@@ -47,30 +46,27 @@ public class SigninUtils {
/**
* Opens a Settings page to configure settings for a single account.
* @param context Context to use when starting the Activity.
* @param activity Activity to use when starting the Activity.
* @param account The account for which the Settings page should be opened.
* @return Whether or not Android accepted the Intent.
*/
public static boolean openSettingsForAccount(Context context, Account account) {
public static boolean openSettingsForAccount(Activity activity, Account account) {
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);
return openSettingsForAllAccounts(activity);
}
Intent intent = new Intent(ACCOUNT_SETTINGS_ACTION);
intent.putExtra(ACCOUNT_SETTINGS_ACCOUNT_KEY, account);
if (!(context instanceof Activity)) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return IntentUtils.safeStartActivity(context, intent);
return IntentUtils.safeStartActivity(activity, intent);
}
/**
* Opens a Settings page with all accounts on the device.
* @param context Context to use when starting the Activity.
* @param activity Activity to use when starting the Activity.
* @return Whether or not Android accepted the Intent.
*/
public static boolean openSettingsForAllAccounts(Context context) {
Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
if (!(context instanceof Activity)) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return IntentUtils.safeStartActivity(context, intent);
public static boolean openSettingsForAllAccounts(Activity activity) {
return IntentUtils.safeStartActivity(activity, new Intent(Settings.ACTION_SYNC_SETTINGS));
}
@CalledByNative
......
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