• 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_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 "interfaces/hap_verify.h"
26 #include "want.h"
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 class BmsExtensionDataMgr {
31 public:
32     using Want = OHOS::AAFwk::Want;
33 
34     BmsExtensionDataMgr();
35     ErrCode Init();
36     bool CheckApiInfo(const BundleInfo &bundleInfo, uint32_t sdkVersion);
37     bool CheckApiInfo(uint32_t compatibleVersion, uint32_t sdkVersion);
38     ErrCode HapVerify(const std::string &filePath, Security::Verify::HapVerifyResult &hapVerifyResult);
39     ErrCode QueryAbilityInfos(const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos);
40     ErrCode QueryAbilityInfosWithFlag(const Want &want, int32_t flags, int32_t userId,
41         std::vector<AbilityInfo> &abilityInfos, bool isNewVersion = false);
42     ErrCode GetBundleInfos(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId,
43         bool isNewVersion = false);
44     ErrCode GetBundleInfo(const std::string &bundleName, int32_t flags, int32_t userId,
45         BundleInfo &bundleInfo, bool isNewVersion = false);
46     ErrCode Uninstall(const std::string &bundleName);
47     ErrCode GetBundleStats(const std::string &bundleName, int32_t userId, std::vector<int64_t> &bundleStats);
48     ErrCode ClearData(const std::string &bundleName, int32_t userId);
49     ErrCode ClearCache(const std::string &bundleName, sptr<IRemoteObject> callback, int32_t userId);
50     ErrCode GetUidByBundleName(const std::string &bundleName, int32_t userId, int32_t &uid);
51     ErrCode GetBundleNameByUid(int32_t uid, std::string &bundleName);
52 private:
53     bool OpenHandler();
54     static BmsExtension bmsExtension_;
55     static void *handler_;
56 };
57 }  // namespace AppExecFwk
58 }  // namespace OHOS
59 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BMS_EXTENSION_DATA_MGR_H