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 23namespace OHOS { 24namespace Msdp { 25namespace DeviceStatus { 26namespace Cooperate { 27class CooperateFree final : public ICooperateState { 28public: 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; 36 IDeviceManager& GetDeviceManager() 37 { 38 return env_->GetDeviceManager(); 39 } 40 41private: 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> initial, CooperateFree &parent); 51 static void RemoveChains(std::shared_ptr<Initial> initial); 52 53 private: 54 void OnStart(Context &context, const CooperateEvent &event); 55 void OnStop(Context &context, const CooperateEvent &event); 56 void OnDisable(Context &context, const CooperateEvent &event); 57 void OnAppClosed(Context &context, const CooperateEvent &event); 58 void OnRemoteStart(Context &context, const CooperateEvent &event); 59 void OnPointerEvent(Context &context, const CooperateEvent &event); 60 61 CooperateFree &parent_; 62 }; 63 64 void SetPointerVisible(Context &context); 65 void UnchainConnections(Context &context, const StopCooperateEvent &event) const; 66 67 IContext *env_ { nullptr }; 68 std::shared_ptr<Initial> initial_ { nullptr }; 69}; 70} // namespace Cooperate 71} // namespace DeviceStatus 72} // namespace Msdp 73} // namespace OHOS 74#endif // COOPERATE_FREE_H 75