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 #include "util.h"
21
22 using namespace OHOS;
23
Display(int32_t duration,std::vector<BootAnimationConfig> & configs)24 void BootCompatibleDisplayStrategy::Display(int32_t duration, std::vector<BootAnimationConfig>& configs)
25 {
26 LOGI("BootCompatibleDisplayStrategy START");
27 if (configs.size() != 1) {
28 LOGE("config size error");
29 return;
30 }
31
32 Rosen::RSInterfaces& interface = Rosen::RSInterfaces::GetInstance();
33 for (auto& config : configs) {
34 config.screenId = interface.GetDefaultScreenId();
35 if (config.rotateScreenId >= 0) {
36 config.screenId = interface.GetActiveScreenId();
37 if (config.screenId > 0) {
38 interface.SetScreenPowerStatus(0, Rosen::ScreenPowerStatus::POWER_STATUS_OFF_FAKE);
39 interface.SetScreenPowerStatus(config.screenId, Rosen::ScreenPowerStatus::POWER_STATUS_ON);
40 config.rotateDegree = 0;
41 config.videoDefaultPath = config.videoExtraPath;
42 }
43 } else {
44 interface.SetScreenPowerStatus(config.screenId, Rosen::ScreenPowerStatus::POWER_STATUS_ON);
45 }
46
47 if (!config.videoExtPath.empty()) {
48 std::string status = GetHingeStatus();
49 auto iter = config.videoExtPath.find(status);
50 if (iter != config.videoExtPath.end()) {
51 config.videoDefaultPath = iter->second;
52 config.screenStatus = status;
53 }
54 }
55
56 Rosen::RSScreenModeInfo modeInfo = interface.GetScreenActiveMode(config.screenId);
57 int32_t screenWidth = modeInfo.GetScreenWidth();
58 int32_t screenHeight = modeInfo.GetScreenHeight();
59 operator_ = std::make_shared<BootAnimationOperation>();
60 operator_->Init(config, screenWidth, screenHeight, duration);
61 if (operator_->GetThread().joinable()) {
62 operator_->GetThread().join();
63 }
64
65 if (IsOtaUpdate()) {
66 bootCompileProgress_ = std::make_shared<BootCompileProgress>();
67 bootCompileProgress_->Init(configPath_, config);
68 }
69 }
70
71 while (!CheckExitAnimation()) {
72 usleep(SLEEP_TIME_US);
73 }
74 }
75