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_independent_display_strategy.h"
17 
18 #include "log.h"
19 #include "transaction/rs_interfaces.h"
20 
21 using namespace OHOS;
Display(int32_t duration,std::vector<BootAnimationConfig> & configs)22 void BootIndependentDisplayStrategy::Display(int32_t duration, std::vector<BootAnimationConfig>& configs)
23 {
24     LOGI("BootIndependentDisplayStrategy START");
25     Rosen::RSInterfaces& interface = Rosen::RSInterfaces::GetInstance();
26     BootAnimationConfig screenConfig;
27     for (const auto& config : configs) {
28         interface.SetScreenPowerStatus(config.screenId, Rosen::ScreenPowerStatus::POWER_STATUS_ON);
29         Rosen::RSScreenModeInfo modeInfo = interface.GetScreenActiveMode(config.screenId);
30         int screenWidth = modeInfo.GetScreenWidth();
31         int screenHeight = modeInfo.GetScreenHeight();
32         std::shared_ptr<BootAnimationOperation> op = std::make_shared<BootAnimationOperation>();
33         Rosen::ScreenId defaultId = interface.GetDefaultScreenId();
34         if (config.screenId != defaultId) {
35             op->SetSoundEnable(false);
36         } else {
37             screenConfig = config;
38         }
39         op->Init(config, screenWidth, screenHeight, duration);
40         operators_.emplace_back(op);
41     }
42 
43     for (const auto& op : operators_) {
44         op->GetThread().join();
45     }
46 
47     if (CheckNeedOtaCompile()) {
48         bootCompileProgress_ = std::make_shared<BootCompileProgress>();
49         bootCompileProgress_->Init(screenConfig);
50     }
51 
52     while (!CheckExitAnimation()) {
53         usleep(SLEEP_TIME_US);
54     }
55 }
56