1 /* 2 * Copyright (c) 2021 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 "system_info.h" 17 18 #include "ace_log.h" 19 #include "product_adapter.h" 20 #include "screen.h" 21 #include "securec.h" 22 23 namespace OHOS { 24 namespace ACELite { GetInstance()25SystemInfo &SystemInfo::GetInstance() 26 { 27 static SystemInfo systemInfo; 28 return systemInfo; 29 } 30 Initialize()31void SystemInfo::Initialize() 32 { 33 // reset 34 screenWidth_ = screenHeight_ = 0; 35 ProductAdapter::GetScreenSize(screenWidth_, screenHeight_); 36 if (screenWidth_ != 0 && screenHeight_ != 0) { 37 aspectRatio_ = (float)screenWidth_ / (float)screenHeight_; 38 } else { 39 aspectRatio_ = 0; 40 } 41 isRoundScreen_ = (Screen::GetInstance().GetScreenShape() == ScreenShape::CIRCLE); 42 deviceType_ = ProductAdapter::GetDeviceType(); 43 } 44 GetAspectRatio() const45float SystemInfo::GetAspectRatio() const 46 { 47 return aspectRatio_; 48 } 49 GetScreenHeight() const50uint16_t SystemInfo::GetScreenHeight() const 51 { 52 return screenHeight_; 53 } 54 GetScreenWidth() const55uint16_t SystemInfo::GetScreenWidth() const 56 { 57 return screenWidth_; 58 } 59 GetDeviceType() const60const char *SystemInfo::GetDeviceType() const 61 { 62 return deviceType_; 63 } 64 IsRoundScreen() const65bool SystemInfo::IsRoundScreen() const 66 { 67 return isRoundScreen_; 68 } 69 } // namespace ACELite 70 } // namespace OHOS 71