Merge changes I6c0940fd,I1b2dc636 into rvc-dev am: 01d150e539 am: fdd1c9d081 am: f40041df55
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11727208 Change-Id: Idc84f05f27119d716da559b37b1f8aa56f315515
This commit is contained in:
@@ -32,7 +32,7 @@ import android.util.TimeUtils;
|
||||
import com.android.internal.app.IBatteryStats;
|
||||
import com.android.internal.location.nano.GnssLogsProto.GnssLog;
|
||||
import com.android.internal.location.nano.GnssLogsProto.PowerMetrics;
|
||||
import com.android.internal.os.BackgroundThread;
|
||||
import com.android.internal.util.ConcurrentUtils;
|
||||
import com.android.internal.util.FrameworkStatsLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -465,7 +465,7 @@ public class GnssMetrics {
|
||||
mConstellationTypes = new boolean[GnssStatus.CONSTELLATION_COUNT];
|
||||
}
|
||||
|
||||
/** Class for storing statistics */
|
||||
/** Thread-safe class for storing statistics */
|
||||
private static class Statistics {
|
||||
|
||||
private int mCount;
|
||||
@@ -474,7 +474,7 @@ public class GnssMetrics {
|
||||
private long mLongSum;
|
||||
|
||||
/** Resets statistics */
|
||||
public void reset() {
|
||||
public synchronized void reset() {
|
||||
mCount = 0;
|
||||
mSum = 0.0;
|
||||
mSumSquare = 0.0;
|
||||
@@ -482,7 +482,7 @@ public class GnssMetrics {
|
||||
}
|
||||
|
||||
/** Adds an item */
|
||||
public void addItem(double item) {
|
||||
public synchronized void addItem(double item) {
|
||||
mCount++;
|
||||
mSum += item;
|
||||
mSumSquare += item * item;
|
||||
@@ -490,17 +490,17 @@ public class GnssMetrics {
|
||||
}
|
||||
|
||||
/** Returns number of items added */
|
||||
public int getCount() {
|
||||
public synchronized int getCount() {
|
||||
return mCount;
|
||||
}
|
||||
|
||||
/** Returns mean */
|
||||
public double getMean() {
|
||||
public synchronized double getMean() {
|
||||
return mSum / mCount;
|
||||
}
|
||||
|
||||
/** Returns standard deviation */
|
||||
public double getStandardDeviation() {
|
||||
public synchronized double getStandardDeviation() {
|
||||
double m = mSum / mCount;
|
||||
m = m * m;
|
||||
double v = mSumSquare / mCount;
|
||||
@@ -511,7 +511,7 @@ public class GnssMetrics {
|
||||
}
|
||||
|
||||
/** Returns long sum */
|
||||
public long getLongSum() {
|
||||
public synchronized long getLongSum() {
|
||||
return mLongSum;
|
||||
}
|
||||
}
|
||||
@@ -625,7 +625,7 @@ public class GnssMetrics {
|
||||
mStatsManager.setPullAtomCallback(
|
||||
FrameworkStatsLog.GNSS_STATS,
|
||||
null, // use default PullAtomMetadata values
|
||||
BackgroundThread.getExecutor(), pullAtomCallback);
|
||||
ConcurrentUtils.DIRECT_EXECUTOR, pullAtomCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user