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
22 namespace OHOS::Ace {
23 namespace MockSystemProperties {
24 bool g_isSuperFoldDisplayDevice = false;
25 }
26 namespace {
27 constexpr int32_t ORIENTATION_PORTRAIT = 0;
28 constexpr int32_t ORIENTATION_LANDSCAPE = 1;
29 constexpr int32_t DEFAULT_FORM_SHARED_IMAGE_CACHE_THRESHOLD = 20;
30
Swap(int32_t & deviceWidth,int32_t & deviceHeight)31 void Swap(int32_t& deviceWidth, int32_t& deviceHeight)
32 {
33 int32_t temp = deviceWidth;
34 deviceWidth = deviceHeight;
35 deviceHeight = temp;
36 }
37 } // namespace
38
39 DeviceType SystemProperties::deviceType_ = DeviceType::PHONE;
40 DeviceOrientation SystemProperties::orientation_ { DeviceOrientation::PORTRAIT };
41 bool SystemProperties::isHookModeEnabled_ = false;
42 bool SystemProperties::rosenBackendEnabled_ = true;
43 bool SystemProperties::windowAnimationEnabled_ = true;
44 std::atomic<bool> SystemProperties::layoutTraceEnable_(false);
45 std::atomic<bool> SystemProperties::traceInputEventEnable_(false);
46 bool SystemProperties::buildTraceEnable_ = false;
47 bool SystemProperties::dynamicDetectionTraceEnable_ = false;
48 bool SystemProperties::syncDebugTraceEnable_ = false;
49 bool SystemProperties::measureDebugTraceEnable_ = false;
50 bool SystemProperties::safeAreaDebugTraceEnable_ = false;
51 bool SystemProperties::pixelRoundEnable_ = true;
52 bool SystemProperties::textTraceEnable_ = false;
53 bool SystemProperties::vsyncModeTraceEnable_ = false;
54 bool SystemProperties::syntaxTraceEnable_ = false;
55 double SystemProperties::resolution_ = 0.0;
56 constexpr float defaultAnimationScale = 1.0f;
57 bool SystemProperties::extSurfaceEnabled_ = false;
58 uint32_t SystemProperties::dumpFrameCount_ = 0;
59 bool SystemProperties::debugEnabled_ = false;
60 DebugFlags SystemProperties::debugFlags_ = 0;
61 bool SystemProperties::containerDeleteFlag_ = false;
62 bool SystemProperties::layoutDetectEnabled_ = false;
63 int32_t SystemProperties::deviceWidth_ = 720;
64 int32_t SystemProperties::deviceHeight_ = 1280;
65 bool SystemProperties::debugOffsetLogEnabled_ = false;
66 bool SystemProperties::downloadByNetworkEnabled_ = false;
67 bool SystemProperties::recycleImageEnabled_ = false;
68 int32_t SystemProperties::devicePhysicalWidth_ = 0;
69 int32_t SystemProperties::devicePhysicalHeight_ = 0;
70 bool SystemProperties::enableScrollableItemPool_ = false;
71 bool SystemProperties::navigationBlurEnabled_ = false;
72 bool SystemProperties::forceSplitIgnoreOrientationEnabled_ = false;
73 std::optional<bool> SystemProperties::arkUIHookEnabled_;
74 bool SystemProperties::cacheNavigationNodeEnable_ = false;
75 bool SystemProperties::gridCacheEnabled_ = true;
76 bool SystemProperties::gridIrregularLayoutEnable_ = true;
77 bool SystemProperties::sideBarContainerBlurEnable_ = false;
78 std::atomic<bool> SystemProperties::stateManagerEnable_(false);
79 std::atomic<bool> SystemProperties::acePerformanceMonitorEnable_(false);
80 std::atomic<bool> SystemProperties::focusCanBeActive_(true);
81 bool SystemProperties::aceCommercialLogEnable_ = false;
82 std::atomic<bool> SystemProperties::debugBoundaryEnabled_(false);
83 bool SystemProperties::developerModeOn_ = false;
84 bool SystemProperties::faultInjectEnabled_ = false;
85 bool SystemProperties::imageFileCacheConvertAstc_ = true;
86 bool SystemProperties::imageFrameworkEnable_ = true;
87 bool SystemProperties::debugAutoUIEnabled_ = false;
88 float SystemProperties::dragStartDampingRatio_ = 0.2f;
89 float SystemProperties::dragStartPanDisThreshold_ = 10.0f;
90 int32_t SystemProperties::velocityTrackerPointNumber_ = 20;
91 bool SystemProperties::isVelocityWithinTimeWindow_ = true;
92 bool SystemProperties::isVelocityWithoutUpPoint_ = true;
93 float SystemProperties::pageCount_ = 0.0f;
94 std::pair<float, float> SystemProperties::brightUpPercent_ = {};
95 int32_t SystemProperties::imageFileCacheConvertAstcThreshold_ = 3;
96 bool SystemProperties::taskPriorityAdjustmentEnable_ = false;
97 int32_t SystemProperties::dragDropFrameworkStatus_ = 0;
98 bool SystemProperties::multiInstanceEnabled_ = false;
99 bool SystemProperties::pageTransitionFrzEnabled_ = false;
100 bool SystemProperties::softPagetransition_ = false;
101 bool SystemProperties::formSkeletonBlurEnabled_ = true;
102 bool SystemProperties::syncLoadEnabled_ = true;
103 int32_t SystemProperties::formSharedImageCacheThreshold_ = DEFAULT_FORM_SHARED_IMAGE_CACHE_THRESHOLD;
104 bool SystemProperties::debugThreadSafeNodeEnable_ = false;
105 bool SystemProperties::prebuildInMultiFrameEnabled_ = false;
106
107 bool g_segmentedWaterflow = true;
108 bool g_isNeedSymbol = true;
109 bool g_isResourceDecoupling = true;
110 bool g_isConfigChangePerform = false;
111 bool g_isMultiInstanceEnabled = false;
112 WidthLayoutBreakPoint SystemProperties::widthLayoutBreakpoints_ = WidthLayoutBreakPoint();
113 HeightLayoutBreakPoint SystemProperties::heightLayoutBreakpoints_ = HeightLayoutBreakPoint();
114
GetFontWeightScale()115 float SystemProperties::GetFontWeightScale()
116 {
117 // Default value of font weight scale is 1.0.
118 return 1.0f;
119 }
120
GetDeviceType()121 DeviceType SystemProperties::GetDeviceType()
122 {
123 return deviceType_;
124 }
125
GetDebugEnabled()126 bool SystemProperties::GetDebugEnabled()
127 {
128 return debugEnabled_;
129 }
130
GetLayoutDetectEnabled()131 bool SystemProperties::GetLayoutDetectEnabled()
132 {
133 return layoutDetectEnabled_;
134 }
135
GetAnimationScale()136 float SystemProperties::GetAnimationScale()
137 {
138 return defaultAnimationScale;
139 }
140
GetIsUseMemoryMonitor()141 bool SystemProperties::GetIsUseMemoryMonitor()
142 {
143 return false;
144 }
145
GetMultiInstanceEnabled()146 bool SystemProperties::GetMultiInstanceEnabled()
147 {
148 return g_isMultiInstanceEnabled || multiInstanceEnabled_;
149 }
150
SetMultiInstanceEnabled(bool enabled)151 void SystemProperties::SetMultiInstanceEnabled(bool enabled)
152 {
153 g_isMultiInstanceEnabled = enabled;
154 multiInstanceEnabled_ = enabled;
155 }
156
IsSyscapExist(const char * cap)157 bool SystemProperties::IsSyscapExist(const char* cap)
158 {
159 return false;
160 }
161
IsOpIncEnable()162 bool SystemProperties::IsOpIncEnable()
163 {
164 return true;
165 }
166
SetDeviceOrientation(int32_t orientation)167 void SystemProperties::SetDeviceOrientation(int32_t orientation)
168 {
169 if (orientation == ORIENTATION_PORTRAIT && orientation_ != DeviceOrientation::PORTRAIT) {
170 Swap(deviceWidth_, deviceHeight_);
171 orientation_ = DeviceOrientation::PORTRAIT;
172 } else if (orientation == ORIENTATION_LANDSCAPE && orientation_ != DeviceOrientation::LANDSCAPE) {
173 Swap(deviceWidth_, deviceHeight_);
174 orientation_ = DeviceOrientation::LANDSCAPE;
175 }
176 }
177
Is24HourClock()178 bool SystemProperties::Is24HourClock()
179 {
180 return false;
181 }
182
GetTitleStyleEnabled()183 bool SystemProperties::GetTitleStyleEnabled()
184 {
185 return false;
186 }
187
GetCustomTitleFilePath()188 std::string SystemProperties::GetCustomTitleFilePath()
189 {
190 return {};
191 }
192
GetDisplaySyncSkipEnabled()193 bool SystemProperties::GetDisplaySyncSkipEnabled()
194 {
195 return true;
196 }
197
GetNavigationBlurEnabled()198 bool SystemProperties::GetNavigationBlurEnabled()
199 {
200 return navigationBlurEnabled_;
201 }
202
GetForceSplitIgnoreOrientationEnabled()203 bool SystemProperties::GetForceSplitIgnoreOrientationEnabled()
204 {
205 return forceSplitIgnoreOrientationEnabled_;
206 }
207
GetArkUIHookEnabled()208 std::optional<bool> SystemProperties::GetArkUIHookEnabled()
209 {
210 return arkUIHookEnabled_;
211 }
212
GetCacheNavigationNodeEnable()213 bool SystemProperties::GetCacheNavigationNodeEnable()
214 {
215 return cacheNavigationNodeEnable_;
216 }
217
GetGridCacheEnabled()218 bool SystemProperties::GetGridCacheEnabled()
219 {
220 return gridCacheEnabled_;
221 }
222
GetGridIrregularLayoutEnabled()223 bool SystemProperties::GetGridIrregularLayoutEnabled()
224 {
225 return gridIrregularLayoutEnable_;
226 }
227
WaterFlowUseSegmentedLayout()228 bool SystemProperties::WaterFlowUseSegmentedLayout()
229 {
230 return g_segmentedWaterflow;
231 }
232
GetSideBarContainerBlurEnable()233 bool SystemProperties::GetSideBarContainerBlurEnable()
234 {
235 return sideBarContainerBlurEnable_;
236 }
237
GetDefaultResolution()238 float SystemProperties::GetDefaultResolution()
239 {
240 return 1.0f;
241 }
242
GetAtomicServiceBundleName()243 std::string SystemProperties::GetAtomicServiceBundleName()
244 {
245 return {};
246 }
247
GetDragStartDampingRatio()248 float SystemProperties::GetDragStartDampingRatio()
249 {
250 return dragStartDampingRatio_;
251 }
252
GetDragStartPanDistanceThreshold()253 float SystemProperties::GetDragStartPanDistanceThreshold()
254 {
255 return dragStartPanDisThreshold_;
256 }
257
GetVelocityTrackerPointNumber()258 int32_t SystemProperties::GetVelocityTrackerPointNumber()
259 {
260 return velocityTrackerPointNumber_;
261 }
262
IsVelocityWithinTimeWindow()263 bool SystemProperties::IsVelocityWithinTimeWindow()
264 {
265 return isVelocityWithinTimeWindow_;
266 }
267
IsVelocityWithoutUpPoint()268 bool SystemProperties::IsVelocityWithoutUpPoint()
269 {
270 return isVelocityWithoutUpPoint_;
271 }
272
GetAllowWindowOpenMethodEnabled()273 bool SystemProperties::GetAllowWindowOpenMethodEnabled()
274 {
275 return false;
276 }
277
IsSmallFoldProduct()278 bool SystemProperties::IsSmallFoldProduct()
279 {
280 return false;
281 }
282
IsBigFoldProduct()283 bool SystemProperties::IsBigFoldProduct()
284 {
285 return false;
286 }
287
GetDebugInspectorId()288 std::string SystemProperties::GetDebugInspectorId()
289 {
290 return "N/A";
291 }
292
GetSrollableVelocityScale()293 double SystemProperties::GetSrollableVelocityScale()
294 {
295 return 0.0;
296 }
297
GetSrollableFriction()298 double SystemProperties::GetSrollableFriction()
299 {
300 return 0.0;
301 }
302
GetScrollableDistance()303 double SystemProperties::GetScrollableDistance()
304 {
305 return 0.0;
306 }
307
GetWebDebugMaximizeResizeOptimize()308 bool SystemProperties::GetWebDebugMaximizeResizeOptimize()
309 {
310 return true;
311 }
312
IsNeedResampleTouchPoints()313 bool SystemProperties::IsNeedResampleTouchPoints()
314 {
315 return true;
316 }
317
IsNeedSymbol()318 bool SystemProperties::IsNeedSymbol()
319 {
320 return g_isNeedSymbol;
321 }
322
GetResourceDecoupling()323 bool SystemProperties::GetResourceDecoupling()
324 {
325 return g_isResourceDecoupling;
326 }
327
ConfigChangePerform()328 bool SystemProperties::ConfigChangePerform()
329 {
330 return g_isConfigChangePerform;
331 }
332
GetDragDropFrameworkStatus()333 int32_t SystemProperties::GetDragDropFrameworkStatus()
334 {
335 return dragDropFrameworkStatus_;
336 }
337
GetContainerDeleteFlag()338 bool SystemProperties::GetContainerDeleteFlag()
339 {
340 return containerDeleteFlag_;
341 }
342
IsSuperFoldDisplayDevice()343 bool SystemProperties::IsSuperFoldDisplayDevice()
344 {
345 return MockSystemProperties::g_isSuperFoldDisplayDevice;
346 }
347
IsPageTransitionFreeze()348 bool SystemProperties::IsPageTransitionFreeze()
349 {
350 return pageTransitionFrzEnabled_;
351 }
352
IsSoftPageTransition()353 bool SystemProperties::IsSoftPageTransition()
354 {
355 return softPagetransition_;
356 }
357
IsFormSkeletonBlurEnabled()358 bool SystemProperties::IsFormSkeletonBlurEnabled()
359 {
360 return formSkeletonBlurEnabled_;
361 }
362
getFormSharedImageCacheThreshold()363 int32_t SystemProperties::getFormSharedImageCacheThreshold()
364 {
365 return formSharedImageCacheThreshold_;
366 }
367
IsWhiteBlockEnabled()368 bool SystemProperties::IsWhiteBlockEnabled()
369 {
370 return false;
371 }
372
IsWhiteBlockIdleChange()373 bool SystemProperties::IsWhiteBlockIdleChange()
374 {
375 return true;
376 }
377
GetWhiteBlockIndexValue()378 int32_t SystemProperties::GetWhiteBlockIndexValue()
379 {
380 return 1;
381 }
382
GetWhiteBlockCacheCountValue()383 int32_t SystemProperties::GetWhiteBlockCacheCountValue()
384 {
385 return 1;
386 }
387
GetPreviewStatus()388 int32_t SystemProperties::GetPreviewStatus()
389 {
390 return -1;
391 }
392 } // namespace OHOS::Ace
393