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 INTENTION_MANAGER_H 17 #define INTENTION_MANAGER_H 18 19 #include <mutex> 20 21 #include "singleton.h" 22 23 #include "cooperate_client.h" 24 #include "drag_client.h" 25 #include "drag_data.h" 26 #include "drag_manager_impl.h" 27 #include "i_event_listener.h" 28 #include "socket_client.h" 29 #include "stationary_client.h" 30 #include "tunnel_client.h" 31 32 namespace OHOS { 33 namespace Msdp { 34 namespace DeviceStatus { 35 class IntentionManager { 36 DECLARE_SINGLETON(IntentionManager); 37 using CooperateMsgInfoCallback = std::function<void(const std::string&, const CoordinationMsgInfo&)>; 38 39 public: 40 DISALLOW_MOVE(IntentionManager); 41 int32_t SubscribeCallback(Type type, ActivityEvent event, ReportLatencyNs latency, 42 sptr<IRemoteDevStaCallback> callback); 43 int32_t UnsubscribeCallback(Type type, ActivityEvent event, sptr<IRemoteDevStaCallback> callback); 44 Data GetDeviceStatusData(const Type type); 45 int32_t RegisterCoordinationListener( 46 std::shared_ptr<ICoordinationListener> listener, bool isCompatible = false); 47 int32_t UnregisterCoordinationListener( 48 std::shared_ptr<ICoordinationListener> listener, bool isCompatible = false); 49 int32_t PrepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible = false); 50 int32_t UnprepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible = false); 51 int32_t ActivateCoordination(const std::string &remoteNetworkId, int32_t startDeviceId, 52 CooperateMsgInfoCallback callback, bool isCompatible = false); 53 int32_t DeactivateCoordination(bool isUnchained, CooperateMsgInfoCallback callback, bool isCompatible = false); 54 int32_t GetCoordinationState(const std::string &networkId, std::function<void(bool)> callback, 55 bool isCompatible = false); 56 int32_t GetCoordinationState(const std::string &udId, bool &state); 57 int32_t RegisterEventListener(const std::string &networkId, std::shared_ptr<IEventListener> listener); 58 int32_t UnregisterEventListener(const std::string &networkId, std::shared_ptr<IEventListener> listener = nullptr); 59 int32_t UpdateDragStyle(DragCursorStyle style, int32_t eventId = -1); 60 int32_t StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener); 61 int32_t StopDrag(const DragDropResult &dropResult); 62 int32_t GetDragTargetPid(); 63 int32_t GetUdKey(std::string &udKey); 64 int32_t AddDraglistener(DragListenerPtr listener, bool isJsCaller = false); 65 int32_t RemoveDraglistener(DragListenerPtr listener, bool isJsCaller = false); 66 int32_t AddSubscriptListener(SubscriptListenerPtr listener); 67 int32_t RemoveSubscriptListener(SubscriptListenerPtr listener); 68 int32_t SetDragWindowVisible(bool visible, bool isForce = false); 69 int32_t GetShadowOffset(ShadowOffset &shadowOffset); 70 int32_t UpdateShadowPic(const ShadowInfo &shadowInfo); 71 int32_t GetDragData(DragData &dragData); 72 int32_t GetDragState(DragState &dragState); 73 int32_t AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener); 74 int32_t RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener = nullptr); 75 int32_t UpdatePreviewStyle(const PreviewStyle &previewStyle); 76 int32_t UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle, const PreviewAnimation &animation); 77 int32_t RotateDragWindowSync(const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr); 78 int32_t GetDragSummary(std::map<std::string, int64_t> &summarys, bool isJsCaller = false); 79 int32_t EnterTextEditorArea(bool enable); 80 int32_t GetDragAction(DragAction &dragAction); 81 int32_t GetExtraInfo(std::string &extraInfo); 82 int32_t AddPrivilege(); 83 int32_t EraseMouseIcon(); 84 int32_t SetDragWindowScreenId(uint64_t displayId, uint64_t screenId); 85 int32_t SetMouseDragMonitorState(bool state); 86 void OnConnected(); 87 void OnDisconnected(); 88 89 private: 90 void InitClient(); 91 void InitMsgHandler(); 92 93 std::mutex mutex_; 94 std::shared_ptr<TunnelClient> tunnel_ { nullptr }; 95 std::unique_ptr<SocketClient> client_ { nullptr }; 96 CooperateClient cooperate_; 97 DragClient drag_; 98 StationaryClient stationary_; 99 bool isScreenRotation_ { false }; 100 std::vector<std::string> foldRotatePolicys_ {}; 101 }; 102 103 #define INTER_MGR_IMPL OHOS::Singleton<IntentionManager>::GetInstance() 104 } // namespace DeviceStatus 105 } // namespace Msdp 106 } // namespace OHOS 107 #endif // INTENTION_MANAGER_H 108