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_SERVICES_TRANSIENT_TASK_INCLUDE_DELAY_SUSPEND_INFO_EX_H
17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_TRANSIENT_TASK_INCLUDE_DELAY_SUSPEND_INFO_EX_H
18 
19 #include <string>
20 
21 #include "delay_suspend_info.h"
22 #include "time_provider.h"
23 
24 namespace OHOS {
25 namespace BackgroundTaskMgr {
26 class DelaySuspendInfoEx : public DelaySuspendInfo {
27 public:
28     explicit DelaySuspendInfoEx(const int32_t& pid, const int32_t& requestId = -1, const int32_t& delaytime = 0);
29     ~DelaySuspendInfoEx() override = default;
30     int32_t GetRemainDelayTime();
31     int32_t GetAdvanceCallbackTime();
32     void StartAccounting();
33     void StopAccounting();
34     void Dump(std::string& result);
GetPid()35     inline int32_t GetPid() const
36     {
37         return pid_;
38     }
39 
SetPid(int32_t pid)40     inline void SetPid(int32_t pid)
41     {
42         pid_ = pid;
43     }
44 
GetBaseTime()45     inline int64_t GetBaseTime() const
46     {
47         return baseTime_;
48     }
49 
50 private:
51     const int32_t advanceTime_ = 6 * MSEC_PER_SEC; // 6s
52     int32_t pid_ {-1};
53     int64_t baseTime_ {0};
54     int64_t spendTime_ {0};
55 };
56 }  // namespace BackgroundTaskMgr
57 }  // namespace OHOS
58 #endif  // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_TRANSIENT_TASK_INCLUDE_DELAY_SUSPEND_INFO_EX_H