• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <string>
21 #include <map>
22 
23 #include "reclaim_strategy_constants.h"
24 
25 namespace OHOS {
26 namespace Memory {
27 constexpr int EXTENSION_STATUS_BIND_UNKOWN = 0;
28 constexpr int EXTENSION_STATUS_FG_BIND = 1;
29 constexpr int EXTENSION_STATUS_BG_BIND = 2;
30 constexpr int EXTENSION_STATUS_NO_BIND = 3;
31 const std::string DEFAULT_PROCESS_NAME = "";
32 
33 class ProcessPriorityInfo {
34 public:
35     explicit ProcessPriorityInfo(pid_t pid, int bundleUid, int priority, bool isImportant = false);
36     ProcessPriorityInfo(const ProcessPriorityInfo &copyProcess);
37     ~ProcessPriorityInfo();
38 
39     int uid_;
40     pid_t pid_;
41     int priority_;
42     int priorityIfImportant_; // only enable when configured in xml, and should not be changed after read from xml
43     bool isImportant_; // true means important background, false means normal background
44     bool isVisible_;
45     bool isRender_;
46     bool isFreground; // true means freground, false means background
47     bool isBackgroundRunning;
48     bool isSuspendDelay;
49     bool isEventStart;
50     bool isDistDeviceConnected;
51     bool isExtension_;
52     bool hasUI_ = false;
53     int extensionBindStatus; // 0: unkown, 1:fg bind, 2:bg bind, 3:no bind
54     std::map<int32_t, int32_t> procsBindToMe_;
55     std::map<int32_t, int32_t> procsBindFromMe_;
56 
57     void SetPriority(int targetPriority);
58     int32_t ExtensionConnectorsCount();
59 
60     void ProcBindToMe(int32_t pid, int32_t uid);
61     void ProcUnBindToMe(int32_t pid);
62 
63     void ProcBindFromMe(int32_t pid, int32_t uid);
64     void ProcUnBindFromMe(int32_t pid);
65 
66     std::string ProcsBindToMe();
67     std::string ProcsBindFromMe();
68 
69     bool IsAbilityStarting() const;
70     void SetIsAbilityStarting(bool isAbilityStarting); // use to set value of isAbilityStarting_
71 
72     void SetStartingAbilityTime(int64_t time);
73     int64_t GetStartingAbilityTime() const;
74 
75 private:
76     bool isAbilityStarting_; // true means proc current is starting ability, false means not
77     int64_t startingAbilityTime_;
78 };
79 } // namespace Memory
80 } // namespace OHOS
81 #endif // OHOS_MEMORY_MEMMGR_PROCESS_PRIORITY_INFO_H
82