From 54fa4803abd61395fb5d98c77c752a9d3e7c75dc Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Mon, 27 Sep 2021 18:04:00 +0800 Subject: [PATCH] fix warning Signed-off-by: zhouyongfei --- .../inputmethod_ability/src/event_target.cpp | 51 ++++++----------- .../src/input_method_ability.cpp | 45 +++++---------- .../src/input_method_agent_proxy.cpp | 3 +- .../src/input_method_agent_stub.cpp | 9 +-- .../src/input_method_core_proxy.cpp | 57 +++++++------------ .../src/input_method_core_stub.cpp | 42 +++++--------- .../src/input_client_proxy.cpp | 15 ++--- .../src/input_client_stub.cpp | 15 ++--- .../src/input_data_channel_proxy.cpp | 9 +-- .../src/input_data_channel_stub.cpp | 13 ++--- .../src/input_method_controller.cpp | 57 +++++++------------ .../src/input_method_system_ability_proxy.cpp | 24 +++----- 12 files changed, 113 insertions(+), 227 deletions(-) diff --git a/frameworks/inputmethod_ability/src/event_target.cpp b/frameworks/inputmethod_ability/src/event_target.cpp index cb303d0..8269d9c 100644 --- a/frameworks/inputmethod_ability/src/event_target.cpp +++ b/frameworks/inputmethod_ability/src/event_target.cpp @@ -41,14 +41,11 @@ namespace MiscServices { EventTarget::~EventTarget() { EventListener *temp = nullptr; - for (EventListener *i = first_; i != nullptr; i = temp) - { + for (EventListener *i = first_; i != nullptr; i = temp) { temp = i->next; - if (i == first_) - { + if (i == first_) { first_ = first_->next; - } else if (i == last_) - { + } else if (i == last_) { last_ = last_->back; } else { i->next->back = i->back; @@ -66,15 +63,13 @@ namespace MiscServices { IMSA_HILOGI("EventTarget::On"); auto tmp = new EventListener(); - if (strncpy_s(tmp->type, LISTENER_TYPTE_MAX_LENGTH, type, strlen(type)) == -1) - { + if (strncpy_s(tmp->type, LISTENER_TYPTE_MAX_LENGTH, type, strlen(type)) == -1) { delete tmp; tmp = nullptr; return; } - if (first_ == nullptr) - { + if (first_ == nullptr) { first_ = last_ = tmp; } else { last_->next = tmp; @@ -90,15 +85,13 @@ namespace MiscServices { IMSA_HILOGI("EventTarget::Once"); auto tmp = new EventListener(); - if (strncpy_s(tmp->type, LISTENER_TYPTE_MAX_LENGTH, type, strlen(type)) == -1) - { + if (strncpy_s(tmp->type, LISTENER_TYPTE_MAX_LENGTH, type, strlen(type)) == -1) { delete tmp; tmp = nullptr; return; } - if (first_ == nullptr) - { + if (first_ == nullptr) { first_ = last_ = tmp; } else { last_->next = tmp; @@ -114,24 +107,20 @@ namespace MiscServices { IMSA_HILOGI("EventTarget::Off"); napi_handle_scope scope = nullptr; napi_open_handle_scope(env_, &scope); - if (scope == nullptr) - { + if (scope == nullptr) { HILOG_ERROR("scope is nullptr"); return; } EventListener *temp = nullptr; - for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = temp) - { + for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = temp) { temp = eventListener->next; bool isEquals = false; napi_value handlerTemp = nullptr; napi_get_reference_value(env_, eventListener->handlerRef, &handlerTemp); napi_strict_equals(env_, handlerTemp, handler, &isEquals); - if (strcmp(eventListener->type, type) == 0 && isEquals) - { - if (eventListener == first_) - { + if (strcmp(eventListener->type, type) == 0 && isEquals) { + if (eventListener == first_) { first_ = first_->next; } else if (eventListener == last_) { last_ = last_->back; @@ -152,13 +141,10 @@ namespace MiscServices { { IMSA_HILOGI("EventTarget::Off"); EventListener *temp = nullptr; - for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = temp) - { + for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = temp) { temp = eventListener->next; - if (strcmp(eventListener->type, type) == 0) - { - if (eventListener == first_) - { + if (strcmp(eventListener->type, type) == 0) { + if (eventListener == first_) { first_ = first_->next; } else if (eventListener == last_) { last_ = last_->back; @@ -181,17 +167,14 @@ namespace MiscServices { napi_value thisVar = nullptr; napi_get_reference_value(env_, thisVarRef_, &thisVar); - for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = eventListener->next) - { - if (strcmp(eventListener->type, type) == 0) - { + for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = eventListener->next) { + if (strcmp(eventListener->type, type) == 0) { napi_value jsEvent = event ? event->ToJsObject() : nullptr; napi_value handler = nullptr; napi_value result = nullptr; napi_get_reference_value(env_, eventListener->handlerRef, &handler); napi_call_function(env_, thisVar, handler, jsEvent ? 1 : 0, jsEvent ? &jsEvent : nullptr, &result); - if (eventListener->isOnce) - { + if (eventListener->isOnce) { Off(type, handler); } } diff --git a/frameworks/inputmethod_ability/src/input_method_ability.cpp b/frameworks/inputmethod_ability/src/input_method_ability.cpp index a4e6b0c..b782ff6 100644 --- a/frameworks/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/inputmethod_ability/src/input_method_ability.cpp @@ -37,8 +37,7 @@ namespace MiscServices { InputMethodAbility::~InputMethodAbility() { - if (msgHandler != nullptr) - { + if (msgHandler != nullptr) { delete msgHandler; msgHandler = nullptr; } @@ -47,11 +46,9 @@ namespace MiscServices { sptr InputMethodAbility::GetInstance() { IMSA_HILOGI("InputMethodAbility::GetInstance"); - if (instance_ == nullptr) - { + if (instance_ == nullptr) { std::lock_guard autoLock(instanceLock_); - if (instance_ == nullptr) - { + if (instance_ == nullptr) { IMSA_HILOGI("InputMethodAbility::GetInstance need new IMA"); instance_ = new InputMethodAbility(); } @@ -64,15 +61,13 @@ namespace MiscServices { IMSA_HILOGI("InputMethodAbility::GetImsaProxy"); sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (systemAbilityManager == nullptr) - { + if (systemAbilityManager == nullptr) { IMSA_HILOGI("InputMethodAbility::GetImsaProxy systemAbilityManager is nullptr"); return nullptr; } auto systemAbility = systemAbilityManager->GetSystemAbility(INPUT_METHOD_SYSTEM_ABILITY_ID, ""); - if (systemAbility == nullptr) - { + if (systemAbility == nullptr) { IMSA_HILOGI("InputMethodAbility::GetImsaProxy systemAbility is nullptr"); return nullptr; } @@ -88,8 +83,7 @@ namespace MiscServices { sptr stub = new InputMethodCoreStub(0); stub->SetMessageHandler(msgHandler); sptr stub2 = stub; - if (mImms != nullptr) - { + if (mImms != nullptr) { mImms->setInputMethodCore(stub2); } IMSA_HILOGI("InputMethodAbility::OnConnect() mImms is nullptr"); @@ -115,8 +109,7 @@ namespace MiscServices { void InputMethodAbility::WorkThread() { - while(1) - { + while(1) { Message *msg = msgHandler->GetMessage(); switch (msg->msgId_) { case MSG_ID_INITIALIZE_INPUT: { @@ -164,15 +157,13 @@ namespace MiscServices { MessageParcel *data = msg->msgContent_; displyId = data->ReadInt32(); sptr channelObject = data->ReadRemoteObject(); - if (channelObject == nullptr) - { + if (channelObject == nullptr) { IMSA_HILOGI("InputMethodAbility::OnInitialInput channelObject is nullptr"); return; } sptr channelProxy = new InputControlChannelProxy(channelObject); inputControlChannel = channelProxy; - if (inputControlChannel == nullptr) - { + if (inputControlChannel == nullptr) { IMSA_HILOGI("InputMethodAbility::OnInitialInput inputControlChannel is nullptr"); return; } @@ -185,20 +176,17 @@ namespace MiscServices { MessageParcel *data = msg->msgContent_; sptr channalProxy = new InputDataChannelProxy(data->ReadRemoteObject()); inputDataChannel = channalProxy; - if (inputDataChannel == nullptr) - { + if (inputDataChannel == nullptr) { IMSA_HILOGI("InputMethodAbility::OnStartInput inputDataChannel is nullptr"); } editorAttribute = data->ReadParcelable(); - if (editorAttribute == nullptr) - { + if (editorAttribute == nullptr) { IMSA_HILOGI("InputMethodAbility::OnStartInput editorAttribute is nullptr"); } mSupportPhysicalKbd = data->ReadBool(); CreateInputMethodAgent(mSupportPhysicalKbd); - if (inputControlChannel != nullptr) - { + if (inputControlChannel != nullptr) { IMSA_HILOGI("InputMethodAbility::OnStartInput inputControlChannel is not nullptr"); inputControlChannel->onAgentCreated(inputMethodAgent, nullptr); } @@ -219,8 +207,7 @@ namespace MiscServices { void InputMethodAbility::OnStopInput(Message *msg) { IMSA_HILOGI("InputMethodAbility::OnStopInput"); - if (writeInputChannel != nullptr) - { + if (writeInputChannel != nullptr) { delete writeInputChannel; writeInputChannel = nullptr; } @@ -264,8 +251,7 @@ namespace MiscServices { bool InputMethodAbility::InsertText(const std::string text) { IMSA_HILOGI("InputMethodAbility::InsertText"); - if (inputDataChannel == nullptr) - { + if (inputDataChannel == nullptr) { IMSA_HILOGI("InputMethodAbility::InsertText inputDataChanel is nullptr"); return false; } @@ -276,8 +262,7 @@ namespace MiscServices { void InputMethodAbility::DeleteBackward(int32_t length) { IMSA_HILOGI("InputMethodAbility::DeleteBackward"); - if (inputDataChannel == nullptr) - { + if (inputDataChannel == nullptr) { IMSA_HILOGI("InputMethodAbility::DeleteBackward inputDataChanel is nullptr"); return; } diff --git a/frameworks/inputmethod_ability/src/input_method_agent_proxy.cpp b/frameworks/inputmethod_ability/src/input_method_agent_proxy.cpp index 92b1383..1e06f7e 100644 --- a/frameworks/inputmethod_ability/src/input_method_agent_proxy.cpp +++ b/frameworks/inputmethod_ability/src/input_method_agent_proxy.cpp @@ -28,8 +28,7 @@ namespace MiscServices { IMSA_HILOGI("InputMethodAgentProxy::DispatchKey key = %{public}d, status = %{public}d", key, status); MessageParcel data, reply; MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) - { + if (!data.WriteInterfaceToken(GetDescriptor())) { IMSA_HILOGI("InputMethodAgentProxy::DispatchKey descriptor is not match"); return ERROR_EX_PARCELABLE; } diff --git a/frameworks/inputmethod_ability/src/input_method_agent_stub.cpp b/frameworks/inputmethod_ability/src/input_method_agent_stub.cpp index 52eb5a7..f562d97 100644 --- a/frameworks/inputmethod_ability/src/input_method_agent_stub.cpp +++ b/frameworks/inputmethod_ability/src/input_method_agent_stub.cpp @@ -35,8 +35,7 @@ namespace MiscServices { { IMSA_HILOGI("InputMethodAgentStub::OnRemoteRequest code = %{public}d", code); auto descriptorToken = data.ReadInterfaceToken(); - if (descriptorToken != GetDescriptor()) - { + if (descriptorToken != GetDescriptor()) { return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION; } @@ -45,8 +44,7 @@ namespace MiscServices { int32_t key = data.ReadInt32(); int32_t status = data.ReadInt32(); int32_t result = DispatchKey(key, status); - if (result == ErrorCode::NO_ERROR) - { + if (result == ErrorCode::NO_ERROR) { reply.WriteNoException(); } else { reply.WriteInt32(result); @@ -63,8 +61,7 @@ namespace MiscServices { int32_t InputMethodAgentStub::DispatchKey(int32_t key, int32_t status) { IMSA_HILOGI("InputMethodAgentStub::DispatchKey key = %{public}d, status = %{public}d", key, status); - if (msgHandler_ == nullptr) - { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } MessageParcel *data = new MessageParcel(); diff --git a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp index 3ee9ae3..58dc01a 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp @@ -31,13 +31,11 @@ namespace MiscServices { sptr &inputControlChannel) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput"); - if (startInputToken == nullptr) - { + if (startInputToken == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput startInputToken is nullptr"); } - if (inputControlChannel == nullptr) - { + if (inputControlChannel == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput inputControlChannel is nullptr"); } IMSA_HILOGI("InputMethodCoreProxy::initializeInput displayId = %{public}d", displayId); @@ -45,13 +43,11 @@ namespace MiscServices { data.WriteInterfaceToken(GetDescriptor()); data.WriteInt32(displayId); sptr channelObject = inputControlChannel->AsObject(); - if (channelObject == nullptr) - { + if (channelObject == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput channelObject is nullptr"); } bool wor = data.WriteRemoteObject(channelObject); - if (wor) - { + if (wor) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput Success to write inputControlChannel"); } else { IMSA_HILOGI("InputMethodCoreProxy::initializeInput Failed to write inputControlChannel"); @@ -60,8 +56,7 @@ namespace MiscServices { MessageOption::TF_SYNC }; int32_t status = Remote()->SendRequest(INITIALIZE_INPUT, data, reply, option); - if (status != ErrorCode::NO_ERROR) - { + if (status != ErrorCode::NO_ERROR) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput status = %{public}d", status); return status; } @@ -73,8 +68,7 @@ namespace MiscServices { const InputAttribute& editorAttribute, bool supportPhysicalKbd) { IMSA_HILOGI("InputMethodCoreProxy::startInput"); - if (inputDataChannel == nullptr) - { + if (inputDataChannel == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::startInput inputDataChannel is nullptr"); } @@ -82,8 +76,7 @@ namespace MiscServices { if (!(data.WriteInterfaceToken(GetDescriptor()) && data.WriteRemoteObject(inputDataChannel->AsObject()) && data.WriteParcelable(&editorAttribute) - && data.WriteBool(supportPhysicalKbd))) - { + && data.WriteBool(supportPhysicalKbd))) { IMSA_HILOGI("InputMethodCoreProxy::startInput write error"); return false; } @@ -93,8 +86,7 @@ namespace MiscServices { }; int32_t status = Remote()->SendRequest(START_INPUT, data, reply, option); - if (status != ErrorCode::NO_ERROR) - { + if (status != ErrorCode::NO_ERROR) { IMSA_HILOGI("InputMethodCoreProxy::startInput status = %{public}d", status); return false; } @@ -112,14 +104,12 @@ namespace MiscServices { MessageOption::TF_SYNC }; int32_t status = Remote()->SendRequest(STOP_INPUT, data, reply, option); - if (status != ErrorCode::NO_ERROR) - { + if (status != ErrorCode::NO_ERROR) { IMSA_HILOGI("InputMethodCoreProxy::stopInput status = %{public}d", status); return status; } int code = reply.ReadException(); - if (code != ErrorCode::NO_ERROR) - { + if (code != ErrorCode::NO_ERROR) { IMSA_HILOGI("InputMethodCoreProxy::stopInput code = %{public}d", code); return code; } @@ -130,15 +120,13 @@ namespace MiscServices { { IMSA_HILOGI("InputMethodCoreProxy::showKeyboard"); auto remote = Remote(); - if (remote == nullptr) - { + if (remote == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::showKeyboard remote is nullptr"); return false; } MessageParcel data; - if (!(data.WriteInterfaceToken(GetDescriptor()) && data.WriteInt32(flags))) - { + if (!(data.WriteInterfaceToken(GetDescriptor()) && data.WriteInt32(flags))) { return false; } MessageParcel reply; @@ -147,8 +135,7 @@ namespace MiscServices { }; int32_t res = remote->SendRequest(SHOW_KEYBOARD, data, reply, option); - if (res != ErrorCode::NO_ERROR) - { + if (res != ErrorCode::NO_ERROR) { return false; } return true; @@ -158,14 +145,12 @@ namespace MiscServices { { IMSA_HILOGI("InputMethodCoreProxy::hideKeyboard"); auto remote = Remote(); - if (remote == nullptr) - { + if (remote == nullptr) { return false; } MessageParcel data; - if (!(data.WriteInterfaceToken(GetDescriptor()) && data.WriteInt32(flags))) - { + if (!(data.WriteInterfaceToken(GetDescriptor()) && data.WriteInt32(flags))) { return false; } MessageParcel reply; @@ -174,8 +159,7 @@ namespace MiscServices { }; int32_t res = remote->SendRequest(HIDE_KEYBOARD, data, reply, option); - if (res != ErrorCode::NO_ERROR) - { + if (res != ErrorCode::NO_ERROR) { return false; } return true; @@ -191,8 +175,7 @@ namespace MiscServices { MessageOption::TF_SYNC }; int32_t status = Remote()->SendRequest(SET_KEYBOARD_TYPE, data, reply, option); - if (status != ErrorCode::NO_ERROR) - { + if (status != ErrorCode::NO_ERROR) { return status; } int32_t code = reply.ReadException(); @@ -208,13 +191,11 @@ namespace MiscServices { MessageOption::TF_SYNC }; int32_t status = Remote()->SendRequest(GET_KEYBOARD_WINDOW_HEIGHT, data, reply, option); - if (status != ErrorCode::NO_ERROR) - { + if (status != ErrorCode::NO_ERROR) { return status; } int32_t code = reply.ReadException(); - if (code != 0) - { + if (code != 0) { return code; } retHeight = reply.ReadInt32(); diff --git a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp index f8afa16..d1d0862 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp @@ -44,8 +44,7 @@ namespace MiscServices { { IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest"); auto descriptorToken = data.ReadInterfaceToken(); - if (descriptorToken != GetDescriptor()) - { + if (descriptorToken != GetDescriptor()) { IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest descriptorToken is invalid"); return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION; } @@ -55,13 +54,11 @@ namespace MiscServices { int32_t displayId = data.ReadInt32(); IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest displayId = %{public}d", displayId); sptr channelObject = data.ReadRemoteObject(); - if (channelObject == nullptr) - { + if (channelObject == nullptr) { IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest channelObject is nullptr"); } sptr inputControlChannel = new InputControlChannelProxy(channelObject); - if (inputControlChannel == nullptr) - { + if (inputControlChannel == nullptr) { IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest inputControlChannel is nullptr"); } @@ -74,8 +71,7 @@ namespace MiscServices { InputAttribute *editorAttribute = data.ReadParcelable(); bool supportPhysicalKbd = data.ReadBool(); - if (inputDataChannel == nullptr) - { + if (inputDataChannel == nullptr) { IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest START_INPUT inputDataChannel is nulltpr"); } startInput(inputDataChannel, *editorAttribute, supportPhysicalKbd); @@ -122,20 +118,17 @@ namespace MiscServices { sptr& inputControlChannel) { IMSA_HILOGI("InputMethodCoreStub::initializeInput"); - if (msgHandler_ == nullptr) - { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } - if (startInputToken == nullptr) - { + if (startInputToken == nullptr) { IMSA_HILOGI("InputMethodCoreStub::initializeInput startInputToken is nullptr"); } MessageParcel *data = new MessageParcel(); data->WriteInt32(displayId); - if (inputControlChannel != nullptr) - { + if (inputControlChannel != nullptr) { IMSA_HILOGI("InputMethodCoreStub::initializeInput. inputControlChannel is not nullptr"); data->WriteRemoteObject(inputControlChannel->AsObject()); } @@ -148,13 +141,11 @@ namespace MiscServices { const InputAttribute& editorAttribute, bool supportPhysicalKbd) { IMSA_HILOGI("InputMethodCoreStub::startInput"); - if (msgHandler_ == nullptr) - { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } MessageParcel *data = new MessageParcel(); - if (inputDataChannel != nullptr) - { + if (inputDataChannel != nullptr) { IMSA_HILOGI("InputMethodCoreStub::startInput inputDataChannel is not nullptr"); data->WriteRemoteObject(inputDataChannel->AsObject()); } @@ -168,8 +159,7 @@ namespace MiscServices { int32_t InputMethodCoreStub::stopInput() { IMSA_HILOGI("InputMethodCoreStub::stopInput"); - if (msgHandler_ == nullptr) - { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } MessageParcel *data = new MessageParcel(); @@ -181,8 +171,7 @@ namespace MiscServices { bool InputMethodCoreStub::showKeyboard(int32_t flags) { IMSA_HILOGI("InputMethodCoreStub::showKeyboard"); - if (msgHandler_ == nullptr) - { + if (msgHandler_ == nullptr) { return false; } MessageParcel *data = new MessageParcel(); @@ -197,8 +186,7 @@ namespace MiscServices { bool InputMethodCoreStub::hideKeyboard(int32_t flags) { IMSA_HILOGI("InputMethodCoreStub::hideKeyboard"); - if (msgHandler_ == nullptr) - { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } MessageParcel *data = new MessageParcel(); @@ -213,8 +201,7 @@ namespace MiscServices { int32_t InputMethodCoreStub::setKeyboardType(const KeyboardType& type) { IMSA_HILOGI("InputMethodCoreStub::setKeyboardType"); - if (msgHandler_ == nullptr) - { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } MessageParcel *data = new MessageParcel(); @@ -228,8 +215,7 @@ namespace MiscServices { int32_t InputMethodCoreStub::getKeyboardWindowHeight(int32_t retHeight) { IMSA_HILOGI("InputMethodCoreStub::getKeyboardWindowHeight"); - if (msgHandler_ == nullptr) - { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } MessageParcel *data = new MessageParcel(); diff --git a/frameworks/inputmethod_controller/src/input_client_proxy.cpp b/frameworks/inputmethod_controller/src/input_client_proxy.cpp index 1ce8261..c4185f6 100644 --- a/frameworks/inputmethod_controller/src/input_client_proxy.cpp +++ b/frameworks/inputmethod_controller/src/input_client_proxy.cpp @@ -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; } diff --git a/frameworks/inputmethod_controller/src/input_client_stub.cpp b/frameworks/inputmethod_controller/src/input_client_stub.cpp index 5cc9c50..b2764d5 100644 --- a/frameworks/inputmethod_controller/src/input_client_stub.cpp +++ b/frameworks/inputmethod_controller/src/input_client_stub.cpp @@ -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()); } @@ -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(); diff --git a/frameworks/inputmethod_controller/src/input_data_channel_proxy.cpp b/frameworks/inputmethod_controller/src/input_data_channel_proxy.cpp index edfd951..9026e96 100644 --- a/frameworks/inputmethod_controller/src/input_data_channel_proxy.cpp +++ b/frameworks/inputmethod_controller/src/input_data_channel_proxy.cpp @@ -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) { } } } diff --git a/frameworks/inputmethod_controller/src/input_data_channel_stub.cpp b/frameworks/inputmethod_controller/src/input_data_channel_stub.cpp index 512f480..9c91dad 100644 --- a/frameworks/inputmethod_controller/src/input_data_channel_stub.cpp +++ b/frameworks/inputmethod_controller/src/input_data_channel_stub.cpp @@ -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) diff --git a/frameworks/inputmethod_controller/src/input_method_controller.cpp b/frameworks/inputmethod_controller/src/input_method_controller.cpp index 640b11c..64c08a0 100644 --- a/frameworks/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/inputmethod_controller/src/input_method_controller.cpp @@ -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::GetInstance() { IMSA_HILOGI("InputMethodController::GetInstance"); - if (instance_ == nullptr) - { + if (instance_ == nullptr) { std::lock_guard 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 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 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 &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 &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 &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 &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); diff --git a/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp b/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp index 3315433..85bf021 100644 --- a/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp +++ b/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp @@ -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; }