1 /*
2 * Copyright (c) 2023-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 "picture_in_picture_controller.h"
17 #include "picture_in_picture_manager.h"
18 #include "singleton_container.h"
19 #include "window_manager_hilog.h"
20
21 namespace OHOS {
22 namespace Rosen {
23 namespace {
24 const std::string PIP_CONTENT_PATH = "/system/etc/window/resources/pip_content.abc";
25 const std::string DESTROY_TIMEOUT_TASK = "PipDestroyTimeout";
26 }
27
PictureInPictureController(sptr<PipOption> pipOption,sptr<Window> mainWindow,uint32_t windowId,napi_env env)28 PictureInPictureController::PictureInPictureController(sptr<PipOption> pipOption, sptr<Window> mainWindow,
29 uint32_t windowId, napi_env env)
30 {
31 pipOption_ = pipOption;
32 mainWindow_ = mainWindow;
33 mainWindowId_ = windowId;
34 env_ = env;
35 curState_ = PiPWindowState::STATE_UNDEFINED;
36 weakRef_ = this;
37 }
38
~PictureInPictureController()39 PictureInPictureController::~PictureInPictureController()
40 {
41 if (!isAutoStartEnabled_) {
42 return;
43 }
44 PictureInPictureManager::DetachAutoStartController(handleId_, weakRef_);
45 }
46
CreatePictureInPictureWindow(StartPipType startType)47 WMError PictureInPictureController::CreatePictureInPictureWindow(StartPipType startType)
48 {
49 if (pipOption_ == nullptr || pipOption_->GetContext() == nullptr) {
50 TLOGE(WmsLogTag::WMS_PIP, "Create pip failed, invalid pipOption");
51 return WMError::WM_ERROR_PIP_CREATE_FAILED;
52 }
53 mainWindowXComponentController_ = pipOption_->GetXComponentController();
54 if ((mainWindowXComponentController_ == nullptr && !IsTypeNodeEnabled()) || mainWindow_ == nullptr) {
55 TLOGE(WmsLogTag::WMS_PIP, "mainWindowXComponentController or mainWindow is nullptr");
56 return WMError::WM_ERROR_PIP_CREATE_FAILED;
57 }
58 TLOGI(WmsLogTag::WMS_PIP, "mainWindow:%{public}u, mainWindowState:%{public}u",
59 mainWindowId_, mainWindow_->GetWindowState());
60 mainWindowLifeCycleListener_ = sptr<PictureInPictureController::WindowLifeCycleListener>::MakeSptr();
61 mainWindow_->RegisterLifeCycleListener(mainWindowLifeCycleListener_);
62 if (startType != StartPipType::AUTO_START && mainWindow_->GetWindowState() != WindowState::STATE_SHOWN) {
63 TLOGE(WmsLogTag::WMS_PIP, "mainWindow is not shown. create failed.");
64 return WMError::WM_ERROR_PIP_CREATE_FAILED;
65 }
66 UpdateWinRectByComponent();
67 auto windowOption = sptr<WindowOption>::MakeSptr();
68 windowOption->SetWindowName(PIP_WINDOW_NAME);
69 windowOption->SetWindowType(WindowType::WINDOW_TYPE_PIP);
70 windowOption->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
71 windowOption->SetWindowRect(windowRect_);
72 windowOption->SetKeepScreenOn(true);
73 windowOption->SetTouchable(false);
74 WMError errCode = WMError::WM_OK;
75 PiPTemplateInfo pipTemplateInfo;
76 pipOption_->GetPiPTemplateInfo(pipTemplateInfo);
77 auto context = static_cast<std::weak_ptr<AbilityRuntime::Context>*>(pipOption_->GetContext());
78 const std::shared_ptr<AbilityRuntime::Context>& abilityContext = context->lock();
79 SingletonContainer::Get<PiPReporter>().SetCurrentPackageName(abilityContext->GetApplicationInfo()->name);
80 sptr<Window> window = Window::CreatePiP(windowOption, pipTemplateInfo, context->lock(), errCode);
81 if (window == nullptr || errCode != WMError::WM_OK) {
82 TLOGW(WmsLogTag::WMS_PIP, "Window create failed, reason: %{public}d", errCode);
83 return WMError::WM_ERROR_PIP_CREATE_FAILED;
84 }
85 window_ = window;
86 window_->UpdatePiPRect(windowRect_, WindowSizeChangeReason::PIP_START);
87 PictureInPictureManager::PutPipControllerInfo(window_->GetWindowId(), this);
88 return WMError::WM_OK;
89 }
90
StartPictureInPicture(StartPipType startType)91 WMError PictureInPictureController::StartPictureInPicture(StartPipType startType)
92 {
93 TLOGI(WmsLogTag::WMS_PIP, "called");
94 if (pipOption_ == nullptr || pipOption_->GetContext() == nullptr) {
95 TLOGE(WmsLogTag::WMS_PIP, "pipOption is null or Get PictureInPictureOption failed");
96 return WMError::WM_ERROR_PIP_CREATE_FAILED;
97 }
98 if (curState_ == PiPWindowState::STATE_STARTING || curState_ == PiPWindowState::STATE_STARTED) {
99 TLOGW(WmsLogTag::WMS_PIP, "pipWindow is starting, state: %{public}u, id: %{public}u, mainWindow: %{public}u",
100 curState_, (window_ == nullptr) ? INVALID_WINDOW_ID : window_->GetWindowId(), mainWindowId_);
101 SingletonContainer::Get<PiPReporter>().ReportPiPStartWindow(static_cast<int32_t>(startType),
102 pipOption_->GetPipTemplate(), PipConst::FAILED, "Pip window is starting");
103 return WMError::WM_ERROR_PIP_REPEAT_OPERATION;
104 }
105 if (!IsPullPiPAndHandleNavigation()) {
106 TLOGE(WmsLogTag::WMS_PIP, "Navigation operate failed");
107 return WMError::WM_ERROR_PIP_CREATE_FAILED;
108 }
109 curState_ = PiPWindowState::STATE_STARTING;
110 if (PictureInPictureManager::HasActiveController() && !PictureInPictureManager::IsActiveController(weakRef_)) {
111 // if current controller is not the active one, but belongs to the same mainWindow, reserve pipWindow
112 if (PictureInPictureManager::IsAttachedToSameWindow(mainWindowId_)) {
113 window_ = PictureInPictureManager::GetCurrentWindow();
114 if (window_ == nullptr) {
115 TLOGE(WmsLogTag::WMS_PIP, "Reuse pipWindow failed");
116 curState_ = PiPWindowState::STATE_UNDEFINED;
117 return WMError::WM_ERROR_PIP_CREATE_FAILED;
118 }
119 TLOGI(WmsLogTag::WMS_PIP, "Reuse pipWindow: %{public}u as attached to the same mainWindow: %{public}u",
120 window_->GetWindowId(), mainWindowId_);
121 PictureInPictureManager::DoClose(false, false);
122 mainWindowXComponentController_ = IsTypeNodeEnabled() ? nullptr : pipOption_->GetXComponentController();
123 UpdateWinRectByComponent();
124 UpdateContentSize(windowRect_.width_, windowRect_.height_);
125 PictureInPictureManager::PutPipControllerInfo(window_->GetWindowId(), this);
126 WMError err = ShowPictureInPictureWindow(startType);
127 if (err != WMError::WM_OK) {
128 curState_ = PiPWindowState::STATE_UNDEFINED;
129 } else {
130 curState_ = PiPWindowState::STATE_STARTED;
131 }
132 return err;
133 }
134 // otherwise, stop the previous one
135 PictureInPictureManager::DoClose(true, true);
136 }
137 return StartPictureInPictureInner(startType);
138 }
139
SetAutoStartEnabled(bool enable)140 void PictureInPictureController::SetAutoStartEnabled(bool enable)
141 {
142 TLOGI(WmsLogTag::WMS_PIP, "enable: %{public}u, mainWindow: %{public}u", enable, mainWindowId_);
143 isAutoStartEnabled_ = enable;
144 if (mainWindow_ == nullptr) {
145 return;
146 }
147 if (!pipOption_) {
148 TLOGE(WmsLogTag::WMS_PIP, "pipOption is null");
149 return;
150 }
151 uint32_t priority = pipOption_->GetPipPriority(pipOption_->GetPipTemplate());
152 uint32_t contentWidth = 0;
153 uint32_t contentHeight = 0;
154 pipOption_->GetContentSize(contentWidth, contentHeight);
155 if (isAutoStartEnabled_) {
156 // cache navigation here as we cannot get containerId while BG
157 if (!IsPullPiPAndHandleNavigation()) {
158 TLOGE(WmsLogTag::WMS_PIP, "Navigation operate failed");
159 isAutoStartEnabled_ = false;
160 mainWindow_->SetAutoStartPiP(false, priority, contentWidth, contentHeight);
161 return;
162 }
163 mainWindow_->SetAutoStartPiP(true, priority, contentWidth, contentHeight);
164 PictureInPictureManager::AttachAutoStartController(handleId_, weakRef_);
165 } else {
166 mainWindow_->SetAutoStartPiP(false, priority, contentWidth, contentHeight);
167 PictureInPictureManager::DetachAutoStartController(handleId_, weakRef_);
168 if (IsTypeNodeEnabled()) {
169 TLOGI(WmsLogTag::WMS_PIP, "typeNode enabled");
170 return;
171 }
172 std::string navId = pipOption_->GetNavigationId();
173 if (!navId.empty()) {
174 auto navController = NavigationController::GetNavigationController(mainWindow_->GetUIContent(), navId);
175 if (navController) {
176 navController->DeletePIPMode(handleId_);
177 TLOGI(WmsLogTag::WMS_PIP, "Delete pip mode id: %{public}d", handleId_);
178 }
179 }
180 }
181 }
182
IsAutoStartEnabled(bool & enable) const183 void PictureInPictureController::IsAutoStartEnabled(bool& enable) const
184 {
185 enable = isAutoStartEnabled_;
186 }
187
SetUIContent() const188 void PictureInPictureController::SetUIContent() const
189 {
190 napi_value storage = nullptr;
191 napi_ref storageRef = pipOption_->GetStorageRef();
192 if (storageRef != nullptr) {
193 napi_get_reference_value(env_, storageRef, &storage);
194 TLOGI(WmsLogTag::WMS_PIP, "startPiP with localStorage");
195 }
196 window_->SetUIContentByAbc(PIP_CONTENT_PATH, env_, storage, nullptr);
197 }
198
UpdateContentSize(int32_t width,int32_t height)199 void PictureInPictureController::UpdateContentSize(int32_t width, int32_t height)
200 {
201 if (width <= 0 || height <= 0) {
202 TLOGE(WmsLogTag::WMS_PIP, "invalid size");
203 return;
204 }
205 if (pipOption_ == nullptr) {
206 TLOGE(WmsLogTag::WMS_PIP, "pipOption_ is nullptr");
207 return;
208 }
209 if (mainWindow_ != nullptr) {
210 TLOGI(WmsLogTag::WMS_PIP, "mainWindow width:%{public}u height:%{public}u", width, height);
211 uint32_t priority = pipOption_->GetPipPriority(pipOption_->GetPipTemplate());
212 uint32_t contentWidth = static_cast<uint32_t>(width);
213 uint32_t contentHeight = static_cast<uint32_t>(height);
214 mainWindow_->SetAutoStartPiP(isAutoStartEnabled_, priority, contentWidth, contentHeight);
215 }
216 pipOption_->SetContentSize(static_cast<uint32_t>(width), static_cast<uint32_t>(height));
217 if (curState_ != PiPWindowState::STATE_STARTED) {
218 TLOGD(WmsLogTag::WMS_PIP, "UpdateContentSize is disabled when state: %{public}u", curState_);
219 return;
220 }
221 if (window_ == nullptr) {
222 TLOGE(WmsLogTag::WMS_PIP, "pipWindow not exist");
223 return;
224 }
225 if (mainWindowXComponentController_ && !IsTypeNodeEnabled()) {
226 float posX = 0;
227 float posY = 0;
228 float newWidth = 0;
229 float newHeight = 0;
230 mainWindowXComponentController_->GetGlobalPosition(posX, posY);
231 mainWindowXComponentController_->GetSize(newWidth, newHeight);
232 bool isSizeChange = IsContentSizeChanged(newWidth, newHeight, posX, posY);
233 if (isSizeChange) {
234 Rect r = {static_cast<int32_t>(posX), static_cast<int32_t>(posY),
235 static_cast<uint32_t>(newWidth), static_cast<uint32_t>(newHeight)};
236 window_->UpdatePiPRect(r, WindowSizeChangeReason::TRANSFORM);
237 }
238 }
239 TLOGI(WmsLogTag::WMS_PIP, "window: %{public}u width:%{public}u height:%{public}u",
240 window_->GetWindowId(), width, height);
241 Rect rect = {0, 0, width, height};
242 window_->UpdatePiPRect(rect, WindowSizeChangeReason::PIP_RATIO_CHANGE);
243 SingletonContainer::Get<PiPReporter>().ReportPiPRatio(width, height);
244 }
245
UpdateContentNodeRef(napi_ref nodeRef)246 void PictureInPictureController::UpdateContentNodeRef(napi_ref nodeRef)
247 {
248 TLOGI(WmsLogTag::WMS_PIP, "in");
249 if (pipOption_ == nullptr) {
250 TLOGE(WmsLogTag::WMS_PIP, "option is null");
251 SingletonContainer::Get<PiPReporter>().ReportPiPUpdateContent(static_cast<int32_t>(IsTypeNodeEnabled()),
252 0, PipConst::FAILED, "option is null");
253 return;
254 }
255 pipOption_->SetTypeNodeRef(nodeRef);
256 if (IsTypeNodeEnabled()) {
257 NotifyNodeUpdate(nodeRef);
258 return;
259 }
260 ResetExtController();
261 NotifyNodeUpdate(nodeRef);
262 if (isAutoStartEnabled_) {
263 std::string navId = pipOption_->GetNavigationId();
264 if (!navId.empty()) {
265 auto navController = NavigationController::GetNavigationController(mainWindow_->GetUIContent(), navId);
266 if (navController) {
267 navController->DeletePIPMode(handleId_);
268 TLOGI(WmsLogTag::WMS_PIP, "Delete pip mode id: %{public}d", handleId_);
269 }
270 }
271 }
272 pipOption_->SetTypeNodeEnabled(true);
273 }
274
NotifyNodeUpdate(napi_ref nodeRef)275 void PictureInPictureController::NotifyNodeUpdate(napi_ref nodeRef)
276 {
277 TLOGI(WmsLogTag::WMS_PIP, "in");
278 if (nodeRef == nullptr) {
279 TLOGE(WmsLogTag::WMS_PIP, "invalid nodeRef");
280 SingletonContainer::Get<PiPReporter>().ReportPiPUpdateContent(static_cast<int32_t>(IsTypeNodeEnabled()),
281 pipOption_->GetPipTemplate(), PipConst::FAILED, "invalid nodeRef");
282 return;
283 }
284 if (PictureInPictureManager::IsActiveController(weakRef_)) {
285 for (auto& listener : pipTypeNodeObserver_) {
286 listener->OnPipTypeNodeChange(nodeRef);
287 }
288 SingletonContainer::Get<PiPReporter>().ReportPiPUpdateContent(static_cast<int32_t>(IsTypeNodeEnabled()),
289 pipOption_->GetPipTemplate(), PipConst::PIP_SUCCESS, "updateNode success");
290 }
291 }
292
PrepareSource()293 void PictureInPictureController::PrepareSource()
294 {
295 TLOGI(WmsLogTag::WMS_PIP, "in");
296 if (IsTypeNodeEnabled()) {
297 TLOGI(WmsLogTag::WMS_PIP, "typeNode enabled");
298 return;
299 }
300 if (mainWindow_ == nullptr) {
301 TLOGE(WmsLogTag::WMS_PIP, "mainWindow is nullptr");
302 return;
303 }
304 std::string navId = pipOption_->GetNavigationId();
305 if (navId != "") {
306 auto navController = NavigationController::GetNavigationController(mainWindow_->GetUIContent(), navId);
307 if (navController) {
308 navController->PushInPIP(handleId_);
309 TLOGI(WmsLogTag::WMS_PIP, "Push in pip handleId: %{public}d", handleId_);
310 } else {
311 TLOGE(WmsLogTag::WMS_PIP, "navController is nullptr");
312 }
313 }
314 }
315
RestorePictureInPictureWindow()316 void PictureInPictureController::RestorePictureInPictureWindow()
317 {
318 StopPictureInPicture(true, StopPipType::NULL_STOP, true);
319 SingletonContainer::Get<PiPReporter>().ReportPiPRestore();
320 TLOGI(WmsLogTag::WMS_PIP, "restore pip main window finished");
321 }
322
UpdateWinRectByComponent()323 void PictureInPictureController::UpdateWinRectByComponent()
324 {
325 if (IsTypeNodeEnabled()) {
326 uint32_t contentWidth = 0;
327 uint32_t contentHeight = 0;
328 pipOption_->GetContentSize(contentWidth, contentHeight);
329 if (contentWidth == 0 || contentHeight == 0) {
330 contentWidth = PipConst::DEFAULT_ASPECT_RATIOS[0];
331 contentHeight = PipConst::DEFAULT_ASPECT_RATIOS[1];
332 }
333 windowRect_.posX_ = 0;
334 windowRect_.posY_ = 0;
335 windowRect_.width_ = contentWidth;
336 windowRect_.height_ = contentHeight;
337 return;
338 }
339 if (!mainWindowXComponentController_) {
340 TLOGE(WmsLogTag::WMS_PIP, "main window xComponent not set");
341 return;
342 }
343 float posX = 0;
344 float posY = 0;
345 float width = 0;
346 float height = 0;
347 mainWindowXComponentController_->GetGlobalPosition(posX, posY);
348 mainWindowXComponentController_->GetSize(width, height);
349 windowRect_.width_ = static_cast<uint32_t>(width);
350 windowRect_.height_ = static_cast<uint32_t>(height);
351 if (windowRect_.width_ == 0 || windowRect_.height_ == 0) {
352 uint32_t contentWidth = 0;
353 uint32_t contentHeight = 0;
354 pipOption_->GetContentSize(contentWidth, contentHeight);
355 windowRect_.width_ = contentWidth;
356 windowRect_.height_ = contentHeight;
357 }
358 windowRect_.posX_ = static_cast<int32_t>(posX);
359 windowRect_.posY_ = static_cast<int32_t>(posY);
360 TLOGD(WmsLogTag::WMS_PIP, "position width: %{public}u, height: %{public}u, posX: %{public}d, posY: %{public}d",
361 windowRect_.width_, windowRect_.height_, windowRect_.posX_, windowRect_.posY_);
362 }
363
UpdatePiPSourceRect() const364 void PictureInPictureController::UpdatePiPSourceRect() const
365 {
366 if (IsTypeNodeEnabled() && window_ != nullptr) {
367 Rect rect = {0, 0, 0, 0};
368 TLOGI(WmsLogTag::WMS_PIP, "use typeNode, unable to locate source rect");
369 window_->UpdatePiPRect(rect, WindowSizeChangeReason::PIP_RESTORE);
370 return;
371 }
372 if (mainWindowXComponentController_ == nullptr || window_ == nullptr) {
373 TLOGE(WmsLogTag::WMS_PIP, "xcomponent controller not valid");
374 return;
375 }
376 float posX = 0;
377 float posY = 0;
378 float width = 0;
379 float height = 0;
380 mainWindowXComponentController_->GetGlobalPosition(posX, posY);
381 mainWindowXComponentController_->GetSize(width, height);
382 Rect rect = { posX, posY, width, height };
383 TLOGI(WmsLogTag::WMS_PIP, "result rect: [%{public}d, %{public}d, %{public}u, %{public}u]",
384 rect.posX_, rect.posY_, rect.width_, rect.height_);
385 window_->UpdatePiPRect(rect, WindowSizeChangeReason::PIP_RESTORE);
386 }
387
ResetExtController()388 void PictureInPictureController::ResetExtController()
389 {
390 TLOGI(WmsLogTag::WMS_PIP, "called");
391 if (IsTypeNodeEnabled()) {
392 TLOGI(WmsLogTag::WMS_PIP, "skip resetExtController as nodeController enabled");
393 return;
394 }
395 if (mainWindowXComponentController_ == nullptr || pipXComponentController_ == nullptr) {
396 TLOGE(WmsLogTag::WMS_PIP, "error when resetExtController, one of the xComponentController is null");
397 return;
398 }
399 XComponentControllerErrorCode errorCode =
400 mainWindowXComponentController_->ResetExtController(pipXComponentController_);
401 if (errorCode != XComponentControllerErrorCode::XCOMPONENT_CONTROLLER_NO_ERROR) {
402 TLOGE(WmsLogTag::WMS_PIP, "swap xComponent failed, errorCode: %{public}u", errorCode);
403 }
404 }
405
SetXComponentController(std::shared_ptr<XComponentController> xComponentController)406 WMError PictureInPictureController::SetXComponentController(std::shared_ptr<XComponentController> xComponentController)
407 {
408 TLOGI(WmsLogTag::WMS_PIP, "called");
409 if (IsTypeNodeEnabled()) {
410 TLOGI(WmsLogTag::WMS_PIP, "skip as nodeController enabled");
411 return WMError::WM_OK;
412 }
413 pipXComponentController_ = xComponentController;
414 if (window_ == nullptr) {
415 TLOGE(WmsLogTag::WMS_PIP, "window is nullptr when set XComponentController");
416 return WMError::WM_ERROR_PIP_STATE_ABNORMALLY;
417 }
418 if (mainWindowXComponentController_ == nullptr || pipXComponentController_ == nullptr) {
419 TLOGE(WmsLogTag::WMS_PIP, "error when setXController, one of the xComponentController is null");
420 return WMError::WM_ERROR_PIP_STATE_ABNORMALLY;
421 }
422 XComponentControllerErrorCode errorCode =
423 mainWindowXComponentController_->SetExtController(pipXComponentController_);
424 if (errorCode != XComponentControllerErrorCode::XCOMPONENT_CONTROLLER_NO_ERROR) {
425 TLOGE(WmsLogTag::WMS_PIP, "swap xComponent failed, errorCode: %{public}u", errorCode);
426 return WMError::WM_ERROR_PIP_INTERNAL_ERROR;
427 }
428 OnPictureInPictureStart();
429 return WMError::WM_OK;
430 }
431
IsTypeNodeEnabled() const432 bool PictureInPictureController::IsTypeNodeEnabled() const
433 {
434 return pipOption_ != nullptr ? pipOption_->IsTypeNodeEnabled() : false;
435 }
436
IsPullPiPAndHandleNavigation()437 bool PictureInPictureController::IsPullPiPAndHandleNavigation()
438 {
439 if (IsTypeNodeEnabled()) {
440 TLOGI(WmsLogTag::WMS_PIP, "App use typeNode");
441 return true;
442 }
443 if (pipOption_->GetNavigationId() == "") {
444 TLOGI(WmsLogTag::WMS_PIP, "App not use navigation");
445 return true;
446 }
447 if (mainWindow_ == nullptr) {
448 TLOGE(WmsLogTag::WMS_PIP, "Main window init error");
449 return false;
450 }
451 std::string navId = pipOption_->GetNavigationId();
452 auto navController = NavigationController::GetNavigationController(mainWindow_->GetUIContent(), navId);
453 if (navController) {
454 if (navController->IsNavDestinationInTopStack()) {
455 handleId_ = navController->GetTopHandle();
456 if (handleId_ == -1) {
457 TLOGE(WmsLogTag::WMS_PIP, "Get top handle error");
458 return false;
459 }
460 if (firstHandleId_ != -1) {
461 handleId_ = firstHandleId_;
462 navController->SetInPIPMode(handleId_);
463 TLOGI(WmsLogTag::WMS_PIP, "Cache first navigation");
464 } else {
465 TLOGI(WmsLogTag::WMS_PIP, "First top handle id: %{public}d", handleId_);
466 firstHandleId_ = handleId_;
467 navController->SetInPIPMode(handleId_);
468 }
469 return true;
470 } else {
471 TLOGE(WmsLogTag::WMS_PIP, "Top is not navDestination");
472 return false;
473 }
474 } else {
475 TLOGE(WmsLogTag::WMS_PIP, "Get navController error");
476 }
477 return false;
478 }
479
GetPiPNavigationId()480 std::string PictureInPictureController::GetPiPNavigationId()
481 {
482 return (pipOption_ != nullptr && !IsTypeNodeEnabled()) ? pipOption_->GetNavigationId() : "";
483 }
484
GetCustomNodeController()485 napi_ref PictureInPictureController::GetCustomNodeController()
486 {
487 return pipOption_ == nullptr ? nullptr : pipOption_->GetNodeControllerRef();
488 }
489
GetTypeNode() const490 napi_ref PictureInPictureController::GetTypeNode() const
491 {
492 return pipOption_ == nullptr ? nullptr : pipOption_->GetTypeNodeRef();
493 }
494
495 } // namespace Rosen
496 } // namespace OHOS