mirror of
https://github.com/openharmony/miscservices_inputmethod.git
synced 2026-07-19 20:13:32 -04:00
!175 修改inputmethod 3.2-Beta2
Merge pull request !175 from mashaoyin/OpenHarmony-3.2-Beta2
This commit is contained in:
@@ -73,7 +73,7 @@ namespace MiscServices {
|
||||
|
||||
auto systemAbility = systemAbilityManager->GetSystemAbility(INPUT_METHOD_SYSTEM_ABILITY_ID, "");
|
||||
if (!systemAbility) {
|
||||
IMSA_HILOGI("InputMethodAbility::GetImsaProxy systemAbility is nullptr");
|
||||
IMSA_HILOGI("InputMethodAbility::GetImsaProxy systemAbility is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -202,12 +202,12 @@ namespace MiscServices {
|
||||
IMSA_HILOGI("InputMethodAbility::OnInitialInput channelObject is nullptr");
|
||||
return;
|
||||
}
|
||||
sptr<InputControlChannelProxy> channelProxy = new InputControlChannelProxy(channelObject);
|
||||
inputControlChannel = channelProxy;
|
||||
if (!inputControlChannel) {
|
||||
sptr<InputControlChannelProxy> channelProxy = new (std::nothrow) InputControlChannelProxy(channelObject);
|
||||
if (channelProxy == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::OnInitialInput inputControlChannel is nullptr");
|
||||
return;
|
||||
}
|
||||
inputControlChannel = channelProxy;
|
||||
}
|
||||
|
||||
void InputMethodAbility::OnInitInputControlChannel(Message *msg)
|
||||
@@ -219,23 +219,24 @@ namespace MiscServices {
|
||||
IMSA_HILOGI("InputMethodAbility::OnInitInputControlChannel channelObject is nullptr");
|
||||
return;
|
||||
}
|
||||
sptr<InputControlChannelProxy> channelProxy = new InputControlChannelProxy(channelObject);
|
||||
inputControlChannel = channelProxy;
|
||||
if (!inputControlChannel) {
|
||||
sptr<InputControlChannelProxy> channelProxy = new (std::nothrow) InputControlChannelProxy(channelObject);
|
||||
if (channelProxy == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::OnInitInputControlChannel inputControlChannel is nullptr");
|
||||
return;
|
||||
}
|
||||
inputControlChannel = channelProxy;
|
||||
}
|
||||
|
||||
void InputMethodAbility::OnStartInput(Message *msg)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::OnStartInput");
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
sptr<InputDataChannelProxy> channalProxy = new InputDataChannelProxy(data->ReadRemoteObject());
|
||||
inputDataChannel = channalProxy;
|
||||
if (!inputDataChannel) {
|
||||
sptr<InputDataChannelProxy> channalProxy = new (std::nothrow) InputDataChannelProxy(data->ReadRemoteObject());
|
||||
if (channalProxy == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::OnStartInput inputDataChannel is nullptr");
|
||||
return;
|
||||
}
|
||||
inputDataChannel = channalProxy;
|
||||
editorAttribute = data->ReadParcelable<InputAttribute>();
|
||||
if (!editorAttribute) {
|
||||
IMSA_HILOGI("InputMethodAbility::OnStartInput editorAttribute is nullptr");
|
||||
@@ -247,10 +248,10 @@ namespace MiscServices {
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::OnShowKeyboard");
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
sptr<InputDataChannelProxy> channalProxy = new InputDataChannelProxy(data->ReadRemoteObject());
|
||||
inputDataChannel = channalProxy;
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::OnShowKeyboard inputDataChannel is nullptr");
|
||||
sptr<InputDataChannelProxy> channalProxy = new (std::nothrow) InputDataChannelProxy(data->ReadRemoteObject());
|
||||
if (channalProxy != nullptr) {
|
||||
inputDataChannel = channalProxy;
|
||||
IMSA_HILOGI("InputMethodAbility::OnShowKeyboard inputDataChannel is not nullptr");
|
||||
}
|
||||
ShowInputWindow();
|
||||
}
|
||||
@@ -339,9 +340,12 @@ namespace MiscServices {
|
||||
}
|
||||
imeListener_->OnInputStart();
|
||||
imeListener_->OnKeyboardStatus(true);
|
||||
if (inputDataChannel) {
|
||||
inputDataChannel->SendKeyboardStatus(KEYBOARD_SHOW);
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::ShowInputWindow channel is nullptr");
|
||||
return;
|
||||
}
|
||||
channel->SendKeyboardStatus(KEYBOARD_SHOW);
|
||||
}
|
||||
|
||||
void InputMethodAbility::DissmissInputWindow()
|
||||
@@ -352,124 +356,135 @@ namespace MiscServices {
|
||||
return;
|
||||
}
|
||||
imeListener_->OnKeyboardStatus(false);
|
||||
if (inputDataChannel) {
|
||||
inputDataChannel->SendKeyboardStatus(KEYBOARD_HIDE);
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::DissmissInputWindow channel is nullptr");
|
||||
return;
|
||||
}
|
||||
channel->SendKeyboardStatus(KEYBOARD_HIDE);
|
||||
}
|
||||
|
||||
bool InputMethodAbility::InsertText(const std::string text)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::InsertText");
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::InsertText inputDataChanel is nullptr");
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::InsertText channel is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
return inputDataChannel->InsertText(Utils::to_utf16(text));
|
||||
return channel->InsertText(Utils::to_utf16(text));
|
||||
}
|
||||
|
||||
void InputMethodAbility::DeleteForward(int32_t length)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::DeleteForward");
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::DeleteForward inputDataChanel is nullptr");
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::DeleteForward channel is nullptr");
|
||||
return;
|
||||
}
|
||||
inputDataChannel->DeleteForward(length);
|
||||
channel->DeleteForward(length);
|
||||
}
|
||||
|
||||
void InputMethodAbility::DeleteBackward(int32_t length)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::DeleteBackward");
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::DeleteBackward inputDataChanel is nullptr");
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::DeleteBackward channel is nullptr");
|
||||
return;
|
||||
}
|
||||
inputDataChannel->DeleteBackward(length);
|
||||
channel->DeleteBackward(length);
|
||||
}
|
||||
|
||||
void InputMethodAbility::SendFunctionKey(int32_t funcKey)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::SendFunctionKey");
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::SendFunctionKey inputDataChanel is nullptr");
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::SendFunctionKey channel is nullptr");
|
||||
return;
|
||||
}
|
||||
inputDataChannel->SendFunctionKey(funcKey);
|
||||
channel->SendFunctionKey(funcKey);
|
||||
}
|
||||
|
||||
void InputMethodAbility::HideKeyboardSelf()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::HideKeyboardSelf");
|
||||
inputControlChannel->hideKeyboardSelf(1);
|
||||
sptr<IInputControlChannel> controlChannel = inputControlChannel;
|
||||
if (controlChannel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::HideKeyboardSelf controlChannel is nullptr");
|
||||
return;
|
||||
}
|
||||
controlChannel->hideKeyboardSelf(1);
|
||||
}
|
||||
|
||||
std::u16string InputMethodAbility::GetTextBeforeCursor(int32_t number)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::GetTextBeforeCursor");
|
||||
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::GetTextBeforeCursor inputDataChanel is nullptr");
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::GetTextBeforeCursor channel is nullptr");
|
||||
return u"";
|
||||
}
|
||||
return inputDataChannel->GetTextBeforeCursor(number);
|
||||
return channel->GetTextBeforeCursor(number);
|
||||
}
|
||||
|
||||
std::u16string InputMethodAbility::GetTextAfterCursor(int32_t number)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::GetTextAfterCursor");
|
||||
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::GetTextAfterCursor inputDataChanel is nullptr");
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::GetTextAfterCursor channel is nullptr");
|
||||
return u"";
|
||||
}
|
||||
return inputDataChannel->GetTextAfterCursor(number);
|
||||
return channel->GetTextAfterCursor(number);
|
||||
}
|
||||
|
||||
void InputMethodAbility::MoveCursor(int32_t keyCode)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::MoveCursor");
|
||||
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::MoveCursor inputDataChanel is nullptr");
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::MoveCursor channel is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
inputDataChannel->MoveCursor(keyCode);
|
||||
channel->MoveCursor(keyCode);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t InputMethodAbility::GetEnterKeyType()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::GetEnterKeyType");
|
||||
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::GetEnterKeyType inputDataChanel is nullptr");
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::GetEnterKeyType channel is nullptr");
|
||||
return 0;
|
||||
}
|
||||
return inputDataChannel->GetEnterKeyType();
|
||||
return channel->GetEnterKeyType();
|
||||
}
|
||||
|
||||
int32_t InputMethodAbility::GetInputPattern()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::GetInputPattern");
|
||||
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::GetInputPattern inputDataChanel is nullptr");
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::GetInputPattern channel is nullptr");
|
||||
return 0;
|
||||
}
|
||||
return inputDataChannel->GetInputPattern();
|
||||
return channel->GetInputPattern();
|
||||
}
|
||||
|
||||
void InputMethodAbility::StopInput()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::StopInput");
|
||||
|
||||
if (!inputDataChannel) {
|
||||
IMSA_HILOGI("InputMethodAbility::StopInput inputDataChanel is nullptr");
|
||||
sptr<IInputDataChannel> channel = inputDataChannel;
|
||||
if (channel == nullptr) {
|
||||
IMSA_HILOGI("InputMethodAbility::StopInput channel is nullptr");
|
||||
return;
|
||||
}
|
||||
inputDataChannel->StopInput();
|
||||
channel->StopInput();
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -111,6 +111,8 @@ namespace MiscServices {
|
||||
bool stop_;
|
||||
int32_t enterKeyType_ = 0;
|
||||
int32_t inputPattern_ = 0;
|
||||
|
||||
bool isStopInput {false};
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -294,6 +294,7 @@ using namespace MessageID;
|
||||
&& data.WriteRemoteObject(client->AsObject()))) {
|
||||
return;
|
||||
}
|
||||
isStopInput = false;
|
||||
mImms->startInput(data);
|
||||
}
|
||||
|
||||
@@ -308,6 +309,7 @@ using namespace MessageID;
|
||||
&& data.WriteRemoteObject(client->AsObject().GetRefPtr()))) {
|
||||
return;
|
||||
}
|
||||
isStopInput = true;
|
||||
mImms->releaseInput(data);
|
||||
}
|
||||
|
||||
@@ -322,6 +324,7 @@ using namespace MessageID;
|
||||
&& data.WriteRemoteObject(client->AsObject().GetRefPtr()))) {
|
||||
return;
|
||||
}
|
||||
isStopInput = true;
|
||||
mImms->stopInput(data);
|
||||
}
|
||||
|
||||
@@ -341,8 +344,14 @@ using namespace MessageID;
|
||||
|
||||
void InputMethodController::OnCursorUpdate(CursorInfo cursorInfo)
|
||||
{
|
||||
if (!mAgent) {
|
||||
IMSA_HILOGI("InputMethodController::OnCursorUpdate mAgent is nullptr");
|
||||
sptr<InputMethodAgentProxy> agent = mAgent;
|
||||
if (agent == nullptr) {
|
||||
IMSA_HILOGI("InputMethodController::OnCursorUpdate agent is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isStopInput) {
|
||||
IMSA_HILOGD("InputMethodController::OnCursorUpdate isStopInput");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -351,7 +360,7 @@ using namespace MessageID;
|
||||
return;
|
||||
}
|
||||
cursorInfo_ = cursorInfo;
|
||||
mAgent->OnCursorUpdate(cursorInfo.left, cursorInfo.top, cursorInfo.height);
|
||||
agent->OnCursorUpdate(cursorInfo.left, cursorInfo.top, cursorInfo.height);
|
||||
}
|
||||
|
||||
void InputMethodController::OnSelectionChange(std::u16string text, int start, int end)
|
||||
@@ -365,11 +374,18 @@ using namespace MessageID;
|
||||
mSelectOldEnd = mSelectNewEnd;
|
||||
mSelectNewBegin = start;
|
||||
mSelectNewEnd = end;
|
||||
if (!mAgent) {
|
||||
IMSA_HILOGI("InputMethodController::OnSelectionChange mAgent is nullptr");
|
||||
sptr<InputMethodAgentProxy> agent = mAgent;
|
||||
if (agent == nullptr) {
|
||||
IMSA_HILOGI("InputMethodController::OnSelectionChange agent is nullptr");
|
||||
return;
|
||||
}
|
||||
mAgent->OnSelectionChange(mTextString, mSelectOldBegin, mSelectOldEnd, mSelectNewBegin, mSelectNewEnd);
|
||||
|
||||
if (isStopInput) {
|
||||
IMSA_HILOGD("InputMethodController::OnSelectionChange isStopInput");
|
||||
return;
|
||||
}
|
||||
|
||||
agent->OnSelectionChange(mTextString, mSelectOldBegin, mSelectOldEnd, mSelectNewBegin, mSelectNewEnd);
|
||||
}
|
||||
|
||||
void InputMethodController::OnConfigurationChange(Configuration info)
|
||||
@@ -404,18 +420,25 @@ using namespace MessageID;
|
||||
bool InputMethodController::dispatchKeyEvent(std::shared_ptr<MMI::KeyEvent> keyEvent)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodController::dispatchKeyEvent");
|
||||
if (!mAgent) {
|
||||
IMSA_HILOGI("InputMethodController::dispatchKeyEvent mAgent is nullptr");
|
||||
sptr<InputMethodAgentProxy> agent = mAgent;
|
||||
if (agent == nullptr) {
|
||||
IMSA_HILOGI("InputMethodController::dispatchKeyEvent agent is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isStopInput) {
|
||||
IMSA_HILOGD("InputMethodController::dispatchKeyEvent isStopInput");
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
if (!(data.WriteInterfaceToken(mAgent->GetDescriptor())
|
||||
if (!(data.WriteInterfaceToken(agent->GetDescriptor())
|
||||
&& data.WriteInt32(keyEvent->GetKeyCode())
|
||||
&& data.WriteInt32(keyEvent->GetKeyAction()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mAgent->DispatchKeyEvent(data);
|
||||
return agent->DispatchKeyEvent(data);
|
||||
}
|
||||
|
||||
int32_t InputMethodController::GetEnterKeyType()
|
||||
@@ -432,13 +455,19 @@ using namespace MessageID;
|
||||
|
||||
void InputMethodController::SetCallingWindow(uint32_t windowId)
|
||||
{
|
||||
sptr<InputMethodAgentProxy> agent = mAgent;
|
||||
IMSA_HILOGI("InputMethodController::SetCallingWindow windowId = %{public}d", windowId);
|
||||
if (!mAgent) {
|
||||
IMSA_HILOGI("InputMethodController::SetCallingWindow mAgent is nullptr");
|
||||
if (agent == nullptr) {
|
||||
IMSA_HILOGI("InputMethodController::SetCallingWindow agent is nullptr");
|
||||
return;
|
||||
}
|
||||
mAgent->SetCallingWindow(windowId);
|
||||
return;
|
||||
|
||||
if (isStopInput) {
|
||||
IMSA_HILOGD("InputMethodController::SetCallingWindow isStopInput");
|
||||
return;
|
||||
}
|
||||
|
||||
agent->SetCallingWindow(windowId);
|
||||
}
|
||||
|
||||
int32_t InputMethodController::SwitchInputMethod(InputMethodProperty *target)
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OHOS {
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (size < OHOS::THRESHOLD) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
/* Run your code on data */
|
||||
OHOS::FuzzInputClientStub(data, size);
|
||||
|
||||
Reference in New Issue
Block a user