Add a mechanism to configure whether the summary should be set or not
Add a mechanism to customize whether the summary information in the battery entry should be set or not. We can consider is as the extension for the ag/18062824. Bug: 220717612 Test: make RunSettingsRoboTests -j56 ROBOTEST_FILTER="com.android.settings.fuelgauge" Change-Id: I3c21148d288f29ce65378f59f9086dab90c14a7b
This commit is contained in:
@@ -1646,4 +1646,8 @@
|
|||||||
<item>1875000</item> <!-- 15Mbps == 1875000/s -->
|
<item>1875000</item> <!-- 15Mbps == 1875000/s -->
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- An allowlist which packages won't show summary in battery usage screen.
|
||||||
|
[CHAR LIMIT=NONE] -->
|
||||||
|
<string-array name="allowlist_hide_summary_in_battery_usage" translatable="false">
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -59,6 +59,7 @@ import com.android.settingslib.utils.StringUtil;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller that update the battery header view
|
* Controller that update the battery header view
|
||||||
@@ -72,7 +73,6 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
|||||||
private static final int MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP = 10;
|
private static final int MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP = 10;
|
||||||
private static final String MEDIASERVER_PACKAGE_NAME = "mediaserver";
|
private static final String MEDIASERVER_PACKAGE_NAME = "mediaserver";
|
||||||
|
|
||||||
private final String mPreferenceKey;
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
PreferenceGroup mAppListGroup;
|
PreferenceGroup mAppListGroup;
|
||||||
private BatteryUsageStats mBatteryUsageStats;
|
private BatteryUsageStats mBatteryUsageStats;
|
||||||
@@ -83,6 +83,9 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
|||||||
private final PackageManager mPackageManager;
|
private final PackageManager mPackageManager;
|
||||||
private final SettingsActivity mActivity;
|
private final SettingsActivity mActivity;
|
||||||
private final InstrumentedPreferenceFragment mFragment;
|
private final InstrumentedPreferenceFragment mFragment;
|
||||||
|
private final Set<CharSequence> mNotAllowShowSummaryPackages;
|
||||||
|
private final String mPreferenceKey;
|
||||||
|
|
||||||
private Context mPrefContext;
|
private Context mPrefContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,6 +162,10 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
|||||||
mPackageManager = context.getPackageManager();
|
mPackageManager = context.getPackageManager();
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mFragment = fragment;
|
mFragment = fragment;
|
||||||
|
mNotAllowShowSummaryPackages = Set.of(
|
||||||
|
FeatureFactory.getFactory(context)
|
||||||
|
.getPowerUsageFeatureProvider(context)
|
||||||
|
.getHideApplicationSummary(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -427,6 +434,12 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
|||||||
if (entry.getUid() == Process.SYSTEM_UID) {
|
if (entry.getUid() == Process.SYSTEM_UID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String packageName = entry.getDefaultPackageName();
|
||||||
|
if (packageName != null
|
||||||
|
&& mNotAllowShowSummaryPackages != null
|
||||||
|
&& mNotAllowShowSummaryPackages.contains(packageName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Only show summary when usage time is longer than one minute
|
// Only show summary when usage time is longer than one minute
|
||||||
final long usageTimeMs = entry.getTimeInForegroundMs();
|
final long usageTimeMs = entry.getTimeInForegroundMs();
|
||||||
if (shouldShowSummary(entry) && usageTimeMs >= DateUtils.MINUTE_IN_MILLIS) {
|
if (shouldShowSummary(entry) && usageTimeMs >= DateUtils.MINUTE_IN_MILLIS) {
|
||||||
|
@@ -25,6 +25,7 @@ import android.util.ArraySet;
|
|||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
|
|
||||||
import com.android.internal.util.ArrayUtils;
|
import com.android.internal.util.ArrayUtils;
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.fuelgauge.Estimate;
|
import com.android.settingslib.fuelgauge.Estimate;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -179,6 +180,7 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence[] getHideApplicationSummary(Context context) {
|
public CharSequence[] getHideApplicationSummary(Context context) {
|
||||||
return new CharSequence[0];
|
return context.getResources().getTextArray(
|
||||||
|
R.array.allowlist_hide_summary_in_battery_usage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user