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

Commit c8e4fad8 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Make android:cantSaveState an optional feature.

This doesn't make sense on things like watches and appliances,
so make this an optional feature that the device must enable.
If the feature is not set, then the system will ignore
the app's request.

Bug: 76213401
Test: atest CtsAppTestCases:ActivityManagerProcessStateTest
Change-Id: I91abf9d86ec14fa632e3bcc83c4a3febade5d2e4
parent c6163bf6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11274,6 +11274,7 @@ package android.content.pm {
    field public static final java.lang.String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
    field public static final java.lang.String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
    field public static final java.lang.String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
    field public static final java.lang.String FEATURE_CANT_SAVE_STATE = "android.software.cant_save_state";
    field public static final java.lang.String FEATURE_COMPANION_DEVICE_SETUP = "android.software.companion_device_setup";
    field public static final java.lang.String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
    field public static final java.lang.String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
+7 −0
Original line number Diff line number Diff line
@@ -2281,6 +2281,13 @@ public abstract class PackageManager {
     */
    @SdkConstant(SdkConstantType.FEATURE)
    public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
    /**
     * Feature for {@link #getSystemAvailableFeatures} and
     * {@link #hasSystemFeature}: The device supports the
     * {@link android.R.attr#cantSaveState} API.
     */
    @SdkConstant(SdkConstantType.FEATURE)
    public static final String FEATURE_CANT_SAVE_STATE = "android.software.cant_save_state";

    /**
     * @hide
+4 −0
Original line number Diff line number Diff line
@@ -1970,6 +1970,8 @@ public class ActivityManagerService extends IActivityManager.Stub
    final boolean mPermissionReviewRequired;
    boolean mHasHeavyWeightFeature;
    /**
     * Whether to force background check on all apps (for battery saver) or not.
     */
@@ -15085,6 +15087,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                return;
            }
            mHasHeavyWeightFeature = mContext.getPackageManager().hasSystemFeature(
                    PackageManager.FEATURE_CANT_SAVE_STATE);
            mLocalDeviceIdleController
                    = LocalServices.getService(DeviceIdleController.LocalService.class);
            mAssistUtils = new AssistUtils(mContext);
+2 −1
Original line number Diff line number Diff line
@@ -1526,7 +1526,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
                mService.getLifecycleManager().scheduleTransaction(clientTransaction);


                if ((app.info.privateFlags & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) {
                if ((app.info.privateFlags & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0
                        && mService.mHasHeavyWeightFeature) {
                    // This may be a heavy-weight process!  Note that the package
                    // manager will ensure that only activity can run in the main
                    // process of the .apk, which is the only thing that will be
+2 −1
Original line number Diff line number Diff line
@@ -1023,7 +1023,8 @@ class ActivityStarter {

            if (aInfo != null &&
                    (aInfo.applicationInfo.privateFlags
                            & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) {
                            & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0 &&
                    mService.mHasHeavyWeightFeature) {
                // This may be a heavy-weight process!  Check to see if we already
                // have another, different heavy-weight process running.
                if (aInfo.processName.equals(aInfo.applicationInfo.packageName)) {