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

Commit dbd9904c authored by Reema Bajwa's avatar Reema Bajwa
Browse files

Calling isServiceEnabled with the context in credential manager settings

Test: Built and deployed locally

Change-Id: I22d3fe863fa31c2601cedbde10907c79469a75f4
parent 5ba7d67b
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.pm.UserInfo;
import android.credentials.CredentialManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.SearchIndexableResource;

import com.android.settings.R;
import com.android.settings.applications.autofill.PasswordsPreferenceController;
@@ -46,7 +47,6 @@ import java.util.List;

@SearchIndexable
public class AccountDashboardFragment extends DashboardFragment {

    private static final String TAG = "AccountDashboardFrag";

    @Override
@@ -61,7 +61,7 @@ public class AccountDashboardFragment extends DashboardFragment {

    @Override
    protected int getPreferenceScreenResId() {
        return getPreferenceLayoutResId();
        return getPreferenceLayoutResId(this.getContext());
    }

    @Override
@@ -72,7 +72,7 @@ public class AccountDashboardFragment extends DashboardFragment {
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (CredentialManager.isServiceEnabled()) {
        if (CredentialManager.isServiceEnabled(context)) {
            CredentialManagerPreferenceController cmpp =
                    use(CredentialManagerPreferenceController.class);
            cmpp.setParentFragment(this);
@@ -118,14 +118,21 @@ public class AccountDashboardFragment extends DashboardFragment {
        controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
    }

    public static int getPreferenceLayoutResId() {
        return CredentialManager.isServiceEnabled()
    private static int getPreferenceLayoutResId(Context context) {
        return (context != null && CredentialManager.isServiceEnabled(context))
                ? R.xml.accounts_dashboard_settings_credman
                : R.xml.accounts_dashboard_settings;
    }

    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider(getPreferenceLayoutResId()) {
            new BaseSearchIndexProvider() {
                @Override
                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
                        boolean enabled) {
                    final SearchIndexableResource sir = new SearchIndexableResource(context);
                    sir.xmlResId = getPreferenceLayoutResId(context);
                    return List.of(sir);
                }

                @Override
                public List<AbstractPreferenceController> createPreferenceControllers(
+2 −4
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import java.util.List;

/** Account Setting page for personal profile. */
public class AccountPersonalDashboardFragment extends DashboardFragment {

    private static final String TAG = "AccountPersonalFrag";

    @Override
@@ -53,7 +52,7 @@ public class AccountPersonalDashboardFragment extends DashboardFragment {

    @Override
    protected int getPreferenceScreenResId() {
        if (CredentialManager.isServiceEnabled()) {
        if (this.getContext() != null && CredentialManager.isServiceEnabled(this.getContext())) {
            return R.xml.accounts_personal_dashboard_settings_credman;
        }
        return R.xml.accounts_personal_dashboard_settings;
@@ -67,8 +66,7 @@ public class AccountPersonalDashboardFragment extends DashboardFragment {
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        if (CredentialManager.isServiceEnabled()) {
        if (CredentialManager.isServiceEnabled(context)) {
            CredentialManagerPreferenceController cmpp =
                    use(CredentialManagerPreferenceController.class);
            cmpp.setParentFragment(this);
+2 −4
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import java.util.List;

/** Account Setting page for work profile. */
public class AccountWorkProfileDashboardFragment extends DashboardFragment {

    private static final String TAG = "AccountWorkProfileFrag";

    @Override
@@ -53,7 +52,7 @@ public class AccountWorkProfileDashboardFragment extends DashboardFragment {

    @Override
    protected int getPreferenceScreenResId() {
        if (CredentialManager.isServiceEnabled()) {
        if (this.getContext() != null && CredentialManager.isServiceEnabled(this.getContext())) {
            return R.xml.accounts_work_dashboard_settings_credman;
        }
        return R.xml.accounts_work_dashboard_settings;
@@ -67,8 +66,7 @@ public class AccountWorkProfileDashboardFragment extends DashboardFragment {
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        if (CredentialManager.isServiceEnabled()) {
        if (CredentialManager.isServiceEnabled(context)) {
            CredentialManagerPreferenceController cmpp =
                    use(CredentialManagerPreferenceController.class);
            cmpp.setParentFragment(this);
+2 −1
Original line number Diff line number Diff line
@@ -96,7 +96,8 @@ public class CredentialManagerPreferenceController extends BasePreferenceControl
        }

        Object service = context.getSystemService(Context.CREDENTIAL_SERVICE);
        if (service != null && CredentialManager.isServiceEnabled()) {

        if (service != null && CredentialManager.isServiceEnabled(context)) {
            return (CredentialManager) service;
        }