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_compatible_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 BootCompatibleDisplayStrategy::Display(int32_t duration, std::vector<BootAnimationConfig>& configs)
24 {
25 LOGI("BootCompatibleDisplayStrategy START");
26 if (configs.size() != 1) {
27 LOGE("config size error");
28 return;
29 }
30
31 Rosen::RSInterfaces& interface = Rosen::RSInterfaces::GetInstance();
32 for (auto& config : configs) {
33 config.screenId = interface.GetDefaultScreenId();
34 if (config.rotateScreenId >= 0) {
35 config.screenId = interface.GetActiveScreenId();
36 if (config.screenId > 0) {
37 interface.SetScreenPowerStatus(0, Rosen::ScreenPowerStatus::POWER_STATUS_OFF_FAKE);
38 interface.SetScreenPowerStatus(config.screenId, Rosen::ScreenPowerStatus::POWER_STATUS_ON);
39 config.rotateDegree = 0;
40 config.videoDefaultPath = config.videoExtraPath;
41 }
42 } else {
43 interface.SetScreenPowerStatus(config.screenId, Rosen::ScreenPowerStatus::POWER_STATUS_ON);
44 }
45
46 Rosen::RSScreenModeInfo modeInfo = interface.GetScreenActiveMode(config.screenId);
47 int32_t screenWidth = modeInfo.GetScreenWidth();
48 int32_t screenHeight = modeInfo.GetScreenHeight();
49 operator_ = std::make_shared<BootAnimationOperation>();
50 operator_->Init(config, screenWidth, screenHeight, duration);
51 operator_->GetThread().join();
52
53 if (CheckNeedOtaCompile()) {
54 bootCompileProgress_ = std::make_shared<BootCompileProgress>();
55 bootCompileProgress_->Init(config);
56 }
57 }
58
59 while (!CheckExitAnimation()) {
60 usleep(SLEEP_TIME_US);
61 }
62 }
63