1 /* 2 * Copyright (c) 2025 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_ANI_DRIVER_EXTENSION_H 17 #define OHOS_ABILITY_RUNTIME_ANI_DRIVER_EXTENSION_H 18 19 #include "ani.h" 20 #include "driver_extension.h" 21 #include "driver_extension_context.h" 22 #include "runtime.h" 23 #include "ets_runtime.h" 24 25 class ETSRuntime; 26 27 namespace OHOS { 28 namespace AbilityRuntime { 29 class AniDriverExtension : public DriverExtension, public std::enable_shared_from_this<AniDriverExtension> { 30 public: 31 explicit AniDriverExtension(ETSRuntime &stsRuntime); 32 virtual ~AniDriverExtension() override; 33 static AniDriverExtension *Create(const std::unique_ptr<Runtime> &runtime); 34 virtual void Init(const std::shared_ptr<AppExecFwk::AbilityLocalRecord> &record, 35 const std::shared_ptr<AppExecFwk::OHOSApplication> &application, 36 std::shared_ptr<AppExecFwk::AbilityHandler> &handler, const sptr<IRemoteObject> &token) override; 37 virtual void OnStart(const AAFwk::Want &want) override; 38 virtual sptr<IRemoteObject> OnConnect(const AAFwk::Want &want) override; 39 virtual sptr<IRemoteObject> OnConnect(const AAFwk::Want &want, 40 AppExecFwk::AbilityTransactionCallbackInfo<sptr<IRemoteObject>> *callbackInfo, bool &isAsyncCallback) override; 41 virtual void OnDisconnect(const AAFwk::Want &want) override; 42 void OnDisconnect(const AAFwk::Want &want, AppExecFwk::AbilityTransactionCallbackInfo<> *callbackInfo, 43 bool &isAsyncCallback) override; 44 virtual void OnStop() override; 45 ani_array_ref ToAniStringList(ani_env *env, const std::vector<std::string> ¶ms, const uint32_t length); 46 virtual void Dump(const std::vector<std::string> ¶ms, std::vector<std::string> &info) override; 47 void BindContext( 48 ani_env *env, std::shared_ptr<AAFwk::Want> want, const std::shared_ptr<OHOSApplication> &application); 49 50 private: 51 std::unique_ptr<AppExecFwk::ETSNativeReference> stsObj_; 52 ETSRuntime &stsRuntime_; 53 }; 54 } // namespace AbilityRuntime 55 } // namespace OHOS 56 #endif // OHOS_ABILITY_RUNTIME_ANI_DRIVER_EXTENSION_H