• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 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_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BMS_EXTENSION_DATA_MGR_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BMS_EXTENSION_DATA_MGR_H
18 #include <mutex>
19 #include <string>
20 
21 #include "ability_info.h"
22 #include "appexecfwk_errors.h"
23 #include "bms_extension.h"
24 #include "bundle_info.h"
25 #include "bundle_resource_info.h"
26 #include "code_protect_bundle_info.h"
27 #include "launcher_ability_resource_info.h"
28 #include "interfaces/hap_verify.h"
29 #include "want.h"
30 #include "abs_rdb_predicates.h"
31 
32 namespace OHOS {
33 namespace AppExecFwk {
34 class BmsExtensionDataMgr {
35 public:
36     using Want = OHOS::AAFwk::Want;
37 
38     BmsExtensionDataMgr();
39     ErrCode Init();
40     bool CheckApiInfo(const BundleInfo &bundleInfo, uint32_t sdkVersion);
41     bool CheckApiInfo(uint32_t compatibleVersion, uint32_t sdkVersion);
42     ErrCode HapVerify(const std::string &filePath, Security::Verify::HapVerifyResult &hapVerifyResult);
43     bool IsRdDevice();
44     ErrCode QueryAbilityInfos(const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos);
45     ErrCode QueryAbilityInfosWithFlag(const Want &want, int32_t flags, int32_t userId,
46         std::vector<AbilityInfo> &abilityInfos, bool isNewVersion = false);
47     ErrCode GetBundleInfos(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId,
48         bool isNewVersion = false);
49     ErrCode GetBundleInfo(const std::string &bundleName, int32_t flags, int32_t userId,
50         BundleInfo &bundleInfo, bool isNewVersion = false);
51     ErrCode Uninstall(const std::string &bundleName);
52     ErrCode GetBundleStats(const std::string &bundleName, int32_t userId, std::vector<int64_t> &bundleStats);
53     ErrCode ClearData(const std::string &bundleName, int32_t userId);
54     ErrCode ClearCache(const std::string &bundleName, sptr<IRemoteObject> callback, int32_t userId);
55     ErrCode GetUidByBundleName(const std::string &bundleName, int32_t userId, int32_t &uid);
56     ErrCode GetBundleNameByUid(int32_t uid, std::string &bundleName);
57     ErrCode VerifyActivationLock(bool &res);
58     ErrCode GetBackupUninstallList(int32_t userId, std::set<std::string> &uninstallBundles);
59     ErrCode ClearBackupUninstallFile(int32_t userId);
60     ErrCode AddResourceInfoByBundleName(const std::string &bundleName, const int32_t userId);
61     ErrCode AddResourceInfoByAbility(const std::string &bundleName, const std::string &moduleName,
62         const std::string &abilityName, const int32_t userId);
63     ErrCode DeleteResourceInfo(const std::string &key);
64     ErrCode OptimizeDisposedPredicates(const std::string &callingName, const std::string &appId,
65         int32_t userId, int32_t appIndex, NativeRdb::AbsRdbPredicates &absRdbPredicates);
66     bool IsAppInBlocklist(const std::string &bundleName, const int32_t userId);
67     ErrCode KeyOperation(const std::vector<CodeProtectBundleInfo> &codeProtectBundleInfos, int32_t type);
68     bool CheckWhetherCanBeUninstalled(const std::string &bundleName, const std::string &appIdentifier);
69     ErrCode GetBundleResourceInfo(const std::string &bundleName, const uint32_t flags,
70         BundleResourceInfo &bundleResourceInfo, const int32_t appIndex = 0);
71     ErrCode GetLauncherAbilityResourceInfo(const std::string &bundleName, const uint32_t flags,
72         std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfo, const int32_t appIndex = 0);
73     ErrCode GetAllBundleResourceInfo(const uint32_t flags, std::vector<BundleResourceInfo> &bundleResourceInfos);
74     ErrCode GetAllLauncherAbilityResourceInfo(const uint32_t flags,
75         std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfos);
76     void CheckBundleNameAndStratAbility(const std::string &bundleName, const std::string &appIdentifier);
77     bool IsTargetApp(const std::string &bundleName, const std::string &appIdentifier);
78 
79     bool DetermineCloneNum(const std::string &bundleName, const std::string &appIdentifier, int32_t &cloneNum);
80     std::string GetCompatibleDeviceType(const std::string &bundleName);
81     ErrCode VerifyActivationLockToken(bool &res);
82     bool IsNeedToSkipPreBundleInstall();
83     ErrCode GetBundleNamesForUidExt(const int32_t uid, std::vector<std::string> &bundleNames);
84     ErrCode RegisterPreInstallWithCard();
85     bool IsMCFlagSet();
86 private:
87     bool OpenHandler();
88     static void *handler_;
89     static BmsExtension bmsExtension_;
90 };
91 }  // namespace AppExecFwk
92 }  // namespace OHOS
93 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BMS_EXTENSION_DATA_MGR_H