• 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 
16 #ifndef BUNDLE_FRAMEWORK_INTERFACES_KITS_JS_RESOURCE_HELPER_H
17 #define BUNDLE_FRAMEWORK_INTERFACES_KITS_JS_RESOURCE_HELPER_H
18 
19 #include "bundle_resource_interface.h"
20 #include "bundle_resource_info.h"
21 #include "iservice_registry.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 class ResourceHelper {
26 public:
27     static sptr<IBundleResource> GetBundleResourceMgr();
28     static ErrCode InnerGetBundleResourceInfo(
29         const std::string &bundleName, uint32_t flags, int32_t appIndex, BundleResourceInfo &resourceInfo);
30     static ErrCode InnerGetLauncherAbilityResourceInfo(
31         const std::string &bundleName, uint32_t flags, int32_t appIndex,
32         std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfo);
33     static ErrCode InnerGetAllBundleResourceInfo(uint32_t flags, std::vector<BundleResourceInfo> &bundleResourceInfos);
34     static ErrCode InnerGetAllLauncherAbilityResourceInfo(uint32_t flags,
35         std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfos);
36     static ErrCode InnerGetExtensionAbilityResourceInfo(const std::string& bundleName,
37         ExtensionAbilityType extensionAbilityType, uint32_t flags, int32_t appIndex,
38         std::vector<LauncherAbilityResourceInfo>& extensionAbilityResourceInfos);
39 
40 private:
41     class BundleResourceMgrDeathRecipient : public IRemoteObject::DeathRecipient {
42         void OnRemoteDied([[maybe_unused]] const wptr<IRemoteObject>& remote) override;
43     };
44     static sptr<IBundleResource> bundleResourceMgr_;
45     static std::mutex bundleResourceMutex_;
46     static sptr<IRemoteObject::DeathRecipient> deathRecipient_;
47 };
48 } // AppExecFwk
49 } // OHOS
50 #endif