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 #include "ability_local_record.h" 17 #include "ability_impl.h" 18 19 namespace OHOS { 20 namespace AppExecFwk { 21 /** 22 * 23 * default constructor 24 * 25 */ AbilityLocalRecord(const std::shared_ptr<AbilityInfo> & info,const sptr<IRemoteObject> & token)26AbilityLocalRecord::AbilityLocalRecord(const std::shared_ptr<AbilityInfo> &info, const sptr<IRemoteObject> &token) 27 : abilityInfo_(info), token_(token) 28 {} 29 30 /** 31 * 32 * @default Destructor 33 * 34 */ ~AbilityLocalRecord()35AbilityLocalRecord::~AbilityLocalRecord() 36 {} 37 38 /** 39 * @description: Get an AbilityInfo in an ability. 40 * 41 * @return Returns a pointer to abilityinfo 42 */ GetAbilityInfo()43const std::shared_ptr<AbilityInfo> &AbilityLocalRecord::GetAbilityInfo() 44 { 45 return abilityInfo_; 46 } 47 48 /** 49 * @description: Get an EventHandler in an ability. 50 * 51 * @return Returns a pointer to EventHandler 52 */ GetEventHandler()53const std::shared_ptr<EventHandler> &AbilityLocalRecord::GetEventHandler() 54 { 55 return handler_; 56 } 57 58 /** 59 * @description: Set an EventHandler in an ability. 60 * @param handler EventHandler object 61 * @return None. 62 */ SetEventHandler(const std::shared_ptr<EventHandler> & handler)63void AbilityLocalRecord::SetEventHandler(const std::shared_ptr<EventHandler> &handler) 64 { 65 handler_ = handler; 66 } 67 68 /** 69 * @description: Get an EventRunner in an ability. 70 * 71 * @return Returns a pointer to EventRunner 72 */ GetEventRunner()73const std::shared_ptr<EventRunner> &AbilityLocalRecord::GetEventRunner() 74 { 75 return runner_; 76 } 77 78 /** 79 * @description: Set an EventRunner in an ability. 80 * @param runner EventHandler object 81 * @return None. 82 */ SetEventRunner(const std::shared_ptr<EventRunner> & runner)83void AbilityLocalRecord::SetEventRunner(const std::shared_ptr<EventRunner> &runner) 84 { 85 runner_ = runner; 86 } 87 88 /** 89 * @description: Gets the identity of the ability 90 * @return return the identity of the ability. 91 */ GetToken()92const sptr<IRemoteObject> &AbilityLocalRecord::GetToken() 93 { 94 return token_; 95 } 96 97 /** 98 * @description: Get an AbilityImpl in an ability. 99 * 100 * @return Returns AbilityImpl pointer 101 */ GetAbilityImpl()102const std::shared_ptr<AbilityImpl> &AbilityLocalRecord::GetAbilityImpl() 103 { 104 return abilityImpl_; 105 } 106 107 /** 108 * @description: Set an AbilityImpl in an ability. 109 * @param abilityImpl AbilityImpl object 110 * @return None. 111 */ SetAbilityImpl(const std::shared_ptr<AbilityImpl> & abilityImpl)112void AbilityLocalRecord::SetAbilityImpl(const std::shared_ptr<AbilityImpl> &abilityImpl) 113 { 114 abilityImpl_ = abilityImpl; 115 } 116 117 /** 118 * @description: Obtains the information based on ability thread. 119 * @return return AbilityThread Pointer 120 */ GetAbilityThread()121const sptr<AbilityThread> &AbilityLocalRecord::GetAbilityThread() 122 { 123 return abilityThread_; 124 } 125 126 /** 127 * @description: Set an AbilityThread in an ability. 128 * @param abilityThread AbilityThread object 129 * @return None. 130 */ SetAbilityThread(const sptr<AbilityThread> & abilityThread)131void AbilityLocalRecord::SetAbilityThread(const sptr<AbilityThread> &abilityThread) 132 { 133 abilityThread_ = abilityThread; 134 } 135 136 /** 137 * @description: Obtains api version based on ability record. 138 * @return api version. 139 */ GetCompatibleVersion()140int AbilityLocalRecord::GetCompatibleVersion() 141 { 142 return compatibleVersion_; 143 } 144 145 /** 146 * @description: Set api version in an ability record. 147 * @param compatibleVersion api version 148 * @return None. 149 */ SetCompatibleVersion(int32_t compatibleVersion)150void AbilityLocalRecord::SetCompatibleVersion(int32_t compatibleVersion) 151 { 152 compatibleVersion_ = compatibleVersion; 153 } 154 SetWant(const std::shared_ptr<AAFwk::Want> & want)155void AbilityLocalRecord::SetWant(const std::shared_ptr<AAFwk::Want> &want) 156 { 157 want_ = want; 158 } 159 GetWant()160const std::shared_ptr<AAFwk::Want> &AbilityLocalRecord::GetWant() 161 { 162 return want_; 163 } 164 } // namespace AppExecFwk 165 } // namespace OHOS