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