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 #include "intention_manager.h"
17
18 #include "display_manager.h"
19
20 #include "devicestatus_define.h"
21 #include "drag_data.h"
22
23 #undef LOG_TAG
24 #define LOG_TAG "IntentionManager"
25
26 namespace OHOS {
27 namespace Msdp {
28 namespace DeviceStatus {
29 namespace {
30 constexpr int32_t INDEX_FOLDED { 0 };
31 constexpr int32_t INDEX_EXPAND { 1 };
32 constexpr size_t POLICY_VEC_SIZE { 2 };
33 const std::string SCREEN_ROTATION { "1" };
34 } // namespace
35
IntentionManager()36 IntentionManager::IntentionManager()
37 {
38 tunnel_ = std::make_shared<TunnelClient>();
39 }
40
~IntentionManager()41 IntentionManager::~IntentionManager()
42 {
43 client_.reset();
44 }
45
InitClient()46 void IntentionManager::InitClient()
47 {
48 CALL_DEBUG_ENTER;
49 {
50 std::lock_guard<std::mutex> guard(mutex_);
51 if (client_ != nullptr) {
52 return;
53 }
54 client_ = std::make_unique<SocketClient>(tunnel_);
55 InitMsgHandler();
56 client_->RegisterConnectedFunction([this] {
57 this->OnConnected();
58 });
59 client_->RegisterDisconnectedFunction([this] {
60 this->OnDisconnected();
61 });
62 client_->Start();
63 }
64 GetRotatePolicy(isScreenRotation_, foldRotatePolicys_);
65 }
66
InitMsgHandler()67 void IntentionManager::InitMsgHandler()
68 {
69 CALL_DEBUG_ENTER;
70 std::map<MessageId, std::function<int32_t(const StreamClient&, NetPacket&)>> funs {
71 #ifdef OHOS_BUILD_ENABLE_COORDINATION
72 {MessageId::COORDINATION_ADD_LISTENER, [this](const StreamClient &client, NetPacket &pkt) {
73 return this->cooperate_.OnCoordinationListener(client, pkt);
74 }},
75 {MessageId::COORDINATION_MESSAGE, [this](const StreamClient &client, NetPacket &pkt) {
76 return this->cooperate_.OnCoordinationMessage(client, pkt);
77 }},
78 {MessageId::COORDINATION_GET_STATE, [this](const StreamClient &client, NetPacket &pkt) {
79 return this->cooperate_.OnCoordinationState(client, pkt);
80 }},
81 {MessageId::HOT_AREA_ADD_LISTENER, [this](const StreamClient &client, NetPacket &pkt) {
82 return this->cooperate_.OnHotAreaListener(client, pkt);
83 }},
84 {MessageId::MOUSE_LOCATION_ADD_LISTENER, [this](const StreamClient &client, NetPacket &pkt) {
85 return this->cooperate_.OnMouseLocationListener(client, pkt);
86 }},
87 #endif // OHOS_BUILD_ENABLE_COORDINATION
88
89 {MessageId::DRAG_NOTIFY_RESULT, [this](const StreamClient &client, NetPacket &pkt) {
90 return this->drag_.OnNotifyResult(client, pkt);
91 }},
92 {MessageId::DRAG_STATE_LISTENER, [this](const StreamClient &client, NetPacket &pkt) {
93 return this->drag_.OnStateChangedMessage(client, pkt);
94 }},
95 {MessageId::DRAG_NOTIFY_HIDE_ICON, [this](const StreamClient &client, NetPacket &pkt) {
96 return this->drag_.OnNotifyHideIcon(client, pkt);
97 }},
98 {MessageId::DRAG_STYLE_LISTENER, [this](const StreamClient &client, NetPacket &pkt) {
99 return this->drag_.OnDragStyleChangedMessage(client, pkt);
100 }},
101 {MessageId::ADD_SELECTED_PIXELMAP_RESULT, [this](const StreamClient &client, NetPacket &pkt) {
102 return this->drag_.OnAddSelectedPixelMapResult(client, pkt);
103 }}
104 };
105 CHKPV(client_);
106 for (auto &[id, cb] : funs) {
107 if (!client_->RegisterEvent(id, cb)) {
108 FI_HILOGI("RegistER event handler msg:%{public}d already exists", id);
109 }
110 }
111 }
112
SubscribeCallback(Type type,ActivityEvent event,ReportLatencyNs latency,sptr<IRemoteDevStaCallback> callback)113 int32_t IntentionManager::SubscribeCallback(Type type, ActivityEvent event, ReportLatencyNs latency,
114 sptr<IRemoteDevStaCallback> callback)
115 {
116 return stationary_.SubscribeCallback(*tunnel_, type, event, latency, callback);
117 }
118
UnsubscribeCallback(Type type,ActivityEvent event,sptr<IRemoteDevStaCallback> callback)119 int32_t IntentionManager::UnsubscribeCallback(Type type, ActivityEvent event, sptr<IRemoteDevStaCallback> callback)
120 {
121 return stationary_.UnsubscribeCallback(*tunnel_, type, event, callback);
122 }
123
SubscribeCallback(BoomerangType type,std::string bundleName,sptr<IRemoteBoomerangCallback> callback)124 int32_t IntentionManager::SubscribeCallback(BoomerangType type, std::string bundleName,
125 sptr<IRemoteBoomerangCallback> callback)
126 {
127 return boomerang_.SubscribeCallback(*tunnel_, type, bundleName, callback);
128 }
129
UnsubscribeCallback(BoomerangType type,std::string bundleName,sptr<IRemoteBoomerangCallback> callback)130 int32_t IntentionManager::UnsubscribeCallback(BoomerangType type, std::string bundleName,
131 sptr<IRemoteBoomerangCallback> callback)
132 {
133 return boomerang_.UnsubscribeCallback(*tunnel_, type, bundleName, callback);
134 }
135
NotifyMetadataBindingEvent(std::string bundleName,sptr<IRemoteBoomerangCallback> callback)136 int32_t IntentionManager::NotifyMetadataBindingEvent(std::string bundleName, sptr<IRemoteBoomerangCallback> callback)
137 {
138 return boomerang_.NotifyMetadataBindingEvent(*tunnel_, bundleName, callback);
139 }
140
SubmitMetadata(std::string metadata)141 int32_t IntentionManager::SubmitMetadata(std::string metadata)
142 {
143 return boomerang_.SubmitMetadata(*tunnel_, metadata);
144 }
145
BoomerangEncodeImage(std::shared_ptr<Media::PixelMap> pixelMap,std::string matedata,sptr<IRemoteBoomerangCallback> callback)146 int32_t IntentionManager::BoomerangEncodeImage(std::shared_ptr<Media::PixelMap> pixelMap, std::string matedata,
147 sptr<IRemoteBoomerangCallback> callback)
148 {
149 return boomerang_.BoomerangEncodeImage(*tunnel_, pixelMap, matedata, callback);
150 }
151
BoomerangDecodeImage(std::shared_ptr<Media::PixelMap> pixelMap,sptr<IRemoteBoomerangCallback> callback)152 int32_t IntentionManager::BoomerangDecodeImage(std::shared_ptr<Media::PixelMap> pixelMap,
153 sptr<IRemoteBoomerangCallback> callback)
154 {
155 return boomerang_.BoomerangDecodeImage(*tunnel_, pixelMap, callback);
156 }
157
GetDeviceStatusData(const Type type)158 Data IntentionManager::GetDeviceStatusData(const Type type)
159 {
160 return stationary_.GetDeviceStatusData(*tunnel_, type);
161 }
162
RegisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,bool isCompatible)163 int32_t IntentionManager::RegisterCoordinationListener(
164 std::shared_ptr<ICoordinationListener> listener, bool isCompatible)
165 {
166 CALL_INFO_TRACE;
167 #ifdef OHOS_BUILD_ENABLE_COORDINATION
168 InitClient();
169 return cooperate_.RegisterListener(*tunnel_, listener, isCompatible);
170 #else
171 FI_HILOGW("Coordination does not support");
172 (void)(listener);
173 (void)(isCompatible);
174 return ERROR_UNSUPPORT;
175 #endif // OHOS_BUILD_ENABLE_COORDINATION
176 }
177
UnregisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,bool isCompatible)178 int32_t IntentionManager::UnregisterCoordinationListener(
179 std::shared_ptr<ICoordinationListener> listener, bool isCompatible)
180 {
181 CALL_INFO_TRACE;
182 #ifdef OHOS_BUILD_ENABLE_COORDINATION
183 return cooperate_.UnregisterListener(*tunnel_, listener, isCompatible);
184 #else
185 FI_HILOGW("Coordination does not support");
186 (void)(listener);
187 (void)(isCompatible);
188 return ERROR_UNSUPPORT;
189 #endif // OHOS_BUILD_ENABLE_COORDINATION
190 }
191
PrepareCoordination(CooperateMsgInfoCallback callback,bool isCompatible)192 int32_t IntentionManager::PrepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible)
193 {
194 CALL_INFO_TRACE;
195 #ifdef OHOS_BUILD_ENABLE_COORDINATION
196 InitClient();
197 return cooperate_.Enable(*tunnel_, callback, isCompatible);
198 #else
199 FI_HILOGW("Coordination does not support");
200 (void)(callback);
201 (void)(isCompatible);
202 return ERROR_UNSUPPORT;
203 #endif // OHOS_BUILD_ENABLE_COORDINATION
204 }
205
UnprepareCoordination(CooperateMsgInfoCallback callback,bool isCompatible)206 int32_t IntentionManager::UnprepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible)
207 {
208 CALL_INFO_TRACE;
209 #ifdef OHOS_BUILD_ENABLE_COORDINATION
210 InitClient();
211 return cooperate_.Disable(*tunnel_, callback, isCompatible);
212 #else
213 FI_HILOGW("Coordination does not support");
214 (void)(callback);
215 (void)(isCompatible);
216 return ERROR_UNSUPPORT;
217 #endif // OHOS_BUILD_ENABLE_COORDINATION
218 }
219
ActivateCoordination(const std::string & remoteNetworkId,int32_t startDeviceId,CooperateMsgInfoCallback callback,bool isCompatible)220 int32_t IntentionManager::ActivateCoordination(const std::string &remoteNetworkId, int32_t startDeviceId,
221 CooperateMsgInfoCallback callback, bool isCompatible)
222 {
223 CALL_INFO_TRACE;
224 #ifdef OHOS_BUILD_ENABLE_COORDINATION
225 InitClient();
226 return cooperate_.Start(*tunnel_, remoteNetworkId, startDeviceId, callback, isCompatible);
227 #else
228 FI_HILOGW("Coordination does not support");
229 (void)(remoteNetworkId);
230 (void)(startDeviceId);
231 (void)(callback);
232 (void)(isCompatible);
233 return ERROR_UNSUPPORT;
234 #endif // OHOS_BUILD_ENABLE_COORDINATION
235 }
236
ActivateCooperateWithOptions(const std::string & remoteNetworkId,int32_t startDeviceId,CooperateMsgInfoCallback callback,const CooperateOptions & options)237 int32_t IntentionManager::ActivateCooperateWithOptions(const std::string &remoteNetworkId,
238 int32_t startDeviceId, CooperateMsgInfoCallback callback, const CooperateOptions &options)
239 {
240 CALL_INFO_TRACE;
241 #ifdef OHOS_BUILD_ENABLE_COORDINATION
242 InitClient();
243 return cooperate_.StartWithOptions(*tunnel_, remoteNetworkId, startDeviceId, callback, options);
244 #else
245 FI_HILOGW("Coordination does not support");
246 (void)(remoteNetworkId);
247 (void)(startDeviceId);
248 (void)(callback);
249 (void)(options);
250 return ERROR_UNSUPPORT;
251 #endif // OHOS_BUILD_ENABLE_COORDINATION
252 }
253
DeactivateCoordination(bool isUnchained,CooperateMsgInfoCallback callback,bool isCompatible)254 int32_t IntentionManager::DeactivateCoordination(bool isUnchained,
255 CooperateMsgInfoCallback callback, bool isCompatible)
256 {
257 CALL_INFO_TRACE;
258 #ifdef OHOS_BUILD_ENABLE_COORDINATION
259 InitClient();
260 return cooperate_.Stop(*tunnel_, isUnchained, callback, isCompatible);
261 #else
262 FI_HILOGW("Coordination does not support");
263 (void)(callback);
264 (void)(isCompatible);
265 return ERROR_UNSUPPORT;
266 #endif // OHOS_BUILD_ENABLE_COORDINATION
267 }
268
GetCoordinationState(const std::string & networkId,std::function<void (bool)> callback,bool isCompatible)269 int32_t IntentionManager::GetCoordinationState(
270 const std::string &networkId, std::function<void(bool)> callback, bool isCompatible)
271 {
272 CALL_INFO_TRACE;
273 #ifdef OHOS_BUILD_ENABLE_COORDINATION
274 InitClient();
275 return cooperate_.GetCooperateState(*tunnel_, networkId, callback, isCompatible);
276 #else
277 (void)(networkId);
278 (void)(callback);
279 (void)(isCompatible);
280 FI_HILOGW("Coordination does not support");
281 return ERROR_UNSUPPORT;
282 #endif // OHOS_BUILD_ENABLE_COORDINATION
283 }
284
GetCoordinationState(const std::string & udId,bool & state)285 int32_t IntentionManager::GetCoordinationState(const std::string &udId, bool &state)
286 {
287 CALL_INFO_TRACE;
288 #ifdef OHOS_BUILD_ENABLE_COORDINATION
289 InitClient();
290 return cooperate_.GetCooperateState(*tunnel_, udId, state);
291 #else
292 (void)(udId);
293 (void)(state);
294 FI_HILOGW("Coordination does not support");
295 return ERROR_UNSUPPORT;
296 #endif // OHOS_BUILD_ENABLE_COORDINATION
297 }
298
RegisterEventListener(const std::string & networkId,std::shared_ptr<IEventListener> listener)299 int32_t IntentionManager::RegisterEventListener(const std::string &networkId, std::shared_ptr<IEventListener> listener)
300 {
301 CALL_INFO_TRACE;
302 #ifdef OHOS_BUILD_ENABLE_COORDINATION
303 InitClient();
304 return cooperate_.RegisterEventListener(*tunnel_, networkId, listener);
305 #else
306 (void)(networkId);
307 (void)(listener);
308 FI_HILOGW("Coordination does not support");
309 return ERROR_UNSUPPORT;
310 #endif // OHOS_BUILD_ENABLE_COORDINATION
311 }
312
UnregisterEventListener(const std::string & networkId,std::shared_ptr<IEventListener> listener)313 int32_t IntentionManager::UnregisterEventListener(const std::string &networkId,
314 std::shared_ptr<IEventListener> listener)
315 {
316 CALL_INFO_TRACE;
317 #ifdef OHOS_BUILD_ENABLE_COORDINATION
318 InitClient();
319 return cooperate_.UnregisterEventListener(*tunnel_, networkId, listener);
320 #else
321 (void)(networkId);
322 (void)(listener);
323 FI_HILOGW("Coordination does not support");
324 return ERROR_UNSUPPORT;
325 #endif // OHOS_BUILD_ENABLE_COORDINATION
326 }
327
SetDamplingCoefficient(uint32_t direction,double coefficient)328 int32_t IntentionManager::SetDamplingCoefficient(uint32_t direction, double coefficient)
329 {
330 CALL_INFO_TRACE;
331 #ifdef OHOS_BUILD_ENABLE_COORDINATION
332 InitClient();
333 return cooperate_.SetDamplingCoefficient(*tunnel_, direction, coefficient);
334 #else
335 (void)(direction);
336 (void)(coefficient);
337 FI_HILOGW("Coordination does not support");
338 return ERROR_UNSUPPORT;
339 #endif // OHOS_BUILD_ENABLE_COORDINATION
340 }
341
UpdateDragStyle(DragCursorStyle style,int32_t eventId)342 int32_t IntentionManager::UpdateDragStyle(DragCursorStyle style, int32_t eventId)
343 {
344 CALL_DEBUG_ENTER;
345 return drag_.UpdateDragStyle(*tunnel_, style, eventId);
346 }
347
StartDrag(const DragData & dragData,std::shared_ptr<IStartDragListener> listener)348 int32_t IntentionManager::StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener)
349 {
350 CALL_DEBUG_ENTER;
351 InitClient();
352 return drag_.StartDrag(*tunnel_, dragData, listener);
353 }
354
StopDrag(const DragDropResult & dropResult)355 int32_t IntentionManager::StopDrag(const DragDropResult &dropResult)
356 {
357 CALL_DEBUG_ENTER;
358 return drag_.StopDrag(*tunnel_, dropResult);
359 }
360
GetDragTargetPid()361 int32_t IntentionManager::GetDragTargetPid()
362 {
363 CALL_DEBUG_ENTER;
364 return drag_.GetDragTargetPid(*tunnel_);
365 }
366
GetUdKey(std::string & udKey)367 int32_t IntentionManager::GetUdKey(std::string &udKey)
368 {
369 CALL_DEBUG_ENTER;
370 return drag_.GetUdKey(*tunnel_, udKey);
371 }
372
AddDraglistener(DragListenerPtr listener,bool isJsCaller)373 int32_t IntentionManager::AddDraglistener(DragListenerPtr listener, bool isJsCaller)
374 {
375 CALL_DEBUG_ENTER;
376 InitClient();
377 return drag_.AddDraglistener(*tunnel_, listener, isJsCaller);
378 }
379
RemoveDraglistener(DragListenerPtr listener,bool isJsCaller)380 int32_t IntentionManager::RemoveDraglistener(DragListenerPtr listener, bool isJsCaller)
381 {
382 CALL_DEBUG_ENTER;
383 return drag_.RemoveDraglistener(*tunnel_, listener, isJsCaller);
384 }
385
AddSubscriptListener(SubscriptListenerPtr listener)386 int32_t IntentionManager::AddSubscriptListener(SubscriptListenerPtr listener)
387 {
388 CALL_DEBUG_ENTER;
389 InitClient();
390 return drag_.AddSubscriptListener(*tunnel_, listener);
391 }
392
RemoveSubscriptListener(SubscriptListenerPtr listener)393 int32_t IntentionManager::RemoveSubscriptListener(SubscriptListenerPtr listener)
394 {
395 CALL_DEBUG_ENTER;
396 return drag_.RemoveSubscriptListener(*tunnel_, listener);
397 }
398
SetDragWindowVisible(bool visible,bool isForce)399 int32_t IntentionManager::SetDragWindowVisible(bool visible, bool isForce)
400 {
401 CALL_DEBUG_ENTER;
402 return drag_.SetDragWindowVisible(*tunnel_, visible, isForce);
403 }
404
GetShadowOffset(ShadowOffset & shadowOffset)405 int32_t IntentionManager::GetShadowOffset(ShadowOffset &shadowOffset)
406 {
407 CALL_DEBUG_ENTER;
408 return drag_.GetShadowOffset(*tunnel_, shadowOffset);
409 }
410
UpdateShadowPic(const ShadowInfo & shadowInfo)411 int32_t IntentionManager::UpdateShadowPic(const ShadowInfo &shadowInfo)
412 {
413 CALL_DEBUG_ENTER;
414 return drag_.UpdateShadowPic(*tunnel_, shadowInfo);
415 }
416
GetDragData(DragData & dragData)417 int32_t IntentionManager::GetDragData(DragData &dragData)
418 {
419 CALL_DEBUG_ENTER;
420 return drag_.GetDragData(*tunnel_, dragData);
421 }
422
GetDragState(DragState & dragState)423 int32_t IntentionManager::GetDragState(DragState &dragState)
424 {
425 CALL_DEBUG_ENTER;
426 return drag_.GetDragState(*tunnel_, dragState);
427 }
428
GetDragAction(DragAction & dragAction)429 int32_t IntentionManager::GetDragAction(DragAction &dragAction)
430 {
431 CALL_DEBUG_ENTER;
432 return drag_.GetDragAction(*tunnel_, dragAction);
433 }
434
GetExtraInfo(std::string & extraInfo)435 int32_t IntentionManager::GetExtraInfo(std::string &extraInfo)
436 {
437 CALL_DEBUG_ENTER;
438 return drag_.GetExtraInfo(*tunnel_, extraInfo);
439 }
440
AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener)441 int32_t IntentionManager::AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener)
442 {
443 CALL_DEBUG_ENTER;
444 #ifdef OHOS_BUILD_ENABLE_COORDINATION
445 InitClient();
446 return cooperate_.AddHotAreaListener(*tunnel_, listener);
447 #else
448 FI_HILOGW("Coordination does not support");
449 (void)(listener);
450 return ERROR_UNSUPPORT;
451 #endif // OHOS_BUILD_ENABLE_COORDINATION
452 }
453
RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener)454 int32_t IntentionManager::RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener)
455 {
456 CALL_DEBUG_ENTER;
457 #ifdef OHOS_BUILD_ENABLE_COORDINATION
458 return cooperate_.RemoveHotAreaListener(*tunnel_, listener);
459 #else
460 FI_HILOGW("Coordination does not support");
461 (void)(listener);
462 return ERROR_UNSUPPORT;
463 #endif // OHOS_BUILD_ENABLE_COORDINATION
464 }
465
UpdatePreviewStyle(const PreviewStyle & previewStyle)466 int32_t IntentionManager::UpdatePreviewStyle(const PreviewStyle &previewStyle)
467 {
468 CALL_DEBUG_ENTER;
469 return drag_.UpdatePreviewStyle(*tunnel_, previewStyle);
470 }
471
UpdatePreviewStyleWithAnimation(const PreviewStyle & previewStyle,const PreviewAnimation & animation)472 int32_t IntentionManager::UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle,
473 const PreviewAnimation &animation)
474 {
475 CALL_DEBUG_ENTER;
476 return drag_.UpdatePreviewStyleWithAnimation(*tunnel_, previewStyle, animation);
477 }
478
RotateDragWindowSync(const std::shared_ptr<Rosen::RSTransaction> & rsTransaction)479 int32_t IntentionManager::RotateDragWindowSync(const std::shared_ptr<Rosen::RSTransaction>& rsTransaction)
480 {
481 CALL_DEBUG_ENTER;
482 if (isScreenRotation_) {
483 FI_HILOGW("Screen rotation, not need rotate drag window");
484 return RET_OK;
485 }
486 if (Rosen::DisplayManager::GetInstance().IsFoldable()) {
487 if ((foldRotatePolicys_.empty()) || (foldRotatePolicys_.size() < POLICY_VEC_SIZE)) {
488 FI_HILOGE("foldRotatePolicys_ is invalid");
489 return drag_.RotateDragWindowSync(*tunnel_, rsTransaction);
490 }
491 Rosen::FoldStatus foldStatus = Rosen::DisplayManager::GetInstance().GetFoldStatus();
492 if (IsSecondaryDevice()) {
493 bool isExpand = (foldStatus == Rosen::FoldStatus::EXPAND || foldStatus == Rosen::FoldStatus::HALF_FOLD ||
494 foldStatus == Rosen::FoldStatus::FOLD_STATE_EXPAND_WITH_SECOND_EXPAND ||
495 foldStatus == Rosen::FoldStatus::FOLD_STATE_EXPAND_WITH_SECOND_HALF_FOLDED ||
496 foldStatus == Rosen::FoldStatus::FOLD_STATE_HALF_FOLDED_WITH_SECOND_EXPAND ||
497 foldStatus == Rosen::FoldStatus::FOLD_STATE_HALF_FOLDED_WITH_SECOND_HALF_FOLDED);
498 bool isFold = (foldStatus == Rosen::FoldStatus::FOLDED ||
499 foldStatus == Rosen::FoldStatus::FOLD_STATE_FOLDED_WITH_SECOND_EXPAND ||
500 foldStatus == Rosen::FoldStatus::FOLD_STATE_FOLDED_WITH_SECOND_HALF_FOLDED);
501 if ((isExpand && (foldRotatePolicys_[INDEX_EXPAND] == SCREEN_ROTATION)) ||
502 (isFold && (foldRotatePolicys_[INDEX_FOLDED] == SCREEN_ROTATION))) {
503 FI_HILOGD("Secondary device Full display rotation, not need rotate drag window");
504 return RET_OK;
505 }
506 } else {
507 if (((foldStatus == Rosen::FoldStatus::EXPAND) && (foldRotatePolicys_[INDEX_EXPAND] == SCREEN_ROTATION)) ||
508 ((foldStatus == Rosen::FoldStatus::FOLDED) && (foldRotatePolicys_[INDEX_FOLDED] == SCREEN_ROTATION))) {
509 FI_HILOGD("Full display rotation, not need rotate drag window");
510 return RET_OK;
511 }
512 }
513 }
514 return drag_.RotateDragWindowSync(*tunnel_, rsTransaction);
515 }
516
SetDragWindowScreenId(uint64_t displayId,uint64_t screenId)517 int32_t IntentionManager::SetDragWindowScreenId(uint64_t displayId, uint64_t screenId)
518 {
519 CALL_DEBUG_ENTER;
520 return drag_.SetDragWindowScreenId(*tunnel_, displayId, screenId);
521 }
522
GetDragSummary(std::map<std::string,int64_t> & summarys,bool isJsCaller)523 int32_t IntentionManager::GetDragSummary(std::map<std::string, int64_t> &summarys, bool isJsCaller)
524 {
525 CALL_DEBUG_ENTER;
526 return drag_.GetDragSummary(*tunnel_, summarys, isJsCaller);
527 }
528
SetDragSwitchState(bool enable,bool isJsCaller)529 int32_t IntentionManager::SetDragSwitchState(bool enable, bool isJsCaller)
530 {
531 CALL_DEBUG_ENTER;
532 return drag_.SetDragSwitchState(*tunnel_, enable, isJsCaller);
533 }
534
SetAppDragSwitchState(bool enable,const std::string & pkgName,bool isJsCaller)535 int32_t IntentionManager::SetAppDragSwitchState(bool enable, const std::string &pkgName, bool isJsCaller)
536 {
537 CALL_DEBUG_ENTER;
538 return drag_.SetAppDragSwitchState(*tunnel_, enable, pkgName, isJsCaller);
539 }
540
EnterTextEditorArea(bool enable)541 int32_t IntentionManager::EnterTextEditorArea(bool enable)
542 {
543 CALL_DEBUG_ENTER;
544 return drag_.EnableUpperCenterMode(*tunnel_, enable);
545 }
546
AddPrivilege()547 int32_t IntentionManager::AddPrivilege()
548 {
549 CALL_DEBUG_ENTER;
550 return drag_.AddPrivilege(*tunnel_);
551 }
552
EraseMouseIcon()553 int32_t IntentionManager::EraseMouseIcon()
554 {
555 CALL_DEBUG_ENTER;
556 return drag_.EraseMouseIcon(*tunnel_);
557 }
558
SetMouseDragMonitorState(bool state)559 int32_t IntentionManager::SetMouseDragMonitorState(bool state)
560 {
561 CALL_DEBUG_ENTER;
562 return drag_.SetMouseDragMonitorState(*tunnel_, state);
563 }
564
AddSelectedPixelMap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap,std::function<void (bool)> callback)565 int32_t IntentionManager::AddSelectedPixelMap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap,
566 std::function<void(bool)> callback)
567 {
568 CALL_DEBUG_ENTER;
569 return drag_.AddSelectedPixelMap(*tunnel_, pixelMap, callback);
570 }
571
OnConnected()572 void IntentionManager::OnConnected()
573 {
574 CALL_DEBUG_ENTER;
575 CHKPV(tunnel_);
576 drag_.OnConnected(*tunnel_);
577 }
578
OnDisconnected()579 void IntentionManager::OnDisconnected()
580 {
581 CALL_DEBUG_ENTER;
582 CHKPV(tunnel_);
583 drag_.OnDisconnected(*tunnel_);
584 }
585
SetDraggableState(bool state)586 int32_t IntentionManager::SetDraggableState(bool state)
587 {
588 CALL_DEBUG_ENTER;
589 return drag_.SetDraggableState(*tunnel_, state);
590 }
591
GetAppDragSwitchState(bool & state)592 int32_t IntentionManager::GetAppDragSwitchState(bool &state)
593 {
594 CALL_DEBUG_ENTER;
595 return drag_.GetAppDragSwitchState(*tunnel_, state);
596 }
597
SetDraggableStateAsync(bool state,int64_t downTime)598 void IntentionManager::SetDraggableStateAsync(bool state, int64_t downTime)
599 {
600 CALL_DEBUG_ENTER;
601 return drag_.SetDraggableStateAsync(*tunnel_, state, downTime);
602 }
603 } // namespace DeviceStatus
604 } // namespace Msdp
605 } // namespace OHOS
606