Not call refreshStats() in setDuration()
refreshStats() needs to be called on worker thread, and all usage places call refreshStats() after setDuration(). So no need to call refreshStats() in setDuration(), this also prevent ANRs. Fix: 241167275 Test: manual - on dev options Change-Id: I8f4ad57c3843f14f6baee1d06d29eea1341509f1
This commit is contained in:
@@ -29,6 +29,8 @@ import android.util.Log;
|
|||||||
import android.util.LongSparseArray;
|
import android.util.LongSparseArray;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
|
import androidx.annotation.WorkerThread;
|
||||||
|
|
||||||
import com.android.internal.app.ProcessMap;
|
import com.android.internal.app.ProcessMap;
|
||||||
import com.android.internal.app.procstats.DumpUtils;
|
import com.android.internal.app.procstats.DumpUtils;
|
||||||
import com.android.internal.app.procstats.IProcessStats;
|
import com.android.internal.app.procstats.IProcessStats;
|
||||||
@@ -85,24 +87,10 @@ public class ProcStatsData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotalTime(int totalTime) {
|
|
||||||
memTotalTime = totalTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void xferStats() {
|
public void xferStats() {
|
||||||
sStatsXfer = mStats;
|
sStatsXfer = mStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMemStates(int[] memStates) {
|
|
||||||
mMemStates = memStates;
|
|
||||||
refreshStats(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStats(int[] stats) {
|
|
||||||
this.mStates = stats;
|
|
||||||
refreshStats(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMemState() {
|
public int getMemState() {
|
||||||
int factor = mStats.mMemFactor;
|
int factor = mStats.mMemFactor;
|
||||||
if (factor == ProcessStats.ADJ_NOTHING) {
|
if (factor == ProcessStats.ADJ_NOTHING) {
|
||||||
@@ -118,15 +106,13 @@ public class ProcStatsData {
|
|||||||
return mMemInfo;
|
return mMemInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getElapsedTime() {
|
/**
|
||||||
return mStats.mTimePeriodEndRealtime - mStats.mTimePeriodStartRealtime;
|
* Sets the duration.
|
||||||
}
|
*
|
||||||
|
* <p>Note: {@link #refreshStats(boolean)} needs to called manually to take effect.
|
||||||
|
*/
|
||||||
public void setDuration(long duration) {
|
public void setDuration(long duration) {
|
||||||
if (duration != mDuration) {
|
|
||||||
mDuration = duration;
|
mDuration = duration;
|
||||||
refreshStats(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDuration() {
|
public long getDuration() {
|
||||||
@@ -137,6 +123,12 @@ public class ProcStatsData {
|
|||||||
return pkgEntries;
|
return pkgEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refreshes the stats.
|
||||||
|
*
|
||||||
|
* <p>Note: This needs to be called manually to take effect.
|
||||||
|
*/
|
||||||
|
@WorkerThread
|
||||||
public void refreshStats(boolean forceLoad) {
|
public void refreshStats(boolean forceLoad) {
|
||||||
if (mStats == null || forceLoad) {
|
if (mStats == null || forceLoad) {
|
||||||
load();
|
load();
|
||||||
|
Reference in New Issue
Block a user