1 /* 2 * Copyright (c) 2024 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 #include "mem_mgr_constant.h" 17 18 namespace OHOS { 19 namespace Memory { GetReclaimPriorityString(int32_t priority)20std::string GetReclaimPriorityString(int32_t priority) 21 { 22 if (priority < RECLAIM_PRIORITY_SYSTEM || priority > RECLAIM_PRIORITY_UNKNOWN) { 23 return RECLAIM_PRIORITY_UNKNOWN_DESC; 24 } else if (priority < RECLAIM_ONDEMAND_SYSTEM) { 25 return ReclaimPriorityMapping.at(RECLAIM_PRIORITY_SYSTEM); 26 } else if (priority < RECLAIM_PRIORITY_KILLABLE_SYSTEM) { 27 return ReclaimPriorityMapping.at(RECLAIM_ONDEMAND_SYSTEM); 28 } else if (priority < RECLAIM_PRIORITY_FOREGROUND) { 29 return ReclaimPriorityMapping.at(RECLAIM_PRIORITY_KILLABLE_SYSTEM); 30 } else if (priority < RECLAIM_PRIORITY_VISIBLE) { 31 return ReclaimPriorityMapping.at(RECLAIM_PRIORITY_FOREGROUND); 32 } else if (priority < RECLAIM_PRIORITY_BG_SUSPEND_DELAY) { 33 return ReclaimPriorityMapping.at(RECLAIM_PRIORITY_VISIBLE); 34 } else if (priority < RECLAIM_PRIORITY_BG_PERCEIVED) { 35 return ReclaimPriorityMapping.at(RECLAIM_PRIORITY_BG_SUSPEND_DELAY); 36 } else if (priority < RECLAIM_PRIORITY_BG_DIST_DEVICE) { 37 return ReclaimPriorityMapping.at(RECLAIM_PRIORITY_BG_PERCEIVED); 38 } else if (priority < RECLAIM_PRIORITY_BACKGROUND) { 39 return ReclaimPriorityMapping.at(RECLAIM_PRIORITY_BG_DIST_DEVICE); 40 } else { 41 return ReclaimPriorityMapping.at(RECLAIM_PRIORITY_BACKGROUND); 42 } 43 } 44 } // namespace Memory 45 } // namespace OHOS 46