• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #ifndef SYSTEM_PROPERTIES_ADAPTER_IMPL_H
17 #define SYSTEM_PROPERTIES_ADAPTER_IMPL_H
18 
19 #include <mutex>
20 #include <shared_mutex>
21 #include <unordered_map>
22 #include <vector>
23 #include "system_properties_adapter.h"
24 
25 namespace OHOS::NWeb {
26 
27 class SystemPropertiesAdapterImpl : public SystemPropertiesAdapter {
28 public:
29     static SystemPropertiesAdapterImpl& GetInstance();
30 
31     ~SystemPropertiesAdapterImpl() override;
32 
33     bool GetResourceUseHapPathEnable() override;
34 
35     std::string GetDeviceInfoProductModel() override;
36 
37     std::string GetDeviceInfoBrand() override;
38 
39     int32_t GetDeviceInfoMajorVersion() override;
40 
41     ProductDeviceType GetProductDeviceType() override;
42 
43     bool GetWebOptimizationValue() override;
44 
45     bool IsAdvancedSecurityMode() override;
46 
47     std::string GetUserAgentOSName() override;
48 
49     std::string GetUserAgentOSVersion() override;
50 
51     std::string GetUserAgentBaseOSName() override;
52 
53     int32_t GetSoftwareMajorVersion() override;
54 
55     int32_t GetSoftwareSeniorVersion() override;
56 
57     std::string GetNetlogMode() override;
58 
59     bool GetTraceDebugEnable() override;
60 
61     std::string GetSiteIsolationMode() override;
62 
63     int32_t GetFlowBufMaxFd() override;
64 
65     bool GetOOPGPUEnable() override;
66 
67     void SetOOPGPUDisable() override;
68 
69     int32_t GetInitialCongestionWindowSize() override;
70 
71     void AttachSysPropObserver(PropertiesKey key, SystemPropertiesObserver* observer) override;
72 
73     void DetachSysPropObserver(PropertiesKey key, SystemPropertiesObserver* observer) override;
74 
75     void DispatchAllWatcherInfo(const char* key, const char* value);
76 
77     bool GetBoolParameter(const std::string& key, bool defaultValue) override;
78 
79     std::vector<FrameRateSetting> GetLTPOConfig(const std::string& settingName) override;
80 
81     std::string GetOOPGPUStatus() override;
82 
83     bool IsLTPODynamicApp(const std::string& bundleName) override;
84 
85     int32_t GetLTPOStrategy() override;
86 
87     std::string GetVulkanStatus() override;
88 
89     std::string GetCompatibleDeviceType() override;
90 
91     std::string GetDeviceInfoApiVersion() override;
92 
93     std::string GetPRPPreloadMode() override;
94 
95     std::string GetScrollVelocityScale() override;
96 
97     std::string GetScrollFriction() override;
98 
99     std::string GetBundleName() override;
100 
101     std::string GetStringParameter(const std::string& key, const std::string& defaultValue) override;
102 
103     int32_t GetIntParameter(const std::string& key, int32_t defaultValue) override;
104 
105 private:
106     SystemPropertiesAdapterImpl();
107 
108     SystemPropertiesAdapterImpl(const SystemPropertiesAdapterImpl& other) = delete;
109 
110     SystemPropertiesAdapterImpl& operator=(const SystemPropertiesAdapterImpl&) = delete;
111 
112     ProductDeviceType AnalysisFromConfig();
113 
114     void AddAllSysPropWatchers();
115 
116     void RemoveAllSysPropWatchers();
117 
118     int softwareMajorVersion_ = -1;
119     int softwareSeniorVersion_ = -1;
120     std::string baseOsName_;
121 
122     std::unordered_map<PropertiesKey, std::vector<SystemPropertiesObserver*>> sysPropObserver_;
123     std::unordered_map<PropertiesKey, std::shared_mutex> sysPropMutex_;
124 };
125 
126 }  // namespace OHOS::NWeb
127 
128 #endif  // SYSTEM_PROPERTIES_ADAPTER_IMPL_H
129