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
21 using namespace OHOS;
22
Display(int32_t duration,std::vector<BootAnimationConfig> & configs)23 void BootAssociativeDisplayStrategy::Display(int32_t duration, std::vector<BootAnimationConfig>& configs)
24 {
25 LOGI("BootAssociativeDisplayStrategy START");
26 if (configs.size() <= 1) {
27 LOGE("config size error");
28 return;
29 }
30
31 if (IsExtraVideoExist(configs)) {
32 LOGI("not support play extra video for multi screen now");
33 return;
34 }
35
36 Rosen::RSInterfaces& interface = Rosen::RSInterfaces::GetInstance();
37 Rosen::ScreenId defaultId = interface.GetDefaultScreenId();
38 Rosen::ScreenId activeId = interface.GetActiveScreenId();
39 LOGI("defaultId: " BPUBU64 ", activeId: " BPUBU64 "", defaultId, activeId);
40 if (defaultId != activeId) {
41 LOGD("SetScreenPowerStatus POWER_STATUS_OFF_FAKE: " BPUBU64 "", defaultId);
42 interface.SetScreenPowerStatus(defaultId, Rosen::ScreenPowerStatus::POWER_STATUS_OFF_FAKE);
43 LOGD("SetScreenPowerStatus POWER_STATUS_ON: " BPUBU64 "", activeId);
44 interface.SetScreenPowerStatus(activeId, Rosen::ScreenPowerStatus::POWER_STATUS_ON);
45 }
46
47 for (const auto& config : configs) {
48 if (config.screenId != activeId) {
49 continue;
50 }
51
52 Rosen::RSScreenModeInfo modeInfo = interface.GetScreenActiveMode(config.screenId);
53 int screenWidth = modeInfo.GetScreenWidth();
54 int screenHeight = modeInfo.GetScreenHeight();
55 operator_ = std::make_shared<BootAnimationOperation>();
56 operator_->Init(config, screenWidth, screenHeight, duration);
57 operator_->GetThread().join();
58
59 if (CheckNeedOtaCompile()) {
60 bootCompileProgress_ = std::make_shared<BootCompileProgress>();
61 bootCompileProgress_->Init(config);
62 }
63
64 while (!CheckExitAnimation()) {
65 usleep(SLEEP_TIME_US);
66 }
67 }
68 }
69
IsExtraVideoExist(const std::vector<BootAnimationConfig> & configs)70 bool BootAssociativeDisplayStrategy::IsExtraVideoExist(const std::vector<BootAnimationConfig>& configs)
71 {
72 for (const auto& config : configs) {
73 if (config.videoExtPath.size() != 0) {
74 return true;
75 }
76 }
77 return false;
78 }
79