SearchFeatureProvider was holding on to a context and outlived the SettingsActivity, thus leaking the activity. The context was passed into most methods, and thus it makes more sense to pass it in to every method. Bug: 33677967 Test: Run MakeSettingsRoboTests Change-Id: Ia82f30e7e0b83587b4baeef28e81da6b8e4303fe
119 lines
4.6 KiB
Java
119 lines
4.6 KiB
Java
/*
|
|
* Copyright (C) 2016 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.android.settings.overlay;
|
|
|
|
import android.app.admin.DevicePolicyManager;
|
|
import android.content.Context;
|
|
import android.support.annotation.Keep;
|
|
|
|
import com.android.settings.applications.ApplicationFeatureProvider;
|
|
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
|
import com.android.settings.applications.PackageManagerWrapperImpl;
|
|
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
|
import com.android.settings.core.instrumentation.MetricsFeatureProviderImpl;
|
|
import com.android.settings.dashboard.DashboardFeatureProvider;
|
|
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
|
|
import com.android.settings.enterprise.DevicePolicyManagerWrapperImpl;
|
|
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
|
|
import com.android.settings.enterprise.EnterprisePrivacyFeatureProviderImpl;
|
|
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
|
|
import com.android.settings.localepicker.LocaleFeatureProvider;
|
|
import com.android.settings.localepicker.LocaleFeatureProviderImpl;
|
|
import com.android.settings.search2.SearchFeatureProvider;
|
|
import com.android.settings.search2.SearchFeatureProviderImpl;
|
|
|
|
/**
|
|
* {@link FeatureFactory} implementation for AOSP Settings.
|
|
*/
|
|
@Keep
|
|
public class FeatureFactoryImpl extends FeatureFactory {
|
|
|
|
private ApplicationFeatureProvider mApplicationFeatureProvider;
|
|
private MetricsFeatureProvider mMetricsFeatureProvider;
|
|
private DashboardFeatureProviderImpl mDashboardFeatureProvider;
|
|
private LocaleFeatureProvider mLocaleFeatureProvider;
|
|
private EnterprisePrivacyFeatureProvider mEnterprisePrivacyFeatureProvider;
|
|
private SearchFeatureProvider mSearchFeatureProvider;
|
|
|
|
@Override
|
|
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public MetricsFeatureProvider getMetricsFeatureProvider() {
|
|
if (mMetricsFeatureProvider == null) {
|
|
mMetricsFeatureProvider = new MetricsFeatureProviderImpl();
|
|
}
|
|
return mMetricsFeatureProvider;
|
|
}
|
|
|
|
@Override
|
|
public PowerUsageFeatureProvider getPowerUsageFeatureProvider(Context context) {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public DashboardFeatureProvider getDashboardFeatureProvider(Context context) {
|
|
if (mDashboardFeatureProvider == null) {
|
|
mDashboardFeatureProvider = new DashboardFeatureProviderImpl(context);
|
|
}
|
|
return mDashboardFeatureProvider;
|
|
}
|
|
|
|
@Override
|
|
public ApplicationFeatureProvider getApplicationFeatureProvider(Context context) {
|
|
if (mApplicationFeatureProvider == null) {
|
|
mApplicationFeatureProvider = new ApplicationFeatureProviderImpl(context,
|
|
new PackageManagerWrapperImpl(context.getPackageManager()));
|
|
}
|
|
return mApplicationFeatureProvider;
|
|
}
|
|
|
|
@Override
|
|
public LocaleFeatureProvider getLocaleFeatureProvider() {
|
|
if (mLocaleFeatureProvider == null) {
|
|
mLocaleFeatureProvider = new LocaleFeatureProviderImpl();
|
|
}
|
|
return mLocaleFeatureProvider;
|
|
}
|
|
|
|
@Override
|
|
public EnterprisePrivacyFeatureProvider getEnterprisePrivacyFeatureProvider(Context context) {
|
|
if (mEnterprisePrivacyFeatureProvider == null) {
|
|
mEnterprisePrivacyFeatureProvider = new EnterprisePrivacyFeatureProviderImpl(
|
|
new DevicePolicyManagerWrapperImpl((DevicePolicyManager) context
|
|
.getSystemService(Context.DEVICE_POLICY_SERVICE)),
|
|
new PackageManagerWrapperImpl(context.getPackageManager()));
|
|
}
|
|
return mEnterprisePrivacyFeatureProvider;
|
|
}
|
|
|
|
@Override
|
|
public SearchFeatureProvider getSearchFeatureProvider() {
|
|
if (mSearchFeatureProvider == null) {
|
|
mSearchFeatureProvider = new SearchFeatureProviderImpl();
|
|
}
|
|
return mSearchFeatureProvider;
|
|
}
|
|
|
|
@Override
|
|
public SurveyFeatureProvider getSurveyFeatureProvider(Context context) {
|
|
return null;
|
|
}
|
|
}
|