1 /* 2 * Copyright (c) 2024 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_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H 17 #define OHOS_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H 18 19 #include <singleton.h> 20 21 #include "bundle_mgr_interface.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 using Want = OHOS::AAFwk::Want; 26 27 class BundleMgrHelper : public std::enable_shared_from_this<BundleMgrHelper> { 28 public: 29 DISALLOW_COPY_AND_MOVE(BundleMgrHelper); 30 31 ErrCode GetSandboxBundleInfo(const std::string &bundleName, int32_t appIndex, int32_t userId, BundleInfo &info); 32 33 bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId); 34 35 bool GetApplicationInfo(const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo); 36 37 ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appCloneIndex, 38 BundleInfo &bundleInfo, int32_t userId); 39 40 std::string GetAppIdByBundleName(const std::string &bundleName, const int32_t userId); 41 42 private: 43 void OnDeath(); 44 45 private: 46 DECLARE_DELAYED_SINGLETON(BundleMgrHelper) 47 sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr; 48 }; 49 } // namespace AppExecFwk 50 } // namespace OHOS 51 #endif // OHOS_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H