diff options
| author | 2020-11-11 18:57:13 +0000 | |
|---|---|---|
| committer | 2020-11-11 18:57:13 +0000 | |
| commit | c035a6f07bec4ed8c96dd400b74b41d3d9a59979 (patch) | |
| tree | 10b17ab13f6d0f902464fd67e5bac5494b65a950 | |
| parent | 1f33d4c06f50584662459745938b235b32ad6911 (diff) | |
| parent | 423349508c3b896a73ea2658fddd4fe0cdabb50a (diff) | |
Merge "ActivityManager: use proc state from compiled aidl"
| -rw-r--r-- | Android.bp | 8 | ||||
| -rw-r--r-- | core/java/android/app/ActivityManager.java | 53 | ||||
| -rw-r--r-- | core/java/android/app/ProcessStateEnum.aidl | 100 |
3 files changed, 139 insertions, 22 deletions
diff --git a/Android.bp b/Android.bp index bbaeea57ff2b..6b39b514a2df 100644 --- a/Android.bp +++ b/Android.bp @@ -1093,6 +1093,14 @@ filegroup { path: "core/java", } +filegroup { + name: "activity_manager_procstate_aidl", + srcs: [ + "core/java/android/app/ProcessStateEnum.aidl", + ], + path: "core/java", +} + aidl_interface { name: "libincremental_aidl", unstable: true, diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index f9970dd8e3db..f17b815c5e28 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -490,89 +490,98 @@ public class ActivityManager { @Retention(RetentionPolicy.SOURCE) public @interface ProcessState {} + /* + * PROCESS_STATE_* must come from frameworks/base/core/java/android/app/ProcessStateEnum.aidl. + * This is to make sure that Java side uses the same values as native. + */ /** @hide Not a real process state. */ - public static final int PROCESS_STATE_UNKNOWN = -1; + public static final int PROCESS_STATE_UNKNOWN = ProcessStateEnum.UNKNOWN; /** @hide Process is a persistent system process. */ - public static final int PROCESS_STATE_PERSISTENT = 0; + public static final int PROCESS_STATE_PERSISTENT = ProcessStateEnum.PERSISTENT; /** @hide Process is a persistent system process and is doing UI. */ - public static final int PROCESS_STATE_PERSISTENT_UI = 1; + public static final int PROCESS_STATE_PERSISTENT_UI = ProcessStateEnum.PERSISTENT_UI; /** @hide Process is hosting the current top activities. Note that this covers * all activities that are visible to the user. */ @UnsupportedAppUsage - public static final int PROCESS_STATE_TOP = 2; + public static final int PROCESS_STATE_TOP = ProcessStateEnum.TOP; /** @hide Process is bound to a TOP app. */ - public static final int PROCESS_STATE_BOUND_TOP = 3; + public static final int PROCESS_STATE_BOUND_TOP = ProcessStateEnum.BOUND_TOP; /** @hide Process is hosting a foreground service. */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static final int PROCESS_STATE_FOREGROUND_SERVICE = 4; + public static final int PROCESS_STATE_FOREGROUND_SERVICE = ProcessStateEnum.FOREGROUND_SERVICE; /** @hide Process is hosting a foreground service due to a system binding. */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static final int PROCESS_STATE_BOUND_FOREGROUND_SERVICE = 5; + public static final int PROCESS_STATE_BOUND_FOREGROUND_SERVICE = + ProcessStateEnum.BOUND_FOREGROUND_SERVICE; /** @hide Process is important to the user, and something they are aware of. */ - public static final int PROCESS_STATE_IMPORTANT_FOREGROUND = 6; + public static final int PROCESS_STATE_IMPORTANT_FOREGROUND = + ProcessStateEnum.IMPORTANT_FOREGROUND; /** @hide Process is important to the user, but not something they are aware of. */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static final int PROCESS_STATE_IMPORTANT_BACKGROUND = 7; + public static final int PROCESS_STATE_IMPORTANT_BACKGROUND = + ProcessStateEnum.IMPORTANT_BACKGROUND; /** @hide Process is in the background transient so we will try to keep running. */ - public static final int PROCESS_STATE_TRANSIENT_BACKGROUND = 8; + public static final int PROCESS_STATE_TRANSIENT_BACKGROUND = + ProcessStateEnum.TRANSIENT_BACKGROUND; /** @hide Process is in the background running a backup/restore operation. */ - public static final int PROCESS_STATE_BACKUP = 9; + public static final int PROCESS_STATE_BACKUP = ProcessStateEnum.BACKUP; /** @hide Process is in the background running a service. Unlike oom_adj, this level * is used for both the normal running in background state and the executing * operations state. */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static final int PROCESS_STATE_SERVICE = 10; + public static final int PROCESS_STATE_SERVICE = ProcessStateEnum.SERVICE; /** @hide Process is in the background running a receiver. Note that from the * perspective of oom_adj, receivers run at a higher foreground level, but for our * prioritization here that is not necessary and putting them below services means * many fewer changes in some process states as they receive broadcasts. */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static final int PROCESS_STATE_RECEIVER = 11; + public static final int PROCESS_STATE_RECEIVER = ProcessStateEnum.RECEIVER; /** @hide Same as {@link #PROCESS_STATE_TOP} but while device is sleeping. */ - public static final int PROCESS_STATE_TOP_SLEEPING = 12; + public static final int PROCESS_STATE_TOP_SLEEPING = ProcessStateEnum.TOP_SLEEPING; /** @hide Process is in the background, but it can't restore its state so we want * to try to avoid killing it. */ - public static final int PROCESS_STATE_HEAVY_WEIGHT = 13; + public static final int PROCESS_STATE_HEAVY_WEIGHT = ProcessStateEnum.HEAVY_WEIGHT; /** @hide Process is in the background but hosts the home activity. */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static final int PROCESS_STATE_HOME = 14; + public static final int PROCESS_STATE_HOME = ProcessStateEnum.HOME; /** @hide Process is in the background but hosts the last shown activity. */ - public static final int PROCESS_STATE_LAST_ACTIVITY = 15; + public static final int PROCESS_STATE_LAST_ACTIVITY = ProcessStateEnum.LAST_ACTIVITY; /** @hide Process is being cached for later use and contains activities. */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static final int PROCESS_STATE_CACHED_ACTIVITY = 16; + public static final int PROCESS_STATE_CACHED_ACTIVITY = ProcessStateEnum.CACHED_ACTIVITY; /** @hide Process is being cached for later use and is a client of another cached * process that contains activities. */ - public static final int PROCESS_STATE_CACHED_ACTIVITY_CLIENT = 17; + public static final int PROCESS_STATE_CACHED_ACTIVITY_CLIENT = + ProcessStateEnum.CACHED_ACTIVITY_CLIENT; /** @hide Process is being cached for later use and has an activity that corresponds * to an existing recent task. */ - public static final int PROCESS_STATE_CACHED_RECENT = 18; + public static final int PROCESS_STATE_CACHED_RECENT = ProcessStateEnum.CACHED_RECENT; /** @hide Process is being cached for later use and is empty. */ - public static final int PROCESS_STATE_CACHED_EMPTY = 19; + public static final int PROCESS_STATE_CACHED_EMPTY = ProcessStateEnum.CACHED_EMPTY; /** @hide Process does not exist. */ - public static final int PROCESS_STATE_NONEXISTENT = 20; + public static final int PROCESS_STATE_NONEXISTENT = ProcessStateEnum.NONEXISTENT; /** * The set of flags for process capability. diff --git a/core/java/android/app/ProcessStateEnum.aidl b/core/java/android/app/ProcessStateEnum.aidl new file mode 100644 index 000000000000..a14e7a651eec --- /dev/null +++ b/core/java/android/app/ProcessStateEnum.aidl @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2020 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. + */ +package android.app; + +/** + * Defines the PROCESS_STATE_* values used by ActivityManager. + * These values are shared by Java and native side. + * {@hide} + */ +@Backing(type="int") +enum ProcessStateEnum { + /** @hide Not a real process state. */ + UNKNOWN = -1, + + /** @hide Process is a persistent system process. */ + PERSISTENT = 0, + + /** @hide Process is a persistent system process and is doing UI. */ + PERSISTENT_UI = 1, + + /** @hide Process is hosting the current top activities. Note that this covers + * all activities that are visible to the user. */ + TOP = 2, + + /** @hide Process is bound to a TOP app. */ + BOUND_TOP = 3, + + /** @hide Process is hosting a foreground service. */ + FOREGROUND_SERVICE = 4, + + /** @hide Process is hosting a foreground service due to a system binding. */ + BOUND_FOREGROUND_SERVICE = 5, + + /** @hide Process is important to the user, and something they are aware of. */ + IMPORTANT_FOREGROUND = 6, + + /** @hide Process is important to the user, but not something they are aware of. */ + IMPORTANT_BACKGROUND = 7, + + /** @hide Process is in the background transient so we will try to keep running. */ + TRANSIENT_BACKGROUND = 8, + + /** @hide Process is in the background running a backup/restore operation. */ + BACKUP = 9, + + /** @hide Process is in the background running a service. Unlike oom_adj, this level + * is used for both the normal running in background state and the executing + * operations state. */ + SERVICE = 10, + + /** @hide Process is in the background running a receiver. Note that from the + * perspective of oom_adj, receivers run at a higher foreground level, but for our + * prioritization here that is not necessary and putting them below services means + * many fewer changes in some process states as they receive broadcasts. */ + RECEIVER = 11, + + /** @hide Same as {@link #PROCESS_STATE_TOP} but while device is sleeping. */ + TOP_SLEEPING = 12, + + /** @hide Process is in the background, but it can't restore its state so we want + * to try to avoid killing it. */ + HEAVY_WEIGHT = 13, + + /** @hide Process is in the background but hosts the home activity. */ + HOME = 14, + + /** @hide Process is in the background but hosts the last shown activity. */ + LAST_ACTIVITY = 15, + + /** @hide Process is being cached for later use and contains activities. */ + CACHED_ACTIVITY = 16, + + /** @hide Process is being cached for later use and is a client of another cached + * process that contains activities. */ + CACHED_ACTIVITY_CLIENT = 17, + + /** @hide Process is being cached for later use and has an activity that corresponds + * to an existing recent task. */ + CACHED_RECENT = 18, + + /** @hide Process is being cached for later use and is empty. */ + CACHED_EMPTY = 19, + + /** @hide Process does not exist. */ + NONEXISTENT = 20, + +} |