mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 14:49:59 +00:00
commit
297b819c09
@ -22,7 +22,7 @@
|
||||
#include "input_channel.h"
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include "message_parcel.h"
|
||||
#include "input_attribute.h"
|
||||
#include "i_input_data_channel.h"
|
||||
|
@ -81,7 +81,7 @@ namespace MiscServices {
|
||||
mImms = GetImsaProxy();
|
||||
sptr<InputMethodCoreStub> stub = new InputMethodCoreStub(0);
|
||||
stub->SetMessageHandler(msgHandler);
|
||||
sptr<IInputMethodCore> stub2=stub;
|
||||
sptr<IInputMethodCore> stub2 = stub;
|
||||
if (mImms != nullptr) {
|
||||
mImms->setInputMethodCore(stub2);
|
||||
}
|
||||
@ -94,7 +94,10 @@ namespace MiscServices {
|
||||
IMSA_HILOGI("InputMethodAbility::Initialize");
|
||||
InitialInputWindow();
|
||||
msgHandler = new MessageHandler();
|
||||
workThreadHandler = std::thread([this]{WorkThread();});
|
||||
workThreadHandler = std::thread([this]
|
||||
{
|
||||
WorkThread();
|
||||
});
|
||||
}
|
||||
|
||||
void InputMethodAbility::setEventTarget(sptr<EventTarget> &eventTarget) {
|
||||
@ -104,7 +107,8 @@ namespace MiscServices {
|
||||
|
||||
void InputMethodAbility::WorkThread()
|
||||
{
|
||||
while(1){
|
||||
while(1)
|
||||
{
|
||||
Message *msg = msgHandler->GetMessage();
|
||||
switch(msg->msgId_) {
|
||||
case MSG_ID_INITIALIZE_INPUT: {
|
||||
@ -132,7 +136,7 @@ namespace MiscServices {
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_ID_DISPATCH_KEY : {
|
||||
case MSG_ID_DISPATCH_KEY: {
|
||||
DispatchKey(msg);
|
||||
break;
|
||||
}
|
||||
@ -155,9 +159,10 @@ namespace MiscServices {
|
||||
IMSA_HILOGI("InputMethodAbility::OnInitialInput channelObject is nullptr");
|
||||
return;
|
||||
}
|
||||
sptr<InputControlChannelProxy> channelProxy=new InputControlChannelProxy(channelObject);
|
||||
sptr<InputControlChannelProxy> channelProxy = new InputControlChannelProxy(channelObject);
|
||||
inputControlChannel = channelProxy;
|
||||
if(inputControlChannel == nullptr) {
|
||||
if (inputControlChannel == nullptr)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::OnInitialInput inputControlChannel is nullptr");
|
||||
return;
|
||||
}
|
||||
@ -170,17 +175,20 @@ namespace MiscServices {
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
sptr<InputDataChannelProxy> channalProxy = new InputDataChannelProxy(data->ReadRemoteObject());
|
||||
inputDataChannel = channalProxy;
|
||||
if(inputDataChannel == nullptr) {
|
||||
if (inputDataChannel == nullptr)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::OnStartInput inputDataChannel is nullptr");
|
||||
}
|
||||
editorAttribute = data->ReadParcelable<InputAttribute>();
|
||||
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);
|
||||
}
|
||||
@ -232,13 +240,13 @@ namespace MiscServices {
|
||||
void InputMethodAbility::ShowInputWindow()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::ShowInputWindow");
|
||||
eventTarget_->Emit("keyboardShow",nullptr);
|
||||
eventTarget_->Emit("keyboardShow", nullptr);
|
||||
}
|
||||
|
||||
void InputMethodAbility::DissmissInputWindow()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::DissmissInputWindow");
|
||||
eventTarget_->Emit("keyboardHide",nullptr);
|
||||
eventTarget_->Emit("keyboardHide", nullptr);
|
||||
}
|
||||
|
||||
bool InputMethodAbility::InsertText(const std::string text)
|
||||
|
@ -52,7 +52,10 @@ namespace MiscServices {
|
||||
} else {
|
||||
IMSA_HILOGI("InputMethodCoreProxy::initializeInput Failed to write inputControlChannel");
|
||||
}
|
||||
MessageOption option { MessageOption::TF_SYNC };
|
||||
MessageOption option
|
||||
{
|
||||
MessageOption::TF_SYNC
|
||||
};
|
||||
int32_t status = Remote()->SendRequest(INITIALIZE_INPUT, data, reply, option);
|
||||
if (status != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodCoreProxy::initializeInput status = %{public}d", status);
|
||||
@ -79,7 +82,10 @@ namespace MiscServices {
|
||||
return false;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option { MessageOption::TF_SYNC };
|
||||
MessageOption option
|
||||
{
|
||||
MessageOption::TF_SYNC
|
||||
};
|
||||
|
||||
int32_t status = Remote()->SendRequest(START_INPUT, data, reply, option);
|
||||
if (status != ErrorCode::NO_ERROR) {
|
||||
@ -96,15 +102,18 @@ namespace MiscServices {
|
||||
IMSA_HILOGI("InputMethodCoreProxy::stopInput");
|
||||
MessageParcel data, reply;
|
||||
data.WriteInterfaceToken(GetDescriptor());
|
||||
MessageOption option { MessageOption::TF_SYNC };
|
||||
MessageOption option
|
||||
{
|
||||
MessageOption::TF_SYNC
|
||||
};
|
||||
int32_t status = Remote()->SendRequest(STOP_INPUT, data, reply, option);
|
||||
if (status != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodCoreProxy::stopInput status = %{public}d",status);
|
||||
IMSA_HILOGI("InputMethodCoreProxy::stopInput status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
int code = reply.ReadException();
|
||||
if (code != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGI("InputMethodCoreProxy::stopInput code = %{public}d",code);
|
||||
IMSA_HILOGI("InputMethodCoreProxy::stopInput code = %{public}d", code);
|
||||
return code;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
@ -114,7 +123,7 @@ namespace MiscServices {
|
||||
{
|
||||
IMSA_HILOGI("InputMethodCoreProxy::showKeyboard");
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr){
|
||||
if (remote == nullptr) {
|
||||
IMSA_HILOGI("InputMethodCoreProxy::showKeyboard remote is nullptr");
|
||||
return false;
|
||||
}
|
||||
@ -124,7 +133,10 @@ namespace MiscServices {
|
||||
return false;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option{ MessageOption::TF_SYNC };
|
||||
MessageOption option
|
||||
{
|
||||
MessageOption::TF_SYNC
|
||||
};
|
||||
|
||||
int32_t res = remote->SendRequest(SHOW_KEYBOARD, data, reply, option);
|
||||
if (res != ErrorCode::NO_ERROR) {
|
||||
@ -146,7 +158,10 @@ namespace MiscServices {
|
||||
return false;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option{ MessageOption::TF_SYNC };
|
||||
MessageOption option
|
||||
{
|
||||
MessageOption::TF_SYNC
|
||||
};
|
||||
|
||||
int32_t res = remote->SendRequest(HIDE_KEYBOARD, data, reply, option);
|
||||
if (res != ErrorCode::NO_ERROR) {
|
||||
@ -161,7 +176,10 @@ namespace MiscServices {
|
||||
MessageParcel data, reply;
|
||||
data.WriteInterfaceToken(GetDescriptor());
|
||||
data.WriteParcelable(&type);
|
||||
MessageOption option{ MessageOption::TF_SYNC };
|
||||
MessageOption option
|
||||
{
|
||||
MessageOption::TF_SYNC
|
||||
};
|
||||
int32_t status = Remote()->SendRequest(SET_KEYBOARD_TYPE, data, reply, option);
|
||||
if (status != ErrorCode::NO_ERROR) {
|
||||
return status;
|
||||
@ -175,7 +193,10 @@ namespace MiscServices {
|
||||
IMSA_HILOGI("InputMethodCoreProxy::getKeyboardWindowHeight");
|
||||
MessageParcel data, reply;
|
||||
data.WriteInterfaceToken(GetDescriptor());
|
||||
MessageOption option { MessageOption::TF_SYNC };
|
||||
MessageOption option
|
||||
{
|
||||
MessageOption::TF_SYNC
|
||||
};
|
||||
int32_t status = Remote()->SendRequest(GET_KEYBOARD_WINDOW_HEIGHT, data, reply, option);
|
||||
if (status != ErrorCode::NO_ERROR) {
|
||||
return status;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <chrono>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include "message_handler.h"
|
||||
#include "i_input_data_channel.h"
|
||||
#include "input_method_core_stub.h"
|
||||
@ -118,7 +118,7 @@ namespace MiscServices {
|
||||
sptr<IInputControlChannel>& inputControlChannel)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodCoreStub::initializeInput");
|
||||
if (msgHandler_==nullptr) {
|
||||
if (msgHandler_ == nullptr) {
|
||||
return ErrorCode::ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ namespace MiscServices {
|
||||
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());
|
||||
}
|
||||
@ -171,7 +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();
|
||||
@ -186,7 +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();
|
||||
@ -201,7 +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();
|
||||
@ -215,7 +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();
|
||||
@ -227,7 +227,7 @@ namespace MiscServices {
|
||||
|
||||
void InputMethodCoreStub::SetMessageHandler(MessageHandler *msgHandler)
|
||||
{
|
||||
msgHandler_=msgHandler;
|
||||
msgHandler_ = msgHandler;
|
||||
}
|
||||
}
|
||||
}
|
@ -23,18 +23,18 @@
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class InputClientProxy : public IRemoteProxy<IInputClient> {
|
||||
public:
|
||||
explicit InputClientProxy(const sptr<IRemoteObject> &object);
|
||||
~InputClientProxy() = default;
|
||||
DISALLOW_COPY_AND_MOVE(InputClientProxy);
|
||||
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 onInputReleased(int32_t retValue) override;
|
||||
int32_t setDisplayMode(int32_t mode) 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:
|
||||
static inline BrokerDelegator<InputClientProxy> delegator_;
|
||||
};
|
||||
private:
|
||||
static inline BrokerDelegator<InputClientProxy> delegator_;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
@ -47,7 +47,7 @@ class InputMethodSystemAbilityProxy : public IRemoteProxy<IInputMethodSystemAbil
|
||||
int32_t Start(sptr<InputClientStub> &client);
|
||||
int32_t Stop(sptr<InputClientStub> &client);
|
||||
|
||||
virtual int32_t getDisplayMode(int32_t *retMode) 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;
|
||||
|
@ -226,7 +226,7 @@ namespace MiscServices {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t InputMethodSystemAbilityProxy::getDisplayMode(int32_t *retMode)
|
||||
int32_t InputMethodSystemAbilityProxy::getDisplayMode(int32_t retMode)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
@ -245,7 +245,7 @@ namespace MiscServices {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(*retMode)) {
|
||||
if (!reply.ReadInt32(retMode)) {
|
||||
return ERROR_STATUS_BAD_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
|
@ -54,7 +54,7 @@ namespace MiscServices {
|
||||
virtual void stopInput(MessageParcel& data) = 0;
|
||||
virtual int32_t setInputMethodCore(sptr<IInputMethodCore> &core)=0;
|
||||
|
||||
virtual int32_t getDisplayMode(int32_t *retMode) = 0;
|
||||
virtual int32_t getDisplayMode(int32_t retMode) = 0;
|
||||
virtual int32_t getKeyboardWindowHeight(int32_t retHeight) = 0;
|
||||
virtual int32_t getCurrentKeyboardType(KeyboardType *retType) = 0;
|
||||
virtual int32_t listInputMethodEnabled(std::vector<InputMethodProperty*> *properties) = 0;
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H
|
||||
#define FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H
|
||||
#ifndef FM_IMMS_PROJECT_INPUTCONTROLCHANNELSTUB_H
|
||||
#define FM_IMMS_PROJECT_INPUTCONTROLCHANNELSTUB_H
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_stub.h"
|
||||
@ -57,4 +57,4 @@ namespace OHOS {
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H
|
||||
#endif // FM_IMMS_PROJECT_INPUTCONTROLCHANNELSTUB_H
|
||||
|
@ -45,7 +45,7 @@ namespace MiscServices {
|
||||
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) override;
|
||||
virtual int32_t getDisplayMode(int32_t *retMode) 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;
|
||||
|
@ -174,7 +174,7 @@ namespace MiscServices {
|
||||
int AddClient(int pid, int uid, int displayId, const sptr<IInputClient>& inputClient,
|
||||
const sptr<IInputDataChannel>& channel,
|
||||
const InputAttribute& attribute);
|
||||
int RemoveClient(const sptr<IInputClient>& inputClient, int *retClientNum);
|
||||
int RemoveClient(const sptr<IInputClient>& inputClient, int retClientNum);
|
||||
int StartInputMethod(int index);
|
||||
int StopInputMethod(int index);
|
||||
int ShowKeyboard(const sptr<IInputClient>& inputClient);
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include "global.h"
|
||||
|
||||
namespace OHOS {
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include "message_handler.h"
|
||||
#include "input_control_channel_stub.h"
|
||||
#include "i_input_control_channel.h"
|
||||
|
@ -37,7 +37,7 @@ namespace MiscServices {
|
||||
* @param runOnCreate
|
||||
*/
|
||||
InputMethodSystemAbility::InputMethodSystemAbility(int32_t systemAbilityId, bool runOnCreate)
|
||||
: SystemAbility(systemAbilityId, runOnCreate), state_(ServiceRunningState::STATE_NOT_START)
|
||||
: SystemAbility(systemAbilityId, runOnCreate), state_(ServiceRunningState::STATE_NOT_START)
|
||||
{
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ namespace MiscServices {
|
||||
\return ErrorCode::NO_ERROR no error
|
||||
\return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked
|
||||
*/
|
||||
int32_t InputMethodSystemAbility::getDisplayMode(int32_t *retMode)
|
||||
int32_t InputMethodSystemAbility::getDisplayMode(int32_t retMode)
|
||||
{
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
@ -209,7 +209,7 @@ namespace MiscServices {
|
||||
IMSA_HILOGE("%s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId);
|
||||
return ErrorCode::ERROR_USER_NOT_UNLOCKED;
|
||||
}
|
||||
*retMode = GetUserSession(userId)->GetDisplayMode();
|
||||
retMode = GetUserSession(userId)->GetDisplayMode();
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ namespace MiscServices {
|
||||
}
|
||||
case GET_DISPLAY_MODE: {
|
||||
int32_t mode = 0;
|
||||
int32_t status = getDisplayMode(&mode);
|
||||
int32_t status = getDisplayMode(mode);
|
||||
if (status == ErrorCode::NO_ERROR) {
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
reply.WriteInt32(mode);
|
||||
|
@ -351,7 +351,7 @@ namespace MiscServices {
|
||||
\return ErrorCode::NO_ERROR no error
|
||||
\return ErrorCode::ERROR_CLIENT_NOT_FOUND client is not found
|
||||
*/
|
||||
int PerUserSession::RemoveClient(const sptr<IInputClient>& inputClient, int *remainClientNum)
|
||||
int PerUserSession::RemoveClient(const sptr<IInputClient>& inputClient, int remainClientNum)
|
||||
{
|
||||
IMSA_HILOGE("PerUserSession::RemoveClient");
|
||||
sptr<IRemoteObject> b = inputClient->AsObject();
|
||||
@ -373,12 +373,10 @@ namespace MiscServices {
|
||||
delete clientInfo;
|
||||
mapClients.erase(it);
|
||||
|
||||
if(remainClientNum!=nullptr) {
|
||||
*remainClientNum = 0;
|
||||
for(it=mapClients.begin(); it!=mapClients.end(); ++it) {
|
||||
if (it->second->attribute.GetSecurityFlag() == flag) {
|
||||
(*remainClientNum)++;
|
||||
}
|
||||
remainClientNum = 0;
|
||||
for(it=mapClients.begin(); it!=mapClients.end(); ++it) {
|
||||
if (it->second->attribute.GetSecurityFlag() == flag) {
|
||||
remainClientNum++;
|
||||
}
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
@ -659,7 +657,7 @@ namespace MiscServices {
|
||||
if (currentClient != nullptr) {
|
||||
HideKeyboard(client);
|
||||
}
|
||||
RemoveClient(client, &remainClientNum);
|
||||
RemoveClient(client, remainClientNum);
|
||||
}
|
||||
|
||||
/*! Handle the situation a input method service died\n
|
||||
@ -1345,7 +1343,7 @@ namespace MiscServices {
|
||||
if (currentClient == interface) {
|
||||
HideKeyboard(client);
|
||||
}
|
||||
int ret = RemoveClient(client, &remainClientNum);
|
||||
int ret = RemoveClient(client, remainClientNum);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::OnReleaseInput Aborted! Failed to RemoveClient [%{public}d]\n", userId_);
|
||||
}
|
||||
|
@ -22,17 +22,16 @@
|
||||
#include "peer_holder.h"
|
||||
#include "utils.h"
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
/*! \class PlatformApiProxy
|
||||
\brief The proxy implementation of IPlatformApi
|
||||
*/
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class PlatformApiProxy : public IRemoteProxy < IPlatformApi > {
|
||||
class PlatformApiProxy : public IRemoteProxy<IPlatformApi> {
|
||||
public:
|
||||
PlatformApiProxy(const sptr<IRemoteObject>& impl)
|
||||
: IRemoteProxy < IPlatformApi >(impl)
|
||||
PlatformApiProxy(const sptr<IRemoteObject>& impl) : IRemoteProxy<IPlatformApi>(impl)
|
||||
{
|
||||
}
|
||||
|
||||
@ -40,7 +39,7 @@ namespace MiscServices {
|
||||
{
|
||||
}
|
||||
|
||||
int32_t registerCallback(const sptr < IPlatformCallback >& cb)
|
||||
int32_t registerCallback(const sptr<IPlatformCallback>& cb)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
@ -62,7 +61,7 @@ namespace MiscServices {
|
||||
return Utils::to_utf16("20210814");
|
||||
}
|
||||
|
||||
sptr < IInputMethodCore > bindInputMethodService(const std::u16string& packageName,
|
||||
sptr<IInputMethodCore> bindInputMethodService(const std::u16string& packageName,
|
||||
const std::u16string& intention, int userId)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
@ -104,7 +103,7 @@ namespace MiscServices {
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
|
||||
sptr < IRemoteObject > createWindowToken(int userId, int displayId, const std::u16string& packageName)
|
||||
sptr<IRemoteObject> createWindowToken(int userId, int displayId, const std::u16string& packageName)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
|
@ -26,8 +26,7 @@ namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class PlatformCallbackProxy : public IRemoteProxy<IPlatformCallback> {
|
||||
public:
|
||||
PlatformCallbackProxy(const sptr < IRemoteObject >& impl)
|
||||
: IRemoteProxy < IPlatformCallback >(impl)
|
||||
PlatformCallbackProxy(const sptr<IRemoteObject>& impl) : IRemoteProxy<IPlatformCallback>(impl)
|
||||
{
|
||||
}
|
||||
|
||||
@ -35,7 +34,7 @@ namespace MiscServices {
|
||||
{
|
||||
}
|
||||
|
||||
void notifyEvent(int eventId, int userId, const std::vector < std::u16string >& eventContent)
|
||||
void notifyEvent(int eventId, int userId, const std::vector<std::u16string>& eventContent)
|
||||
{
|
||||
(void)eventId;
|
||||
(void)userId;
|
||||
|
@ -20,21 +20,16 @@
|
||||
#include <thread>
|
||||
#include <string>
|
||||
#include "global.h"
|
||||
#include "ability_manager_interface.h"
|
||||
#include "ability_connect_callback_proxy.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "want.h"
|
||||
#include "input_method_ability_connection_stub.h"
|
||||
#include "ability_connect_callback_proxy.h"
|
||||
#include "sa_mgr_client.h"
|
||||
#include "element_name.h"
|
||||
#include "input_method_ability.h"
|
||||
#include "input_method_agent_stub.h"
|
||||
#include "input_method_core_stub.h"
|
||||
#include "input_control_channel_stub.h"
|
||||
#include "input_attribute.h"
|
||||
#include "message_handler.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::MiscServices;
|
||||
using namespace OHOS::AAFwk;
|
||||
|
||||
class InputMethodAbilityTest : public testing::Test {
|
||||
public:
|
||||
@ -62,4 +57,98 @@ void InputMethodAbilityTest::SetUp(void)
|
||||
void InputMethodAbilityTest::TearDown(void)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityTest::TearDown");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Ima001
|
||||
* @tc.desc: Checkout IInputMethodAgent.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityTest, Ima001, TestSize.Level0)
|
||||
{
|
||||
sptr<InputMethodAgentStub> mInputMethodAgentStub = new InputMethodAgentStub();
|
||||
MessageParcel data;
|
||||
auto ret = data.WriteRemoteObject(mInputMethodAgentStub->AsObject());
|
||||
ASSERT_TRUE(ret);
|
||||
auto remoteObject = data.ReadRemoteObject();
|
||||
sptr<IInputMethodAgent> iface = iface_cast<IInputMethodAgent>(remoteObject);
|
||||
ASSERT_TRUE(iface != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Ima002
|
||||
* @tc.desc: Checkout IInputMethodCore.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityTest, Ima002, TestSize.Level0)
|
||||
{
|
||||
sptr<InputMethodCoreStub> mInputMethodCoreStub = new InputMethodCoreStub(0);
|
||||
MessageParcel data;
|
||||
auto ret = data.WriteRemoteObject(mInputMethodCoreStub->AsObject());
|
||||
ASSERT_TRUE(ret);
|
||||
auto remoteObject = data.ReadRemoteObject();
|
||||
sptr<IInputMethodCore> iface = iface_cast<IInputMethodCore>(remoteObject);
|
||||
ASSERT_TRUE(iface != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Ima003
|
||||
* @tc.desc: Checkout IInputControlChannel.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityTest, Ima003, TestSize.Level0)
|
||||
{
|
||||
sptr<InputControlChannelStub> mInputControlChannelStub = new InputControlChannelStub(0);
|
||||
MessageParcel data;
|
||||
auto ret = data.WriteRemoteObject(mInputControlChannelStub->AsObject());
|
||||
ASSERT_TRUE(ret);
|
||||
auto remoteObject = data.ReadRemoteObject();
|
||||
sptr<IInputControlChannel> iface = iface_cast<IInputControlChannel>(remoteObject);
|
||||
ASSERT_TRUE(iface != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Ima004
|
||||
* @tc.desc: Checkout the function of getInstance.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityTest, Ima004, TestSize.Level0)
|
||||
{
|
||||
auto ima = InputMethodAbility::GetInstance();
|
||||
ASSERT_TRUE(ima != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Ima005
|
||||
* @tc.desc: Checkout the serialization of InputAttribute.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityTest, Ima005, TestSize.Level0)
|
||||
{
|
||||
sptr<InputAttribute> mInputAttribute = new InputAttribute();
|
||||
mInputAttribute->SetInputPattern(InputAttribute::PATTERN_PASSWORD);
|
||||
MessageParcel data;
|
||||
auto ret = data.WriteParcelable(mInputAttribute);
|
||||
ASSERT_TRUE(ret);
|
||||
sptr<InputAttribute> deserialization = data.ReadParcelable<InputAttribute>();
|
||||
ASSERT_TRUE(deserialization != nullptr);
|
||||
ASSERT_TRUE(deserialization->GetSecurityFlag());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Ima006
|
||||
* @tc.desc: Checkout the serialization of KeyboardType.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodAbilityTest, Ima006, TestSize.Level0)
|
||||
{
|
||||
int32_t def_value = 2021;
|
||||
sptr<KeyboardType> mKeyboardType = new KeyboardType();
|
||||
mKeyboardType->setId(def_value);
|
||||
MessageParcel data;
|
||||
auto ret = data.WriteParcelable(mKeyboardType);
|
||||
ASSERT_TRUE(ret);
|
||||
sptr<KeyboardType> deserialization = data.ReadParcelable<KeyboardType>();
|
||||
ASSERT_TRUE(deserialization != nullptr);
|
||||
ASSERT_TRUE(deserialization->getId() == def_value);
|
||||
}
|
@ -29,6 +29,7 @@
|
||||
#include "input_client_stub.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "input_method_setting.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS;
|
||||
@ -83,10 +84,114 @@ void InputMethodControllerTest::TearDown(void)
|
||||
|
||||
/**
|
||||
* @tc.name: Imc001
|
||||
* @tc.desc: Bind IMSA.
|
||||
* @tc.desc: Get Imsa Proxy.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodControllerTest, Imc001, TestSize.Level0)
|
||||
{
|
||||
auto systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
ASSERT_TRUE(systemAbilityManager != nullptr);
|
||||
auto systemAbility = systemAbilityManager->GetSystemAbility(INPUT_METHOD_SYSTEM_ABILITY_ID, "");
|
||||
ASSERT_TRUE(systemAbility != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Imc002
|
||||
* @tc.desc: Checkout IInputDataChannel.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodControllerTest, Imc002, TestSize.Level0)
|
||||
{
|
||||
sptr<InputDataChannelStub> mInputDataChannel = new InputDataChannelStub();
|
||||
MessageParcel data;
|
||||
auto ret = data.WriteRemoteObject(mInputDataChannel->AsObject());
|
||||
ASSERT_TRUE(ret);
|
||||
auto remoteObject = data.ReadRemoteObject();
|
||||
sptr<IInputDataChannel> iface = iface_cast<IInputDataChannel>(remoteObject);
|
||||
ASSERT_TRUE(iface != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Imc003
|
||||
* @tc.desc: Bind IMSA.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodControllerTest, Imc003, TestSize.Level0)
|
||||
{
|
||||
sptr<InputClientStub> mClient = new InputClientStub();
|
||||
MessageParcel data;
|
||||
auto ret = data.WriteRemoteObject(mClient->AsObject());
|
||||
ASSERT_TRUE(ret);
|
||||
auto remoteObject = data.ReadRemoteObject();
|
||||
sptr<IInputClient> iface = iface_cast<IInputClient>(remoteObject);
|
||||
ASSERT_TRUE(iface != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Imc004
|
||||
* @tc.desc: Checkout setting.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodControllerTest, Imc004, TestSize.Level0)
|
||||
{
|
||||
InputMethodSetting setting;
|
||||
std::u16string key = InputMethodSetting::CURRENT_INPUT_METHOD_TAG;
|
||||
std::u16string oldValue = setting.GetValue(key);
|
||||
std::u16string newValue = u"testCurrentImeId";
|
||||
setting.SetValue(key, newValue);
|
||||
ASSERT_TRUE(newValue == setting.GetValue(key));
|
||||
|
||||
setting.SetValue(key, oldValue);
|
||||
ASSERT_TRUE(oldValue == setting.GetValue(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Imc005
|
||||
* @tc.desc: Checkout setting.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodControllerTest, Imc005, TestSize.Level0)
|
||||
{
|
||||
InputMethodSetting setting;
|
||||
std::u16string curIme = setting.GetCurrentInputMethod();
|
||||
std::u16string testIme = u"testCurrentImeId";
|
||||
setting.SetCurrentInputMethod(testIme);
|
||||
ASSERT_TRUE(testIme == setting.GetCurrentInputMethod());
|
||||
|
||||
setting.SetCurrentInputMethod(curIme);
|
||||
ASSERT_TRUE(curIme == setting.GetCurrentInputMethod());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Imc006
|
||||
* @tc.desc: Checkout setting.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodControllerTest, Imc006, TestSize.Level0)
|
||||
{
|
||||
InputMethodSetting setting;
|
||||
int32_t curType = setting.GetCurrentKeyboardType();
|
||||
int32_t testType = 10;
|
||||
setting.SetCurrentKeyboardType(testType);
|
||||
ASSERT_TRUE(testType == setting.GetCurrentKeyboardType());
|
||||
|
||||
setting.SetCurrentKeyboardType(curType);
|
||||
ASSERT_TRUE(curType == setting.GetCurrentKeyboardType());
|
||||
|
||||
curType = setting.GetCurrentKeyboardType();
|
||||
setting.SetCurrentKeyboardType(testType);
|
||||
ASSERT_TRUE(testType == setting.GetCurrentKeyboardType());
|
||||
|
||||
setting.SetCurrentKeyboardType(curType);
|
||||
ASSERT_TRUE(curType == setting.GetCurrentKeyboardType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Imc007
|
||||
* @tc.desc: Bind IMSA.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputMethodControllerTest, Imc007, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("IMC TEST START");
|
||||
sptr<InputMethodController> imc = InputMethodController::GetInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user