1 /* 2 * Copyright (c) 2022 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_EVENT_CESFWK_SERVICES_INCLUDE_ABILITY_MANAGER_HELPER_H 17 #define FOUNDATION_EVENT_CESFWK_SERVICES_INCLUDE_ABILITY_MANAGER_HELPER_H 18 19 #include "ability_connect_callback_interface.h" 20 #include "ability_manager_interface.h" 21 #include "ability_manager_death_recipient.h" 22 #include "common_event_data.h" 23 #include "singleton.h" 24 25 namespace OHOS { 26 namespace EventFwk { 27 class AbilityManagerHelper : public DelayedSingleton<AbilityManagerHelper> { 28 public: AbilityManagerHelper()29 AbilityManagerHelper() {} 30 ~AbilityManagerHelper()31 virtual ~AbilityManagerHelper() {} 32 33 /** 34 * Connects ability. 35 * 36 * @param want Indicates ability inofmation. 37 * @param event Indicates the common event 38 * @param callerToken Indicates the token of caller. 39 * @param userId Indicates the ID of user. 40 * @return Returns result code. 41 */ 42 int ConnectAbility(const AAFwk::Want &want, const CommonEventData &event, 43 const sptr<IRemoteObject> &callerToken, const int32_t &userId); 44 45 /** 46 * Clears ability manager service remote object. 47 * 48 */ 49 void Clear(); 50 private: 51 bool GetAbilityMgrProxy(); 52 53 std::mutex mutex_; 54 sptr<AAFwk::IAbilityManager> abilityMgr_; 55 sptr<AbilityManagerDeathRecipient> deathRecipient_; 56 }; 57 } // namespace EventFwk 58 } // namespace OHOS 59 60 #endif // FOUNDATION_EVENT_CESFWK_SERVICES_INCLUDE_ABILITY_MANAGER_HELPER_H 61