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

Commit 88dd3128 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Store the application context statically in FeatureFactory"

parents 85c5d731 b2451418
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.Nullable;

import com.android.settings.R;
import com.android.settings.accounts.AccountFeatureProvider;
import com.android.settings.applications.ApplicationFeatureProvider;
@@ -50,6 +52,7 @@ public abstract class FeatureFactory {
    private static final boolean DEBUG = false;

    protected static FeatureFactory sFactory;
    protected static Context sAppContext;

    /**
     * Returns a factory for creating feature controllers. Creates the factory if it does not
@@ -60,6 +63,9 @@ public abstract class FeatureFactory {
        if (sFactory != null) {
            return sFactory;
        }
        if (sAppContext == null) {
            sAppContext = context.getApplicationContext();
        }

        if (DEBUG) Log.d(LOG_TAG, "getFactory");
        final String clsName = context.getString(R.string.config_featureFactory);
@@ -76,6 +82,16 @@ public abstract class FeatureFactory {
        return sFactory;
    }

    /**
     * Returns an application {@link Context} used to create this {@link FeatureFactory}. If the
     * factory has not been properly created yet (aka {@link #getFactory} has not been called), this
     * will return null.
     */
    @Nullable
    public static Context getAppContext() {
        return sAppContext;
    }

    public abstract AssistGestureFeatureProvider getAssistGestureFeatureProvider();

    public abstract SuggestionFeatureProvider getSuggestionFeatureProvider(Context context);