1 /* 2 * Copyright (c) 2021 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 FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_BMS_HELPER_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_BMS_HELPER_H 18 19 #include <singleton.h> 20 #include "ability_connect_callback_interface.h" 21 #include "ability_manager_interface.h" 22 #include "bundle_info.h" 23 #include "bundle_mgr_interface.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 using Want = OHOS::AAFwk::Want; 28 29 /** 30 * @class FormBmsHelper 31 * Bms helpler. 32 */ 33 class FormBmsHelper final : public DelayedRefSingleton<FormBmsHelper> { 34 DECLARE_DELAYED_REF_SINGLETON(FormBmsHelper) 35 36 public: 37 DISALLOW_COPY_AND_MOVE(FormBmsHelper); 38 39 /** 40 * @brief Notify module removable. 41 * @param bundleName Provider ability bundleName. 42 * @param moduleName Provider ability moduleName. 43 */ 44 void NotifyModuleRemovable(const std::string &bundleName, const std::string &moduleName); 45 /** 46 * @brief Notify module not removable. 47 * @param bundleName Provider ability bundleName. 48 * @param moduleName Provider ability moduleName. 49 */ 50 void NotifyModuleNotRemovable(const std::string &bundleName, const std::string &moduleName) const; 51 52 /** 53 * @brief Acquire a bundle manager, if it not existed, 54 * @return returns the bundle manager ipc object, or nullptr for failed. 55 */ 56 sptr<IBundleMgr> GetBundleMgr(); 57 58 /** 59 * @brief Add the bundle manager instance for debug. 60 * @param bundleManager the bundle manager ipc object. 61 */ 62 void SetBundleManager(const sptr<IBundleMgr> &bundleManager); 63 64 private: 65 /** 66 * @brief Generate module key. 67 * @param bundleName Provider ability bundleName. 68 * @param moduleName Provider ability moduleName. 69 * @return Module key. 70 */ 71 std::string GenerateModuleKey(const std::string &bundleName, const std::string &moduleName) const; 72 73 private: 74 sptr<IBundleMgr> iBundleMgr_ = nullptr; 75 }; 76 } // namespace AppExecFwk 77 } // namespace OHOS 78 79 #endif // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_BMS_HELPER_H 80