1 /* 2 * Copyright (c) 2023-2025 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 I_COOPERATE_H 17 #define I_COOPERATE_H 18 19 #include <memory> 20 #include <string> 21 22 namespace OHOS { 23 namespace Msdp { 24 namespace DeviceStatus { 25 struct Coordinate { 26 int32_t x; 27 int32_t y; 28 }; 29 using NormalizedCoordinate = Coordinate; 30 31 constexpr uint32_t COOPERATE_FLAG_HIDE_CURSOR { 0x1 }; 32 constexpr uint32_t COOPERATE_FLAG_FREEZE_CURSOR { 0x2 }; // 在穿越到对端时,不注入事件,对本端无效 33 34 struct StartCooperateData { 35 uint32_t flag; 36 uint32_t priv; 37 }; 38 using RemoteStartCooperateData = StartCooperateData; 39 40 struct CooperateOptions { 41 int32_t displayX { -1 }; 42 int32_t displayY { -1 }; 43 int32_t displayId { -1 }; 44 }; 45 using NormalizedCooperateOptions = CooperateOptions; 46 47 struct CooperateInfo { 48 NormalizedCoordinate normalizedCoords; 49 CooperateOptions cooperateOptions; // To support activateCooperateWithOptions 50 }; 51 52 class ICooperateObserver { 53 public: 54 ICooperateObserver() = default; 55 virtual ~ICooperateObserver() = default; 56 57 virtual bool IsAllowCooperate() = 0; 58 virtual void OnStartCooperate(StartCooperateData &data) = 0; 59 virtual void OnRemoteStartCooperate(RemoteStartCooperateData &data) = 0; 60 virtual void OnStopCooperate(const std::string &remoteNetworkId) = 0; 61 virtual void OnTransitionOut(const std::string &remoteNetworkId, const CooperateInfo &cooperateInfo) = 0; 62 virtual void OnTransitionIn(const std::string &remoteNetworkId, const CooperateInfo &cooperateInfo) = 0; 63 virtual void OnBack(const std::string &remoteNetworkId, const CooperateInfo &cooperateInfo) = 0; 64 virtual void OnRelay(const std::string &remoteNetworkId, const CooperateInfo &cooperateInfo) = 0; 65 virtual void OnReset() = 0; CloseDistributedFileConnection(const std::string & remoteNetworkId)66 virtual void CloseDistributedFileConnection(const std::string &remoteNetworkId) {} 67 }; 68 69 class ICooperate { 70 public: 71 ICooperate() = default; 72 virtual ~ICooperate() = default; 73 74 virtual void AddObserver(std::shared_ptr<ICooperateObserver> observer) = 0; 75 virtual void RemoveObserver(std::shared_ptr<ICooperateObserver> observer) = 0; 76 77 virtual int32_t RegisterListener(int32_t pid) = 0; 78 virtual int32_t UnregisterListener(int32_t pid) = 0; 79 virtual int32_t RegisterHotAreaListener(int32_t pid) = 0; 80 virtual int32_t UnregisterHotAreaListener(int32_t pid) = 0; 81 82 virtual int32_t Enable(int32_t tokenId, int32_t pid, int32_t userData) = 0; 83 virtual int32_t Disable(int32_t pid, int32_t userData) = 0; 84 virtual int32_t Start(int32_t pid, int32_t userData, 85 const std::string &remoteNetworkId, int32_t startDeviceId, int32_t uid = 0) = 0; 86 virtual int32_t Stop(int32_t pid, int32_t userData, bool isUnchained) = 0; 87 virtual int32_t StartWithOptions(int32_t pid, int32_t userData, const std::string &remoteNetworkId, 88 int32_t startDeviceId, const NormalizedCooperateOptions &cooperateOptions) = 0; 89 90 virtual int32_t GetCooperateState(int32_t pid, int32_t userData, const std::string &networkId) = 0; 91 virtual int32_t Update(uint32_t mask, uint32_t flag) = 0; 92 93 virtual int32_t RegisterEventListener(int32_t pid, const std::string &networkId) = 0; 94 virtual int32_t UnregisterEventListener(int32_t pid, const std::string &networkId) = 0; 95 virtual int32_t GetCooperateState(const std::string &udId, bool &state) = 0; 96 virtual int32_t SetDamplingCoefficient(uint32_t direction, double coefficient) = 0; 97 virtual void Dump(int32_t fd) = 0; 98 }; 99 } // namespace DeviceStatus 100 } // namespace Msdp 101 } // namespace OHOS 102 #endif // I_COOPERATE_H 103