• 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 OHOS_CLOUD_BUNDLE_MGR_HELPER_H
17 #define OHOS_CLOUD_BUNDLE_MGR_HELPER_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "bundle_mgr_interface.h"
23 #include "iremote_object.h"
24 #include "refbase.h"
25 #include "singleton.h"
26 #include "oaid_death_recipient.h"
27 
28 namespace OHOS {
29 namespace Cloud {
30 class BundleMgrHelper : public DelayedSingleton<BundleMgrHelper> {
31 public:
32     using IBundleMgr = AppExecFwk::IBundleMgr;
33 
34     BundleMgrHelper();
35 
36     virtual ~BundleMgrHelper();
37 
38     /**
39      * Get all bundle infos about permission.
40      */
41     bool GetBundleInfosV9ByReqPermission(std::vector<AppExecFwk::BundleInfo> &bundleInfos, int32_t userId);
42 
43     bool GetApplicationInfoV9WithPermission(
44         const std::string bundleName, int32_t userId, AppExecFwk::ApplicationInfo &applicationInfo);
45 
46     /**
47      * Clears bundle manager helper.
48      */
49     void ClearBundleMgrHelper();
50 
51     void GetBundleNameByUid(const int uid, std::string &name);
52 
53 private:
54     bool GetBundleMgrProxy();
55 
56     sptr<AppExecFwk::IBundleMgr> bundleMgrProxy_;
57     std::mutex mutex_;
58     sptr<OAIDDeathRecipient> oaidDeathRecipient_;
59 };
60 }  // namespace Cloud
61 }  // namespace OHOS
62 
63 #endif  // OHOS_CLOUD_BUNDLE_MGR_HELPER_H