• 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;
GetOsAccountIdByUid(int bundleUid)56 inline int GetOsAccountIdByUid(int bundleUid)
57 {
58     return (bundleUid / USER_ID_SHIFT);
59 }
60 
61 const int IGNORE_PID = -1;
62 
63 enum class AppStateUpdateReason {
64     CREATE_PROCESS = 0,
65     PROCESS_READY,
66     FOREGROUND,
67     BACKGROUND,
68     SUSPEND_DELAY_START,
69     SUSPEND_DELAY_END,
70     BACKGROUND_RUNNING_START,
71     BACKGROUND_RUNNING_END,
72     EVENT_START,
73     EVENT_END,
74     APPLICATION_SUSPEND,
75     PROCESS_TERMINATED,
76     OS_ACCOUNT_CHANGED,
77     DIST_DEVICE_CONNECTED,
78     DIST_DEVICE_DISCONNECTED,
79     BIND_EXTENSION,
80     UNBIND_EXTENSION,
81     UPDATE_EXTENSION_PROCESS,
82     VISIBLE,
83     UN_VISIBLE,
84     RENDER_CREATE_PROCESS,
85 };
86 
87 enum class BundleState {
88     STATE_DEFAULT = 0,
89     STATE_WAITING_FOR_KILL,
90 };
91 } // namespace Memory
92 } // namespace OHOS
93 #endif // OHOS_MEMORY_MEMMGR_RECALIM_PRIORITY_CONSTANTS_H
94