1 /* 2 * Copyright (c) 2021-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 "priority_object.h" 17 18 #include "hilog_tag_wrapper.h" 19 20 namespace OHOS { 21 namespace AppExecFwk { GetPid() const22pid_t PriorityObject::GetPid() const 23 { 24 return pid_; 25 } 26 GetMaxAdj() const27int32_t PriorityObject::GetMaxAdj() const 28 { 29 return maxAdj_; 30 } 31 GetCurAdj() const32int32_t PriorityObject::GetCurAdj() const 33 { 34 return curAdj_; 35 } 36 GetCurCgroup() const37int32_t PriorityObject::GetCurCgroup() const 38 { 39 return curCgroup_; 40 } 41 GetTimeLevel() const42int32_t PriorityObject::GetTimeLevel() const 43 { 44 return timeLevel_; 45 } 46 GetVisibleStatus() const47bool PriorityObject::GetVisibleStatus() const 48 { 49 return visibleStatus_; 50 } 51 GetPerceptibleStatus() const52bool PriorityObject::GetPerceptibleStatus() const 53 { 54 return perceptibleStatus_; 55 } 56 SetPid(const pid_t pid)57void PriorityObject::SetPid(const pid_t pid) 58 { 59 pid_ = pid; 60 } 61 SetMaxAdj(const int32_t maxAdj)62void PriorityObject::SetMaxAdj(const int32_t maxAdj) 63 { 64 maxAdj_ = maxAdj; 65 } 66 SetCurAdj(const int32_t curAdj)67void PriorityObject::SetCurAdj(const int32_t curAdj) 68 { 69 curAdj_ = curAdj; 70 } 71 SetCurCgroup(const int32_t curCgroup)72void PriorityObject::SetCurCgroup(const int32_t curCgroup) 73 { 74 curCgroup_ = curCgroup; 75 } 76 SetTimeLevel(const int32_t timeLevel)77void PriorityObject::SetTimeLevel(const int32_t timeLevel) 78 { 79 timeLevel_ = timeLevel; 80 } 81 SetVisibleStatus(bool status)82void PriorityObject::SetVisibleStatus(bool status) 83 { 84 visibleStatus_ = status; 85 } 86 SetPerceptibleStatus(bool status)87void PriorityObject::SetPerceptibleStatus(bool status) 88 { 89 perceptibleStatus_ = status; 90 } 91 Marshalling(Parcel & parcel) const92bool PriorityObject::Marshalling(Parcel &parcel) const 93 { 94 if (!parcel.WriteInt32(pid_)) { 95 return false; 96 } 97 if (!parcel.WriteInt32(maxAdj_)) { 98 return false; 99 } 100 if (!parcel.WriteInt32(curAdj_)) { 101 return false; 102 } 103 if (!parcel.WriteInt32(curCgroup_)) { 104 return false; 105 } 106 if (!parcel.WriteInt32(timeLevel_)) { 107 return false; 108 } 109 return true; 110 } 111 ReadFromParcel(Parcel & parcel)112bool PriorityObject::ReadFromParcel(Parcel &parcel) 113 { 114 if (!parcel.ReadInt32(pid_)) { 115 return false; 116 } 117 if (!parcel.ReadInt32(maxAdj_)) { 118 return false; 119 } 120 if (!parcel.ReadInt32(curAdj_)) { 121 return false; 122 } 123 if (!parcel.ReadInt32(curCgroup_)) { 124 return false; 125 } 126 if (!parcel.ReadInt32(timeLevel_)) { 127 return false; 128 } 129 return true; 130 } 131 Unmarshalling(Parcel & parcel)132PriorityObject *PriorityObject::Unmarshalling(Parcel &parcel) 133 { 134 PriorityObject *priorityObject = new (std::nothrow) PriorityObject(); 135 if (priorityObject && !priorityObject->ReadFromParcel(parcel)) { 136 TAG_LOGW(AAFwkTag::APPMGR, "failed, because ReadFromParcel failed"); 137 delete priorityObject; 138 priorityObject = nullptr; 139 } 140 return priorityObject; 141 } 142 } // namespace AppExecFwk 143 } // namespace OHOS 144