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

Commit d4d67d03 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Removed references to ATMS.mHomeProcess and mPreviousProcess from AMS (33/n)

Should only be access from ATMS side.

Bug: 80414790
Test: Existing tests pass
Change-Id: I726037d5a5fba9295ddeffb4c02637c287bf6da8
parent d7889f5b
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -7284,7 +7284,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        mBatteryStatsService.shutdown();
        synchronized (this) {
            mProcessStats.shutdownLocked();
            mActivityTaskManager.notifyTaskPersisterLocked(null, true);
        }
        return timedout;
@@ -10384,11 +10383,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        dumpProcessesToGc(pw, needSep, null);
        pw.println();
        pw.println("  mHomeProcess: " + mActivityTaskManager.mHomeProcess);
        pw.println("  mPreviousProcess: " + mActivityTaskManager.mPreviousProcess);
        if (mActivityTaskManager.mHeavyWeightProcess != null) {
            pw.println("  mHeavyWeightProcess: " + mActivityTaskManager.mHeavyWeightProcess);
        }
        mAtmInternal.dumpForOom(pw);
        return true;
    }
@@ -15442,7 +15437,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        if (wpc == mActivityTaskManager.mHomeProcess) {
        if (wpc.isHomeProcess()) {
            if (adj > ProcessList.HOME_APP_ADJ) {
                // This process is hosting what we currently consider to be the
                // home app, so we don't want to let it go into the background.
@@ -15463,7 +15458,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        if (wpc == mActivityTaskManager.mPreviousProcess && app.hasActivities()) {
        if (wpc.isPreviousProcess() && app.hasActivities()) {
            if (adj > ProcessList.PREVIOUS_APP_ADJ) {
                // This was the previous process that showed UI to the user.
                // We want to try to keep it around more aggressively, to give
@@ -15540,7 +15535,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                                "Raise procstate to started service: " + app);
                    }
                }
                if (app.hasShownUi && wpc != mActivityTaskManager.mHomeProcess) {
                if (app.hasShownUi && !wpc.isHomeProcess()) {
                    // If this process has shown some UI, let it immediately
                    // go to the LRU list because it may be pretty heavy with
                    // UI stuff.  We'll tag it with a label just to help
@@ -15619,7 +15614,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        if ((cr.flags&Context.BIND_ALLOW_OOM_MANAGEMENT) != 0) {
                            // Not doing bind OOM management, so treat
                            // this guy more like a started service.
                            if (app.hasShownUi && wpc != mActivityTaskManager.mHomeProcess) {
                            if (app.hasShownUi && !wpc.isHomeProcess()) {
                                // If this process has shown some UI, let it immediately
                                // go to the LRU list because it may be pretty heavy with
                                // UI stuff.  We'll tag it with a label just to help
@@ -15652,7 +15647,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                            // about letting this process get into the LRU
                            // list to be killed and restarted if needed for
                            // memory.
                            if (app.hasShownUi && wpc != mActivityTaskManager.mHomeProcess
                            if (app.hasShownUi && !wpc.isHomeProcess()
                                    && clientAdj > ProcessList.PERCEPTIBLE_APP_ADJ) {
                                if (adj >= ProcessList.CACHED_APP_MIN_ADJ) {
                                    adjType = "cch-bound-ui-services";
@@ -15858,7 +15853,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                }
                String adjType = null;
                if (adj > clientAdj) {
                    if (app.hasShownUi && wpc != mActivityTaskManager.mHomeProcess
                    if (app.hasShownUi && !wpc.isHomeProcess()
                            && clientAdj > ProcessList.PERCEPTIBLE_APP_ADJ) {
                        adjType = "cch-ui-provider";
                    } else {
@@ -17349,8 +17344,8 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            int factor = numTrimming/3;
            int minFactor = 2;
            if (mActivityTaskManager.mHomeProcess != null) minFactor++;
            if (mActivityTaskManager.mPreviousProcess != null) minFactor++;
            if (mAtmInternal.getHomeProcess() != null) minFactor++;
            if (mAtmInternal.getPreviousProcess() != null) minFactor++;
            if (factor < minFactor) factor = minFactor;
            int curLevel = ComponentCallbacks2.TRIM_MEMORY_COMPLETE;
            for (int i=N-1; i>=0; i--) {
+26 −0
Original line number Diff line number Diff line
@@ -5904,6 +5904,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                mShuttingDown = true;
                mStackSupervisor.prepareForShutdownLocked();
                updateEventDispatchingLocked(booted);
                notifyTaskPersisterLocked(null, true);
                return mStackSupervisor.shutdownLocked(timeout);
            }
        }
@@ -6583,6 +6584,17 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            }
        }

        @Override
        public void dumpForOom(PrintWriter pw) {
            synchronized (mGlobalLock) {
                pw.println("  mHomeProcess: " + mHomeProcess);
                pw.println("  mPreviousProcess: " + mPreviousProcess);
                if (mHeavyWeightProcess != null) {
                    pw.println("  mHeavyWeightProcess: " + mHeavyWeightProcess);
                }
            }
        }

        @Override
        public boolean canGcNow() {
            synchronized (mGlobalLock) {
@@ -6741,5 +6753,19 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        public void flushRecentTasks() {
            mRecentTasks.flush();
        }

        @Override
        public WindowProcessController getHomeProcess() {
            synchronized (mGlobalLock) {
                return mHomeProcess;
            }
        }

        @Override
        public WindowProcessController getPreviousProcess() {
            synchronized (mGlobalLock) {
                return mPreviousProcess;
            }
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -730,7 +730,7 @@ class AppErrors {
        // with a home activity running in the process to prevent a repeatedly crashing app
        // from blocking the user to manually clear the list.
        final WindowProcessController proc = app.getWindowProcessController();
        final WindowProcessController homeProc = mService.mActivityTaskManager.mHomeProcess;
        final WindowProcessController homeProc = mService.mAtmInternal.getHomeProcess();
        if (proc == homeProc && proc.hasActivities()
                && (homeProc.mInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
            proc.clearPackagePreferredForHomeActivities();
+12 −0
Original line number Diff line number Diff line
@@ -860,6 +860,18 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
        }
    }

    public boolean isHomeProcess() {
        synchronized (mAtm.mGlobalLock) {
            return this == mAtm.mHomeProcess;
        }
    }

    public boolean isPreviousProcess() {
        synchronized (mAtm.mGlobalLock) {
            return this == mAtm.mPreviousProcess;
        }
    }

    public void dump(PrintWriter pw, String prefix) {
        synchronized (mAtm.mGlobalLock) {
            if (mActivities.size() > 0) {
+6 −0
Original line number Diff line number Diff line
@@ -410,6 +410,9 @@ public abstract class ActivityTaskManagerInternal {
            String[] args, int opti, boolean dumpAll, boolean dumpVisibleStacksOnly,
            boolean dumpFocusedStackOnly);

    /** Dump the current state for inclusion in oom dump. */
    public abstract void dumpForOom(PrintWriter pw);

    /** @return true if it the activity management system is okay with GC running now. */
    public abstract boolean canGcNow();

@@ -460,4 +463,7 @@ public abstract class ActivityTaskManagerInternal {
            int userId);
    /** Flush recent tasks to disk. */
    public abstract void flushRecentTasks();

    public abstract WindowProcessController getHomeProcess();
    public abstract WindowProcessController getPreviousProcess();
}