Sort app list after smeared on screen
Then we could make sure the app list is sorted Bug: 62035385 Test: RunSettingsRoboTests Change-Id: I3fa3d6ffc5930cf011e382632143e459fdbc4369
This commit is contained in:
@@ -33,6 +33,8 @@ import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -219,7 +221,7 @@ public class BatteryUtils {
|
||||
* Calculate the whole running time in the state {@code statsType}
|
||||
*
|
||||
* @param batteryStatsHelper utility class that contains the data
|
||||
* @param statsType state that we want to calculate the time for
|
||||
* @param statsType state that we want to calculate the time for
|
||||
* @return the running time in millis
|
||||
*/
|
||||
public long calculateRunningTimeBasedOnStatsType(BatteryStatsHelper batteryStatsHelper,
|
||||
@@ -247,6 +249,18 @@ public class BatteryUtils {
|
||||
return ArrayUtils.isEmpty(packageNames) ? null : packageNames[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the {@code usageList} based on {@link BatterySipper#totalPowerMah}
|
||||
*/
|
||||
public void sortUsageList(List<BatterySipper> usageList) {
|
||||
Collections.sort(usageList, new Comparator<BatterySipper>() {
|
||||
@Override
|
||||
public int compare(BatterySipper a, BatterySipper b) {
|
||||
return Double.compare(b.totalPowerMah, a.totalPowerMah);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private long convertUsToMs(long timeUs) {
|
||||
return timeUs / 1000;
|
||||
}
|
||||
|
Reference in New Issue
Block a user