fix warning

Signed-off-by: zhouyongfei <zhouyongfei@huawei.com>
This commit is contained in:
zhouyongfei
2021-09-23 20:57:43 +08:00
parent 4905aca179
commit a8eee40e32
75 changed files with 3307 additions and 3247 deletions
@@ -13,8 +13,8 @@
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_NAPI_TEST_NATIVE_MODULE_NETSERVER_EVENT_TARGET_H
#define FOUNDATION_ACE_NAPI_TEST_NATIVE_MODULE_NETSERVER_EVENT_TARGET_H
#ifndef INPUT_METHOD_NAPI_EVENT_TARGET_H
#define INPUT_METHOD_NAPI_EVENT_TARGET_H
#include "napi/native_api.h"
#include "global.h"
@@ -22,30 +22,29 @@
namespace OHOS {
namespace MiscServices {
struct EventListener;
struct EventListener;
class Event {
public:
virtual napi_value ToJsObject() = 0;
};
class Event {
public:
virtual napi_value ToJsObject() = 0;
};
class EventTarget : public RefBase {
public:
EventTarget(napi_env env, napi_value thisVar);
virtual ~EventTarget();
class EventTarget : public RefBase {
public:
EventTarget(napi_env env, napi_value thisVar);
virtual ~EventTarget();
virtual void On(const char* type, napi_value handler);
virtual void Once(const char* type, napi_value handler);
virtual void Off(const char* type, napi_value handler);
virtual void Off(const char* type);
virtual void Emit(const char* type, Event* event);
virtual void On(const char* type, napi_value handler);
virtual void Once(const char* type, napi_value handler);
virtual void Off(const char* type, napi_value handler);
virtual void Off(const char* type);
virtual void Emit(const char* type, Event* event);
protected:
napi_env env_;
napi_ref thisVarRef_;
EventListener* first_;
EventListener* last_;
};
protected:
napi_env env_;
napi_ref thisVarRef_;
EventListener *first_;
EventListener *last_;
};
}
}
#endif /* FOUNDATION_ACE_NAPI_TEST_NATIVE_MODULE_NETSERVER_EVENT_TARGET_H */
#endif // INPUT_METHOD_NAPI_EVENT_TARGET_H
@@ -53,7 +53,7 @@ namespace MiscServices {
virtual bool showKeyboard(int32_t flags) = 0;
virtual bool hideKeyboard(int32_t flags) = 0;
virtual int32_t setKeyboardType(const KeyboardType& type) = 0;
virtual int32_t getKeyboardWindowHeight(int32_t* retHeight) = 0;
virtual int32_t getKeyboardWindowHeight(int32_t retHeight) = 0;
};
}
}
@@ -47,12 +47,12 @@ namespace MiscServices {
private:
std::thread workThreadHandler;
MessageHandler* msgHandler;
MessageHandler *msgHandler;
bool mSupportPhysicalKbd = false;
InputAttribute* editorAttribute;
InputAttribute *editorAttribute;
int32_t displyId = 0;
sptr<IRemoteObject> startInputToken;
InputChannel* writeInputChannel;
InputChannel *writeInputChannel;
// communicating with IMSA
sptr<IInputControlChannel> inputControlChannel;
@@ -66,21 +66,20 @@ namespace MiscServices {
sptr<InputMethodSystemAbilityProxy> mImms;
sptr<InputMethodSystemAbilityProxy> GetImsaProxy();
void Initialize();
void WorkThread();
void CreateInputMethodAgent(bool supportPhysicalKbd);
// the message from IMSA
void OnInitialInput(Message* msg);
void OnStartInput(Message* msg);
void OnStopInput(Message* msg);
void OnSetKeyboardType(Message* msg);
void OnShowKeyboard(Message* msg);
void OnHideKeyboard(Message* msg);
void OnInitialInput(Message *msg);
void OnStartInput(Message *msg);
void OnStopInput(Message *msg);
void OnSetKeyboardType(Message *msg);
void OnShowKeyboard(Message *msg);
void OnHideKeyboard(Message *msg);
// the message from IMC
bool DispatchKey(Message* msg);
bool DispatchKey(Message *msg);
// control inputwindow
void InitialInputWindow();
@@ -33,9 +33,9 @@ namespace MiscServices {
MessageParcel &reply,
MessageOption &option) override;
virtual int32_t DispatchKey(int32_t key, int32_t status) override;
void SetMessageHandler(MessageHandler* msgHandler);
void SetMessageHandler(MessageHandler *msgHandler);
private:
MessageHandler* msgHandler_;
MessageHandler *msgHandler_;
};
}
}
@@ -43,7 +43,7 @@ namespace MiscServices {
virtual bool showKeyboard(int32_t flags) override;
virtual bool hideKeyboard(int32_t flags) override;
virtual int32_t setKeyboardType(const KeyboardType& type) override;
virtual int32_t getKeyboardWindowHeight(int32_t * retHeight) override;
virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override;
private:
static inline BrokerDelegator<InputMethodCoreProxy> delegator_;
@@ -52,12 +52,12 @@ namespace MiscServices {
virtual bool showKeyboard(int32_t flags) override;
virtual bool hideKeyboard(int32_t flags)override;
virtual int32_t setKeyboardType(const KeyboardType& type) override;
virtual int32_t getKeyboardWindowHeight(int32_t * retHeight) override;
void SetMessageHandler(MessageHandler* msgHandler);
virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override;
void SetMessageHandler(MessageHandler *msgHandler);
private:
int userId_;
MessageHandler* msgHandler_;
MessageHandler *msgHandler_;
};
}
}
@@ -26,10 +26,11 @@ namespace MiscServices {
char type[LISTENER_TYPTE_MAX_LENGTH] = { 0 };
bool isOnce = false;
napi_ref handlerRef = nullptr;
EventListener* back = nullptr;
EventListener* next = nullptr;
EventListener *back = nullptr;
EventListener *next = nullptr;
};
EventTarget::EventTarget(napi_env env, napi_value thisVar) {
EventTarget::EventTarget(napi_env env, napi_value thisVar)
{
IMSA_HILOGI("EventTarget::EventTarget");
env_ = env;
first_ = last_ = nullptr;
@@ -37,8 +38,9 @@ namespace MiscServices {
napi_create_reference(env, thisVar, 1, &thisVarRef_);
}
EventTarget::~EventTarget() {
EventListener* temp = nullptr;
EventTarget::~EventTarget()
{
EventListener *temp = nullptr;
for (EventListener* i = first_; i != nullptr; i = temp) {
temp = i->next;
if (i == first_) {
@@ -99,7 +101,7 @@ namespace MiscServices {
napi_create_reference(env_, handler, 1, &last_->handlerRef);
}
void EventTarget::Off(const char* type, napi_value handler)
void EventTarget::Off(const char *type, napi_value handler)
{
IMSA_HILOGI("EventTarget::Off");
napi_handle_scope scope = nullptr;
@@ -109,8 +111,8 @@ namespace MiscServices {
return;
}
EventListener* temp = nullptr;
for (EventListener* eventListener = first_; eventListener != nullptr; eventListener = temp) {
EventListener *temp = nullptr;
for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = temp) {
temp = eventListener->next;
bool isEquals = false;
napi_value handlerTemp = nullptr;
@@ -137,8 +139,8 @@ namespace MiscServices {
void EventTarget::Off(const char* type)
{
IMSA_HILOGI("EventTarget::Off");
EventListener* temp = nullptr;
for (EventListener* eventListener = first_; eventListener != nullptr; eventListener = temp) {
EventListener *temp = nullptr;
for (EventListener *eventListener = first_; eventListener != nullptr; eventListener = temp) {
temp = eventListener->next;
if (strcmp(eventListener->type, type) == 0) {
if (eventListener == first_) {
@@ -156,7 +158,7 @@ namespace MiscServices {
}
}
void EventTarget::Emit(const char* type, Event* event)
void EventTarget::Emit(const char* type, Event *event)
{
IMSA_HILOGI("EventTarget::Emit");
napi_handle_scope scope = nullptr;
@@ -164,7 +166,7 @@ namespace MiscServices {
napi_value thisVar = nullptr;
napi_get_reference_value(env_, thisVarRef_, &thisVar);
for (EventListener* eventListener = first_; eventListener != nullptr; eventListener = eventListener->next) {
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;
@@ -12,9 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "input_method_ability.h"
#include "input_method_core_proxy.h"
#include "input_method_core_stub.h"
@@ -32,18 +29,21 @@ namespace MiscServices {
sptr<InputMethodAbility> InputMethodAbility::instance_;
std::mutex InputMethodAbility::instanceLock_;
InputMethodAbility::InputMethodAbility() {
InputMethodAbility::InputMethodAbility()
{
Initialize();
OnConnect();
}
InputMethodAbility::~InputMethodAbility() {
InputMethodAbility::~InputMethodAbility()
{
if (msgHandler != nullptr) {
delete msgHandler;
}
}
sptr<InputMethodAbility> InputMethodAbility::GetInstance() {
sptr<InputMethodAbility> InputMethodAbility::GetInstance()
{
IMSA_HILOGI("InputMethodAbility::GetInstance");
if (instance_ == nullptr) {
std::lock_guard<std::mutex> autoLock(instanceLock_);
@@ -55,7 +55,8 @@ namespace MiscServices {
return instance_;
}
sptr<InputMethodSystemAbilityProxy> InputMethodAbility::GetImsaProxy() {
sptr<InputMethodSystemAbilityProxy> InputMethodAbility::GetImsaProxy()
{
IMSA_HILOGI("InputMethodAbility::GetImsaProxy");
sptr<ISystemAbilityManager> systemAbilityManager =
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
@@ -74,7 +75,8 @@ namespace MiscServices {
return iface;
}
sptr<IInputMethodCore> InputMethodAbility::OnConnect() {
sptr<IInputMethodCore> InputMethodAbility::OnConnect()
{
IMSA_HILOGI("InputMethodAbility::OnConnect");
mImms = GetImsaProxy();
sptr<InputMethodCoreStub> stub = new InputMethodCoreStub(0);
@@ -87,7 +89,8 @@ namespace MiscServices {
return nullptr;
}
void InputMethodAbility::Initialize() {
void InputMethodAbility::Initialize()
{
IMSA_HILOGI("InputMethodAbility::Initialize");
InitialInputWindow();
msgHandler = new MessageHandler();
@@ -99,9 +102,10 @@ namespace MiscServices {
eventTarget_ = eventTarget;
}
void InputMethodAbility::WorkThread() {
void InputMethodAbility::WorkThread()
{
while(1){
Message* msg = msgHandler->GetMessage();
Message *msg = msgHandler->GetMessage();
switch(msg->msgId_) {
case MSG_ID_INITIALIZE_INPUT: {
OnInitialInput(msg);
@@ -141,9 +145,10 @@ namespace MiscServices {
}
}
void InputMethodAbility::OnInitialInput(Message* msg) {
void InputMethodAbility::OnInitialInput(Message *msg)
{
IMSA_HILOGI("InputMethodAbility::OnInitialInput");
MessageParcel* data = msg->msgContent_;
MessageParcel *data = msg->msgContent_;
displyId = data->ReadInt32();
sptr<IRemoteObject> channelObject = data->ReadRemoteObject();
if (channelObject == nullptr) {
@@ -159,9 +164,10 @@ namespace MiscServices {
InitialInputWindow();
}
void InputMethodAbility::OnStartInput(Message* msg) {
void InputMethodAbility::OnStartInput(Message *msg)
{
IMSA_HILOGI("InputMethodAbility::OnStartInput");
MessageParcel* data = msg->msgContent_;
MessageParcel *data = msg->msgContent_;
sptr<InputDataChannelProxy> channalProxy = new InputDataChannelProxy(data->ReadRemoteObject());
inputDataChannel = channalProxy;
if(inputDataChannel == nullptr) {
@@ -180,54 +186,63 @@ namespace MiscServices {
}
}
void InputMethodAbility::OnShowKeyboard(Message* msg) {
void InputMethodAbility::OnShowKeyboard(Message *msg)
{
IMSA_HILOGI("InputMethodAbility::OnShowKeyboard");
ShowInputWindow();
}
void InputMethodAbility::OnHideKeyboard(Message* msg) {
void InputMethodAbility::OnHideKeyboard(Message *msg)
{
IMSA_HILOGI("InputMethodAbility::OnHideKeyboard");
DissmissInputWindow();
}
void InputMethodAbility::OnStopInput(Message* msg) {
void InputMethodAbility::OnStopInput(Message *msg)
{
IMSA_HILOGI("InputMethodAbility::OnStopInput");
if (writeInputChannel != nullptr) {
delete writeInputChannel;
}
}
bool InputMethodAbility::DispatchKey(Message* msg) {
bool InputMethodAbility::DispatchKey(Message *msg)
{
IMSA_HILOGI("InputMethodAbility::DispatchKey");
MessageParcel* data = msg->msgContent_;
MessageParcel *data = msg->msgContent_;
int32_t key = data->ReadInt32();
int32_t status = data->ReadInt32();
IMSA_HILOGI("InputMethodAbility::DispatchKey: key = %{public}d, status = %{public}d", key, status);
return true;
}
void InputMethodAbility::CreateInputMethodAgent(bool supportPhysicalKbd) {
void InputMethodAbility::CreateInputMethodAgent(bool supportPhysicalKbd)
{
IMSA_HILOGI("InputMethodAbility::CreateInputMethodAgent");
sptr<InputMethodAgentStub> inputMethodAgentStub(new InputMethodAgentStub());
inputMethodAgentStub->SetMessageHandler(msgHandler);
inputMethodAgent = sptr(new InputMethodAgentProxy(inputMethodAgentStub));
}
void InputMethodAbility::InitialInputWindow() {
void InputMethodAbility::InitialInputWindow()
{
IMSA_HILOGI("InputMethodAbility::InitialInputWindow");
}
void InputMethodAbility::ShowInputWindow() {
void InputMethodAbility::ShowInputWindow()
{
IMSA_HILOGI("InputMethodAbility::ShowInputWindow");
eventTarget_->Emit("keyboardShow",nullptr);
}
void InputMethodAbility::DissmissInputWindow() {
void InputMethodAbility::DissmissInputWindow()
{
IMSA_HILOGI("InputMethodAbility::DissmissInputWindow");
eventTarget_->Emit("keyboardHide",nullptr);
}
bool InputMethodAbility::InsertText(const std::string text) {
bool InputMethodAbility::InsertText(const std::string text)
{
IMSA_HILOGI("InputMethodAbility::InsertText");
if (inputDataChannel == nullptr){
IMSA_HILOGI("InputMethodAbility::InsertText inputDataChanel is nullptr");
@@ -237,7 +252,8 @@ namespace MiscServices {
return inputDataChannel->InsertText(Utils::to_utf16(text));
}
void InputMethodAbility::DeleteBackward(int32_t length) {
void InputMethodAbility::DeleteBackward(int32_t length)
{
IMSA_HILOGI("InputMethodAbility::DeleteBackward");
if (inputDataChannel == nullptr){
IMSA_HILOGI("InputMethodAbility::DeleteBackward inputDataChanel is nullptr");
@@ -246,7 +262,8 @@ namespace MiscServices {
inputDataChannel->DeleteBackward(length);
}
void InputMethodAbility::HideKeyboardSelf() {
void InputMethodAbility::HideKeyboardSelf()
{
IMSA_HILOGI("InputMethodAbility::HideKeyboardSelf");
inputControlChannel->hideKeyboardSelf(1);
}
@@ -18,10 +18,13 @@
namespace OHOS {
namespace MiscServices {
using namespace ErrorCode;
InputMethodAgentProxy::InputMethodAgentProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<IInputMethodAgent>(object) {
InputMethodAgentProxy::InputMethodAgentProxy(const sptr<IRemoteObject> &object)
: IRemoteProxy<IInputMethodAgent>(object)
{
}
int32_t InputMethodAgentProxy::DispatchKey(int32_t key, int32_t status) {
int32_t InputMethodAgentProxy::DispatchKey(int32_t key, int32_t status)
{
IMSA_HILOGI("InputMethodAgentProxy::DispatchKey key = %{public}d, status = %{public}d", key, status);
MessageParcel data, reply;
MessageOption option;
@@ -22,13 +22,17 @@ namespace OHOS {
namespace MiscServices {
using namespace MessageID;
InputMethodAgentStub::InputMethodAgentStub() {
InputMethodAgentStub::InputMethodAgentStub()
{
}
InputMethodAgentStub::~InputMethodAgentStub() {
InputMethodAgentStub::~InputMethodAgentStub()
{
}
int32_t InputMethodAgentStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) {
int32_t InputMethodAgentStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option)
{
IMSA_HILOGI("InputMethodAgentStub::OnRemoteRequest code = %{public}d", code);
auto descriptorToken = data.ReadInterfaceToken();
if (descriptorToken != GetDescriptor()) {
@@ -54,20 +58,22 @@ namespace MiscServices {
return ErrorCode::NO_ERROR;
}
int32_t InputMethodAgentStub::DispatchKey(int32_t key, int32_t status) {
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) {
return ErrorCode::ERROR_NULL_POINTER;
}
MessageParcel* data = new MessageParcel();
MessageParcel *data = new MessageParcel();
data->WriteInt32(key);
data->WriteInt32(status);
Message* message = new Message(MessageID::MSG_ID_DISPATCH_KEY, data);
Message *message = new Message(MessageID::MSG_ID_DISPATCH_KEY, data);
msgHandler_->SendMessage(message);
return ErrorCode::NO_ERROR;
}
void InputMethodAgentStub::SetMessageHandler(MessageHandler* msgHandler) {
void InputMethodAgentStub::SetMessageHandler(MessageHandler *msgHandler)
{
msgHandler_ = msgHandler;
}
}
@@ -20,12 +20,16 @@
namespace OHOS {
namespace MiscServices {
InputMethodCoreProxy::InputMethodCoreProxy(const OHOS::sptr<OHOS::IRemoteObject> &impl) : IRemoteProxy<IInputMethodCore>(impl) {
InputMethodCoreProxy::InputMethodCoreProxy(const OHOS::sptr<OHOS::IRemoteObject> &impl)
: IRemoteProxy<IInputMethodCore>(impl)
{
}
InputMethodCoreProxy::~InputMethodCoreProxy() = default;
int32_t InputMethodCoreProxy::initializeInput(sptr<IRemoteObject> &startInputToken, int32_t displayId, sptr<IInputControlChannel> &inputControlChannel) {
int32_t InputMethodCoreProxy::initializeInput(sptr<IRemoteObject> &startInputToken, int32_t displayId,
sptr<IInputControlChannel> &inputControlChannel)
{
IMSA_HILOGI("InputMethodCoreProxy::initializeInput");
if (startInputToken == nullptr) {
IMSA_HILOGI("InputMethodCoreProxy::initializeInput startInputToken is nullptr");
@@ -58,7 +62,9 @@ namespace MiscServices {
return code;
}
bool InputMethodCoreProxy::startInput(const sptr<IInputDataChannel> &inputDataChannel, const InputAttribute& editorAttribute, bool supportPhysicalKbd) {
bool InputMethodCoreProxy::startInput(const sptr<IInputDataChannel> &inputDataChannel,
const InputAttribute& editorAttribute, bool supportPhysicalKbd)
{
IMSA_HILOGI("InputMethodCoreProxy::startInput");
if (inputDataChannel == nullptr) {
IMSA_HILOGI("InputMethodCoreProxy::startInput inputDataChannel is nullptr");
@@ -85,7 +91,8 @@ namespace MiscServices {
return code == ErrorCode::NO_ERROR;
}
int32_t InputMethodCoreProxy::stopInput() {
int32_t InputMethodCoreProxy::stopInput()
{
IMSA_HILOGI("InputMethodCoreProxy::stopInput");
MessageParcel data, reply;
data.WriteInterfaceToken(GetDescriptor());
@@ -103,7 +110,8 @@ namespace MiscServices {
return reply.ReadInt32();
}
bool InputMethodCoreProxy::showKeyboard(int32_t flags) {
bool InputMethodCoreProxy::showKeyboard(int32_t flags)
{
IMSA_HILOGI("InputMethodCoreProxy::showKeyboard");
auto remote = Remote();
if (remote == nullptr){
@@ -125,7 +133,8 @@ namespace MiscServices {
return true;
}
bool InputMethodCoreProxy::hideKeyboard(int32_t flags) {
bool InputMethodCoreProxy::hideKeyboard(int32_t flags)
{
IMSA_HILOGI("InputMethodCoreProxy::hideKeyboard");
auto remote = Remote();
if (remote == nullptr) {
@@ -146,7 +155,8 @@ namespace MiscServices {
return true;
}
int32_t InputMethodCoreProxy::setKeyboardType(const KeyboardType& type) {
int32_t InputMethodCoreProxy::setKeyboardType(const KeyboardType& type)
{
IMSA_HILOGI("InputMethodCoreProxy::setKeyboardType");
MessageParcel data, reply;
data.WriteInterfaceToken(GetDescriptor());
@@ -160,7 +170,8 @@ namespace MiscServices {
return code;
}
int32_t InputMethodCoreProxy::getKeyboardWindowHeight(int32_t * retHeight) {
int32_t InputMethodCoreProxy::getKeyboardWindowHeight(int32_t retHeight)
{
IMSA_HILOGI("InputMethodCoreProxy::getKeyboardWindowHeight");
MessageParcel data, reply;
data.WriteInterfaceToken(GetDescriptor());
@@ -173,7 +184,7 @@ namespace MiscServices {
if (code != 0) {
return code;
}
*retHeight = reply.ReadInt32();
retHeight = reply.ReadInt32();
return ErrorCode::NO_ERROR;
}
}
@@ -12,8 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <chrono>
#include <stdint.h>
#include "message_handler.h"
@@ -32,14 +30,18 @@ namespace MiscServices {
* param userId the id of the user to whom the object is linking
* @param userId
*/
InputMethodCoreStub::InputMethodCoreStub(int userId) {
InputMethodCoreStub::InputMethodCoreStub(int userId)
{
userId_ = userId;
}
InputMethodCoreStub::~InputMethodCoreStub() {
InputMethodCoreStub::~InputMethodCoreStub()
{
}
int32_t InputMethodCoreStub::OnRemoteRequest(uint32_t code, MessageParcel & data, MessageParcel & reply, MessageOption & option) {
int32_t InputMethodCoreStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
MessageOption& option)
{
IMSA_HILOGI("InputMethodCoreStub::OnRemoteRequest");
auto descriptorToken = data.ReadInterfaceToken();
if (descriptorToken != GetDescriptor()) {
@@ -66,7 +68,7 @@ namespace MiscServices {
}
case START_INPUT: {
sptr<IInputDataChannel> inputDataChannel = iface_cast<IInputDataChannel>(data.ReadRemoteObject());
InputAttribute* editorAttribute = data.ReadParcelable<InputAttribute>();
InputAttribute *editorAttribute = data.ReadParcelable<InputAttribute>();
bool supportPhysicalKbd = data.ReadBool();
if (inputDataChannel == nullptr) {
@@ -94,13 +96,13 @@ namespace MiscServices {
break;
}
case SET_KEYBOARD_TYPE: {
KeyboardType* type = data.ReadParcelable<KeyboardType>();
KeyboardType *type = data.ReadParcelable<KeyboardType>();
setKeyboardType(*type);
reply.WriteNoException();
break;
}
case GET_KEYBOARD_WINDOW_HEIGHT: {
int32_t* retHeight = nullptr;
int32_t retHeight = 0;
getKeyboardWindowHeight(retHeight);
reply.WriteNoException();
break;
@@ -112,7 +114,9 @@ namespace MiscServices {
return NO_ERROR;
}
int32_t InputMethodCoreStub::initializeInput(sptr<IRemoteObject>& startInputToken, int32_t displayId, sptr<IInputControlChannel>& inputControlChannel) {
int32_t InputMethodCoreStub::initializeInput(sptr<IRemoteObject>& startInputToken, int32_t displayId,
sptr<IInputControlChannel>& inputControlChannel)
{
IMSA_HILOGI("InputMethodCoreStub::initializeInput");
if (msgHandler_==nullptr) {
return ErrorCode::ERROR_NULL_POINTER;
@@ -122,99 +126,107 @@ namespace MiscServices {
IMSA_HILOGI("InputMethodCoreStub::initializeInput startInputToken is nullptr");
}
MessageParcel* data = new MessageParcel();
MessageParcel *data = new MessageParcel();
data->WriteInt32(displayId);
if (inputControlChannel != nullptr) {
IMSA_HILOGI("InputMethodCoreStub::initializeInput. inputControlChannel is not nullptr");
data->WriteRemoteObject(inputControlChannel->AsObject());
}
Message* msg = new Message(MessageID::MSG_ID_INITIALIZE_INPUT, data);
Message *msg = new Message(MessageID::MSG_ID_INITIALIZE_INPUT, data);
msgHandler_->SendMessage(msg);
return ErrorCode::NO_ERROR;
}
bool InputMethodCoreStub::startInput(const sptr<IInputDataChannel>& inputDataChannel, const InputAttribute& editorAttribute, bool supportPhysicalKbd) {
bool InputMethodCoreStub::startInput(const sptr<IInputDataChannel>& inputDataChannel,
const InputAttribute& editorAttribute, bool supportPhysicalKbd)
{
IMSA_HILOGI("InputMethodCoreStub::startInput");
if (msgHandler_ == nullptr) {
return ErrorCode::ERROR_NULL_POINTER;
}
MessageParcel* data = new MessageParcel();
MessageParcel *data = new MessageParcel();
if (inputDataChannel !=nullptr) {
IMSA_HILOGI("InputMethodCoreStub::startInput inputDataChannel is not nullptr");
data->WriteRemoteObject(inputDataChannel->AsObject());
}
data->WriteParcelable(&editorAttribute);
data->WriteBool(supportPhysicalKbd);
Message* msg = new Message(MessageID::MSG_ID_START_INPUT, data);
Message *msg = new Message(MessageID::MSG_ID_START_INPUT, data);
msgHandler_->SendMessage(msg);
return true;
}
int32_t InputMethodCoreStub::stopInput() {
int32_t InputMethodCoreStub::stopInput()
{
IMSA_HILOGI("InputMethodCoreStub::stopInput");
if (msgHandler_ == nullptr) {
return ErrorCode::ERROR_NULL_POINTER;
}
MessageParcel* data = new MessageParcel();
Message* msg = new Message(MessageID::MSG_ID_STOP_INPUT, data);
MessageParcel *data = new MessageParcel();
Message *msg = new Message(MessageID::MSG_ID_STOP_INPUT, data);
msgHandler_->SendMessage(msg);
return ErrorCode::NO_ERROR;
}
bool InputMethodCoreStub::showKeyboard(int32_t flags) {
bool InputMethodCoreStub::showKeyboard(int32_t flags)
{
IMSA_HILOGI("InputMethodCoreStub::showKeyboard");
if (msgHandler_==nullptr) {
return false;
}
MessageParcel* data = new MessageParcel();
MessageParcel *data = new MessageParcel();
data->WriteInt32(userId_);
data->WriteInt32(flags);
Message* msg = new Message(MessageID::MSG_ID_SHOW_KEYBOARD, data);
Message *msg = new Message(MessageID::MSG_ID_SHOW_KEYBOARD, data);
msgHandler_->SendMessage(msg);
return true;
}
bool InputMethodCoreStub::hideKeyboard(int32_t flags) {
bool InputMethodCoreStub::hideKeyboard(int32_t flags)
{
IMSA_HILOGI("InputMethodCoreStub::hideKeyboard");
if (msgHandler_==nullptr) {
return ErrorCode::ERROR_NULL_POINTER;
}
MessageParcel* data = new MessageParcel();
MessageParcel *data = new MessageParcel();
data->WriteInt32(userId_);
data->WriteInt32(flags);
Message* msg = new Message(MessageID::MSG_ID_HIDE_KEYBOARD, data);
Message *msg = new Message(MessageID::MSG_ID_HIDE_KEYBOARD, data);
msgHandler_->SendMessage(msg);
return true;
}
int32_t InputMethodCoreStub::setKeyboardType(const KeyboardType& type) {
int32_t InputMethodCoreStub::setKeyboardType(const KeyboardType& type)
{
IMSA_HILOGI("InputMethodCoreStub::setKeyboardType");
if (msgHandler_==nullptr) {
return ErrorCode::ERROR_NULL_POINTER;
}
MessageParcel* data = new MessageParcel();
MessageParcel *data = new MessageParcel();
data->WriteParcelable(&type);
Message* msg = new Message(MessageID::MSG_ID_SET_KEYBOARD_TYPE, data);
Message *msg = new Message(MessageID::MSG_ID_SET_KEYBOARD_TYPE, data);
msgHandler_->SendMessage(msg);
return ErrorCode::NO_ERROR;
}
int32_t InputMethodCoreStub::getKeyboardWindowHeight(int32_t * retHeight) {
int32_t InputMethodCoreStub::getKeyboardWindowHeight(int32_t retHeight)
{
IMSA_HILOGI("InputMethodCoreStub::getKeyboardWindowHeight");
if (msgHandler_==nullptr) {
return ErrorCode::ERROR_NULL_POINTER;
}
MessageParcel* data = new MessageParcel();
MessageParcel *data = new MessageParcel();
Message* msg = new Message(MessageID::MSG_ID_GET_KEYBOARD_WINDOW_HEIGHT, data);
Message *msg = new Message(MessageID::MSG_ID_GET_KEYBOARD_WINDOW_HEIGHT, data);
msgHandler_->SendMessage(msg);
return ErrorCode::NO_ERROR;
}
void InputMethodCoreStub::SetMessageHandler(MessageHandler* msgHandler) {
void InputMethodCoreStub::SetMessageHandler(MessageHandler *msgHandler)
{
msgHandler_=msgHandler;
}
}
@@ -27,21 +27,21 @@
*/
namespace OHOS {
namespace MiscServices {
class IInputClient : public IRemoteBroker {
public:
enum {
ON_INPUT_READY = 0,
ON_INPUT_RELEASED ,
SET_DISPLAY_MODE ,
};
class IInputClient : public IRemoteBroker {
public:
enum {
ON_INPUT_READY = 0,
ON_INPUT_RELEASED,
SET_DISPLAY_MODE,
};
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.InputClient");
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.InputClient");
virtual int32_t onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent, const InputChannel* channel) = 0;
virtual int32_t onInputReleased(int32_t retValue) = 0;
virtual int32_t setDisplayMode(int32_t mode) = 0;
};
virtual int32_t onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent,
const InputChannel *channel) = 0;
virtual int32_t onInputReleased(int32_t retValue) = 0;
virtual int32_t setDisplayMode(int32_t mode) = 0;
};
}
}
#endif // FM_IMMS_PROJECT_IINPUTCLIENT_H
#endif // FM_IMMS_PROJECT_IINPUTCLIENT_H
@@ -25,7 +25,7 @@
*/
namespace OHOS {
namespace MiscServices {
class IInputDataChannel: public IRemoteBroker {
class IInputDataChannel : public IRemoteBroker {
public:
enum {
INSERT_TEXT = 0,
@@ -22,15 +22,13 @@
namespace OHOS {
namespace MiscServices {
class InputClientProxy : public IRemoteProxy<IInputClient>
{
class InputClientProxy : public IRemoteProxy<IInputClient> {
public:
explicit InputClientProxy(const sptr<IRemoteObject> &object);
~InputClientProxy() = default;
DISALLOW_COPY_AND_MOVE(InputClientProxy);
int32_t onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent, const InputChannel* channel) override;
int32_t onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent, const InputChannel *channel) override;
int32_t onInputReleased(int32_t retValue) override;
int32_t setDisplayMode(int32_t mode) override;
@@ -29,13 +29,13 @@ public:
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
InputClientStub();
~InputClientStub();
void SetHandler(MessageHandler* handler);
void SetHandler(MessageHandler *handler);
int32_t onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent, const InputChannel* channel) override;
int32_t onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent, const InputChannel *channel) override;
int32_t onInputReleased(int32_t retValue) override;
int32_t setDisplayMode(int32_t mode) override;
private:
MessageHandler* msgHandler = nullptr;
MessageHandler *msgHandler = nullptr;
};
}
}
@@ -13,8 +13,6 @@
* limitations under the License.
*/
#ifndef FM_IMC_PROJECT_INPUTDATACHANNELPROXY_H
#define FM_IMC_PROJECT_INPUTDATACHANNELPROXY_H
@@ -23,21 +21,19 @@
namespace OHOS {
namespace MiscServices {
class InputDataChannelProxy : public IRemoteProxy<IInputDataChannel> {
public:
explicit InputDataChannelProxy(const sptr<IRemoteObject> &object);
~InputDataChannelProxy() = default;
DISALLOW_COPY_AND_MOVE(InputDataChannelProxy);
class InputDataChannelProxy : public IRemoteProxy<IInputDataChannel>
{
public:
explicit InputDataChannelProxy(const sptr<IRemoteObject> &object);
~InputDataChannelProxy() = default;
DISALLOW_COPY_AND_MOVE(InputDataChannelProxy);
bool InsertText(const std::u16string& text) override;
bool DeleteBackward(int32_t length) override;
void Close() override;
bool InsertText(const std::u16string& text) override;
bool DeleteBackward(int32_t length) override;
void Close() override;
private:
static inline BrokerDelegator<InputDataChannelProxy> delegator_;
};
private:
static inline BrokerDelegator<InputDataChannelProxy> delegator_;
};
}
}
#endif
@@ -29,13 +29,13 @@ public:
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
InputDataChannelStub();
~InputDataChannelStub();
void SetHandler(MessageHandler* handler);
void SetHandler(MessageHandler *handler);
bool InsertText(const std::u16string& text) override;
bool DeleteBackward(int32_t length) override;
void Close() override;
private:
MessageHandler* msgHandler;
MessageHandler *msgHandler;
};
}
}
@@ -17,7 +17,6 @@
#ifndef FM_IMC_PROJECT_INPUTMETHODCONTROLLER_H
#define FM_IMC_PROJECT_INPUTMETHODCONTROLLER_H
//#include "refbase.h"
#include <mutex>
#include <thread>
#include "input_data_channel_stub.h"
@@ -30,7 +29,6 @@
namespace OHOS {
namespace MiscServices {
class OnTextChangedListener : public virtual RefBase {
public:
virtual void InsertText(const std::u16string& text) = 0;
@@ -60,7 +58,8 @@ namespace MiscServices {
bool Initialize();
sptr<InputMethodSystemAbilityProxy> GetImsaProxy();
void PrepareInput(int32_t displayId,sptr<InputClientStub> &client,sptr<InputDataChannelStub> &channel,InputAttribute &attribute);
void PrepareInput(int32_t displayId, sptr<InputClientStub> &client, sptr<InputDataChannelStub> &channel,
InputAttribute &attribute);
void StartInput(sptr<InputClientStub> &client);
void StopInput(sptr<InputClientStub> &client);
void ReleaseInput(sptr<InputClientStub> &client);
@@ -71,13 +70,13 @@ namespace MiscServices {
sptr<InputMethodSystemAbilityProxy> mImms;
sptr<ImsaDeathRecipient> deathRecipient_;
sptr<InputMethodAgentProxy> mAgent;
OnTextChangedListener* textListener;
OnTextChangedListener *textListener;
InputAttribute mAttribute;
static std::mutex instanceLock_;
static sptr<InputMethodController> instance_;
std::thread workThreadHandler;
MessageHandler* msgHandler;
MessageHandler *msgHandler;
};
}
}
@@ -13,7 +13,6 @@
* limitations under the License.
*/
#ifndef FM_IMC_PROJECT_INPUTMETHODSYSTEMABILITYPROXY_H
#define FM_IMC_PROJECT_INPUTMETHODSYSTEMABILITYPROXY_H
@@ -30,35 +29,34 @@
namespace OHOS {
namespace MiscServices {
class InputMethodSystemAbilityProxy : public IRemoteProxy<IInputMethodSystemAbility> {
public:
explicit InputMethodSystemAbilityProxy(const sptr<IRemoteObject> &object);
~InputMethodSystemAbilityProxy() = default;
DISALLOW_COPY_AND_MOVE(InputMethodSystemAbilityProxy);
class InputMethodSystemAbilityProxy : public IRemoteProxy<IInputMethodSystemAbility>
{
public:
explicit InputMethodSystemAbilityProxy(const sptr<IRemoteObject> &object);
~InputMethodSystemAbilityProxy() = default;
DISALLOW_COPY_AND_MOVE(InputMethodSystemAbilityProxy);
virtual void prepareInput(MessageParcel& data) override;
virtual void releaseInput(MessageParcel& data) override;
virtual void startInput(MessageParcel& data) override;
virtual void stopInput(MessageParcel& data) override;
virtual int32_t setInputMethodCore(sptr<IInputMethodCore> &core) override;
virtual void prepareInput(MessageParcel& data) override;
virtual void releaseInput(MessageParcel& data) override;
virtual void startInput(MessageParcel& data) override;
virtual void stopInput(MessageParcel& data) override;
virtual int32_t setInputMethodCore(sptr<IInputMethodCore> &core) override;
int32_t Prepare(int32_t displayId, sptr<InputClientStub> &client, sptr<InputDataChannelStub> &channel,
InputAttribute &attribute);
int32_t Release(sptr<InputClientStub> &client);
int32_t Start(sptr<InputClientStub> &client);
int32_t Stop(sptr<InputClientStub> &client);
int32_t Prepare(int32_t displayId, sptr<InputClientStub> &client, sptr<InputDataChannelStub> &channel, InputAttribute &attribute);
int32_t Release(sptr<InputClientStub> &client);
int32_t Start(sptr<InputClientStub> &client);
int32_t Stop(sptr<InputClientStub> &client);
virtual int32_t getDisplayMode(int32_t *retMode) override;
virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override;
virtual int32_t getCurrentKeyboardType(KeyboardType *retType) override;
virtual int32_t listInputMethodEnabled(std::vector<InputMethodProperty*> *properties) override;
virtual int32_t listInputMethod(std::vector<InputMethodProperty*> *properties) override;
virtual int32_t listKeyboardType(const std::u16string& imeId, std::vector<KeyboardType*> *types) override;
virtual int32_t getDisplayMode(int32_t *retMode) override;
virtual int32_t getKeyboardWindowHeight(int32_t *retHeight) override;
virtual int32_t getCurrentKeyboardType(KeyboardType* retType) override;
virtual int32_t listInputMethodEnabled(std::vector<InputMethodProperty*> *properties) override;
virtual int32_t listInputMethod(std::vector<InputMethodProperty*> *properties) override;
virtual int32_t listKeyboardType(const std::u16string& imeId, std::vector<KeyboardType*> *types) override;
private:
static inline BrokerDelegator<InputMethodSystemAbilityProxy> delegator_;
};
private:
static inline BrokerDelegator<InputMethodSystemAbilityProxy> delegator_;
};
}
}
#endif
@@ -22,7 +22,8 @@ using namespace ErrorCode;
{
}
int32_t InputClientProxy::onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent, const InputChannel* channel)
int32_t InputClientProxy::onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent,
const InputChannel *channel)
{
IMSA_HILOGI("InputClientProxy::onInputReady");
MessageParcel data, reply;
@@ -18,88 +18,85 @@
namespace OHOS {
namespace MiscServices {
InputClientStub::InputClientStub()
{
}
InputClientStub::~InputClientStub()
{
}
int32_t InputClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
IMSA_HILOGI("InputClientStub::OnRemoteRequest. code = %{public}u", code);
auto descriptorToken = data.ReadInterfaceToken();
if (descriptorToken != GetDescriptor()) {
return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
InputClientStub::InputClientStub()
{
}
switch (code) {
case ON_INPUT_READY: {
if (msgHandler == nullptr) {
break;
}
MessageParcel* parcel = new MessageParcel();
parcel->WriteInt32(data.ReadInt32());
if (data.ReadInt32() > 0) {
parcel->WriteRemoteObject(data.ReadRemoteObject());
}
if (data.ReadInt32() > 0) {
parcel->WriteParcelable(data.ReadParcelable<InputChannel>());
}
Message* msg = new Message(MessageID::MSG_ID_ON_INPUT_READY, parcel);
msgHandler->SendMessage(msg);
break;
}
case ON_INPUT_RELEASED: {
if (msgHandler == nullptr) {
break;
}
MessageParcel* parcel = new MessageParcel();
parcel->WriteInt32(data.ReadInt32());
Message* msg = new Message(MessageID::MSG_ID_EXIT_SERVICE, parcel);
msgHandler->SendMessage(msg);
break;
}
case SET_DISPLAY_MODE: {
if (msgHandler == nullptr) {
break;
}
MessageParcel* parcel = new MessageParcel();
parcel->WriteInt32(data.ReadInt32());
Message* msg = new Message(MessageID::MSG_ID_SET_DISPLAY_MODE, parcel);
msgHandler->SendMessage(msg);
break;
}
default:
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
InputClientStub::~InputClientStub()
{
}
return NO_ERROR;
}
int32_t InputClientStub::onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent, const InputChannel* channel)
{
return ErrorCode::NO_ERROR;
}
int32_t InputClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
IMSA_HILOGI("InputClientStub::OnRemoteRequest. code = %{public}u", code);
auto descriptorToken = data.ReadInterfaceToken();
if (descriptorToken != GetDescriptor()) {
return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
}
switch (code) {
case ON_INPUT_READY: {
if (msgHandler == nullptr) {
break;
}
MessageParcel *parcel = new MessageParcel();
parcel->WriteInt32(data.ReadInt32());
if (data.ReadInt32() > 0) {
parcel->WriteRemoteObject(data.ReadRemoteObject());
}
if (data.ReadInt32() > 0) {
parcel->WriteParcelable(data.ReadParcelable<InputChannel>());
}
int32_t InputClientStub::onInputReleased(int32_t retValue)
{
return ErrorCode::NO_ERROR;
}
Message *msg = new Message(MessageID::MSG_ID_ON_INPUT_READY, parcel);
msgHandler->SendMessage(msg);
break;
}
case ON_INPUT_RELEASED: {
if (msgHandler == nullptr) {
break;
}
MessageParcel *parcel = new MessageParcel();
parcel->WriteInt32(data.ReadInt32());
Message *msg = new Message(MessageID::MSG_ID_EXIT_SERVICE, parcel);
msgHandler->SendMessage(msg);
break;
}
case SET_DISPLAY_MODE: {
if (msgHandler == nullptr) {
break;
}
MessageParcel *parcel = new MessageParcel();
parcel->WriteInt32(data.ReadInt32());
Message *msg = new Message(MessageID::MSG_ID_SET_DISPLAY_MODE, parcel);
msgHandler->SendMessage(msg);
break;
}
default:
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
return NO_ERROR;
}
int32_t InputClientStub::setDisplayMode(int32_t mode)
{
return ErrorCode::NO_ERROR;
}
int32_t InputClientStub::onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent,
const InputChannel *channel)
{
return ErrorCode::NO_ERROR;
}
void InputClientStub::SetHandler(MessageHandler* handler)
{
msgHandler = handler;
}
int32_t InputClientStub::onInputReleased(int32_t retValue)
{
return ErrorCode::NO_ERROR;
}
int32_t InputClientStub::setDisplayMode(int32_t mode)
{
return ErrorCode::NO_ERROR;
}
void InputClientStub::SetHandler(MessageHandler *handler)
{
msgHandler = handler;
}
}
}
@@ -19,55 +19,54 @@
namespace OHOS {
namespace MiscServices {
InputDataChannelProxy::InputDataChannelProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<IInputDataChannel>(object)
{
}
bool InputDataChannelProxy::InsertText(const std::u16string& text)
{
IMSA_HILOGI("InputDataChannelProxy::InsertText");
MessageParcel data, reply;
MessageOption option;
data.WriteInterfaceToken(GetDescriptor());
data.WriteString16(text);
auto ret = Remote()->SendRequest(INSERT_TEXT, data, reply, option);
if (ret != NO_ERROR) {
return false;
InputDataChannelProxy::InputDataChannelProxy(const sptr<IRemoteObject> &object)
: IRemoteProxy<IInputDataChannel>(object)
{
}
auto result = reply.ReadBool();
return result;
}
bool InputDataChannelProxy::DeleteBackward(int32_t length)
{
IMSA_HILOGI("InputDataChannelProxy::DeleteBackward");
MessageParcel data, reply;
MessageOption option;
data.WriteInterfaceToken(GetDescriptor());
data.WriteInt32(length);
bool InputDataChannelProxy::InsertText(const std::u16string& text)
{
IMSA_HILOGI("InputDataChannelProxy::InsertText");
MessageParcel data, reply;
MessageOption option;
data.WriteInterfaceToken(GetDescriptor());
data.WriteString16(text);
auto ret = Remote()->SendRequest(DELETE_BACKWARD, data, reply, option);
if (ret != NO_ERROR) {
return false;
auto ret = Remote()->SendRequest(INSERT_TEXT, data, reply, option);
if (ret != NO_ERROR) {
return false;
}
auto result = reply.ReadBool();
return result;
}
auto result = reply.ReadBool();
return result;
}
void InputDataChannelProxy::Close()
{
IMSA_HILOGI("InputDataChannelProxy::Close");
MessageParcel data, reply;
MessageOption option;
data.WriteInterfaceToken(GetDescriptor());
bool InputDataChannelProxy::DeleteBackward(int32_t length)
{
IMSA_HILOGI("InputDataChannelProxy::DeleteBackward");
MessageParcel data, reply;
MessageOption option;
data.WriteInterfaceToken(GetDescriptor());
data.WriteInt32(length);
auto ret = Remote()->SendRequest(CLOSE, data, reply, option);
if (ret != NO_ERROR) {
auto ret = Remote()->SendRequest(DELETE_BACKWARD, data, reply, option);
if (ret != NO_ERROR) {
return false;
}
auto result = reply.ReadBool();
return result;
}
void InputDataChannelProxy::Close()
{
IMSA_HILOGI("InputDataChannelProxy::Close");
MessageParcel data, reply;
MessageOption option;
data.WriteInterfaceToken(GetDescriptor());
auto ret = Remote()->SendRequest(CLOSE, data, reply, option);
if (ret != NO_ERROR) {
}
}
}
}
}
@@ -17,82 +17,81 @@
namespace OHOS {
namespace MiscServices {
InputDataChannelStub::InputDataChannelStub() : msgHandler(nullptr)
{
}
InputDataChannelStub::~InputDataChannelStub()
{
if (msgHandler != nullptr) {
delete msgHandler;
InputDataChannelStub::InputDataChannelStub() : msgHandler(nullptr)
{
}
}
int32_t InputDataChannelStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
IMSA_HILOGI("InputDataChannelStub::OnRemoteRequest code = %{public}d", code);
auto descriptorToken = data.ReadInterfaceToken();
if (descriptorToken != GetDescriptor()) {
return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
}
switch (code) {
case INSERT_TEXT: {
auto text = data.ReadString16();
InsertText(text);
break;
InputDataChannelStub::~InputDataChannelStub()
{
if (msgHandler != nullptr) {
delete msgHandler;
}
case DELETE_BACKWARD: {
auto length = data.ReadInt32();
DeleteBackward(length);
break;
}
int32_t InputDataChannelStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
IMSA_HILOGI("InputDataChannelStub::OnRemoteRequest code = %{public}d", code);
auto descriptorToken = data.ReadInterfaceToken();
if (descriptorToken != GetDescriptor()) {
return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
}
case CLOSE: {
Close();
break;
switch (code) {
case INSERT_TEXT: {
auto text = data.ReadString16();
InsertText(text);
break;
}
case DELETE_BACKWARD: {
auto length = data.ReadInt32();
DeleteBackward(length);
break;
}
case CLOSE: {
Close();
break;
}
default:
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
default:
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
return NO_ERROR;
}
return NO_ERROR;
}
bool InputDataChannelStub::InsertText(const std::u16string& text)
{
IMSA_HILOGI("InputDataChannelStub::InsertText");
if (msgHandler != nullptr) {
MessageParcel* parcel = new MessageParcel;
parcel->WriteString16(text);
Message* msg = new Message(MessageID::MSG_ID_INSERT_CHAR, parcel);
msgHandler->SendMessage(msg);
IMSA_HILOGI("InputDataChannelStub::InsertText return true");
return true;
bool InputDataChannelStub::InsertText(const std::u16string& text)
{
IMSA_HILOGI("InputDataChannelStub::InsertText");
if (msgHandler != nullptr) {
MessageParcel *parcel = new MessageParcel;
parcel->WriteString16(text);
Message *msg = new Message(MessageID::MSG_ID_INSERT_CHAR, parcel);
msgHandler->SendMessage(msg);
IMSA_HILOGI("InputDataChannelStub::InsertText return true");
return true;
}
return false;
}
return false;
}
bool InputDataChannelStub::DeleteBackward(int32_t length)
{
IMSA_HILOGI("InputDataChannelStub::DeleteBackward");
if (msgHandler != nullptr) {
MessageParcel* parcel = new MessageParcel;
parcel->WriteInt32(length);
Message* msg = new Message(MessageID::MSG_ID_DELETE_BACKWARD, parcel);
msgHandler->SendMessage(msg);
return true;
bool InputDataChannelStub::DeleteBackward(int32_t length)
{
IMSA_HILOGI("InputDataChannelStub::DeleteBackward");
if (msgHandler != nullptr) {
MessageParcel *parcel = new MessageParcel;
parcel->WriteInt32(length);
Message *msg = new Message(MessageID::MSG_ID_DELETE_BACKWARD, parcel);
msgHandler->SendMessage(msg);
return true;
}
return false;
}
return false;
}
void InputDataChannelStub::Close()
{
void InputDataChannelStub::Close()
{
}
}
void InputDataChannelStub::SetHandler(MessageHandler* handler)
{
msgHandler = handler;
}
void InputDataChannelStub::SetHandler(MessageHandler *handler)
{
msgHandler = handler;
}
}
}
@@ -95,10 +95,10 @@ using namespace MessageID;
void InputMethodController::WorkThread()
{
while(1) {
Message* msg = msgHandler->GetMessage();
Message *msg = msgHandler->GetMessage();
switch(msg->msgId_) {
case MSG_ID_INSERT_CHAR:{
MessageParcel* data = msg->msgContent_;
MessageParcel *data = msg->msgContent_;
std::u16string text = data->ReadString16();
if(textListener != nullptr){
textListener->InsertText(text);
@@ -106,7 +106,7 @@ using namespace MessageID;
break;
}
case MSG_ID_DELETE_BACKWARD:{
MessageParcel* data = msg->msgContent_;
MessageParcel *data = msg->msgContent_;
int32_t length = data->ReadInt32();
if(textListener != nullptr){
textListener->DeleteBackward(length);
@@ -114,13 +114,13 @@ using namespace MessageID;
break;
}
case MSG_ID_SET_DISPLAY_MODE:{
MessageParcel* data = msg->msgContent_;
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:{
MessageParcel* data = msg->msgContent_;
MessageParcel *data = msg->msgContent_;
int32_t ret = data->ReadInt32();
if(ret != ErrorCode::NO_ERROR) {
if (textListener != nullptr){
@@ -137,7 +137,7 @@ using namespace MessageID;
break;
}
case MSG_ID_EXIT_SERVICE:{
MessageParcel* data = msg->msgContent_;
MessageParcel *data = msg->msgContent_;
int32_t ret = data->ReadInt32();
textListener = nullptr;
IMSA_HILOGI("MSG_ID_EXIT_SERVICE : %{public}d", ret);
@@ -174,7 +174,8 @@ using namespace MessageID;
ReleaseInput(mClient);
}
void InputMethodController::PrepareInput(int32_t displayId,sptr<InputClientStub> &client,sptr<InputDataChannelStub> &channel,InputAttribute &attribute)
void InputMethodController::PrepareInput(int32_t displayId, sptr<InputClientStub> &client,
sptr<InputDataChannelStub> &channel, InputAttribute &attribute)
{
IMSA_HILOGI("InputMethodController::PrepareInput");
if(mImms == nullptr){
@@ -233,13 +234,13 @@ using namespace MessageID;
mImms->stopInput(data);
}
void InputMethodController::OnRemoteSaDied(const wptr<IRemoteObject> &remote) {
void InputMethodController::OnRemoteSaDied(const wptr<IRemoteObject> &remote)
{
mImms = GetImsaProxy();
}
ImsaDeathRecipient::ImsaDeathRecipient()
{
}
void ImsaDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &object)
@@ -17,87 +17,85 @@
namespace OHOS {
namespace MiscServices {
using namespace ErrorCode;
InputMethodSystemAbilityProxy::InputMethodSystemAbilityProxy(const sptr<IRemoteObject> &object)
: IRemoteProxy<IInputMethodSystemAbility>(object)
{
}
void InputMethodSystemAbilityProxy::prepareInput(MessageParcel& data)
{
MessageParcel reply;
MessageOption option;
auto ret = Remote()->SendRequest(PREPARE_INPUT, data, reply, option);
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::prepareInput SendRequest failed");
return;
using namespace ErrorCode;
InputMethodSystemAbilityProxy::InputMethodSystemAbilityProxy(const sptr<IRemoteObject> &object)
: IRemoteProxy<IInputMethodSystemAbility>(object)
{
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::prepareInput reply failed");
return;
}
}
void InputMethodSystemAbilityProxy::prepareInput(MessageParcel& data)
{
MessageParcel reply;
MessageOption option;
void InputMethodSystemAbilityProxy::releaseInput(MessageParcel& data)
{
MessageParcel reply;
MessageOption option;
auto ret = Remote()->SendRequest(PREPARE_INPUT, data, reply, option);
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::prepareInput SendRequest failed");
return;
}
auto ret = Remote()->SendRequest(RELEASE_INPUT, data, reply, option);
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::releaseInput SendRequest failed");
return;
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::prepareInput reply failed");
return;
}
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::releaseInput reply failed");
return;
}
}
void InputMethodSystemAbilityProxy::releaseInput(MessageParcel& data)
{
MessageParcel reply;
MessageOption option;
void InputMethodSystemAbilityProxy::startInput(MessageParcel& data)
{
IMSA_HILOGI("InputMethodSystemAbilityProxy::startInput");
MessageParcel reply;
MessageOption option;
auto ret = Remote()->SendRequest(RELEASE_INPUT, data, reply, option);
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::releaseInput SendRequest failed");
return;
}
auto ret = Remote()->SendRequest(START_INPUT,data,reply,option);
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::startInput SendRequest failed");
return;
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::releaseInput reply failed");
return;
}
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::startInput reply failed");
return;
}
}
void InputMethodSystemAbilityProxy::startInput(MessageParcel& data)
{
IMSA_HILOGI("InputMethodSystemAbilityProxy::startInput");
MessageParcel reply;
MessageOption option;
void InputMethodSystemAbilityProxy::stopInput(MessageParcel& data)
{
IMSA_HILOGI("InputMethodSystemAbilityProxy::stopInput");
MessageParcel reply;
MessageOption option;
auto ret = Remote()->SendRequest(START_INPUT,data,reply,option);
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::startInput SendRequest failed");
return;
}
auto ret = Remote()->SendRequest(STOP_INPUT,data,reply,option);
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::stopInput SendRequest failed");
return;
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::startInput reply failed");
return;
}
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::stopInput reply failed");
return;
void InputMethodSystemAbilityProxy::stopInput(MessageParcel& data)
{
IMSA_HILOGI("InputMethodSystemAbilityProxy::stopInput");
MessageParcel reply;
MessageOption option;
auto ret = Remote()->SendRequest(STOP_INPUT,data,reply,option);
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::stopInput SendRequest failed");
return;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
IMSA_HILOGI("InputMethodSystemAbilityProxy::stopInput reply failed");
return;
}
}
}
int32_t InputMethodSystemAbilityProxy::setInputMethodCore(sptr<IInputMethodCore> &core)
{
@@ -107,12 +105,14 @@ void InputMethodSystemAbilityProxy::stopInput(MessageParcel& data)
IMSA_HILOGI("InputMethodSystemAbilityProxy::setInputMethodCore inputDataChannel is nullptr");
}
auto remote = Remote();
if (remote == nullptr)
if (remote == nullptr) {
return -1;
}
MessageParcel data;
if (!(data.WriteInterfaceToken(GetDescriptor())
&& data.WriteRemoteObject(core->AsObject())))
&& data.WriteRemoteObject(core->AsObject()))) {
return -1;
}
MessageParcel reply;
MessageOption option { MessageOption::TF_SYNC };
@@ -121,290 +121,288 @@ void InputMethodSystemAbilityProxy::stopInput(MessageParcel& data)
return status;
}
int32_t InputMethodSystemAbilityProxy::Prepare(int32_t displayId, sptr<InputClientStub> &client, sptr<InputDataChannelStub> &channel, InputAttribute &attribute)
{
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
int32_t InputMethodSystemAbilityProxy::Prepare(int32_t displayId, sptr<InputClientStub> &client,
sptr<InputDataChannelStub> &channel, InputAttribute &attribute)
{
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
if (!(data.WriteInt32(displayId)
&& data.WriteRemoteObject(client->AsObject())
&& data.WriteRemoteObject(channel->AsObject())
&& data.WriteParcelable(&attribute))) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(PREPARE_INPUT, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
return NO_ERROR;
}
if (!(data.WriteInt32(displayId)
&& data.WriteRemoteObject(client->AsObject())
&& data.WriteRemoteObject(channel->AsObject())
&& data.WriteParcelable(&attribute))) {
return ERROR_EX_PARCELABLE;
}
int32_t InputMethodSystemAbilityProxy::Release(sptr<InputClientStub> &client)
{
IMSA_HILOGI("InputMethodSystemAbilityProxy::Release");
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(PREPARE_INPUT, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
if (!data.WriteRemoteObject(client->AsObject().GetRefPtr())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(RELEASE_INPUT, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
return NO_ERROR;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
int32_t InputMethodSystemAbilityProxy::Start(sptr<InputClientStub> &client)
{
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
if (!data.WriteRemoteObject(client->AsObject().GetRefPtr())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(START_INPUT, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
return NO_ERROR;
}
return NO_ERROR;
}
int32_t InputMethodSystemAbilityProxy::Stop(sptr<InputClientStub> &client)
{
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
int32_t InputMethodSystemAbilityProxy::Release(sptr<InputClientStub> &client)
{
IMSA_HILOGI("InputMethodSystemAbilityProxy::Release");
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
if (!data.WriteRemoteObject(client->AsObject().GetRefPtr())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(STOP_INPUT, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
return NO_ERROR;
}
if (!data.WriteRemoteObject(client->AsObject().GetRefPtr())) {
return ERROR_EX_PARCELABLE;
int32_t InputMethodSystemAbilityProxy::getDisplayMode(int32_t *retMode)
{
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(GET_DISPLAY_MODE, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
if (!reply.ReadInt32(*retMode)) {
return ERROR_STATUS_BAD_VALUE;
}
return NO_ERROR;
}
auto ret = Remote()->SendRequest(RELEASE_INPUT, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
int32_t InputMethodSystemAbilityProxy::getKeyboardWindowHeight(int32_t retHeight)
{
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(GET_KEYBOARD_WINDOW_HEIGHT, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
if (!reply.ReadInt32(retHeight)) {
return ERROR_STATUS_BAD_VALUE;
}
return NO_ERROR;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
int32_t InputMethodSystemAbilityProxy::getCurrentKeyboardType(KeyboardType *retType)
{
if (retType == nullptr) {
return ERROR_NULL_POINTER;
}
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(GET_CURRENT_KEYBOARD_TYPE, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
KeyboardType *keyType = reply.ReadParcelable<KeyboardType>();
*retType = *keyType;
delete keyType;
return NO_ERROR;
}
return NO_ERROR;
}
int32_t InputMethodSystemAbilityProxy::listInputMethodEnabled(std::vector<InputMethodProperty*> *properties)
{
if (properties == nullptr) {
return ERROR_NULL_POINTER;
}
int32_t InputMethodSystemAbilityProxy::Start(sptr<InputClientStub> &client)
{
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(LIST_INPUT_METHOD_ENABLED, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
auto size = reply.ReadInt32();
while (size > 0) {
InputMethodProperty *imp = reply.ReadParcelable<InputMethodProperty>();
properties->push_back(imp);
size--;
}
return NO_ERROR;
}
if (!data.WriteRemoteObject(client->AsObject().GetRefPtr())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(START_INPUT, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
int32_t InputMethodSystemAbilityProxy::listInputMethod(std::vector<InputMethodProperty*> *properties)
{
if (properties == nullptr) {
return ERROR_NULL_POINTER;
}
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(LIST_INPUT_METHOD, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
auto size = reply.ReadInt32();
while (size > 0) {
InputMethodProperty *imp = reply.ReadParcelable<InputMethodProperty>();
properties->push_back(imp);
size--;
}
return NO_ERROR;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
int32_t InputMethodSystemAbilityProxy::listKeyboardType(const std::u16string& imeId,
std::vector<KeyboardType*> *types)
{
if (types == nullptr) {
return ERROR_NULL_POINTER;
}
MessageParcel data, reply;
MessageOption option;
if (!(data.WriteInterfaceToken(GetDescriptor()) && data.WriteString16(imeId))) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(LIST_KEYBOARD_TYPE, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
auto size = reply.ReadInt32();
while (size > 0) {
KeyboardType *kt = reply.ReadParcelable<KeyboardType>();
types->push_back(kt);
size--;
}
return NO_ERROR;
}
return NO_ERROR;
}
int32_t InputMethodSystemAbilityProxy::Stop(sptr<InputClientStub> &client)
{
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
if (!data.WriteRemoteObject(client->AsObject().GetRefPtr())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(STOP_INPUT, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
return NO_ERROR;
}
int32_t InputMethodSystemAbilityProxy::getDisplayMode(int32_t *retMode)
{
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(GET_DISPLAY_MODE, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
if (!reply.ReadInt32(*retMode)) {
return ERROR_STATUS_BAD_VALUE;
}
return NO_ERROR;
}
int32_t InputMethodSystemAbilityProxy::getKeyboardWindowHeight(int32_t *retHeight)
{
if (retHeight == nullptr) {
return ERROR_NULL_POINTER;
}
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(GET_KEYBOARD_WINDOW_HEIGHT, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
if (!reply.ReadInt32(*retHeight)) {
return ERROR_STATUS_BAD_VALUE;
}
return NO_ERROR;
}
int32_t InputMethodSystemAbilityProxy::getCurrentKeyboardType(KeyboardType* retType)
{
if (retType == nullptr) {
return ERROR_NULL_POINTER;
}
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(GET_CURRENT_KEYBOARD_TYPE, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
KeyboardType* keyType = reply.ReadParcelable<KeyboardType>();
*retType = *keyType;
delete keyType;
return NO_ERROR;
}
int32_t InputMethodSystemAbilityProxy::listInputMethodEnabled(std::vector<InputMethodProperty*> *properties)
{
if (properties == nullptr) {
return ERROR_NULL_POINTER;
}
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(LIST_INPUT_METHOD_ENABLED, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
auto size = reply.ReadInt32();
while (size > 0) {
InputMethodProperty* imp = reply.ReadParcelable<InputMethodProperty>();
properties->push_back(imp);
size--;
}
return NO_ERROR;
}
int32_t InputMethodSystemAbilityProxy::listInputMethod(std::vector<InputMethodProperty*> *properties)
{
if (properties == nullptr) {
return ERROR_NULL_POINTER;
}
MessageParcel data, reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(LIST_INPUT_METHOD, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
auto size = reply.ReadInt32();
while (size > 0) {
InputMethodProperty* imp = reply.ReadParcelable<InputMethodProperty>();
properties->push_back(imp);
size--;
}
return NO_ERROR;
}
int32_t InputMethodSystemAbilityProxy::listKeyboardType(const std::u16string& imeId, std::vector<KeyboardType*> *types)
{
if (types == nullptr) {
return ERROR_NULL_POINTER;
}
MessageParcel data, reply;
MessageOption option;
if (!(data.WriteInterfaceToken(GetDescriptor()) && data.WriteString16(imeId))) {
return ERROR_EX_PARCELABLE;
}
auto ret = Remote()->SendRequest(LIST_KEYBOARD_TYPE, data, reply, option);
if (ret != NO_ERROR) {
return ERROR_STATUS_FAILED_TRANSACTION;
}
ret = reply.ReadInt32();
if (ret != NO_ERROR) {
return ret;
}
auto size = reply.ReadInt32();
while (size > 0) {
KeyboardType* kt = reply.ReadParcelable<KeyboardType>();
types->push_back(kt);
size--;
}
return NO_ERROR;
}
}
}