1/* 2 * Copyright (c) 2021-2023 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 "test/mock/base/mock_system_properties.h" 17 18#include <string> 19 20#include "base/utils/system_properties.h" 21 22namespace OHOS::Ace { 23namespace { 24constexpr int32_t ORIENTATION_PORTRAIT = 0; 25constexpr int32_t ORIENTATION_LANDSCAPE = 1; 26 27void Swap(int32_t& deviceWidth, int32_t& deviceHeight) 28{ 29 int32_t temp = deviceWidth; 30 deviceWidth = deviceHeight; 31 deviceHeight = temp; 32} 33} // namespace 34 35DeviceType SystemProperties::deviceType_ = DeviceType::PHONE; 36DeviceOrientation SystemProperties::orientation_ { DeviceOrientation::PORTRAIT }; 37bool SystemProperties::isHookModeEnabled_ = false; 38bool SystemProperties::rosenBackendEnabled_ = true; 39bool SystemProperties::windowAnimationEnabled_ = true; 40std::atomic<bool> SystemProperties::layoutTraceEnable_(false); 41std::atomic<bool> SystemProperties::traceInputEventEnable_(false); 42bool SystemProperties::buildTraceEnable_ = false; 43bool SystemProperties::syncDebugTraceEnable_ = false; 44bool SystemProperties::pixelRoundEnable_ = true; 45bool SystemProperties::textTraceEnable_ = false; 46bool SystemProperties::syntaxTraceEnable_ = false; 47double SystemProperties::resolution_ = 0.0; 48constexpr float defaultAnimationScale = 1.0f; 49bool SystemProperties::extSurfaceEnabled_ = false; 50uint32_t SystemProperties::dumpFrameCount_ = 0; 51bool SystemProperties::debugEnabled_ = false; 52bool SystemProperties::layoutDetectEnabled_ = false; 53ColorMode SystemProperties::colorMode_ { ColorMode::LIGHT }; 54int32_t SystemProperties::deviceWidth_ = 720; 55int32_t SystemProperties::deviceHeight_ = 1280; 56bool SystemProperties::debugOffsetLogEnabled_ = false; 57bool SystemProperties::downloadByNetworkEnabled_ = false; 58int32_t SystemProperties::devicePhysicalWidth_ = 0; 59int32_t SystemProperties::devicePhysicalHeight_ = 0; 60bool SystemProperties::enableScrollableItemPool_ = false; 61bool SystemProperties::navigationBlurEnabled_ = false; 62bool SystemProperties::gridCacheEnabled_ = true; 63bool SystemProperties::sideBarContainerBlurEnable_ = false; 64std::atomic<bool> SystemProperties::stateManagerEnable_(false); 65std::atomic<bool> SystemProperties::acePerformanceMonitorEnable_(false); 66bool SystemProperties::aceCommercialLogEnable_ = false; 67std::atomic<bool> SystemProperties::debugBoundaryEnabled_(false); 68bool SystemProperties::developerModeOn_ = false; 69bool SystemProperties::faultInjectEnabled_ = false; 70bool SystemProperties::imageFileCacheConvertAstc_ = true; 71bool SystemProperties::imageFrameworkEnable_ = true; 72bool SystemProperties::debugAutoUIEnabled_ = false; 73float SystemProperties::dragStartDampingRatio_ = 0.2f; 74float SystemProperties::dragStartPanDisThreshold_ = 10.0f; 75std::pair<float, float> SystemProperties::brightUpPercent_ = {}; 76int32_t SystemProperties::imageFileCacheConvertAstcThreshold_ = 3; 77 78bool g_irregularGrid = true; 79bool g_segmentedWaterflow = true; 80 81float SystemProperties::GetFontWeightScale() 82{ 83 // Default value of font weight scale is 1.0. 84 return 1.0f; 85} 86 87DeviceType SystemProperties::GetDeviceType() 88{ 89 return deviceType_; 90} 91 92bool SystemProperties::GetDebugEnabled() 93{ 94 return debugEnabled_; 95} 96 97bool SystemProperties::GetLayoutDetectEnabled() 98{ 99 return layoutDetectEnabled_; 100} 101 102float SystemProperties::GetAnimationScale() 103{ 104 return defaultAnimationScale; 105} 106 107bool SystemProperties::GetIsUseMemoryMonitor() 108{ 109 return false; 110} 111 112bool SystemProperties::IsOpIncEnable() 113{ 114 return true; 115} 116 117void SystemProperties::SetDeviceOrientation(int32_t orientation) 118{ 119 if (orientation == ORIENTATION_PORTRAIT && orientation_ != DeviceOrientation::PORTRAIT) { 120 Swap(deviceWidth_, deviceHeight_); 121 orientation_ = DeviceOrientation::PORTRAIT; 122 } else if (orientation == ORIENTATION_LANDSCAPE && orientation_ != DeviceOrientation::LANDSCAPE) { 123 Swap(deviceWidth_, deviceHeight_); 124 orientation_ = DeviceOrientation::LANDSCAPE; 125 } 126} 127 128bool SystemProperties::Is24HourClock() 129{ 130 return false; 131} 132 133bool SystemProperties::GetTitleStyleEnabled() 134{ 135 return false; 136} 137 138std::string SystemProperties::GetCustomTitleFilePath() 139{ 140 return {}; 141} 142 143bool SystemProperties::GetDisplaySyncSkipEnabled() 144{ 145 return true; 146} 147 148bool SystemProperties::GetNavigationBlurEnabled() 149{ 150 return navigationBlurEnabled_; 151} 152 153bool SystemProperties::GetGridCacheEnabled() 154{ 155 return gridCacheEnabled_; 156} 157 158bool SystemProperties::GetGridIrregularLayoutEnabled() 159{ 160 return g_irregularGrid; 161} 162 163bool SystemProperties::WaterFlowUseSegmentedLayout() 164{ 165 return g_segmentedWaterflow; 166} 167 168bool SystemProperties::GetSideBarContainerBlurEnable() 169{ 170 return sideBarContainerBlurEnable_; 171} 172 173float SystemProperties::GetDefaultResolution() 174{ 175 return 1.0f; 176} 177 178std::string SystemProperties::GetAtomicServiceBundleName() 179{ 180 return {}; 181} 182 183float SystemProperties::GetDragStartDampingRatio() 184{ 185 return dragStartDampingRatio_; 186} 187 188float SystemProperties::GetDragStartPanDistanceThreshold() 189{ 190 return dragStartPanDisThreshold_; 191} 192 193bool SystemProperties::GetAllowWindowOpenMethodEnabled() 194{ 195 return false; 196} 197 198bool SystemProperties::IsSmallFoldProduct() 199{ 200 return false; 201} 202 203std::string SystemProperties::GetDebugInspectorId() 204{ 205 return "N/A"; 206} 207 208double SystemProperties::GetSrollableVelocityScale() 209{ 210 return 0.0; 211} 212 213double SystemProperties::GetSrollableFriction() 214{ 215 return 0.0; 216} 217} // namespace OHOS::Ace 218