• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved.
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 ROSEN_MODULES_SPTEXT_BUNDLE_MANAGER_H
17 #define ROSEN_MODULES_SPTEXT_BUNDLE_MANAGER_H
18 
19 #include <cstddef>
20 #include <cstdint>
21 #include <limits>
22 #include <string>
23 
24 #ifdef ENABLE_OHOS_ENHANCE
25 #include "bundlemgr/bundle_mgr_interface.h"
26 #endif
27 
28 namespace OHOS {
29 namespace Rosen {
30 namespace SPText {
31 constexpr uint32_t SINCE_API18_VERSION = 18;
32 
33 class TextBundleConfigParser {
34 public:
GetInstance()35     static TextBundleConfigParser& GetInstance()
36     {
37         static TextBundleConfigParser instance;
38         return instance;
39     }
40 
41     bool IsAdapterTextHeightEnabled() const;
42     bool IsTargetApiVersion(size_t targetVersion) const;
43 
44 private:
TextBundleConfigParser()45     TextBundleConfigParser()
46     {
47         InitBundleInfo();
48     };
49 
~TextBundleConfigParser()50     ~TextBundleConfigParser() {};
51 
52     TextBundleConfigParser(const TextBundleConfigParser&) = delete;
53     TextBundleConfigParser& operator=(const TextBundleConfigParser&) = delete;
54     TextBundleConfigParser(TextBundleConfigParser&&) = delete;
55     TextBundleConfigParser& operator=(TextBundleConfigParser&&) = delete;
56 
57     uint32_t bundleApiVersion_{0};
58     bool adapterTextHeightEnable_{false};
59     bool initStatus_{false};
60 
61     void InitBundleInfo();
62     void InitTextBundleConfig();
63     void InitTextBundleFailed();
64 
65 #ifdef ENABLE_OHOS_ENHANCE
66     bool IsMetaDataExistInModule(const std::string& metaData, const AppExecFwk::BundleInfo& bundleInfo);
67     bool GetBundleInfo(AppExecFwk::BundleInfo& bundleInfo);
68 #endif
69 };
70 } // namespace SPText
71 } // namespace Rosen
72 } // namespace OHOS
73 
74 #endif // ROSEN_MODULES_SPTEXT_BUNDLE_MANAGER_H