diff options
4 files changed, 30 insertions, 2 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 0a05f704f523..e32625e1f7a8 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -17818,6 +17818,12 @@ public final class Settings { public static final String FORCE_NON_DEBUGGABLE_FINAL_BUILD_FOR_COMPAT = "force_non_debuggable_final_build_for_compat"; + /** + * Flag to enable the use of ApplicationInfo for getting not-launched status. + * + * @hide + */ + public static final String ENABLE_USE_APP_INFO_NOT_LAUNCHED = "use_app_info_not_launched"; /** * Current version of signed configuration applied. diff --git a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java index d39b5645109d..b491b5a146e1 100644 --- a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java @@ -223,6 +223,7 @@ public class SettingsBackupTest { Settings.Global.ENABLE_DELETION_HELPER_NO_THRESHOLD_TOGGLE, Settings.Global.ENABLE_DISKSTATS_LOGGING, Settings.Global.ENABLE_EPHEMERAL_FEATURE, + Settings.Global.ENABLE_USE_APP_INFO_NOT_LAUNCHED, Settings.Global.DYNAMIC_POWER_SAVINGS_ENABLED, Settings.Global.DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD, Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS, diff --git a/services/core/java/com/android/server/am/ActivityManagerConstants.java b/services/core/java/com/android/server/am/ActivityManagerConstants.java index f5a297bfd4f5..6fd281e7003e 100644 --- a/services/core/java/com/android/server/am/ActivityManagerConstants.java +++ b/services/core/java/com/android/server/am/ActivityManagerConstants.java @@ -685,6 +685,11 @@ final class ActivityManagerConstants extends ContentObserver { // default. Controlled by Settings.Global.FORCE_ENABLE_PSS_PROFILING volatile boolean mForceEnablePssProfiling = false; + // Indicates whether to use ApplicationInfo to determine launched state instead of PM user state + // This is a temporary workaround until the trunk-stable flag is pushed to nextfood. + // TODO: b/365979852 - remove this workaround when redundant + volatile boolean mFlagUseAppInfoNotLaunched = false; + /** * Indicates whether the foreground service background start restriction is enabled for * caller app that is targeting S+. @@ -1017,6 +1022,9 @@ final class ActivityManagerConstants extends ContentObserver { private static final Uri FORCE_ENABLE_PSS_PROFILING_URI = Settings.Global.getUriFor(Settings.Global.FORCE_ENABLE_PSS_PROFILING); + private static final Uri ENABLE_USE_APP_INFO_NOT_LAUNCHED_URI = + Settings.Global.getUriFor(Settings.Global.ENABLE_USE_APP_INFO_NOT_LAUNCHED); + /** * The threshold to decide if a given association should be dumped into metrics. */ @@ -1479,6 +1487,7 @@ final class ActivityManagerConstants extends ContentObserver { false, this); } mResolver.registerContentObserver(FORCE_ENABLE_PSS_PROFILING_URI, false, this); + mResolver.registerContentObserver(ENABLE_USE_APP_INFO_NOT_LAUNCHED_URI, false, this); updateConstants(); if (mSystemServerAutomaticHeapDumpEnabled) { updateEnableAutomaticSystemServerHeapDumps(); @@ -1495,6 +1504,7 @@ final class ActivityManagerConstants extends ContentObserver { updateActivityStartsLoggingEnabled(); updateForegroundServiceStartsLoggingEnabled(); updateForceEnablePssProfiling(); + updateEnableUseAppInfoNotLaunched(); // Read DropboxRateLimiter params from flags. mService.initDropboxRateLimiter(); } @@ -1540,6 +1550,8 @@ final class ActivityManagerConstants extends ContentObserver { updateEnableAutomaticSystemServerHeapDumps(); } else if (FORCE_ENABLE_PSS_PROFILING_URI.equals(uri)) { updateForceEnablePssProfiling(); + } else if (ENABLE_USE_APP_INFO_NOT_LAUNCHED_URI.equals(uri)) { + updateEnableUseAppInfoNotLaunched(); } } @@ -1659,6 +1671,11 @@ final class ActivityManagerConstants extends ContentObserver { Settings.Global.FORCE_ENABLE_PSS_PROFILING, 0) == 1; } + private void updateEnableUseAppInfoNotLaunched() { + mFlagUseAppInfoNotLaunched = Settings.Global.getInt(mResolver, + Settings.Global.ENABLE_USE_APP_INFO_NOT_LAUNCHED, 0) == 1; + } + private void updateBackgroundActivityStarts() { mFlagBackgroundActivityStartsEnabled = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, @@ -2538,6 +2555,8 @@ final class ActivityManagerConstants extends ContentObserver { pw.print(" OOMADJ_UPDATE_QUICK="); pw.println(OOMADJ_UPDATE_QUICK); pw.print(" ENABLE_WAIT_FOR_FINISH_ATTACH_APPLICATION="); pw.println(mEnableWaitForFinishAttachApplication); + pw.print(" FLAG_USE_APP_INFO_NOT_LAUNCHED="); + pw.println(mFlagUseAppInfoNotLaunched); pw.print(" "); pw.print(KEY_FOLLOW_UP_OOMADJ_UPDATE_WAIT_DURATION); pw.print("="); pw.println(FOLLOW_UP_OOMADJ_UPDATE_WAIT_DURATION); diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java index 93b228f37c26..9bf007b468f8 100644 --- a/services/core/java/com/android/server/am/ProcessList.java +++ b/services/core/java/com/android/server/am/ProcessList.java @@ -3398,7 +3398,8 @@ public final class ProcessList { // Check if we should mark the processrecord for first launch after force-stopping if (wasStopped) { boolean wasEverLaunched = false; - if (android.app.Flags.useAppInfoNotLaunched()) { + if (android.app.Flags.useAppInfoNotLaunched() + || mService.mConstants.mFlagUseAppInfoNotLaunched) { wasEverLaunched = !info.isNotLaunched(); } else { try { @@ -3419,7 +3420,8 @@ public final class ProcessList { : STOPPED_STATE_FIRST_LAUNCH; r.getWindowProcessController().setStoppedState(stoppedState); } else { - if (android.app.Flags.useAppInfoNotLaunched()) { + if (android.app.Flags.useAppInfoNotLaunched() + || mService.mConstants.mFlagUseAppInfoNotLaunched) { // If it was launched before, then it must be a force-stop r.setWasForceStopped(wasEverLaunched); } else { |