diff --git a/frameworks/native/ability/native/form_runtime/js_form_extension_context.cpp b/frameworks/native/ability/native/form_runtime/js_form_extension_context.cpp index dfa4b78757..28a5e5f9ad 100644 --- a/frameworks/native/ability/native/form_runtime/js_form_extension_context.cpp +++ b/frameworks/native/ability/native/form_runtime/js_form_extension_context.cpp @@ -32,11 +32,9 @@ namespace OHOS { namespace AbilityRuntime { namespace { constexpr int32_t INDEX_ZERO = 0; -constexpr int32_t INDEX_ONE = 1; constexpr int32_t ERROR_CODE_ONE = 1; constexpr size_t ARGC_ONE = 1; constexpr size_t ARGC_TWO = 2; -constexpr size_t ARGC_THREE = 3; const int UPDATE_FORM_PARAMS_SIZE = 2; class JsFormExtensionContext final { public: @@ -126,8 +124,8 @@ private: NativeValue* OnStartAbility(NativeEngine& engine, NativeCallbackInfo& info) { HILOG_INFO("OnStartAbility is called"); - // only support one or two or three params - if (info.argc != ARGC_ONE && info.argc != ARGC_TWO && info.argc != ARGC_THREE) { + // only support one or two params + if (info.argc != ARGC_ONE && info.argc != ARGC_TWO) { HILOG_ERROR("Not enough params"); return engine.CreateUndefined(); } @@ -142,16 +140,8 @@ private: want.GetElement().GetAbilityName().c_str()); unwrapArgc++; - AAFwk::StartOptions startOptions; - if (info.argc > ARGC_ONE && info.argv[INDEX_ONE]->TypeOf() == NATIVE_OBJECT) { - HILOG_INFO("OnStartAbility start options is used."); - AppExecFwk::UnwrapStartOptions(reinterpret_cast(&engine), - reinterpret_cast(info.argv[INDEX_ONE]), startOptions); - unwrapArgc++; - } - AsyncTask::CompleteCallback complete = - [weak = context_, want, startOptions, unwrapArgc](NativeEngine& engine, AsyncTask& task, int32_t status) { + [weak = context_, want, unwrapArgc](NativeEngine& engine, AsyncTask& task, int32_t status) { HILOG_INFO("startAbility begin"); auto context = weak.lock(); if (!context) { @@ -161,8 +151,8 @@ private: } ErrCode errcode = ERR_OK; - (unwrapArgc == 1) ? errcode = context->StartAbility(want) : - errcode = context->StartAbility(want, startOptions); + // entry to the core functionality. + errcode = context->StartAbility(want); if (errcode == 0) { task.Resolve(engine, engine.CreateUndefined()); } else { diff --git a/frameworks/native/appkit/ability_runtime/form_extension_context.cpp b/frameworks/native/appkit/ability_runtime/form_extension_context.cpp index c5e945d2c9..0b51c17a47 100644 --- a/frameworks/native/appkit/ability_runtime/form_extension_context.cpp +++ b/frameworks/native/appkit/ability_runtime/form_extension_context.cpp @@ -53,18 +53,8 @@ int FormExtensionContext::UpdateForm(const int64_t formId, const AppExecFwk::For ErrCode FormExtensionContext::StartAbility(const AAFwk::Want &want) const { HILOG_DEBUG("%{public}s begin.", __func__); - ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, token_, -1); - HILOG_DEBUG("%{public}s. End calling StartAbility. ret=%{public}d", __func__, err); - if (err != ERR_OK) { - HILOG_ERROR("FormExtensionContext::StartAbility is failed %{public}d", err); - } - return err; -} - -ErrCode FormExtensionContext::StartAbility(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions) const -{ - HILOG_DEBUG("%{public}s begin.", __func__); - ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, startOptions, token_, -1); + // route to FMS + ErrCode err = AppExecFwk::FormMgr::GetInstance().StartAbility(want, token_); HILOG_DEBUG("%{public}s. End calling StartAbility. ret=%{public}d", __func__, err); if (err != ERR_OK) { HILOG_ERROR("FormExtensionContext::StartAbility is failed %{public}d", err); diff --git a/interfaces/kits/native/appkit/ability_runtime/form_extension_context.h b/interfaces/kits/native/appkit/ability_runtime/form_extension_context.h index 3e80f413ca..2128598781 100644 --- a/interfaces/kits/native/appkit/ability_runtime/form_extension_context.h +++ b/interfaces/kits/native/appkit/ability_runtime/form_extension_context.h @@ -55,7 +55,6 @@ public: * @return errCode ERR_OK on success, others on failure. */ ErrCode StartAbility(const AAFwk::Want &want) const; - ErrCode StartAbility(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions) const; /** * @brief Obtains information about the current ability.