• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 "boot_associative_display_strategy.h"
17 
18 #include "log.h"
19 #include "transaction/rs_interfaces.h"
20 #include <parameters.h>
21 
22 using namespace OHOS;
23 
24 namespace {
25     const bool IS_COORDINATION_SUPPORT =
26         system::GetBoolParameter("const.window.foldabledevice.is_coordination_support", false);
27 }
28 
Display(int32_t duration,std::vector<BootAnimationConfig> & configs)29 void BootAssociativeDisplayStrategy::Display(int32_t duration, std::vector<BootAnimationConfig>& configs)
30 {
31     LOGI("BootAssociativeDisplayStrategy START");
32     if (configs.size() <= 1) {
33         LOGE("config size error");
34         return;
35     }
36 
37     if (IsExtraVideoExist(configs)) {
38         LOGI("not support play extra video for multi screen now");
39         return;
40     }
41 
42     Rosen::RSInterfaces& interface = Rosen::RSInterfaces::GetInstance();
43     Rosen::ScreenId defaultId = interface.GetDefaultScreenId();
44     Rosen::ScreenId activeId = interface.GetActiveScreenId();
45     LOGI("defaultId: " BPUBU64 ", activeId: " BPUBU64 "", defaultId, activeId);
46     bool isSupportCoordination = IsSupportCoordination();
47     LOGI("isSupportCoordination = %{public}d", isSupportCoordination);
48     if (defaultId != activeId && isSupportCoordination) {
49         LOGD("SetScreenPowerStatus POWER_STATUS_OFF_FAKE: " BPUBU64 "", defaultId);
50         interface.SetScreenPowerStatus(defaultId, Rosen::ScreenPowerStatus::POWER_STATUS_OFF_FAKE);
51         LOGD("SetScreenPowerStatus POWER_STATUS_ON: " BPUBU64 "", activeId);
52         interface.SetScreenPowerStatus(activeId, Rosen::ScreenPowerStatus::POWER_STATUS_ON);
53     }
54 
55     for (const auto& config : configs) {
56         if (config.screenId != activeId) {
57             continue;
58         }
59 
60         Rosen::RSScreenModeInfo modeInfo = interface.GetScreenActiveMode(config.screenId);
61         int screenWidth = modeInfo.GetScreenWidth();
62         int screenHeight = modeInfo.GetScreenHeight();
63         operator_ = std::make_shared<BootAnimationOperation>();
64         operator_->Init(config, screenWidth, screenHeight, duration);
65         if (operator_->GetThread().joinable()) {
66             operator_->GetThread().join();
67         }
68 
69         if (IsOtaUpdate()) {
70             bootCompileProgress_ = std::make_shared<BootCompileProgress>();
71             bootCompileProgress_->Init(configPath_, config);
72         }
73 
74         while (!CheckExitAnimation()) {
75             usleep(SLEEP_TIME_US);
76         }
77     }
78 }
79 
IsExtraVideoExist(const std::vector<BootAnimationConfig> & configs)80 bool BootAssociativeDisplayStrategy::IsExtraVideoExist(const std::vector<BootAnimationConfig>& configs)
81 {
82     for (const auto& config : configs) {
83         if (config.videoExtPath.size() != 0) {
84             return true;
85         }
86     }
87     return false;
88 }
89 
IsSupportCoordination()90 bool BootAssociativeDisplayStrategy::IsSupportCoordination()
91 {
92     // only psd return false
93     return IS_COORDINATION_SUPPORT || !(!FOLD_SCREEN_TYPE.empty() && FOLD_SCREEN_TYPE[0] == '2');
94 }