Loading core/java/android/app/activity_manager.aconfig +11 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,17 @@ flag { } } flag { namespace: "backstage_power" name: "use_app_info_not_launched" description: "Use the notLaunched state from ApplicationInfo instead of current value" is_fixed_read_only: true bug: "362516211" metadata { purpose: PURPOSE_BUGFIX } } flag { namespace: "backstage_power" name: "cache_get_current_user_id" Loading core/java/android/content/pm/ApplicationInfo.java +23 −0 Original line number Diff line number Diff line Loading @@ -849,6 +849,12 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { */ public static final int PRIVATE_FLAG_EXT_CPU_OVERRIDE = 1 << 5; /** * Whether the app has been previously not launched * @hide */ public static final int PRIVATE_FLAG_EXT_NOT_LAUNCHED = 1 << 6; /** @hide */ @IntDef(flag = true, prefix = { "PRIVATE_FLAG_EXT_" }, value = { PRIVATE_FLAG_EXT_PROFILEABLE, Loading @@ -857,6 +863,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK, PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS, PRIVATE_FLAG_EXT_CPU_OVERRIDE, PRIVATE_FLAG_EXT_NOT_LAUNCHED, }) @Retention(RetentionPolicy.SOURCE) public @interface ApplicationInfoPrivateFlagsExt {} Loading Loading @@ -2663,6 +2670,22 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { return (privateFlags & ApplicationInfo.PRIVATE_FLAG_IS_RESOURCE_OVERLAY) != 0; } /** * Returns whether the app in the STOPPED state. * @hide */ public boolean isStopped() { return (flags & ApplicationInfo.FLAG_STOPPED) != 0; } /** * Returns whether the app was never launched (any process started) before. * @hide */ public boolean isNotLaunched() { return (privateFlagsExt & ApplicationInfo.PRIVATE_FLAG_EXT_NOT_LAUNCHED) != 0; } /** * Checks if a changeId is enabled for the current user * @param changeId The changeId to verify Loading services/core/java/com/android/server/am/ActiveServices.java +4 −10 Original line number Diff line number Diff line Loading @@ -1516,9 +1516,8 @@ public final class ActiveServices { serviceName, FrameworkStatsLog.SERVICE_STATE_CHANGED__STATE__START); mAm.mBatteryStatsService.noteServiceStartRunning(uid, packageName, serviceName); final ProcessRecord hostApp = r.app; final boolean wasStopped = hostApp == null ? wasStopped(r) : false; final boolean firstLaunch = hostApp == null ? !mAm.wasPackageEverLaunched(r.packageName, r.userId) : false; final boolean wasStopped = hostApp == null ? r.appInfo.isStopped() : false; final boolean firstLaunch = hostApp == null ? r.appInfo.isNotLaunched() : false; String error = bringUpServiceLocked(r, service.getFlags(), callerFg, false /* whileRestarting */, Loading Loading @@ -4308,9 +4307,8 @@ public final class ActiveServices { true, UNKNOWN_ADJ); } final boolean wasStopped = hostApp == null ? wasStopped(s) : false; final boolean firstLaunch = hostApp == null ? !mAm.wasPackageEverLaunched(s.packageName, s.userId) : false; final boolean wasStopped = hostApp == null ? s.appInfo.isStopped() : false; final boolean firstLaunch = hostApp == null ? s.appInfo.isNotLaunched() : false; boolean needOomAdj = false; if (c.hasFlag(Context.BIND_AUTO_CREATE)) { Loading Loading @@ -9350,8 +9348,4 @@ public final class ActiveServices { return mCachedDeviceProvisioningPackage != null && mCachedDeviceProvisioningPackage.equals(packageName); } private boolean wasStopped(ServiceRecord serviceRecord) { return (serviceRecord.appInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0; } } services/core/java/com/android/server/am/AppStartInfoTracker.java +5 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.IntentFilter; import android.content.pm.PackageManager; import android.icu.text.SimpleDateFormat; import android.os.Binder; import android.os.Debug; import android.os.FileUtils; import android.os.Handler; import android.os.IBinder.DeathRecipient; Loading Loading @@ -495,6 +496,10 @@ public final class AppStartInfoTracker { private void addBaseFieldsFromProcessRecord(ApplicationStartInfo start, ProcessRecord app) { if (app == null) { if (DEBUG) { Slog.w(TAG, "app is null in addBaseFieldsFromProcessRecord: " + Debug.getCallers(4)); } return; } final int definingUid = app.getHostingRecord() != null Loading services/core/java/com/android/server/am/BroadcastQueueModernImpl.java +3 −6 Original line number Diff line number Diff line Loading @@ -1005,13 +1005,10 @@ class BroadcastQueueModernImpl extends BroadcastQueue { final ApplicationInfo info = ((ResolveInfo) receiver).activityInfo.applicationInfo; final ComponentName component = ((ResolveInfo) receiver).activityInfo.getComponentName(); if ((info.flags & ApplicationInfo.FLAG_STOPPED) != 0) { queue.setActiveWasStopped(true); } final int intentFlags = r.intent.getFlags() | Intent.FLAG_FROM_BACKGROUND; final boolean firstLaunch = !mService.wasPackageEverLaunched(info.packageName, r.userId); queue.setActiveFirstLaunch(firstLaunch); queue.setActiveWasStopped(info.isStopped()); queue.setActiveFirstLaunch(info.isNotLaunched()); final int intentFlags = r.intent.getFlags() | Intent.FLAG_FROM_BACKGROUND; final HostingRecord hostingRecord = new HostingRecord(HostingRecord.HOSTING_TYPE_BROADCAST, component, r.intent.getAction(), r.getHostingRecordTriggerType()); final boolean isActivityCapable = (r.options != null Loading Loading
core/java/android/app/activity_manager.aconfig +11 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,17 @@ flag { } } flag { namespace: "backstage_power" name: "use_app_info_not_launched" description: "Use the notLaunched state from ApplicationInfo instead of current value" is_fixed_read_only: true bug: "362516211" metadata { purpose: PURPOSE_BUGFIX } } flag { namespace: "backstage_power" name: "cache_get_current_user_id" Loading
core/java/android/content/pm/ApplicationInfo.java +23 −0 Original line number Diff line number Diff line Loading @@ -849,6 +849,12 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { */ public static final int PRIVATE_FLAG_EXT_CPU_OVERRIDE = 1 << 5; /** * Whether the app has been previously not launched * @hide */ public static final int PRIVATE_FLAG_EXT_NOT_LAUNCHED = 1 << 6; /** @hide */ @IntDef(flag = true, prefix = { "PRIVATE_FLAG_EXT_" }, value = { PRIVATE_FLAG_EXT_PROFILEABLE, Loading @@ -857,6 +863,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK, PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS, PRIVATE_FLAG_EXT_CPU_OVERRIDE, PRIVATE_FLAG_EXT_NOT_LAUNCHED, }) @Retention(RetentionPolicy.SOURCE) public @interface ApplicationInfoPrivateFlagsExt {} Loading Loading @@ -2663,6 +2670,22 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { return (privateFlags & ApplicationInfo.PRIVATE_FLAG_IS_RESOURCE_OVERLAY) != 0; } /** * Returns whether the app in the STOPPED state. * @hide */ public boolean isStopped() { return (flags & ApplicationInfo.FLAG_STOPPED) != 0; } /** * Returns whether the app was never launched (any process started) before. * @hide */ public boolean isNotLaunched() { return (privateFlagsExt & ApplicationInfo.PRIVATE_FLAG_EXT_NOT_LAUNCHED) != 0; } /** * Checks if a changeId is enabled for the current user * @param changeId The changeId to verify Loading
services/core/java/com/android/server/am/ActiveServices.java +4 −10 Original line number Diff line number Diff line Loading @@ -1516,9 +1516,8 @@ public final class ActiveServices { serviceName, FrameworkStatsLog.SERVICE_STATE_CHANGED__STATE__START); mAm.mBatteryStatsService.noteServiceStartRunning(uid, packageName, serviceName); final ProcessRecord hostApp = r.app; final boolean wasStopped = hostApp == null ? wasStopped(r) : false; final boolean firstLaunch = hostApp == null ? !mAm.wasPackageEverLaunched(r.packageName, r.userId) : false; final boolean wasStopped = hostApp == null ? r.appInfo.isStopped() : false; final boolean firstLaunch = hostApp == null ? r.appInfo.isNotLaunched() : false; String error = bringUpServiceLocked(r, service.getFlags(), callerFg, false /* whileRestarting */, Loading Loading @@ -4308,9 +4307,8 @@ public final class ActiveServices { true, UNKNOWN_ADJ); } final boolean wasStopped = hostApp == null ? wasStopped(s) : false; final boolean firstLaunch = hostApp == null ? !mAm.wasPackageEverLaunched(s.packageName, s.userId) : false; final boolean wasStopped = hostApp == null ? s.appInfo.isStopped() : false; final boolean firstLaunch = hostApp == null ? s.appInfo.isNotLaunched() : false; boolean needOomAdj = false; if (c.hasFlag(Context.BIND_AUTO_CREATE)) { Loading Loading @@ -9350,8 +9348,4 @@ public final class ActiveServices { return mCachedDeviceProvisioningPackage != null && mCachedDeviceProvisioningPackage.equals(packageName); } private boolean wasStopped(ServiceRecord serviceRecord) { return (serviceRecord.appInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0; } }
services/core/java/com/android/server/am/AppStartInfoTracker.java +5 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.IntentFilter; import android.content.pm.PackageManager; import android.icu.text.SimpleDateFormat; import android.os.Binder; import android.os.Debug; import android.os.FileUtils; import android.os.Handler; import android.os.IBinder.DeathRecipient; Loading Loading @@ -495,6 +496,10 @@ public final class AppStartInfoTracker { private void addBaseFieldsFromProcessRecord(ApplicationStartInfo start, ProcessRecord app) { if (app == null) { if (DEBUG) { Slog.w(TAG, "app is null in addBaseFieldsFromProcessRecord: " + Debug.getCallers(4)); } return; } final int definingUid = app.getHostingRecord() != null Loading
services/core/java/com/android/server/am/BroadcastQueueModernImpl.java +3 −6 Original line number Diff line number Diff line Loading @@ -1005,13 +1005,10 @@ class BroadcastQueueModernImpl extends BroadcastQueue { final ApplicationInfo info = ((ResolveInfo) receiver).activityInfo.applicationInfo; final ComponentName component = ((ResolveInfo) receiver).activityInfo.getComponentName(); if ((info.flags & ApplicationInfo.FLAG_STOPPED) != 0) { queue.setActiveWasStopped(true); } final int intentFlags = r.intent.getFlags() | Intent.FLAG_FROM_BACKGROUND; final boolean firstLaunch = !mService.wasPackageEverLaunched(info.packageName, r.userId); queue.setActiveFirstLaunch(firstLaunch); queue.setActiveWasStopped(info.isStopped()); queue.setActiveFirstLaunch(info.isNotLaunched()); final int intentFlags = r.intent.getFlags() | Intent.FLAG_FROM_BACKGROUND; final HostingRecord hostingRecord = new HostingRecord(HostingRecord.HOSTING_TYPE_BROADCAST, component, r.intent.getAction(), r.getHostingRecordTriggerType()); final boolean isActivityCapable = (r.options != null Loading