• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "base/utils/system_properties.h"
17 
18 #include <regex>
19 
20 #include "display_info.h"
21 #include "display_manager.h"
22 #include "locale_config.h"
23 #include "parameter.h"
24 #include "parameters.h"
25 
26 #include "adapter/ohos/entrance/ace_container.h"
27 #include "adapter/ohos/osal/window_utils.h"
28 #include "core/common/ace_application_info.h"
29 
30 #ifdef OHOS_STANDARD_SYSTEM
31 #include "systemcapability.h"
32 #endif
33 
34 namespace OHOS::Ace {
35 namespace {
36 constexpr char PROPERTY_DEVICE_TYPE[] = "const.product.devicetype";
37 constexpr char PROPERTY_NEED_AVOID_WINDOW[] = "const.window.need_avoid_window";
38 constexpr char PROPERTY_DEVICE_TYPE_DEFAULT[] = "default";
39 constexpr char PROPERTY_DEVICE_TYPE_TV[] = "tv";
40 constexpr char PROPERTY_DEVICE_TYPE_TABLET[] = "tablet";
41 constexpr char PROPERTY_DEVICE_TYPE_TWOINONE[] = "2in1";
42 constexpr char PROPERTY_DEVICE_TYPE_WATCH[] = "watch";
43 constexpr char PROPERTY_DEVICE_TYPE_CAR[] = "car";
44 constexpr char PROPERTY_DEVICE_TYPE_WEARABLE[] = "wearable";
45 constexpr char PROPERTY_FOLD_TYPE[] = "const.window.foldscreen.type";
46 constexpr char ENABLE_DEBUG_AUTOUI_KEY[] = "persist.ace.debug.autoui.enabled";
47 constexpr char ENABLE_DEBUG_BOUNDARY_KEY[] = "persist.ace.debug.boundary.enabled";
48 constexpr char ENABLE_DOWNLOAD_BY_NETSTACK_KEY[] = "persist.ace.download.netstack.enabled";
49 constexpr char ENABLE_RECYCLE_IMAGE_KEY[] = "persist.ace.recycle.image.enabled";
50 constexpr char ENABLE_DEBUG_OFFSET_LOG_KEY[] = "persist.ace.scrollable.log.enabled";
51 constexpr char ANIMATION_SCALE_KEY[] = "persist.sys.arkui.animationscale";
52 constexpr char CUSTOM_TITLE_KEY[] = "persist.sys.arkui.customtitle";
53 constexpr char DISTRIBUTE_ENGINE_BUNDLE_NAME[] = "atomic.service.distribute.engine.bundle.name";
54 constexpr char IS_OPINC_ENABLE[] = "persist.ddgr.opinctype";
55 constexpr int32_t ORIENTATION_PORTRAIT = 0;
56 constexpr int32_t ORIENTATION_LANDSCAPE = 1;
57 constexpr int DEFAULT_THRESHOLD_JANK = 15;
58 constexpr float DEFAULT_ANIMATION_SCALE = 1.0f;
59 float animationScale_ = DEFAULT_ANIMATION_SCALE;
60 constexpr int32_t DEFAULT_DRAG_START_DAMPING_RATIO = 20;
61 constexpr int32_t DEFAULT_DRAG_START_PAN_DISTANCE_THRESHOLD_IN_VP = 10;
62 std::shared_mutex mutex_;
63 const std::regex FOLD_TYPE_REGEX("^(\\d+)(,\\d+){3,}$");
64 #ifdef ENABLE_ROSEN_BACKEND
65 constexpr char DISABLE_ROSEN_FILE_PATH[] = "/etc/disablerosen";
66 constexpr char DISABLE_WINDOW_ANIMATION_PATH[] = "/etc/disable_window_size_animation";
67 #endif
68 constexpr int32_t CONVERT_ASTC_THRESHOLD = 2;
69 constexpr int32_t FOLD_TYPE_TWO = 2;
70 constexpr int32_t FOLD_TYPE_FOUR = 4;
71 
IsOpIncEnabled()72 bool IsOpIncEnabled()
73 {
74     return (system::GetParameter(IS_OPINC_ENABLE, "2") == "2");
75 }
76 
Swap(int32_t & deviceWidth,int32_t & deviceHeight)77 void Swap(int32_t& deviceWidth, int32_t& deviceHeight)
78 {
79     int32_t temp = deviceWidth;
80     deviceWidth = deviceHeight;
81     deviceHeight = temp;
82 }
83 
IsDebugAutoUIEnabled()84 bool IsDebugAutoUIEnabled()
85 {
86     return (system::GetParameter(ENABLE_DEBUG_AUTOUI_KEY, "false") == "true");
87 }
88 
IsDebugOffsetLogEnabled()89 bool IsDebugOffsetLogEnabled()
90 {
91     return (system::GetParameter(ENABLE_DEBUG_OFFSET_LOG_KEY, "false") == "true");
92 }
93 
IsDebugBoundaryEnabled()94 bool IsDebugBoundaryEnabled()
95 {
96     return system::GetParameter(ENABLE_DEBUG_BOUNDARY_KEY, "false") == "true";
97 }
98 
IsDownloadByNetworkDisabled()99 bool IsDownloadByNetworkDisabled()
100 {
101     return system::GetParameter(ENABLE_DOWNLOAD_BY_NETSTACK_KEY, "true") == "true";
102 }
103 
IsRecycleImageEnabled()104 bool IsRecycleImageEnabled()
105 {
106     return system::GetParameter(ENABLE_RECYCLE_IMAGE_KEY, "true") == "true";
107 }
108 
IsSvgTraceEnabled()109 bool IsSvgTraceEnabled()
110 {
111     return (system::GetParameter("persist.ace.trace.svg.enabled", "0") == "1");
112 }
113 
IsLayoutTraceEnabled()114 bool IsLayoutTraceEnabled()
115 {
116     return (system::GetParameter("persist.ace.trace.layout.enabled", "false") == "true");
117 }
118 
IsTextTraceEnabled()119 bool IsTextTraceEnabled()
120 {
121     return (system::GetParameter("persist.ace.trace.text.enabled", "false") == "true");
122 }
123 
IsSyntaxTraceEnabled()124 bool IsSyntaxTraceEnabled()
125 {
126     return (system::GetParameter("persist.ace.trace.syntax.enabled", "false") == "true");
127 }
128 
IsAccessTraceEnabled()129 bool IsAccessTraceEnabled()
130 {
131     return (system::GetParameter("persist.ace.trace.access.enabled", "false") == "true");
132 }
133 
IsTraceInputEventEnabled()134 bool IsTraceInputEventEnabled()
135 {
136     return (system::GetParameter("persist.ace.trace.inputevent.enabled", "false") == "true");
137 }
138 
IsStateManagerEnable()139 bool IsStateManagerEnable()
140 {
141     return (system::GetParameter("persist.ace.debug.statemgr.enabled", "false") == "true");
142 }
143 
IsBuildTraceEnabled()144 bool IsBuildTraceEnabled()
145 {
146     return (system::GetParameter("persist.ace.trace.build.enabled", "false") == "true");
147 }
148 
IsSyncDebugTraceEnabled()149 bool IsSyncDebugTraceEnabled()
150 {
151     return (system::GetParameter("persist.ace.trace.sync.debug.enabled", "false") == "true");
152 }
153 
IsMeasureDebugTraceEnabled()154 bool IsMeasureDebugTraceEnabled()
155 {
156     return (system::GetParameter("persist.ace.trace.measure.debug.enabled", "false") == "true");
157 }
158 
IsSafeAreaDebugTraceEnabled()159 bool IsSafeAreaDebugTraceEnabled()
160 {
161     return (system::GetParameter("persist.ace.trace.safeArea.debug.enabled", "false") == "true");
162 }
163 
IsVsyncModeDebugTraceEnabled()164 bool IsVsyncModeDebugTraceEnabled()
165 {
166     return system::GetBoolParameter("persist.ace.trace.vsyncMode.debug.enabled", false);
167 }
168 
IsDeveloperModeOn()169 bool IsDeveloperModeOn()
170 {
171     return (system::GetParameter("const.security.developermode.state", "false") == "true");
172 }
173 
IsWindowRectResizeEnabled()174 bool IsWindowRectResizeEnabled()
175 {
176     return (system::GetParameter("persist.ace.windowresize.enabled", "true") == "true");
177 }
178 
IsFocusCanBeActive()179 bool IsFocusCanBeActive()
180 {
181     return system::GetParameter("persist.gesture.smart_gesture_enable", "1") != "0";
182 }
183 
IsCacheNavigationNodeEnable()184 bool IsCacheNavigationNodeEnable()
185 {
186     return system::GetParameter("persist.ace.navigation.groupnode.cached", "true") == "true";
187 }
188 
IsHookModeEnabled()189 bool IsHookModeEnabled()
190 {
191 #ifdef PREVIEW
192     return false;
193 #endif
194     const int bufferLen = 128;
195     char paramOutBuf[bufferLen] = { 0 };
196     constexpr char hook_mode[] = "startup:";
197     int ret = GetParameter("persist.libc.hook_mode", "", paramOutBuf, bufferLen);
198     if (ret <= 0 || strncmp(paramOutBuf, hook_mode, strlen(hook_mode)) != 0) {
199         return false;
200     }
201     return true;
202 }
203 
IsRosenBackendEnabled()204 bool IsRosenBackendEnabled()
205 {
206 #ifdef PREVIEW
207     return false;
208 #endif
209 #ifdef ENABLE_ROSEN_BACKEND
210     if (system::GetParameter("persist.ace.rosen.backend.enabled", "0") == "1") {
211         return true;
212     }
213     if (system::GetParameter("persist.ace.rosen.backend.enabled", "0") == "2") {
214         return false;
215     }
216     if (access(DISABLE_ROSEN_FILE_PATH, F_OK) == 0) {
217         return false;
218     }
219     return true;
220 #else
221     return false;
222 #endif
223 }
224 
IsWindowAnimationEnabled()225 bool IsWindowAnimationEnabled()
226 {
227 #ifdef PREVIEW
228     return false;
229 #endif
230 #ifdef ENABLE_ROSEN_BACKEND
231     if (access(DISABLE_WINDOW_ANIMATION_PATH, F_OK) == 0) {
232         return false;
233     }
234     return true;
235 #else
236     return false;
237 #endif
238 }
239 
IsAccessibilityEnabled()240 bool IsAccessibilityEnabled()
241 {
242     return (system::GetParameter("persist.ace.testmode.enabled", "0") == "1" ||
243             system::GetParameter("debug.ace.testmode.enabled", "0") == "1");
244 }
245 
IsDebugEnabled()246 bool IsDebugEnabled()
247 {
248     return (system::GetParameter("persist.ace.debug.enabled", "0") == "1");
249 }
250 
GetDebugFlags()251 int64_t GetDebugFlags()
252 {
253     return system::GetIntParameter<int64_t>("persist.ace.debug.flags", 0);
254 }
255 
IsContainerDeleteFlag()256 bool IsContainerDeleteFlag()
257 {
258     return (system::GetParameter("persist.container.delete", "true") == "true");
259 }
260 
IsLayoutDetectEnabled()261 bool IsLayoutDetectEnabled()
262 {
263     return (system::GetParameter("persist.ace.layoutdetect.enabled", "0") == "1");
264 }
265 
IsNavigationBlurEnabled()266 bool IsNavigationBlurEnabled()
267 {
268     return (system::GetParameter("persist.ace.navigation.blur.enabled", "0") == "1");
269 }
270 
IsGridCacheEnabled()271 bool IsGridCacheEnabled()
272 {
273     return (system::GetParameter("persist.ace.grid.cache.enabled", "1") == "1");
274 }
275 
IsSideBarContainerBlurEnable()276 bool IsSideBarContainerBlurEnable()
277 {
278     return (system::GetParameter("persist.ace.sidebar.blur.enabled", "0") == "1");
279 }
280 
IsGpuUploadEnabled()281 bool IsGpuUploadEnabled()
282 {
283     return (system::GetParameter("persist.ace.gpuupload.enabled", "0") == "1" ||
284             system::GetParameter("debug.ace.gpuupload.enabled", "0") == "1");
285 }
286 
IsImageFrameworkEnabled()287 bool IsImageFrameworkEnabled()
288 {
289     return system::GetBoolParameter("persist.ace.image.framework.enabled", true);
290 }
291 
OnAnimationScaleChanged(const char * key,const char * value,void * context)292 void OnAnimationScaleChanged(const char* key, const char* value, void* context)
293 {
294     CHECK_NULL_VOID(key);
295     if (strcmp(key, ANIMATION_SCALE_KEY) != 0) {
296         LOGE("AnimationScale key not matched. key: %{public}s", key);
297         return;
298     }
299     std::unique_lock<std::shared_mutex> lock(mutex_);
300     if (value == nullptr) {
301         LOGW("AnimationScale changes with null value, use default. key: %{public}s", key);
302         animationScale_ = DEFAULT_ANIMATION_SCALE;
303         return;
304     }
305     auto animationScale = std::atof(value);
306     if (animationScale < 0.0f) {
307         LOGE("AnimationScale changes with invalid value: %{public}s. ignore", value);
308         return;
309     }
310     LOGI("AnimationScale: %{public}f -> %{public}f", animationScale_, animationScale);
311     animationScale_ = animationScale;
312 }
313 
GetSysDumpFrameCount()314 uint32_t GetSysDumpFrameCount()
315 {
316     return system::GetUintParameter<uint32_t>(
317         "persist.ace.framedumpcount", 10); // 10: Pipeline dump of the last 10 frames' task.
318 }
319 
GetAstcEnabled()320 bool GetAstcEnabled()
321 {
322     return system::GetParameter("persist.astc.enable", "true") == "true";
323 }
324 
GetAstcMaxErrorProp()325 int32_t GetAstcMaxErrorProp()
326 {
327     return system::GetIntParameter<int>("persist.astc.max", 50000); // 50000: Anomaly threshold of astc.
328 }
329 
GetAstcPsnrProp()330 int32_t GetAstcPsnrProp()
331 {
332     return system::GetIntParameter<int>("persist.astc.psnr", 0);
333 }
334 
GetImageFileCacheConvertToAstcEnabled()335 bool GetImageFileCacheConvertToAstcEnabled()
336 {
337     return system::GetParameter("persist.image.filecache.astc.enable", "false") == "true";
338 }
339 
GetImageFileCacheConvertAstcThresholdProp()340 int32_t GetImageFileCacheConvertAstcThresholdProp()
341 {
342     return system::GetIntParameter<int>("persist.image.filecache.astc.threshold", CONVERT_ASTC_THRESHOLD);
343 }
344 
IsUseMemoryMonitor()345 bool IsUseMemoryMonitor()
346 {
347     return (system::GetParameter("persist.ace.memorymonitor.enabled", "0") == "1");
348 }
349 
IsExtSurfaceEnabled()350 bool IsExtSurfaceEnabled()
351 {
352 #ifdef EXT_SURFACE_ENABLE
353     return true;
354 #else
355     return false;
356 #endif
357 }
358 
IsEnableScrollableItemPool()359 bool IsEnableScrollableItemPool()
360 {
361     return system::GetBoolParameter("persist.ace.scrollablepool.enabled", false);
362 }
363 
IsResourceDecoupling()364 bool IsResourceDecoupling()
365 {
366     return system::GetBoolParameter("persist.sys.arkui.resource.decoupling", true);
367 }
368 
IsAcePerformanceMonitorEnabled()369 bool IsAcePerformanceMonitorEnabled()
370 {
371     return system::GetBoolParameter("persist.ace.performance.monitor.enabled", false);
372 }
373 
IsAceCommercialLogEnable()374 bool IsAceCommercialLogEnable()
375 {
376     return system::GetParameter("const.logsystem.versiontype", "commercial") == "commercial";
377 }
378 } // namespace
379 
ReadDragStartDampingRatio()380 float ReadDragStartDampingRatio()
381 {
382     return system::GetIntParameter("debug.ace.drag.damping.ratio", DEFAULT_DRAG_START_DAMPING_RATIO) / 100.0f;
383 }
384 
ReadDragStartPanDistanceThreshold()385 float ReadDragStartPanDistanceThreshold()
386 {
387     return system::GetIntParameter("debug.ace.drag.pan.threshold",
388         DEFAULT_DRAG_START_PAN_DISTANCE_THRESHOLD_IN_VP) * 1.0f;
389 }
390 
ReadCanvasDebugMode()391 uint32_t ReadCanvasDebugMode()
392 {
393     return system::GetUintParameter("persist.ace.canvas.debug.mode", 0u);
394 }
395 
IsFaultInjectEnabled()396 bool IsFaultInjectEnabled()
397 {
398     return (system::GetParameter("persist.ace.fault.inject.enabled", "false") == "true");
399 }
400 
ReadScrollableDistance()401 double ReadScrollableDistance()
402 {
403     auto ret = system::GetParameter("persist.scrollable.distance", "");
404     return StringUtils::StringToDouble(ret);
405 }
406 
GetPercent()407 std::pair<float, float> GetPercent()
408 {
409     std::vector<double> result;
410     StringUtils::StringSplitter(
411         system::GetParameter("const.ace.darkModeAppBGColorBrightness", "0.10,0.05"), ',', result);
412     std::pair<float, float> percent(result.front(), result.back());
413     return percent;
414 }
415 
GetPageCountProp()416 int32_t GetPageCountProp()
417 {
418     float pageCount = std::atof(system::GetParameter("persist.ace.cachedcount.page_count", "1.0").c_str());
419     return pageCount > 0.0f ? pageCount : 0.0f;
420 }
421 
IsTaskPriorityAdjustmentEnable()422 bool IsTaskPriorityAdjustmentEnable()
423 {
424     int32_t appVsyncPriority = system::GetIntParameter("const.graphic.app_vsync_priority", -1);
425     bool isArkUIEnable = system::GetBoolParameter("persist.sys.arkui.task_priority.enabled", false);
426     return appVsyncPriority != -1 && isArkUIEnable;
427 }
428 
ReadDragDropFrameworkStatus()429 int32_t ReadDragDropFrameworkStatus()
430 {
431     return system::GetIntParameter("debug.ace.drag.drop.framework.status", 0);
432 }
433 
ReadTouchAccelarateMode()434 int32_t ReadTouchAccelarateMode()
435 {
436     return system::GetIntParameter("debug.ace.touch.accelarate", 0);
437 }
438 
IsAsyncInitializeEnabled()439 bool IsAsyncInitializeEnabled()
440 {
441     return system::GetBoolParameter("persist.ace.async.initialize", true);
442 }
443 
InitSysBrand()444 std::string InitSysBrand()
445 {
446     const char* res = ::GetBrand();
447     if (res) {
448         return std::string(res);
449     }
450     return SystemProperties::INVALID_PARAM;
451 }
452 
InitSysManufacture()453 std::string InitSysManufacture()
454 {
455     const char* res = ::GetManufacture();
456     if (res) {
457         return std::string(res);
458     }
459     return SystemProperties::INVALID_PARAM;
460 }
461 
InitSysProductModel()462 std::string InitSysProductModel()
463 {
464     const char* res = ::GetProductModel();
465     if (res) {
466         return std::string(res);
467     }
468     return SystemProperties::INVALID_PARAM;
469 }
470 
InitSysMarketName()471 std::string InitSysMarketName()
472 {
473     const char* res = ::GetMarketName();
474     if (res) {
475         return std::string(res);
476     }
477     return SystemProperties::INVALID_PARAM;
478 }
479 
InitSysSdkApiVersion()480 std::string InitSysSdkApiVersion()
481 {
482     return std::to_string(::GetSdkApiVersion());
483 }
484 
InitSysOsReleaseType()485 std::string InitSysOsReleaseType()
486 {
487     const char* res = ::GetOsReleaseType();
488     if (res) {
489         return std::string(res);
490     }
491     return SystemProperties::INVALID_PARAM;
492 }
493 
InitSysDeviceType()494 std::string InitSysDeviceType()
495 {
496     const char* res = ::GetDeviceType();
497     if (res) {
498         return std::string(res);
499     }
500     return SystemProperties::INVALID_PARAM;
501 }
502 
503 std::atomic<bool> SystemProperties::asyncInitializeEnabled_(IsAsyncInitializeEnabled());
504 bool SystemProperties::svgTraceEnable_ = IsSvgTraceEnabled();
505 bool SystemProperties::developerModeOn_ = IsDeveloperModeOn();
506 std::atomic<bool> SystemProperties::layoutTraceEnable_(IsLayoutTraceEnabled() && developerModeOn_);
507 bool SystemProperties::imageFrameworkEnable_ = IsImageFrameworkEnabled();
508 std::atomic<bool> SystemProperties::traceInputEventEnable_(IsTraceInputEventEnabled() && developerModeOn_);
509 std::atomic<bool> SystemProperties::stateManagerEnable_(IsStateManagerEnable());
510 bool SystemProperties::buildTraceEnable_ = IsBuildTraceEnabled() && developerModeOn_;
511 bool SystemProperties::cacheNavigationNodeEnable_ = IsCacheNavigationNodeEnable();
512 bool SystemProperties::syncDebugTraceEnable_ = IsSyncDebugTraceEnabled();
513 bool SystemProperties::measureDebugTraceEnable_ = IsMeasureDebugTraceEnabled();
514 bool SystemProperties::safeAreaDebugTraceEnable_ = IsSafeAreaDebugTraceEnabled();
515 bool SystemProperties::pixelRoundEnable_ = IsPixelRoundEnabled();
516 bool SystemProperties::textTraceEnable_ = IsTextTraceEnabled();
517 bool SystemProperties::syntaxTraceEnable_ = IsSyntaxTraceEnabled();
518 bool SystemProperties::accessTraceEnable_ = IsAccessTraceEnabled();
519 bool SystemProperties::vsyncModeTraceEnable_ = IsVsyncModeDebugTraceEnabled();
520 bool SystemProperties::accessibilityEnabled_ = IsAccessibilityEnabled();
521 bool SystemProperties::isRound_ = false;
522 bool SystemProperties::isDeviceAccess_ = false;
523 ACE_WEAK_SYM int32_t SystemProperties::deviceWidth_ = 0;
524 ACE_WEAK_SYM int32_t SystemProperties::deviceHeight_ = 0;
525 ACE_WEAK_SYM int32_t SystemProperties::devicePhysicalWidth_ = 0;
526 ACE_WEAK_SYM int32_t SystemProperties::devicePhysicalHeight_ = 0;
527 ACE_WEAK_SYM double SystemProperties::resolution_ = 1.0;
528 ACE_WEAK_SYM DeviceType SystemProperties::deviceType_ { DeviceType::UNKNOWN };
529 ACE_WEAK_SYM FoldScreenType SystemProperties::foldScreenType_ { FoldScreenType::UNKNOWN };
530 ACE_WEAK_SYM bool SystemProperties::needAvoidWindow_ { false };
531 ACE_WEAK_SYM DeviceOrientation SystemProperties::orientation_ { DeviceOrientation::PORTRAIT };
532 std::string SystemProperties::brand_ = InitSysBrand();
533 std::string SystemProperties::manufacturer_ = InitSysManufacture();
534 std::string SystemProperties::model_ = InitSysProductModel();
535 std::string SystemProperties::product_ = InitSysMarketName();
536 std::string SystemProperties::apiVersion_ = InitSysSdkApiVersion();
537 std::string SystemProperties::releaseType_ = InitSysOsReleaseType();
538 std::string SystemProperties::paramDeviceType_ = InitSysDeviceType();
539 int32_t SystemProperties::mcc_ = MCC_UNDEFINED;
540 int32_t SystemProperties::mnc_ = MNC_UNDEFINED;
541 ScreenShape SystemProperties::screenShape_ { ScreenShape::NOT_ROUND };
542 LongScreenType SystemProperties::LongScreen_ { LongScreenType::NOT_LONG };
543 bool SystemProperties::unZipHap_ = true;
544 ACE_WEAK_SYM bool SystemProperties::rosenBackendEnabled_ = IsRosenBackendEnabled();
545 ACE_WEAK_SYM bool SystemProperties::isHookModeEnabled_ = IsHookModeEnabled();
546 std::atomic<bool> SystemProperties::debugBoundaryEnabled_(IsDebugBoundaryEnabled() && developerModeOn_);
547 bool SystemProperties::debugAutoUIEnabled_ = IsDebugAutoUIEnabled();
548 bool SystemProperties::downloadByNetworkEnabled_ = IsDownloadByNetworkDisabled();
549 bool SystemProperties::recycleImageEnabled_ = IsRecycleImageEnabled();
550 bool SystemProperties::debugOffsetLogEnabled_ = IsDebugOffsetLogEnabled();
551 ACE_WEAK_SYM bool SystemProperties::windowAnimationEnabled_ = IsWindowAnimationEnabled();
552 ACE_WEAK_SYM bool SystemProperties::debugEnabled_ = IsDebugEnabled();
553 ACE_WEAK_SYM DebugFlags SystemProperties::debugFlags_ = GetDebugFlags();
554 ACE_WEAK_SYM bool SystemProperties::containerDeleteFlag_ = IsContainerDeleteFlag();
555 ACE_WEAK_SYM bool SystemProperties::layoutDetectEnabled_ = IsLayoutDetectEnabled();
556 bool SystemProperties::gpuUploadEnabled_ = IsGpuUploadEnabled();
557 bool SystemProperties::astcEnabled_ = GetAstcEnabled();
558 int32_t SystemProperties::astcMax_ = GetAstcMaxErrorProp();
559 int32_t SystemProperties::astcPsnr_ = GetAstcPsnrProp();
560 bool SystemProperties::imageFileCacheConvertAstc_ = GetImageFileCacheConvertToAstcEnabled();
561 int32_t SystemProperties::imageFileCacheConvertAstcThreshold_ = GetImageFileCacheConvertAstcThresholdProp();
562 ACE_WEAK_SYM bool SystemProperties::extSurfaceEnabled_ = IsExtSurfaceEnabled();
563 ACE_WEAK_SYM uint32_t SystemProperties::dumpFrameCount_ = GetSysDumpFrameCount();
564 ACE_WEAK_SYM bool SystemProperties::windowRectResizeEnabled_ = IsWindowRectResizeEnabled();
565 bool SystemProperties::enableScrollableItemPool_ = IsEnableScrollableItemPool();
566 bool SystemProperties::resourceDecoupling_ = IsResourceDecoupling();
567 bool SystemProperties::navigationBlurEnabled_ = IsNavigationBlurEnabled();
568 bool SystemProperties::gridCacheEnabled_ = IsGridCacheEnabled();
569 std::pair<float, float> SystemProperties::brightUpPercent_ = GetPercent();
570 float SystemProperties::pageCount_ = GetPageCountProp();
571 bool SystemProperties::sideBarContainerBlurEnable_ = IsSideBarContainerBlurEnable();
572 std::atomic<bool> SystemProperties::acePerformanceMonitorEnable_(IsAcePerformanceMonitorEnabled());
573 std::atomic<bool> SystemProperties::focusCanBeActive_(IsFocusCanBeActive());
574 bool SystemProperties::aceCommercialLogEnable_ = IsAceCommercialLogEnable();
575 bool SystemProperties::faultInjectEnabled_  = IsFaultInjectEnabled();
576 bool SystemProperties::opincEnabled_ = IsOpIncEnabled();
577 float SystemProperties::dragStartDampingRatio_ = ReadDragStartDampingRatio();
578 float SystemProperties::dragStartPanDisThreshold_ = ReadDragStartPanDistanceThreshold();
579 uint32_t SystemProperties::canvasDebugMode_ = ReadCanvasDebugMode();
580 float SystemProperties::fontScale_ = 1.0;
581 float SystemProperties::fontWeightScale_ = 1.0;
582 double SystemProperties::scrollableDistance_ = ReadScrollableDistance();
583 bool SystemProperties::taskPriorityAdjustmentEnable_ = IsTaskPriorityAdjustmentEnable();
584 int32_t SystemProperties::dragDropFrameworkStatus_ = ReadDragDropFrameworkStatus();
585 int32_t SystemProperties::touchAccelarate_ = ReadTouchAccelarateMode();
IsOpIncEnable()586 bool SystemProperties::IsOpIncEnable()
587 {
588     return opincEnabled_;
589 }
590 
IsSyscapExist(const char * cap)591 bool SystemProperties::IsSyscapExist(const char* cap)
592 {
593 #ifdef OHOS_STANDARD_SYSTEM
594     return HasSystemCapability(cap);
595 #else
596     return false;
597 #endif
598 }
599 
InitDeviceType(DeviceType)600 void SystemProperties::InitDeviceType(DeviceType)
601 {
602     // Do nothing, no need to store type here, use system property at 'GetDeviceType' instead.
603 }
604 
GetArkProperties()605 int SystemProperties::GetArkProperties()
606 {
607     return system::GetIntParameter<int>("persist.ark.properties", -1);
608 }
609 
GetMemConfigProperty()610 std::string SystemProperties::GetMemConfigProperty()
611 {
612     return system::GetParameter("persist.ark.mem_config_property", "");
613 }
614 
GetArkBundleName()615 std::string SystemProperties::GetArkBundleName()
616 {
617     return system::GetParameter("persist.ark.arkbundlename", "");
618 }
619 
GetGcThreadNum()620 size_t SystemProperties::GetGcThreadNum()
621 {
622     size_t defaultGcThreadNums = 7;
623     return system::GetUintParameter<size_t>("persist.ark.gcthreads", defaultGcThreadNums);
624 }
625 
GetLongPauseTime()626 size_t SystemProperties::GetLongPauseTime()
627 {
628     size_t defaultLongPauseTime = 40; // 40ms
629     return system::GetUintParameter<size_t>("persist.ark.longpausetime", defaultLongPauseTime);
630 }
631 
GetAsmInterpreterEnabled()632 bool SystemProperties::GetAsmInterpreterEnabled()
633 {
634     return system::GetParameter("persist.ark.asminterpreter", "true") == "true";
635 }
636 
GetAsmOpcodeDisableRange()637 std::string SystemProperties::GetAsmOpcodeDisableRange()
638 {
639     return system::GetParameter("persist.ark.asmopcodedisablerange", "");
640 }
641 
IsScoringEnabled(const std::string & name)642 bool SystemProperties::IsScoringEnabled(const std::string& name)
643 {
644     if (name.empty()) {
645         return false;
646     }
647     std::string filePath = "/etc/" + name;
648     if (access(filePath.c_str(), F_OK) == 0) {
649         return true;
650     }
651     std::string prop = system::GetParameter("persist.ace.trace.scoringtool", "");
652     return prop == name;
653 }
654 
GetDeviceType()655 ACE_WEAK_SYM DeviceType SystemProperties::GetDeviceType()
656 {
657     InitDeviceTypeBySystemProperty();
658     return deviceType_;
659 }
660 
GetNeedAvoidWindow()661 ACE_WEAK_SYM bool SystemProperties::GetNeedAvoidWindow()
662 {
663     return needAvoidWindow_;
664 }
665 
InitDeviceTypeBySystemProperty()666 void SystemProperties::InitDeviceTypeBySystemProperty()
667 {
668     if (deviceType_ != DeviceType::UNKNOWN) {
669         return;
670     }
671 
672     auto deviceProp = system::GetParameter(PROPERTY_DEVICE_TYPE, PROPERTY_DEVICE_TYPE_DEFAULT);
673     // Properties: "default", "tv", "tablet", "watch", "car"
674     if (deviceProp == PROPERTY_DEVICE_TYPE_TV) {
675         deviceType_ = DeviceType::TV;
676     } else if (deviceProp == PROPERTY_DEVICE_TYPE_CAR) {
677         deviceType_ = DeviceType::CAR;
678     } else if (deviceProp == PROPERTY_DEVICE_TYPE_WATCH) {
679         deviceType_ = DeviceType::WATCH;
680     } else if (deviceProp == PROPERTY_DEVICE_TYPE_TABLET) {
681         deviceType_ = DeviceType::TABLET;
682     } else if (deviceProp == PROPERTY_DEVICE_TYPE_TWOINONE) {
683         deviceType_ = DeviceType::TWO_IN_ONE;
684     } else if (deviceProp == PROPERTY_DEVICE_TYPE_WEARABLE) {
685         deviceType_ = DeviceType::WEARABLE;
686     } else {
687         deviceType_ = DeviceType::PHONE;
688     }
689 }
690 
InitDeviceInfo(int32_t deviceWidth,int32_t deviceHeight,int32_t orientation,double resolution,bool isRound)691 void SystemProperties::InitDeviceInfo(
692     int32_t deviceWidth, int32_t deviceHeight, int32_t orientation, double resolution, bool isRound)
693 {
694     // SetDeviceOrientation should be earlier than deviceWidth/deviceHeight init.
695     SetDeviceOrientation(orientation);
696     isRound_ = isRound;
697     resolution_ = resolution;
698     deviceWidth_ = deviceWidth;
699     deviceHeight_ = deviceHeight;
700     needAvoidWindow_ = system::GetBoolParameter(PROPERTY_NEED_AVOID_WINDOW, false);
701     debugEnabled_ = IsDebugEnabled();
702     debugFlags_ = GetDebugFlags();
703     layoutDetectEnabled_ = IsLayoutDetectEnabled();
704     svgTraceEnable_ = IsSvgTraceEnabled();
705     layoutTraceEnable_.store(IsLayoutTraceEnabled() && developerModeOn_);
706     traceInputEventEnable_.store(IsTraceInputEventEnabled() && developerModeOn_);
707     stateManagerEnable_.store(IsStateManagerEnable());
708     buildTraceEnable_ = IsBuildTraceEnabled() && developerModeOn_;
709     syncDebugTraceEnable_ = IsSyncDebugTraceEnabled();
710     measureDebugTraceEnable_ = IsMeasureDebugTraceEnabled();
711     safeAreaDebugTraceEnable_ = IsSafeAreaDebugTraceEnabled();
712     vsyncModeTraceEnable_ = IsVsyncModeDebugTraceEnabled();
713     pixelRoundEnable_ = IsPixelRoundEnabled();
714     accessibilityEnabled_ = IsAccessibilityEnabled();
715     canvasDebugMode_ = ReadCanvasDebugMode();
716     isHookModeEnabled_ = IsHookModeEnabled();
717     debugAutoUIEnabled_ = system::GetParameter(ENABLE_DEBUG_AUTOUI_KEY, "false") == "true";
718     debugOffsetLogEnabled_ = system::GetParameter(ENABLE_DEBUG_OFFSET_LOG_KEY, "false") == "true";
719     downloadByNetworkEnabled_ = system::GetParameter(ENABLE_DOWNLOAD_BY_NETSTACK_KEY, "true") == "true";
720     recycleImageEnabled_ = system::GetParameter(ENABLE_RECYCLE_IMAGE_KEY, "true") == "true";
721     animationScale_ = std::atof(system::GetParameter(ANIMATION_SCALE_KEY, "1").c_str());
722     WatchParameter(ANIMATION_SCALE_KEY, OnAnimationScaleChanged, nullptr);
723     resourceDecoupling_ = IsResourceDecoupling();
724     navigationBlurEnabled_ = IsNavigationBlurEnabled();
725     gridCacheEnabled_ = IsGridCacheEnabled();
726     sideBarContainerBlurEnable_ = IsSideBarContainerBlurEnable();
727     acePerformanceMonitorEnable_.store(IsAcePerformanceMonitorEnabled());
728     asyncInitializeEnabled_.store(IsAsyncInitializeEnabled());
729     focusCanBeActive_.store(IsFocusCanBeActive());
730     faultInjectEnabled_  = IsFaultInjectEnabled();
731     windowRectResizeEnabled_ = IsWindowRectResizeEnabled();
732     taskPriorityAdjustmentEnable_ = IsTaskPriorityAdjustmentEnable();
733     if (isRound_) {
734         screenShape_ = ScreenShape::ROUND;
735     } else {
736         screenShape_ = ScreenShape::NOT_ROUND;
737     }
738     InitDeviceTypeBySystemProperty();
739 }
740 
SetDeviceOrientation(int32_t orientation)741 ACE_WEAK_SYM void SystemProperties::SetDeviceOrientation(int32_t orientation)
742 {
743     auto newOrientation = static_cast<int32_t>(WindowUtils::GetDeviceOrientation(orientation));
744     if (newOrientation == ORIENTATION_PORTRAIT && orientation_ != DeviceOrientation::PORTRAIT) {
745         Swap(deviceWidth_, deviceHeight_);
746         orientation_ = DeviceOrientation::PORTRAIT;
747     } else if (newOrientation == ORIENTATION_LANDSCAPE && orientation_ != DeviceOrientation::LANDSCAPE) {
748         Swap(deviceWidth_, deviceHeight_);
749         orientation_ = DeviceOrientation::LANDSCAPE;
750     }
751 }
752 
GetFontWeightScale()753 ACE_WEAK_SYM float SystemProperties::GetFontWeightScale()
754 {
755     // Default value of font weight scale is 1.0.
756     return fontWeightScale_;
757 }
758 
GetFontScale()759 ACE_WEAK_SYM float SystemProperties::GetFontScale()
760 {
761     // Default value of font size scale is 1.0.
762     return fontScale_;
763 }
764 
GetContainerDeleteFlag()765 bool SystemProperties::GetContainerDeleteFlag()
766 {
767     return containerDeleteFlag_;
768 }
769 
InitMccMnc(int32_t mcc,int32_t mnc)770 void SystemProperties::InitMccMnc(int32_t mcc, int32_t mnc)
771 {
772     mcc_ = mcc;
773     mnc_ = mnc;
774 }
775 
GetDebugEnabled()776 ACE_WEAK_SYM bool SystemProperties::GetDebugEnabled()
777 {
778     return debugEnabled_;
779 }
780 
GetLayoutDetectEnabled()781 ACE_WEAK_SYM bool SystemProperties::GetLayoutDetectEnabled()
782 {
783     return layoutDetectEnabled_;
784 }
785 
GetLanguage()786 std::string SystemProperties::GetLanguage()
787 {
788     return system::GetParameter("const.global.language", INVALID_PARAM);
789 }
790 
GetRegion()791 std::string SystemProperties::GetRegion()
792 {
793     return system::GetParameter("const.global.region", INVALID_PARAM);
794 }
795 
GetNewPipePkg()796 std::string SystemProperties::GetNewPipePkg()
797 {
798     return system::GetParameter("persist.ace.newpipe.pkgname", "");
799 }
800 
GetAnimationScale()801 ACE_WEAK_SYM float SystemProperties::GetAnimationScale()
802 {
803     std::shared_lock<std::shared_mutex> lock(mutex_);
804     return animationScale_;
805 }
806 
GetPartialUpdatePkg()807 std::string SystemProperties::GetPartialUpdatePkg()
808 {
809     return system::GetParameter("persist.ace.partial.pkgname", "");
810 }
811 
GetSvgMode()812 int32_t SystemProperties::GetSvgMode()
813 {
814 #ifdef NG_BUILD
815     // disable ace svg before updated to new pipeline
816     return system::GetIntParameter<int>("persist.ace.svg.mode", 0);
817 #else
818     return system::GetIntParameter<int>("persist.ace.svg.mode", 1);
819 #endif
820 }
821 
GetAllowWindowOpenMethodEnabled()822 bool SystemProperties::GetAllowWindowOpenMethodEnabled()
823 {
824     return system::GetBoolParameter("persist.web.allowWindowOpenMethod.enabled", false);
825 }
826 
GetDebugPixelMapSaveEnabled()827 bool SystemProperties::GetDebugPixelMapSaveEnabled()
828 {
829     return system::GetBoolParameter("persist.ace.save.pixelmap.enabled", false);
830 }
831 
IsPixelRoundEnabled()832 bool SystemProperties::IsPixelRoundEnabled()
833 {
834     return system::GetBoolParameter("ace.debug.pixelround.enabled", true);
835 }
836 
GetIsUseMemoryMonitor()837 ACE_WEAK_SYM bool SystemProperties::GetIsUseMemoryMonitor()
838 {
839     static bool isUseMemoryMonitor = IsUseMemoryMonitor();
840     return isUseMemoryMonitor;
841 }
842 
IsFormAnimationLimited()843 bool SystemProperties::IsFormAnimationLimited()
844 {
845     return system::GetBoolParameter("persist.sys.arkui.formAnimationLimit", true);
846 }
847 
GetResourceDecoupling()848 bool SystemProperties::GetResourceDecoupling()
849 {
850     return resourceDecoupling_;
851 }
852 
GetTitleStyleEnabled()853 bool SystemProperties::GetTitleStyleEnabled()
854 {
855     return system::GetBoolParameter("persist.ace.title.style.enabled", false);
856 }
857 
GetJankFrameThreshold()858 int32_t SystemProperties::GetJankFrameThreshold()
859 {
860     return system::GetIntParameter<int>("persist.sys.arkui.perf.threshold", DEFAULT_THRESHOLD_JANK);
861 }
862 
GetCustomTitleFilePath()863 ACE_WEAK_SYM std::string SystemProperties::GetCustomTitleFilePath()
864 {
865     return system::GetParameter(CUSTOM_TITLE_KEY, "");
866 }
867 
Is24HourClock()868 ACE_WEAK_SYM bool SystemProperties::Is24HourClock()
869 {
870     return Global::I18n::LocaleConfig::Is24HourClock();
871 }
872 
GetRtlEnabled()873 std::optional<bool> SystemProperties::GetRtlEnabled()
874 {
875     const std::string emptyParam("none");
876     auto ret = system::GetParameter("debug.ace.rtl.enabled", emptyParam);
877     if (ret == emptyParam) {
878         return std::nullopt;
879     } else {
880         return (ret == "true") ? true : false;
881     }
882 }
883 
GetDisplaySyncSkipEnabled()884 bool SystemProperties::GetDisplaySyncSkipEnabled()
885 {
886     return system::GetBoolParameter("debug.ace.displaySyncSkip.enabled", true);
887 }
888 
GetNavigationBlurEnabled()889 bool SystemProperties::GetNavigationBlurEnabled()
890 {
891     return navigationBlurEnabled_;
892 }
893 
GetCacheNavigationNodeEnable()894 bool SystemProperties::GetCacheNavigationNodeEnable()
895 {
896     return cacheNavigationNodeEnable_;
897 }
898 
GetGridCacheEnabled()899 bool SystemProperties::GetGridCacheEnabled()
900 {
901     return gridCacheEnabled_;
902 }
903 
GetGridIrregularLayoutEnabled()904 bool SystemProperties::GetGridIrregularLayoutEnabled()
905 {
906     return system::GetBoolParameter("persist.ace.grid.irregular.enabled", false);
907 }
908 
WaterFlowUseSegmentedLayout()909 bool SystemProperties::WaterFlowUseSegmentedLayout()
910 {
911     return system::GetBoolParameter("persist.ace.water.flow.segmented", false);
912 }
913 
GetSideBarContainerBlurEnable()914 bool SystemProperties::GetSideBarContainerBlurEnable()
915 {
916     return sideBarContainerBlurEnable_;
917 }
918 
AddWatchSystemParameter(const char * key,void * context,EnableSystemParameterCallback callback)919 void SystemProperties::AddWatchSystemParameter(const char* key, void* context, EnableSystemParameterCallback callback)
920 {
921     WatchParameter(key, callback, context);
922 }
923 
GetWindowRectResizeEnabled()924 ACE_WEAK_SYM bool SystemProperties::GetWindowRectResizeEnabled()
925 {
926     return windowRectResizeEnabled_;
927 }
928 
RemoveWatchSystemParameter(const char * key,void * context,EnableSystemParameterCallback callback)929 void SystemProperties::RemoveWatchSystemParameter(
930     const char* key, void* context, EnableSystemParameterCallback callback)
931 {
932     RemoveParameterWatcher(key, callback, context);
933 }
934 
EnableSystemParameterTraceLayoutCallback(const char * key,const char * value,void * context)935 void SystemProperties::EnableSystemParameterTraceLayoutCallback(const char* key, const char* value, void* context)
936 {
937     if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0) {
938         SetLayoutTraceEnabled(strcmp(value, "true") == 0);
939     }
940 }
941 
EnableSystemParameterTraceInputEventCallback(const char * key,const char * value,void * context)942 void SystemProperties::EnableSystemParameterTraceInputEventCallback(const char* key, const char* value, void* context)
943 {
944     if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0) {
945         SetInputEventTraceEnabled(strcmp(value, "true") == 0);
946     }
947 }
948 
EnableSystemParameterSecurityDevelopermodeCallback(const char * key,const char * value,void * context)949 void SystemProperties::EnableSystemParameterSecurityDevelopermodeCallback(
950     const char* key, const char* value, void* context)
951 {
952     if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0) {
953         SetSecurityDevelopermodeLayoutTraceEnabled(strcmp(value, "true") == 0);
954     }
955 }
956 
EnableSystemParameterDebugStatemgrCallback(const char * key,const char * value,void * context)957 void SystemProperties::EnableSystemParameterDebugStatemgrCallback(const char* key, const char* value, void* context)
958 {
959     if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0) {
960         SetStateManagerEnabled(strcmp(value, "true") == 0);
961     }
962 }
963 
EnableSystemParameterDebugBoundaryCallback(const char * key,const char * value,void * context)964 void SystemProperties::EnableSystemParameterDebugBoundaryCallback(const char* key, const char* value, void* context)
965 {
966     bool isDebugBoundary = strcmp(value, "true") == 0;
967     SetDebugBoundaryEnabled(isDebugBoundary);
968     auto container = reinterpret_cast<Platform::AceContainer*>(context);
969     CHECK_NULL_VOID(container);
970     container->RenderLayoutBoundary(isDebugBoundary);
971 }
972 
EnableSystemParameterPerformanceMonitorCallback(const char * key,const char * value,void * context)973 void SystemProperties::EnableSystemParameterPerformanceMonitorCallback(const char* key, const char* value,
974     void* context)
975 {
976     if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0) {
977         SetPerformanceMonitorEnabled(strcmp(value, "true") == 0);
978     }
979 }
980 
OnFocusActiveChanged(const char * key,const char * value,void * context)981 void SystemProperties::OnFocusActiveChanged(const char* key, const char* value, void* context)
982 {
983     bool focusCanBeActive = true;
984     if (value && strcmp(value, "0") == 0) {
985         focusCanBeActive = false;
986     }
987     if (focusCanBeActive != focusCanBeActive_) {
988         SetFocusCanBeActive(focusCanBeActive);
989         if (!focusCanBeActive) {
990             auto container = reinterpret_cast<Platform::AceContainer*>(context);
991             CHECK_NULL_VOID(container);
992             ContainerScope scope(container->GetInstanceId());
993             container->SetIsFocusActive(focusCanBeActive);
994         }
995         LOGI("focusCanBeActive turns to %{public}d", focusCanBeActive);
996     }
997     return;
998 }
999 
GetDefaultResolution()1000 float SystemProperties::GetDefaultResolution()
1001 {
1002     // always return density of main screen, don't use this interface unless you need density when no window exists
1003     float density = 1.0f;
1004     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
1005     CHECK_NULL_RETURN(defaultDisplay, density);
1006     auto displayInfo = defaultDisplay->GetDisplayInfoWithCache();
1007     CHECK_NULL_RETURN(displayInfo, density);
1008     density = displayInfo->GetVirtualPixelRatio();
1009     return density;
1010 }
1011 
SetLayoutTraceEnabled(bool layoutTraceEnable)1012 void SystemProperties::SetLayoutTraceEnabled(bool layoutTraceEnable)
1013 {
1014     layoutTraceEnable_.store(layoutTraceEnable && developerModeOn_);
1015 }
1016 
SetInputEventTraceEnabled(bool inputEventTraceEnable)1017 void SystemProperties::SetInputEventTraceEnabled(bool inputEventTraceEnable)
1018 {
1019     traceInputEventEnable_.store(inputEventTraceEnable && developerModeOn_);
1020 }
1021 
SetSecurityDevelopermodeLayoutTraceEnabled(bool layoutTraceEnable)1022 void SystemProperties::SetSecurityDevelopermodeLayoutTraceEnabled(bool layoutTraceEnable)
1023 {
1024     layoutTraceEnable_.store(layoutTraceEnable && IsLayoutTraceEnabled());
1025 }
1026 
SetDebugBoundaryEnabled(bool debugBoundaryEnabled)1027 void SystemProperties::SetDebugBoundaryEnabled(bool debugBoundaryEnabled)
1028 {
1029     debugBoundaryEnabled_.store(debugBoundaryEnabled && developerModeOn_);
1030 }
1031 
SetPerformanceMonitorEnabled(bool performanceMonitorEnable)1032 void SystemProperties::SetPerformanceMonitorEnabled(bool performanceMonitorEnable)
1033 {
1034     acePerformanceMonitorEnable_.store(performanceMonitorEnable);
1035 }
1036 
SetFocusCanBeActive(bool focusCanBeActive)1037 void SystemProperties::SetFocusCanBeActive(bool focusCanBeActive)
1038 {
1039     focusCanBeActive_.store(focusCanBeActive);
1040 }
1041 
GetAtomicServiceBundleName()1042 std::string SystemProperties::GetAtomicServiceBundleName()
1043 {
1044     return system::GetParameter(DISTRIBUTE_ENGINE_BUNDLE_NAME, "");
1045 }
1046 
GetDragStartDampingRatio()1047 float SystemProperties::GetDragStartDampingRatio()
1048 {
1049     return dragStartDampingRatio_;
1050 }
1051 
GetDragStartPanDistanceThreshold()1052 float SystemProperties::GetDragStartPanDistanceThreshold()
1053 {
1054     return dragStartPanDisThreshold_;
1055 }
1056 
IsSmallFoldProduct()1057 ACE_WEAK_SYM bool SystemProperties::IsSmallFoldProduct()
1058 {
1059     InitFoldScreenTypeBySystemProperty();
1060     return foldScreenType_ == FoldScreenType::SMALL_FOLDER;
1061 }
1062 
IsBigFoldProduct()1063 ACE_WEAK_SYM bool SystemProperties::IsBigFoldProduct()
1064 {
1065     InitFoldScreenTypeBySystemProperty();
1066     return foldScreenType_ == FoldScreenType::BIG_FOLDER;
1067 }
1068 
InitFoldScreenTypeBySystemProperty()1069 void SystemProperties::InitFoldScreenTypeBySystemProperty()
1070 {
1071     if (foldScreenType_ != FoldScreenType::UNKNOWN) {
1072         return;
1073     }
1074 
1075     auto foldTypeProp = system::GetParameter(PROPERTY_FOLD_TYPE, "0,0,0,0");
1076     if (std::regex_match(foldTypeProp, FOLD_TYPE_REGEX)) {
1077         auto index = foldTypeProp.find_first_of(',');
1078         auto foldScreenTypeStr = foldTypeProp.substr(0, index);
1079         auto type = StringUtils::StringToInt(foldScreenTypeStr);
1080         if (type == FOLD_TYPE_FOUR) {
1081             type = FOLD_TYPE_TWO;
1082         }
1083         foldScreenType_ = static_cast<FoldScreenType>(type);
1084     }
1085 }
1086 
GetWebDebugRenderMode()1087 std::string SystemProperties::GetWebDebugRenderMode()
1088 {
1089     return OHOS::system::GetParameter("web.debug.renderMode", "");
1090 }
1091 
GetDebugInspectorId()1092 std::string SystemProperties::GetDebugInspectorId()
1093 {
1094     return system::GetParameter("ace.debug.inspectorId", INVALID_PARAM);
1095 }
1096 
GetSrollableVelocityScale()1097 double SystemProperties::GetSrollableVelocityScale()
1098 {
1099     auto ret = system::GetParameter("persist.scrollable.velocityScale", "");
1100     return StringUtils::StringToDouble(ret);
1101 }
1102 
GetSrollableFriction()1103 double SystemProperties::GetSrollableFriction()
1104 {
1105     auto ret = system::GetParameter("persist.scrollable.friction", "");
1106     return StringUtils::StringToDouble(ret);
1107 }
1108 
GetScrollableDistance()1109 double SystemProperties::GetScrollableDistance()
1110 {
1111     return scrollableDistance_;
1112 }
1113 
GetWebDebugMaximizeResizeOptimize()1114 bool SystemProperties::GetWebDebugMaximizeResizeOptimize()
1115 {
1116     return system::GetBoolParameter("web.debug.maximize_resize_optimize", true);
1117 }
1118 
IsNeedResampleTouchPoints()1119 bool SystemProperties::IsNeedResampleTouchPoints()
1120 {
1121     return true;
1122 }
1123 
IsNeedSymbol()1124 bool SystemProperties::IsNeedSymbol()
1125 {
1126     return true;
1127 }
1128 
GetDragDropFrameworkStatus()1129 int32_t SystemProperties::GetDragDropFrameworkStatus()
1130 {
1131     return dragDropFrameworkStatus_;
1132 }
1133 
GetTouchAccelarate()1134 int32_t SystemProperties::GetTouchAccelarate()
1135 {
1136     return touchAccelarate_;
1137 }
1138 
IsSuperFoldDisplayDevice()1139 bool SystemProperties::IsSuperFoldDisplayDevice()
1140 {
1141     InitFoldScreenTypeBySystemProperty();
1142     return foldScreenType_ == FoldScreenType::SUPER_FOLDER;
1143 }
1144 } // namespace OHOS::Ace
1145