• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_MEMORY_MEMMGR_RECALIM_PRIORITY_CONSTANTS_H
17 #define OHOS_MEMORY_MEMMGR_RECALIM_PRIORITY_CONSTANTS_H
18 
19 namespace OHOS {
20 namespace Memory {
21 // system app
22 constexpr int RECLAIM_PRIORITY_SYSTEM = -1000;
23 // killable system app
24 constexpr int RECLAIM_PRIORITY_KILLABLE_SYSTEM = -800;
25 // foreground process priority
26 constexpr int RECLAIM_PRIORITY_FOREGROUND = 0;
27 // visible process priority
28 constexpr int RECLAIM_PRIORITY_VISIBLE = 1;
29 // perceived suspend delay case
30 constexpr int RECLAIM_PRIORITY_BG_SUSPEND_DELAY = 100;
31 // extension and a bg process bind to it
32 constexpr int RECLAIM_PRIORITY_FG_BIND_EXTENSION = 100;
33 // perceived background process priority
34 constexpr int RECLAIM_PRIORITY_BG_PERCEIVED = 200;
35 // extension and a bg process bind to it (reserved, now unsed)
36 constexpr int RECLAIM_PRIORITY_BG_BIND_EXTENSION = 240;
37 // background and connected by distribute device
38 constexpr int RECLAIM_PRIORITY_BG_DIST_DEVICE = 260;
39 // extension and no process bind to it
40 constexpr int RECLAIM_PRIORITY_NO_BIND_EXTENSION = 400;
41 // background priority
42 constexpr int RECLAIM_PRIORITY_BACKGROUND = 400;
43 // frozen process priority
44 constexpr int RECLAIM_PRIORITY_FROZEN = 600;
45 // suspend process priority
46 constexpr int RECLAIM_PRIORITY_SUSPEND = 800;
47 // empty process priority
48 constexpr int RECLAIM_PRIORITY_EMPTY = 900;
49 // unknown process priority
50 constexpr int RECLAIM_PRIORITY_UNKNOWN = 1000;
51 
52 constexpr int RECLAIM_PRIORITY_MIN = -1000;
53 constexpr int RECLAIM_PRIORITY_MAX = 1000;
54 
55 const int USER_ID_SHIFT = 200000;
56 #define GET_OS_ACCOUNT_ID_BY_UID(bundleUid) ((bundleUid) / USER_ID_SHIFT)
57 
58 const int IGNORE_PID = -1;
59 
60 enum class AppStateUpdateReason {
61     CREATE_PROCESS = 0,
62     PROCESS_READY,
63     FOREGROUND,
64     BACKGROUND,
65     SUSPEND_DELAY_START,
66     SUSPEND_DELAY_END,
67     BACKGROUND_RUNNING_START,
68     BACKGROUND_RUNNING_END,
69     EVENT_START,
70     EVENT_END,
71     APPLICATION_SUSPEND,
72     PROCESS_TERMINATED,
73     OS_ACCOUNT_CHANGED,
74     DIST_DEVICE_CONNECTED,
75     DIST_DEVICE_DISCONNECTED,
76     BIND_EXTENSION,
77     UNBIND_EXTENSION,
78 };
79 
80 enum class BundleState {
81     STATE_DEFAULT = 0,
82     STATE_WAITING_FOR_KILL,
83 };
84 } // namespace Memory
85 } // namespace OHOS
86 #endif // OHOS_MEMORY_MEMMGR_RECALIM_PRIORITY_CONSTANTS_H
87