Move allowed list definition in the battery usage to feature provider
Bug: 199367609 Test: make SettingsRoboTests Change-Id: I321426e6ff1b9586ee493792f1d39aed35ecc34d Signed-off-by: ykhung <ykhung@google.com>
This commit is contained in:
@@ -47,6 +47,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
@@ -440,8 +441,10 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
||||
}
|
||||
|
||||
private boolean shouldShowSummary(BatteryEntry entry) {
|
||||
final CharSequence[] allowlistPackages = mContext.getResources()
|
||||
.getTextArray(R.array.allowlist_hide_summary_in_battery_usage);
|
||||
final CharSequence[] allowlistPackages =
|
||||
FeatureFactory.getFactory(mContext)
|
||||
.getPowerUsageFeatureProvider(mContext)
|
||||
.getHideApplicationSummary(mContext);
|
||||
final String target = entry.getDefaultPackageName();
|
||||
|
||||
for (CharSequence packageName : allowlistPackages) {
|
||||
|
@@ -121,14 +121,16 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
mFragment = fragment;
|
||||
mPreferenceKey = preferenceKey;
|
||||
mIs24HourFormat = DateFormat.is24HourFormat(context);
|
||||
mNotAllowShowSummaryPackages = context.getResources()
|
||||
.getTextArray(R.array.allowlist_hide_summary_in_battery_usage);
|
||||
mMetricsFeatureProvider =
|
||||
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
|
||||
mNotAllowShowEntryPackages =
|
||||
FeatureFactory.getFactory(mContext)
|
||||
FeatureFactory.getFactory(context)
|
||||
.getPowerUsageFeatureProvider(context)
|
||||
.getHideApplicationEntries(mContext);
|
||||
.getHideApplicationEntries(context);
|
||||
mNotAllowShowSummaryPackages =
|
||||
FeatureFactory.getFactory(context)
|
||||
.getPowerUsageFeatureProvider(context)
|
||||
.getHideApplicationSummary(context);
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
|
@@ -163,4 +163,9 @@ public interface PowerUsageFeatureProvider {
|
||||
* Returns package names for hidding application in the usage screen.
|
||||
*/
|
||||
CharSequence[] getHideApplicationEntries(Context context);
|
||||
|
||||
/**
|
||||
* Returns package names for hidding summary in the usage screen.
|
||||
*/
|
||||
CharSequence[] getHideApplicationSummary(Context context);
|
||||
}
|
||||
|
@@ -190,4 +190,9 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
||||
public CharSequence[] getHideApplicationEntries(Context context) {
|
||||
return new CharSequence[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence[] getHideApplicationSummary(Context context) {
|
||||
return new CharSequence[0];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user