Merge "Sorting Historical Location Request Stats in Dumpsys"
This commit is contained in:
@@ -118,6 +118,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -2886,10 +2887,12 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
ipw.println("Historical Records by Provider:");
|
||||
ipw.increaseIndent();
|
||||
TreeMap<PackageProviderKey, PackageStatistics> sorted = new TreeMap<>();
|
||||
sorted.putAll(mRequestStatistics.statistics);
|
||||
for (Map.Entry<PackageProviderKey, PackageStatistics> entry
|
||||
: mRequestStatistics.statistics.entrySet()) {
|
||||
: sorted.entrySet()) {
|
||||
PackageProviderKey key = entry.getKey();
|
||||
ipw.println(key.packageName + ": " + key.providerName + ": " + entry.getValue());
|
||||
ipw.println(key.providerName + ": " + key.packageName + ": " + entry.getValue());
|
||||
}
|
||||
ipw.decreaseIndent();
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public class LocationRequestStatistics {
|
||||
/**
|
||||
* A key that holds both package and provider names.
|
||||
*/
|
||||
public static class PackageProviderKey {
|
||||
public static class PackageProviderKey implements Comparable<PackageProviderKey> {
|
||||
/**
|
||||
* Name of package requesting location.
|
||||
*/
|
||||
@@ -107,6 +107,16 @@ public class LocationRequestStatistics {
|
||||
this.providerName = providerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PackageProviderKey other) {
|
||||
final int providerCompare = providerName.compareTo(other.providerName);
|
||||
if (providerCompare != 0) {
|
||||
return providerCompare;
|
||||
} else {
|
||||
return packageName.compareTo(other.packageName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof PackageProviderKey)) {
|
||||
@@ -211,7 +221,7 @@ public class LocationRequestStatistics {
|
||||
void dump(IndentingPrintWriter ipw, long systemElapsedOffsetMillis) {
|
||||
StringBuilder s = new StringBuilder();
|
||||
long systemTimeMillis = systemElapsedOffsetMillis + mElapsedRealtimeMillis;
|
||||
s.append("At ").append(TimeUtils.formatForLogging(systemTimeMillis)).append(": ")
|
||||
s.append("At ").append(TimeUtils.logTimeOfDay(systemTimeMillis)).append(": ")
|
||||
.append(mIntervalMillis == REQUEST_ENDED_INTERVAL ? "- " : "+ ")
|
||||
.append(String.format("%7s", mProviderName)).append(" request from ")
|
||||
.append(mPackageName);
|
||||
|
||||
Reference in New Issue
Block a user