Merge "Add field to note if a process has a foreground service" into tm-dev am: b6c06687dd am: 4fe78f6476
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18764698 Change-Id: I3b9e0f7cbbde50ad200986d71a02e612c9bdd8d8 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -524,6 +524,13 @@ public final class ApplicationExitInfo implements Parcelable {
|
||||
*/
|
||||
private boolean mLoggedInStatsd;
|
||||
|
||||
/**
|
||||
* Whether or not this process hosts one or more foreground services.
|
||||
*
|
||||
* for system internal use only, will not retain across processes.
|
||||
*/
|
||||
private boolean mHasForegroundServices;
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = { "REASON_" }, value = {
|
||||
REASON_UNKNOWN,
|
||||
@@ -996,6 +1003,24 @@ public final class ApplicationExitInfo implements Parcelable {
|
||||
mLoggedInStatsd = loggedInStatsd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #mHasForegroundServices
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public boolean hasForegroundServices() {
|
||||
return mHasForegroundServices;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #mHasForegroundServices
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setHasForegroundServices(boolean hasForegroundServices) {
|
||||
mHasForegroundServices = hasForegroundServices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
@@ -1060,6 +1085,8 @@ public final class ApplicationExitInfo implements Parcelable {
|
||||
mTraceFile = other.mTraceFile;
|
||||
mAppTraceRetriever = other.mAppTraceRetriever;
|
||||
mNativeTombstoneRetriever = other.mNativeTombstoneRetriever;
|
||||
mLoggedInStatsd = other.mLoggedInStatsd;
|
||||
mHasForegroundServices = other.mHasForegroundServices;
|
||||
}
|
||||
|
||||
private ApplicationExitInfo(@NonNull Parcel in) {
|
||||
|
||||
@@ -28,12 +28,15 @@ public final class ProcessMemoryState implements Parcelable {
|
||||
public final int pid;
|
||||
public final String processName;
|
||||
public final int oomScore;
|
||||
public final boolean hasForegroundServices;
|
||||
|
||||
public ProcessMemoryState(int uid, int pid, String processName, int oomScore) {
|
||||
public ProcessMemoryState(int uid, int pid, String processName, int oomScore,
|
||||
boolean hasForegroundServices) {
|
||||
this.uid = uid;
|
||||
this.pid = pid;
|
||||
this.processName = processName;
|
||||
this.oomScore = oomScore;
|
||||
this.hasForegroundServices = hasForegroundServices;
|
||||
}
|
||||
|
||||
private ProcessMemoryState(Parcel in) {
|
||||
@@ -41,6 +44,7 @@ public final class ProcessMemoryState implements Parcelable {
|
||||
pid = in.readInt();
|
||||
processName = in.readString();
|
||||
oomScore = in.readInt();
|
||||
hasForegroundServices = in.readInt() == 1;
|
||||
}
|
||||
|
||||
public static final @android.annotation.NonNull Creator<ProcessMemoryState> CREATOR = new Creator<ProcessMemoryState>() {
|
||||
@@ -66,5 +70,6 @@ public final class ProcessMemoryState implements Parcelable {
|
||||
parcel.writeInt(pid);
|
||||
parcel.writeString(processName);
|
||||
parcel.writeInt(oomScore);
|
||||
parcel.writeInt(hasForegroundServices ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2654,6 +2654,7 @@ public final class ActiveServices {
|
||||
}
|
||||
}
|
||||
mAm.updateProcessForegroundLocked(psr.mApp, anyForeground, fgServiceTypes, oomAdj);
|
||||
psr.setHasReportedForegroundServices(anyForeground);
|
||||
}
|
||||
|
||||
private void updateAllowlistManagerLocked(ProcessServiceRecord psr) {
|
||||
|
||||
@@ -16683,7 +16683,8 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
for (int i = 0, size = mPidsSelfLocked.size(); i < size; i++) {
|
||||
final ProcessRecord r = mPidsSelfLocked.valueAt(i);
|
||||
processMemoryStates.add(new ProcessMemoryState(
|
||||
r.uid, r.getPid(), r.processName, r.mState.getCurAdj()));
|
||||
r.uid, r.getPid(), r.processName, r.mState.getCurAdj(),
|
||||
r.mServices.hasForegroundServices()));
|
||||
}
|
||||
}
|
||||
return processMemoryStates;
|
||||
|
||||
@@ -893,7 +893,8 @@ public final class AppExitInfoTracker {
|
||||
}
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.APP_PROCESS_DIED,
|
||||
info.getPackageUid(), processName, info.getReason(), info.getSubReason(),
|
||||
info.getImportance(), (int) info.getPss(), (int) info.getRss());
|
||||
info.getImportance(), (int) info.getPss(), (int) info.getRss(),
|
||||
info.hasForegroundServices());
|
||||
}
|
||||
|
||||
@GuardedBy("mLock")
|
||||
@@ -1008,6 +1009,7 @@ public final class AppExitInfoTracker {
|
||||
info.setPss(app.mProfile.getLastPss());
|
||||
info.setRss(app.mProfile.getLastRss());
|
||||
info.setTimestamp(timestamp);
|
||||
info.setHasForegroundServices(app.mServices.hasReportedForegroundServices());
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
@@ -45,6 +45,11 @@ final class ProcessServiceRecord {
|
||||
*/
|
||||
private boolean mHasForegroundServices;
|
||||
|
||||
/**
|
||||
* Last reported state of whether it's running any services that are foreground.
|
||||
*/
|
||||
private boolean mRepHasForegroundServices;
|
||||
|
||||
/**
|
||||
* Running any services that are almost perceptible (started with
|
||||
* {@link Context#BIND_ALMOST_PERCEPTIBLE} while the app was on TOP)?
|
||||
@@ -155,6 +160,14 @@ final class ProcessServiceRecord {
|
||||
return mHasForegroundServices;
|
||||
}
|
||||
|
||||
void setHasReportedForegroundServices(boolean hasForegroundServices) {
|
||||
mRepHasForegroundServices = hasForegroundServices;
|
||||
}
|
||||
|
||||
boolean hasReportedForegroundServices() {
|
||||
return mRepHasForegroundServices;
|
||||
}
|
||||
|
||||
int getForegroundServiceTypes() {
|
||||
return mHasForegroundServices ? mFgServiceTypes : 0;
|
||||
}
|
||||
|
||||
@@ -2269,7 +2269,7 @@ public class StatsPullAtomService extends SystemService {
|
||||
managedProcess.processName, managedProcess.pid, managedProcess.oomScore,
|
||||
snapshot.rssInKilobytes, snapshot.anonRssInKilobytes, snapshot.swapInKilobytes,
|
||||
snapshot.anonRssInKilobytes + snapshot.swapInKilobytes,
|
||||
gpuMemPerPid.get(managedProcess.pid)));
|
||||
gpuMemPerPid.get(managedProcess.pid), managedProcess.hasForegroundServices));
|
||||
}
|
||||
// Complement the data with native system processes. Given these measurements can be taken
|
||||
// in response to LMKs happening, we want to first collect the managed app stats (to
|
||||
@@ -2288,7 +2288,7 @@ public class StatsPullAtomService extends SystemService {
|
||||
-1001 /*Placeholder for native processes, OOM_SCORE_ADJ_MIN - 1.*/,
|
||||
snapshot.rssInKilobytes, snapshot.anonRssInKilobytes, snapshot.swapInKilobytes,
|
||||
snapshot.anonRssInKilobytes + snapshot.swapInKilobytes,
|
||||
gpuMemPerPid.get(pid)));
|
||||
gpuMemPerPid.get(pid), false /* has_foreground_services */));
|
||||
}
|
||||
return StatsManager.PULL_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user