mirror of
https://github.com/openharmony/miscservices_inputmethod.git
synced 2026-07-22 00:15:21 -04:00
@@ -28,25 +28,21 @@ using namespace ErrorCode;
|
||||
IMSA_HILOGI("InputClientProxy::onInputReady");
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor()))
|
||||
{
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
return ERROR_EX_PARCELABLE;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(retValue))
|
||||
{
|
||||
if (!data.WriteInt32(retValue)) {
|
||||
return ERROR_EX_PARCELABLE;
|
||||
}
|
||||
if (agent == nullptr)
|
||||
{
|
||||
if (agent == nullptr) {
|
||||
data.WriteInt32(0);
|
||||
} else {
|
||||
data.WriteInt32(1);
|
||||
data.WriteRemoteObject(agent->AsObject().GetRefPtr());
|
||||
}
|
||||
|
||||
if (channel == nullptr)
|
||||
{
|
||||
if (channel == nullptr) {
|
||||
data.WriteInt32(0);
|
||||
} else {
|
||||
data.WriteInt32(1);
|
||||
@@ -54,8 +50,7 @@ using namespace ErrorCode;
|
||||
}
|
||||
|
||||
auto ret = Remote()->SendRequest(ON_INPUT_READY, data, reply, option);
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputClientProxy::onInputReady SendRequest failed");
|
||||
return ERROR_STATUS_FAILED_TRANSACTION;
|
||||
}
|
||||
|
||||
@@ -36,18 +36,15 @@ namespace MiscServices {
|
||||
}
|
||||
switch (code) {
|
||||
case ON_INPUT_READY: {
|
||||
if (msgHandler == nullptr)
|
||||
{
|
||||
if (msgHandler == nullptr) {
|
||||
break;
|
||||
}
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(data.ReadInt32());
|
||||
if (data.ReadInt32() > 0)
|
||||
{
|
||||
if (data.ReadInt32() > 0) {
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
}
|
||||
if (data.ReadInt32() > 0)
|
||||
{
|
||||
if (data.ReadInt32() > 0) {
|
||||
parcel->WriteParcelable(data.ReadParcelable<InputChannel>());
|
||||
}
|
||||
|
||||
@@ -56,8 +53,7 @@ namespace MiscServices {
|
||||
break;
|
||||
}
|
||||
case ON_INPUT_RELEASED: {
|
||||
if (msgHandler == nullptr)
|
||||
{
|
||||
if (msgHandler == nullptr) {
|
||||
break;
|
||||
}
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
@@ -67,8 +63,7 @@ namespace MiscServices {
|
||||
break;
|
||||
}
|
||||
case SET_DISPLAY_MODE: {
|
||||
if (msgHandler == nullptr)
|
||||
{
|
||||
if (msgHandler == nullptr) {
|
||||
break;
|
||||
}
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
|
||||
@@ -33,8 +33,7 @@ namespace MiscServices {
|
||||
data.WriteString16(text);
|
||||
|
||||
auto ret = Remote()->SendRequest(INSERT_TEXT, data, reply, option);
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
return false;
|
||||
}
|
||||
auto result = reply.ReadBool();
|
||||
@@ -50,8 +49,7 @@ namespace MiscServices {
|
||||
data.WriteInt32(length);
|
||||
|
||||
auto ret = Remote()->SendRequest(DELETE_BACKWARD, data, reply, option);
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
return false;
|
||||
}
|
||||
auto result = reply.ReadBool();
|
||||
@@ -66,8 +64,7 @@ namespace MiscServices {
|
||||
data.WriteInterfaceToken(GetDescriptor());
|
||||
|
||||
auto ret = Remote()->SendRequest(CLOSE, data, reply, option);
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ namespace MiscServices {
|
||||
|
||||
InputDataChannelStub::~InputDataChannelStub()
|
||||
{
|
||||
if (msgHandler != nullptr)
|
||||
{
|
||||
if (msgHandler != nullptr) {
|
||||
delete msgHandler;
|
||||
msgHandler = nullptr;
|
||||
}
|
||||
@@ -35,8 +34,7 @@ namespace MiscServices {
|
||||
{
|
||||
IMSA_HILOGI("InputDataChannelStub::OnRemoteRequest code = %{public}d", code);
|
||||
auto descriptorToken = data.ReadInterfaceToken();
|
||||
if (descriptorToken != GetDescriptor())
|
||||
{
|
||||
if (descriptorToken != GetDescriptor()) {
|
||||
return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
|
||||
}
|
||||
switch (code) {
|
||||
@@ -63,8 +61,7 @@ namespace MiscServices {
|
||||
bool InputDataChannelStub::InsertText(const std::u16string& text)
|
||||
{
|
||||
IMSA_HILOGI("InputDataChannelStub::InsertText");
|
||||
if (msgHandler != nullptr)
|
||||
{
|
||||
if (msgHandler != nullptr) {
|
||||
MessageParcel *parcel = new MessageParcel;
|
||||
parcel->WriteString16(text);
|
||||
Message *msg = new Message(MessageID::MSG_ID_INSERT_CHAR, parcel);
|
||||
@@ -78,8 +75,7 @@ namespace MiscServices {
|
||||
bool InputDataChannelStub::DeleteBackward(int32_t length)
|
||||
{
|
||||
IMSA_HILOGI("InputDataChannelStub::DeleteBackward");
|
||||
if (msgHandler != nullptr)
|
||||
{
|
||||
if (msgHandler != nullptr) {
|
||||
MessageParcel *parcel = new MessageParcel;
|
||||
parcel->WriteInt32(length);
|
||||
Message *msg = new Message(MessageID::MSG_ID_DELETE_BACKWARD, parcel);
|
||||
@@ -91,7 +87,6 @@ namespace MiscServices {
|
||||
|
||||
void InputDataChannelStub::Close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InputDataChannelStub::SetHandler(MessageHandler *handler)
|
||||
|
||||
@@ -32,8 +32,7 @@ using namespace MessageID;
|
||||
|
||||
InputMethodController::~InputMethodController()
|
||||
{
|
||||
if (msgHandler != nullptr)
|
||||
{
|
||||
if (msgHandler != nullptr) {
|
||||
delete msgHandler;
|
||||
msgHandler = nullptr;
|
||||
}
|
||||
@@ -42,11 +41,9 @@ using namespace MessageID;
|
||||
sptr<InputMethodController> InputMethodController::GetInstance()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodController::GetInstance");
|
||||
if (instance_ == nullptr)
|
||||
{
|
||||
if (instance_ == nullptr) {
|
||||
std::lock_guard<std::mutex> autoLock(instanceLock_);
|
||||
if (instance_ == nullptr)
|
||||
{
|
||||
if (instance_ == nullptr) {
|
||||
IMSA_HILOGI("InputMethodController::GetInstance instance_ is nullptr");
|
||||
instance_ = new InputMethodController();
|
||||
}
|
||||
@@ -78,21 +75,18 @@ using namespace MessageID;
|
||||
IMSA_HILOGI("InputMethodController::GetImsaProxy");
|
||||
sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityManager == nullptr)
|
||||
{
|
||||
if (systemAbilityManager == nullptr) {
|
||||
IMSA_HILOGI("InputMethodController::GetImsaProxy systemAbilityManager is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto systemAbility = systemAbilityManager->GetSystemAbility(INPUT_METHOD_SYSTEM_ABILITY_ID, "");
|
||||
if (systemAbility == nullptr)
|
||||
{
|
||||
if (systemAbility == nullptr) {
|
||||
IMSA_HILOGI("InputMethodController::GetImsaProxy systemAbility is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (deathRecipient_ == nullptr)
|
||||
{
|
||||
if (deathRecipient_ == nullptr) {
|
||||
deathRecipient_ = new ImsaDeathRecipient();
|
||||
}
|
||||
systemAbility->AddDeathRecipient(deathRecipient_);
|
||||
@@ -109,8 +103,7 @@ using namespace MessageID;
|
||||
case MSG_ID_INSERT_CHAR: {
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
std::u16string text = data->ReadString16();
|
||||
if (textListener != nullptr)
|
||||
{
|
||||
if (textListener != nullptr) {
|
||||
textListener->InsertText(text);
|
||||
}
|
||||
break;
|
||||
@@ -118,8 +111,7 @@ using namespace MessageID;
|
||||
case MSG_ID_DELETE_BACKWARD: {
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
int32_t length = data->ReadInt32();
|
||||
if (textListener != nullptr)
|
||||
{
|
||||
if (textListener != nullptr) {
|
||||
textListener->DeleteBackward(length);
|
||||
}
|
||||
break;
|
||||
@@ -133,10 +125,8 @@ using namespace MessageID;
|
||||
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;
|
||||
@@ -144,8 +134,7 @@ using namespace MessageID;
|
||||
}
|
||||
sptr<IRemoteObject> object = data->ReadRemoteObject();
|
||||
mAgent = new InputMethodAgentProxy(object);
|
||||
if (textListener != nullptr)
|
||||
{
|
||||
if (textListener != nullptr) {
|
||||
textListener->SetKeyboardStatus(true);
|
||||
}
|
||||
break;
|
||||
@@ -193,8 +182,7 @@ using namespace MessageID;
|
||||
sptr<InputDataChannelStub> &channel, InputAttribute &attribute)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodController::PrepareInput");
|
||||
if (mImms == nullptr)
|
||||
{
|
||||
if (mImms == nullptr) {
|
||||
return;
|
||||
}
|
||||
MessageParcel data;
|
||||
@@ -202,8 +190,7 @@ using namespace MessageID;
|
||||
&& data.WriteInt32(displayId)
|
||||
&& data.WriteRemoteObject(client->AsObject())
|
||||
&& data.WriteRemoteObject(channel->AsObject())
|
||||
&& data.WriteParcelable(&attribute)))
|
||||
{
|
||||
&& data.WriteParcelable(&attribute))) {
|
||||
return;
|
||||
}
|
||||
mImms->prepareInput(data);
|
||||
@@ -212,14 +199,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())))
|
||||
{
|
||||
&& data.WriteRemoteObject(client->AsObject()))) {
|
||||
return;
|
||||
}
|
||||
mImms->startInput(data);
|
||||
@@ -228,14 +213,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())))
|
||||
{
|
||||
&& data.WriteRemoteObject(client->AsObject().GetRefPtr()))) {
|
||||
return;
|
||||
}
|
||||
mImms->releaseInput(data);
|
||||
@@ -244,14 +227,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())))
|
||||
{
|
||||
&& data.WriteRemoteObject(client->AsObject().GetRefPtr()))) {
|
||||
return;
|
||||
}
|
||||
mImms->stopInput(data);
|
||||
|
||||
@@ -29,15 +29,13 @@ namespace MiscServices {
|
||||
MessageOption option;
|
||||
|
||||
auto ret = Remote()->SendRequest(PREPARE_INPUT, data, reply, option);
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::prepareInput SendRequest failed");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = reply.ReadInt32();
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::prepareInput reply failed");
|
||||
return;
|
||||
}
|
||||
@@ -49,15 +47,13 @@ namespace MiscServices {
|
||||
MessageOption option;
|
||||
|
||||
auto ret = Remote()->SendRequest(RELEASE_INPUT, data, reply, option);
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::releaseInput SendRequest failed");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = reply.ReadInt32();
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::releaseInput reply failed");
|
||||
return;
|
||||
}
|
||||
@@ -70,15 +66,13 @@ namespace MiscServices {
|
||||
MessageOption option;
|
||||
|
||||
auto ret = Remote()->SendRequest(START_INPUT, data, reply, option);
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::startInput SendRequest failed");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = reply.ReadInt32();
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::startInput reply failed");
|
||||
return;
|
||||
}
|
||||
@@ -91,15 +85,13 @@ namespace MiscServices {
|
||||
MessageOption option;
|
||||
|
||||
auto ret = Remote()->SendRequest(STOP_INPUT, data, reply, option);
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::stopInput SendRequest failed");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = reply.ReadInt32();
|
||||
if (ret != NO_ERROR)
|
||||
{
|
||||
if (ret != NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::stopInput reply failed");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user