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

Commit 497175be authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Rework network stats to use proc state for fg/bg.

Switch to using the process state to determine whether a
process should be foreground or background, instead of the
boolean foreground given by the activity manager.

This is for battery save mode, where we can now allow more apps
to havenetwork access: everything whose process state is at
least IMPORTANT_FOREGROUND, which allows music playback
and other use-visible things to continue to have network
access.

Note this also impact the traditional background data disabled
state, where now we allow anything top or better to have
network access.  This automatically includes all persistent
processes, the current top activity, and any other processes
hosting the top activity or being used by the top activity.
So it broadens the set of apps that get network access, but I
think this increases it to a reasonable set of things that may
actually be needed for the foreground app to work correctly.

Change-Id: Icb609a2cea280dc3fa3e83417f478ed77f3685aa
parent 2141cb53
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -372,7 +372,7 @@ public final class ArraySet<E> implements Collection<E>, Set<E> {
     * Perform a {@link #add(Object)} of all values in <var>array</var>
     * @param array The array whose contents are to be retrieved.
     */
    public void putAll(ArraySet<? extends E> array) {
    public void addAll(ArraySet<? extends E> array) {
        final int N = array.mSize;
        ensureCapacity(mSize + N);
        if (mSize == 0) {
+1 −1
Original line number Diff line number Diff line
@@ -3182,7 +3182,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            }
            final boolean updates = !mVisibleNotifications.containsAll(mNewVisibleNotifications);
            mVisibleNotifications.clear();
            mVisibleNotifications.putAll(mNewVisibleNotifications);
            mVisibleNotifications.addAll(mNewVisibleNotifications);

            // We have new notifications
            if (updates && mDozeServiceHost != null) {
+0 −7
Original line number Diff line number Diff line
@@ -15020,7 +15020,6 @@ public final class ActivityManagerService extends ActivityManagerNative
        int schedGroup;
        int procState;
        boolean foregroundActivities = false;
        boolean interesting = false;
        BroadcastQueue queue;
        if (app == TOP_APP) {
            // The last app on the list is the foreground app.
@@ -15028,14 +15027,12 @@ public final class ActivityManagerService extends ActivityManagerNative
            schedGroup = Process.THREAD_GROUP_DEFAULT;
            app.adjType = "top-activity";
            foregroundActivities = true;
            interesting = true;
            procState = ActivityManager.PROCESS_STATE_TOP;
        } else if (app.instrumentationClass != null) {
            // Don't want to kill running instrumentation.
            adj = ProcessList.FOREGROUND_APP_ADJ;
            schedGroup = Process.THREAD_GROUP_DEFAULT;
            app.adjType = "instrumentation";
            interesting = true;
            procState = ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
        } else if ((queue = isReceivingBroadcast(app)) != null) {
            // An app that is currently receiving a broadcast also
@@ -15151,10 +15148,6 @@ public final class ActivityManagerService extends ActivityManagerNative
            }
        }
        if (app.foregroundServices) {
            interesting = true;
        }
        if (app == mHeavyWeightProcess) {
            if (adj > ProcessList.HEAVY_WEIGHT_APP_ADJ) {
                // We don't want to kill the current heavy-weight process.
+114 −112

File changed.

Preview size limit exceeded, changes collapsed.