Clean up unused function getHideApplicationSummary in
PowerUsageFeatureProvider. Bug: 253395332 Bug: 254769892 Bug: 254769770 Test: make RunSettingsRoboTests Change-Id: I6acf0cbdb7321934e85939e0acee567001107a17
This commit is contained in:
@@ -131,7 +131,6 @@ public class AppBatteryPreferenceController extends BasePreferenceController
|
||||
mBatteryDiffEntry,
|
||||
Utils.formatPercentage(
|
||||
mBatteryDiffEntry.getPercentOfTotal(), /* round */ true),
|
||||
/*isValidToShowSummary=*/ true,
|
||||
/*slotInformation=*/ null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -133,8 +133,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
/** Launches battery details page for an individual battery consumer. */
|
||||
public static void startBatteryDetailPage(
|
||||
Activity caller, InstrumentedPreferenceFragment fragment,
|
||||
BatteryDiffEntry diffEntry, String usagePercent,
|
||||
boolean isValidToShowSummary, String slotInformation) {
|
||||
BatteryDiffEntry diffEntry, String usagePercent, String slotInformation) {
|
||||
final BatteryHistEntry histEntry = diffEntry.mBatteryHistEntry;
|
||||
final LaunchBatteryDetailPageArgs launchArgs = new LaunchBatteryDetailPageArgs();
|
||||
// configure the launch argument.
|
||||
@@ -145,10 +144,8 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
launchArgs.mUid = (int) histEntry.mUid;
|
||||
launchArgs.mIconId = diffEntry.getAppIconId();
|
||||
launchArgs.mConsumedPower = (int) diffEntry.mConsumePower;
|
||||
launchArgs.mForegroundTimeMs =
|
||||
isValidToShowSummary ? diffEntry.mForegroundUsageTimeInMs : 0;
|
||||
launchArgs.mBackgroundTimeMs =
|
||||
isValidToShowSummary ? diffEntry.mBackgroundUsageTimeInMs : 0;
|
||||
launchArgs.mForegroundTimeMs = diffEntry.mForegroundUsageTimeInMs;
|
||||
launchArgs.mBackgroundTimeMs = diffEntry.mBackgroundUsageTimeInMs;
|
||||
launchArgs.mIsUserEntry = histEntry.isUserEntry();
|
||||
startBatteryDetailPage(caller, fragment, launchArgs);
|
||||
}
|
||||
|
||||
@@ -173,9 +173,4 @@ 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);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.util.ArraySet;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.fuelgauge.batteryusage.BatteryHistEntry;
|
||||
import com.android.settingslib.fuelgauge.Estimate;
|
||||
|
||||
@@ -190,10 +189,4 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
||||
public CharSequence[] getHideApplicationEntries(Context context) {
|
||||
return new CharSequence[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence[] getHideApplicationSummary(Context context) {
|
||||
return context.getResources().getTextArray(
|
||||
R.array.allowlist_hide_summary_in_battery_usage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
|
||||
import com.android.settings.fuelgauge.BatteryUtils;
|
||||
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;
|
||||
@@ -60,7 +59,6 @@ import com.android.settingslib.utils.StringUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Controller that update the battery header view
|
||||
@@ -85,7 +83,6 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
||||
private final PackageManager mPackageManager;
|
||||
private final SettingsActivity mActivity;
|
||||
private final InstrumentedPreferenceFragment mFragment;
|
||||
private final Set<CharSequence> mNotAllowShowSummaryPackages;
|
||||
private final String mPreferenceKey;
|
||||
|
||||
private Context mPrefContext;
|
||||
@@ -164,10 +161,6 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
||||
mPackageManager = context.getPackageManager();
|
||||
mActivity = activity;
|
||||
mFragment = fragment;
|
||||
mNotAllowShowSummaryPackages = Set.of(
|
||||
FeatureFactory.getFactory(context)
|
||||
.getPowerUsageFeatureProvider(context)
|
||||
.getHideApplicationSummary(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -439,15 +432,9 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
||||
if (BatteryEntry.isSystemUid(entry.getUid())) {
|
||||
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
|
||||
final long usageTimeMs = entry.getTimeInForegroundMs();
|
||||
if (shouldShowSummary(entry) && usageTimeMs >= DateUtils.MINUTE_IN_MILLIS) {
|
||||
if (usageTimeMs >= DateUtils.MINUTE_IN_MILLIS) {
|
||||
final CharSequence timeSequence =
|
||||
StringUtil.formatElapsedTime(mContext, usageTimeMs, false, false);
|
||||
preference.setSummary(
|
||||
@@ -470,21 +457,6 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldShowSummary(BatteryEntry entry) {
|
||||
final CharSequence[] allowlistPackages =
|
||||
FeatureFactory.getFactory(mContext)
|
||||
.getPowerUsageFeatureProvider(mContext)
|
||||
.getHideApplicationSummary(mContext);
|
||||
final String target = entry.getDefaultPackageName();
|
||||
|
||||
for (CharSequence packageName : allowlistPackages) {
|
||||
if (TextUtils.equals(target, packageName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isSharedGid(int uid) {
|
||||
return UserHandle.getAppIdFromSharedAppGid(uid) > 0;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
private final String mPreferenceKey;
|
||||
private final SettingsActivity mActivity;
|
||||
private final InstrumentedPreferenceFragment mFragment;
|
||||
private final CharSequence[] mNotAllowShowSummaryPackages;
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
private final AnimatorListenerAdapter mHourlyChartFadeInAdapter =
|
||||
@@ -149,10 +148,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
mIs24HourFormat = DateFormat.is24HourFormat(context);
|
||||
mMetricsFeatureProvider =
|
||||
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
|
||||
mNotAllowShowSummaryPackages =
|
||||
FeatureFactory.getFactory(context)
|
||||
.getPowerUsageFeatureProvider(context)
|
||||
.getHideApplicationSummary(context);
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
@@ -257,8 +252,7 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
Log.d(TAG, String.format("handleClick() label=%s key=%s package=%s",
|
||||
diffEntry.getAppLabel(), histEntry.getKey(), histEntry.mPackageName));
|
||||
AdvancedPowerUsageDetail.startBatteryDetailPage(
|
||||
mActivity, mFragment, diffEntry, powerPref.getPercent(),
|
||||
isValidToShowSummary(packageName), getSlotInformation());
|
||||
mActivity, mFragment, diffEntry, powerPref.getPercent(), getSlotInformation());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -634,11 +628,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
final long foregroundUsageTimeInMs = entry.mForegroundUsageTimeInMs;
|
||||
final long backgroundUsageTimeInMs = entry.mBackgroundUsageTimeInMs;
|
||||
final long totalUsageTimeInMs = foregroundUsageTimeInMs + backgroundUsageTimeInMs;
|
||||
// Checks whether the package is allowed to show summary or not.
|
||||
if (!isValidToShowSummary(entry.getPackageName())) {
|
||||
preference.setSummary(null);
|
||||
return;
|
||||
}
|
||||
String usageTimeSummary = null;
|
||||
// Not shows summary for some system components without usage time.
|
||||
if (totalUsageTimeInMs == 0) {
|
||||
@@ -677,11 +666,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
return mPrefContext.getString(resourceId, timeSequence);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isValidToShowSummary(String packageName) {
|
||||
return !DataProcessor.contains(packageName, mNotAllowShowSummaryPackages);
|
||||
}
|
||||
|
||||
private void animateBatteryChartViewGroup() {
|
||||
if (mBatteryChartViewGroup != null && mBatteryChartViewGroup.getAlpha() == 0) {
|
||||
mBatteryChartViewGroup.animate().alpha(1f).setDuration(FADE_IN_ANIMATION_DURATION)
|
||||
|
||||
@@ -157,20 +157,6 @@ public final class DataProcessor {
|
||||
processedBatteryHistoryMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether the target is in the CharSequence array.
|
||||
*/
|
||||
public static boolean contains(String target, CharSequence[] packageNames) {
|
||||
if (target != null && packageNames != null) {
|
||||
for (CharSequence packageName : packageNames) {
|
||||
if (TextUtils.equals(target, packageName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link BatteryUsageStats} from system service.
|
||||
*/
|
||||
@@ -1223,6 +1209,20 @@ public final class DataProcessor {
|
||||
countOfAppBeforePurge - countOfAppAfterPurge);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether the target is in the CharSequence array.
|
||||
*/
|
||||
private static boolean contains(String target, CharSequence[] packageNames) {
|
||||
if (target != null && packageNames != null) {
|
||||
for (CharSequence packageName : packageNames) {
|
||||
if (TextUtils.equals(target, packageName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void log(Context context, final String content, final long timestamp,
|
||||
final BatteryHistEntry entry) {
|
||||
if (DEBUG) {
|
||||
|
||||
Reference in New Issue
Block a user