Follow-on for #10671878: Proc stats needs to remove old data structures
The UI can now show better information about services, now that we have the name of the process each service runs in and its total run time. Change-Id: I0777d8295a50c8f69c57bad24ccafe3bf0fbe5b8
This commit is contained in:
@@ -78,7 +78,6 @@ public final class ProcStatsEntry implements Parcelable {
|
||||
mBestTargetPackage = null;
|
||||
if (mUnique) {
|
||||
mBestTargetPackage = mPackage;
|
||||
addServices(stats.getPackageStateLocked(mPackage, mUid));
|
||||
} else {
|
||||
// See if there is one significant package that was running here.
|
||||
ArrayList<ProcStatsEntry> subProcs = new ArrayList<ProcStatsEntry>();
|
||||
@@ -90,18 +89,13 @@ public final class ProcStatsEntry implements Parcelable {
|
||||
continue;
|
||||
}
|
||||
ProcessStats.PackageState pkgState = uids.valueAt(iu);
|
||||
boolean match = false;
|
||||
for (int iproc=0, NPROC=pkgState.mProcesses.size(); iproc<NPROC; iproc++) {
|
||||
ProcessStats.ProcessState subProc =
|
||||
pkgState.mProcesses.valueAt(iproc);
|
||||
if (subProc.mName.equals(mName)) {
|
||||
match = true;
|
||||
subProcs.add(new ProcStatsEntry(subProc, totals));
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
addServices(stats.getPackageStateLocked(mPackage, mUid));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (subProcs.size() > 1) {
|
||||
@@ -173,13 +167,9 @@ public final class ProcStatsEntry implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
public void addServices(ProcessStats.PackageState pkgState) {
|
||||
for (int isvc=0, NSVC=pkgState.mServices.size(); isvc<NSVC; isvc++) {
|
||||
ProcessStats.ServiceState svc = pkgState.mServices.valueAt(isvc);
|
||||
// XXX can't tell what process it is in!
|
||||
public void addService(ProcessStats.ServiceState svc) {
|
||||
mServices.add(new Service(svc));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
@@ -213,32 +203,22 @@ public final class ProcStatsEntry implements Parcelable {
|
||||
public static final class Service implements Parcelable {
|
||||
final String mPackage;
|
||||
final String mName;
|
||||
final String mProcess;
|
||||
final long mDuration;
|
||||
|
||||
public Service(ProcessStats.ServiceState service) {
|
||||
mPackage = service.mPackage;
|
||||
mName = service.mName;
|
||||
long startDuration = ProcessStats.dumpSingleServiceTime(null, null, service,
|
||||
ProcessStats.ServiceState.SERVICE_STARTED,
|
||||
mProcess = service.mProcessName;
|
||||
mDuration = ProcessStats.dumpSingleServiceTime(null, null, service,
|
||||
ProcessStats.ServiceState.SERVICE_RUN,
|
||||
ProcessStats.STATE_NOTHING, 0, 0);
|
||||
long bindDuration = ProcessStats.dumpSingleServiceTime(null, null, service,
|
||||
ProcessStats.ServiceState.SERVICE_BOUND,
|
||||
ProcessStats.STATE_NOTHING, 0, 0);
|
||||
long execDuration = ProcessStats.dumpSingleServiceTime(null, null, service,
|
||||
ProcessStats.ServiceState.SERVICE_EXEC,
|
||||
ProcessStats.STATE_NOTHING, 0, 0);
|
||||
if (bindDuration > startDuration) {
|
||||
startDuration = bindDuration;
|
||||
}
|
||||
if (execDuration > startDuration) {
|
||||
startDuration = execDuration;
|
||||
}
|
||||
mDuration = startDuration;
|
||||
}
|
||||
|
||||
public Service(Parcel in) {
|
||||
mPackage = in.readString();
|
||||
mName = in.readString();
|
||||
mProcess = in.readString();
|
||||
mDuration = in.readLong();
|
||||
}
|
||||
|
||||
@@ -251,6 +231,7 @@ public final class ProcStatsEntry implements Parcelable {
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(mPackage);
|
||||
dest.writeString(mName);
|
||||
dest.writeString(mProcess);
|
||||
dest.writeLong(mDuration);
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,7 @@ import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TimeUtils;
|
||||
@@ -245,10 +246,14 @@ public class ProcessStatsUi extends PreferenceFragment {
|
||||
}
|
||||
*/
|
||||
|
||||
ArrayMap<String, ProcStatsEntry> processes = new ArrayMap<String, ProcStatsEntry>(
|
||||
mStats.mProcesses.getMap().size());
|
||||
for (int ip=0, N=mStats.mProcesses.getMap().size(); ip<N; ip++) {
|
||||
SparseArray<ProcessStats.ProcessState> uids = mStats.mProcesses.getMap().valueAt(ip);
|
||||
for (int iu=0; iu<uids.size(); iu++) {
|
||||
procs.add(new ProcStatsEntry(uids.valueAt(iu), totals));
|
||||
ProcStatsEntry ent = new ProcStatsEntry(uids.valueAt(iu), totals);
|
||||
procs.add(ent);
|
||||
processes.put(ent.mName, ent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,6 +288,21 @@ public class ProcessStatsUi extends PreferenceFragment {
|
||||
mAppListGroup.addPreference(pref);
|
||||
if (mAppListGroup.getPreferenceCount() > (MAX_ITEMS_TO_LIST+1)) break;
|
||||
}
|
||||
|
||||
// Add in service info.
|
||||
for (int ip=0, N=mStats.mPackages.getMap().size(); ip<N; ip++) {
|
||||
SparseArray<ProcessStats.PackageState> uids = mStats.mPackages.getMap().valueAt(ip);
|
||||
for (int iu=0; iu<uids.size(); iu++) {
|
||||
ProcessStats.PackageState ps = uids.valueAt(iu);
|
||||
for (int is=0, NS=ps.mServices.size(); is<NS; is++) {
|
||||
ProcessStats.ServiceState ss = ps.mServices.valueAt(is);
|
||||
if (ss.mProcessName != null) {
|
||||
ProcStatsEntry ent = processes.get(ss.mProcessName);
|
||||
ent.addService(ss);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void load() {
|
||||
|
Reference in New Issue
Block a user