• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 #ifndef COOPERATE_FREE_H
17 #define COOPERATE_FREE_H
18 
19 #include "nocopyable.h"
20 
21 #include "i_cooperate_state.h"
22 
23 namespace OHOS {
24 namespace Msdp {
25 namespace DeviceStatus {
26 namespace Cooperate {
27 class CooperateFree final : public ICooperateState {
28 public:
29     CooperateFree(IStateMachine &parent, IContext *env);
30     ~CooperateFree();
31     DISALLOW_COPY_AND_MOVE(CooperateFree);
32 
33     void OnEvent(Context &context, const CooperateEvent &event) override;
34     void OnEnterState(Context &context) override;
35     void OnLeaveState(Context &context) override;
GetDeviceManager()36     IDeviceManager& GetDeviceManager()
37     {
38         return env_->GetDeviceManager();
39     }
40 
41 private:
42     class Initial final : public ICooperateStep {
43     public:
44         Initial(CooperateFree &parent);
45         ~Initial() = default;
46 
47         void OnProgress(Context &context, const CooperateEvent &event) override;
48         void OnReset(Context &context, const CooperateEvent &event) override;
49 
50         static void BuildChains(std::shared_ptr<Initial> self, CooperateFree &parent);
51         static void RemoveChains(std::shared_ptr<Initial> self);
52         void OnProgressWithOptions(Context &context, const CooperateEvent &event) override;
53 
54     private:
55         void OnStart(Context &context, const CooperateEvent &event);
56         void OnStop(Context &context, const CooperateEvent &event);
57         void OnDisable(Context &context, const CooperateEvent &event);
58         void OnAppClosed(Context &context, const CooperateEvent &event);
59         void OnRemoteStart(Context &context, const CooperateEvent &event);
60         void OnPointerEvent(Context &context, const CooperateEvent &event);
61         void OnUpdateCooperateFlag(Context &context, const CooperateEvent &event);
62         void OnStartWithOptions(Context &context, const CooperateEvent &event);
63         void OnRemoteStartWithOptions(Context &context, const CooperateEvent &event);
64         void CooperateFail(Context &context, int32_t ret);
65         void InitiatorPointerVisible(bool visible);
66 
67         CooperateFree &parent_;
68     };
69 
70     void SetPointerVisible(Context &context);
71     void UnchainConnections(Context &context, const StopCooperateEvent &event) const;
72     void SimulateShowPointerEvent();
73 
74     IContext *env_ { nullptr };
75     std::shared_ptr<Initial> initial_ { nullptr };
76 };
77 } // namespace Cooperate
78 } // namespace DeviceStatus
79 } // namespace Msdp
80 } // namespace OHOS
81 #endif // COOPERATE_FREE_H
82