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

Commit 617a922a authored by Amith Yamasani's avatar Amith Yamasani Committed by android-build-merger
Browse files

Merge "Update process state after unbinding a service." into oc-dev am: f57b93cd

am: dccddf02

Change-Id: I8f4082ac526cdfa6f206ffcdbbc498c38bbfff48
parents 6ba13368 dccddf02
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -1364,7 +1364,7 @@ public final class ActiveServices {
                // This could have made the service more important.
                mAm.updateLruProcessLocked(s.app, s.app.hasClientActivities
                        || s.app.treatLikeActivity, b.client);
                mAm.updateOomAdjLocked(s.app);
                mAm.updateOomAdjLocked(s.app, true);
            }

            if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "Bind " + s + " with " + b
@@ -1479,13 +1479,15 @@ public final class ActiveServices {
                                r.binding.service.app.hasClientActivities
                                || r.binding.service.app.treatLikeActivity, null);
                    }
                    mAm.updateOomAdjLocked(r.binding.service.app);
                    mAm.updateOomAdjLocked(r.binding.service.app, false);
                }
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
        }

        mAm.updateOomAdjLocked();

        return true;
    }

@@ -2225,7 +2227,7 @@ public final class ActiveServices {
            bumpServiceExecutingLocked(r, execInFg, "start");
            if (!oomAdjusted) {
                oomAdjusted = true;
                mAm.updateOomAdjLocked(r.app);
                mAm.updateOomAdjLocked(r.app, true);
            }
            if (r.fgRequired && !r.fgWaiting) {
                if (!r.isForeground) {
@@ -2349,7 +2351,7 @@ public final class ActiveServices {
                if (ibr.hasBound) {
                    try {
                        bumpServiceExecutingLocked(r, false, "bring down unbind");
                        mAm.updateOomAdjLocked(r.app);
                        mAm.updateOomAdjLocked(r.app, true);
                        ibr.hasBound = false;
                        ibr.requested = false;
                        r.app.thread.scheduleUnbindService(r,
@@ -2441,7 +2443,7 @@ public final class ActiveServices {
                    bumpServiceExecutingLocked(r, false, "destroy");
                    mDestroyingServices.add(r);
                    r.destroying = true;
                    mAm.updateOomAdjLocked(r.app);
                    mAm.updateOomAdjLocked(r.app, true);
                    r.app.thread.scheduleStopService(r);
                } catch (Exception e) {
                    Slog.w(TAG, "Exception when destroying service "
@@ -2542,7 +2544,7 @@ public final class ActiveServices {
                        // it to go down there and we want it to start out near the top.
                        mAm.updateLruProcessLocked(s.app, false, null);
                    }
                    mAm.updateOomAdjLocked(s.app);
                    mAm.updateOomAdjLocked(s.app, true);
                    b.intent.hasBound = false;
                    // Assume the client doesn't want to know about a rebind;
                    // we will deal with that later if it asks for one.
@@ -2695,7 +2697,7 @@ public final class ActiveServices {
                    mDestroyingServices.remove(r);
                    r.bindings.clear();
                }
                mAm.updateOomAdjLocked(r.app);
                mAm.updateOomAdjLocked(r.app, true);
            }
            r.executeFg = false;
            if (r.tracker != null) {
+16 −8
Original line number Diff line number Diff line
@@ -11293,7 +11293,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                checkTime(startTime, "getContentProviderImpl: before updateOomAdj");
                final int verifiedAdj = cpr.proc.verifiedAdj;
                boolean success = updateOomAdjLocked(cpr.proc);
                boolean success = updateOomAdjLocked(cpr.proc, true);
                // XXX things have changed so updateOomAdjLocked doesn't actually tell us
                // if the process has been successfully adjusted.  So to reduce races with
                // it, we will check whether the process still exists.  Note that this doesn't
@@ -11755,7 +11755,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        dst.proc = r;
                        dst.notifyAll();
                    }
                    updateOomAdjLocked(r);
                    updateOomAdjLocked(r, true);
                    maybeUpdateProviderUsageStatsLocked(r, src.info.packageName,
                            src.info.authority);
                }
@@ -13480,7 +13480,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    }
                }
                if (changed) {
                    updateOomAdjLocked(pr);
                    updateOomAdjLocked(pr, true);
                }
            }
        } finally {
@@ -18254,7 +18254,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            mBackupAppName = app.packageName;
            // Try not to kill the process during backup
            updateOomAdjLocked(proc);
            updateOomAdjLocked(proc, true);
            // If the process is already attached, schedule the creation of the backup agent now.
            // If it is not yet live, this will be done when it attaches to the framework.
@@ -18351,7 +18351,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                // Not backing this app up any more; reset its OOM adjustment
                final ProcessRecord proc = mBackupTarget.app;
                updateOomAdjLocked(proc);
                updateOomAdjLocked(proc, true);
                proc.inFullBackup = false;
                oldBackupUid = mBackupTarget != null ? mBackupTarget.appInfo.uid : -1;
@@ -22111,7 +22111,14 @@ public class ActivityManagerService extends IActivityManager.Stub
        return act;
    }
    final boolean updateOomAdjLocked(ProcessRecord app) {
    /**
     * Update OomAdj for a specific process.
     * @param app The process to update
     * @param oomAdjAll If it's ok to call updateOomAdjLocked() for all running apps
     *                  if necessary, or skip.
     * @return whether updateOomAdjLocked(app) was successful.
     */
    final boolean updateOomAdjLocked(ProcessRecord app, boolean oomAdjAll) {
        final ActivityRecord TOP_ACT = resumedAppLocked();
        final ProcessRecord TOP_APP = TOP_ACT != null ? TOP_ACT.app : null;
        final boolean wasCached = app.cached;
@@ -22126,7 +22133,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                ? app.curRawAdj : ProcessList.UNKNOWN_ADJ;
        boolean success = updateOomAdjLocked(app, cachedAdj, TOP_APP, false,
                SystemClock.uptimeMillis());
        if (wasCached != app.cached || app.curRawAdj == ProcessList.UNKNOWN_ADJ) {
        if (oomAdjAll
                && (wasCached != app.cached || app.curRawAdj == ProcessList.UNKNOWN_ADJ)) {
            // Changed to/from cached state, so apps after it in the LRU
            // list may also be changed.
            updateOomAdjLocked();
@@ -23704,7 +23712,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                }
                pr.hasOverlayUi = hasOverlayUi;
                //Slog.i(TAG, "Setting hasOverlayUi=" + pr.hasOverlayUi + " for pid=" + pid);
                updateOomAdjLocked(pr);
                updateOomAdjLocked(pr, true);
            }
        }
+1 −2
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import android.os.UserHandle;
import android.util.EventLog;
import android.util.Slog;
import android.util.TimeUtils;
import com.android.server.DeviceIdleController;

import static com.android.server.am.ActivityManagerDebugConfig.*;

@@ -682,7 +681,7 @@ public final class BroadcastQueue {
                // are already core system stuff so don't matter for this.
                r.curApp = filter.receiverList.app;
                filter.receiverList.app.curReceivers.add(r);
                mService.updateOomAdjLocked(r.curApp);
                mService.updateOomAdjLocked(r.curApp, true);
            }
        }
        try {