1 /* 2 * Copyright (c) 2021-2024 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 #ifndef HIVIEW_OAL_SYSTEM_PROPERTY_H 16 #define HIVIEW_OAL_SYSTEM_PROPERTY_H 17 #include <cstdint> 18 #include <string> 19 namespace OHOS { 20 namespace HiviewDFX { 21 constexpr char KEY_BUILD_CHARACTER[] = "ro.build.characteristics"; 22 constexpr char KEY_HIVIEW_VERSION_TYPE[] = "const.logsystem.versiontype"; 23 constexpr char KEY_DEVELOPER_MODE_STATE[] = "const.security.developermode.state"; 24 constexpr char HIVIEW_UCOLLECTION_STATE[] = "hiviewdfx.ucollection.switchon"; 25 constexpr char DEVELOP_HIVIEW_TRACE_RECORDER[] = "persist.hiview.trace_recorder"; 26 constexpr char KEY_LEAKDECTOR_MODE_STATE[] = "persist.hiview.leak_detector"; 27 constexpr char KEY_IS_DEBUGGABLE[] = "const.debuggable"; 28 namespace Parameter { 29 enum UserType: uint8_t { 30 USER_TYPE_CHINA_COMMERCIAL = 1, 31 USER_TYPE_CHINA_BETA = 3, 32 USER_TYPE_OVERSEA_BETA = 5, 33 USER_TYPE_OVERSEA_COMMERCIAL = 6 34 }; 35 36 std::string GetString(const std::string& key, const std::string& defaultValue); 37 int64_t GetInteger(const std::string& key, const int64_t defaultValue); 38 uint64_t GetUnsignedInteger(const std::string& key, const uint64_t defaultValue); 39 bool GetBoolean(const std::string& key, const bool defaultValue); 40 bool SetProperty(const std::string& key, const std::string& defaultValue); 41 int WaitParamSync(const char *key, const char *value, int timeout); 42 typedef void (*ParameterChgPtr)(const char *key, const char *value, void *context); 43 int WatchParamChange(const char *keyPrefix, ParameterChgPtr callback, void *context); 44 int RemoveParameterWatcherEx(const char *keyPrefix, ParameterChgPtr callback, void *context); 45 bool IsBetaVersion(); 46 bool IsDeveloperMode(); 47 bool IsFactoryMode(); 48 bool IsOversea(); 49 UserType GetUserType(); 50 bool IsUCollectionSwitchOn(); 51 bool IsTraceCollectionSwitchOn(); 52 bool IsTestAppTraceOn(); 53 bool IsLeakStateMode(); 54 bool IsUserMode(); 55 std::string GetDeviceTypeStr(); 56 std::string GetDisplayVersionStr(); 57 std::string GetBrandStr(); 58 std::string GetManufactureStr(); 59 std::string GetMarketNameStr(); 60 std::string GetSysVersionStr(); 61 std::string GetProductModelStr(); 62 std::string GetSysVersionDetailsStr(); 63 std::string GetVersionTypeStr(); 64 std::string GetPatchVersionStr(); 65 }; 66 } // namespace HiviewDFX 67 } // namespace OHOS 68 #endif // HIVIEW_OAL_SYSTEM_PROPERTY_H 69