1 /* 2 * Copyright (c) 2021-2023 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 OHOS_ABILITY_RUNTIME_ABILITY_LOCAL_RECORD_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_LOCAL_RECORD_H 18 19 #include <string> 20 21 #include "iremote_object.h" 22 #include "ability_info.h" 23 #include "refbase.h" 24 #include "want.h" 25 26 namespace OHOS { 27 namespace AppExecFwk { 28 class AbilityThread; 29 class AbilityLocalRecord { 30 public: 31 /** 32 * 33 * default constructor 34 * 35 */ 36 AbilityLocalRecord(const std::shared_ptr<AbilityInfo> &info, const sptr<IRemoteObject> &token, 37 const std::shared_ptr<AAFwk::Want> &want, int32_t abilityRecordId); 38 39 /** 40 * 41 * @default Destructor 42 * 43 */ 44 virtual ~AbilityLocalRecord(); 45 46 /** 47 * @description: Get an AbilityInfo in an ability. 48 * 49 * @return Returns a pointer to abilityinfo. 50 */ 51 const std::shared_ptr<AbilityInfo> &GetAbilityInfo(); 52 53 /** 54 * @description: Gets the identity of the ability 55 * @return return the identity of the ability. 56 */ 57 const sptr<IRemoteObject> &GetToken(); 58 59 int32_t GetAbilityRecordId() const; 60 61 /** 62 * @description: Obtains the information based on ability thread. 63 * @return return AbilityThread Pointer 64 */ 65 const sptr<AbilityThread> &GetAbilityThread(); 66 67 /** 68 * @description: Set an AbilityThread in an ability. 69 * @param abilityThread AbilityThread object 70 * @return None. 71 */ 72 void SetAbilityThread(const sptr<AbilityThread> &abilityThread); 73 74 void SetWant(const std::shared_ptr<AAFwk::Want> &want); 75 76 const std::shared_ptr<AAFwk::Want> &GetWant(); 77 78 bool IsHook() const; 79 private: 80 std::shared_ptr<AbilityInfo> abilityInfo_ = nullptr; 81 sptr<IRemoteObject> token_ = nullptr; 82 std::shared_ptr<AAFwk::Want> want_ = nullptr; 83 int32_t abilityRecordId_ = 0; 84 sptr<AbilityThread> abilityThread_; 85 }; 86 } // namespace AppExecFwk 87 } // namespace OHOS 88 #endif // OHOS_ABILITY_RUNTIME_ABILITY_LOCAL_RECORD_H 89