• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_PLUGINS_EXT_INCLUDE_ISTATE_MANAGER_ADAPTER_H
16 #define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_PLUGINS_EXT_INCLUDE_ISTATE_MANAGER_ADAPTER_H
17 
18 #include <vector>
19 #include <memory>
20 
21 #include "event_handler.h"
22 #include "event_runner.h"
23 
24 #include "standby_service_errors.h"
25 #include "base_state.h"
26 #include "istrategy_manager_adapter.h"
27 
28 namespace OHOS {
29 namespace DevStandbyMgr {
30 class IConstraintManagerAdapter;
31 class BaseState;
32 struct ConstraintEvalParam;
33 class IStateManagerAdapter {
34 public:
35     virtual ~IStateManagerAdapter() = default;
36     virtual bool Init() = 0;
37     virtual bool UnInit() = 0;
38     virtual void HandleEvent(const StandbyMessage& message) = 0;
39 
40     virtual ErrCode StartEvalCurrentState(const ConstraintEvalParam& params) = 0;
41     virtual ErrCode EndEvalCurrentState(bool evalResult) = 0;
42 
43     virtual ErrCode TransitToState(uint32_t nextState) = 0;
44     virtual ErrCode TransitToStateInner(uint32_t nextState) = 0;
45     virtual void ShellDump(const std::vector<std::string>& argsInStr, std::string& result) = 0;
46 
47     virtual uint32_t GetCurState() = 0;
48     virtual uint32_t GetPreState() = 0;
49     virtual void BlockCurrentState() = 0;
50     virtual void UnblockCurrentState() = 0;
51     virtual void OnScreenOffHalfHour(bool scrOffHalfHourCtrl, bool repeated) = 0;
52     virtual void StopEvalution() = 0;
53     void SetEvalution(bool isEvalution);
54     bool IsEvalution();
55     bool IsScreenOn();
56     virtual int64_t GetScreenOffTimeStamp();
57 protected:
58     bool isEvalution_ {false};
59     bool isBlocked_ {false};
60     std::shared_ptr<BaseState> preStatePtr_ {nullptr};
61     std::shared_ptr<BaseState> curStatePtr_ {nullptr};
62     std::shared_ptr<AppExecFwk::EventHandler> handler_ {nullptr};
63     std::shared_ptr<IConstraintManagerAdapter> constraintManager_ {nullptr};
64     std::shared_ptr<IStrategyManagerAdapter> strategyManager_ {nullptr};
65     int64_t screenOffTimeStamp_ {0};
66     uint64_t scrOffHalfHourTimerId_ {0};
67     bool isScreenOn_ {false};
68     bool scrOffHalfHourCtrl_ {false};
69 };
70 }  // namespace DevStandbyMgr
71 }  // namespace OHOS
72 #endif  // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_PLUGINS_EXT_INCLUDE_ISTATE_MANAGER_ADAPTER_H
73