1 /* 2 * Copyright (c) 2022 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 FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_DELAY_SUSPEND_INFO_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_DELAY_SUSPEND_INFO_H 18 19 #include <message_parcel.h> 20 21 namespace OHOS { 22 namespace BackgroundTaskMgr { 23 class DelaySuspendInfo : public Parcelable { 24 public: 25 26 /** 27 * @brief Unmarshals a purpose from a Parcel. 28 * 29 * @param parcel Indicates the parcel object for unmarshalling. 30 * @return The info of delay suspend. 31 */ 32 static std::shared_ptr<DelaySuspendInfo> Unmarshalling(Parcel& in); 33 34 /** 35 * @brief Marshals a purpose into a parcel. 36 * 37 * @param parcel Indicates the parcel object for marshalling. 38 * @return True if success, else false. 39 */ 40 bool Marshalling(Parcel& out) const override; 41 42 /** 43 * @brief Judge whether the request id is same. 44 * 45 * @param requestId Id use to judge. 46 * @return True if success, else false. 47 */ IsSameRequestId(int32_t requestId)48 inline bool IsSameRequestId(int32_t requestId) const 49 { 50 return requestId_ == requestId; 51 } 52 53 /** 54 * @brief Get the request id. 55 * 56 * @return Request id. 57 */ GetRequestId()58 inline int32_t GetRequestId() const 59 { 60 return requestId_; 61 } 62 63 /** 64 * @brief Get delay time. 65 * 66 * @return The delay time. 67 */ GetActualDelayTime()68 inline int32_t GetActualDelayTime() const 69 { 70 return actualDelayTime_; 71 } 72 73 /** 74 * @brief Set id of the request. 75 * 76 * @param id Id of the request. 77 */ SetRequestId(int32_t id)78 inline void SetRequestId(int32_t id) 79 { 80 requestId_ = id; 81 } 82 83 /** 84 * @brief Set the actual delay time. 85 * 86 * @param time The delay time. 87 */ SetActualDelayTime(int32_t time)88 inline void SetActualDelayTime(int32_t time) 89 { 90 actualDelayTime_ = time; 91 } 92 93 private: 94 bool ReadFromParcel(Parcel& in); 95 96 int32_t requestId_ {-1}; 97 int32_t actualDelayTime_ {0}; 98 }; 99 } // namespace BackgroundTaskMgr 100 } // namespace OHOS 101 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_DELAY_SUSPEND_INFO_H