• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 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_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_CONTINUOUS_TASK_INCLUDE_BUNDLE_MANAGER_HELPER_H
17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_CONTINUOUS_TASK_INCLUDE_BUNDLE_MANAGER_HELPER_H
18 
19 #include "bundle_mgr_interface.h"
20 #include "ipc_skeleton.h"
21 #include "iremote_object.h"
22 #include "resource_manager.h"
23 #include "singleton.h"
24 
25 #include "remote_death_recipient.h"
26 
27 namespace OHOS {
28 namespace BackgroundTaskMgr {
29 using OHOS::AppExecFwk::Constants::UNSPECIFIED_USERID;
30 class BundleManagerHelper : public DelayedSingleton<BundleManagerHelper> {
31 public:
32     std::string GetClientBundleName(int32_t uid);
33     bool CheckPermission(const std::string &permission);
34     bool CheckACLPermission(const std::string &permission, uint64_t callingTokenId);
35     bool IsSystemApp(uint64_t fullTokenId);
36     bool GetBundleInfo(const std::string &bundleName, const AppExecFwk::BundleFlag flag,
37         AppExecFwk::BundleInfo &bundleInfo, int32_t userId = UNSPECIFIED_USERID);
38     bool GetApplicationInfo(const std::string &appName, const AppExecFwk::ApplicationFlag flag,
39         const int userId, AppExecFwk::ApplicationInfo &appInfo);
40     bool QueryAbilityInfo(const AAFwk::Want &want, int32_t flags, int32_t userId,
41         AppExecFwk::AbilityInfo &abilityInfo);
42     bool GetBundleResourceInfo(const std::string &bundleName, const AppExecFwk::ResourceFlag flags,
43         AppExecFwk::BundleResourceInfo &bundleResourceInfo);
44 
45 private:
46     bool Connect();
47     void Disconnect();
48     void OnRemoteDied(const wptr<IRemoteObject> &object);
49 
50 private:
51     sptr<AppExecFwk::IBundleMgr> bundleMgr_ = nullptr;
52     std::mutex connectionMutex_;
53     sptr<RemoteDeathRecipient> bundleMgrDeathRecipient_ = nullptr;
54 
55     DECLARE_DELAYED_SINGLETON(BundleManagerHelper)
56 };
57 }  // namespace BackgroundTaskMgr
58 }  // namespace OHOS
59 #endif  // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_CONTINUOUS_TASK_INCLUDE_BUNDLE_MANAGER_HELPER_H