1 /* 2 * Copyright (c) 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 #ifndef UDMF_CUSTOM_UTD_STORE_H 17 #define UDMF_CUSTOM_UTD_STORE_H 18 #include <string> 19 #include <vector> 20 #include <set> 21 #include <map> 22 #include <cstdint> 23 #include "visibility.h" 24 #include "utd_common.h" 25 #include "custom_utd_json_parser.h" 26 namespace OHOS { 27 namespace UDMF { 28 class API_EXPORT CustomUtdStore { 29 public: 30 static CustomUtdStore &GetInstance(); 31 std::vector<TypeDescriptorCfg> GetTypeCfgs(int32_t userId); 32 std::vector<TypeDescriptorCfg> GetHapTypeCfgs(); 33 int32_t SaveTypeCfgs(const std::vector<TypeDescriptorCfg> &customUtdTypes, int32_t user); 34 bool InstallCustomUtds(const std::string &bundleName, const std::string &jsonStr, int32_t user, 35 std::vector<TypeDescriptorCfg> &customTyepCfgs); 36 bool UninstallCustomUtds(const std::string &bundleName, int32_t user, 37 std::vector<TypeDescriptorCfg> &customTyepCfgs); 38 private: 39 CustomUtdStore(); 40 ~CustomUtdStore(); 41 int32_t SavaCfgFile(const std::string &jsonData, const std::string &cfgFilePath); 42 bool CreateDirectory(const std::string &path) const; 43 void ProcessUtdForSave(const CustomUtdCfgs &utdTypes, std::vector<TypeDescriptorCfg> &customTyepCfgs, 44 const std::string &bundleName); 45 CustomUtdJsonParser utdJsonParser_; 46 }; 47 } // namespace UDMF 48 } // namespace OHOS 49 #endif // UDMF_CUSTOM_UTD_STORE_H