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