mirror of
https://github.com/openharmony/miscservices_inputmethod.git
synced 2026-07-21 16:05:20 -04:00
Merge branch 'OpenHarmony-3.0-LTS' of gitee.com:openharmony/miscservices_inputmethod into OpenHarmony-3.0-LTS
Signed-off-by: championships <chenjiale5@hisilicon.com>
This commit is contained in:
@@ -24,7 +24,7 @@ using namespace MessageID;
|
||||
sptr<InputMethodController> InputMethodController::instance_;
|
||||
std::mutex InputMethodController::instanceLock_;
|
||||
|
||||
InputMethodController::InputMethodController()
|
||||
InputMethodController::InputMethodController() : stop_(false)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodController structure");
|
||||
Initialize();
|
||||
@@ -34,6 +34,8 @@ using namespace MessageID;
|
||||
{
|
||||
if (msgHandler != nullptr) {
|
||||
delete msgHandler;
|
||||
msgHandler = nullptr;
|
||||
stop_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +66,8 @@ using namespace MessageID;
|
||||
|
||||
workThreadHandler = std::thread([this]{WorkThread();});
|
||||
mAttribute.SetInputPattern(InputAttribute::PATTERN_TEXT);
|
||||
|
||||
textListener = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -94,60 +98,61 @@ using namespace MessageID;
|
||||
|
||||
void InputMethodController::WorkThread()
|
||||
{
|
||||
while(1) {
|
||||
while (!stop_) {
|
||||
Message *msg = msgHandler->GetMessage();
|
||||
switch(msg->msgId_) {
|
||||
case MSG_ID_INSERT_CHAR:{
|
||||
switch (msg->msgId_) {
|
||||
case MSG_ID_INSERT_CHAR: {
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
std::u16string text = data->ReadString16();
|
||||
if(textListener != nullptr){
|
||||
if (textListener != nullptr) {
|
||||
textListener->InsertText(text);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_ID_DELETE_BACKWARD:{
|
||||
case MSG_ID_DELETE_BACKWARD: {
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
int32_t length = data->ReadInt32();
|
||||
if(textListener != nullptr){
|
||||
if (textListener != nullptr) {
|
||||
textListener->DeleteBackward(length);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_ID_SET_DISPLAY_MODE:{
|
||||
case MSG_ID_SET_DISPLAY_MODE: {
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
int32_t ret = data->ReadInt32();
|
||||
IMSA_HILOGI("MSG_ID_SET_DISPLAY_MODE : %{public}d", ret);
|
||||
break;
|
||||
}
|
||||
case MSG_ID_ON_INPUT_READY:{
|
||||
case MSG_ID_ON_INPUT_READY: {
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
int32_t ret = data->ReadInt32();
|
||||
if(ret != ErrorCode::NO_ERROR) {
|
||||
if (textListener != nullptr){
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
if (textListener != nullptr) {
|
||||
textListener->SetKeyboardStatus(false);
|
||||
}
|
||||
mAgent=nullptr;
|
||||
mAgent = nullptr;
|
||||
break;
|
||||
}
|
||||
sptr<IRemoteObject> object = data->ReadRemoteObject();
|
||||
mAgent = new InputMethodAgentProxy(object);
|
||||
if (textListener != nullptr){
|
||||
if (textListener != nullptr) {
|
||||
textListener->SetKeyboardStatus(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_ID_EXIT_SERVICE:{
|
||||
case MSG_ID_EXIT_SERVICE: {
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
int32_t ret = data->ReadInt32();
|
||||
textListener = nullptr;
|
||||
IMSA_HILOGI("MSG_ID_EXIT_SERVICE : %{public}d", ret);
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete msg;
|
||||
msg = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,15 +183,15 @@ using namespace MessageID;
|
||||
sptr<InputDataChannelStub> &channel, InputAttribute &attribute)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodController::PrepareInput");
|
||||
if(mImms == nullptr){
|
||||
if (mImms == nullptr) {
|
||||
return;
|
||||
}
|
||||
MessageParcel data;
|
||||
if(!(data.WriteInterfaceToken(mImms->GetDescriptor())
|
||||
&&data.WriteInt32(displayId)
|
||||
&&data.WriteRemoteObject(client->AsObject())
|
||||
&&data.WriteRemoteObject(channel->AsObject())
|
||||
&&data.WriteParcelable(&attribute))){
|
||||
if (!(data.WriteInterfaceToken(mImms->GetDescriptor())
|
||||
&& data.WriteInt32(displayId)
|
||||
&& data.WriteRemoteObject(client->AsObject())
|
||||
&& data.WriteRemoteObject(channel->AsObject())
|
||||
&& data.WriteParcelable(&attribute))) {
|
||||
return;
|
||||
}
|
||||
mImms->prepareInput(data);
|
||||
@@ -195,12 +200,12 @@ using namespace MessageID;
|
||||
void InputMethodController::StartInput(sptr<InputClientStub> &client)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodController::StartInput");
|
||||
if(mImms == nullptr){
|
||||
if (mImms == nullptr) {
|
||||
return;
|
||||
}
|
||||
MessageParcel data;
|
||||
if(!(data.WriteInterfaceToken(mImms->GetDescriptor())
|
||||
&&data.WriteRemoteObject(client->AsObject()))){
|
||||
if (!(data.WriteInterfaceToken(mImms->GetDescriptor())
|
||||
&& data.WriteRemoteObject(client->AsObject()))) {
|
||||
return;
|
||||
}
|
||||
mImms->startInput(data);
|
||||
@@ -209,12 +214,12 @@ using namespace MessageID;
|
||||
void InputMethodController::ReleaseInput(sptr<InputClientStub> &client)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodController::ReleaseInput");
|
||||
if(mImms == nullptr){
|
||||
if (mImms == nullptr) {
|
||||
return;
|
||||
}
|
||||
MessageParcel data;
|
||||
if(!(data.WriteInterfaceToken(mImms->GetDescriptor())
|
||||
&&data.WriteRemoteObject(client->AsObject().GetRefPtr()))) {
|
||||
if (!(data.WriteInterfaceToken(mImms->GetDescriptor())
|
||||
&& data.WriteRemoteObject(client->AsObject().GetRefPtr()))) {
|
||||
return;
|
||||
}
|
||||
mImms->releaseInput(data);
|
||||
@@ -223,12 +228,12 @@ using namespace MessageID;
|
||||
void InputMethodController::StopInput(sptr<InputClientStub> &client)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodController::StopInput");
|
||||
if(mImms == nullptr){
|
||||
if (mImms == nullptr) {
|
||||
return;
|
||||
}
|
||||
MessageParcel data;
|
||||
if(!(data.WriteInterfaceToken(mImms->GetDescriptor())
|
||||
&&data.WriteRemoteObject(client->AsObject().GetRefPtr()))) {
|
||||
if (!(data.WriteInterfaceToken(mImms->GetDescriptor())
|
||||
&& data.WriteRemoteObject(client->AsObject().GetRefPtr()))) {
|
||||
return;
|
||||
}
|
||||
mImms->stopInput(data);
|
||||
|
||||
Reference in New Issue
Block a user