1 /* 2 * Copyright (c) 2022-2023 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_PROCESS_PRIORITY_INFO_H 17 #define OHOS_MEMORY_MEMMGR_PROCESS_PRIORITY_INFO_H 18 19 #include <set> 20 21 namespace OHOS { 22 namespace Memory { 23 constexpr int EXTENSION_STATUS_BIND_UNKOWN = 0; 24 constexpr int EXTENSION_STATUS_FG_BIND = 1; 25 constexpr int EXTENSION_STATUS_BG_BIND = 2; 26 constexpr int EXTENSION_STATUS_NO_BIND = 3; 27 28 class ProcessPriorityInfo { 29 public: 30 explicit ProcessPriorityInfo(pid_t pid, int bundleUid, int priority); 31 ProcessPriorityInfo(const ProcessPriorityInfo ©Process); 32 ~ProcessPriorityInfo(); 33 34 int uid_; 35 pid_t pid_; 36 int priority_; 37 bool isVisible_; 38 bool isRender_; 39 bool isFreground; // true means freground, false means background 40 bool isBackgroundRunning; 41 bool isSuspendDelay; 42 bool isEventStart; 43 bool isDistDeviceConnected; 44 bool isExtension; 45 int extensionBindStatus; // 0: unkown, 1:fg bind, 2:bg bind, 3:no bind 46 std::set<int32_t> extensionConnectors_; // contains all pid of connectors 47 std::set<int32_t> extensionProcessUids_; 48 std::set<int32_t> extensionConnectorUids_; 49 50 void SetPriority(int targetPriority); 51 int32_t ExtensionConnectorsCount(); 52 void AddExtensionConnector(int32_t pid); 53 void RemoveExtensionConnector(int32_t pid); 54 void AddExtensionProcessUid(int32_t uid); 55 void RemoveExtensionProcessUid(int32_t uid); 56 void AddExtensionConnectorUid(int32_t uid); 57 void RemoveExtensionConnectorUid(int32_t uid); 58 bool ContainsConnector(int32_t pid); 59 std::string ConnectorsToString(); 60 std::string ExtensionProcessUidToString(); 61 std::string ExtensionConnectorsUidToString(); 62 }; 63 } // namespace Memory 64 } // namespace OHOS 65 #endif // OHOS_MEMORY_MEMMGR_PROCESS_PRIORITY_INFO_H 66