add switch napi fuction

Signed-off-by: zhaolinglan <zhaolinglan@huawei.com>
This commit is contained in:
zhaolinglan
2022-07-05 12:16:44 +08:00
parent 2a937f009f
commit 607a9195d0
6 changed files with 105 additions and 0 deletions
@@ -72,6 +72,7 @@ namespace MiscServices {
int32_t GetInputPattern();
void HideCurrentInput();
void SetCallingWindow(uint32_t windowId);
int32_t SwitchInputMethod(InputMethodProperty *target);
private:
InputMethodController();
@@ -56,6 +56,7 @@ namespace MiscServices {
int32_t listInputMethodEnabled(std::vector<InputMethodProperty*> *properties) override;
int32_t listInputMethod(std::vector<InputMethodProperty*> *properties) override;
int32_t listKeyboardType(const std::u16string& imeId, std::vector<KeyboardType*> *types) override;
int32_t SwitchInputMethod(InputMethodProperty* target);
private:
static inline BrokerDelegator<InputMethodSystemAbilityProxy> delegator_;
@@ -433,5 +433,14 @@ using namespace MessageID;
mAgent->SetCallingWindow(windowId);
return;
}
int32_t InputMethodController::SwitchInputMethod(InputMethodProperty *target)
{
IMSA_HILOGI("InputMethodController::SwitchInputMethod");
if (!mImms) {
return false;
}
return mImms->SwitchInputMethod(target);
}
} // namespace MiscServices
} // namespace OHOS
@@ -437,5 +437,26 @@ namespace MiscServices {
}
return NO_ERROR;
}
int32_t InputMethodSystemAbilityProxy::SwitchInputMethod(InputMethodProperty* target)
{
IMSA_HILOGI("InputMethodSystemAbilityProxy::switchInputMethod");
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return false;
}
if (!target->Marshalling(data)) {
IMSA_HILOGE("InputMethodSystemAbilityProxy::switchInputMethod Failed to marshall target to data!");
delete target;
return false;
}
delete target;
auto ret = Remote()->SendRequest(SWITCH_INPUT_METHOD, data, reply, option);
ret = reply.ReadInt32();
return ret;
}
} // namespace MiscServices
} // namespace OHOS