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 "utd_common.h" 24 #include "custom_utd_json_parser.h" 25 namespace OHOS { 26 namespace UDMF { 27 class CustomUtdStore { 28 public: 29 static CustomUtdStore &GetInstance(); 30 std::vector<TypeDescriptorCfg> GetCustomUtd(bool isHap, int32_t userId); 31 int32_t SaveTypeCfgs(const std::vector<TypeDescriptorCfg> &customUtdTypes, int32_t user); 32 bool InstallCustomUtds(const std::string &bundleName, const std::string &jsonStr, int32_t user, 33 std::vector<TypeDescriptorCfg> &customTyepCfgs); 34 bool UninstallCustomUtds(const std::string &bundleName, int32_t user, 35 std::vector<TypeDescriptorCfg> &customTyepCfgs); 36 UtdFileInfo GetCustomUtdInfo(bool isHap, int32_t userId); 37 38 private: 39 CustomUtdStore(); 40 ~CustomUtdStore(); 41 int32_t SaveCfgFile(const std::string &jsonData, const std::string &cfgFilePath); 42 bool CreateDirectory(const std::string &path) const; 43 static void ProcessUtdForSave(const CustomUtdCfgs &utdTypes, std::vector<TypeDescriptorCfg> &customTyepCfgs, 44 const std::string &bundleName); 45 std::string GetCustomUtdPath(bool isHap, int32_t userId); 46 47 CustomUtdJsonParser utdJsonParser_; 48 }; 49 } // namespace UDMF 50 } // namespace OHOS 51 #endif // UDMF_CUSTOM_UTD_STORE_H