1 /* 2 * Copyright (c) 2025 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_PARAM_MANAGER_H 17 #define SYSTEM_PARAM_MANAGER_H 18 19 #include <mutex> 20 #include <vector> 21 22 #include "parameter.h" 23 24 namespace OHOS { 25 namespace UserIam { 26 namespace PinAuth { 27 inline const char *TRUE_STR = "true"; 28 inline const char *FALSE_STR = "false"; 29 30 inline const char *FWK_READY_KEY = "bootevent.useriam.fwkready"; 31 inline const char *IS_PIN_ENROLLED_KEY = "persist.useriam.isPinEnrolled"; 32 inline const char *IS_CREDENTIAL_CHECKED_KEY = "useriam.isCredentialChecked"; 33 inline const char *IS_PIN_FUNCTION_READY_KEY = "useriam.isPinFunctionReady"; 34 inline const char *STOP_SA_KEY = "useriam.stopSa"; 35 inline const char *START_SA_KEY = "useriam.startSa"; 36 37 class SystemParamManager { 38 public: 39 static SystemParamManager &GetInstance(); 40 41 std::string GetParam(const std::string &key, const std::string &defaultValue); 42 void SetParam(const std::string &key, const std::string &value); 43 void SetParamTwice(const std::string &key, const std::string &value1, const std::string &value2); 44 typedef void (*SystemParamCallback)(const std::string &value); 45 void WatchParam(const std::string &key, SystemParamCallback callback); 46 void OnParamChange(const std::string &key, const std::string &value); 47 48 private: 49 SystemParamManager() = default; 50 ~SystemParamManager() = default; 51 52 std::recursive_mutex mutex_; 53 std::vector<std::pair<std::string, SystemParamCallback>> keyCallbackVec_; 54 }; 55 } // namespace PinAuth 56 } // namespace UserIam 57 } // namespace OHOS 58 59 #endif // SYSTEM_PARAM_MANAGER_H 60