diff --git a/frameworks/js/napi/inputmethodability/js_input_method_engine_setting.cpp b/frameworks/js/napi/inputmethodability/js_input_method_engine_setting.cpp index 1ae2395e..218d11cd 100644 --- a/frameworks/js/napi/inputmethodability/js_input_method_engine_setting.cpp +++ b/frameworks/js/napi/inputmethodability/js_input_method_engine_setting.cpp @@ -531,7 +531,7 @@ napi_value JsInputMethodEngineSetting::GetResultOnSetSubtype(napi_env env, const napi_set_named_property(env, subType, "label", label); napi_value labelId = nullptr; - napi_create_int32(env, property.labelId, &labelId); + napi_create_uint32(env, property.labelId, &labelId); napi_set_named_property(env, subType, "labelId", labelId); napi_value name = nullptr; @@ -559,7 +559,7 @@ napi_value JsInputMethodEngineSetting::GetResultOnSetSubtype(napi_env env, const napi_set_named_property(env, subType, "icon", icon); napi_value iconId = nullptr; - napi_create_int32(env, property.iconId, &iconId); + napi_create_uint32(env, property.iconId, &iconId); napi_set_named_property(env, subType, "iconId", iconId); napi_value extra = nullptr; diff --git a/frameworks/js/napi/inputmethodclient/js_input_method.cpp b/frameworks/js/napi/inputmethodclient/js_input_method.cpp index 156a36dc..8cc3b088 100644 --- a/frameworks/js/napi/inputmethodclient/js_input_method.cpp +++ b/frameworks/js/napi/inputmethodclient/js_input_method.cpp @@ -120,7 +120,7 @@ napi_value JsInputMethod::GetJsInputMethodProperty(napi_env env, const Property napi_set_named_property(env, prop, "icon", icon); napi_value iconId = nullptr; - napi_create_int32(env, property.iconId, &iconId); + napi_create_uint32(env, property.iconId, &iconId); napi_set_named_property(env, prop, "iconId", iconId); napi_value label = nullptr; @@ -128,7 +128,7 @@ napi_value JsInputMethod::GetJsInputMethodProperty(napi_env env, const Property napi_set_named_property(env, prop, "label", label); napi_value labelId = nullptr; - napi_create_int32(env, property.labelId, &labelId); + napi_create_uint32(env, property.labelId, &labelId); napi_set_named_property(env, prop, "labelId", labelId); return prop; } @@ -147,7 +147,7 @@ napi_value JsInputMethod::GetJsInputMethodSubProperty(napi_env env, const SubPro napi_set_named_property(env, prop, "label", label); napi_value labelId = nullptr; - napi_create_int32(env, subProperty.labelId, &labelId); + napi_create_uint32(env, subProperty.labelId, &labelId); napi_set_named_property(env, prop, "labelId", labelId); napi_value name = nullptr; @@ -171,7 +171,7 @@ napi_value JsInputMethod::GetJsInputMethodSubProperty(napi_env env, const SubPro napi_set_named_property(env, prop, "icon", icon); napi_value iconId = nullptr; - napi_create_int32(env, subProperty.iconId, &iconId); + napi_create_uint32(env, subProperty.iconId, &iconId); napi_set_named_property(env, prop, "iconId", iconId); return prop; } diff --git a/frameworks/native/inputmethod_controller/include/input_method_property.h b/frameworks/native/inputmethod_controller/include/input_method_property.h index 4bdf20fa..b5301b3a 100644 --- a/frameworks/native/inputmethod_controller/include/input_method_property.h +++ b/frameworks/native/inputmethod_controller/include/input_method_property.h @@ -26,21 +26,21 @@ struct Property { std::string name; // the bundleName of inputMethod std::string id; // the extensionName of inputMethod std::string label; // the label of inputMethod - int32_t labelId = 0; // the labelId of inputMethod + uint32_t labelId = 0; // the labelId of inputMethod std::string icon; // the icon of inputMethod - int32_t iconId = 0; // the icon id of inputMethod + uint32_t iconId = 0; // the icon id of inputMethod }; struct SubProperty { std::string label; // the label of subtype - int32_t labelId = 0; // the labelId of subtype + uint32_t labelId = 0; // the labelId of subtype std::string name; // the bundleName of inputMethod std::string id; // the name of subtype std::string mode; // the mode of subtype, containing "upper" and "lower" std::string locale; // the tongues of subtype, such as "zh_CN", "en_US", etc. std::string language; // the language of subtype std::string icon; // the icon of subtype - int32_t iconId = 0; // the icon id of subtype + uint32_t iconId = 0; // the icon id of subtype }; struct FullImeInfo { diff --git a/services/include/ime_info_inquirer.h b/services/include/ime_info_inquirer.h index f4269270..8aa71af9 100644 --- a/services/include/ime_info_inquirer.h +++ b/services/include/ime_info_inquirer.h @@ -103,7 +103,7 @@ private: ~ImeInfoInquirer() = default; OHOS::sptr GetBundleMgr(); SubProperty GetExtends(const std::vector &metaData); - std::string GetStringById(const std::string &bundleName, const std::string &moduleName, const int32_t labelId, + std::string GetStringById(const std::string &bundleName, const std::string &moduleName, const uint32_t labelId, const int32_t userId); bool GetAppIdByBundleName(int32_t userId, const std::string &bundleName, std::string &appId); std::shared_ptr GetImeInfoFromCache(const int32_t userId, const std::string &bundleName, diff --git a/services/include/input_method_info.h b/services/include/input_method_info.h index 6597247b..38ad1458 100644 --- a/services/include/input_method_info.h +++ b/services/include/input_method_info.h @@ -29,8 +29,8 @@ struct InputMethodInfo { std::string mConfigurationPage; bool isSystemIme = false; int32_t mDefaultImeId = 0; - int32_t labelId = 0; - int32_t descriptionId = 0; + uint32_t labelId = 0; + uint32_t descriptionId = 0; std::string label; std::string description; }; diff --git a/services/src/ime_info_inquirer.cpp b/services/src/ime_info_inquirer.cpp index 5dc96dbf..86475a38 100644 --- a/services/src/ime_info_inquirer.cpp +++ b/services/src/ime_info_inquirer.cpp @@ -620,7 +620,7 @@ void ImeInfoInquirer::CovertToLanguage(const std::string &locale, std::string &l } std::string ImeInfoInquirer::GetStringById(const std::string &bundleName, const std::string &moduleName, - int32_t labelId, int32_t userId) + uint32_t labelId, int32_t userId) { auto bundleMgr = GetBundleMgr(); return bundleMgr == nullptr ? "" : bundleMgr->GetStringById(bundleName, moduleName, labelId, userId); diff --git a/test/fuzztest/inputmethodcontroller_fuzzer/inputmethodcontroller_fuzzer.cpp b/test/fuzztest/inputmethodcontroller_fuzzer/inputmethodcontroller_fuzzer.cpp index bad39149..a6d5d2ea 100644 --- a/test/fuzztest/inputmethodcontroller_fuzzer/inputmethodcontroller_fuzzer.cpp +++ b/test/fuzztest/inputmethodcontroller_fuzzer/inputmethodcontroller_fuzzer.cpp @@ -40,7 +40,7 @@ void TestListInputMethod(sptr imc) imc->DisplayOptionalInputMethod(); } -void TestListInputMethodSubtype(sptr imc, const std::string &fuzzedString, int32_t fuzzedInt32) +void TestListInputMethodSubtype(sptr imc, const std::string &fuzzedString, uint32_t fuzzedUint32) { std::vector subProperties = {}; Property property; @@ -48,7 +48,7 @@ void TestListInputMethodSubtype(sptr imc, const std::stri property.id = fuzzedString; property.label = fuzzedString; property.icon = fuzzedString; - property.iconId = fuzzedInt32; + property.iconId = fuzzedUint32; imc->ListInputMethodSubtype(property, subProperties); } @@ -206,7 +206,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) OHOS::sptr imc = InputMethodController::GetInstance(); OHOS::TestListInputMethod(imc); - OHOS::TestListInputMethodSubtype(imc, fuzzedString, fuzzedInt32); + OHOS::TestListInputMethodSubtype(imc, fuzzedString, fuzzedUint32); OHOS::TestOnSelectionChange(imc, fuzzedU16String, fuzzedInt, fuzzedDouble); OHOS::TestOnConfigurationChange(imc); OHOS::TestSwitchInputMethod(fuzzedTrigger, imc, fuzzedString); diff --git a/test/unittest/cpp_test/src/js_util_test.cpp b/test/unittest/cpp_test/src/js_util_test.cpp index d1d1be2e..db5809d2 100644 --- a/test/unittest/cpp_test/src/js_util_test.cpp +++ b/test/unittest/cpp_test/src/js_util_test.cpp @@ -28,7 +28,7 @@ struct Property { std::string name; std::string id; std::string icon; - int32_t iconId = 0; + uint32_t iconId = 0; }; struct JsProperty { static napi_value Write(napi_env env, const std::shared_ptr &nativeObject)