1 /* 2 * Copyright (c) 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_EXTENSION_RECORD_H 17 #define OHOS_ABILITY_RUNTIME_EXTENSION_RECORD_H 18 19 #include <atomic> 20 #include <map> 21 #include <memory> 22 #include <string> 23 24 #include "ability_record.h" 25 #include "preload_uiext_state_observer.h" 26 27 namespace OHOS { 28 namespace AbilityRuntime { 29 namespace { 30 constexpr int32_t INVALID_EXTENSION_RECORD_ID = 0; 31 } 32 class ExtensionRecord : public std::enable_shared_from_this<ExtensionRecord> { 33 public: 34 ExtensionRecord(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord); 35 36 virtual ~ExtensionRecord(); 37 38 sptr<IRemoteObject> GetCallToken() const; 39 40 sptr<IRemoteObject> GetRootCallerToken() const; 41 42 void SetRootCallerToken(sptr<IRemoteObject> &rootCallerToken); 43 44 sptr<IRemoteObject> GetFocusedCallerToken() const; 45 46 void SetFocusedCallerToken(sptr<IRemoteObject> &rootCallerToken); 47 48 virtual bool ContinueToGetCallerToken(); 49 50 virtual void Update(const AAFwk::AbilityRequest &abilityRequest); 51 52 void UnloadUIExtensionAbility(); 53 54 int32_t RegisterStateObserver(const std::string &hostBundleName); 55 56 std::shared_ptr<AAFwk::AbilityRecord> abilityRecord_ = nullptr; 57 std::string hostBundleName_; 58 int32_t extensionRecordId_ = INVALID_EXTENSION_RECORD_ID; 59 uint32_t processMode_ = 0; 60 bool isHostSpecified_ = false; 61 pid_t hostPid_ = 0; 62 private: 63 sptr<IRemoteObject> rootCallerToken_ = nullptr; 64 sptr<IRemoteObject> focusedCallerToken_ = nullptr; 65 sptr<AAFwk::PreLoadUIExtStateObserver> preLoadUIExtStateObserver_; 66 }; 67 } // namespace AbilityRuntime 68 } // namespace OHOS 69 #endif // OHOS_ABILITY_RUNTIME_EXTENSION_RECORD_H 70