1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved. 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 VK_BUNDLE_MGR_HELPER_H 16 #define VK_BUNDLE_MGR_HELPER_H 17 18 #include "vulkan/vulkan_core.h" 19 #ifdef __cplusplus 20 #include <singleton.h> 21 #include "bundle_mgr_interface.h" 22 23 extern "C" { 24 #endif // __cplusplus 25 26 bool InitBundleInfo(char* debugHapName); 27 char* GetDebugLayerLibPath(const struct loader_instance *inst, VkSystemAllocationScope allocation_sacope); 28 29 #ifdef __cplusplus 30 } 31 namespace OHOS { 32 namespace AppExecFwk { 33 class VKBundleMgrHelper : public std::enable_shared_from_this<VKBundleMgrHelper> { 34 public: 35 DISALLOW_COPY_AND_MOVE(VKBundleMgrHelper); 36 37 BundleInfo g_bundleInfo; 38 ErrCode GetBundleInfoForSelf(AppExecFwk::GetBundleInfoFlag flags, BundleInfo& bundleInfo); 39 40 private: 41 sptr<AppExecFwk::IBundleMgr> Connect(); 42 43 void OnDeath(); 44 45 private: 46 DECLARE_DELAYED_SINGLETON(VKBundleMgrHelper); 47 48 std::mutex mutex_; 49 sptr<AppExecFwk::IBundleMgr> bundleMgr_; 50 sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr; 51 }; 52 53 class VKBundleMgrServiceDeathRecipient : public IRemoteObject::DeathRecipient { 54 public: 55 explicit VKBundleMgrServiceDeathRecipient( 56 const std::function<void(const wptr<IRemoteObject>& object)>& deathCallback); 57 DISALLOW_COPY_AND_MOVE(VKBundleMgrServiceDeathRecipient); 58 virtual ~VKBundleMgrServiceDeathRecipient() = default; 59 void OnRemoteDied(const wptr<IRemoteObject>& object) override; 60 61 private: 62 std::function<void (const wptr<IRemoteObject>& object)> deathCallback_; 63 }; 64 } 65 } 66 #endif // __cplusplus 67 #endif