• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef OHOS_BUILD_ENABLE_ARKUI_X
21 #include "intention_manager.h"
22 #else
23 #include "drag_manager.h"
24 #endif // OHOS_BUILD_ENABLE_ARKUI_X
25 
26 namespace OHOS {
27 namespace Msdp {
28 namespace DeviceStatus {
29 
30 #ifndef OHOS_BUILD_ENABLE_ARKUI_X
31 using CooperateMsgInfoCallback = std::function<void(const std::string&, const CoordinationMsgInfo&)>;
32 #endif // OHOS_BUILD_ENABLE_ARKUI_X
33 
34 InteractionManager *InteractionManager::instance_ = new (std::nothrow) InteractionManager();
35 
GetInstance()36 InteractionManager *InteractionManager::GetInstance()
37 {
38     return instance_;
39 }
40 
41 #ifndef OHOS_BUILD_ENABLE_ARKUI_X
RegisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,bool isCompatible)42 int32_t InteractionManager::RegisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,
43     bool isCompatible)
44 {
45     return INTER_MGR_IMPL.RegisterCoordinationListener(listener, isCompatible);
46 }
47 
UnregisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,bool isCompatible)48 int32_t InteractionManager::UnregisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,
49     bool isCompatible)
50 {
51     return INTER_MGR_IMPL.UnregisterCoordinationListener(listener, isCompatible);
52 }
53 
PrepareCoordination(CooperateMsgInfoCallback callback,bool isCompatible)54 int32_t InteractionManager::PrepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible)
55 {
56     return INTER_MGR_IMPL.PrepareCoordination(callback, isCompatible);
57 }
58 
UnprepareCoordination(CooperateMsgInfoCallback callback,bool isCompatible)59 int32_t InteractionManager::UnprepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible)
60 {
61     return INTER_MGR_IMPL.UnprepareCoordination(callback, isCompatible);
62 }
63 
ActivateCoordination(const std::string & remoteNetworkId,int32_t startDeviceId,CooperateMsgInfoCallback callback,bool isCompatible)64 int32_t InteractionManager::ActivateCoordination(const std::string &remoteNetworkId, int32_t startDeviceId,
65     CooperateMsgInfoCallback callback, bool isCompatible)
66 {
67     return INTER_MGR_IMPL.ActivateCoordination(remoteNetworkId, startDeviceId, callback, isCompatible);
68 }
69 
ActivateCooperateWithOptions(const std::string & remoteNetworkId,int32_t startDeviceId,CooperateMsgInfoCallback callback,const CooperateOptions & cooperateOptions)70 int32_t InteractionManager::ActivateCooperateWithOptions(const std::string &remoteNetworkId, int32_t startDeviceId,
71     CooperateMsgInfoCallback callback, const CooperateOptions &cooperateOptions)
72 {
73     return INTER_MGR_IMPL.ActivateCooperateWithOptions(remoteNetworkId, startDeviceId, callback, cooperateOptions);
74 }
75 
DeactivateCoordination(bool isUnchained,CooperateMsgInfoCallback callback,bool isCompatible)76 int32_t InteractionManager::DeactivateCoordination(bool isUnchained, CooperateMsgInfoCallback callback,
77     bool isCompatible)
78 {
79     return INTER_MGR_IMPL.DeactivateCoordination(isUnchained, callback, isCompatible);
80 }
81 
SetDraggableState(bool state)82 int32_t InteractionManager::SetDraggableState(bool state)
83 {
84     return INTER_MGR_IMPL.SetDraggableState(state);
85 }
86 
GetAppDragSwitchState(bool & state)87 int32_t InteractionManager::GetAppDragSwitchState(bool &state)
88 {
89     return INTER_MGR_IMPL.GetAppDragSwitchState(state);
90 }
91 
SetDraggableStateAsync(bool state,int64_t downTime)92 void InteractionManager::SetDraggableStateAsync(bool state, int64_t downTime)
93 {
94     INTER_MGR_IMPL.SetDraggableStateAsync(state, downTime);
95 }
96 
GetCoordinationState(const std::string & networkId,std::function<void (bool)> callback,bool isCompatible)97 int32_t InteractionManager::GetCoordinationState(
98     const std::string &networkId, std::function<void(bool)> callback, bool isCompatible)
99 {
100     return INTER_MGR_IMPL.GetCoordinationState(networkId, callback, isCompatible);
101 }
102 
GetCoordinationState(const std::string & udId,bool & state)103 int32_t InteractionManager::GetCoordinationState(const std::string &udId, bool &state)
104 {
105     return INTER_MGR_IMPL.GetCoordinationState(udId, state);
106 }
107 
RegisterEventListener(const std::string & networkId,std::shared_ptr<IEventListener> listener)108 int32_t InteractionManager::RegisterEventListener(const std::string &networkId,
109     std::shared_ptr<IEventListener> listener)
110 {
111 #ifdef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
112     return INTER_MGR_IMPL.RegisterEventListener(networkId, listener);
113 #else
114     return RET_OK;
115 #endif // OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
116 }
117 
UnregisterEventListener(const std::string & networkId,std::shared_ptr<IEventListener> listener)118 int32_t InteractionManager::UnregisterEventListener(const std::string &networkId,
119     std::shared_ptr<IEventListener> listener)
120 {
121 #ifdef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
122     return INTER_MGR_IMPL.UnregisterEventListener(networkId, listener);
123 #else
124     return RET_OK;
125 #endif // OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
126 }
127 
SetDamplingCoefficient(uint32_t direction,double coefficient)128 int32_t InteractionManager::SetDamplingCoefficient(uint32_t direction, double coefficient)
129 {
130 #ifdef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
131     return INTER_MGR_IMPL.SetDamplingCoefficient(direction, coefficient);
132 #else
133     return RET_OK;
134 #endif // OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
135 }
136 
UpdateDragStyle(DragCursorStyle style,int32_t eventId)137 int32_t InteractionManager::UpdateDragStyle(DragCursorStyle style, int32_t eventId)
138 {
139     return INTER_MGR_IMPL.UpdateDragStyle(style, eventId);
140 }
141 
StartDrag(const DragData & dragData,std::shared_ptr<IStartDragListener> listener)142 int32_t InteractionManager::StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener)
143 {
144     return INTER_MGR_IMPL.StartDrag(dragData, listener);
145 }
146 
StopDrag(const DragDropResult & dropResult)147 int32_t InteractionManager::StopDrag(const DragDropResult &dropResult)
148 {
149     return INTER_MGR_IMPL.StopDrag(dropResult);
150 }
151 
GetDragTargetPid()152 int32_t InteractionManager::GetDragTargetPid()
153 {
154     return INTER_MGR_IMPL.GetDragTargetPid();
155 }
156 
GetUdKey(std::string & udKey)157 int32_t InteractionManager::GetUdKey(std::string &udKey)
158 {
159     return INTER_MGR_IMPL.GetUdKey(udKey);
160 }
161 
AddDraglistener(DragListenerPtr listener,bool isJsCaller)162 int32_t InteractionManager::AddDraglistener(DragListenerPtr listener, bool isJsCaller)
163 {
164     return INTER_MGR_IMPL.AddDraglistener(listener, isJsCaller);
165 }
166 
RemoveDraglistener(DragListenerPtr listener,bool isJsCaller)167 int32_t InteractionManager::RemoveDraglistener(DragListenerPtr listener, bool isJsCaller)
168 {
169     return INTER_MGR_IMPL.RemoveDraglistener(listener, isJsCaller);
170 }
171 
AddSubscriptListener(SubscriptListenerPtr listener)172 int32_t InteractionManager::AddSubscriptListener(SubscriptListenerPtr listener)
173 {
174     return INTER_MGR_IMPL.AddSubscriptListener(listener);
175 }
176 
RemoveSubscriptListener(SubscriptListenerPtr listener)177 int32_t InteractionManager::RemoveSubscriptListener(SubscriptListenerPtr listener)
178 {
179     return INTER_MGR_IMPL.RemoveSubscriptListener(listener);
180 }
181 
SetDragWindowVisible(bool visible,bool isForce)182 int32_t InteractionManager::SetDragWindowVisible(bool visible, bool isForce)
183 {
184     return INTER_MGR_IMPL.SetDragWindowVisible(visible, isForce);
185 }
186 
GetShadowOffset(int32_t & offsetX,int32_t & offsetY,int32_t & width,int32_t & height)187 int32_t InteractionManager::GetShadowOffset(int32_t &offsetX, int32_t &offsetY, int32_t &width, int32_t &height)
188 {
189     ShadowOffset shadowOffset;
190     int32_t ret = INTER_MGR_IMPL.GetShadowOffset(shadowOffset);
191     offsetX = shadowOffset.offsetX;
192     offsetY = shadowOffset.offsetY;
193     width = shadowOffset.width;
194     height = shadowOffset.height;
195     return ret;
196 }
197 
UpdateShadowPic(const ShadowInfo & shadowInfo)198 int32_t InteractionManager::UpdateShadowPic(const ShadowInfo &shadowInfo)
199 {
200     return INTER_MGR_IMPL.UpdateShadowPic(shadowInfo);
201 }
202 
GetDragData(DragData & dragData)203 int32_t InteractionManager::GetDragData(DragData &dragData)
204 {
205     return INTER_MGR_IMPL.GetDragData(dragData);
206 }
207 
GetDragState(DragState & dragState)208 int32_t InteractionManager::GetDragState(DragState &dragState)
209 {
210     return INTER_MGR_IMPL.GetDragState(dragState);
211 }
212 
AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener)213 int32_t InteractionManager::AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener)
214 {
215     return INTER_MGR_IMPL.AddHotAreaListener(listener);
216 }
217 
RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener)218 int32_t InteractionManager::RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener)
219 {
220     return INTER_MGR_IMPL.RemoveHotAreaListener(listener);
221 }
222 
UpdatePreviewStyle(const PreviewStyle & previewStyle)223 int32_t InteractionManager::UpdatePreviewStyle(const PreviewStyle &previewStyle)
224 {
225     return INTER_MGR_IMPL.UpdatePreviewStyle(previewStyle);
226 }
227 
UpdatePreviewStyleWithAnimation(const PreviewStyle & previewStyle,const PreviewAnimation & animation)228 int32_t InteractionManager::UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle,
229     const PreviewAnimation &animation)
230 {
231     return INTER_MGR_IMPL.UpdatePreviewStyleWithAnimation(previewStyle, animation);
232 }
233 
RotateDragWindowSync(const std::shared_ptr<Rosen::RSTransaction> & rsTransaction)234 int32_t InteractionManager::RotateDragWindowSync(const std::shared_ptr<Rosen::RSTransaction>& rsTransaction)
235 {
236     return INTER_MGR_IMPL.RotateDragWindowSync(rsTransaction);
237 }
238 
SetDragWindowScreenId(uint64_t displayId,uint64_t screenId)239 int32_t InteractionManager::SetDragWindowScreenId(uint64_t displayId, uint64_t screenId)
240 {
241     return INTER_MGR_IMPL.SetDragWindowScreenId(displayId, screenId);
242 }
243 
GetDragSummary(std::map<std::string,int64_t> & summarys,bool isJsCaller)244 int32_t InteractionManager::GetDragSummary(std::map<std::string, int64_t> &summarys, bool isJsCaller)
245 {
246     return INTER_MGR_IMPL.GetDragSummary(summarys, isJsCaller);
247 }
248 
SetDragSwitchState(bool enable,bool isJsCaller)249 int32_t InteractionManager::SetDragSwitchState(bool enable, bool isJsCaller)
250 {
251     return INTER_MGR_IMPL.SetDragSwitchState(enable, isJsCaller);
252 }
253 
SetAppDragSwitchState(bool enable,const std::string & pkgName,bool isJsCaller)254 int32_t InteractionManager::SetAppDragSwitchState(bool enable, const std::string &pkgName, bool isJsCaller)
255 {
256     return INTER_MGR_IMPL.SetAppDragSwitchState(enable, pkgName, isJsCaller);
257 }
258 
GetDragAction(DragAction & dragAction)259 int32_t InteractionManager::GetDragAction(DragAction &dragAction)
260 {
261     return INTER_MGR_IMPL.GetDragAction(dragAction);
262 }
263 
EnterTextEditorArea(bool enable)264 int32_t InteractionManager::EnterTextEditorArea(bool enable)
265 {
266     return INTER_MGR_IMPL.EnterTextEditorArea(enable);
267 }
268 
GetExtraInfo(std::string & extraInfo)269 int32_t InteractionManager::GetExtraInfo(std::string &extraInfo)
270 {
271     return INTER_MGR_IMPL.GetExtraInfo(extraInfo);
272 }
273 
AddPrivilege()274 int32_t InteractionManager::AddPrivilege()
275 {
276     return INTER_MGR_IMPL.AddPrivilege();
277 }
278 
EraseMouseIcon()279 int32_t InteractionManager::EraseMouseIcon()
280 {
281     return INTER_MGR_IMPL.EraseMouseIcon();
282 }
283 
SetMouseDragMonitorState(bool state)284 int32_t InteractionManager::SetMouseDragMonitorState(bool state)
285 {
286     return INTER_MGR_IMPL.SetMouseDragMonitorState(state);
287 }
288 
AddSelectedPixelMap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap,std::function<void (bool)> callback)289 int32_t InteractionManager::AddSelectedPixelMap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap,
290     std::function<void(bool)> callback)
291 {
292     return INTER_MGR_IMPL.AddSelectedPixelMap(pixelMap, callback);
293 }
294 #else
StartDrag(const DragData & dragData)295 int32_t InteractionManager::StartDrag(const DragData &dragData)
296 {
297     return DRAG_MANAGER.StartDrag(dragData);
298 }
299 
UpdateDragStyle(DragCursorStyle style)300 int32_t InteractionManager::UpdateDragStyle(DragCursorStyle style)
301 {
302     return DRAG_MANAGER.UpdateDragStyle(style);
303 }
304 
StopDrag(const DragDropResult & dropResult)305 int32_t InteractionManager::StopDrag(const DragDropResult &dropResult)
306 {
307     return DRAG_MANAGER.StopDrag(dropResult);
308 }
309 
GetDragTargetPid()310 int32_t InteractionManager::GetDragTargetPid()
311 {
312     return DRAG_MANAGER.GetDragTargetPid();
313 }
314 
GetUdKey(std::string & udKey)315 int32_t InteractionManager::GetUdKey(std::string &udKey)
316 {
317     return DRAG_MANAGER.GetUdKey(udKey);
318 }
319 
SetDragWindowVisible(bool visible,bool isForce)320 int32_t InteractionManager::SetDragWindowVisible(bool visible, bool isForce)
321 {
322     return DRAG_MANAGER.OnSetDragWindowVisible(visible, isForce);
323 }
324 
GetShadowOffset(int32_t & offsetX,int32_t & offsetY,int32_t & width,int32_t & height)325 int32_t InteractionManager::GetShadowOffset(int32_t &offsetX, int32_t &offsetY, int32_t &width, int32_t &height)
326 {
327     ShadowOffset shadowOffset;
328     int32_t ret = DRAG_MANAGER.OnGetShadowOffset(shadowOffset);
329     if (ret != 0) {
330         FI_HILOGE("shadowOffset is empty");
331         return ret;
332     }
333     offsetX = shadowOffset.offsetX;
334     offsetY = shadowOffset.offsetY;
335     width = shadowOffset.width;
336     height = shadowOffset.height;
337     return ret;
338 }
339 
UpdateShadowPic(const ShadowInfo & shadowInfo)340 int32_t InteractionManager::UpdateShadowPic(const ShadowInfo &shadowInfo)
341 {
342     return DRAG_MANAGER.UpdateShadowPic(shadowInfo);
343 }
344 
GetDragData(DragData & dragData)345 int32_t InteractionManager::GetDragData(DragData &dragData)
346 {
347     return DRAG_MANAGER.GetDragData(dragData);
348 }
349 
GetDragState(DragState & dragState)350 int32_t InteractionManager::GetDragState(DragState &dragState)
351 {
352     return DRAG_MANAGER.GetDragState(dragState);
353 }
354 
UpdatePreviewStyle(const PreviewStyle & previewStyle)355 int32_t InteractionManager::UpdatePreviewStyle(const PreviewStyle &previewStyle)
356 {
357     return DRAG_MANAGER.UpdatePreviewStyle(previewStyle);
358 }
359 
UpdatePreviewStyleWithAnimation(const PreviewStyle & previewStyle,const PreviewAnimation & animation)360 int32_t InteractionManager::UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle,
361     const PreviewAnimation &animation)
362 {
363     return DRAG_MANAGER.UpdatePreviewStyleWithAnimation(previewStyle, animation);
364 }
365 
GetDragSummary(std::map<std::string,int64_t> & summarys)366 int32_t InteractionManager::GetDragSummary(std::map<std::string, int64_t> &summarys)
367 {
368     return DRAG_MANAGER.GetDragSummary(summarys);
369 }
370 
GetDragAction(DragAction & dragAction)371 int32_t InteractionManager::GetDragAction(DragAction &dragAction)
372 {
373     return DRAG_MANAGER.GetDragAction(dragAction);
374 }
375 
EnterTextEditorArea(bool enable)376 int32_t InteractionManager::EnterTextEditorArea(bool enable)
377 {
378     return DRAG_MANAGER.EnterTextEditorArea(enable);
379 }
380 
GetExtraInfo(std::string & extraInfo)381 int32_t InteractionManager::GetExtraInfo(std::string &extraInfo)
382 {
383     return DRAG_MANAGER.GetExtraInfo(extraInfo);
384 }
385 
UpdatePointerAction(std::shared_ptr<MMI::PointerEvent> pointerEvent)386 int32_t InteractionManager::UpdatePointerAction(std::shared_ptr<MMI::PointerEvent> pointerEvent)
387 {
388     return DRAG_MANAGER.UpdatePointerAction(pointerEvent);
389 }
390 
SetDragWindow(std::shared_ptr<OHOS::Rosen::Window> window)391 void InteractionManager::SetDragWindow(std::shared_ptr<OHOS::Rosen::Window> window)
392 {
393     DRAG_MANAGER.SetDragWindow(window);
394 }
395 
RegisterDragWindow(std::function<void ()> cb)396 void InteractionManager::RegisterDragWindow(std::function<void()> cb)
397 {
398     DRAG_MANAGER.AddDragDestroy(cb);
399 }
400 
SetSVGFilePath(const std::string & filePath)401 void InteractionManager::SetSVGFilePath(const std::string &filePath)
402 {
403     DRAG_MANAGER.SetSVGFilePath(filePath);
404 }
405 #endif // OHOS_BUILD_ENABLE_ARKUI_X
406 } // namespace DeviceStatus
407 } // namespace Msdp
408 } // namespace OHOS
409