• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 #ifndef ACCESSIBILITY_RESOURCE_BUNDLE_MANAGER_H
16 #define ACCESSIBILITY_RESOURCE_BUNDLE_MANAGER_H
17 
18 #include "singleton.h"
19 #include "resource_manager.h"
20 #include "res_config.h"
21 #include "bundle_info.h"
22 #include "bundlemgr/bundle_mgr_interface.h"
23 #include "iaccessible_ability_manager_service.h"
24 #include "iremote_object.h"
25 #include "ffrt.h"
26 
27 namespace OHOS {
28 namespace Accessibility {
29 
30 class AccessibilityResourceBundleManager {
31 public:
32     AccessibilityResourceBundleManager();
33     ~AccessibilityResourceBundleManager();
34 
35     ErrCode GetBundleInfoV9(const std::string& bundleName, int32_t flags,
36         AppExecFwk::BundleInfo& bundleInfo, int32_t userId);
37 
38     int GetUidByBundleName(const std::string &bundleName, const std::string &abilityName, const int userId);
39 
40     bool QueryExtensionAbilityInfos(const AppExecFwk::ExtensionAbilityType &extensionType, const int32_t &userId,
41         std::vector<AppExecFwk::ExtensionAbilityInfo> &extensionInfos);
42 
43     bool GetBundleNameByUid(const int uid, std::string &bundleName);
44 
45 public:
46     ffrt::mutex bundleMutex_;
47 
48 private:
49     class BundleManagerDeathRecipient final : public IRemoteObject::DeathRecipient {
50     public:
51         BundleManagerDeathRecipient() = default;
52         ~BundleManagerDeathRecipient() final = default;
53         DISALLOW_COPY_AND_MOVE(BundleManagerDeathRecipient);
54 
55         void OnRemoteDied(const wptr<IRemoteObject> &remote) final;
56     };
57 
58     void OnBundleManagerDied(const wptr<IRemoteObject> &remote);
59     sptr<AppExecFwk::IBundleMgr> GetBundleMgrProxy();
60 
61     sptr<AppExecFwk::IBundleMgr> bundleManager_ = nullptr;
62     sptr<IRemoteObject::DeathRecipient> bundleManagerDeathRecipient_ = nullptr;
63 };
64 
65 } // namespace Accessibility
66 } // namespace OHOS
67 
68 #endif // ACCESSIBILITY_RESOURCE_BUNDLE_MANAGER_H