Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bab31979 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am 9210bc85: Implement #10744011: Serialize running of background services

* commit '9210bc85':
  Implement #10744011: Serialize running of background services
parents 0899d983 9210bc85
Loading
Loading
Loading
Loading
+355 −152

File changed.

Preview size limit exceeded, changes collapsed.

+27 −1
Original line number Diff line number Diff line
@@ -528,6 +528,32 @@ final class ProcessRecord {
        return stringName = sb.toString();
    }

    public String makeAdjReason() {
        StringBuilder sb = new StringBuilder(128);
        sb.append('(').append(adjType).append(')');
        if (adjSource != null || adjTarget != null) {
            sb.append(' ');
            if (adjTarget instanceof ComponentName) {
                sb.append(((ComponentName)adjTarget).flattenToShortString());
            } else if (adjTarget != null) {
                sb.append(adjTarget.toString());
            } else {
                sb.append("{null}");
            }
            sb.append("<=");
            if (adjSource instanceof ProcessRecord) {
                sb.append("Proc{");
                sb.append(((ProcessRecord)adjSource).toShortString());
                sb.append("}");
            } else if (adjSource != null) {
                sb.append(adjSource.toString());
            } else {
                sb.append("{null}");
            }
        }
        return sb.toString();
    }

    /*
     *  Return true if package has been added false if not
     */
+13 −4
Original line number Diff line number Diff line
@@ -85,11 +85,14 @@ final class ServiceRecord extends Binder {
    ProcessRecord app;      // where this service is running or null.
    ProcessRecord isolatedProc; // keep track of isolated process, if requested
    ProcessStats.ServiceState tracker; // tracking service execution, may be null
    boolean delayed;        // are we waiting to start this service in the background?
    boolean isForeground;   // is service currently in foreground mode?
    int foregroundId;       // Notification ID of last foreground req.
    Notification foregroundNoti; // Notification record of foreground state.
    long lastActivity;      // last time there was some activity on the service.
    long startingBgTimeout;  // time at which we scheduled this for a delayed start.
    boolean startRequested; // someone explicitly called start?
    boolean delayedStop;    // service has been stopped but is in a delayed start?
    boolean stopIfKilled;   // last onStart() said to stop if service killed?
    boolean callStart;      // last onStart() has asked to alway be called on restart.
    int executeNesting;     // number of outstanding operations keeping foreground.
@@ -220,6 +223,9 @@ final class ServiceRecord extends Binder {
        if (isolatedProc != null) {
            pw.print(prefix); pw.print("isolatedProc="); pw.println(isolatedProc);
        }
        if (delayed) {
            pw.print(prefix); pw.print("delayed="); pw.println(delayed);
        }
        if (isForeground || foregroundId != 0) {
            pw.print(prefix); pw.print("isForeground="); pw.print(isForeground);
                    pw.print(" foregroundId="); pw.print(foregroundId);
@@ -227,14 +233,17 @@ final class ServiceRecord extends Binder {
        }
        pw.print(prefix); pw.print("createTime=");
                TimeUtils.formatDuration(createTime, nowReal, pw);
                pw.print(" lastActivity=");
                TimeUtils.formatDuration(lastActivity, now, pw);
                pw.print(" startingBgTimeout=");
                TimeUtils.formatDuration(startingBgTimeout, now, pw);
                pw.println();
        pw.print(prefix); pw.print("restartTime=");
        pw.print(prefix); pw.print("lastActivity=");
                TimeUtils.formatDuration(lastActivity, now, pw);
                pw.print(" restartTime=");
                TimeUtils.formatDuration(restartTime, now, pw);
                pw.print(" createdFromFg="); pw.println(createdFromFg);
        if (startRequested || lastStartId != 0) {
        if (startRequested || delayedStop || lastStartId != 0) {
            pw.print(prefix); pw.print("startRequested="); pw.print(startRequested);
                    pw.print(" delayedStop="); pw.print(delayedStop);
                    pw.print(" stopIfKilled="); pw.print(stopIfKilled);
                    pw.print(" callStart="); pw.print(callStart);
                    pw.print(" lastStartId="); pw.println(lastStartId);