1 /*
2 * Copyright (c) 2022-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 #include "interaction_manager.h"
17
18 #include "devicestatus_define.h"
19 #include "drag_data.h"
20 #include "intention_manager.h"
21
22 namespace OHOS {
23 namespace Msdp {
24 namespace DeviceStatus {
25 using CooperateMsgInfoCallback = std::function<void(const std::string&, const CoordinationMsgInfo&)>;
26 InteractionManager *InteractionManager::instance_ = new (std::nothrow) InteractionManager();
27
GetInstance()28 InteractionManager *InteractionManager::GetInstance()
29 {
30 return instance_;
31 }
32
RegisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,bool isCompatible)33 int32_t InteractionManager::RegisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,
34 bool isCompatible)
35 {
36 return INTER_MGR_IMPL.RegisterCoordinationListener(listener, isCompatible);
37 }
38
UnregisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,bool isCompatible)39 int32_t InteractionManager::UnregisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,
40 bool isCompatible)
41 {
42 return INTER_MGR_IMPL.UnregisterCoordinationListener(listener, isCompatible);
43 }
44
PrepareCoordination(CooperateMsgInfoCallback callback,bool isCompatible)45 int32_t InteractionManager::PrepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible)
46 {
47 return INTER_MGR_IMPL.PrepareCoordination(callback, isCompatible);
48 }
49
UnprepareCoordination(CooperateMsgInfoCallback callback,bool isCompatible)50 int32_t InteractionManager::UnprepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible)
51 {
52 return INTER_MGR_IMPL.UnprepareCoordination(callback, isCompatible);
53 }
54
ActivateCoordination(const std::string & remoteNetworkId,int32_t startDeviceId,CooperateMsgInfoCallback callback,bool isCompatible)55 int32_t InteractionManager::ActivateCoordination(const std::string &remoteNetworkId, int32_t startDeviceId,
56 CooperateMsgInfoCallback callback, bool isCompatible)
57 {
58 return INTER_MGR_IMPL.ActivateCoordination(remoteNetworkId, startDeviceId, callback, isCompatible);
59 }
60
DeactivateCoordination(bool isUnchained,CooperateMsgInfoCallback callback,bool isCompatible)61 int32_t InteractionManager::DeactivateCoordination(bool isUnchained, CooperateMsgInfoCallback callback,
62 bool isCompatible)
63 {
64 return INTER_MGR_IMPL.DeactivateCoordination(isUnchained, callback, isCompatible);
65 }
66
GetCoordinationState(const std::string & networkId,std::function<void (bool)> callback,bool isCompatible)67 int32_t InteractionManager::GetCoordinationState(
68 const std::string &networkId, std::function<void(bool)> callback, bool isCompatible)
69 {
70 return INTER_MGR_IMPL.GetCoordinationState(networkId, callback, isCompatible);
71 }
72
GetCoordinationState(const std::string & udId,bool & state)73 int32_t InteractionManager::GetCoordinationState(const std::string &udId, bool &state)
74 {
75 return INTER_MGR_IMPL.GetCoordinationState(udId, state);
76 }
77
RegisterEventListener(const std::string & networkId,std::shared_ptr<IEventListener> listener)78 int32_t InteractionManager::RegisterEventListener(const std::string &networkId,
79 std::shared_ptr<IEventListener> listener)
80 {
81 #ifdef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
82 return INTER_MGR_IMPL.RegisterEventListener(networkId, listener);
83 #else
84 return RET_OK;
85 #endif // OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
86 }
87
UnregisterEventListener(const std::string & networkId,std::shared_ptr<IEventListener> listener)88 int32_t InteractionManager::UnregisterEventListener(const std::string &networkId,
89 std::shared_ptr<IEventListener> listener)
90 {
91 #ifdef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
92 return INTER_MGR_IMPL.UnregisterEventListener(networkId, listener);
93 #else
94 return RET_OK;
95 #endif // OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
96 }
97
UpdateDragStyle(DragCursorStyle style,int32_t eventId)98 int32_t InteractionManager::UpdateDragStyle(DragCursorStyle style, int32_t eventId)
99 {
100 return INTER_MGR_IMPL.UpdateDragStyle(style, eventId);
101 }
102
StartDrag(const DragData & dragData,std::shared_ptr<IStartDragListener> listener)103 int32_t InteractionManager::StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener)
104 {
105 return INTER_MGR_IMPL.StartDrag(dragData, listener);
106 }
107
StopDrag(const DragDropResult & dropResult)108 int32_t InteractionManager::StopDrag(const DragDropResult &dropResult)
109 {
110 return INTER_MGR_IMPL.StopDrag(dropResult);
111 }
112
GetDragTargetPid()113 int32_t InteractionManager::GetDragTargetPid()
114 {
115 return INTER_MGR_IMPL.GetDragTargetPid();
116 }
117
GetUdKey(std::string & udKey)118 int32_t InteractionManager::GetUdKey(std::string &udKey)
119 {
120 return INTER_MGR_IMPL.GetUdKey(udKey);
121 }
122
AddDraglistener(DragListenerPtr listener,bool isJsCaller)123 int32_t InteractionManager::AddDraglistener(DragListenerPtr listener, bool isJsCaller)
124 {
125 return INTER_MGR_IMPL.AddDraglistener(listener, isJsCaller);
126 }
127
RemoveDraglistener(DragListenerPtr listener,bool isJsCaller)128 int32_t InteractionManager::RemoveDraglistener(DragListenerPtr listener, bool isJsCaller)
129 {
130 return INTER_MGR_IMPL.RemoveDraglistener(listener, isJsCaller);
131 }
132
AddSubscriptListener(SubscriptListenerPtr listener)133 int32_t InteractionManager::AddSubscriptListener(SubscriptListenerPtr listener)
134 {
135 return INTER_MGR_IMPL.AddSubscriptListener(listener);
136 }
137
RemoveSubscriptListener(SubscriptListenerPtr listener)138 int32_t InteractionManager::RemoveSubscriptListener(SubscriptListenerPtr listener)
139 {
140 return INTER_MGR_IMPL.RemoveSubscriptListener(listener);
141 }
142
SetDragWindowVisible(bool visible,bool isForce)143 int32_t InteractionManager::SetDragWindowVisible(bool visible, bool isForce)
144 {
145 return INTER_MGR_IMPL.SetDragWindowVisible(visible, isForce);
146 }
147
GetShadowOffset(int32_t & offsetX,int32_t & offsetY,int32_t & width,int32_t & height)148 int32_t InteractionManager::GetShadowOffset(int32_t &offsetX, int32_t &offsetY, int32_t &width, int32_t &height)
149 {
150 ShadowOffset shadowOffset;
151 int32_t ret = INTER_MGR_IMPL.GetShadowOffset(shadowOffset);
152 offsetX = shadowOffset.offsetX;
153 offsetY = shadowOffset.offsetY;
154 width = shadowOffset.width;
155 height = shadowOffset.height;
156 return ret;
157 }
158
UpdateShadowPic(const ShadowInfo & shadowInfo)159 int32_t InteractionManager::UpdateShadowPic(const ShadowInfo &shadowInfo)
160 {
161 return INTER_MGR_IMPL.UpdateShadowPic(shadowInfo);
162 }
163
GetDragData(DragData & dragData)164 int32_t InteractionManager::GetDragData(DragData &dragData)
165 {
166 return INTER_MGR_IMPL.GetDragData(dragData);
167 }
168
GetDragState(DragState & dragState)169 int32_t InteractionManager::GetDragState(DragState &dragState)
170 {
171 return INTER_MGR_IMPL.GetDragState(dragState);
172 }
173
AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener)174 int32_t InteractionManager::AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener)
175 {
176 return INTER_MGR_IMPL.AddHotAreaListener(listener);
177 }
178
RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener)179 int32_t InteractionManager::RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener)
180 {
181 return INTER_MGR_IMPL.RemoveHotAreaListener(listener);
182 }
183
UpdatePreviewStyle(const PreviewStyle & previewStyle)184 int32_t InteractionManager::UpdatePreviewStyle(const PreviewStyle &previewStyle)
185 {
186 return INTER_MGR_IMPL.UpdatePreviewStyle(previewStyle);
187 }
188
UpdatePreviewStyleWithAnimation(const PreviewStyle & previewStyle,const PreviewAnimation & animation)189 int32_t InteractionManager::UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle,
190 const PreviewAnimation &animation)
191 {
192 return INTER_MGR_IMPL.UpdatePreviewStyleWithAnimation(previewStyle, animation);
193 }
194
RotateDragWindowSync(const std::shared_ptr<Rosen::RSTransaction> & rsTransaction)195 int32_t InteractionManager::RotateDragWindowSync(const std::shared_ptr<Rosen::RSTransaction>& rsTransaction)
196 {
197 return INTER_MGR_IMPL.RotateDragWindowSync(rsTransaction);
198 }
199
SetDragWindowScreenId(uint64_t displayId,uint64_t screenId)200 int32_t InteractionManager::SetDragWindowScreenId(uint64_t displayId, uint64_t screenId)
201 {
202 return INTER_MGR_IMPL.SetDragWindowScreenId(displayId, screenId);
203 }
204
GetDragSummary(std::map<std::string,int64_t> & summarys,bool isJsCaller)205 int32_t InteractionManager::GetDragSummary(std::map<std::string, int64_t> &summarys, bool isJsCaller)
206 {
207 return INTER_MGR_IMPL.GetDragSummary(summarys, isJsCaller);
208 }
209
GetDragAction(DragAction & dragAction)210 int32_t InteractionManager::GetDragAction(DragAction &dragAction)
211 {
212 return INTER_MGR_IMPL.GetDragAction(dragAction);
213 }
214
EnterTextEditorArea(bool enable)215 int32_t InteractionManager::EnterTextEditorArea(bool enable)
216 {
217 return INTER_MGR_IMPL.EnterTextEditorArea(enable);
218 }
219
GetExtraInfo(std::string & extraInfo)220 int32_t InteractionManager::GetExtraInfo(std::string &extraInfo)
221 {
222 return INTER_MGR_IMPL.GetExtraInfo(extraInfo);
223 }
224
AddPrivilege()225 int32_t InteractionManager::AddPrivilege()
226 {
227 return INTER_MGR_IMPL.AddPrivilege();
228 }
229
EraseMouseIcon()230 int32_t InteractionManager::EraseMouseIcon()
231 {
232 return INTER_MGR_IMPL.EraseMouseIcon();
233 }
234
SetMouseDragMonitorState(bool state)235 int32_t InteractionManager::SetMouseDragMonitorState(bool state)
236 {
237 return INTER_MGR_IMPL.SetMouseDragMonitorState(state);
238 }
239 } // namespace DeviceStatus
240 } // namespace Msdp
241 } // namespace OHOS
242