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_INNERKITS_MEM_MGR_CONSTANT_H 17 #define OHOS_MEMORY_MEMMGR_INNERKITS_MEM_MGR_CONSTANT_H 18 19 #include <string> 20 #include <map> 21 22 namespace OHOS { 23 namespace Memory { 24 // system app 25 constexpr int RECLAIM_PRIORITY_SYSTEM = -1000; 26 //ondemand system app 27 constexpr int RECLAIM_ONDEMAND_SYSTEM = -900; 28 // persist(killable) system app 29 constexpr int RECLAIM_PRIORITY_KILLABLE_SYSTEM = -800; 30 // foreground process priority 31 constexpr int RECLAIM_PRIORITY_FOREGROUND = 0; 32 // visible process priority 33 constexpr int RECLAIM_PRIORITY_VISIBLE = 50; 34 // perceived suspend delay case 35 constexpr int RECLAIM_PRIORITY_BG_SUSPEND_DELAY = 100; 36 // perceived background process priority 37 constexpr int RECLAIM_PRIORITY_BG_PERCEIVED = 200; 38 // background and connected by distribute device 39 constexpr int RECLAIM_PRIORITY_BG_DIST_DEVICE = 260; 40 // background priority 41 constexpr int RECLAIM_PRIORITY_BACKGROUND = 400; 42 // unknown process priority 43 constexpr int RECLAIM_PRIORITY_UNKNOWN = 1000; 44 45 enum class MemMgrErrorCode { 46 MEMMGR_SERVICE_ERR = 190900, 47 }; 48 49 const std::map<int, std::string> ReclaimPriorityMapping = { 50 { RECLAIM_PRIORITY_SYSTEM, "System" }, 51 { RECLAIM_ONDEMAND_SYSTEM, "OnDemand_system" }, 52 { RECLAIM_PRIORITY_KILLABLE_SYSTEM, "Persistent" }, 53 { RECLAIM_PRIORITY_FOREGROUND, "Foreground" }, 54 { RECLAIM_PRIORITY_VISIBLE, "visible" }, 55 { RECLAIM_PRIORITY_BG_SUSPEND_DELAY, "Suspend-delay" }, 56 { RECLAIM_PRIORITY_BG_PERCEIVED, "Perceived" }, 57 { RECLAIM_PRIORITY_BG_DIST_DEVICE, "Dist-device" }, 58 { RECLAIM_PRIORITY_BACKGROUND, "Background" }, 59 }; 60 61 const std::string RECLAIM_PRIORITY_UNKNOWN_DESC = "Undefined"; 62 std::string GetReclaimPriorityString(int32_t priority); 63 } // namespace Memory 64 } // namespace OHOS 65 #endif // OHOS_MEMORY_MEMMGR_INNERKITS_MEM_MGR_CONSTANT_H 66