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 void AttachSysPropObserver(PropertiesKey key, SystemPropertiesObserver* observer) override; 70 71 void DetachSysPropObserver(PropertiesKey key, SystemPropertiesObserver* observer) override; 72 73 void DispatchAllWatcherInfo(const char* key, const char* value); 74 75 bool GetBoolParameter(const std::string& key, bool defaultValue) override; 76 77 std::vector<FrameRateSetting> GetLTPOConfig(const std::string& settingName) override; 78 79 std::string GetOOPGPUStatus() override; 80 private: 81 SystemPropertiesAdapterImpl(); 82 83 SystemPropertiesAdapterImpl(const SystemPropertiesAdapterImpl& other) = delete; 84 85 SystemPropertiesAdapterImpl& operator=(const SystemPropertiesAdapterImpl&) = delete; 86 87 ProductDeviceType AnalysisFromConfig(); 88 89 void AddAllSysPropWatchers(); 90 91 void RemoveAllSysPropWatchers(); 92 93 int softwareMajorVersion_ = -1; 94 int softwareSeniorVersion_ = -1; 95 std::string baseOsName_ ; 96 97 std::unordered_map<PropertiesKey, std::vector<SystemPropertiesObserver*>> sysPropObserver_; 98 std::unordered_map<PropertiesKey, std::shared_mutex> sysPropMutex_; 99 }; 100 101 } // namespace OHOS::NWeb 102 103 #endif // SYSTEM_PROPERTIES_ADAPTER_IMPL_H 104