Loading services/core/java/com/android/server/am/ServiceRecord.java +5 −7 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; /** Loading @@ -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; Loading services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java +16 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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() { Loading Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading
services/core/java/com/android/server/am/ServiceRecord.java +5 −7 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; /** Loading @@ -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; Loading
services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java +16 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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() { Loading Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading