Signed-off-by: zhouyongfei <zhouyongfei@huawei.com>
This commit is contained in:
zhouyongfei 2021-09-15 20:33:09 +08:00
parent cb8bd91313
commit cc82dbf2ff
7 changed files with 1310 additions and 1304 deletions

View File

@ -13,24 +13,33 @@ Input Method Framework, is used to connect the application and input method. the
The input method framework currently has four modules, as follows:
1. Application client
Path: /base/miscservices/inputmethod/frameworks/inputmethod_controller
Function: realize the service delivery of application and input method framework, including the binding between application and input method service, application display and hiding request for input method, etc
2. Input method client
Path: /base/miscservices/inputmethod/frameworks/inputmethod_ability
Function: the intermediate bridge between input method framework service and input method delivery, including monitoring the current status of input method, etc
3. Input method service
Path: /base/miscservices/inputmethod/services
Function: as the core of the input method framework, the main processing logic of the input method is completed here
4. Input method JS interface
Path: /base/miscservices/inputmethod/interfaces/kits/JS
Function: the temporarily exposed JS interface is mainly reserved for calling input methods
####Main functions supported by the framework
1. Click in the edit attribute control to invoke the default input method application through the input method framework
2. Typing can be carried out through the input method application, and characters can be input to the application client on the screen
####Participation contribution

View File

@ -10,19 +10,27 @@
输入法框架目前有四大模块,具体如下:
1. 应用客户端
路径:/base/miscservices/inputmethod/frameworks/inputmethod_controller
作用:实现应用和输入法框架服务交付,包括应用与输入法服务的绑定、应用对输入法的显示和隐藏请求等等
2. 输入法客户端
路径:/base/miscservices/inputmethod/frameworks/inputmethod_ability
作用:实现输入法框架服务与输入法交付的中间桥梁,包括监听输入法当前的状态等等
3. 输入法服务
路径:/base/miscservices/inputmethod/services
作用:作为输入法框架的核心,输入法的主要处理逻辑都是在这里完成
4. 输入法Js接口
路径:/base/miscservices/inputmethod/interfaces/kits/js
作用暂时对外暴露的js接口主要是留给输入法进行调用使用的
#### 框架主要支持功能

View File

@ -71,7 +71,7 @@ namespace MiscServices {
sptr<InputMethodSystemAbilityProxy> mImms;
sptr<ImsaDeathRecipient> deathRecipient_;
sptr<InputMethodAgentProxy> mAgent;
sptr<OnTextChangedListener> textListener;
OnTextChangedListener* textListener;
InputAttribute mAttribute;
static std::mutex instanceLock_;

View File

@ -139,6 +139,7 @@ using namespace MessageID;
case MSG_ID_EXIT_SERVICE:{
MessageParcel* data = msg->msgContent_;
int32_t ret = data->ReadInt32();
textListener = nullptr;
IMSA_HILOGI("MSG_ID_EXIT_SERVICE : %{public}d", ret);
break;
}

View File

@ -41,156 +41,149 @@
#include "input_method_ability.h"
namespace OHOS {
namespace MiscServices {
namespace MiscServices {
class RemoteObjectDeathRecipient : public IRemoteObject::DeathRecipient {
public:
RemoteObjectDeathRecipient(int userId, int msgId);
~RemoteObjectDeathRecipient();
void OnRemoteDied(const wptr<IRemoteObject>& who) override;
private :
int userId_; //!< the id of the user to whom the object is linking
int msgId_; //!< the message id can be MessageID::MSG_ID_CLIENT_DIED and MessageID::MSG_ID_IMS_DIED
};
/*! \class ClientInfo
\brief The class defines the details of an input client.
*/
class ClientInfo {
public:
int pid; //!< the process id of the process in which the input client is running
int uid; //!< the uid of the process in which the input client is running
int userId; //!< the user if of the user under which the input client is running
int displayId; //!< the display id on which the input client is showing
sptr<IInputClient> client; //!< the remote object handler for the service to callback to the input client
sptr<IInputDataChannel> channel; //!< the remote object handler for input method service callback to input client
InputAttribute attribute; //!< the input attribute of the input client
class RemoteObjectDeathRecipient : public IRemoteObject::DeathRecipient {
public:
RemoteObjectDeathRecipient(int userId, int msgId);
~RemoteObjectDeathRecipient();
void OnRemoteDied(const wptr<IRemoteObject>& who) override;
private :
int userId_; //!< the id of the user to whom the object is linking
int msgId_; //!< the message id can be MessageID::MSG_ID_CLIENT_DIED and MessageID::MSG_ID_IMS_DIED
};
ClientInfo(int pid, int uid, int userId, int displayId, const sptr<IInputClient>& client,
const sptr<IInputDataChannel>& channel, const InputAttribute& attribute)
{
this->pid = pid;
this->uid = uid;
this->userId = userId;
this->displayId = displayId;
this->client = client;
this->channel = channel;
this->attribute = attribute;
};
/*! \class ClientInfo
\brief The class defines the details of an input client.
*/
class ClientInfo {
public:
int pid; //!< the process id of the process in which the input client is running
int uid; //!< the uid of the process in which the input client is running
int userId; //!< the user if of the user under which the input client is running
int displayId; //!< the display id on which the input client is showing
sptr<IInputClient> client; //!< the remote object handler for the service to callback to the input client
sptr<IInputDataChannel> channel; //!< the remote object handler for input method service callback to input client
InputAttribute attribute; //!< the input attribute of the input client
~ClientInfo()
{
this->client = nullptr;
this->channel = nullptr;
};
};
ClientInfo(int pid, int uid, int userId, int displayId, const sptr<IInputClient>& client,
const sptr<IInputDataChannel>& channel, const InputAttribute& attribute)
{
this->pid = pid;
this->uid = uid;
this->userId = userId;
this->displayId = displayId;
this->client = client;
this->channel = channel;
this->attribute = attribute;
};
/*! \class PerUserSession
\brief The class provides session management in input method management service
~ClientInfo()
{
this->client = nullptr;
this->channel = nullptr;
};
};
This class manages the sessions between input clients and input method engines for each unlocked user.
*/
class PerUserSession {
enum {
DEFAULT_IME = 0, //!< index for default input method service
SECURITY_IME = 1, //!< index for security input method service
MAX_IME = 2, //!< the maximum count of ims started for a user
};
/*! \class PerUserSession
\brief The class provides session management in input method management service
public:
explicit PerUserSession(int userId);
~PerUserSession();
This class manages the sessions between input clients and input method engines for each unlocked user.
*/
class PerUserSession {
enum {
DEFAULT_IME = 0, //!< index for default input method service
SECURITY_IME = 1, //!< index for security input method service
MAX_IME = 2, //!< the maximum count of ims started for a user
};
void SetCurrentIme(InputMethodProperty* ime);
void SetSecurityIme(InputMethodProperty* ime);
void SetInputMethodSetting(InputMethodSetting* setting);
void ResetIme(InputMethodProperty* defaultIme, InputMethodProperty* securityIme);
void OnPackageRemoved(const std::u16string& packageName);
public:
explicit PerUserSession(int userId);
~PerUserSession();
int GetDisplayMode();
int GetKeyboardWindowHeight(int *retHeight);
KeyboardType* GetCurrentKeyboardType();
void SetCurrentIme(InputMethodProperty* ime);
void SetSecurityIme(InputMethodProperty* ime);
void SetInputMethodSetting(InputMethodSetting* setting);
void ResetIme(InputMethodProperty* defaultIme, InputMethodProperty* securityIme);
void OnPackageRemoved(const std::u16string& packageName);
int OnSettingChanged(const std::u16string& key, const std::u16string& value);
void Dump(int fd);
void CreateWorkThread(MessageHandler& handler);
void JoinWorkThread();
void SetInputMethodAbility(sptr<InputMethodAbility> &inputMethodAbility);
static void BindInputAbility();
private:
int userId_; //!< the id of the user to whom the object is linking
int userState; //!< the state of the user to whom the object is linking
int displayId; //!< the id of the display screen on which the user is
int currentIndex;
std::map<sptr<IRemoteObject>, ClientInfo*> mapClients; //!< a map to manage the input clients connected to the service
int GetDisplayMode();
int GetKeyboardWindowHeight(int *retHeight);
KeyboardType* GetCurrentKeyboardType();
InputMethodProperty* currentIme[MAX_IME]; //!< 0 - the default ime. 1 - security ime
int OnSettingChanged(const std::u16string& key, const std::u16string& value);
void Dump(int fd);
void CreateWorkThread(MessageHandler& handler);
void JoinWorkThread();
void SetInputMethodAbility(sptr<InputMethodAbility> &inputMethodAbility);
static void BindInputAbility();
private:
int userId_; //!< the id of the user to whom the object is linking
int userState; //!< the state of the user to whom the object is linking
int displayId; //!< the id of the display screen on which the user is
int currentIndex;
std::map<sptr<IRemoteObject>, ClientInfo*> mapClients; //!< a map to manage the input clients connected to the service
/*!< \n key is the remote IInputClient handler
\n value is an object of an ClientInfo */
InputControlChannelStub* localControlChannel[MAX_IME]; //!< inputControlChannel object used by the local process
sptr<IInputControlChannel> inputControlChannel[MAX_IME]; //!< channels between the service and input method service
sptr<IInputMethodCore> imsCore[MAX_IME]; //!< the remote handlers of input method service
sptr<IRemoteObject> inputMethodToken[MAX_IME]; //!< the window token of keyboard
int currentKbdIndex[MAX_IME]; //!< current keyboard index
int lastImeIndex; //!< The last ime which showed keyboard
InputMethodSetting* inputMethodSetting; //!< The pointer referred to the object in PerUserSetting
int currentDisplayMode; //!< the display mode of the current keyboard
InputMethodProperty* currentIme[MAX_IME]; //!< 0 - the default ime. 1 - security ime
/*!< \n The pointers are referred to the objects in the PerUserSetting */
sptr<IInputMethodAgent> imsAgent;
InputChannel* imsChannel; //!< the write channel created by input method service
sptr<IInputClient> currentClient; //!< the current input client
sptr<IInputClient> needReshowClient; //!< the input client for which keyboard need to re-show
InputControlChannelStub* localControlChannel[MAX_IME]; //!< inputControlChannel object used by the local process
sptr<IInputControlChannel> inputControlChannel[MAX_IME]; //!< channels between the service and input method service
sptr<IInputMethodCore> imsCore[MAX_IME]; //!< the remote handlers of input method service
sptr<IRemoteObject> inputMethodToken[MAX_IME]; //!< the window token of keyboard
int currentKbdIndex[MAX_IME]; //!< current keyboard index
int lastImeIndex; //!< The last ime which showed keyboard
InputMethodSetting* inputMethodSetting; //!< The pointer referred to the object in PerUserSetting
int currentDisplayMode; //!< the display mode of the current keyboard
sptr<RemoteObjectDeathRecipient> clientDeathRecipient; //!< remote object death monitor for input client
sptr<RemoteObjectDeathRecipient> imsDeathRecipient; //!< remote object death monitor for input method service
MessageHandler* msgHandler = nullptr; //!< message handler working with Work Thread
std::thread workThreadHandler; //!< work thread handler
std::mutex mtx; //!< mutex to lock the operations among multi work threads
sptr<AAFwk::AbilityConnectionProxy> connCallback;
sptr<InputMethodAbility> inputMethodAbility_;
sptr<IInputMethodAgent> imsAgent;
InputChannel* imsChannel; //!< the write channel created by input method service
sptr<IInputClient> currentClient; //!< the current input client
sptr<IInputClient> needReshowClient; //!< the input client for which keyboard need to re-show
sptr<RemoteObjectDeathRecipient> clientDeathRecipient; //!< remote object death monitor for input client
sptr<RemoteObjectDeathRecipient> imsDeathRecipient; //!< remote object death monitor for input method service
MessageHandler* msgHandler = nullptr; //!< message handler working with Work Thread
std::thread workThreadHandler; //!< work thread handler
std::mutex mtx; //!< mutex to lock the operations among multi work threads
sptr<AAFwk::AbilityConnectionProxy> connCallback;
sptr<InputMethodAbility> inputMethodAbility_;
PerUserSession(const PerUserSession&);
PerUserSession& operator= (const PerUserSession&);
PerUserSession(const PerUserSession&&);
PerUserSession& operator= (const PerUserSession&&);
int IncreaseOrResetImeError(bool resetFlag, int imeIndex);
KeyboardType* GetKeyboardType(int imeIndex, int typeIndex);
void ResetCurrentKeyboardType(int imeIndex);
int OnCurrentKeyboardTypeChanged(int index, const std::u16string& value);
void DumpClientInfo(int fd, const ClientInfo& clientInfo);
void DumpCurrentSession(int fd);
void CopyInputMethodService(int imeIndex);
ClientInfo* GetClientInfo(const sptr<IInputClient>& inputClient);
void WorkThread();
void OnPrepareInput(Message* msg);
void OnReleaseInput(Message* msg);
void OnStartInput(Message* msg);
void OnStopInput(Message* msg);
void OnClientDied(const wptr<IRemoteObject>& who);
void OnImsDied(const wptr<IRemoteObject>& who);
void OnHideKeyboardSelf(int flags);
void OnAdvanceToNext();
void OnSetDisplayMode(int mode);
void OnRestartIms(int index, const std::u16string& imeId);
void OnUserLocked();
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 StartInputMethod(int index);
int StopInputMethod(int index);
int ShowKeyboard(const sptr<IInputClient>& inputClient);
int HideKeyboard(const sptr<IInputClient>& inputClient);
void SetDisplayId(int displayId);
int GetImeIndex(const sptr<IInputClient>& inputClient);
static sptr<AAFwk::IAbilityManager> GetAbilityManagerService();
void onSetInputMethodCore(Message* msg);
};
}
PerUserSession(const PerUserSession&);
PerUserSession& operator= (const PerUserSession&);
PerUserSession(const PerUserSession&&);
PerUserSession& operator= (const PerUserSession&&);
int IncreaseOrResetImeError(bool resetFlag, int imeIndex);
KeyboardType* GetKeyboardType(int imeIndex, int typeIndex);
void ResetCurrentKeyboardType(int imeIndex);
int OnCurrentKeyboardTypeChanged(int index, const std::u16string& value);
void DumpClientInfo(int fd, const ClientInfo& clientInfo);
void DumpCurrentSession(int fd);
void CopyInputMethodService(int imeIndex);
ClientInfo* GetClientInfo(const sptr<IInputClient>& inputClient);
void WorkThread();
void OnPrepareInput(Message* msg);
void OnReleaseInput(Message* msg);
void OnStartInput(Message* msg);
void OnStopInput(Message* msg);
void OnClientDied(const wptr<IRemoteObject>& who);
void OnImsDied(const wptr<IRemoteObject>& who);
void OnHideKeyboardSelf(int flags);
void OnAdvanceToNext();
void OnSetDisplayMode(int mode);
void OnRestartIms(int index, const std::u16string& imeId);
void OnUserLocked();
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 StartInputMethod(int index);
int StopInputMethod(int index);
int ShowKeyboard(const sptr<IInputClient>& inputClient);
int HideKeyboard(const sptr<IInputClient>& inputClient);
void SetDisplayId(int displayId);
int GetImeIndex(const sptr<IInputClient>& inputClient);
static sptr<AAFwk::IAbilityManager> GetAbilityManagerService();
void onSetInputMethodCore(Message* msg);
};
}
}
#endif // FM_IMMS_PROJECT_PERUSERSESSION_H

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@ public:
TextListener() {}
~TextListener() {}
void InsertText(const std::u16string& text) {
IMSA_HILOGI("IMC TEST TextListener InsertText: %{public}s", Utils::to_utf8(text).c_str());
IMSA_HILOGI("IMC TEST TextListener InsertText: %{public}s", MiscServices::Utils::to_utf8(text).c_str());
}
void DeleteBackward(int32_t length){