1 /*
2  * Copyright (c) 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 FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_STANDBY_STATE_CHANGE_CALLBACK_H
17 #define FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_STANDBY_STATE_CHANGE_CALLBACK_H
18 #ifdef  DEVICE_STANDBY_ENABLE
19 #include "standby_service_subscriber_stub.h"
20 #include "work_queue_manager.h"
21 
22 namespace OHOS {
23 namespace WorkScheduler {
24 class WorkStandbyStateChangeCallback : public DevStandbyMgr::StandbyServiceSubscriberStub {
25 public:
26     explicit WorkStandbyStateChangeCallback(std::shared_ptr<WorkQueueManager> workQueueManager);
27     ~WorkStandbyStateChangeCallback() override = default;
28 
29     /*
30     * @brief callback when device_standby state change.
31     *
32     * @param napped current state is nap or not.
33     * @param sleeping current state is sleep or not.
34     */
35     void OnDeviceIdleMode(bool napped, bool sleeping) override;
36 
37    /*
38     * @brief callback when device_standby allowList change.
39     *
40     * @param uid of application who apply allowList.
41     * @param name bundleName of application who apply allowList.
42     * @param allowType allowType mean strategy type, such as WORK_SCHEDULER.
43     * @param added true mean starting allow, false mean ending allow.
44     */
45     void OnAllowListChanged(int32_t uid, const std::string& name, uint32_t allowType, bool added) override;
46 private:
47     std::shared_ptr<WorkQueueManager> workQueueManager_;
48 };
49 }  // namespace WorkScheduler
50 }  // namespace OHOS
51 #endif
52 #endif  // FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_STANDBY_STATE_CHANGE_CALLBACK_H