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 FRAMEWORKS_OPENGL_WRAPPER_EGL_BUNDLE_MGR_HELPER_H 16 #define FRAMEWORKS_OPENGL_WRAPPER_EGL_BUNDLE_MGR_HELPER_H 17 18 #include <singleton.h> 19 20 #include "bundle_mgr_interface.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 class EGLBundleMgrHelper : public std::enable_shared_from_this<EGLBundleMgrHelper> { 25 public: 26 DISALLOW_COPY_AND_MOVE(EGLBundleMgrHelper); 27 28 ErrCode GetBundleInfoForSelf(AppExecFwk::GetBundleInfoFlag flags, BundleInfo& bundleInfo); 29 30 private: 31 sptr<IBundleMgr> Connect(); 32 33 void OnDeath(); 34 35 private: 36 DECLARE_DELAYED_SINGLETON(EGLBundleMgrHelper); 37 38 std::mutex mutex_; 39 sptr<IBundleMgr> bundleMgr_; 40 sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr; 41 }; 42 43 class EGLBundleMgrServiceDeathRecipient : public IRemoteObject::DeathRecipient { 44 public: 45 explicit EGLBundleMgrServiceDeathRecipient( 46 const std::function<void(const wptr<IRemoteObject>& object)>& deathCallback); 47 DISALLOW_COPY_AND_MOVE(EGLBundleMgrServiceDeathRecipient); 48 virtual ~EGLBundleMgrServiceDeathRecipient() = default; 49 void OnRemoteDied(const wptr<IRemoteObject>& object) override; 50 51 private: 52 std::function<void (const wptr<IRemoteObject>& object)> deathCallback_; 53 }; 54 55 } 56 } 57 58 #endif // FRAMEWORKS_OPENGL_WRAPPER_EGL_BUNDLE_MGR_HELPER_H