mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 22:59:45 +00:00
commit
956c5a6c3c
@ -408,7 +408,7 @@ napi_value JsGetInputMethodSetting::Subscribe(napi_env env, napi_callback_info i
|
||||
std::make_shared<JSCallbackObject>(env, argv[ARGC_ONE], std::this_thread::get_id());
|
||||
auto ret = engine->RegisterListener(argv[ARGC_ONE], type, callback);
|
||||
auto errCode = JsUtils::Convert(ret);
|
||||
if (errCode == EXCEPTION_PERMISSION) {
|
||||
if (errCode == EXCEPTION_SYSTEM_PERMISSION) {
|
||||
JsUtils::ThrowException(env, errCode, "", TYPE_NONE);
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
|
@ -24,6 +24,7 @@ constexpr size_t ARGC_MAX = 6;
|
||||
const std::map<int32_t, int32_t> JsUtils::ERROR_CODE_MAP = {
|
||||
{ ErrorCode::ERROR_CONTROLLER_INVOKING_FAILED, EXCEPTION_CONTROLLER },
|
||||
{ ErrorCode::ERROR_STATUS_PERMISSION_DENIED, EXCEPTION_PERMISSION },
|
||||
{ ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION, EXCEPTION_SYSTEM_PERMISSION },
|
||||
{ ErrorCode::ERROR_REMOTE_CLIENT_DIED, EXCEPTION_IMCLIENT },
|
||||
{ ErrorCode::ERROR_CLIENT_NOT_FOUND, EXCEPTION_IMCLIENT },
|
||||
{ ErrorCode::ERROR_CLIENT_NULL_POINTER, EXCEPTION_IMCLIENT },
|
||||
@ -51,6 +52,7 @@ const std::map<int32_t, int32_t> JsUtils::ERROR_CODE_MAP = {
|
||||
|
||||
const std::map<int32_t, std::string> JsUtils::ERROR_CODE_CONVERT_MESSAGE_MAP = {
|
||||
{ EXCEPTION_PERMISSION, "the permissions check fails." },
|
||||
{ EXCEPTION_SYSTEM_PERMISSION, "not system application." },
|
||||
{ EXCEPTION_PARAMCHECK, "the parameters check fails." },
|
||||
{ EXCEPTION_UNSUPPORTED, "call unsupported api." },
|
||||
{ EXCEPTION_PACKAGEMANAGER, "package manager error." },
|
||||
|
@ -33,6 +33,7 @@ namespace OHOS {
|
||||
namespace MiscServices {
|
||||
enum IMFErrorCode : int32_t {
|
||||
EXCEPTION_PERMISSION = 201,
|
||||
EXCEPTION_SYSTEM_PERMISSION = 202,
|
||||
EXCEPTION_PARAMCHECK = 401,
|
||||
EXCEPTION_UNSUPPORTED = 801,
|
||||
EXCEPTION_PACKAGEMANAGER = 12800001,
|
||||
|
@ -95,6 +95,7 @@ enum {
|
||||
ERROR_NOT_CURRENT_IME = 21,
|
||||
ERROR_NOT_IME = 22,
|
||||
ERROR_ADD_DEATH_RECIPIENT_FAILED = 23,
|
||||
ERROR_STATUS_SYSTEM_PERMISSION = 24, // not system application
|
||||
};
|
||||
}; // namespace ErrorCode
|
||||
|
||||
|
@ -338,8 +338,8 @@ int32_t InputMethodSystemAbility::UpdateListenEventFlag(InputClientInfo &clientI
|
||||
IMSA_HILOGI("eventType: %{public}u, eventFlag: %{public}u", eventType, clientInfo.eventFlag);
|
||||
if ((eventType == IME_SHOW || eventType == IME_HIDE)
|
||||
&& !BundleChecker::IsSystemApp(IPCSkeleton::GetCallingFullTokenID())) {
|
||||
IMSA_HILOGD("permission denied");
|
||||
return ErrorCode::ERROR_STATUS_PERMISSION_DENIED;
|
||||
IMSA_HILOGE("not system application");
|
||||
return ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION;
|
||||
}
|
||||
auto ret = GenerateClientInfo(clientInfo);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
|
@ -1127,4 +1127,42 @@ describe('InputMethodTest', function () {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number inputmethod_settings_test_on_imeShow_001
|
||||
* @tc.name Test whether the register the callback of the input method is valid.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 2
|
||||
*/
|
||||
it('inputmethod_setting_test_on_imeShow_001', 0, async function (done) {
|
||||
let inputMethodSetting = inputMethod.getSetting();
|
||||
try {
|
||||
inputMethodSetting.on('imeShow', (info) => {});
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
} catch (error) {
|
||||
console.info(`inputmethod_setting_test_on_imeShow_001 result: ${JSON.stringify(error)}`);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number inputmethod_settings_test_on_imeHide_001
|
||||
* @tc.name Test whether the register the callback of the input method is valid.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 2
|
||||
*/
|
||||
it('inputmethod_setting_test_on_imeHide_001', 0, async function (done) {
|
||||
let inputMethodSetting = inputMethod.getSetting();
|
||||
try {
|
||||
inputMethodSetting.on('imeHide', (info) => {});
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
} catch (error) {
|
||||
console.info(`inputmethod_setting_test_on_imeHide_001 result: ${JSON.stringify(error)}`);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user