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

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

Changes need to implement heavy-weight gaming app tests.

We need to expose the CANT_SAVE_STATE importance for CTS to use.

I also found a serious issue with how instrumentation ApplicationInfo
is set up, where it doesn't have lots of important stuff like the
targetSdkVersion!  This is now fixed...  though ghod knows how this
will impact existing CTS tests, there could certainly be stuff relying
on code thinking it is running as targetSdk 0. :(

Finally delete the CantSaveState tests here, they are going to CTS.

Bug: 63937884
Test: ran new CTS tests
Change-Id: I42a73e0e83d799f8e5ff8ac4d4704a74ab5aab3e
parent eb370876
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3952,6 +3952,7 @@ package android.app {
    field public static final android.os.Parcelable.Creator<android.app.ActivityManager.RunningAppProcessInfo> CREATOR;
    field public static final deprecated int IMPORTANCE_BACKGROUND = 400; // 0x190
    field public static final int IMPORTANCE_CACHED = 400; // 0x190
    field public static final int IMPORTANCE_CANT_SAVE_STATE = 270; // 0x10e
    field public static final deprecated int IMPORTANCE_EMPTY = 500; // 0x1f4
    field public static final int IMPORTANCE_FOREGROUND = 100; // 0x64
    field public static final int IMPORTANCE_FOREGROUND_SERVICE = 125; // 0x7d
+5 −5
Original line number Diff line number Diff line
@@ -2944,8 +2944,8 @@ public class ActivityManager {
        /**
         * Constant for {@link #importance}: This process is running an
         * application that can not save its state, and thus can't be killed
         * while in the background.
         * @hide
         * while in the background.  This will be used with apps that have
         * {@link android.R.attr#cantSaveState} set on their application tag.
         */
        public static final int IMPORTANCE_CANT_SAVE_STATE = 270;

@@ -2995,7 +2995,7 @@ public class ActivityManager {
                return IMPORTANCE_CACHED;
            } else if (procState >= PROCESS_STATE_SERVICE) {
                return IMPORTANCE_SERVICE;
            } else if (procState > PROCESS_STATE_HEAVY_WEIGHT) {
            } else if (procState == PROCESS_STATE_HEAVY_WEIGHT) {
                return IMPORTANCE_CANT_SAVE_STATE;
            } else if (procState >= PROCESS_STATE_TRANSIENT_BACKGROUND) {
                return IMPORTANCE_PERCEPTIBLE;
@@ -3051,7 +3051,7 @@ public class ActivityManager {
                return PROCESS_STATE_HOME;
            } else if (importance >= IMPORTANCE_SERVICE) {
                return PROCESS_STATE_SERVICE;
            } else if (importance > IMPORTANCE_CANT_SAVE_STATE) {
            } else if (importance == IMPORTANCE_CANT_SAVE_STATE) {
                return PROCESS_STATE_HEAVY_WEIGHT;
            } else if (importance >= IMPORTANCE_PERCEPTIBLE) {
                return PROCESS_STATE_TRANSIENT_BACKGROUND;
+10 −1
Original line number Diff line number Diff line
@@ -5605,7 +5605,16 @@ public final class ActivityThread extends ClientTransactionHandler {

        // Continue loading instrumentation.
        if (ii != null) {
            final ApplicationInfo instrApp = new ApplicationInfo();
            ApplicationInfo instrApp;
            try {
                instrApp = getPackageManager().getApplicationInfo(ii.packageName, 0,
                        UserHandle.myUserId());
            } catch (RemoteException e) {
                instrApp = null;
            }
            if (instrApp == null) {
                instrApp = new ApplicationInfo();
            }
            ii.copyTo(instrApp);
            instrApp.initForUser(UserHandle.myUserId());
            final LoadedApk pi = getPackageInfo(instrApp, data.compatInfo,

tests/CantSaveState1/Android.mk

deleted100644 → 0
+0 −10
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := tests

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_PACKAGE_NAME := CantSaveState1

include $(BUILD_PACKAGE)
+0 −27
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.test.cantsavestate1">
    <application android:label="Can't Save 1" android:cantSaveState="true">
        <activity android:name="CantSave1Activity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
Loading