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 "core/common/display_info_utils.h"
17 
18 #include "core/common/display_info.h"
19 #include "window_display.h"
20 
21 namespace OHOS::Previewer {
22     class PreviewerDisplay;
23 }
24 namespace OHOS::Ace {
GetInstance()25 DisplayInfoUtils& DisplayInfoUtils::GetInstance()
26 {
27     static DisplayInfoUtils instance;
28     return instance;
29 }
30 
GetDisplayInfo()31 RefPtr<DisplayInfo> DisplayInfoUtils::GetDisplayInfo()
32 {
33     return AceType::MakeRefPtr<DisplayInfo>();
34 }
35 
InitIsFoldable()36 void DisplayInfoUtils::InitIsFoldable() {}
37 
IsFoldable()38 bool DisplayInfoUtils::IsFoldable()
39 {
40     hasInitIsFoldable = true;
41     return OHOS::Previewer::PreviewerDisplay::GetInstance().IsFoldable();
42 }
43 
GetCurrentFoldStatus()44 FoldStatus DisplayInfoUtils::GetCurrentFoldStatus()
45 {
46     auto dmFoldStatus = OHOS::Previewer::PreviewerDisplay::GetInstance().GetFoldStatus();
47     CHECK_NULL_RETURN(displayInfo_, FoldStatus::UNKNOWN);
48     displayInfo_->SetFoldStatus(static_cast<FoldStatus>(static_cast<uint32_t>(dmFoldStatus)));
49     return displayInfo_->GetFoldStatus();
50 }
51 } // namespace OHOS::Ace::DisplayInfoUtils
52