• 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 FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_HELPER_H
17 #define FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_HELPER_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "bundle_constants.h"
23 #include "bundle_resource_info.h"
24 #include "inner_bundle_info.h"
25 #include "launcher_ability_resource_info.h"
26 
27 namespace OHOS {
28 namespace AppExecFwk {
29 enum class ADD_RESOURCE_TYPE {
30     INSTALL_BUNDLE = 1,
31     UPDATE_BUNDLE = 2,
32     CREATE_USER = 3
33 };
34 
35 class BundleResourceHelper {
36 public:
37     // parse system config and init BundleSystemState, like language and colorMode
38     static void BundleSystemStateInit();
39 
40     // Register observer to monitor system state changes
41     static void RegisterConfigurationObserver();
42 
43     // Register subscriber to monitor userId changes
44     static void RegisterCommonEventSubscriber();
45 
46     static void AddResourceInfoByBundleName(const std::string &bundleName,
47         const int32_t userId, const ADD_RESOURCE_TYPE type, const bool isBundleFirstInstall = true);
48 
49     static bool DeleteBundleResourceInfo(const std::string &bundleName,
50         const int32_t userId, const bool isExistInOtherUser);
51 
52     static bool DeleteAllResourceInfo();
53 
54     static void GetAllBundleResourceName(std::vector<std::string> &resourceNames);
55 
56     static std::string ParseBundleName(const std::string &keyName);
57 
58     static void SetIsOnlineThemeWhenBoot();
59 
60     static void SetOverlayEnabled(const std::string &bundleName, const std::string &moduleName, bool isEnabled,
61         int32_t userId);
62 
63     static bool AddCloneBundleResourceInfo(const std::string &bundleName,
64         const int32_t userId, const int32_t appIndex, const bool isExistInOtherUser);
65 
66     static bool DeleteCloneBundleResourceInfo(const std::string &bundleName, const int32_t userId,
67         const int32_t appIndex, const bool isExistInOtherUser);
68 
69     static bool ProcessThemeAndDynamicIconWhenOta(const std::set<std::string> updateBundleNames);
70 
71     static void DeleteNotExistResourceInfo();
72 
73     static bool GetBundleResourceInfo(const std::string &bundleName, const uint32_t flags,
74         BundleResourceInfo &bundleResourceInfo, const int32_t appIndex = 0);
75 
76     static bool GetLauncherAbilityResourceInfo(const std::string &bundleName, const uint32_t flags,
77         std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfo, const int32_t appIndex = 0);
78 
79     static void ProcessBundleResourceChange();
80 };
81 } // AppExecFwk
82 } // OHOS
83 #endif // FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_HELPER_H
84