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

Commit 5d03dab2 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Enable the new while-in-use / BFSL logic for V+ apps" into main

parents 6075ec3c 64ff8582
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ import android.app.PendingIntent;
import android.app.RemoteServiceException.CannotPostForegroundServiceNotificationException;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.Disabled;
import android.compat.annotation.EnabledAfter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -49,6 +49,7 @@ import android.content.pm.ServiceInfo;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.IBinder;
import android.os.PowerExemptionManager;
import android.os.SystemClock;
@@ -94,16 +95,14 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
     * (See also android.app.ForegroundServiceTypePolicy)
     */
    @ChangeId
    // @EnabledAfter(targetSdkVersion = VERSION_CODES.UPSIDE_DOWN_CAKE)
    @Disabled
    @EnabledAfter(targetSdkVersion = VERSION_CODES.UPSIDE_DOWN_CAKE)
    static final long USE_NEW_WIU_LOGIC_FOR_START = 311208629L;

    /**
     * Compat ID to enable the new FGS start logic, for capability calculation.
     */
    @ChangeId
    // Always enabled
    @Disabled
    @EnabledAfter(targetSdkVersion = VERSION_CODES.UPSIDE_DOWN_CAKE)
    static final long USE_NEW_WIU_LOGIC_FOR_CAPABILITIES = 313677553L;

    /**
@@ -111,8 +110,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
     * the background.
     */
    @ChangeId
    // @EnabledAfter(targetSdkVersion = VERSION_CODES.UPSIDE_DOWN_CAKE)
    @Disabled
    @EnabledAfter(targetSdkVersion = VERSION_CODES.UPSIDE_DOWN_CAKE)
    static final long USE_NEW_BFSL_LOGIC = 311208749L;

    final ActivityManagerService ams;
+16 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ import android.os.Process;
import android.os.SystemClock;
import android.os.UserHandle;
import android.platform.test.annotations.Presubmit;
import android.platform.test.flag.junit.SetFlagsRule;
import android.util.ArrayMap;
import android.util.SparseArray;

@@ -111,7 +112,9 @@ import com.android.server.wm.WindowProcessController;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
@@ -161,6 +164,9 @@ public class MockingOomAdjusterTests {
    private static PackageManagerInternal sPackageManagerInternal;
    private static ActivityManagerService sService;

    @Rule
    public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();

    @SuppressWarnings("GuardedBy")
    @BeforeClass
    public static void setUpOnce() {
@@ -227,6 +233,11 @@ public class MockingOomAdjusterTests {
        }
    }

    @Before
    public void setUp() {
        mSetFlagsRule.enableFlags(Flags.FLAG_NEW_FGS_RESTRICTION_LOGIC);
    }

    @AfterClass
    public static void tearDownOnce() {
        LocalServices.removeServiceForTest(PackageManagerInternal.class);
@@ -540,6 +551,7 @@ public class MockingOomAdjusterTests {
        sService.mConstants.mShortFgsProcStateExtraWaitDuration = 200_000;

        ServiceRecord s = ServiceRecord.newEmptyInstanceForTest(sService);
        s.appInfo = new ApplicationInfo();
        s.startRequested = true;
        s.isForeground = true;
        s.foregroundServiceType = FOREGROUND_SERVICE_TYPE_SHORT_SERVICE;
@@ -582,6 +594,7 @@ public class MockingOomAdjusterTests {

        // SHORT_SERVICE, timed out already.
        s = ServiceRecord.newEmptyInstanceForTest(sService);
        s.appInfo = new ApplicationInfo();
        s.startRequested = true;
        s.isForeground = true;
        s.foregroundServiceType = FOREGROUND_SERVICE_TYPE_SHORT_SERVICE;
@@ -1100,6 +1113,7 @@ public class MockingOomAdjusterTests {

        // In order to trick OomAdjuster to think it has a short-service, we need this logic.
        ServiceRecord s = ServiceRecord.newEmptyInstanceForTest(sService);
        s.appInfo = new ApplicationInfo();
        s.startRequested = true;
        s.isForeground = true;
        s.foregroundServiceType = FOREGROUND_SERVICE_TYPE_SHORT_SERVICE;
@@ -1130,6 +1144,7 @@ public class MockingOomAdjusterTests {

        // In order to trick OomAdjuster to think it has a short-service, we need this logic.
        ServiceRecord s = ServiceRecord.newEmptyInstanceForTest(sService);
        s.appInfo = new ApplicationInfo();
        s.startRequested = true;
        s.isForeground = true;
        s.foregroundServiceType = FOREGROUND_SERVICE_TYPE_SHORT_SERVICE;
@@ -1421,6 +1436,7 @@ public class MockingOomAdjusterTests {

        // In order to trick OomAdjuster to think it has a short-service, we need this logic.
        ServiceRecord s = ServiceRecord.newEmptyInstanceForTest(sService);
        s.appInfo = new ApplicationInfo();
        s.startRequested = true;
        s.isForeground = true;
        s.foregroundServiceType = FOREGROUND_SERVICE_TYPE_SHORT_SERVICE;