From 4451d28c3b6fb2f36d43a71014c416baf5848cd1 Mon Sep 17 00:00:00 2001 From: liangwei Date: Wed, 4 Jun 2025 17:05:02 +0800 Subject: [PATCH 1/2] liangwei49@huawei.com Signed-off-by: liangwei --- .../napi/inputmethodability/js_text_input_client_engine.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 c15d633a5..d768f0398 100644 --- a/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp +++ b/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp @@ -35,6 +35,7 @@ namespace MiscServices { using namespace std::chrono; thread_local napi_ref JsTextInputClientEngine::TICRef_ = nullptr; const std::string JsTextInputClientEngine::TIC_CLASS_NAME = "TextInputClient"; +constexpr int32_t DEVICE_TYPE_TABLET = 1; constexpr int32_t DEVICE_TYPE_2IN1 = 7; constexpr int32_t MAX_WAIT_TIME = 5000; constexpr int32_t MAX_WAIT_TIME_PRIVATE_COMMAND = 2000; @@ -1254,7 +1255,7 @@ napi_value JsTextInputClientEngine::GetAttachOptions(napi_env env, napi_callback { IMSA_HILOGD("GetAttachOptions requestKeyboardReason:%{public}d.", InputMethodAbility::GetInstance().GetRequestKeyboardReason()); - bool flag = IsTargetDeviceType(DEVICE_TYPE_2IN1); + bool flag = IsTargetDeviceType(DEVICE_TYPE_2IN1) || IsTargetDeviceType(DEVICE_TYPE_TABLET); if (!flag) { JsUtils::ThrowException( env, JsUtils::Convert(ErrorCode::ERROR_DEVICE_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); @@ -1280,7 +1281,8 @@ napi_value JsTextInputClientEngine::Subscribe(napi_env env, napi_callback_info i IMSA_HILOGE("subscribe failed, type: %{public}s.", type.c_str()); return nullptr; } - if (type == "attachOptionsDidChange" && !IsTargetDeviceType(DEVICE_TYPE_2IN1)) { + if (type == "attachOptionsDidChange" && + !(IsTargetDeviceType(DEVICE_TYPE_2IN1) || IsTargetDeviceType(DEVICE_TYPE_TABLET))) { JsUtils::ThrowException( env, JsUtils::Convert(ErrorCode::ERROR_DEVICE_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); return JsUtil::Const::Null(env); -- Gitee From aa23844412a49f83761e8d61aefa65f3a1cf5976 Mon Sep 17 00:00:00 2001 From: liangwei Date: Wed, 4 Jun 2025 17:05:02 +0800 Subject: [PATCH 2/2] liangwei49@huawei.com Signed-off-by: liangwei --- .../inputmethodability/js_text_input_client_engine.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 c15d633a5..150ba2ef2 100644 --- a/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp +++ b/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp @@ -35,6 +35,7 @@ namespace MiscServices { using namespace std::chrono; thread_local napi_ref JsTextInputClientEngine::TICRef_ = nullptr; const std::string JsTextInputClientEngine::TIC_CLASS_NAME = "TextInputClient"; +constexpr int32_t DEVICE_TYPE_TABLET = 1; constexpr int32_t DEVICE_TYPE_2IN1 = 7; constexpr int32_t MAX_WAIT_TIME = 5000; constexpr int32_t MAX_WAIT_TIME_PRIVATE_COMMAND = 2000; @@ -1254,10 +1255,10 @@ napi_value JsTextInputClientEngine::GetAttachOptions(napi_env env, napi_callback { IMSA_HILOGD("GetAttachOptions requestKeyboardReason:%{public}d.", InputMethodAbility::GetInstance().GetRequestKeyboardReason()); - bool flag = IsTargetDeviceType(DEVICE_TYPE_2IN1); + bool flag = IsTargetDeviceType(DEVICE_TYPE_2IN1) || IsTargetDeviceType(DEVICE_TYPE_TABLET); if (!flag) { JsUtils::ThrowException( - env, JsUtils::Convert(ErrorCode::ERROR_DEVICE_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); + env, JsUtils::Convert(ErrorCode::ERROR_DEVICE_UNSUPPORTED), "only 2in1 and tablet supported!", TYPE_NONE); return JsUtil::Const::Null(env); } AttachOptions attachOptions; @@ -1280,9 +1281,10 @@ napi_value JsTextInputClientEngine::Subscribe(napi_env env, napi_callback_info i IMSA_HILOGE("subscribe failed, type: %{public}s.", type.c_str()); return nullptr; } - if (type == "attachOptionsDidChange" && !IsTargetDeviceType(DEVICE_TYPE_2IN1)) { + if (type == "attachOptionsDidChange" && + !(IsTargetDeviceType(DEVICE_TYPE_2IN1) || IsTargetDeviceType(DEVICE_TYPE_TABLET))) { JsUtils::ThrowException( - env, JsUtils::Convert(ErrorCode::ERROR_DEVICE_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); + env, JsUtils::Convert(ErrorCode::ERROR_DEVICE_UNSUPPORTED), "only 2in1 and tablet supported!", TYPE_NONE); return JsUtil::Const::Null(env); } IMSA_HILOGD("subscribe type:%{public}s.", type.c_str()); -- Gitee