Merge "Hide Camera background running time in the battery usage screen" into sc-dev
This commit is contained in:
@@ -24,6 +24,8 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -288,7 +290,7 @@ public final class ConvertUtils {
|
||||
}
|
||||
insert24HoursData(BatteryChartView.SELECTED_INDEX_ALL, resultMap);
|
||||
if (purgeLowPercentageAndFakeData) {
|
||||
purgeLowPercentageAndFakeData(resultMap);
|
||||
purgeLowPercentageAndFakeData(context, resultMap);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
@@ -327,7 +329,12 @@ public final class ConvertUtils {
|
||||
|
||||
// Removes low percentage data and fake usage data, which will be zero value.
|
||||
private static void purgeLowPercentageAndFakeData(
|
||||
final Context context,
|
||||
final Map<Integer, List<BatteryDiffEntry>> indexedUsageMap) {
|
||||
final List<CharSequence> backgroundUsageTimeHideList =
|
||||
FeatureFactory.getFactory(context)
|
||||
.getPowerUsageFeatureProvider(context)
|
||||
.getHideBackgroundUsageTimeList(context);
|
||||
for (List<BatteryDiffEntry> entries : indexedUsageMap.values()) {
|
||||
final Iterator<BatteryDiffEntry> iterator = entries.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -336,6 +343,12 @@ public final class ConvertUtils {
|
||||
|| FAKE_PACKAGE_NAME.equals(entry.getPackageName())) {
|
||||
iterator.remove();
|
||||
}
|
||||
final String packageName = entry.getPackageName();
|
||||
if (packageName != null
|
||||
&& !backgroundUsageTimeHideList.isEmpty()
|
||||
&& backgroundUsageTimeHideList.contains(packageName)) {
|
||||
entry.mBackgroundUsageTimeInMs = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import android.util.SparseIntArray;
|
||||
import com.android.internal.os.BatterySipper;
|
||||
import com.android.settingslib.fuelgauge.Estimate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -141,4 +142,9 @@ public interface PowerUsageFeatureProvider {
|
||||
* Returns battery history data with corresponding timestamp key.
|
||||
*/
|
||||
Map<Long, Map<String, BatteryHistEntry>> getBatteryHistory(Context context);
|
||||
|
||||
/**
|
||||
* Returns {@link List} for hidding applications background usage time.
|
||||
*/
|
||||
List<CharSequence> getHideBackgroundUsageTimeList(Context context);
|
||||
}
|
||||
|
@@ -26,6 +26,8 @@ import com.android.internal.os.BatterySipper;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.settingslib.fuelgauge.Estimate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider {
|
||||
@@ -167,4 +169,9 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
||||
public Map<Long, Map<String, BatteryHistEntry>> getBatteryHistory(Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CharSequence> getHideBackgroundUsageTimeList(Context context) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user