• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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> GetTypeCfgs(int32_t userId);
31     std::vector<TypeDescriptorCfg> GetHapTypeCfgs();
32     int32_t SaveTypeCfgs(const std::vector<TypeDescriptorCfg> &customUtdTypes, int32_t user);
33     bool InstallCustomUtds(const std::string &bundleName, const std::string &jsonStr, int32_t user,
34         std::vector<TypeDescriptorCfg> &customTyepCfgs);
35     bool UninstallCustomUtds(const std::string &bundleName, int32_t user,
36         std::vector<TypeDescriptorCfg> &customTyepCfgs);
37 private:
38     CustomUtdStore();
39     ~CustomUtdStore();
40     int32_t SavaCfgFile(const std::string &jsonData, const std::string &cfgFilePath);
41     bool CreateDirectory(const std::string &path) const;
42     static void ProcessUtdForSave(const CustomUtdCfgs &utdTypes, std::vector<TypeDescriptorCfg> &customTyepCfgs,
43         const std::string &bundleName);
44     CustomUtdJsonParser utdJsonParser_;
45 };
46 } // namespace UDMF
47 } // namespace OHOS
48 #endif // UDMF_CUSTOM_UTD_STORE_H