Remove context from applicationFeatureProvider
ApplicationFeatureProvider is created by using application context, no need pass context in when get. Bug: 286764889 Test: m Settings Change-Id: I7f8dfe5716b7b55e0ff984f7603875d7896e2313
This commit is contained in:
@@ -90,8 +90,8 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mFinishing = false;
|
mFinishing = false;
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
mApplicationFeatureProvider = FeatureFactory.getFactory(activity)
|
mApplicationFeatureProvider = FeatureFactory.getFeatureFactory()
|
||||||
.getApplicationFeatureProvider(activity);
|
.getApplicationFeatureProvider();
|
||||||
mState = ApplicationsState.getInstance(activity.getApplication());
|
mState = ApplicationsState.getInstance(activity.getApplication());
|
||||||
mSession = mState.newSession(this, getSettingsLifecycle());
|
mSession = mState.newSession(this, getSettingsLifecycle());
|
||||||
mDpm = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
mDpm = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
|
@@ -138,9 +138,9 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
|
|||||||
"Fragment should implement AppButtonsDialogListener");
|
"Fragment should implement AppButtonsDialogListener");
|
||||||
}
|
}
|
||||||
|
|
||||||
final FeatureFactory factory = FeatureFactory.getFactory(activity);
|
final FeatureFactory factory = FeatureFactory.getFeatureFactory();
|
||||||
mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
|
mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
|
||||||
mApplicationFeatureProvider = factory.getApplicationFeatureProvider(activity);
|
mApplicationFeatureProvider = factory.getApplicationFeatureProvider();
|
||||||
mState = state;
|
mState = state;
|
||||||
mDpm = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
mDpm = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
|
mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
|
||||||
|
@@ -40,8 +40,8 @@ public class LongBackgroundTasksDetailsPreferenceController extends
|
|||||||
|
|
||||||
public LongBackgroundTasksDetailsPreferenceController(Context context, String key) {
|
public LongBackgroundTasksDetailsPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mAppFeatureProvider = FeatureFactory.getFactory(context)
|
mAppFeatureProvider = FeatureFactory.getFeatureFactory()
|
||||||
.getApplicationFeatureProvider(context);
|
.getApplicationFeatureProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@@ -53,8 +53,8 @@ public class TimeSpentInAppPreferenceController extends LiveDataController {
|
|||||||
public TimeSpentInAppPreferenceController(Context context, String preferenceKey) {
|
public TimeSpentInAppPreferenceController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mPackageManager = context.getPackageManager();
|
mPackageManager = context.getPackageManager();
|
||||||
mAppFeatureProvider = FeatureFactory.getFactory(context)
|
mAppFeatureProvider = FeatureFactory.getFeatureFactory()
|
||||||
.getApplicationFeatureProvider(context);
|
.getApplicationFeatureProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPackageName(String packageName) {
|
public void setPackageName(String packageName) {
|
||||||
|
@@ -30,8 +30,8 @@ public class LongBackgroundTaskController extends BasePreferenceController {
|
|||||||
|
|
||||||
public LongBackgroundTaskController(Context context, String preferenceKey) {
|
public LongBackgroundTaskController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mAppFeatureProvider = FeatureFactory.getFactory(context)
|
mAppFeatureProvider = FeatureFactory.getFeatureFactory()
|
||||||
.getApplicationFeatureProvider(context);
|
.getApplicationFeatureProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -38,8 +38,8 @@ public abstract class AdminGrantedPermissionsPreferenceControllerBase
|
|||||||
String[] permissions) {
|
String[] permissions) {
|
||||||
super(context);
|
super(context);
|
||||||
mPermissions = permissions;
|
mPermissions = permissions;
|
||||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
mFeatureProvider = FeatureFactory.getFeatureFactory()
|
||||||
.getApplicationFeatureProvider(context);
|
.getApplicationFeatureProvider();
|
||||||
mAsync = async;
|
mAsync = async;
|
||||||
mHasApps = false;
|
mHasApps = false;
|
||||||
}
|
}
|
||||||
|
@@ -79,7 +79,7 @@ public abstract class ApplicationListFragment extends DashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void buildApplicationList(Context context,
|
public void buildApplicationList(Context context,
|
||||||
ApplicationFeatureProvider.ListOfAppsCallback callback) {
|
ApplicationFeatureProvider.ListOfAppsCallback callback) {
|
||||||
FeatureFactory.getFactory(context).getApplicationFeatureProvider(context)
|
FeatureFactory.getFeatureFactory().getApplicationFeatureProvider()
|
||||||
.listAppsWithAdminGrantedPermissions(mPermissions, callback);
|
.listAppsWithAdminGrantedPermissions(mPermissions, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,8 +120,8 @@ public abstract class ApplicationListFragment extends DashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void buildApplicationList(Context context,
|
public void buildApplicationList(Context context,
|
||||||
ApplicationFeatureProvider.ListOfAppsCallback callback) {
|
ApplicationFeatureProvider.ListOfAppsCallback callback) {
|
||||||
FeatureFactory.getFactory(context).getApplicationFeatureProvider(context).
|
FeatureFactory.getFeatureFactory()
|
||||||
listPolicyInstalledApps(callback);
|
.getApplicationFeatureProvider().listPolicyInstalledApps(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,8 +34,8 @@ public class EnterpriseInstalledPackagesPreferenceController
|
|||||||
|
|
||||||
public EnterpriseInstalledPackagesPreferenceController(Context context, boolean async) {
|
public EnterpriseInstalledPackagesPreferenceController(Context context, boolean async) {
|
||||||
super(context);
|
super(context);
|
||||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
mFeatureProvider = FeatureFactory.getFeatureFactory()
|
||||||
.getApplicationFeatureProvider(context);
|
.getApplicationFeatureProvider();
|
||||||
mAsync = async;
|
mAsync = async;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,8 +69,8 @@ public class EnterpriseSetDefaultAppsListPreferenceController extends
|
|||||||
super(context);
|
super(context);
|
||||||
mPm = packageManager;
|
mPm = packageManager;
|
||||||
mParent = parent;
|
mParent = parent;
|
||||||
final FeatureFactory factory = FeatureFactory.getFactory(context);
|
final FeatureFactory factory = FeatureFactory.getFeatureFactory();
|
||||||
mApplicationFeatureProvider = factory.getApplicationFeatureProvider(context);
|
mApplicationFeatureProvider = factory.getApplicationFeatureProvider();
|
||||||
mEnterprisePrivacyFeatureProvider = factory.getEnterprisePrivacyFeatureProvider(context);
|
mEnterprisePrivacyFeatureProvider = factory.getEnterprisePrivacyFeatureProvider(context);
|
||||||
mUserFeatureProvider = factory.getUserFeatureProvider(context);
|
mUserFeatureProvider = factory.getUserFeatureProvider(context);
|
||||||
buildAppList();
|
buildAppList();
|
||||||
|
@@ -37,8 +37,8 @@ public class EnterpriseSetDefaultAppsPreferenceController
|
|||||||
|
|
||||||
public EnterpriseSetDefaultAppsPreferenceController(Context context) {
|
public EnterpriseSetDefaultAppsPreferenceController(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
final FeatureFactory factory = FeatureFactory.getFactory(context);
|
final FeatureFactory factory = FeatureFactory.getFeatureFactory();
|
||||||
mApplicationFeatureProvider = factory.getApplicationFeatureProvider(context);
|
mApplicationFeatureProvider = factory.getApplicationFeatureProvider();
|
||||||
mUserFeatureProvider = factory.getUserFeatureProvider(context);
|
mUserFeatureProvider = factory.getUserFeatureProvider(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ abstract class FeatureFactory {
|
|||||||
|
|
||||||
abstract fun getDashboardFeatureProvider(context: Context): DashboardFeatureProvider
|
abstract fun getDashboardFeatureProvider(context: Context): DashboardFeatureProvider
|
||||||
abstract val dockUpdaterFeatureProvider: DockUpdaterFeatureProvider
|
abstract val dockUpdaterFeatureProvider: DockUpdaterFeatureProvider
|
||||||
abstract fun getApplicationFeatureProvider(context: Context): ApplicationFeatureProvider
|
abstract val applicationFeatureProvider: ApplicationFeatureProvider
|
||||||
abstract val localeFeatureProvider: LocaleFeatureProvider
|
abstract val localeFeatureProvider: LocaleFeatureProvider
|
||||||
|
|
||||||
abstract fun getEnterprisePrivacyFeatureProvider(
|
abstract fun getEnterprisePrivacyFeatureProvider(
|
||||||
|
@@ -66,15 +66,6 @@ import com.android.settingslib.spaprivileged.framework.common.devicePolicyManage
|
|||||||
* [FeatureFactory] implementation for AOSP Settings.
|
* [FeatureFactory] implementation for AOSP Settings.
|
||||||
*/
|
*/
|
||||||
open class FeatureFactoryImpl : FeatureFactory() {
|
open class FeatureFactoryImpl : FeatureFactory() {
|
||||||
private val applicationFeatureProvider by lazy {
|
|
||||||
ApplicationFeatureProviderImpl(
|
|
||||||
appContext,
|
|
||||||
appContext.packageManager,
|
|
||||||
AppGlobals.getPackageManager(),
|
|
||||||
appContext.devicePolicyManager,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val dashboardFeatureProvider by lazy { DashboardFeatureProviderImpl(appContext) }
|
private val dashboardFeatureProvider by lazy { DashboardFeatureProviderImpl(appContext) }
|
||||||
|
|
||||||
private val enterprisePrivacyFeatureProvider by lazy {
|
private val enterprisePrivacyFeatureProvider by lazy {
|
||||||
@@ -120,7 +111,14 @@ open class FeatureFactoryImpl : FeatureFactory() {
|
|||||||
DockUpdaterFeatureProviderImpl()
|
DockUpdaterFeatureProviderImpl()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getApplicationFeatureProvider(context: Context) = applicationFeatureProvider
|
override val applicationFeatureProvider by lazy {
|
||||||
|
ApplicationFeatureProviderImpl(
|
||||||
|
appContext,
|
||||||
|
appContext.packageManager,
|
||||||
|
AppGlobals.getPackageManager(),
|
||||||
|
appContext.devicePolicyManager,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
override val localeFeatureProvider by lazy { LocaleFeatureProviderImpl() }
|
override val localeFeatureProvider by lazy { LocaleFeatureProviderImpl() }
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ class AppDisableButton(
|
|||||||
private val packageManager = context.packageManager
|
private val packageManager = context.packageManager
|
||||||
private val userManager = context.userManager
|
private val userManager = context.userManager
|
||||||
private val devicePolicyManager = context.devicePolicyManager
|
private val devicePolicyManager = context.devicePolicyManager
|
||||||
private val applicationFeatureProvider = featureFactory.getApplicationFeatureProvider(context)
|
private val applicationFeatureProvider = featureFactory.applicationFeatureProvider
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun getActionButton(app: ApplicationInfo): ActionButton? {
|
fun getActionButton(app: ApplicationInfo): ActionButton? {
|
||||||
|
@@ -60,7 +60,7 @@ private class AppTimeSpentPresenter(
|
|||||||
private val intent = Intent(Settings.ACTION_APP_USAGE_SETTINGS).apply {
|
private val intent = Intent(Settings.ACTION_APP_USAGE_SETTINGS).apply {
|
||||||
putExtra(Intent.EXTRA_PACKAGE_NAME, app.packageName)
|
putExtra(Intent.EXTRA_PACKAGE_NAME, app.packageName)
|
||||||
}
|
}
|
||||||
private val appFeatureProvider = featureFactory.getApplicationFeatureProvider(context)
|
private val appFeatureProvider = featureFactory.applicationFeatureProvider
|
||||||
|
|
||||||
fun isAvailable() = context.packageManager.queryIntentActivitiesAsUser(
|
fun isAvailable() = context.packageManager.queryIntentActivitiesAsUser(
|
||||||
intent, ResolveInfoFlags.of(0), app.userId
|
intent, ResolveInfoFlags.of(0), app.userId
|
||||||
|
@@ -53,6 +53,8 @@ import com.android.settings.wifi.WifiTrackerLibProvider;
|
|||||||
import com.android.settings.wifi.factory.WifiFeatureProvider;
|
import com.android.settings.wifi.factory.WifiFeatureProvider;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test util to provide fake FeatureFactory. To use this factory, call {@code setupForTest} in
|
* Test util to provide fake FeatureFactory. To use this factory, call {@code setupForTest} in
|
||||||
* {@code @Before} method of the test class.
|
* {@code @Before} method of the test class.
|
||||||
@@ -177,8 +179,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
return dockUpdaterFeatureProvider;
|
return dockUpdaterFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ApplicationFeatureProvider getApplicationFeatureProvider(Context context) {
|
public ApplicationFeatureProvider getApplicationFeatureProvider() {
|
||||||
return applicationFeatureProvider;
|
return applicationFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -93,7 +93,7 @@ class FakeFeatureFactory : FeatureFactory() {
|
|||||||
override val dockUpdaterFeatureProvider: DockUpdaterFeatureProvider
|
override val dockUpdaterFeatureProvider: DockUpdaterFeatureProvider
|
||||||
get() = TODO("Not yet implemented")
|
get() = TODO("Not yet implemented")
|
||||||
|
|
||||||
override fun getApplicationFeatureProvider(context: Context) = mockApplicationFeatureProvider
|
override val applicationFeatureProvider = mockApplicationFeatureProvider
|
||||||
|
|
||||||
override val localeFeatureProvider: LocaleFeatureProvider
|
override val localeFeatureProvider: LocaleFeatureProvider
|
||||||
get() = TODO("Not yet implemented")
|
get() = TODO("Not yet implemented")
|
||||||
|
@@ -53,6 +53,8 @@ import com.android.settings.wifi.WifiTrackerLibProvider;
|
|||||||
import com.android.settings.wifi.factory.WifiFeatureProvider;
|
import com.android.settings.wifi.factory.WifiFeatureProvider;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test util to provide fake FeatureFactory. To use this factory, call {@code setupForTest} in
|
* Test util to provide fake FeatureFactory. To use this factory, call {@code setupForTest} in
|
||||||
* {@code @Before} method of the test class.
|
* {@code @Before} method of the test class.
|
||||||
@@ -176,8 +178,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
return dockUpdaterFeatureProvider;
|
return dockUpdaterFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ApplicationFeatureProvider getApplicationFeatureProvider(Context context) {
|
public ApplicationFeatureProvider getApplicationFeatureProvider() {
|
||||||
return applicationFeatureProvider;
|
return applicationFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user