diff --git a/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp b/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp index 8c63fb061a0fc00a1d12bab206e1002bdfb8a9b9..b7fcec913b184adce344c877d1f1ab315c3b912e 100644 --- a/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp +++ b/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp @@ -1247,7 +1247,8 @@ napi_value JsTextInputClientEngine::GetAttachOptions(napi_env env, napi_callback bool flag = IsTargetDeviceType(DEVICE_TYPE_2IN1); if (!flag) { JsUtils::ThrowException( - env, JsUtils::Convert(IMFErrorCode::EXCEPTION_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); + env, JsUtils::Convert(ErrorCode::ERROR_DEVICE_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); + return JsUtil::Const::Null(env); } AttachOptions attachOptions; attachOptions.requestKeyboardReason = InputMethodAbility::GetInstance()->GetRequestKeyboardReason(); @@ -1271,7 +1272,8 @@ napi_value JsTextInputClientEngine::Subscribe(napi_env env, napi_callback_info i } if (type == "attachOptionsDidChange" && !IsTargetDeviceType(DEVICE_TYPE_2IN1)) { JsUtils::ThrowException( - env, JsUtils::Convert(IMFErrorCode::EXCEPTION_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); + env, JsUtils::Convert(ErrorCode::ERROR_DEVICE_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); + return JsUtil::Const::Null(env); } IMSA_HILOGD("subscribe type:%{public}s.", type.c_str()); auto engine = reinterpret_cast(JsUtils::GetNativeSelf(env, info)); @@ -1302,10 +1304,6 @@ napi_value JsTextInputClientEngine::UnSubscribe(napi_env env, napi_callback_info IMSA_HILOGE("unsubscribe failed, type: %{public}s!", type.c_str()); return nullptr; } - if (type == "attachOptionsDidChange" && !IsTargetDeviceType(DEVICE_TYPE_2IN1)) { - JsUtils::ThrowException( - env, JsUtils::Convert(IMFErrorCode::EXCEPTION_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); - } // if the second param is not napi_function/napi_null/napi_undefined, return auto paramType = JsUtil::GetType(env, argv[1]); if (paramType != napi_function && paramType != napi_null && paramType != napi_undefined) {