1 /* 2 * Copyright (c) 2021 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_ABILITY_RUNTIME_PRIORITY_OBJECT_H 17 #define OHOS_ABILITY_RUNTIME_PRIORITY_OBJECT_H 18 19 #include <string> 20 #include <unistd.h> 21 22 #include "nocopyable.h" 23 #include "parcel.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 class PriorityObject : public Parcelable { 28 public: 29 PriorityObject() = default; 30 virtual ~PriorityObject() = default; 31 32 /** 33 * @brief Obtains the app pid. 34 * 35 * @return Returns the app pid. 36 */ 37 pid_t GetPid() const; 38 39 /** 40 * @brief Obtains the app max adj. 41 * 42 * @return Returns the app max adj. 43 */ 44 int32_t GetMaxAdj() const; 45 46 /** 47 * @brief Obtains the app cur adj. 48 * 49 * @return Returns the app cur adj. 50 */ 51 int32_t GetCurAdj() const; 52 53 /** 54 * @brief Obtains the app cur cgroup. 55 * 56 * @return Returns the app cur cgroup. 57 */ 58 int32_t GetCurCgroup() const; 59 60 /** 61 * @brief Obtains the app time level. 62 * 63 * @return Returns the app time level. 64 */ 65 int32_t GetTimeLevel() const; 66 67 /** 68 * @brief Obtains the ability visible status. 69 * 70 * @return Returns the ability visible status. 71 */ 72 bool GetVisibleStatus() const; 73 74 /** 75 * @brief Obtains the ability preceptible status. 76 * 77 * @return Returns the ability preceptible status. 78 */ 79 bool GetPerceptibleStatus() const; 80 81 /** 82 * @brief Setting pid for app. 83 * 84 * @param appName, the app pid. 85 */ 86 void SetPid(const pid_t pid); 87 88 /** 89 * @brief Setting max adj for app. 90 * 91 * @param appName, the app max adj. 92 */ 93 void SetMaxAdj(const int32_t maxAdj); 94 95 /** 96 * @brief Setting cur adj for app. 97 * 98 * @param appName, the app cur adj. 99 */ 100 void SetCurAdj(const int32_t curAdj); 101 102 /** 103 * @brief Setting cur cgroup for app. 104 * 105 * @param appName, the app cur cgroup. 106 */ 107 void SetCurCgroup(const int32_t curCgroup); 108 109 /** 110 * @brief Setting time level for app. 111 * 112 * @param appName, the app time level. 113 */ 114 void SetTimeLevel(const int32_t timeLevel); 115 116 /** 117 * @brief Setting visible status for ability. 118 * 119 * @param status, the visible status. 120 */ 121 void SetVisibleStatus(bool status); 122 123 /** 124 * @brief Setting perceptible status for ability. 125 * 126 * @param status, the perceptible status. 127 */ 128 void SetPerceptibleStatus(bool status); 129 130 /** 131 * @brief read this Sequenceable object from a Parcel. 132 * 133 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 134 * @return Returns true if read successed; returns false otherwise. 135 */ 136 bool ReadFromParcel(Parcel &parcel); 137 138 /** 139 * @brief Marshals this Sequenceable object into a Parcel. 140 * 141 * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled. 142 */ 143 virtual bool Marshalling(Parcel &parcel) const override; 144 145 /** 146 * @brief Unmarshals this Sequenceable object from a Parcel. 147 * 148 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 149 */ 150 static PriorityObject *Unmarshalling(Parcel &parcel); 151 152 private: 153 pid_t pid_ = 0; 154 int32_t maxAdj_ = 0; 155 int32_t curAdj_ = 0; 156 int32_t curCgroup_ = 0; 157 int32_t timeLevel_ = 0; 158 bool visibleStatus_ = false; 159 bool perceptibleStatus_ = false; 160 }; 161 } // namespace AppExecFwk 162 } // namespace OHOS 163 164 #endif // OHOS_ABILITY_RUNTIME_PRIORITY_OBJECT_H 165