mirror of
https://github.com/openharmony/miscservices_inputmethod.git
synced 2026-07-18 17:24:37 -04:00
@@ -1,14 +1,14 @@
|
||||
# miscservices_inputmethod
|
||||
|
||||
####Introduction
|
||||
#### Introduction
|
||||
|
||||
Input Method Framework, is used to connect the application and input method. the application can input text through the input method
|
||||
|
||||
####Warehouse path
|
||||
#### Warehouse path
|
||||
|
||||
/base/miscservices/inputmethod
|
||||
|
||||
####Introduction to framework code
|
||||
#### Introduction to framework code
|
||||
|
||||
The input method framework currently has four modules, as follows:
|
||||
|
||||
@@ -36,12 +36,25 @@ 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
|
||||
#### 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
|
||||
|
||||
#### Debugging method
|
||||
|
||||
1. Compile command
|
||||
|
||||
./build.sh --product-name (Fill in the specific product name, such as:Hi3516DV300) --build-target inputmethod_native
|
||||
|
||||
2. push so file
|
||||
|
||||
in $root\out\ohos-arm-release\miscservices\inputmethod_native, push libinputmethod_client.z.so libinputmethod_ability.z.so
|
||||
libinputmethod_service.z.so to system/lib,and push libinputmethodability.z.so to system/lib/module, and make sure the four so files is readable at least.
|
||||
|
||||
3. reboot
|
||||
|
||||
####Participation contribution
|
||||
|
||||
1. Fork warehouse
|
||||
|
||||
@@ -39,6 +39,19 @@
|
||||
|
||||
2.通过输入法应用可以进行打字,并上屏输入字符到应用客户端
|
||||
|
||||
#### 本框架编译调试方法
|
||||
|
||||
1. 编译命令
|
||||
|
||||
./build.sh --product-name (填写具体的产品名,如:Hi3516DV300) --build-target inputmethod_native
|
||||
|
||||
2. 推送so文件
|
||||
|
||||
将工程目录下out\ohos-arm-release\miscservices\inputmethod_native下的libinputmethod_client.z.so libinputmethod_ability.z.so
|
||||
libinputmethod_service.z.so三大so推送到system/lib,将libinputmethodability.z.so推送到system/lib/module下,并确保四个so至少为可读状态。
|
||||
|
||||
3. 重启设备
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,7 @@ import { AsyncCallback } from './basic';
|
||||
/**
|
||||
* inputmethod
|
||||
*
|
||||
* @since 6
|
||||
* @import inputmethod from '@ohos.inputmethod';
|
||||
* @since 7
|
||||
* @devices phone, tablet, tv, wearable
|
||||
*/
|
||||
declare namespace inputMethodAbility {
|
||||
|
||||
@@ -27,14 +27,14 @@ napi_value JS_Constructor(napi_env env, napi_callback_info cbInfo)
|
||||
void* data = nullptr;
|
||||
napi_get_cb_info(env, cbInfo, nullptr, nullptr, &thisVar, &data);
|
||||
|
||||
OHOS::MiscServices::EventTarget* imeAbility = new OHOS::MiscServices::EventTarget(env,thisVar);
|
||||
napi_wrap(env, thisVar, imeAbility,
|
||||
OHOS::MiscServices::EventTarget *eventTarget = new OHOS::MiscServices::EventTarget(env,thisVar);
|
||||
napi_wrap(env, thisVar, eventTarget,
|
||||
[](napi_env env, void* data, void* hint){
|
||||
EventTarget* imeAbility = (EventTarget*)data;
|
||||
delete imeAbility;
|
||||
EventTarget *eventTarget = (EventTarget*)data;
|
||||
delete eventTarget;
|
||||
},
|
||||
nullptr, nullptr);
|
||||
OHOS::sptr<EventTarget> eventTarget_=imeAbility;
|
||||
OHOS::sptr<EventTarget> eventTarget_ = eventTarget;
|
||||
InputMethodAbility::GetInstance()->setEventTarget(eventTarget_);
|
||||
return thisVar;
|
||||
}
|
||||
@@ -48,8 +48,8 @@ napi_value JS_InsertText(napi_env env, napi_callback_info cbInfo)
|
||||
void* data = nullptr;
|
||||
napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, &data);
|
||||
|
||||
EventTarget* imeAbility = nullptr;
|
||||
napi_unwrap(env, thisVar, (void **)&imeAbility);
|
||||
EventTarget *eventTarget = nullptr;
|
||||
napi_unwrap(env, thisVar, (void **)&eventTarget);
|
||||
|
||||
char type[64] = { 0 };
|
||||
size_t typeLen = 0;
|
||||
@@ -72,8 +72,8 @@ napi_value JS_DeleteBackward(napi_env env, napi_callback_info cbInfo)
|
||||
void* data = nullptr;
|
||||
napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, &data);
|
||||
|
||||
EventTarget* imeAbility = nullptr;
|
||||
napi_unwrap(env, thisVar, (void **)&imeAbility);
|
||||
EventTarget *eventTarget = nullptr;
|
||||
napi_unwrap(env, thisVar, (void **)&eventTarget);
|
||||
|
||||
int32_t value32 = 0;
|
||||
napi_get_value_int32(env, argv[0], &value32);
|
||||
@@ -93,8 +93,8 @@ napi_value JS_HideKeyboardSelf(napi_env env, napi_callback_info cbInfo)
|
||||
void* data = nullptr;
|
||||
napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, &data);
|
||||
|
||||
EventTarget* imeAbility = nullptr;
|
||||
napi_unwrap(env, thisVar, (void **)&imeAbility);
|
||||
EventTarget *eventTarget = nullptr;
|
||||
napi_unwrap(env, thisVar, (void **)&eventTarget);
|
||||
|
||||
InputMethodAbility::GetInstance()->HideKeyboardSelf();
|
||||
|
||||
@@ -113,8 +113,8 @@ napi_value JS_On(napi_env env, napi_callback_info cbInfo)
|
||||
void* data = nullptr;
|
||||
napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, &data);
|
||||
|
||||
EventTarget* imeAbility = nullptr;
|
||||
napi_unwrap(env, thisVar, (void **)&imeAbility);
|
||||
EventTarget *eventTarget = nullptr;
|
||||
napi_unwrap(env, thisVar, (void **)&eventTarget);
|
||||
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "requires 2 parameter");
|
||||
|
||||
@@ -131,7 +131,7 @@ napi_value JS_On(napi_env env, napi_callback_info cbInfo)
|
||||
napi_get_value_string_utf8(env, argv[0], type, sizeof(type), &typeLen);
|
||||
|
||||
IMSA_HILOGI("call ima on function");
|
||||
imeAbility->On((const char*)type, argv[1]);
|
||||
eventTarget->On((const char*)type, argv[1]);
|
||||
|
||||
napi_value result = nullptr;
|
||||
napi_get_undefined(env, &result);
|
||||
@@ -148,8 +148,8 @@ napi_value JS_Off(napi_env env, napi_callback_info cbInfo)
|
||||
void* data = nullptr;
|
||||
napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, &data);
|
||||
|
||||
EventTarget* imeAbility = nullptr;
|
||||
napi_unwrap(env, thisVar, (void **)&imeAbility);
|
||||
EventTarget *eventTarget = nullptr;
|
||||
napi_unwrap(env, thisVar, (void **)&eventTarget);
|
||||
|
||||
NAPI_ASSERT(env, argc >= requireArgc, "requires 2 parameter");
|
||||
|
||||
@@ -165,10 +165,9 @@ napi_value JS_Off(napi_env env, napi_callback_info cbInfo)
|
||||
|
||||
if (argc > requireArgc) {
|
||||
NAPI_ASSERT(env, eventValueType == napi_function, "type mismatch for parameter 2");
|
||||
|
||||
imeAbility->Off(type, argv[1]);
|
||||
eventTarget->Off(type, argv[1]);
|
||||
} else {
|
||||
imeAbility->Off(type);
|
||||
eventTarget->Off(type);
|
||||
}
|
||||
|
||||
delete type;
|
||||
@@ -191,7 +190,7 @@ napi_value InputMethodAbilityInit(napi_env env, napi_value exports)
|
||||
DECLARE_NAPI_FUNCTION("off", JS_Off),
|
||||
};
|
||||
napi_define_class(env, className, sizeof(className),JS_Constructor, nullptr,
|
||||
sizeof(desc) / sizeof(desc[0]), desc, &constructor);
|
||||
sizeof(desc) / sizeof(desc[0]), desc, &constructor);
|
||||
napi_set_named_property(env, exports, "InputMethodAbility", constructor);
|
||||
return exports;
|
||||
}
|
||||
|
||||
+77
-79
@@ -34,17 +34,17 @@ using BRemoteObject = IPCObjectStub;
|
||||
#define INPUTMETHOD_DEBUG 0
|
||||
|
||||
#define LOG_INFO(fmt, args...) \
|
||||
LogTimeStamp();printf("I %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
|
||||
LogTimeStamp(); printf("I %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
|
||||
|
||||
#define LOG_ERROR(fmt, args...) \
|
||||
LogTimeStamp();printf("E %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
|
||||
LogTimeStamp(); printf("E %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
|
||||
|
||||
#define LOG_WARNING(fmt, args...) \
|
||||
LogTimeStamp();printf("W %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
|
||||
LogTimeStamp(); printf("W %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
|
||||
|
||||
#if DEBUG
|
||||
#define LOG_DEBUG(fmt, args...) \
|
||||
LogTimeStamp();printf("D %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
|
||||
LogTimeStamp(); printf("D %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
|
||||
#else
|
||||
#define LOG_DEBUG(fmt, args...)
|
||||
#endif
|
||||
@@ -52,100 +52,99 @@ using BRemoteObject = IPCObjectStub;
|
||||
void LogTimeStamp();
|
||||
|
||||
namespace CommonEvent {
|
||||
//! the events handled in input method management system
|
||||
// the events handled in input method management system
|
||||
enum {
|
||||
COMMON_EVENT_USER_STARTED = 10001, /*!< a user is started. */
|
||||
COMMON_EVENT_USER_STOPPED = 10002, /*!< a user is stopped. */
|
||||
COMMON_EVENT_USER_UNLOCKED = 10003, /*!< a user is unlocked. */
|
||||
COMMON_EVENT_USER_LOCKED = 10004, /*!< a user is locked. */
|
||||
COMMON_EVENT_SETTING_CHANGED = 10005, /*!< input method setting data is changed. */
|
||||
COMMON_EVENT_PACKAGE_ADDED = 10006, /*!< a package is installed. */
|
||||
COMMON_EVENT_PACKAGE_REMOVED = 10007, /*!< a package is removed */
|
||||
COMMON_EVENT_USER_STARTED = 10001, // a user is started.
|
||||
COMMON_EVENT_USER_STOPPED = 10002, // a user is stopped.
|
||||
COMMON_EVENT_USER_UNLOCKED = 10003, // a user is unlocked.
|
||||
COMMON_EVENT_USER_LOCKED = 10004, // a user is locked.
|
||||
COMMON_EVENT_SETTING_CHANGED = 10005, // input method setting data is changed.
|
||||
COMMON_EVENT_PACKAGE_ADDED = 10006, // a package is installed.
|
||||
COMMON_EVENT_PACKAGE_REMOVED = 10007, // a package is removed
|
||||
};
|
||||
};
|
||||
|
||||
//! User State
|
||||
// User State
|
||||
namespace UserState {
|
||||
/*! The states of a user in the system. */
|
||||
// The states of a user in the system.
|
||||
enum {
|
||||
USER_STATE_NOT_AVAILABLE = -1,
|
||||
USER_STATE_STARTED = 0, /*!< a user is started. */
|
||||
USER_STATE_UNLOCKED, /*!< a user is unlocked. */
|
||||
USER_STATE_STARTED = 0, // a user is started.
|
||||
USER_STATE_UNLOCKED, // a user is unlocked.
|
||||
};
|
||||
};
|
||||
|
||||
//! Error Code
|
||||
// Error Code
|
||||
namespace ErrorCode {
|
||||
/*! Error Code definition in the input method management system */
|
||||
// Error Code definition in the input method management system
|
||||
enum {
|
||||
ERROR_STATUS_UNKNOWN_ERROR = (-2147483647 - 1), //!< unknown error
|
||||
ERROR_STATUS_NO_MEMORY = -ENOMEM, //!< no memory
|
||||
ERROR_STATUS_INVALID_OPERATION = -ENOSYS, //!< invalid operation
|
||||
ERROR_STATUS_BAD_VALUE = -EINVAL, //!< bad value
|
||||
ERROR_STATUS_BAD_TYPE = ERROR_STATUS_UNKNOWN_ERROR+1, //!< bad type
|
||||
ERROR_STATUS_NAME_NOT_FOUND = -ENOENT, //!< name not found
|
||||
ERROR_STATUS_PERMISSION_DENIED = -EPERM, //!< permission denied
|
||||
ERROR_STATUS_NO_INIT = -ENODEV, //!< no init
|
||||
ERROR_STATUS_ALREADY_EXISTS = -EEXIST, //!< already exist
|
||||
ERROR_STATUS_DEAD_OBJECT = -EPIPE, //!< dead object
|
||||
ERROR_STATUS_FAILED_TRANSACTION = ERROR_STATUS_UNKNOWN_ERROR+2, //!< failed transaction
|
||||
ERROR_STATUS_BAD_INDEX = -EOVERFLOW, //!< bad index
|
||||
ERROR_STATUS_NOT_ENOUGH_DATA = -ENODATA, //!< not enough data
|
||||
ERROR_STATUS_WOULD_BLOCK = -EWOULDBLOCK, //!< would block
|
||||
ERROR_STATUS_TIMED_OUT = -ETIMEDOUT, //!< time out
|
||||
ERROR_STATUS_UNKNOWN_TRANSACTION = -EBADMSG, //!< unknown transaction
|
||||
ERROR_STATUS_FDS_NOT_ALLOWED = ERROR_STATUS_UNKNOWN_ERROR+7, //!< fds not allowed
|
||||
ERROR_STATUS_UNEXPECTED_NULL = ERROR_STATUS_UNKNOWN_ERROR+8, //!< unexpected null,
|
||||
ERROR_STATUS_UNKNOWN_ERROR = (-2147483647 - 1), // unknown error
|
||||
ERROR_STATUS_NO_MEMORY = -ENOMEM, // no memory
|
||||
ERROR_STATUS_INVALID_OPERATION = -ENOSYS, // invalid operation
|
||||
ERROR_STATUS_BAD_VALUE = -EINVAL, // bad value
|
||||
ERROR_STATUS_BAD_TYPE = ERROR_STATUS_UNKNOWN_ERROR + 1, // bad type
|
||||
ERROR_STATUS_NAME_NOT_FOUND = -ENOENT, // name not found
|
||||
ERROR_STATUS_PERMISSION_DENIED = -EPERM, // permission denied
|
||||
ERROR_STATUS_NO_INIT = -ENODEV, // no init
|
||||
ERROR_STATUS_ALREADY_EXISTS = -EEXIST, // already exist
|
||||
ERROR_STATUS_DEAD_OBJECT = -EPIPE, // dead object
|
||||
ERROR_STATUS_FAILED_TRANSACTION = ERROR_STATUS_UNKNOWN_ERROR + 2, // failed transaction
|
||||
ERROR_STATUS_BAD_INDEX = -EOVERFLOW, // bad index
|
||||
ERROR_STATUS_NOT_ENOUGH_DATA = -ENODATA, // not enough data
|
||||
ERROR_STATUS_WOULD_BLOCK = -EWOULDBLOCK, // would block
|
||||
ERROR_STATUS_TIMED_OUT = -ETIMEDOUT, // time out
|
||||
ERROR_STATUS_UNKNOWN_TRANSACTION = -EBADMSG, // unknown transaction
|
||||
ERROR_STATUS_FDS_NOT_ALLOWED = ERROR_STATUS_UNKNOWN_ERROR + 7, // fds not allowed
|
||||
ERROR_STATUS_UNEXPECTED_NULL = ERROR_STATUS_UNKNOWN_ERROR + 8, // unexpected null,
|
||||
|
||||
// binder exception error code from Status.h
|
||||
ERROR_EX_ILLEGAL_ARGUMENT = -3, //!< illegal argument exception
|
||||
ERROR_EX_NULL_POINTER = -4, //!< null pointer exception
|
||||
ERROR_EX_ILLEGAL_STATE = -5, //!< illegal state exception
|
||||
ERROR_EX_NETWORK_MAIN_THREAD = -6, //!< network main thread exception
|
||||
ERROR_EX_UNSUPPORTED_OPERATION = -7, //!< unsupported operation exception
|
||||
ERROR_EX_SERVICE_SPECIFIC = -8, //!< service specific exception
|
||||
ERROR_EX_PARCELABLE = -9, //!< parcelable exception
|
||||
ERROR_EX_ILLEGAL_ARGUMENT = -3, // illegal argument exception
|
||||
ERROR_EX_NULL_POINTER = -4, // null pointer exception
|
||||
ERROR_EX_ILLEGAL_STATE = -5, // illegal state exception
|
||||
ERROR_EX_NETWORK_MAIN_THREAD = -6, // network main thread exception
|
||||
ERROR_EX_UNSUPPORTED_OPERATION = -7, // unsupported operation exception
|
||||
ERROR_EX_SERVICE_SPECIFIC = -8, // service specific exception
|
||||
ERROR_EX_PARCELABLE = -9, // parcelable exception
|
||||
// no error
|
||||
NO_ERROR = 0, //!< no error
|
||||
NO_ERROR = 0, // no error
|
||||
|
||||
// system service error
|
||||
ERROR_NULL_POINTER, //!< null pointer
|
||||
ERROR_BAD_PARAMETERS, //!< bad parameters
|
||||
ERROR_SERVICE_START_FAILED, //!< failed to start service
|
||||
ERROR_USER_NOT_STARTED, //!< user is not started
|
||||
ERROR_USER_ALREADY_STARTED, //!< user has already started
|
||||
ERROR_USER_NOT_UNLOCKED, //!< user is not unlocked
|
||||
ERROR_USER_ALREADY_UNLOCKED, //!< user has already unlocked
|
||||
ERROR_USER_NOT_LOCKED, //!< user is not locked
|
||||
ERROR_NULL_POINTER, // null pointer
|
||||
ERROR_BAD_PARAMETERS, // bad parameters
|
||||
ERROR_SERVICE_START_FAILED, // failed to start service
|
||||
ERROR_USER_NOT_STARTED, // user is not started
|
||||
ERROR_USER_ALREADY_STARTED, // user has already started
|
||||
ERROR_USER_NOT_UNLOCKED, // user is not unlocked
|
||||
ERROR_USER_ALREADY_UNLOCKED, // user has already unlocked
|
||||
ERROR_USER_NOT_LOCKED, // user is not locked
|
||||
|
||||
ERROR_IME_NOT_AVAILABLE, //!< input method engine is not available
|
||||
ERROR_SECURITY_IME_NOT_AVAILABLE, //!< security input method engine is not available
|
||||
ERROR_TOKEN_CREATE_FAILED, //!< failed to create window token
|
||||
ERROR_TOKEN_DESTROY_FAILED, //!< failed to destroy window token
|
||||
ERROR_IME_BIND_FAILED, //!< failed to bind IME service
|
||||
ERROR_IME_UNBIND_FAILED, //!< failed to unbind IME service
|
||||
ERROR_IME_START_FAILED, //!< failed to start IME service
|
||||
ERROR_IME_STOP_FAILED, //!< failed to stop IME service
|
||||
ERROR_KBD_SHOW_FAILED, //!< failed to show keyboard
|
||||
ERROR_KBD_HIDE_FAILED, //!< failed to hide keyboard
|
||||
ERROR_IME_NOT_STARTED, //!< input method service is not started
|
||||
ERROR_KBD_IS_OCCUPIED, //!< keyboard is showing by other client
|
||||
ERROR_KBD_IS_NOT_SHOWING, //!< keyboard is not showing
|
||||
ERROR_IME_ALREADY_STARTED, //!< input method service has already started
|
||||
ERROR_NOT_IME_PACKAGE, //!< not an IME package
|
||||
ERROR_IME_PACKAGE_DUPLICATED, //!< duplicated IME package
|
||||
ERROR_SETTING_SAME_VALUE, //!< same setting value
|
||||
ERROR_NO_NEXT_IME, //!< no next ime is available
|
||||
ERROR_CLIENTWINDOW_NOT_FOCUSED, //!< the input client window is not focused
|
||||
ERROR_CLIENT_NOT_WINDOW, //!< the input client is not from a valid window
|
||||
ERROR_IME_NOT_AVAILABLE, // input method engine is not available
|
||||
ERROR_SECURITY_IME_NOT_AVAILABLE, // security input method engine is not available
|
||||
ERROR_TOKEN_CREATE_FAILED, // failed to create window token
|
||||
ERROR_TOKEN_DESTROY_FAILED, // failed to destroy window token
|
||||
ERROR_IME_BIND_FAILED, // failed to bind IME service
|
||||
ERROR_IME_UNBIND_FAILED, // failed to unbind IME service
|
||||
ERROR_IME_START_FAILED, // failed to start IME service
|
||||
ERROR_IME_STOP_FAILED, // failed to stop IME service
|
||||
ERROR_KBD_SHOW_FAILED, // failed to show keyboard
|
||||
ERROR_KBD_HIDE_FAILED, // failed to hide keyboard
|
||||
ERROR_IME_NOT_STARTED, // input method service is not started
|
||||
ERROR_KBD_IS_OCCUPIED, // keyboard is showing by other client
|
||||
ERROR_KBD_IS_NOT_SHOWING, // keyboard is not showing
|
||||
ERROR_IME_ALREADY_STARTED, // input method service has already started
|
||||
ERROR_NOT_IME_PACKAGE, // not an IME package
|
||||
ERROR_IME_PACKAGE_DUPLICATED, // duplicated IME package
|
||||
ERROR_SETTING_SAME_VALUE, // same setting value
|
||||
ERROR_NO_NEXT_IME, // no next ime is available
|
||||
ERROR_CLIENTWINDOW_NOT_FOCUSED, // the input client window is not focused
|
||||
ERROR_CLIENT_NOT_WINDOW, // the input client is not from a valid window
|
||||
// error from ime
|
||||
ERROR_REMOTE_IME_DIED, //!< remote input method service died abnormally
|
||||
ERROR_RESTART_IME_FAILED, //!< failed to restart input method service
|
||||
ERROR_REMOTE_IME_DIED, // remote input method service died abnormally
|
||||
ERROR_RESTART_IME_FAILED, // failed to restart input method service
|
||||
// error from client
|
||||
ERROR_REMOTE_CLIENT_DIED, //!< remote client died abnormally
|
||||
ERROR_CLIENT_DUPLICATED, //!< duplicated client
|
||||
ERROR_CLIENT_NOT_FOUND, //!< client is not found
|
||||
|
||||
ERROR_REMOTE_CLIENT_DIED, // remote client died abnormally
|
||||
ERROR_CLIENT_DUPLICATED, // duplicated client
|
||||
ERROR_CLIENT_NOT_FOUND, // client is not found
|
||||
};
|
||||
const char* ToString(int errorCode);
|
||||
};
|
||||
@@ -166,7 +165,6 @@ static constexpr HiviewDFX::HiLogLabel g_SMALL_SERVICES_LABEL = {
|
||||
"line: %d, function: %s," fmt, __LINE__, __FUNCTION__, ##__VA_ARGS__)
|
||||
#define IMSA_HILOGW(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Warn(OHOS::MiscServices::g_SMALL_SERVICES_LABEL, \
|
||||
"line: %d, function: %s," fmt, __LINE__, __FUNCTION__, ##__VA_ARGS__)
|
||||
|
||||
}
|
||||
}
|
||||
#endif // FM_IMMS_PROJECT_GLOBAL_H
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OHOS {
|
||||
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.InputControlChannel");
|
||||
|
||||
virtual void onAgentCreated(sptr<IInputMethodAgent>& agent, InputChannel* channel) = 0;
|
||||
virtual void onAgentCreated(sptr<IInputMethodAgent>& agent, InputChannel *channel) = 0;
|
||||
virtual void hideKeyboardSelf(int flags) = 0;
|
||||
virtual bool advanceToNext(bool isCurrentIme) = 0;
|
||||
virtual void setDisplayMode(int mode) = 0;
|
||||
@@ -43,5 +43,4 @@ namespace OHOS {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FM_IMMS_PROJECT_IINPUTCONTROLCHANNEL_H
|
||||
|
||||
@@ -34,5 +34,4 @@ namespace OHOS {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FM_IMMS_PROJECT_IINPUTMETHODAGENT_H
|
||||
|
||||
@@ -30,38 +30,37 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class IInputMethodSystemAbility : public IRemoteBroker {
|
||||
public:
|
||||
enum {
|
||||
PREPARE_INPUT = 0,
|
||||
RELEASE_INPUT,
|
||||
START_INPUT,
|
||||
STOP_INPUT,
|
||||
SET_INPUT_METHOD_CORE,
|
||||
GET_DISPLAY_MODE,
|
||||
GET_KEYBOARD_WINDOW_HEIGHT,
|
||||
GET_CURRENT_KEYBOARD_TYPE,
|
||||
LIST_INPUT_METHOD_ENABLED,
|
||||
LIST_INPUT_METHOD,
|
||||
LIST_KEYBOARD_TYPE,
|
||||
class IInputMethodSystemAbility : public IRemoteBroker {
|
||||
public:
|
||||
enum {
|
||||
PREPARE_INPUT = 0,
|
||||
RELEASE_INPUT,
|
||||
START_INPUT,
|
||||
STOP_INPUT,
|
||||
SET_INPUT_METHOD_CORE,
|
||||
GET_DISPLAY_MODE,
|
||||
GET_KEYBOARD_WINDOW_HEIGHT,
|
||||
GET_CURRENT_KEYBOARD_TYPE,
|
||||
LIST_INPUT_METHOD_ENABLED,
|
||||
LIST_INPUT_METHOD,
|
||||
LIST_KEYBOARD_TYPE,
|
||||
};
|
||||
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IInputMethodSystemAbility");
|
||||
|
||||
virtual void prepareInput(MessageParcel& data) = 0;
|
||||
virtual void releaseInput(MessageParcel& data) = 0;
|
||||
virtual void startInput(MessageParcel& data) = 0;
|
||||
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 getKeyboardWindowHeight(int32_t retHeight) = 0;
|
||||
virtual int32_t getCurrentKeyboardType(KeyboardType *retType) = 0;
|
||||
virtual int32_t listInputMethodEnabled(std::vector<InputMethodProperty*> *properties) = 0;
|
||||
virtual int32_t listInputMethod(std::vector<InputMethodProperty*> *properties) = 0;
|
||||
virtual int32_t listKeyboardType(const std::u16string& imeId, std::vector<KeyboardType*> *types) = 0;
|
||||
};
|
||||
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IInputMethodSystemAbility");
|
||||
|
||||
virtual void prepareInput(MessageParcel& data) = 0;
|
||||
virtual void releaseInput(MessageParcel& data) = 0;
|
||||
virtual void startInput(MessageParcel& data) = 0;
|
||||
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 getKeyboardWindowHeight(int32_t *retHeight) = 0;
|
||||
virtual int32_t getCurrentKeyboardType(KeyboardType* retType) = 0;
|
||||
virtual int32_t listInputMethodEnabled(std::vector<InputMethodProperty*> *properties) = 0;
|
||||
virtual int32_t listInputMethod(std::vector<InputMethodProperty*> *properties) = 0;
|
||||
virtual int32_t listKeyboardType(const std::u16string& imeId, std::vector<KeyboardType*> *types) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FM_IMMS_PROJECT_IINPUTMETHODSYSTEMABILITY_H
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OHOS {
|
||||
virtual int32_t unbindInputMethodService(int userId, const std::u16string& packageName) = 0;
|
||||
virtual sptr<IRemoteObject> createWindowToken(int userId, int displayId, const std::u16string& packageName) = 0;
|
||||
virtual int32_t destroyWindowToken(int userId, const std::u16string& packageName) = 0;
|
||||
virtual int32_t listInputMethod(int userId, std::vector<InputMethodProperty*> *inputMethodProperties) = 0;
|
||||
virtual int32_t listInputMethod(int userId, std::vector<InputMethodProperty*> *properties) = 0;
|
||||
virtual int32_t getInputMethodProperty(int userId, const std::u16string& packageName,
|
||||
InputMethodProperty *inputMethodProperty) = 0;
|
||||
virtual int32_t getInputMethodSetting(int userId, InputMethodSetting *inputMethodSetting) = 0;
|
||||
|
||||
@@ -19,23 +19,23 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class InputAttribute : public Parcelable {
|
||||
public:
|
||||
InputAttribute();
|
||||
InputAttribute(const InputAttribute& attribute);
|
||||
InputAttribute& operator=(const InputAttribute& attribute);
|
||||
~InputAttribute();
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static InputAttribute *Unmarshalling(Parcel &parcel);
|
||||
void SetInputPattern(int32_t pattern);
|
||||
bool GetSecurityFlag();
|
||||
static const int32_t PATTERN_TEXT = 0x00000001;
|
||||
static const int32_t PATTERN_PASSWORD = 0x00000007;
|
||||
private:
|
||||
int32_t inputPattern;
|
||||
int32_t enterKeyType;
|
||||
int32_t inputOption;
|
||||
};
|
||||
class InputAttribute : public Parcelable {
|
||||
public:
|
||||
InputAttribute();
|
||||
InputAttribute(const InputAttribute& attribute);
|
||||
InputAttribute& operator=(const InputAttribute& attribute);
|
||||
~InputAttribute();
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static InputAttribute *Unmarshalling(Parcel &parcel);
|
||||
void SetInputPattern(int32_t pattern);
|
||||
bool GetSecurityFlag();
|
||||
static const int32_t PATTERN_TEXT = 0x00000001;
|
||||
static const int32_t PATTERN_PASSWORD = 0x00000007;
|
||||
private:
|
||||
int32_t inputPattern;
|
||||
int32_t enterKeyType;
|
||||
int32_t inputOption;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class InputChannel : public Parcelable{
|
||||
class InputChannel : public Parcelable {
|
||||
public:
|
||||
InputChannel();
|
||||
~InputChannel();
|
||||
@@ -33,7 +33,7 @@ namespace MiscServices {
|
||||
MessageParcel inputChannelParcel;
|
||||
InputChannel(const InputChannel& channel);
|
||||
InputChannel& operator=(const InputChannel& channel);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // INPUTMETHODSYSTEMSERVICE_INPUTCHANNEL_H
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MiscServices {
|
||||
InputControlChannelProxy(const sptr<IRemoteObject> &impl);
|
||||
~InputControlChannelProxy();
|
||||
|
||||
virtual void onAgentCreated(sptr<IInputMethodAgent>& agent, InputChannel* channel) override;
|
||||
virtual void onAgentCreated(sptr<IInputMethodAgent>& agent, InputChannel *channel) override;
|
||||
virtual void hideKeyboardSelf(int flags) override;
|
||||
virtual bool advanceToNext(bool isCurrentIme) override;
|
||||
virtual void setDisplayMode(int mode) override;
|
||||
@@ -41,6 +41,4 @@ namespace MiscServices {
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // FM_IMMS_PROJECT_INPUTCONTROLCHANNELPROXY_H
|
||||
|
||||
|
||||
#endif // FM_IMMS_PROJECT_INPUTCONTROLCHANNELPROXY_H
|
||||
@@ -35,7 +35,7 @@ namespace OHOS {
|
||||
MessageParcel &data,
|
||||
MessageParcel &reply,
|
||||
MessageOption &option) override;
|
||||
virtual void onAgentCreated(sptr<IInputMethodAgent>& agent, InputChannel* channel) override;
|
||||
virtual void onAgentCreated(sptr<IInputMethodAgent>& agent, InputChannel *channel) override;
|
||||
virtual void hideKeyboardSelf(int flags) override;
|
||||
virtual bool advanceToNext(bool isCurrentIme) override;
|
||||
virtual void setDisplayMode(int mode) override;
|
||||
@@ -47,13 +47,14 @@ namespace OHOS {
|
||||
private:
|
||||
int userId_;
|
||||
sptr<IInputMethodAgent> agent = nullptr;
|
||||
InputChannel* channel = nullptr;
|
||||
InputChannel *channel = nullptr;
|
||||
|
||||
std::mutex mtx;
|
||||
std::condition_variable cv;
|
||||
bool agentReadyFlag = false;
|
||||
bool keyboardReadyFlag = false;
|
||||
};
|
||||
const int32_t sleepTime = 300;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H
|
||||
|
||||
@@ -32,13 +32,13 @@ namespace OHOS {
|
||||
|
||||
InputMethodAbilityConnectionStub(const int index);
|
||||
~InputMethodAbilityConnectionStub();
|
||||
void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode) override;
|
||||
void OnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
const sptr<IRemoteObject> &remoteObject, int resultCode) override;
|
||||
void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override;
|
||||
void SetHandler(MessageHandler* handler);
|
||||
|
||||
void SetHandler(MessageHandler *handler);
|
||||
|
||||
private:
|
||||
MessageHandler* messageHandler;
|
||||
MessageHandler *messageHandler;
|
||||
int mIndex;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,23 +22,23 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class InputMethodProperty : public Parcelable {
|
||||
public:
|
||||
std::u16string mImeId;
|
||||
std::u16string mPackageName;
|
||||
std::u16string mAbilityName;
|
||||
std::u16string mConfigurationPage;
|
||||
bool isSystemIme;
|
||||
int32_t mDefaultImeId;
|
||||
std::vector<KeyboardType*> mTypes;
|
||||
class InputMethodProperty : public Parcelable {
|
||||
public:
|
||||
std::u16string mImeId;
|
||||
std::u16string mPackageName;
|
||||
std::u16string mAbilityName;
|
||||
std::u16string mConfigurationPage;
|
||||
bool isSystemIme;
|
||||
int32_t mDefaultImeId;
|
||||
std::vector<KeyboardType*> mTypes;
|
||||
|
||||
InputMethodProperty();
|
||||
~InputMethodProperty();
|
||||
InputMethodProperty(const InputMethodProperty& property);
|
||||
InputMethodProperty& operator=(const InputMethodProperty& property);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static InputMethodProperty *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
InputMethodProperty();
|
||||
~InputMethodProperty();
|
||||
InputMethodProperty(const InputMethodProperty& property);
|
||||
InputMethodProperty& operator=(const InputMethodProperty& property);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static InputMethodProperty *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // FM_IMMS_PROJECT_INPUTMETHODPROPERTY_H
|
||||
|
||||
@@ -26,13 +26,11 @@ namespace MiscServices {
|
||||
class InputMethodSetting : public Parcelable {
|
||||
public:
|
||||
|
||||
const static std::u16string CURRENT_INPUT_METHOD_TAG; //!< the item name of 'default IME' in the system setting
|
||||
const static std::u16string ENABLED_INPUT_METHODS_TAG; //!< the item name of 'enabled IME list' in the system setting
|
||||
const static std::u16string CURRENT_KEYBOARD_TYPE_TAG; //!< the item name of 'default keyboard type' in the system setting
|
||||
const static std::u16string CURRENT_SYS_KEYBOARD_TYPE_TAG;
|
||||
//!< the item name of 'default keyboard type for security IME in the system setting
|
||||
|
||||
const static std::u16string SYSTEM_LOCALE_TAG; //!< the item name of locale list supported in the system
|
||||
const static std::u16string CURRENT_INPUT_METHOD_TAG; // default IME
|
||||
const static std::u16string ENABLED_INPUT_METHODS_TAG; // enabled IME list
|
||||
const static std::u16string CURRENT_KEYBOARD_TYPE_TAG; // default keyboard type
|
||||
const static std::u16string CURRENT_SYS_KEYBOARD_TYPE_TAG; // default keyboard type for security IME
|
||||
const static std::u16string SYSTEM_LOCALE_TAG; // locale list supported in the system
|
||||
|
||||
|
||||
InputMethodSetting();
|
||||
|
||||
@@ -43,10 +43,11 @@ namespace MiscServices {
|
||||
|
||||
int32_t GetUserState(int32_t userId);
|
||||
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) 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 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;
|
||||
@@ -67,20 +68,20 @@ namespace MiscServices {
|
||||
std::map<int32_t, MessageHandler*> msgHandlers;
|
||||
|
||||
void WorkThread();
|
||||
PerUserSetting* GetUserSetting(int32_t userId);
|
||||
PerUserSession* GetUserSession(int32_t userId);
|
||||
int32_t OnUserStarted(const Message* msg);
|
||||
int32_t OnUserStopped(const Message* msg);
|
||||
int32_t OnUserUnlocked(const Message* msg);
|
||||
int32_t OnUserLocked(const Message* msg);
|
||||
int32_t OnPrepareInput(Message* msg);
|
||||
int32_t OnHandleMessage(Message* msg);
|
||||
int32_t OnRemotePeerDied(const Message* msg);
|
||||
int32_t OnSettingChanged(const Message* msg);
|
||||
int32_t OnPackageRemoved(const Message* msg);
|
||||
int32_t OnPackageAdded(const Message* msg);
|
||||
int32_t OnDisableIms(const Message* msg);
|
||||
int32_t OnAdvanceToNext(const Message* msg);
|
||||
PerUserSetting *GetUserSetting(int32_t userId);
|
||||
PerUserSession *GetUserSession(int32_t userId);
|
||||
int32_t OnUserStarted(const Message *msg);
|
||||
int32_t OnUserStopped(const Message *msg);
|
||||
int32_t OnUserUnlocked(const Message *msg);
|
||||
int32_t OnUserLocked(const Message *msg);
|
||||
int32_t OnPrepareInput(Message *msg);
|
||||
int32_t OnHandleMessage(Message *msg);
|
||||
int32_t OnRemotePeerDied(const Message *msg);
|
||||
int32_t OnSettingChanged(const Message *msg);
|
||||
int32_t OnPackageRemoved(const Message *msg);
|
||||
int32_t OnPackageAdded(const Message *msg);
|
||||
int32_t OnDisableIms(const Message *msg);
|
||||
int32_t OnAdvanceToNext(const Message *msg);
|
||||
|
||||
ServiceRunningState state_;
|
||||
sptr<InputMethodAbility> inputMethodAbility_;
|
||||
|
||||
@@ -24,18 +24,18 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class InputMethodSystemAbilityStub : public IRemoteStub<IInputMethodSystemAbility> {
|
||||
public:
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
class InputMethodSystemAbilityStub : public IRemoteStub<IInputMethodSystemAbility> {
|
||||
public:
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 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;
|
||||
void setInputMethodCoreFromHap(MessageParcel& data);
|
||||
protected:
|
||||
int32_t getUserId(int32_t uid);
|
||||
};
|
||||
virtual void prepareInput(MessageParcel& data) override;
|
||||
virtual void releaseInput(MessageParcel& data) override;
|
||||
virtual void startInput(MessageParcel& data) override;
|
||||
virtual void stopInput(MessageParcel& data) override;
|
||||
void setInputMethodCoreFromHap(MessageParcel& data);
|
||||
protected:
|
||||
int32_t getUserId(int32_t uid);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,42 +22,42 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class KeyboardType : public Parcelable {
|
||||
public:
|
||||
KeyboardType();
|
||||
KeyboardType(const KeyboardType& type);
|
||||
~KeyboardType();
|
||||
KeyboardType& operator=(const KeyboardType& type);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static KeyboardType *Unmarshalling(Parcel &parcel);
|
||||
void setId(int32_t typeId);
|
||||
void setLabelId(int32_t labelId);
|
||||
void setIconId(int32_t iconId);
|
||||
void setAsciiCapability(bool isAsciiCapable);
|
||||
void setLanguage(std::u16string language);
|
||||
void setInputSource(std::u16string inputSource);
|
||||
void setCustomizedValue(std::u16string keyBoardTypeCustomizedValue);
|
||||
int32_t getId() const;
|
||||
int32_t getLabelId() const;
|
||||
int32_t getIconId() const;
|
||||
int32_t getHashCode() const;
|
||||
std::u16string getLanguage() const;
|
||||
std::u16string getInputSource() const;
|
||||
std::u16string getCustomizedValue() const;
|
||||
bool supportsAscii();
|
||||
class KeyboardType : public Parcelable {
|
||||
public:
|
||||
KeyboardType();
|
||||
KeyboardType(const KeyboardType& type);
|
||||
~KeyboardType();
|
||||
KeyboardType& operator=(const KeyboardType& type);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static KeyboardType *Unmarshalling(Parcel &parcel);
|
||||
void setId(int32_t typeId);
|
||||
void setLabelId(int32_t labelId);
|
||||
void setIconId(int32_t iconId);
|
||||
void setAsciiCapability(bool isAsciiCapable);
|
||||
void setLanguage(std::u16string language);
|
||||
void setInputSource(std::u16string inputSource);
|
||||
void setCustomizedValue(std::u16string customizedValue);
|
||||
int32_t getId() const;
|
||||
int32_t getLabelId() const;
|
||||
int32_t getIconId() const;
|
||||
int32_t getHashCode() const;
|
||||
std::u16string getLanguage() const;
|
||||
std::u16string getInputSource() const;
|
||||
std::u16string getCustomizedValue() const;
|
||||
bool supportsAscii();
|
||||
|
||||
private:
|
||||
int32_t mId;
|
||||
int32_t mHashCode;
|
||||
int32_t mLabelId;
|
||||
int32_t mIconId;
|
||||
bool mIsAsciiCapable;
|
||||
std::u16string mLanguage;
|
||||
std::u16string mInputSource;
|
||||
std::u16string mCustomizedValue;
|
||||
private:
|
||||
int32_t mId;
|
||||
int32_t mHashCode;
|
||||
int32_t mLabelId;
|
||||
int32_t mIconId;
|
||||
bool mIsAsciiCapable;
|
||||
std::u16string mLanguage;
|
||||
std::u16string mInputSource;
|
||||
std::u16string mCustomizedValue;
|
||||
|
||||
const int32_t ID_NONE = 0;
|
||||
};
|
||||
const int32_t ID_NONE = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // FM_IMMS_PROJECT_KEYBOARDTYPE_H
|
||||
|
||||
+12
-12
@@ -21,18 +21,18 @@
|
||||
#include "message_parcel.h"
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class Message {
|
||||
public:
|
||||
int32_t msgId_; //!< message id
|
||||
MessageParcel *msgContent_ = nullptr; //!< message content
|
||||
Message(int32_t msgId, MessageParcel* msgContent);
|
||||
explicit Message(const Message& msg);
|
||||
Message& operator= (const Message& msg);
|
||||
~Message();
|
||||
private:
|
||||
Message(const Message&&);
|
||||
Message& operator= (const Message&&);
|
||||
};
|
||||
class Message {
|
||||
public:
|
||||
int32_t msgId_; // message id
|
||||
MessageParcel *msgContent_ = nullptr; // message content
|
||||
Message(int32_t msgId, MessageParcel *msgContent);
|
||||
explicit Message(const Message& msg);
|
||||
Message& operator= (const Message& msg);
|
||||
~Message();
|
||||
private:
|
||||
Message(const Message&&);
|
||||
Message& operator= (const Message&&);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,34 +29,34 @@ namespace MiscServices {
|
||||
namespace MessageID {
|
||||
enum {
|
||||
// for system broadcast
|
||||
MSG_ID_SYSTEM_START = 0, //!< system started
|
||||
MSG_ID_SYSTEM_STOP, //!< system stopped
|
||||
MSG_ID_USER_START, //!< a user started
|
||||
MSG_ID_USER_STOP, //!< a user stopped
|
||||
MSG_ID_USER_UNLOCK, //!< a user unlocked
|
||||
MSG_ID_USER_LOCK, //!< a user locked
|
||||
MSG_ID_PACKAGE_ADDED, //!< a package is installed
|
||||
MSG_ID_PACKAGE_REMOVED, //!< a package is removed
|
||||
MSG_ID_SETTING_CHANGED, //!< input method setting is changed
|
||||
MSG_ID_SYSTEM_START = 0, // system started
|
||||
MSG_ID_SYSTEM_STOP, // system stopped
|
||||
MSG_ID_USER_START, // a user started
|
||||
MSG_ID_USER_STOP, // a user stopped
|
||||
MSG_ID_USER_UNLOCK, // a user unlocked
|
||||
MSG_ID_USER_LOCK, // a user locked
|
||||
MSG_ID_PACKAGE_ADDED, // a package is installed
|
||||
MSG_ID_PACKAGE_REMOVED, // a package is removed
|
||||
MSG_ID_SETTING_CHANGED, // input method setting is changed
|
||||
|
||||
// the request from client
|
||||
MSG_ID_PREPARE_INPUT, //!< prepare input
|
||||
MSG_ID_START_INPUT, //!< start input
|
||||
MSG_ID_STOP_INPUT, //!< stop input
|
||||
MSG_ID_RELEASE_INPUT, //!< release input
|
||||
MSG_ID_PREPARE_INPUT, // prepare input
|
||||
MSG_ID_START_INPUT, // start input
|
||||
MSG_ID_STOP_INPUT, // stop input
|
||||
MSG_ID_RELEASE_INPUT, // release input
|
||||
MSG_ID_SET_INPUT_METHOD_CORE,
|
||||
|
||||
// the request to handle the condition that the remote object died
|
||||
MSG_ID_CLIENT_DIED, //!< input client died
|
||||
MSG_ID_IMS_DIED, //!< input method service died
|
||||
MSG_ID_DISABLE_IMS, //!< disable input method service
|
||||
MSG_ID_RESTART_IMS, //!< restart input method service
|
||||
MSG_ID_HIDE_KEYBOARD_SELF, //!< hide the current keyboard
|
||||
MSG_ID_ADVANCE_TO_NEXT, //!< switch to next
|
||||
MSG_ID_SET_DISPLAY_MODE, //!< set display mode
|
||||
MSG_ID_CLIENT_DIED, // input client died
|
||||
MSG_ID_IMS_DIED, // input method service died
|
||||
MSG_ID_DISABLE_IMS, // disable input method service
|
||||
MSG_ID_RESTART_IMS, // restart input method service
|
||||
MSG_ID_HIDE_KEYBOARD_SELF, // hide the current keyboard
|
||||
MSG_ID_ADVANCE_TO_NEXT, // switch to next
|
||||
MSG_ID_SET_DISPLAY_MODE, // set display mode
|
||||
|
||||
MSG_ID_SHELL_COMMAND, //!< shell command
|
||||
MSG_ID_EXIT_SERVICE, //!< exit service
|
||||
MSG_ID_SHELL_COMMAND, // shell command
|
||||
MSG_ID_EXIT_SERVICE, // exit service
|
||||
|
||||
//the request from IMSA to IMC
|
||||
MSG_ID_INSERT_CHAR,
|
||||
@@ -65,36 +65,35 @@ namespace MessageID {
|
||||
MSG_ID_ON_INPUT_READY,
|
||||
|
||||
// the request from IMSA to IMA
|
||||
MSG_ID_SHOW_KEYBOARD, //
|
||||
MSG_ID_INITIALIZE_INPUT, //
|
||||
MSG_ID_HIDE_KEYBOARD, //
|
||||
MSG_ID_SHOW_KEYBOARD,
|
||||
MSG_ID_INITIALIZE_INPUT,
|
||||
MSG_ID_HIDE_KEYBOARD,
|
||||
MSG_ID_SET_KEYBOARD_TYPE,
|
||||
MSG_ID_GET_KEYBOARD_WINDOW_HEIGHT,
|
||||
|
||||
|
||||
// the request from IMC to IMA
|
||||
MSG_ID_DISPATCH_KEY,//!< dispatch key from PhysicalKbd
|
||||
MSG_ID_DISPATCH_KEY, // dispatch key from PhysicalKbd
|
||||
};
|
||||
}
|
||||
|
||||
class MessageHandler {
|
||||
public:
|
||||
MessageHandler();
|
||||
~MessageHandler();
|
||||
void SendMessage(Message* msg);
|
||||
Message* GetMessage();
|
||||
static MessageHandler* Instance();
|
||||
public:
|
||||
MessageHandler();
|
||||
~MessageHandler();
|
||||
void SendMessage(Message *msg);
|
||||
Message *GetMessage();
|
||||
static MessageHandler *Instance();
|
||||
|
||||
private:
|
||||
std::mutex mMutex; //!< a mutex to guard message queue
|
||||
std::condition_variable mCV; //!< condition variable to work with mMutex
|
||||
std::queue<Message*> mQueue ;//!< Message queue, guarded by mMutex;
|
||||
private:
|
||||
std::mutex mMutex; // a mutex to guard message queue
|
||||
std::condition_variable mCV; // condition variable to work with mMutex
|
||||
std::queue<Message*> mQueue ; // Message queue, guarded by mMutex;
|
||||
|
||||
MessageHandler(const MessageHandler&);
|
||||
MessageHandler& operator= (const MessageHandler&);
|
||||
MessageHandler(const MessageHandler&&);
|
||||
MessageHandler& operator= (const MessageHandler&&);
|
||||
};
|
||||
MessageHandler(const MessageHandler&);
|
||||
MessageHandler& operator= (const MessageHandler&);
|
||||
MessageHandler(const MessageHandler&&);
|
||||
MessageHandler& operator= (const MessageHandler&&);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FM_IMMS_PROJECT_MESSAGEHANDLER_H
|
||||
|
||||
@@ -47,9 +47,9 @@ namespace MiscServices {
|
||||
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
|
||||
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
|
||||
@@ -57,13 +57,13 @@ namespace MiscServices {
|
||||
*/
|
||||
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
|
||||
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 IMSA callback to input client
|
||||
InputAttribute attribute; // the input attribute of the input client
|
||||
|
||||
ClientInfo(int pid, int uid, int userId, int displayId, const sptr<IInputClient>& client,
|
||||
const sptr<IInputDataChannel>& channel, const InputAttribute& attribute)
|
||||
@@ -91,24 +91,24 @@ namespace MiscServices {
|
||||
*/
|
||||
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
|
||||
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
|
||||
};
|
||||
|
||||
public:
|
||||
explicit PerUserSession(int userId);
|
||||
~PerUserSession();
|
||||
|
||||
void SetCurrentIme(InputMethodProperty* ime);
|
||||
void SetSecurityIme(InputMethodProperty* ime);
|
||||
void SetInputMethodSetting(InputMethodSetting* setting);
|
||||
void ResetIme(InputMethodProperty* defaultIme, InputMethodProperty* securityIme);
|
||||
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 GetDisplayMode();
|
||||
int GetKeyboardWindowHeight(int *retHeight);
|
||||
KeyboardType* GetCurrentKeyboardType();
|
||||
int GetKeyboardWindowHeight(int retHeight);
|
||||
KeyboardType *GetCurrentKeyboardType();
|
||||
|
||||
int OnSettingChanged(const std::u16string& key, const std::u16string& value);
|
||||
void Dump(int fd);
|
||||
@@ -117,33 +117,33 @@ namespace MiscServices {
|
||||
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 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
|
||||
std::map<sptr<IRemoteObject>, ClientInfo*> mapClients;
|
||||
|
||||
InputMethodProperty* currentIme[MAX_IME]; //!< 0 - the default ime. 1 - security ime
|
||||
InputMethodProperty *currentIme[MAX_IME]; // 0 - the default ime. 1 - security ime
|
||||
|
||||
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
|
||||
InputControlChannelStub *localControlChannel[MAX_IME];
|
||||
sptr<IInputControlChannel> inputControlChannel[MAX_IME];
|
||||
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<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
|
||||
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<RemoteObjectDeathRecipient> clientDeathRecipient; // remote object death monitor for input client
|
||||
sptr<RemoteObjectDeathRecipient> imsDeathRecipient;
|
||||
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_;
|
||||
|
||||
@@ -152,18 +152,18 @@ namespace MiscServices {
|
||||
PerUserSession(const PerUserSession&&);
|
||||
PerUserSession& operator= (const PerUserSession&&);
|
||||
int IncreaseOrResetImeError(bool resetFlag, int imeIndex);
|
||||
KeyboardType* GetKeyboardType(int imeIndex, int typeIndex);
|
||||
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);
|
||||
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 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);
|
||||
@@ -182,7 +182,7 @@ namespace MiscServices {
|
||||
void SetDisplayId(int displayId);
|
||||
int GetImeIndex(const sptr<IInputClient>& inputClient);
|
||||
static sptr<AAFwk::IAbilityManager> GetAbilityManagerService();
|
||||
void onSetInputMethodCore(Message* msg);
|
||||
void onSetInputMethodCore(Message *msg);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,49 +25,49 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class PerUserSetting {
|
||||
public:
|
||||
explicit PerUserSetting(int32_t userId);
|
||||
class PerUserSetting {
|
||||
public:
|
||||
explicit PerUserSetting(int32_t userId);
|
||||
|
||||
~PerUserSetting();
|
||||
~PerUserSetting();
|
||||
|
||||
void Initialize();
|
||||
int32_t GetUserState();
|
||||
InputMethodProperty* GetCurrentInputMethod();
|
||||
InputMethodProperty* GetSecurityInputMethod();
|
||||
InputMethodProperty* GetNextInputMethod();
|
||||
InputMethodSetting* GetInputMethodSetting();
|
||||
InputMethodProperty* GetInputMethodProperty(const std::u16string& imeId);
|
||||
void Initialize();
|
||||
int32_t GetUserState();
|
||||
InputMethodProperty *GetCurrentInputMethod();
|
||||
InputMethodProperty *GetSecurityInputMethod();
|
||||
InputMethodProperty *GetNextInputMethod();
|
||||
InputMethodSetting *GetInputMethodSetting();
|
||||
InputMethodProperty *GetInputMethodProperty(const std::u16string& imeId);
|
||||
|
||||
int32_t OnPackageAdded(std::u16string& packageName, bool* isSecurityIme = nullptr);
|
||||
int32_t OnPackageRemoved(std::u16string& packageName, bool* isSecurityIme = nullptr);
|
||||
int32_t OnSettingChanged(const std::u16string& key, const std::u16string& value);
|
||||
void OnAdvanceToNext();
|
||||
void OnUserLocked();
|
||||
void Dump(int32_t fd);
|
||||
int32_t OnPackageAdded(std::u16string& packageName, bool isSecurityIme);
|
||||
int32_t OnPackageRemoved(std::u16string& packageName, bool isSecurityIme);
|
||||
int32_t OnSettingChanged(const std::u16string& key, const std::u16string& value);
|
||||
void OnAdvanceToNext();
|
||||
void OnUserLocked();
|
||||
void Dump(int32_t fd);
|
||||
|
||||
int32_t ListInputMethodEnabled(std::vector<InputMethodProperty*> *properties);
|
||||
int32_t ListInputMethod(std::vector<InputMethodProperty*> *properties);
|
||||
int32_t ListKeyboardType(const std::u16string& imeId, std::vector<KeyboardType*> *types);
|
||||
int32_t ListInputMethodEnabled(std::vector<InputMethodProperty*> *properties);
|
||||
int32_t ListInputMethod(std::vector<InputMethodProperty*> *properties);
|
||||
int32_t ListKeyboardType(const std::u16string& imeId, std::vector<KeyboardType*> *types);
|
||||
|
||||
static bool CheckIfSecurityIme(const InputMethodProperty& property);
|
||||
static bool CheckIfSecurityIme(const InputMethodProperty& property);
|
||||
|
||||
private:
|
||||
int32_t userId_; //!< the id of the user to whom the object is linking
|
||||
int32_t userState; //!< the state of the user to whom the object is linking
|
||||
std::vector<InputMethodProperty*> inputMethodProperties; //!< a vector to save all IME installed for this user
|
||||
std::u16string currentImeId; //!< the id of the default input method engine.
|
||||
InputMethodSetting inputMethodSetting; //!< the object to manage the setting data for this user
|
||||
private:
|
||||
int32_t userId_; // the id of the user to whom the object is linking
|
||||
int32_t userState; // the state of the user to whom the object is linking
|
||||
std::vector<InputMethodProperty*> inputMethodProperties; // a vector to save all IME installed for this user
|
||||
std::u16string currentImeId; // the id of the default input method engine.
|
||||
InputMethodSetting inputMethodSetting; // the object to manage the setting data for this user
|
||||
|
||||
PerUserSetting(const PerUserSetting&);
|
||||
PerUserSetting& operator= (const PerUserSetting&);
|
||||
PerUserSetting(const PerUserSetting&&);
|
||||
PerUserSetting& operator= (const PerUserSetting&&);
|
||||
void InitInputMethodSetting();
|
||||
void ResetCurrentInputMethod();
|
||||
std::u16string GetKeyboardTypeLanguage(const InputMethodProperty* property, int32_t hashCode);
|
||||
std::u16string GetImeId(const std::u16string& packageName);
|
||||
};
|
||||
PerUserSetting(const PerUserSetting&);
|
||||
PerUserSetting& operator= (const PerUserSetting&);
|
||||
PerUserSetting(const PerUserSetting&&);
|
||||
PerUserSetting& operator= (const PerUserSetting&&);
|
||||
void InitInputMethodSetting();
|
||||
void ResetCurrentInputMethod();
|
||||
std::u16string GetKeyboardTypeLanguage(const InputMethodProperty *property, int32_t hashCode);
|
||||
std::u16string GetImeId(const std::u16string& packageName);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // FM_IMMS_PROJECT_PERUSERSETTING_H
|
||||
|
||||
@@ -28,19 +28,19 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
|
||||
|
||||
class Platform {
|
||||
public:
|
||||
static Platform* Instance();
|
||||
static Platform *Instance();
|
||||
void SetPlatform(const sptr<IPlatformApi>& platformApi);
|
||||
sptr<IInputMethodCore> BindInputMethodService(int userId, const std::u16string& packageName, const std::u16string& intention);
|
||||
sptr<IInputMethodCore> BindInputMethodService(int userId, const std::u16string& packageName,
|
||||
const std::u16string& intention);
|
||||
int UnbindInputMethodService(int userId, const std::u16string& packageName);
|
||||
sptr<IRemoteObject> CreateWindowToken(int userId, int displayId, const std::u16string& packageName);
|
||||
int DestroyWindowToken(int userId, const std::u16string& packageName);
|
||||
int ListInputMethod(int userId, std::vector<InputMethodProperty*>* inputMethodProperties);
|
||||
int GetInputMethodProperty(int userId, const std::u16string& packageName, InputMethodProperty* inputMethodProperty);
|
||||
int GetInputMethodSetting(int userId, InputMethodSetting* inputMethodSetting);
|
||||
int ListInputMethod(int userId, std::vector<InputMethodProperty*> *properties);
|
||||
int GetInputMethodProperty(int userId, const std::u16string& packageName,
|
||||
InputMethodProperty *inputMethodProperty);
|
||||
int GetInputMethodSetting(int userId, InputMethodSetting *inputMethodSetting);
|
||||
int SetInputMethodSetting(int userId, const InputMethodSetting& inputMethodSetting);
|
||||
bool CheckPhysicalKeyboard();
|
||||
bool IsValidWindow(int uid, int pid, int displayId);
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
|
||||
class PlatformCallbackStub : public IRemoteStub<IPlatformCallback> {
|
||||
public:
|
||||
PlatformCallbackStub();
|
||||
~PlatformCallbackStub();
|
||||
|
||||
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) override;
|
||||
virtual void notifyEvent(int eventId, int userId, const std::vector<std::u16string>& eventContent) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,15 +25,15 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class Utils {
|
||||
public:
|
||||
static std::string to_utf8( std::u16string str16 ) {
|
||||
return std::wstring_convert< std::codecvt_utf8_utf16<char16_t>, char16_t >{}.to_bytes(str16);
|
||||
}
|
||||
static std::u16string to_utf16( std::string str ) {
|
||||
return std::wstring_convert< std::codecvt_utf8_utf16<char16_t>, char16_t >{}.from_bytes(str);
|
||||
}
|
||||
};
|
||||
class Utils {
|
||||
public:
|
||||
static std::string to_utf8(std::u16string str16) {
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(str16);
|
||||
}
|
||||
static std::u16string to_utf16(std::string str) {
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(str);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+196
-198
@@ -18,206 +18,204 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
|
||||
void LogTimeStamp()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
struct tm nowTime;
|
||||
localtime_r(&tv.tv_sec, &nowTime);
|
||||
printf("%02d-%02d %02d:%02d:%02d.%03d\t", nowTime.tm_mon, nowTime.tm_mday,
|
||||
nowTime.tm_hour, nowTime.tm_min, nowTime.tm_sec, (int)tv.tv_usec/1000);
|
||||
}
|
||||
|
||||
namespace ErrorCode {
|
||||
const char* ToString(int errorCode)
|
||||
void LogTimeStamp()
|
||||
{
|
||||
switch (errorCode) {
|
||||
case NO_ERROR: {
|
||||
return "no error";
|
||||
}
|
||||
case ERROR_NULL_POINTER: {
|
||||
return "null pointer";
|
||||
}
|
||||
case ERROR_BAD_PARAMETERS: {
|
||||
return "bad parameters";
|
||||
}
|
||||
case ERROR_SERVICE_START_FAILED: {
|
||||
return "failed to start service";
|
||||
}
|
||||
case ERROR_USER_NOT_STARTED: {
|
||||
return "user has not started";
|
||||
}
|
||||
case ERROR_USER_ALREADY_STARTED: {
|
||||
return "user has already started";
|
||||
}
|
||||
case ERROR_USER_NOT_UNLOCKED: {
|
||||
return "user has not unlocked";
|
||||
}
|
||||
case ERROR_USER_ALREADY_UNLOCKED: {
|
||||
return "user has already unlocked";
|
||||
}
|
||||
case ERROR_USER_NOT_LOCKED: {
|
||||
return "user has not locked";
|
||||
}
|
||||
case ERROR_IME_NOT_AVAILABLE: {
|
||||
return "input method engine is not available";
|
||||
}
|
||||
case ERROR_SECURITY_IME_NOT_AVAILABLE: {
|
||||
return "security input method engine is not available";
|
||||
}
|
||||
case ERROR_TOKEN_CREATE_FAILED: {
|
||||
return "failed to create token";
|
||||
}
|
||||
case ERROR_TOKEN_DESTROY_FAILED: {
|
||||
return "failed to destroy token";
|
||||
}
|
||||
case ERROR_IME_BIND_FAILED: {
|
||||
return "failed to bind service";
|
||||
}
|
||||
case ERROR_IME_UNBIND_FAILED: {
|
||||
return "failed to unbind service";
|
||||
}
|
||||
case ERROR_IME_START_FAILED: {
|
||||
return "failed to start input";
|
||||
}
|
||||
case ERROR_IME_STOP_FAILED: {
|
||||
return "failed to stop input";
|
||||
}
|
||||
case ERROR_KBD_SHOW_FAILED: {
|
||||
return "failed to show keyboard";
|
||||
}
|
||||
case ERROR_KBD_HIDE_FAILED: {
|
||||
return "failed to hide keyboard";
|
||||
}
|
||||
case ERROR_IME_NOT_STARTED: {
|
||||
return "input method service has not started";
|
||||
}
|
||||
case ERROR_KBD_IS_OCCUPIED: {
|
||||
return "keyboard is showing by another client";
|
||||
}
|
||||
case ERROR_KBD_IS_NOT_SHOWING: {
|
||||
return "keyboard is not showing";
|
||||
}
|
||||
case ERROR_IME_ALREADY_STARTED: {
|
||||
return "input method service has already started";
|
||||
}
|
||||
case ERROR_NOT_IME_PACKAGE: {
|
||||
return "not an input method engine package";
|
||||
}
|
||||
case ERROR_IME_PACKAGE_DUPLICATED: {
|
||||
return "duplicated input method engine package";
|
||||
}
|
||||
case ERROR_SETTING_SAME_VALUE: {
|
||||
return "same setting value";
|
||||
}
|
||||
case ERROR_NO_NEXT_IME: {
|
||||
return "next input method engine is not available";
|
||||
}
|
||||
case ERROR_CLIENTWINDOW_NOT_FOCUSED: {
|
||||
return "input client window is not focused";
|
||||
}
|
||||
case ERROR_CLIENT_NOT_WINDOW: {
|
||||
return "input client is not from a valid window";
|
||||
}
|
||||
case ERROR_REMOTE_IME_DIED: {
|
||||
return "input method service died";
|
||||
}
|
||||
case ERROR_RESTART_IME_FAILED: {
|
||||
return "failed to restart input method service";
|
||||
}
|
||||
case ERROR_REMOTE_CLIENT_DIED: {
|
||||
return "input client died";
|
||||
}
|
||||
case ERROR_CLIENT_DUPLICATED: {
|
||||
return "duplicated client";
|
||||
}
|
||||
case ERROR_CLIENT_NOT_FOUND: {
|
||||
return "client is not found";
|
||||
}
|
||||
case ERROR_STATUS_UNKNOWN_ERROR: {
|
||||
return "unknown error";
|
||||
}
|
||||
case ERROR_STATUS_NO_MEMORY: {
|
||||
return "no memory";
|
||||
}
|
||||
case ERROR_STATUS_INVALID_OPERATION: {
|
||||
return "invalid operation";
|
||||
}
|
||||
case ERROR_STATUS_BAD_VALUE: {
|
||||
return "bad value";
|
||||
}
|
||||
case ERROR_STATUS_BAD_TYPE: {
|
||||
return "bad type";
|
||||
}
|
||||
case ERROR_STATUS_NAME_NOT_FOUND: {
|
||||
return "name not found";
|
||||
}
|
||||
case ERROR_STATUS_PERMISSION_DENIED: {
|
||||
return "permission denied";
|
||||
}
|
||||
case ERROR_STATUS_NO_INIT: {
|
||||
return "no init";
|
||||
}
|
||||
case ERROR_STATUS_ALREADY_EXISTS: {
|
||||
return "already exists";
|
||||
}
|
||||
case ERROR_STATUS_DEAD_OBJECT: {
|
||||
return "dead object";
|
||||
}
|
||||
case ERROR_STATUS_FAILED_TRANSACTION: {
|
||||
return "failed transaction";
|
||||
}
|
||||
case ERROR_STATUS_BAD_INDEX: {
|
||||
return "bad index";
|
||||
}
|
||||
case ERROR_STATUS_NOT_ENOUGH_DATA: {
|
||||
return "not enough data";
|
||||
}
|
||||
case ERROR_STATUS_WOULD_BLOCK: {
|
||||
return "would block";
|
||||
}
|
||||
case ERROR_STATUS_TIMED_OUT: {
|
||||
return "time out";
|
||||
}
|
||||
case ERROR_STATUS_UNKNOWN_TRANSACTION: {
|
||||
return "unknown transaction";
|
||||
}
|
||||
case ERROR_STATUS_FDS_NOT_ALLOWED: {
|
||||
return "fds not allowed";
|
||||
}
|
||||
case ERROR_STATUS_UNEXPECTED_NULL: {
|
||||
return "unexpected null";
|
||||
}
|
||||
case ERROR_EX_ILLEGAL_ARGUMENT: {
|
||||
return "illegal argument exception";
|
||||
}
|
||||
case ERROR_EX_NULL_POINTER: {
|
||||
return "null pointer exception";
|
||||
}
|
||||
case ERROR_EX_ILLEGAL_STATE: {
|
||||
return "illegal state exception";
|
||||
}
|
||||
case ERROR_EX_NETWORK_MAIN_THREAD: {
|
||||
return "network main thread exception";
|
||||
}
|
||||
case ERROR_EX_UNSUPPORTED_OPERATION: {
|
||||
return "unsupported operation exception";
|
||||
}
|
||||
case ERROR_EX_SERVICE_SPECIFIC: {
|
||||
return "service specific exception";
|
||||
}
|
||||
case ERROR_EX_PARCELABLE: {
|
||||
return "parcelable exception";
|
||||
}
|
||||
default: {
|
||||
return "error is out of definition";
|
||||
}
|
||||
}
|
||||
return "error is out of definition";
|
||||
};
|
||||
}
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
struct tm nowTime;
|
||||
localtime_r(&tv.tv_sec, &nowTime);
|
||||
printf("%02d-%02d %02d:%02d:%02d.%03d\t", nowTime.tm_mon, nowTime.tm_mday,
|
||||
nowTime.tm_hour, nowTime.tm_min, nowTime.tm_sec, (int)tv.tv_usec/1000);
|
||||
}
|
||||
|
||||
namespace ErrorCode {
|
||||
const char *ToString(int errorCode)
|
||||
{
|
||||
switch (errorCode) {
|
||||
case NO_ERROR: {
|
||||
return "no error";
|
||||
}
|
||||
case ERROR_NULL_POINTER: {
|
||||
return "null pointer";
|
||||
}
|
||||
case ERROR_BAD_PARAMETERS: {
|
||||
return "bad parameters";
|
||||
}
|
||||
case ERROR_SERVICE_START_FAILED: {
|
||||
return "failed to start service";
|
||||
}
|
||||
case ERROR_USER_NOT_STARTED: {
|
||||
return "user has not started";
|
||||
}
|
||||
case ERROR_USER_ALREADY_STARTED: {
|
||||
return "user has already started";
|
||||
}
|
||||
case ERROR_USER_NOT_UNLOCKED: {
|
||||
return "user has not unlocked";
|
||||
}
|
||||
case ERROR_USER_ALREADY_UNLOCKED: {
|
||||
return "user has already unlocked";
|
||||
}
|
||||
case ERROR_USER_NOT_LOCKED: {
|
||||
return "user has not locked";
|
||||
}
|
||||
case ERROR_IME_NOT_AVAILABLE: {
|
||||
return "input method engine is not available";
|
||||
}
|
||||
case ERROR_SECURITY_IME_NOT_AVAILABLE: {
|
||||
return "security input method engine is not available";
|
||||
}
|
||||
case ERROR_TOKEN_CREATE_FAILED: {
|
||||
return "failed to create token";
|
||||
}
|
||||
case ERROR_TOKEN_DESTROY_FAILED: {
|
||||
return "failed to destroy token";
|
||||
}
|
||||
case ERROR_IME_BIND_FAILED: {
|
||||
return "failed to bind service";
|
||||
}
|
||||
case ERROR_IME_UNBIND_FAILED: {
|
||||
return "failed to unbind service";
|
||||
}
|
||||
case ERROR_IME_START_FAILED: {
|
||||
return "failed to start input";
|
||||
}
|
||||
case ERROR_IME_STOP_FAILED: {
|
||||
return "failed to stop input";
|
||||
}
|
||||
case ERROR_KBD_SHOW_FAILED: {
|
||||
return "failed to show keyboard";
|
||||
}
|
||||
case ERROR_KBD_HIDE_FAILED: {
|
||||
return "failed to hide keyboard";
|
||||
}
|
||||
case ERROR_IME_NOT_STARTED: {
|
||||
return "input method service has not started";
|
||||
}
|
||||
case ERROR_KBD_IS_OCCUPIED: {
|
||||
return "keyboard is showing by another client";
|
||||
}
|
||||
case ERROR_KBD_IS_NOT_SHOWING: {
|
||||
return "keyboard is not showing";
|
||||
}
|
||||
case ERROR_IME_ALREADY_STARTED: {
|
||||
return "input method service has already started";
|
||||
}
|
||||
case ERROR_NOT_IME_PACKAGE: {
|
||||
return "not an input method engine package";
|
||||
}
|
||||
case ERROR_IME_PACKAGE_DUPLICATED: {
|
||||
return "duplicated input method engine package";
|
||||
}
|
||||
case ERROR_SETTING_SAME_VALUE: {
|
||||
return "same setting value";
|
||||
}
|
||||
case ERROR_NO_NEXT_IME: {
|
||||
return "next input method engine is not available";
|
||||
}
|
||||
case ERROR_CLIENTWINDOW_NOT_FOCUSED: {
|
||||
return "input client window is not focused";
|
||||
}
|
||||
case ERROR_CLIENT_NOT_WINDOW: {
|
||||
return "input client is not from a valid window";
|
||||
}
|
||||
case ERROR_REMOTE_IME_DIED: {
|
||||
return "input method service died";
|
||||
}
|
||||
case ERROR_RESTART_IME_FAILED: {
|
||||
return "failed to restart input method service";
|
||||
}
|
||||
case ERROR_REMOTE_CLIENT_DIED: {
|
||||
return "input client died";
|
||||
}
|
||||
case ERROR_CLIENT_DUPLICATED: {
|
||||
return "duplicated client";
|
||||
}
|
||||
case ERROR_CLIENT_NOT_FOUND: {
|
||||
return "client is not found";
|
||||
}
|
||||
case ERROR_STATUS_UNKNOWN_ERROR: {
|
||||
return "unknown error";
|
||||
}
|
||||
case ERROR_STATUS_NO_MEMORY: {
|
||||
return "no memory";
|
||||
}
|
||||
case ERROR_STATUS_INVALID_OPERATION: {
|
||||
return "invalid operation";
|
||||
}
|
||||
case ERROR_STATUS_BAD_VALUE: {
|
||||
return "bad value";
|
||||
}
|
||||
case ERROR_STATUS_BAD_TYPE: {
|
||||
return "bad type";
|
||||
}
|
||||
case ERROR_STATUS_NAME_NOT_FOUND: {
|
||||
return "name not found";
|
||||
}
|
||||
case ERROR_STATUS_PERMISSION_DENIED: {
|
||||
return "permission denied";
|
||||
}
|
||||
case ERROR_STATUS_NO_INIT: {
|
||||
return "no init";
|
||||
}
|
||||
case ERROR_STATUS_ALREADY_EXISTS: {
|
||||
return "already exists";
|
||||
}
|
||||
case ERROR_STATUS_DEAD_OBJECT: {
|
||||
return "dead object";
|
||||
}
|
||||
case ERROR_STATUS_FAILED_TRANSACTION: {
|
||||
return "failed transaction";
|
||||
}
|
||||
case ERROR_STATUS_BAD_INDEX: {
|
||||
return "bad index";
|
||||
}
|
||||
case ERROR_STATUS_NOT_ENOUGH_DATA: {
|
||||
return "not enough data";
|
||||
}
|
||||
case ERROR_STATUS_WOULD_BLOCK: {
|
||||
return "would block";
|
||||
}
|
||||
case ERROR_STATUS_TIMED_OUT: {
|
||||
return "time out";
|
||||
}
|
||||
case ERROR_STATUS_UNKNOWN_TRANSACTION: {
|
||||
return "unknown transaction";
|
||||
}
|
||||
case ERROR_STATUS_FDS_NOT_ALLOWED: {
|
||||
return "fds not allowed";
|
||||
}
|
||||
case ERROR_STATUS_UNEXPECTED_NULL: {
|
||||
return "unexpected null";
|
||||
}
|
||||
case ERROR_EX_ILLEGAL_ARGUMENT: {
|
||||
return "illegal argument exception";
|
||||
}
|
||||
case ERROR_EX_NULL_POINTER: {
|
||||
return "null pointer exception";
|
||||
}
|
||||
case ERROR_EX_ILLEGAL_STATE: {
|
||||
return "illegal state exception";
|
||||
}
|
||||
case ERROR_EX_NETWORK_MAIN_THREAD: {
|
||||
return "network main thread exception";
|
||||
}
|
||||
case ERROR_EX_UNSUPPORTED_OPERATION: {
|
||||
return "unsupported operation exception";
|
||||
}
|
||||
case ERROR_EX_SERVICE_SPECIFIC: {
|
||||
return "service specific exception";
|
||||
}
|
||||
case ERROR_EX_PARCELABLE: {
|
||||
return "parcelable exception";
|
||||
}
|
||||
default: {
|
||||
return "error is out of definition";
|
||||
}
|
||||
}
|
||||
return "error is out of definition";
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,89 +17,91 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
/*! Constructor
|
||||
*/
|
||||
InputAttribute::InputAttribute() : enterKeyType(0), inputOption(0)
|
||||
{
|
||||
}
|
||||
/*! Constructor
|
||||
*/
|
||||
InputAttribute::InputAttribute() : enterKeyType(0), inputOption(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*! Constructor
|
||||
\param attribute the source attribute copied to this instance
|
||||
*/
|
||||
InputAttribute::InputAttribute(const InputAttribute& attribute)
|
||||
{
|
||||
inputPattern = attribute.inputPattern;
|
||||
enterKeyType = attribute.enterKeyType;
|
||||
inputOption = attribute.inputOption;
|
||||
}
|
||||
/*! Constructor
|
||||
\param attribute the source attribute copied to this instance
|
||||
*/
|
||||
InputAttribute::InputAttribute(const InputAttribute& attribute)
|
||||
{
|
||||
inputPattern = attribute.inputPattern;
|
||||
enterKeyType = attribute.enterKeyType;
|
||||
inputOption = attribute.inputOption;
|
||||
}
|
||||
|
||||
/*! Destructor
|
||||
*/
|
||||
InputAttribute::~InputAttribute()
|
||||
{
|
||||
}
|
||||
/*! Destructor
|
||||
*/
|
||||
InputAttribute::~InputAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
/*! operator=
|
||||
\param attribute the source attribute copied to this instance
|
||||
\return return this
|
||||
*/
|
||||
InputAttribute& InputAttribute::operator=(const InputAttribute& attribute)
|
||||
{
|
||||
if (this == &attribute) {
|
||||
/*! operator=
|
||||
\param attribute the source attribute copied to this instance
|
||||
\return return this
|
||||
*/
|
||||
InputAttribute& InputAttribute::operator=(const InputAttribute& attribute)
|
||||
{
|
||||
if (this == &attribute) {
|
||||
return *this;
|
||||
}
|
||||
inputPattern = attribute.inputPattern;
|
||||
enterKeyType = attribute.enterKeyType;
|
||||
inputOption = attribute.inputOption;
|
||||
return *this;
|
||||
}
|
||||
inputPattern = attribute.inputPattern;
|
||||
enterKeyType = attribute.enterKeyType;
|
||||
inputOption = attribute.inputOption;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*! Write InputAttribute to parcel
|
||||
\param[out] parcel write the data of InputAttribute to this parcel returned to caller
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
bool InputAttribute::Marshalling(OHOS::Parcel &parcel) const {
|
||||
if (!(parcel.WriteInt32(inputPattern)
|
||||
&& parcel.WriteInt32(enterKeyType)
|
||||
&& parcel.WriteInt32(inputOption)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! Read InputAttribute from parcel
|
||||
\param parcel read the data of InputAttribute from this parcel
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
InputAttribute* InputAttribute::Unmarshalling(OHOS::Parcel &parcel) {
|
||||
auto info = new InputAttribute();
|
||||
info->inputPattern = parcel.ReadInt32();
|
||||
info->enterKeyType = parcel.ReadInt32();
|
||||
info->inputOption = parcel.ReadInt32();
|
||||
return info;
|
||||
}
|
||||
|
||||
/*! Get the security flag
|
||||
\return true - It's password EditView. The input method management service should start system
|
||||
security input method engine for this view.
|
||||
\return false - It's an normal view.
|
||||
*/
|
||||
bool InputAttribute::GetSecurityFlag()
|
||||
{
|
||||
if (inputPattern == PATTERN_PASSWORD) {
|
||||
/*! Write InputAttribute to parcel
|
||||
\param[out] parcel write the data of InputAttribute to this parcel returned to caller
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
bool InputAttribute::Marshalling(OHOS::Parcel &parcel) const
|
||||
{
|
||||
if (!(parcel.WriteInt32(inputPattern)
|
||||
&& parcel.WriteInt32(enterKeyType)
|
||||
&& parcel.WriteInt32(inputOption)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*! Set input pattern.
|
||||
\n It's added for Unit test of PerUserSession
|
||||
\param pattern PATTERN_PASSWORD or 0.
|
||||
*/
|
||||
void InputAttribute::SetInputPattern(int32_t pattern)
|
||||
{
|
||||
inputPattern = pattern;
|
||||
}
|
||||
/*! Read InputAttribute from parcel
|
||||
\param parcel read the data of InputAttribute from this parcel
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
InputAttribute *InputAttribute::Unmarshalling(OHOS::Parcel &parcel)
|
||||
{
|
||||
auto info = new InputAttribute();
|
||||
info->inputPattern = parcel.ReadInt32();
|
||||
info->enterKeyType = parcel.ReadInt32();
|
||||
info->inputOption = parcel.ReadInt32();
|
||||
return info;
|
||||
}
|
||||
|
||||
/*! Get the security flag
|
||||
\return true - It's password EditView. The input method management service should start system
|
||||
security input method engine for this view.
|
||||
\return false - It's an normal view.
|
||||
*/
|
||||
bool InputAttribute::GetSecurityFlag()
|
||||
{
|
||||
if (inputPattern == PATTERN_PASSWORD) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*! Set input pattern.
|
||||
\n It's added for Unit test of PerUserSession
|
||||
\param pattern PATTERN_PASSWORD or 0.
|
||||
*/
|
||||
void InputAttribute::SetInputPattern(int32_t pattern)
|
||||
{
|
||||
inputPattern = pattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,42 +19,44 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
/*! Constructor
|
||||
*/
|
||||
InputChannel::InputChannel()
|
||||
{
|
||||
}
|
||||
/*! Constructor
|
||||
*/
|
||||
InputChannel::InputChannel()
|
||||
{
|
||||
}
|
||||
|
||||
/*! Destructor
|
||||
*/
|
||||
InputChannel::~InputChannel()
|
||||
{
|
||||
}
|
||||
/*! Destructor
|
||||
*/
|
||||
InputChannel::~InputChannel()
|
||||
{
|
||||
}
|
||||
|
||||
/*! Write InputChannel to parcel
|
||||
\param[out] parcel the data of InputChannel is written to this parcel returned to caller
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
bool InputChannel::Marshalling(Parcel &parcel) const {
|
||||
parcel.ParseFrom(inputChannelParcel.GetData(), inputChannelParcel.GetDataSize());
|
||||
return NO_ERROR;
|
||||
}
|
||||
/*! Write InputChannel to parcel
|
||||
\param[out] parcel the data of InputChannel is written to this parcel returned to caller
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
bool InputChannel::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
parcel.ParseFrom(inputChannelParcel.GetData(), inputChannelParcel.GetDataSize());
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
/*! Get InputChannel from parcel
|
||||
\param parcel get the data of InputChannel from this parcel
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
InputChannel* InputChannel::Unmarshalling(Parcel &parcel) {
|
||||
auto inputChannel = new InputChannel();
|
||||
inputChannel->inputChannelParcel.RewindRead(0);
|
||||
inputChannel->inputChannelParcel.ParseFrom(parcel.GetData(), parcel.GetDataSize());
|
||||
inputChannel->inputChannelParcel.RewindRead(0);
|
||||
/*! Get InputChannel from parcel
|
||||
\param parcel get the data of InputChannel from this parcel
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
InputChannel *InputChannel::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
auto inputChannel = new InputChannel();
|
||||
inputChannel->inputChannelParcel.RewindRead(0);
|
||||
inputChannel->inputChannelParcel.ParseFrom(parcel.GetData(), parcel.GetDataSize());
|
||||
inputChannel->inputChannelParcel.RewindRead(0);
|
||||
|
||||
inputChannel->name = inputChannel->inputChannelParcel.ReadString16();
|
||||
inputChannel->inputChannelParcel.RewindRead(0);
|
||||
return inputChannel;
|
||||
}
|
||||
inputChannel->name = inputChannel->inputChannelParcel.ReadString16();
|
||||
inputChannel->inputChannelParcel.RewindRead(0);
|
||||
return inputChannel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "i_input_method_agent.h"
|
||||
#include "input_control_channel_proxy.h"
|
||||
|
||||
|
||||
/*! \class InputControlChannelProxy
|
||||
\brief The proxy implementation of IInputControlChannel
|
||||
|
||||
@@ -32,14 +31,16 @@
|
||||
*/
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
InputControlChannelProxy::InputControlChannelProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IInputControlChannel>(impl) {
|
||||
InputControlChannelProxy::InputControlChannelProxy(const sptr<IRemoteObject> &impl)
|
||||
: IRemoteProxy<IInputControlChannel>(impl)
|
||||
{
|
||||
}
|
||||
|
||||
InputControlChannelProxy::~InputControlChannelProxy()
|
||||
{
|
||||
}
|
||||
|
||||
void InputControlChannelProxy::onAgentCreated(sptr<IInputMethodAgent> &agent, InputChannel* channel)
|
||||
void InputControlChannelProxy::onAgentCreated(sptr<IInputMethodAgent> &agent, InputChannel *channel)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelProxy::onAgentCreated start.");
|
||||
MessageParcel data, reply;
|
||||
@@ -101,5 +102,3 @@ namespace MiscServices {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,233 +23,235 @@
|
||||
#include "message_parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
/*! Constructor
|
||||
\param userId the id of the user to whom the object is linking
|
||||
*/
|
||||
InputControlChannelStub::InputControlChannelStub(int userId)
|
||||
{
|
||||
userId_ = userId;
|
||||
namespace MiscServices {
|
||||
/*! Constructor
|
||||
\param userId the id of the user to whom the object is linking
|
||||
*/
|
||||
InputControlChannelStub::InputControlChannelStub(int userId)
|
||||
{
|
||||
userId_ = userId;
|
||||
}
|
||||
|
||||
/*! Destructor
|
||||
*/
|
||||
InputControlChannelStub::~InputControlChannelStub()
|
||||
{
|
||||
}
|
||||
|
||||
/*! Handle the transaction from the remote binder
|
||||
\n Run in binder thread
|
||||
\param code transaction code number
|
||||
\param data the params from remote binder
|
||||
\param[out] reply the result of the transaction replied to the remote binder
|
||||
\param flags the flags of handling transaction
|
||||
\return int32_t
|
||||
*/
|
||||
int32_t InputControlChannelStub::OnRemoteRequest(uint32_t code, MessageParcel& data,
|
||||
MessageParcel& reply, MessageOption& option)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::OnRemoteRequest code = %{public}u", code);
|
||||
auto descriptorToken = data.ReadInterfaceToken();
|
||||
if (descriptorToken != GetDescriptor()) {
|
||||
return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
|
||||
}
|
||||
switch (code) {
|
||||
case ON_AGENT_CREATED: {
|
||||
sptr<InputMethodAgentProxy> proxy = new InputMethodAgentProxy(data.ReadRemoteObject());
|
||||
sptr<IInputMethodAgent> agent = proxy;
|
||||
|
||||
/*! Destructor
|
||||
*/
|
||||
InputControlChannelStub::~InputControlChannelStub() {
|
||||
}
|
||||
|
||||
/*! Handle the transaction from the remote binder
|
||||
\n Run in binder thread
|
||||
\param code transaction code number
|
||||
\param data the params from remote binder
|
||||
\param[out] reply the result of the transaction replied to the remote binder
|
||||
\param flags the flags of handling transaction
|
||||
\return int32_t
|
||||
*/
|
||||
int32_t InputControlChannelStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::OnRemoteRequest code = %{public}u", code);
|
||||
auto descriptorToken = data.ReadInterfaceToken();
|
||||
if (descriptorToken != GetDescriptor()) {
|
||||
return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
|
||||
}
|
||||
switch (code) {
|
||||
case ON_AGENT_CREATED: {
|
||||
sptr<InputMethodAgentProxy> proxy = new InputMethodAgentProxy(data.ReadRemoteObject());
|
||||
sptr<IInputMethodAgent> agent = proxy;
|
||||
|
||||
InputChannel* channel = nullptr;
|
||||
if (data.ReadInt32() > 0) {
|
||||
channel = data.ReadParcelable<InputChannel>();
|
||||
}
|
||||
onAgentCreated(agent, channel);
|
||||
reply.WriteNoException();
|
||||
break;
|
||||
}
|
||||
case HIDE_KEYBOARD_SELF: {
|
||||
int flag = data.ReadInt32();
|
||||
hideKeyboardSelf(flag);
|
||||
reply.WriteNoException();
|
||||
break;
|
||||
}
|
||||
case ADVANCE_TO_NEXT: {
|
||||
bool isCurrentIme = data.ReadInt32();
|
||||
bool ret = advanceToNext(isCurrentIme);
|
||||
reply.WriteNoException();
|
||||
reply.WriteBool(ret);
|
||||
break;
|
||||
}
|
||||
case SET_DISPLAY_MODE: {
|
||||
int mode = data.ReadInt32();
|
||||
setDisplayMode(mode);
|
||||
reply.WriteNoException();
|
||||
break;
|
||||
}
|
||||
case ON_KEYBOARD_SHOWED: {
|
||||
onKeyboardShowed();
|
||||
reply.WriteNoException();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return IRemoteStub::OnRemoteRequest(code, data, reply, option);
|
||||
InputChannel *channel = nullptr;
|
||||
if (data.ReadInt32() > 0) {
|
||||
channel = data.ReadParcelable<InputChannel>();
|
||||
}
|
||||
onAgentCreated(agent, channel);
|
||||
reply.WriteNoException();
|
||||
break;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/*! Called when input method service creates InputMethodAgentProxy
|
||||
\n This call is running in binder thread
|
||||
\param agent the remote handler from input method service, with which input client can remotely callback to
|
||||
input method service
|
||||
\param channel channel for sending physical keyboard event from input client to input method service
|
||||
*/
|
||||
void InputControlChannelStub::onAgentCreated(sptr < IInputMethodAgent >& agent, InputChannel* channel)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::onAgentCreated");
|
||||
{
|
||||
std::unique_lock < std::mutex > lck(mtx);
|
||||
agentReadyFlag = true;
|
||||
case HIDE_KEYBOARD_SELF: {
|
||||
int flag = data.ReadInt32();
|
||||
hideKeyboardSelf(flag);
|
||||
reply.WriteNoException();
|
||||
break;
|
||||
}
|
||||
this->agent = agent;
|
||||
this->channel = channel;
|
||||
cv.notify_one();
|
||||
}
|
||||
|
||||
/*! Called when input method service showed keyboard
|
||||
\n This call is running in binder thread
|
||||
*/
|
||||
void InputControlChannelStub::onKeyboardShowed()
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::onKeyboardShowed");
|
||||
{
|
||||
std::unique_lock < std::mutex > lck(mtx);
|
||||
keyboardReadyFlag = true;
|
||||
case ADVANCE_TO_NEXT: {
|
||||
bool isCurrentIme = data.ReadInt32();
|
||||
bool ret = advanceToNext(isCurrentIme);
|
||||
reply.WriteNoException();
|
||||
reply.WriteBool(ret);
|
||||
break;
|
||||
}
|
||||
cv.notify_one();
|
||||
}
|
||||
|
||||
/*! Send hideKeyboardSelf command to work thread.
|
||||
\n This call is running in binder thread,
|
||||
but the handling of hideKeyboardSelf is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnHideKeyboardSelf
|
||||
\param flags the flag value of hiding keyboard
|
||||
*/
|
||||
void InputControlChannelStub::hideKeyboardSelf(int flags)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::hideKeyboardSelf flags = %{public}d", flags);
|
||||
MessageParcel* parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId_);
|
||||
parcel->WriteInt32(flags);
|
||||
|
||||
Message* msg = new Message(MessageID::MSG_ID_HIDE_KEYBOARD_SELF, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Send advanceToNext command to work thread.
|
||||
\n This call is running in binder thread,
|
||||
but the handling of advanceToNext is in the work thread of InputMethodSystemAbility service
|
||||
\n or in the work thread of PerUserSession
|
||||
\see InputMethodSystemAbility::OnAdvanceToNext PerUserSession::OnAdvanceToNext
|
||||
\see PerUserSetting::OnAdvanceToNext
|
||||
\param isCurrentIme true - switch to next keyboard type within current input method engine
|
||||
\n false - switch to next input method engine
|
||||
\return true
|
||||
*/
|
||||
bool InputControlChannelStub::advanceToNext(bool isCurrentIme)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::advanceToNext");
|
||||
MessageParcel* parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId_);
|
||||
parcel->WriteBool(isCurrentIme);
|
||||
|
||||
Message* msg = new Message(MessageID::MSG_ID_ADVANCE_TO_NEXT, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! Send setDisplayMode command to work thread.
|
||||
\n This call is running in binder thread,
|
||||
but the handling of setDisplayMode is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnSetDisplayMode
|
||||
\param mode 0 - part screen mode, 1 - full screen mode
|
||||
*/
|
||||
void InputControlChannelStub::setDisplayMode(int mode)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::setDisplayMode start");
|
||||
MessageParcel* parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId_);
|
||||
parcel->WriteInt32(mode);
|
||||
|
||||
Message* msg = new Message(MessageID::MSG_ID_SET_DISPLAY_MODE, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Reset ready flag to be false
|
||||
\n This should be called before imsCore->startInput() in work thread of PerUserSession
|
||||
*/
|
||||
void InputControlChannelStub::ResetFlag()
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::ResetFlag");
|
||||
std::unique_lock < std::mutex > lck(mtx);
|
||||
keyboardReadyFlag = false;
|
||||
agentReadyFlag = false;
|
||||
if (agent) {
|
||||
agent = nullptr;
|
||||
case SET_DISPLAY_MODE: {
|
||||
int mode = data.ReadInt32();
|
||||
setDisplayMode(mode);
|
||||
reply.WriteNoException();
|
||||
break;
|
||||
}
|
||||
if (channel) {
|
||||
delete channel;
|
||||
channel = nullptr;
|
||||
case ON_KEYBOARD_SHOWED: {
|
||||
onKeyboardShowed();
|
||||
reply.WriteNoException();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return IRemoteStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
}
|
||||
/*! Get input method agent and input write channel
|
||||
\n This should be called in work thread of PerUserSession
|
||||
\param[out] retAgent remote handler of InputMethodAgentProxy returned to the caller
|
||||
\param[out] retChannel input write channel returned to caller
|
||||
\return true - onAgentCreated is called by input method service in time
|
||||
\n false - onAgentCreated is not called by input method service in time
|
||||
*/
|
||||
bool InputControlChannelStub::GetAgentAndChannel(sptr<IInputMethodAgent>* retAgent, InputChannel** retChannel)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::GetAgentAndChannel");
|
||||
std::chrono::milliseconds millsec(300);
|
||||
bool ret = false;
|
||||
{
|
||||
std::unique_lock < std::mutex > lck(mtx);
|
||||
ret = cv.wait_for(lck, millsec, [this] {
|
||||
return agentReadyFlag;
|
||||
});
|
||||
}
|
||||
if (ret) {
|
||||
if (retAgent) {
|
||||
*retAgent = agent;
|
||||
agent = nullptr;
|
||||
}
|
||||
if (retChannel) {
|
||||
*retChannel = channel;
|
||||
channel = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
/*! Wait for keyboard to be ready
|
||||
\n This should be called in work thread of PerUserSession
|
||||
\return true - onKeyboardShowed is called by input method service in time
|
||||
\n false - onKeyboardShowed is not called by input method service in time
|
||||
*/
|
||||
bool InputControlChannelStub::WaitKeyboardReady()
|
||||
|
||||
/*! Called when input method service creates InputMethodAgentProxy
|
||||
\n This call is running in binder thread
|
||||
\param agent the remote handler from input method service, with which input client can remotely callback to
|
||||
input method service
|
||||
\param channel channel for sending physical keyboard event from input client to input method service
|
||||
*/
|
||||
void InputControlChannelStub::onAgentCreated(sptr < IInputMethodAgent >& agent, InputChannel *channel)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::onAgentCreated");
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::WaitKeyboardReady");
|
||||
std::chrono::milliseconds millsec(300);
|
||||
bool ret = false;
|
||||
{
|
||||
std::unique_lock < std::mutex > lck(mtx);
|
||||
ret = cv.wait_for(lck, millsec, [this] {
|
||||
return keyboardReadyFlag;
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
std::unique_lock<std::mutex> lck(mtx);
|
||||
agentReadyFlag = true;
|
||||
}
|
||||
this->agent = agent;
|
||||
this->channel = channel;
|
||||
cv.notify_one();
|
||||
}
|
||||
|
||||
/*! Called when input method service showed keyboard
|
||||
\n This call is running in binder thread
|
||||
*/
|
||||
void InputControlChannelStub::onKeyboardShowed()
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::onKeyboardShowed");
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(mtx);
|
||||
keyboardReadyFlag = true;
|
||||
}
|
||||
cv.notify_one();
|
||||
}
|
||||
|
||||
/*! Send hideKeyboardSelf command to work thread.
|
||||
\n This call is running in binder thread,
|
||||
but the handling of hideKeyboardSelf is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnHideKeyboardSelf
|
||||
\param flags the flag value of hiding keyboard
|
||||
*/
|
||||
void InputControlChannelStub::hideKeyboardSelf(int flags)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::hideKeyboardSelf flags = %{public}d", flags);
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId_);
|
||||
parcel->WriteInt32(flags);
|
||||
|
||||
Message *msg = new Message(MessageID::MSG_ID_HIDE_KEYBOARD_SELF, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Send advanceToNext command to work thread.
|
||||
\n This call is running in binder thread,
|
||||
but the handling of advanceToNext is in the work thread of InputMethodSystemAbility service
|
||||
\n or in the work thread of PerUserSession
|
||||
\see InputMethodSystemAbility::OnAdvanceToNext PerUserSession::OnAdvanceToNext
|
||||
\see PerUserSetting::OnAdvanceToNext
|
||||
\param isCurrentIme true - switch to next keyboard type within current input method engine
|
||||
\n false - switch to next input method engine
|
||||
\return true
|
||||
*/
|
||||
bool InputControlChannelStub::advanceToNext(bool isCurrentIme)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::advanceToNext");
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId_);
|
||||
parcel->WriteBool(isCurrentIme);
|
||||
|
||||
Message *msg = new Message(MessageID::MSG_ID_ADVANCE_TO_NEXT, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! Send setDisplayMode command to work thread.
|
||||
\n This call is running in binder thread,
|
||||
but the handling of setDisplayMode is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnSetDisplayMode
|
||||
\param mode 0 - part screen mode, 1 - full screen mode
|
||||
*/
|
||||
void InputControlChannelStub::setDisplayMode(int mode)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::setDisplayMode start");
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId_);
|
||||
parcel->WriteInt32(mode);
|
||||
|
||||
Message *msg = new Message(MessageID::MSG_ID_SET_DISPLAY_MODE, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Reset ready flag to be false
|
||||
\n This should be called before imsCore->startInput() in work thread of PerUserSession
|
||||
*/
|
||||
void InputControlChannelStub::ResetFlag()
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::ResetFlag");
|
||||
std::unique_lock<std::mutex> lck(mtx);
|
||||
keyboardReadyFlag = false;
|
||||
agentReadyFlag = false;
|
||||
if (agent) {
|
||||
agent = nullptr;
|
||||
}
|
||||
if (channel) {
|
||||
delete channel;
|
||||
channel = nullptr;
|
||||
}
|
||||
}
|
||||
/*! Get input method agent and input write channel
|
||||
\n This should be called in work thread of PerUserSession
|
||||
\param[out] retAgent remote handler of InputMethodAgentProxy returned to the caller
|
||||
\param[out] retChannel input write channel returned to caller
|
||||
\return true - onAgentCreated is called by input method service in time
|
||||
\n false - onAgentCreated is not called by input method service in time
|
||||
*/
|
||||
bool InputControlChannelStub::GetAgentAndChannel(sptr<IInputMethodAgent> *retAgent, InputChannel **retChannel)
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::GetAgentAndChannel");
|
||||
std::chrono::milliseconds millsec(sleepTime);
|
||||
bool ret = false;
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(mtx);
|
||||
ret = cv.wait_for(lck, millsec, [this] {
|
||||
return agentReadyFlag;
|
||||
});
|
||||
}
|
||||
if (ret) {
|
||||
if (retAgent) {
|
||||
*retAgent = agent;
|
||||
agent = nullptr;
|
||||
}
|
||||
if (retChannel) {
|
||||
*retChannel = channel;
|
||||
channel = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*! Wait for keyboard to be ready
|
||||
\n This should be called in work thread of PerUserSession
|
||||
\return true - onKeyboardShowed is called by input method service in time
|
||||
\n false - onKeyboardShowed is not called by input method service in time
|
||||
*/
|
||||
bool InputControlChannelStub::WaitKeyboardReady()
|
||||
{
|
||||
IMSA_HILOGI("InputControlChannelStub::WaitKeyboardReady");
|
||||
std::chrono::milliseconds millsec(sleepTime);
|
||||
bool ret = false;
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(mtx);
|
||||
ret = cv.wait_for(lck, millsec, [this] {
|
||||
return keyboardReadyFlag;
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,43 +17,47 @@
|
||||
#include "message_parcel.h"
|
||||
#include "message.h"
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
InputMethodAbilityConnectionStub::InputMethodAbilityConnectionStub(const int index){
|
||||
mIndex = index;
|
||||
}
|
||||
|
||||
InputMethodAbilityConnectionStub::~InputMethodAbilityConnectionStub(){
|
||||
|
||||
}
|
||||
|
||||
void InputMethodAbilityConnectionStub::OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode){
|
||||
IMSA_HILOGE("ConnectAbility: OnAbilityConnectDone.");
|
||||
if(messageHandler != nullptr){
|
||||
MessageParcel* data = new MessageParcel();
|
||||
data->WriteParcelable(&element);
|
||||
data->WriteRemoteObject(remoteObject);
|
||||
data->WriteInt32(mIndex);
|
||||
Message* msg = new Message(MessageID::MSG_ID_ABILITY_CONNECT_DONE, data);
|
||||
messageHandler->SendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void InputMethodAbilityConnectionStub::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) {
|
||||
IMSA_HILOGE("ConnectAbility: OnAbilityDisconnectDone.");
|
||||
if(messageHandler != nullptr){
|
||||
MessageParcel* data = new MessageParcel();
|
||||
data->WriteParcelable(&element);
|
||||
data->WriteInt32(mIndex);
|
||||
Message* msg = new Message(MessageID::MSG_ID_ABILITY_DISCONNECT_DONE, data);
|
||||
messageHandler->SendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void InputMethodAbilityConnectionStub::SetHandler(MessageHandler* handler){
|
||||
messageHandler = handler;
|
||||
}
|
||||
|
||||
namespace MiscServices {
|
||||
InputMethodAbilityConnectionStub::InputMethodAbilityConnectionStub(const int index)
|
||||
{
|
||||
mIndex = index;
|
||||
}
|
||||
|
||||
InputMethodAbilityConnectionStub::~InputMethodAbilityConnectionStub()
|
||||
{
|
||||
}
|
||||
|
||||
void InputMethodAbilityConnectionStub::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
const sptr<IRemoteObject> &remoteObject, int resultCode)
|
||||
{
|
||||
IMSA_HILOGE("ConnectAbility: OnAbilityConnectDone.");
|
||||
if(messageHandler != nullptr){
|
||||
MessageParcel *data = new MessageParcel();
|
||||
data->WriteParcelable(&element);
|
||||
data->WriteRemoteObject(remoteObject);
|
||||
data->WriteInt32(mIndex);
|
||||
Message *msg = new Message(MessageID::MSG_ID_ABILITY_CONNECT_DONE, data);
|
||||
messageHandler->SendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void InputMethodAbilityConnectionStub::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element,
|
||||
int resultCode)
|
||||
{
|
||||
IMSA_HILOGE("ConnectAbility: OnAbilityDisconnectDone.");
|
||||
if(messageHandler != nullptr){
|
||||
MessageParcel *data = new MessageParcel();
|
||||
data->WriteParcelable(&element);
|
||||
data->WriteInt32(mIndex);
|
||||
Message *msg = new Message(MessageID::MSG_ID_ABILITY_DISCONNECT_DONE, data);
|
||||
messageHandler->SendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void InputMethodAbilityConnectionStub::SetHandler(MessageHandler *handler)
|
||||
{
|
||||
messageHandler = handler;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,27 +24,25 @@
|
||||
This class should be implemented by input client
|
||||
*/
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class InputMethodAgentProxy : public IRemoteProxy<IInputMethodAgent> {
|
||||
public:
|
||||
InputMethodAgentProxy(const sptr<IRemoteObject>& impl)
|
||||
: IRemoteProxy<IInputMethodAgent>(impl)
|
||||
{
|
||||
}
|
||||
namespace MiscServices {
|
||||
class InputMethodAgentProxy : public IRemoteProxy<IInputMethodAgent> {
|
||||
public:
|
||||
InputMethodAgentProxy(const sptr<IRemoteObject>& impl)
|
||||
: IRemoteProxy<IInputMethodAgent>(impl)
|
||||
{
|
||||
}
|
||||
|
||||
~InputMethodAgentProxy()
|
||||
{
|
||||
}
|
||||
~InputMethodAgentProxy()
|
||||
{
|
||||
}
|
||||
|
||||
int32_t dispatchKey(int key, int status)
|
||||
{
|
||||
(void)key;
|
||||
(void)status;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
int32_t dispatchKey(int key, int status)
|
||||
{
|
||||
(void)key;
|
||||
(void)status;
|
||||
return NO_ERROR;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,114 +17,110 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
using namespace std;
|
||||
/*! Constructor
|
||||
*/
|
||||
InputMethodProperty::InputMethodProperty()
|
||||
{
|
||||
}
|
||||
|
||||
/*! Destructor
|
||||
*/
|
||||
InputMethodProperty::~InputMethodProperty()
|
||||
{
|
||||
for(int32_t i=0; i<(int32_t)mTypes.size(); i++) {
|
||||
delete mTypes[i];
|
||||
using namespace std;
|
||||
/*! Constructor
|
||||
*/
|
||||
InputMethodProperty::InputMethodProperty()
|
||||
{
|
||||
}
|
||||
mTypes.clear();
|
||||
}
|
||||
|
||||
/*! Constructor
|
||||
\param property the source property will be copied to this instance.
|
||||
*/
|
||||
InputMethodProperty::InputMethodProperty(const InputMethodProperty& property)
|
||||
{
|
||||
mImeId = property.mImeId;
|
||||
mPackageName = property.mPackageName;
|
||||
mAbilityName = property.mAbilityName;
|
||||
mConfigurationPage = property.mConfigurationPage;
|
||||
isSystemIme = property.isSystemIme;
|
||||
mDefaultImeId = property.mDefaultImeId;
|
||||
|
||||
for(int i = 0; i < (int)mTypes.size(); i++) {
|
||||
KeyboardType* type = new KeyboardType(*property.mTypes[i]);
|
||||
mTypes.push_back(type);
|
||||
/*! Destructor
|
||||
*/
|
||||
InputMethodProperty::~InputMethodProperty()
|
||||
{
|
||||
for(int32_t i=0; i<(int32_t)mTypes.size(); i++) {
|
||||
delete mTypes[i];
|
||||
}
|
||||
mTypes.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/*! operator=
|
||||
\param property the source property will be copied to this instance.
|
||||
\return return this
|
||||
*/
|
||||
InputMethodProperty& InputMethodProperty::operator=(const InputMethodProperty& property)
|
||||
{
|
||||
if (this == &property) {
|
||||
/*! Constructor
|
||||
\param property the source property will be copied to this instance.
|
||||
*/
|
||||
InputMethodProperty::InputMethodProperty(const InputMethodProperty& property)
|
||||
{
|
||||
mImeId = property.mImeId;
|
||||
mPackageName = property.mPackageName;
|
||||
mAbilityName = property.mAbilityName;
|
||||
mConfigurationPage = property.mConfigurationPage;
|
||||
isSystemIme = property.isSystemIme;
|
||||
mDefaultImeId = property.mDefaultImeId;
|
||||
|
||||
for(int i = 0; i < (int)mTypes.size(); i++) {
|
||||
KeyboardType *type = new KeyboardType(*property.mTypes[i]);
|
||||
mTypes.push_back(type);
|
||||
}
|
||||
}
|
||||
|
||||
/*! operator=
|
||||
\param property the source property will be copied to this instance.
|
||||
\return return this
|
||||
*/
|
||||
InputMethodProperty& InputMethodProperty::operator=(const InputMethodProperty& property)
|
||||
{
|
||||
if (this == &property) {
|
||||
return *this;
|
||||
}
|
||||
mImeId = property.mImeId;
|
||||
mPackageName = property.mPackageName;
|
||||
mAbilityName = property.mAbilityName;
|
||||
mConfigurationPage = property.mConfigurationPage;
|
||||
isSystemIme = property.isSystemIme;
|
||||
mDefaultImeId = property.mDefaultImeId;
|
||||
|
||||
for(int i = 0; i < (int)mTypes.size(); i++) {
|
||||
KeyboardType *type = new KeyboardType(*property.mTypes[i]);
|
||||
mTypes.push_back(type);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
mImeId = property.mImeId;
|
||||
mPackageName = property.mPackageName;
|
||||
mAbilityName = property.mAbilityName;
|
||||
mConfigurationPage = property.mConfigurationPage;
|
||||
isSystemIme = property.isSystemIme;
|
||||
mDefaultImeId = property.mDefaultImeId;
|
||||
|
||||
for(int i = 0; i < (int)mTypes.size(); i++) {
|
||||
KeyboardType* type = new KeyboardType(*property.mTypes[i]);
|
||||
mTypes.push_back(type);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*! Write InputMethodProperty to parcel
|
||||
\param[out] parcel the information is written to this parcel returned to caller
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
bool InputMethodProperty::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!(parcel.WriteString16(mImeId)
|
||||
&&parcel.WriteString16(mPackageName)
|
||||
&&parcel.WriteString16(mAbilityName)
|
||||
&&parcel.WriteString16(mConfigurationPage)
|
||||
&&parcel.WriteBool(isSystemIme)
|
||||
&&parcel.WriteInt32(mDefaultImeId)))
|
||||
return false;
|
||||
int32_t size = (int32_t)mTypes.size();
|
||||
parcel.WriteInt32(size);
|
||||
if (size == 0)
|
||||
/*! Write InputMethodProperty to parcel
|
||||
\param[out] parcel the information is written to this parcel returned to caller
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
bool InputMethodProperty::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!(parcel.WriteString16(mImeId)
|
||||
&&parcel.WriteString16(mPackageName)
|
||||
&&parcel.WriteString16(mAbilityName)
|
||||
&&parcel.WriteString16(mConfigurationPage)
|
||||
&&parcel.WriteBool(isSystemIme)
|
||||
&&parcel.WriteInt32(mDefaultImeId)))
|
||||
return false;
|
||||
int32_t size = (int32_t)mTypes.size();
|
||||
parcel.WriteInt32(size);
|
||||
if (size == 0)
|
||||
return true;
|
||||
for(int i=0; i<size; i++){
|
||||
parcel.WriteParcelable(mTypes[i]);
|
||||
}
|
||||
return true;
|
||||
for(int i=0; i<size; i++){
|
||||
parcel.WriteParcelable(mTypes[i]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! Get InputMethodProperty from parcel
|
||||
\param parcel read InputMethodProperty from this parcel
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
InputMethodProperty* InputMethodProperty::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
auto info = new InputMethodProperty();
|
||||
info->mImeId = parcel.ReadString16();
|
||||
info->mPackageName = parcel.ReadString16();
|
||||
info->mAbilityName = parcel.ReadString16();
|
||||
info->mConfigurationPage = parcel.ReadString16();
|
||||
info->isSystemIme = parcel.ReadBool();
|
||||
info->mDefaultImeId = parcel.ReadInt32();
|
||||
/*! Get InputMethodProperty from parcel
|
||||
\param parcel read InputMethodProperty from this parcel
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
InputMethodProperty *InputMethodProperty::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
auto info = new InputMethodProperty();
|
||||
info->mImeId = parcel.ReadString16();
|
||||
info->mPackageName = parcel.ReadString16();
|
||||
info->mAbilityName = parcel.ReadString16();
|
||||
info->mConfigurationPage = parcel.ReadString16();
|
||||
info->isSystemIme = parcel.ReadBool();
|
||||
info->mDefaultImeId = parcel.ReadInt32();
|
||||
|
||||
int32_t size = parcel.ReadInt32();
|
||||
if (size == 0)
|
||||
int32_t size = parcel.ReadInt32();
|
||||
if (size == 0)
|
||||
return info;
|
||||
for (int i =0; i < size; i++) {
|
||||
info->mTypes.push_back(parcel.ReadParcelable<KeyboardType>());
|
||||
}
|
||||
return info;
|
||||
for (int i =0; i < size; i++) {
|
||||
info->mTypes.push_back(parcel.ReadParcelable<KeyboardType>());
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -62,7 +62,8 @@ namespace MiscServices {
|
||||
\param[out] parcel the setting data is written to parcel returned to caller.
|
||||
\return ErrorCode::NO_ERROR
|
||||
*/
|
||||
bool InputMethodSetting::Marshalling(OHOS::Parcel &parcel) const {
|
||||
bool InputMethodSetting::Marshalling(OHOS::Parcel &parcel) const
|
||||
{
|
||||
int32_t size = setting.size();
|
||||
parcel.WriteInt32(size);
|
||||
std::map<std::u16string, std::u16string>::const_iterator it;
|
||||
@@ -77,7 +78,8 @@ namespace MiscServices {
|
||||
\param parcel read the setting data from the given parcel
|
||||
\return ErrorCode::NO_ERROR
|
||||
*/
|
||||
InputMethodSetting* InputMethodSetting::Unmarshalling(OHOS::Parcel &parcel) {
|
||||
InputMethodSetting *InputMethodSetting::Unmarshalling(OHOS::Parcel &parcel)
|
||||
{
|
||||
auto ims = new InputMethodSetting();
|
||||
int32_t size = parcel.ReadInt32();
|
||||
for(int i = 0; i < size; i++) {
|
||||
@@ -339,4 +341,4 @@ namespace MiscServices {
|
||||
return retValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,101 +19,118 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
using namespace MessageID;
|
||||
/*! Handle the transaction from the remote binder
|
||||
\n Run in binder thread
|
||||
\param code transaction code number
|
||||
\param data the parameters from remote binder
|
||||
\param[out] reply the result of the transaction replied to the remote binder
|
||||
\param flags the flags of handling transaction
|
||||
\return int32_t
|
||||
*/
|
||||
int32_t InputMethodSystemAbilityStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbilityStub::OnRemoteRequest code = %{public}u", code);
|
||||
auto descriptorToken = data.ReadInterfaceToken();
|
||||
if (descriptorToken != GetDescriptor()) {
|
||||
return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
|
||||
}
|
||||
|
||||
using namespace MessageID;
|
||||
/*! Handle the transaction from the remote binder
|
||||
\n Run in binder thread
|
||||
\param code transaction code number
|
||||
\param data the parameters from remote binder
|
||||
\param[out] reply the result of the transaction replied to the remote binder
|
||||
\param flags the flags of handling transaction
|
||||
\return int32_t
|
||||
*/
|
||||
int32_t InputMethodSystemAbilityStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbilityStub::OnRemoteRequest code = %{public}u", code);
|
||||
auto descriptorToken = data.ReadInterfaceToken();
|
||||
if (descriptorToken != GetDescriptor()) {
|
||||
return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
|
||||
}
|
||||
|
||||
switch(code) {
|
||||
case PREPARE_INPUT: {
|
||||
prepareInput(data);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
break;
|
||||
}
|
||||
case RELEASE_INPUT: {
|
||||
MessageParcel* msgParcel = (MessageParcel*) &data;
|
||||
releaseInput(*msgParcel);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
break;
|
||||
}
|
||||
case START_INPUT: {
|
||||
MessageParcel* msgParcel = (MessageParcel*) &data;
|
||||
startInput(*msgParcel);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
break;
|
||||
}
|
||||
case STOP_INPUT: {
|
||||
MessageParcel* msgParcel = (MessageParcel*) &data;
|
||||
stopInput(*msgParcel);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
break;
|
||||
}
|
||||
case SET_INPUT_METHOD_CORE:{
|
||||
MessageParcel* msgParcel = (MessageParcel*) &data;
|
||||
setInputMethodCoreFromHap(*msgParcel);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
break;
|
||||
}
|
||||
case GET_DISPLAY_MODE: {
|
||||
int32_t mode = 0;
|
||||
int32_t status = getDisplayMode(&mode);
|
||||
if (status == ErrorCode::NO_ERROR) {
|
||||
switch(code) {
|
||||
case PREPARE_INPUT: {
|
||||
prepareInput(data);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
reply.WriteInt32(mode);
|
||||
} else {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE);
|
||||
reply.WriteInt32(-1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GET_KEYBOARD_WINDOW_HEIGHT: {
|
||||
int32_t height = 0;
|
||||
int32_t status = getKeyboardWindowHeight(&height);
|
||||
if (status == ErrorCode::NO_ERROR) {
|
||||
case RELEASE_INPUT: {
|
||||
MessageParcel *msgParcel = (MessageParcel*) &data;
|
||||
releaseInput(*msgParcel);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
reply.WriteInt32(height);
|
||||
} else {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE);
|
||||
reply.WriteInt32(-1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GET_CURRENT_KEYBOARD_TYPE: {
|
||||
KeyboardType type;
|
||||
int32_t status = getCurrentKeyboardType(&type);
|
||||
if (status == ErrorCode::NO_ERROR) {
|
||||
case START_INPUT: {
|
||||
MessageParcel *msgParcel = (MessageParcel*) &data;
|
||||
startInput(*msgParcel);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
reply.WriteParcelable(&type);
|
||||
} else if (status == ErrorCode::ERROR_NULL_POINTER) {
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
reply.WriteInt32(0);
|
||||
} else {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE);
|
||||
reply.WriteInt32(-1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIST_INPUT_METHOD_ENABLED: {
|
||||
std::vector<InputMethodProperty*> properties;
|
||||
int32_t ret = listInputMethodEnabled(&properties);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE); // write exception code
|
||||
reply.WriteInt32(-1);
|
||||
} else {
|
||||
case STOP_INPUT: {
|
||||
MessageParcel *msgParcel = (MessageParcel*) &data;
|
||||
stopInput(*msgParcel);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
break;
|
||||
}
|
||||
case SET_INPUT_METHOD_CORE:{
|
||||
MessageParcel *msgParcel = (MessageParcel*) &data;
|
||||
setInputMethodCoreFromHap(*msgParcel);
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
break;
|
||||
}
|
||||
case GET_DISPLAY_MODE: {
|
||||
int32_t mode = 0;
|
||||
int32_t status = getDisplayMode(&mode);
|
||||
if (status == ErrorCode::NO_ERROR) {
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
reply.WriteInt32(mode);
|
||||
} else {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE);
|
||||
reply.WriteInt32(-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GET_KEYBOARD_WINDOW_HEIGHT: {
|
||||
int32_t height = 0;
|
||||
int32_t status = getKeyboardWindowHeight(height);
|
||||
if (status == ErrorCode::NO_ERROR) {
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
reply.WriteInt32(height);
|
||||
} else {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE);
|
||||
reply.WriteInt32(-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GET_CURRENT_KEYBOARD_TYPE: {
|
||||
KeyboardType type;
|
||||
int32_t status = getCurrentKeyboardType(&type);
|
||||
if (status == ErrorCode::NO_ERROR) {
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
reply.WriteParcelable(&type);
|
||||
} else if (status == ErrorCode::ERROR_NULL_POINTER) {
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
reply.WriteInt32(0);
|
||||
} else {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE);
|
||||
reply.WriteInt32(-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIST_INPUT_METHOD_ENABLED: {
|
||||
std::vector<InputMethodProperty*> properties;
|
||||
int32_t ret = listInputMethodEnabled(&properties);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE); // write exception code
|
||||
reply.WriteInt32(-1);
|
||||
} else {
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
int32_t size = properties.size();
|
||||
reply.WriteInt32(size);
|
||||
for(int32_t i=0; i<size; i++) {
|
||||
reply.WriteParcelable(properties[i]);
|
||||
}
|
||||
properties.clear();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIST_INPUT_METHOD: {
|
||||
std::vector<InputMethodProperty*> properties;
|
||||
int32_t ret = listInputMethod(&properties);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE); // write exception code
|
||||
reply.WriteInt32(-1);
|
||||
return ret;
|
||||
}
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
int32_t size = properties.size();
|
||||
reply.WriteInt32(size);
|
||||
@@ -121,159 +138,140 @@ int32_t InputMethodSystemAbilityStub::OnRemoteRequest(uint32_t code, MessageParc
|
||||
reply.WriteParcelable(properties[i]);
|
||||
}
|
||||
properties.clear();
|
||||
break;
|
||||
}
|
||||
case LIST_KEYBOARD_TYPE: {
|
||||
std::u16string imeId = data.ReadString16();
|
||||
std::vector<KeyboardType*> kbdTypes;
|
||||
int32_t ret = listKeyboardType(imeId, &kbdTypes);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE);
|
||||
reply.WriteInt32(-1);
|
||||
return ret;
|
||||
}
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
int32_t size = kbdTypes.size();
|
||||
reply.WriteInt32(size);
|
||||
for(int32_t i=0; i<size; i++) {
|
||||
reply.WriteParcelable(kbdTypes[i]);
|
||||
}
|
||||
kbdTypes.clear();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return BRemoteObject::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIST_INPUT_METHOD: {
|
||||
std::vector<InputMethodProperty*> properties;
|
||||
int32_t ret = listInputMethod(&properties);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE); // write exception code
|
||||
reply.WriteInt32(-1);
|
||||
return ret;
|
||||
}
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
int32_t size = properties.size();
|
||||
reply.WriteInt32(size);
|
||||
for(int32_t i=0; i<size; i++) {
|
||||
reply.WriteParcelable(properties[i]);
|
||||
}
|
||||
properties.clear();
|
||||
break;
|
||||
}
|
||||
case LIST_KEYBOARD_TYPE: {
|
||||
std::u16string imeId = data.ReadString16();
|
||||
std::vector<KeyboardType*> kbdTypes;
|
||||
int32_t ret = listKeyboardType(imeId, &kbdTypes);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
reply.WriteInt32(ErrorCode::ERROR_EX_ILLEGAL_STATE);
|
||||
reply.WriteInt32(-1);
|
||||
return ret;
|
||||
}
|
||||
reply.WriteInt32(NO_ERROR);
|
||||
int32_t size = kbdTypes.size();
|
||||
reply.WriteInt32(size);
|
||||
for(int32_t i=0; i<size; i++) {
|
||||
reply.WriteParcelable(kbdTypes[i]);
|
||||
}
|
||||
kbdTypes.clear();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return BRemoteObject::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
/*! Prepare input
|
||||
\n Send prepareInput command to work thread.
|
||||
The handling of prepareInput is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnPrepareInput
|
||||
\param data the parcel in which the parameters are saved
|
||||
*/
|
||||
void InputMethodSystemAbilityStub::prepareInput(MessageParcel& data)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbilityStub::prepareInput");
|
||||
int32_t pid = IPCSkeleton::GetCallingPid();
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
MessageParcel* parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
parcel->WriteInt32(pid);
|
||||
parcel->WriteInt32(uid);
|
||||
parcel->WriteInt32(data.ReadInt32());
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
parcel->WriteParcelable(data.ReadParcelable<InputAttribute>());
|
||||
|
||||
Message* msg = new Message(MSG_ID_PREPARE_INPUT, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Release input
|
||||
\n Send releaseInput command to work thread.
|
||||
The handling of releaseInput is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnReleaseInput
|
||||
\param data the parcel in which the parameters are saved
|
||||
*/
|
||||
void InputMethodSystemAbilityStub::releaseInput(MessageParcel& data)
|
||||
{
|
||||
IMSA_HILOGE("InputMethodSystemAbilityStub::releaseInput");
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
MessageParcel* parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
|
||||
Message* msg = new Message(MSG_ID_RELEASE_INPUT, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
|
||||
}
|
||||
|
||||
/*! Start input
|
||||
\n Send startInput command to work thread.
|
||||
The handling of startInput is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnStartInput
|
||||
\param data the parcel in which the parameters are saved
|
||||
*/
|
||||
void InputMethodSystemAbilityStub::startInput(MessageParcel& data)
|
||||
{
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
MessageParcel* parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
|
||||
Message* msg = new Message(MSG_ID_START_INPUT, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Stop input
|
||||
\n Send stopInput command to work thread.
|
||||
The handling of stopInput is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnStopInput
|
||||
\param data the parcel in which the parameters are saved
|
||||
*/
|
||||
void InputMethodSystemAbilityStub::stopInput(MessageParcel& data)
|
||||
{
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
MessageParcel* parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
|
||||
Message* msg = new Message(MSG_ID_STOP_INPUT, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Prepare input
|
||||
\n Send prepareInput command to work thread.
|
||||
The handling of prepareInput is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnPrepareInput
|
||||
\param data the parcel in which the parameters are saved
|
||||
*/
|
||||
\n Send prepareInput command to work thread.
|
||||
The handling of prepareInput is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnPrepareInput
|
||||
\param data the parcel in which the parameters are saved
|
||||
*/
|
||||
void InputMethodSystemAbilityStub::prepareInput(MessageParcel& data)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbilityStub::prepareInput");
|
||||
int32_t pid = IPCSkeleton::GetCallingPid();
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
parcel->WriteInt32(pid);
|
||||
parcel->WriteInt32(uid);
|
||||
parcel->WriteInt32(data.ReadInt32());
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
parcel->WriteParcelable(data.ReadParcelable<InputAttribute>());
|
||||
|
||||
Message *msg = new Message(MSG_ID_PREPARE_INPUT, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Release input
|
||||
\n Send releaseInput command to work thread.
|
||||
The handling of releaseInput is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnReleaseInput
|
||||
\param data the parcel in which the parameters are saved
|
||||
*/
|
||||
void InputMethodSystemAbilityStub::releaseInput(MessageParcel& data)
|
||||
{
|
||||
IMSA_HILOGE("InputMethodSystemAbilityStub::releaseInput");
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
|
||||
Message *msg = new Message(MSG_ID_RELEASE_INPUT, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
|
||||
}
|
||||
|
||||
/*! Start input
|
||||
\n Send startInput command to work thread.
|
||||
The handling of startInput is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnStartInput
|
||||
\param data the parcel in which the parameters are saved
|
||||
*/
|
||||
void InputMethodSystemAbilityStub::startInput(MessageParcel& data)
|
||||
{
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
|
||||
Message *msg = new Message(MSG_ID_START_INPUT, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Stop input
|
||||
\n Send stopInput command to work thread.
|
||||
The handling of stopInput is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnStopInput
|
||||
\param data the parcel in which the parameters are saved
|
||||
*/
|
||||
void InputMethodSystemAbilityStub::stopInput(MessageParcel& data)
|
||||
{
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
|
||||
Message *msg = new Message(MSG_ID_STOP_INPUT, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Prepare input
|
||||
\n Send prepareInput command to work thread.
|
||||
The handling of prepareInput is in the work thread of PerUserSession.
|
||||
\see PerUserSession::OnPrepareInput
|
||||
\param data the parcel in which the parameters are saved
|
||||
*/
|
||||
void InputMethodSystemAbilityStub::setInputMethodCoreFromHap(MessageParcel& data)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbilityStub::setInputMethodCoreFromHap");
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = getUserId(uid);
|
||||
MessageParcel* parcel = new MessageParcel();
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
parcel->WriteRemoteObject(data.ReadRemoteObject());
|
||||
|
||||
Message* msg = new Message(MSG_ID_SET_INPUT_METHOD_CORE, parcel);
|
||||
Message *msg = new Message(MSG_ID_SET_INPUT_METHOD_CORE, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Get user id from uid
|
||||
\param uid the uid from which the remote call is
|
||||
\return return user id of the remote caller
|
||||
*/
|
||||
int32_t InputMethodSystemAbilityStub::getUserId(int32_t uid)
|
||||
{
|
||||
return uid/1000000;
|
||||
}
|
||||
}
|
||||
/*! Get user id from uid
|
||||
\param uid the uid from which the remote call is
|
||||
\return return user id of the remote caller
|
||||
*/
|
||||
int32_t InputMethodSystemAbilityStub::getUserId(int32_t uid)
|
||||
{
|
||||
return uid/1000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
+146
-146
@@ -17,171 +17,171 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
using namespace std;
|
||||
/*! Constructor
|
||||
*/
|
||||
KeyboardType::KeyboardType()
|
||||
{
|
||||
}
|
||||
using namespace std;
|
||||
/*! Constructor
|
||||
*/
|
||||
KeyboardType::KeyboardType()
|
||||
{
|
||||
}
|
||||
|
||||
/*! Constructor from another instance
|
||||
\param type the source instance
|
||||
*/
|
||||
KeyboardType::KeyboardType(const KeyboardType& type)
|
||||
{
|
||||
mId = type.mId;
|
||||
mHashCode = type.mHashCode;
|
||||
mLabelId = type.mLabelId;
|
||||
mIconId = type.mIconId;
|
||||
mIsAsciiCapable = type.mIsAsciiCapable;
|
||||
mLanguage = type.mLanguage;
|
||||
mInputSource = type.mInputSource;
|
||||
mCustomizedValue = type.mCustomizedValue;
|
||||
}
|
||||
/*! Constructor from another instance
|
||||
\param type the source instance
|
||||
*/
|
||||
KeyboardType::KeyboardType(const KeyboardType& type)
|
||||
{
|
||||
mId = type.mId;
|
||||
mHashCode = type.mHashCode;
|
||||
mLabelId = type.mLabelId;
|
||||
mIconId = type.mIconId;
|
||||
mIsAsciiCapable = type.mIsAsciiCapable;
|
||||
mLanguage = type.mLanguage;
|
||||
mInputSource = type.mInputSource;
|
||||
mCustomizedValue = type.mCustomizedValue;
|
||||
}
|
||||
|
||||
/*! Destructor
|
||||
*/
|
||||
KeyboardType::~KeyboardType()
|
||||
{
|
||||
}
|
||||
/*! Destructor
|
||||
*/
|
||||
KeyboardType::~KeyboardType()
|
||||
{
|
||||
}
|
||||
|
||||
/*! Get value from another instance
|
||||
\param type source instance
|
||||
\return return this
|
||||
*/
|
||||
KeyboardType& KeyboardType::operator=(const KeyboardType& type)
|
||||
{
|
||||
if (this == &type) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
mId = type.mId;
|
||||
mHashCode = type.mHashCode;
|
||||
mLabelId = type.mLabelId;
|
||||
mIconId = type.mIconId;
|
||||
mIsAsciiCapable = type.mIsAsciiCapable;
|
||||
mLanguage = type.mLanguage;
|
||||
mInputSource = type.mInputSource;
|
||||
mCustomizedValue = type.mCustomizedValue;
|
||||
|
||||
/*! Get value from another instance
|
||||
\param type source instance
|
||||
\return return this
|
||||
*/
|
||||
KeyboardType& KeyboardType::operator=(const KeyboardType& type)
|
||||
{
|
||||
if (this == &type) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
mId = type.mId;
|
||||
mHashCode = type.mHashCode;
|
||||
mLabelId = type.mLabelId;
|
||||
mIconId = type.mIconId;
|
||||
mIsAsciiCapable = type.mIsAsciiCapable;
|
||||
mLanguage = type.mLanguage;
|
||||
mInputSource = type.mInputSource;
|
||||
mCustomizedValue = type.mCustomizedValue;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*! Write the details of object to parcel
|
||||
*/
|
||||
bool KeyboardType::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!(parcel.WriteInt32(mId)
|
||||
&& parcel.WriteInt32(mHashCode)
|
||||
&& parcel.WriteInt32(mLabelId)
|
||||
&& parcel.WriteInt32(mIconId)
|
||||
&& parcel.WriteBool(mIsAsciiCapable)
|
||||
&& parcel.WriteString16(mLanguage)
|
||||
&& parcel.WriteString16(mInputSource)
|
||||
&& parcel.WriteString16(mCustomizedValue)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! Read the details of object from parcel
|
||||
\param parcel read the details of object from this parcel
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
KeyboardType* KeyboardType::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
auto info = new KeyboardType();
|
||||
info->mId = parcel.ReadInt32();
|
||||
info->mHashCode = parcel.ReadInt32();
|
||||
info->mLabelId = parcel.ReadInt32();
|
||||
info->mIconId = parcel.ReadInt32();
|
||||
info->mIsAsciiCapable = parcel.ReadBool();
|
||||
info->mLanguage = parcel.ReadString16();
|
||||
info->mInputSource = parcel.ReadString16();
|
||||
info->mCustomizedValue = parcel.ReadString16();
|
||||
return info;
|
||||
}
|
||||
|
||||
void KeyboardType::setId(int32_t typeId)
|
||||
{
|
||||
mId = typeId;
|
||||
if (typeId != ID_NONE) {
|
||||
mHashCode = typeId;
|
||||
} else {
|
||||
mHashCode = ID_NONE;
|
||||
/*! Write the details of object to parcel
|
||||
*/
|
||||
bool KeyboardType::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!(parcel.WriteInt32(mId)
|
||||
&& parcel.WriteInt32(mHashCode)
|
||||
&& parcel.WriteInt32(mLabelId)
|
||||
&& parcel.WriteInt32(mIconId)
|
||||
&& parcel.WriteBool(mIsAsciiCapable)
|
||||
&& parcel.WriteString16(mLanguage)
|
||||
&& parcel.WriteString16(mInputSource)
|
||||
&& parcel.WriteString16(mCustomizedValue)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void KeyboardType::setLabelId(int32_t labelId)
|
||||
{
|
||||
mLabelId = labelId;
|
||||
}
|
||||
/*! Read the details of object from parcel
|
||||
\param parcel read the details of object from this parcel
|
||||
\return ErrorCode::NO_ERROR
|
||||
\return ErrorCode::ERROR_NULL_POINTER parcel is null
|
||||
*/
|
||||
KeyboardType *KeyboardType::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
auto info = new KeyboardType();
|
||||
info->mId = parcel.ReadInt32();
|
||||
info->mHashCode = parcel.ReadInt32();
|
||||
info->mLabelId = parcel.ReadInt32();
|
||||
info->mIconId = parcel.ReadInt32();
|
||||
info->mIsAsciiCapable = parcel.ReadBool();
|
||||
info->mLanguage = parcel.ReadString16();
|
||||
info->mInputSource = parcel.ReadString16();
|
||||
info->mCustomizedValue = parcel.ReadString16();
|
||||
return info;
|
||||
}
|
||||
|
||||
void KeyboardType::setIconId(int32_t iconId)
|
||||
{
|
||||
mIconId = iconId;
|
||||
}
|
||||
void KeyboardType::setId(int32_t typeId)
|
||||
{
|
||||
mId = typeId;
|
||||
if (typeId != ID_NONE) {
|
||||
mHashCode = typeId;
|
||||
} else {
|
||||
mHashCode = ID_NONE;
|
||||
}
|
||||
|
||||
void KeyboardType::setAsciiCapability(bool isAsciiCapable)
|
||||
{
|
||||
mIsAsciiCapable = isAsciiCapable;
|
||||
}
|
||||
}
|
||||
|
||||
void KeyboardType::setLanguage(u16string language)
|
||||
{
|
||||
mLanguage = language;
|
||||
}
|
||||
void KeyboardType::setLabelId(int32_t labelId)
|
||||
{
|
||||
mLabelId = labelId;
|
||||
}
|
||||
|
||||
void KeyboardType::setInputSource(u16string inputSource)
|
||||
{
|
||||
mInputSource = inputSource;
|
||||
}
|
||||
void KeyboardType::setIconId(int32_t iconId)
|
||||
{
|
||||
mIconId = iconId;
|
||||
}
|
||||
|
||||
void KeyboardType::setCustomizedValue(u16string keyBoardTypeCustomizedValue)
|
||||
{
|
||||
mCustomizedValue = keyBoardTypeCustomizedValue;
|
||||
}
|
||||
void KeyboardType::setAsciiCapability(bool isAsciiCapable)
|
||||
{
|
||||
mIsAsciiCapable = isAsciiCapable;
|
||||
}
|
||||
|
||||
int32_t KeyboardType::getId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
void KeyboardType::setLanguage(u16string language)
|
||||
{
|
||||
mLanguage = language;
|
||||
}
|
||||
|
||||
int32_t KeyboardType::getLabelId() const
|
||||
{
|
||||
return mLabelId;
|
||||
}
|
||||
void KeyboardType::setInputSource(u16string inputSource)
|
||||
{
|
||||
mInputSource = inputSource;
|
||||
}
|
||||
|
||||
int32_t KeyboardType::getIconId() const
|
||||
{
|
||||
return mIconId;
|
||||
}
|
||||
void KeyboardType::setCustomizedValue(u16string keyBoardTypeCustomizedValue)
|
||||
{
|
||||
mCustomizedValue = keyBoardTypeCustomizedValue;
|
||||
}
|
||||
|
||||
/*! Get hash code of the object
|
||||
\return return hashCode value
|
||||
*/
|
||||
int KeyboardType::getHashCode() const
|
||||
{
|
||||
return mHashCode;
|
||||
}
|
||||
int32_t KeyboardType::getId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
|
||||
/*! Get language of the object
|
||||
\return return the language of this object
|
||||
*/
|
||||
u16string KeyboardType::getLanguage() const
|
||||
{
|
||||
return mLanguage;
|
||||
}
|
||||
int32_t KeyboardType::getLabelId() const
|
||||
{
|
||||
return mLabelId;
|
||||
}
|
||||
|
||||
u16string KeyboardType::getInputSource() const
|
||||
{
|
||||
return mInputSource;
|
||||
}
|
||||
int32_t KeyboardType::getIconId() const
|
||||
{
|
||||
return mIconId;
|
||||
}
|
||||
|
||||
u16string KeyboardType::getCustomizedValue() const
|
||||
{
|
||||
return mCustomizedValue;
|
||||
}
|
||||
/*! Get hash code of the object
|
||||
\return return hashCode value
|
||||
*/
|
||||
int KeyboardType::getHashCode() const
|
||||
{
|
||||
return mHashCode;
|
||||
}
|
||||
|
||||
/*! Get language of the object
|
||||
\return return the language of this object
|
||||
*/
|
||||
u16string KeyboardType::getLanguage() const
|
||||
{
|
||||
return mLanguage;
|
||||
}
|
||||
|
||||
u16string KeyboardType::getInputSource() const
|
||||
{
|
||||
return mInputSource;
|
||||
}
|
||||
|
||||
u16string KeyboardType::getCustomizedValue() const
|
||||
{
|
||||
return mCustomizedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
-44
@@ -17,57 +17,57 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
/*! Constructor
|
||||
\param msgId a message Id
|
||||
\param msgContent the content of a message
|
||||
*/
|
||||
Message::Message(int32_t msgId, MessageParcel* msgContent)
|
||||
{
|
||||
msgId_ = msgId;
|
||||
msgContent_ = msgContent;
|
||||
if (msgContent_) {
|
||||
msgContent_->RewindRead(0);
|
||||
/*! Constructor
|
||||
\param msgId a message Id
|
||||
\param msgContent the content of a message
|
||||
*/
|
||||
Message::Message(int32_t msgId, MessageParcel *msgContent)
|
||||
{
|
||||
msgId_ = msgId;
|
||||
msgContent_ = msgContent;
|
||||
if (msgContent_) {
|
||||
msgContent_->RewindRead(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! Constructor
|
||||
\param msg a source message
|
||||
*/
|
||||
Message::Message(const Message& msg)
|
||||
{
|
||||
msgId_ = msg.msgId_;
|
||||
if (msgContent_ != nullptr) {
|
||||
delete msgContent_;
|
||||
/*! Constructor
|
||||
\param msg a source message
|
||||
*/
|
||||
Message::Message(const Message& msg)
|
||||
{
|
||||
msgId_ = msg.msgId_;
|
||||
if (msgContent_ != nullptr) {
|
||||
delete msgContent_;
|
||||
}
|
||||
MessageParcel *src = msg.msgContent_;
|
||||
if (src) {
|
||||
msgContent_ = new MessageParcel();
|
||||
msgContent_->ParseFrom(src->GetData(), src->GetDataSize());
|
||||
}
|
||||
}
|
||||
MessageParcel* src = msg.msgContent_;
|
||||
if (src) {
|
||||
msgContent_ = new MessageParcel();
|
||||
msgContent_->ParseFrom(src->GetData(), src->GetDataSize());
|
||||
// msgContent_->RewindRead(0);
|
||||
}
|
||||
}
|
||||
|
||||
Message& Message::operator=(const Message& msg)
|
||||
{
|
||||
if (this == &msg) {
|
||||
Message& Message::operator=(const Message& msg)
|
||||
{
|
||||
if (this == &msg) {
|
||||
return *this;
|
||||
}
|
||||
msgId_ = msg.msgId_;
|
||||
if (msgContent_ != nullptr) {
|
||||
delete msgContent_;
|
||||
}
|
||||
if (msg.msgContent_) {
|
||||
msgContent_ = new MessageParcel();
|
||||
msgContent_->ParseFrom(msg.msgContent_->GetData(), msg.msgContent_->GetDataSize());
|
||||
msgContent_->RewindRead(0);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
msgId_ = msg.msgId_;
|
||||
if (msgContent_ != nullptr) {
|
||||
delete msgContent_;
|
||||
}
|
||||
if (msg.msgContent_) {
|
||||
msgContent_ = new MessageParcel();
|
||||
msgContent_->ParseFrom(msg.msgContent_->GetData(), msg.msgContent_->GetDataSize());
|
||||
msgContent_->RewindRead(0);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Message::~Message( ) {
|
||||
if (msgContent_) {
|
||||
delete msgContent_;
|
||||
Message::~Message()
|
||||
{
|
||||
if (msgContent_) {
|
||||
delete msgContent_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace MiscServices {
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
while (! mQueue.empty()) {
|
||||
Message* msg = mQueue.front();
|
||||
Message *msg = mQueue.front();
|
||||
mQueue.pop();
|
||||
delete msg;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace MiscServices {
|
||||
\param msg a message to be sent
|
||||
\note the msg pointer should not be freed by the caller
|
||||
*/
|
||||
void MessageHandler::SendMessage(Message* msg)
|
||||
void MessageHandler::SendMessage(Message *msg)
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
@@ -52,14 +52,14 @@ namespace MiscServices {
|
||||
\return a pointer referred to an object of message
|
||||
\note the returned pointer should be freed by the caller.
|
||||
*/
|
||||
Message* MessageHandler::GetMessage()
|
||||
Message *MessageHandler::GetMessage()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
mCV.wait(lock, [this]{
|
||||
return !this->mQueue.empty();
|
||||
});
|
||||
|
||||
Message* msg = (Message*) mQueue.front();
|
||||
Message *msg = (Message*) mQueue.front();
|
||||
mQueue.pop();
|
||||
return msg;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ namespace MiscServices {
|
||||
/*! The single instance of MessageHandler in the service
|
||||
\return the pointer referred to an object.
|
||||
*/
|
||||
MessageHandler* MessageHandler::Instance()
|
||||
MessageHandler *MessageHandler::Instance()
|
||||
{
|
||||
static MessageHandler *handler = nullptr;
|
||||
if (handler == nullptr) {
|
||||
|
||||
+141
-139
@@ -36,82 +36,85 @@
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
using namespace MessageID;
|
||||
/*! Constructor
|
||||
\param userId the id of the given user
|
||||
\param msgId the msg id can be MessageID::MSG_ID_CLIENT_DIED (to monitor input client)
|
||||
\n or MessageID::MSG_ID_IMS_DIED (to monitor input method service)
|
||||
*/
|
||||
RemoteObjectDeathRecipient::RemoteObjectDeathRecipient(int userId, int msgId)
|
||||
{
|
||||
userId_ = userId;
|
||||
msgId_ = msgId;
|
||||
/*! Constructor
|
||||
\param userId the id of the given user
|
||||
\param msgId the msg id can be MessageID::MSG_ID_CLIENT_DIED (to monitor input client)
|
||||
\n or MessageID::MSG_ID_IMS_DIED (to monitor input method service)
|
||||
*/
|
||||
RemoteObjectDeathRecipient::RemoteObjectDeathRecipient(int userId, int msgId)
|
||||
{
|
||||
userId_ = userId;
|
||||
msgId_ = msgId;
|
||||
}
|
||||
|
||||
RemoteObjectDeathRecipient::~RemoteObjectDeathRecipient()
|
||||
{
|
||||
}
|
||||
|
||||
/*! Notify that a remote object died.
|
||||
\n It's called when the linked remote object died.
|
||||
\param who the IRemoteObject handler of the remote object died.
|
||||
*/
|
||||
void RemoteObjectDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& who)
|
||||
{
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId_);
|
||||
parcel->WriteRemoteObject(who.promote());
|
||||
Message *msg = new Message(msgId_, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
|
||||
/*! Constructor
|
||||
\param userId the user id of this user whose session are managed by this instance of PerUserSession.
|
||||
*/
|
||||
PerUserSession::PerUserSession(int userId)
|
||||
{
|
||||
userState = UserState::USER_STATE_STARTED;
|
||||
userId_ = userId;
|
||||
currentIme[0] = nullptr;
|
||||
currentIme[1] = nullptr;
|
||||
|
||||
needReshowClient = nullptr;
|
||||
|
||||
clientDeathRecipient = new RemoteObjectDeathRecipient(userId, MSG_ID_CLIENT_DIED);
|
||||
imsDeathRecipient = new RemoteObjectDeathRecipient(userId, MSG_ID_IMS_DIED);
|
||||
}
|
||||
|
||||
/*! Destructor
|
||||
*/
|
||||
PerUserSession::~PerUserSession()
|
||||
{
|
||||
if (userState == UserState::USER_STATE_UNLOCKED) {
|
||||
OnUserLocked();
|
||||
}
|
||||
|
||||
RemoteObjectDeathRecipient::~RemoteObjectDeathRecipient(){}
|
||||
|
||||
/*! Notify that a remote object died.
|
||||
\n It's called when the linked remote object died.
|
||||
\param who the IRemoteObject handler of the remote object died.
|
||||
*/
|
||||
void RemoteObjectDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& who)
|
||||
{
|
||||
MessageParcel* parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId_);
|
||||
parcel->WriteRemoteObject(who.promote());
|
||||
Message* msg = new Message(msgId_, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
clientDeathRecipient = nullptr;
|
||||
imsDeathRecipient = nullptr;
|
||||
if (workThreadHandler.joinable()) {
|
||||
workThreadHandler.join();
|
||||
}
|
||||
}
|
||||
|
||||
/*! Constructor
|
||||
\param userId the user id of this user whose session are managed by this instance of PerUserSession.
|
||||
*/
|
||||
PerUserSession::PerUserSession(int userId)
|
||||
{
|
||||
userState = UserState::USER_STATE_STARTED;
|
||||
userId_ = userId;
|
||||
currentIme[0] = nullptr;
|
||||
currentIme[1] = nullptr;
|
||||
|
||||
needReshowClient = nullptr;
|
||||
/*! Create work thread for this user
|
||||
\param handle message handle to receive the message
|
||||
*/
|
||||
void PerUserSession::CreateWorkThread(MessageHandler& handler)
|
||||
{
|
||||
msgHandler = &handler;
|
||||
workThreadHandler = std::thread([this]{WorkThread();});
|
||||
}
|
||||
|
||||
clientDeathRecipient = new RemoteObjectDeathRecipient(userId, MSG_ID_CLIENT_DIED);
|
||||
imsDeathRecipient = new RemoteObjectDeathRecipient(userId, MSG_ID_IMS_DIED);
|
||||
/*! Wait till work thread exits
|
||||
*/
|
||||
void PerUserSession::JoinWorkThread()
|
||||
{
|
||||
if (workThreadHandler.joinable()) {
|
||||
workThreadHandler.join();
|
||||
}
|
||||
}
|
||||
|
||||
/*! Destructor
|
||||
*/
|
||||
PerUserSession::~PerUserSession()
|
||||
{
|
||||
if (userState == UserState::USER_STATE_UNLOCKED) {
|
||||
OnUserLocked();
|
||||
}
|
||||
clientDeathRecipient = nullptr;
|
||||
imsDeathRecipient = nullptr;
|
||||
if (workThreadHandler.joinable()) {
|
||||
workThreadHandler.join();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*! Create work thread for this user
|
||||
\param handle message handle to receive the message
|
||||
*/
|
||||
void PerUserSession::CreateWorkThread(MessageHandler& handler)
|
||||
{
|
||||
msgHandler = &handler;
|
||||
workThreadHandler = std::thread([this]{WorkThread();});
|
||||
}
|
||||
|
||||
/*! Wait till work thread exits
|
||||
*/
|
||||
void PerUserSession::JoinWorkThread()
|
||||
{
|
||||
if (workThreadHandler.joinable()) {
|
||||
workThreadHandler.join();
|
||||
}
|
||||
}
|
||||
|
||||
void PerUserSession::SetInputMethodAbility(sptr<InputMethodAbility> &inputMethodAbility) {
|
||||
void PerUserSession::SetInputMethodAbility(sptr<InputMethodAbility> &inputMethodAbility)
|
||||
{
|
||||
inputMethodAbility_ = inputMethodAbility;
|
||||
}
|
||||
|
||||
@@ -123,7 +126,7 @@ namespace MiscServices {
|
||||
return ;
|
||||
}
|
||||
while(1){
|
||||
Message* msg = msgHandler->GetMessage();
|
||||
Message *msg = msgHandler->GetMessage();
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
switch(msg->msgId_) {
|
||||
case MSG_ID_USER_LOCK:
|
||||
@@ -201,7 +204,7 @@ namespace MiscServices {
|
||||
/*! Set the current input method engine
|
||||
\param ime the current (default) IME pointer referred to the instance in PerUserSetting.
|
||||
*/
|
||||
void PerUserSession::SetCurrentIme(InputMethodProperty* ime)
|
||||
void PerUserSession::SetCurrentIme(InputMethodProperty *ime)
|
||||
{
|
||||
currentIme[DEFAULT_IME] = ime;
|
||||
userState = UserState::USER_STATE_UNLOCKED;
|
||||
@@ -210,7 +213,7 @@ namespace MiscServices {
|
||||
/*! Set the system security input method engine
|
||||
\param ime system security IME pointer referred to the instance in PerUserSetting.
|
||||
*/
|
||||
void PerUserSession::SetSecurityIme(InputMethodProperty* ime)
|
||||
void PerUserSession::SetSecurityIme(InputMethodProperty *ime)
|
||||
{
|
||||
currentIme[SECURITY_IME] = ime;
|
||||
}
|
||||
@@ -218,7 +221,7 @@ namespace MiscServices {
|
||||
/*! Set the input method setting data
|
||||
\param setting InputMethodSetting pointer referred to the instance in PerUserSetting.
|
||||
*/
|
||||
void PerUserSession::SetInputMethodSetting(InputMethodSetting* setting)
|
||||
void PerUserSession::SetInputMethodSetting(InputMethodSetting *setting)
|
||||
{
|
||||
inputMethodSetting = setting;
|
||||
}
|
||||
@@ -229,11 +232,11 @@ namespace MiscServices {
|
||||
\n Two input method engines can be running at the same time for one user.
|
||||
\n One is the default ime, another is security ime
|
||||
*/
|
||||
void PerUserSession::ResetIme(InputMethodProperty* defaultIme, InputMethodProperty* securityIme)
|
||||
void PerUserSession::ResetIme(InputMethodProperty *defaultIme, InputMethodProperty *securityIme)
|
||||
{
|
||||
IMSA_HILOGI("PerUserSession::ResetIme");
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
InputMethodProperty* ime[] = {defaultIme, securityIme};
|
||||
InputMethodProperty *ime[] = {defaultIme, securityIme};
|
||||
for(int i=0; i<2; i++) {
|
||||
if (currentIme[i] == ime[i] && ime[i] != nullptr) {
|
||||
continue;
|
||||
@@ -320,7 +323,7 @@ namespace MiscServices {
|
||||
const InputAttribute& attribute)
|
||||
{
|
||||
IMSA_HILOGI("PerUserSession::AddClient");
|
||||
ClientInfo* clientInfo = GetClientInfo(inputClient);
|
||||
ClientInfo *clientInfo = GetClientInfo(inputClient);
|
||||
if (clientInfo != nullptr) {
|
||||
IMSA_HILOGE("PerUserSession::AddClient clientInfo is not nullptr");
|
||||
return ErrorCode::ERROR_CLIENT_DUPLICATED;
|
||||
@@ -335,7 +338,7 @@ namespace MiscServices {
|
||||
mapClients.insert(std::pair<sptr<IRemoteObject>, ClientInfo*>(obj, clientInfo));
|
||||
int ret = obj->AddDeathRecipient(clientDeathRecipient);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::AddClient AddDeathRecipient return : %{public}s [%{public}d]", ErrorCode::ToString(ret), userId_);
|
||||
IMSA_HILOGE("PerUserSession::AddClient AddDeathRecipient return : %{public}s", ErrorCode::ToString(ret));
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
@@ -354,18 +357,18 @@ namespace MiscServices {
|
||||
sptr<IRemoteObject> b = inputClient->AsObject();
|
||||
std::map<sptr<IRemoteObject>, ClientInfo*>::iterator it = mapClients.find(b);
|
||||
if (it == mapClients.end()) {
|
||||
IMSA_HILOGE("PerUserSession::RemoveClient %{public}s [%{public}d]", ErrorCode::ToString(ErrorCode::ERROR_CLIENT_NOT_FOUND), userId_);
|
||||
IMSA_HILOGE("PerUserSession::RemoveClient ErrorCode::ERROR_CLIENT_NOT_FOUND");
|
||||
return ErrorCode::ERROR_CLIENT_NOT_FOUND;
|
||||
}
|
||||
ClientInfo* clientInfo = it->second;
|
||||
ClientInfo *clientInfo = it->second;
|
||||
bool flag = clientInfo->attribute.GetSecurityFlag();
|
||||
int ret = b->RemoveDeathRecipient(clientDeathRecipient);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::RemoveClient RemoveDeathRecipient return : %{public}s [%{public}d]\n", ErrorCode::ToString(ret), userId_);
|
||||
IMSA_HILOGE("PerUserSession::RemoveClient RemoveDeathRecipient fail %{public}s", ErrorCode::ToString(ret));
|
||||
}
|
||||
ret = clientInfo->client->onInputReleased(0);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::RemoveClient onInputReleased return : %{public}s [%{public}d]\n", ErrorCode::ToString(ret), userId_);
|
||||
IMSA_HILOGE("PerUserSession::RemoveClient onInputReleased fail %{public}s", ErrorCode::ToString(ret));
|
||||
}
|
||||
delete clientInfo;
|
||||
mapClients.erase(it);
|
||||
@@ -405,7 +408,7 @@ namespace MiscServices {
|
||||
inputControlChannel[index] = localControlChannel[index];
|
||||
int ret_init = imsCore[index]->initializeInput(inputMethodToken[index], displayId, inputControlChannel[index]);
|
||||
if (ret_init != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::StartInputMethod initializeInput return : %{public}s [%{public}d]\n", ErrorCode::ToString(ret_init), userId_);
|
||||
IMSA_HILOGE("PerUserSession::StartInputMethod initializeInput fail %{public}s", ErrorCode::ToString(ret_init));
|
||||
localControlChannel[index] = nullptr;
|
||||
inputControlChannel[index] = nullptr;
|
||||
return ret_init;
|
||||
@@ -425,11 +428,11 @@ namespace MiscServices {
|
||||
{
|
||||
IMSA_HILOGI("Start... index = %{public}d [%{public}d]\n", index, userId_);
|
||||
if (index >= MAX_IME || index < 0) {
|
||||
IMSA_HILOGE("Aborted! %{public}s [%{public}d]\n", ErrorCode::ToString(ErrorCode::ERROR_BAD_PARAMETERS), userId_);
|
||||
IMSA_HILOGE("Aborted! %{public}s", ErrorCode::ToString(ErrorCode::ERROR_BAD_PARAMETERS));
|
||||
return ErrorCode::ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
if (imsCore[index] == nullptr || currentIme[index] == nullptr) {
|
||||
IMSA_HILOGE("Aborted! %{public}s [%{public}d]\n", ErrorCode::ToString(ErrorCode::ERROR_IME_NOT_STARTED), userId_);
|
||||
IMSA_HILOGE("Aborted! %{public}s", ErrorCode::ToString(ErrorCode::ERROR_IME_NOT_STARTED));
|
||||
return ErrorCode::ERROR_IME_NOT_STARTED;
|
||||
}
|
||||
if (currentIme[index] == currentIme[1-index] && imsCore[1-index] != nullptr) {
|
||||
@@ -472,10 +475,10 @@ namespace MiscServices {
|
||||
\return ErrorCode::ERROR_KBD_SHOW_FAILED failed to show keyboard
|
||||
\return other errors returned by binder driver
|
||||
*/
|
||||
int PerUserSession::ShowKeyboard( const sptr<IInputClient>& inputClient )
|
||||
int PerUserSession::ShowKeyboard(const sptr<IInputClient>& inputClient)
|
||||
{
|
||||
IMSA_HILOGI("PerUserSession::ShowKeyboard");
|
||||
ClientInfo* clientInfo = GetClientInfo(inputClient);
|
||||
ClientInfo *clientInfo = GetClientInfo(inputClient);
|
||||
int index = GetImeIndex(inputClient);
|
||||
if (index == -1 || clientInfo == nullptr) {
|
||||
IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! index = -1 or clientInfo is nullptr");
|
||||
@@ -491,7 +494,7 @@ namespace MiscServices {
|
||||
IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! client is not ready");
|
||||
int result = clientInfo->client->onInputReady(1, nullptr, nullptr);
|
||||
if (result != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::ShowKeyboard onInputReady return : %{public}s [%{public}d]\n", ErrorCode::ToString(ret), userId_);
|
||||
IMSA_HILOGE("PerUserSession::ShowKeyboard onInputReady return : %{public}s", ErrorCode::ToString(ret));
|
||||
}
|
||||
return ErrorCode::ERROR_IME_START_FAILED;
|
||||
}
|
||||
@@ -534,10 +537,10 @@ namespace MiscServices {
|
||||
IMSA_HILOGI("PerUserSession::HideKeyboard");
|
||||
int index = GetImeIndex(inputClient);
|
||||
if (index == -1) {
|
||||
IMSA_HILOGE("PerUserSession::HideKeyboard Aborted! %{public}s [%{public}d]\n", ErrorCode::ToString(ErrorCode::ERROR_CLIENT_NOT_FOUND), userId_);
|
||||
IMSA_HILOGE("PerUserSession::HideKeyboard Aborted! ErrorCode::ERROR_CLIENT_NOT_FOUND");
|
||||
return ErrorCode::ERROR_CLIENT_NOT_FOUND;
|
||||
}
|
||||
ClientInfo* clientInfo = GetClientInfo(inputClient);
|
||||
ClientInfo *clientInfo = GetClientInfo(inputClient);
|
||||
if(clientInfo == nullptr){
|
||||
IMSA_HILOGE("PerUserSession::HideKeyboard GetClientInfo pointer nullptr");
|
||||
}
|
||||
@@ -549,7 +552,7 @@ namespace MiscServices {
|
||||
|
||||
if (currentClient == nullptr) {
|
||||
clientInfo->client->onInputReady(1, nullptr, nullptr);
|
||||
IMSA_HILOGE("PerUserSession::HideKeyboard Aborted! %{public}s [%{public}d]\n", ErrorCode::ToString(ErrorCode::ERROR_KBD_IS_NOT_SHOWING), userId_);
|
||||
IMSA_HILOGE("PerUserSession::HideKeyboard Aborted! ErrorCode::ERROR_KBD_IS_NOT_SHOWING");
|
||||
return ErrorCode::ERROR_KBD_IS_NOT_SHOWING;
|
||||
}
|
||||
bool ret = imsCore[index]->hideKeyboard(1);
|
||||
@@ -560,7 +563,7 @@ namespace MiscServices {
|
||||
|
||||
int ret_client_stop = clientInfo->client->onInputReady(1, nullptr, nullptr);
|
||||
if (ret_client_stop != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::HideKeyboard onInputReady return : %{public}s [%{public}d]\n", ErrorCode::ToString(ret_client_stop), userId_);
|
||||
IMSA_HILOGE("PerUserSession::HideKeyboard onInputReady return : %{public}s", ErrorCode::ToString(ret_client_stop));
|
||||
}
|
||||
currentClient = nullptr;
|
||||
imsAgent = nullptr;
|
||||
@@ -585,15 +588,12 @@ namespace MiscServices {
|
||||
\param[out] retHeight the height of keyboard window showing or showed returned to caller
|
||||
\return ErrorCode
|
||||
*/
|
||||
int PerUserSession::GetKeyboardWindowHeight(int *retHeight)
|
||||
int PerUserSession::GetKeyboardWindowHeight(int retHeight)
|
||||
{
|
||||
if (retHeight == nullptr) {
|
||||
return ErrorCode::ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
if (imsCore[lastImeIndex] != nullptr) {
|
||||
int ret = imsCore[lastImeIndex]->getKeyboardWindowHeight(retHeight);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("getKeyboardWindowHeight return : %{public}s [%{public}d]\n", ErrorCode::ToString(ret), userId_);
|
||||
IMSA_HILOGE("getKeyboardWindowHeight return : %{public}s", ErrorCode::ToString(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -606,7 +606,7 @@ namespace MiscServices {
|
||||
\n null if no keyboard type supported by the current ime.
|
||||
\note The returned pointer should NOT be freed by the caller.
|
||||
*/
|
||||
KeyboardType* PerUserSession::GetCurrentKeyboardType()
|
||||
KeyboardType *PerUserSession::GetCurrentKeyboardType()
|
||||
{
|
||||
if (inputMethodSetting == nullptr || currentIme[DEFAULT_IME] == nullptr) {
|
||||
IMSA_HILOGI("Ime has not started ! [%{public}d]\n", userId_);
|
||||
@@ -696,7 +696,7 @@ namespace MiscServices {
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId_);
|
||||
parcel->WriteString16(currentIme[index]->mImeId);
|
||||
Message* msg = new Message(MSG_ID_DISABLE_IMS, parcel);
|
||||
Message *msg = new Message(MSG_ID_DISABLE_IMS, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
} else {
|
||||
// restart current input method.
|
||||
@@ -705,7 +705,7 @@ namespace MiscServices {
|
||||
parcel->WriteInt32(userId_);
|
||||
parcel->WriteInt32(index);
|
||||
parcel->WriteString16(currentIme[index]->mImeId);
|
||||
Message* msg = new Message(MSG_ID_RESTART_IMS, parcel);
|
||||
Message *msg = new Message(MSG_ID_RESTART_IMS, parcel);
|
||||
usleep(1600*1000); // wait that PACKAGE_REMOVED message is received if this ime has been removed
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
@@ -727,7 +727,9 @@ namespace MiscServices {
|
||||
}
|
||||
std::u16string currentValue = inputMethodSetting->GetValue(key);
|
||||
|
||||
IMSA_HILOGD("%{public}s=%{public}s, currentValue = %{public}s\n", Utils::to_utf8(key).c_str(), Utils::to_utf8(value).c_str(), Utils::to_utf8(currentValue).c_str());
|
||||
IMSA_HILOGD("PerUserSession::OnSettingChanged key = %{public}s", Utils::to_utf8(key).c_str());
|
||||
IMSA_HILOGD("PerUserSession::OnSettingChanged value = %{public}s", Utils::to_utf8(value).c_str());
|
||||
IMSA_HILOGD("PerUserSession::OnSettingChanged currentValue = %{public}s", Utils::to_utf8(currentValue).c_str());
|
||||
|
||||
if (currentValue == value) {
|
||||
IMSA_HILOGI("End...[%{public}d]\n", userId_);
|
||||
@@ -807,7 +809,7 @@ namespace MiscServices {
|
||||
}
|
||||
}
|
||||
}
|
||||
KeyboardType* type = GetKeyboardType(index, currentKbdIndex[index]);
|
||||
KeyboardType *type = GetKeyboardType(index, currentKbdIndex[index]);
|
||||
if (type != nullptr) {
|
||||
if (currentClient != nullptr) {
|
||||
int ret = imsCore[index]->setKeyboardType(*type);
|
||||
@@ -840,7 +842,7 @@ namespace MiscServices {
|
||||
|
||||
/*! Switch to next keyboard type
|
||||
*/
|
||||
void PerUserSession::OnAdvanceToNext( )
|
||||
void PerUserSession::OnAdvanceToNext()
|
||||
{
|
||||
int index = GetImeIndex(currentClient);
|
||||
if (index == -1) {
|
||||
@@ -862,7 +864,7 @@ namespace MiscServices {
|
||||
|
||||
int num = currentKbdIndex[index]+1;
|
||||
num %= size;
|
||||
KeyboardType* type = GetKeyboardType(index, num);
|
||||
KeyboardType *type = GetKeyboardType(index, num);
|
||||
if (type == nullptr) {
|
||||
IMSA_HILOGW("No next keyboard is available. [%{public}d]\n", userId_);
|
||||
return;
|
||||
@@ -887,7 +889,7 @@ namespace MiscServices {
|
||||
void PerUserSession::OnSetDisplayMode(int mode)
|
||||
{
|
||||
currentDisplayMode = mode;
|
||||
ClientInfo* clientInfo = GetClientInfo(currentClient);
|
||||
ClientInfo *clientInfo = GetClientInfo(currentClient);
|
||||
if (clientInfo == nullptr) {
|
||||
IMSA_HILOGE("%{public}s [%{public}d]\n", ErrorCode::ToString(ErrorCode::ERROR_CLIENT_NOT_FOUND), userId_);
|
||||
return ;
|
||||
@@ -943,11 +945,11 @@ namespace MiscServices {
|
||||
for(it=mapClients.begin(); it!=mapClients.end();) {
|
||||
sptr<IRemoteObject> b = it->first;
|
||||
b->RemoveDeathRecipient(clientDeathRecipient);
|
||||
ClientInfo* clientInfo = it->second;
|
||||
ClientInfo *clientInfo = it->second;
|
||||
if (clientInfo != nullptr) {
|
||||
int ret = clientInfo->client->onInputReleased(0);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("2-onInputReleased return : %{public}s [%{public}d]\n", ErrorCode::ToString(ret), userId_);
|
||||
IMSA_HILOGE("2-onInputReleased return : %{public}s", ErrorCode::ToString(ret));
|
||||
}
|
||||
delete clientInfo;
|
||||
}
|
||||
@@ -962,14 +964,14 @@ namespace MiscServices {
|
||||
needReshowClient = nullptr;
|
||||
}
|
||||
|
||||
/*! Print the session information of this user into the given stream
|
||||
\n The information includes:
|
||||
\li the information of all the input clients connected to the input method management system.
|
||||
\li current input method engine information
|
||||
\li security input method engine information
|
||||
\li current session information
|
||||
\param fd the raw file descriptor that the dump is being sent to
|
||||
*/
|
||||
/* Print the session information of this user into the given stream
|
||||
* The information includes:
|
||||
* the information of all the input clients connected to the input method management system.
|
||||
* current input method engine information
|
||||
* security input method engine information
|
||||
* current session information
|
||||
* param fd the raw file descriptor that the dump is being sent to
|
||||
*/
|
||||
void PerUserSession::Dump(int fd)
|
||||
{
|
||||
std::map<sptr<IRemoteObject>, ClientInfo*>::const_iterator it;
|
||||
@@ -989,7 +991,7 @@ namespace MiscServices {
|
||||
for(int i=0; i<2; i++) {
|
||||
if (currentIme[i] != nullptr) {
|
||||
dprintf(fd, "\n * %s IME mImeId = %s\n", header[i].c_str(), Utils::to_utf8(currentIme[i]->mImeId).c_str());
|
||||
KeyboardType* type = currentIme[i]->mTypes.at(currentKbdIndex[i]);
|
||||
KeyboardType *type = currentIme[i]->mTypes.at(currentKbdIndex[i]);
|
||||
dprintf(fd, " %s KeyboardType mHashCode = %d, mLanguage = %s\n", header[i].c_str(),
|
||||
type->getHashCode(), Utils::to_utf8(type->getLanguage()).c_str());
|
||||
|
||||
@@ -1043,7 +1045,7 @@ namespace MiscServices {
|
||||
dprintf(fd, " displayMode = %d [ full sceen ]\n", currentDisplayMode);
|
||||
}
|
||||
int height = 0;
|
||||
GetKeyboardWindowHeight(&height);
|
||||
GetKeyboardWindowHeight(height);
|
||||
dprintf(fd, " keyboard window height = %d\n", height);
|
||||
}
|
||||
|
||||
@@ -1100,7 +1102,7 @@ namespace MiscServices {
|
||||
\return null when it's not found.
|
||||
\note The returned pointer should not be freed by caller.
|
||||
*/
|
||||
KeyboardType* PerUserSession::GetKeyboardType(int imeIndex, int typeIndex)
|
||||
KeyboardType *PerUserSession::GetKeyboardType(int imeIndex, int typeIndex)
|
||||
{
|
||||
if(typeIndex < 0) {
|
||||
return nullptr;
|
||||
@@ -1139,7 +1141,7 @@ namespace MiscServices {
|
||||
} else {
|
||||
hashCode = inputMethodSetting->GetCurrentSysKeyboardType();
|
||||
}
|
||||
KeyboardType* type = nullptr;
|
||||
KeyboardType *type = nullptr;
|
||||
if (hashCode == -1) {
|
||||
type = GetKeyboardType(imeIndex, currentKbdIndex[imeIndex]);
|
||||
} else {
|
||||
@@ -1163,8 +1165,7 @@ namespace MiscServices {
|
||||
}
|
||||
}
|
||||
if (flag == false) {
|
||||
IMSA_HILOGW("The current keyboard type [hashCode=%{public}d] is not found in the current IME. Reset it! [%{public}d]\n",
|
||||
hashCode, userId_);
|
||||
IMSA_HILOGW("The current keyboard type is not found in the current IME. Reset it!");
|
||||
type = GetKeyboardType(imeIndex, currentKbdIndex[imeIndex]);
|
||||
} else if (imsCore[imeIndex] == imsCore[1-imeIndex]) {
|
||||
currentKbdIndex[1-imeIndex] = currentKbdIndex[imeIndex];
|
||||
@@ -1247,7 +1248,7 @@ namespace MiscServices {
|
||||
\n null if client is not found
|
||||
\note the clientInfo pointer should not be freed by caller
|
||||
*/
|
||||
ClientInfo* PerUserSession::GetClientInfo(const sptr<IInputClient>& inputClient)
|
||||
ClientInfo *PerUserSession::GetClientInfo(const sptr<IInputClient>& inputClient)
|
||||
{
|
||||
if (inputClient == nullptr) {
|
||||
IMSA_HILOGE("PerUserSession::GetClientInfo inputClient is nullptr");
|
||||
@@ -1262,7 +1263,8 @@ namespace MiscServices {
|
||||
return (ClientInfo*) it->second;
|
||||
}
|
||||
|
||||
void PerUserSession::BindInputAbility(){
|
||||
void PerUserSession::BindInputAbility()
|
||||
{
|
||||
IMSA_HILOGE("PerUserSession::BindInputAbility");
|
||||
AAFwk::Want want;
|
||||
want.SetAction("action.system.inputmethod");
|
||||
@@ -1289,10 +1291,10 @@ namespace MiscServices {
|
||||
\param msg the parameters from remote client are saved in msg->msgContent_
|
||||
\return ErrorCode
|
||||
*/
|
||||
void PerUserSession::OnPrepareInput(Message* msg)
|
||||
void PerUserSession::OnPrepareInput(Message *msg)
|
||||
{
|
||||
IMSA_HILOGI("PerUserSession::OnPrepareInput Start...[%{public}d]\n", userId_);
|
||||
MessageParcel* data = msg->msgContent_;
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
int pid = data->ReadInt32();
|
||||
int uid = data->ReadInt32();
|
||||
int displayId = data->ReadInt32();
|
||||
@@ -1307,14 +1309,14 @@ namespace MiscServices {
|
||||
IMSA_HILOGI("PerUserSession::OnPrepareInput channelObject is null");
|
||||
}
|
||||
sptr<InputDataChannelProxy> channel = new InputDataChannelProxy(channelObject);
|
||||
InputAttribute* attribute = data->ReadParcelable<InputAttribute>();
|
||||
InputAttribute *attribute = data->ReadParcelable<InputAttribute>();
|
||||
if (attribute ==nullptr) {
|
||||
IMSA_HILOGI("PerUserSession::OnPrepareInput attribute is nullptr");
|
||||
}
|
||||
|
||||
int ret = AddClient(pid, uid, displayId, client, channel, *attribute);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::OnPrepareInput Aborted! %{public}s [%{public}d]\n", ErrorCode::ToString(ret), userId_);
|
||||
IMSA_HILOGE("PerUserSession::OnPrepareInput Aborted! %{public}s", ErrorCode::ToString(ret));
|
||||
return;
|
||||
}
|
||||
SetDisplayId(displayId);
|
||||
@@ -1331,10 +1333,10 @@ namespace MiscServices {
|
||||
\param msg the parameters from remote client are saved in msg->msgContent_
|
||||
\return ErrorCode
|
||||
*/
|
||||
void PerUserSession::OnReleaseInput(Message* msg)
|
||||
void PerUserSession::OnReleaseInput(Message *msg)
|
||||
{
|
||||
IMSA_HILOGI("PerUserSession::OnReleaseInput Start...[%{public}d]\n", userId_);
|
||||
MessageParcel* data = msg->msgContent_;
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
|
||||
sptr<IRemoteObject> clientObject = data->ReadRemoteObject();
|
||||
sptr<InputClientProxy> client = new InputClientProxy(clientObject);
|
||||
@@ -1355,41 +1357,41 @@ namespace MiscServices {
|
||||
\param msg the parameters from remote client are saved in msg->msgContent_
|
||||
\return ErrorCode
|
||||
*/
|
||||
void PerUserSession::OnStartInput(Message* msg)
|
||||
void PerUserSession::OnStartInput(Message *msg)
|
||||
{
|
||||
IMSA_HILOGI("PerUserSession::OnStartInput");
|
||||
MessageParcel* data = msg->msgContent_;
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
sptr<IRemoteObject> clientObject = data->ReadRemoteObject();
|
||||
sptr<InputClientProxy> client = new InputClientProxy(clientObject);
|
||||
int ret = ShowKeyboard(client);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::OnStartInput Aborted! %{public}s [%{public}d]\n", ErrorCode::ToString(ret), userId_);
|
||||
IMSA_HILOGE("PerUserSession::OnStartInput Aborted! %{public}s", ErrorCode::ToString(ret));
|
||||
} else {
|
||||
IMSA_HILOGI("PerUserSession::OnStartInput End...[%{public}d]\n", userId_);
|
||||
}
|
||||
}
|
||||
|
||||
void PerUserSession::onSetInputMethodCore(Message* msg)
|
||||
void PerUserSession::onSetInputMethodCore(Message *msg)
|
||||
{
|
||||
IMSA_HILOGI("PerUserSession::onSetInputMethodCore Start...[%{public}d]\n", userId_);
|
||||
MessageParcel* data = msg->msgContent_;
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
|
||||
sptr<IRemoteObject> coreObject = data->ReadRemoteObject();
|
||||
sptr<InputMethodCoreProxy> core = new InputMethodCoreProxy(coreObject);
|
||||
int index = currentIndex;
|
||||
IMSA_HILOGI("PerUserSession::onSetInputMethodCore index = [%{public}d]\n", index);
|
||||
if (index >= MAX_IME || index < 0) {
|
||||
IMSA_HILOGE("PerUserSession::onSetInputMethodCore Aborted! %{public}s [%{public}d]\n", ErrorCode::ToString(ErrorCode::ERROR_BAD_PARAMETERS), userId_);
|
||||
IMSA_HILOGE("PerUserSession::onSetInputMethodCore Aborted! ErrorCode::ERROR_BAD_PARAMETERS");
|
||||
return;
|
||||
}
|
||||
if (imsCore[index] != nullptr) {
|
||||
IMSA_HILOGI("PerUserSession::onSetInputMethodCore End... Input Method Service has already been started ! [%{public}d]\n", userId_);
|
||||
IMSA_HILOGI("PerUserSession::onSetInputMethodCore End... Input Method Service has already been started ! ");
|
||||
return;
|
||||
}
|
||||
imsCore[index]=core;
|
||||
int ret = StartInputMethod(index);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::onSetInputMethodCore Aborted! %{public}s [%{public}d]\n", ErrorCode::ToString(ret), userId_);
|
||||
IMSA_HILOGE("PerUserSession::onSetInputMethodCore Aborted! %{public}s", ErrorCode::ToString(ret));
|
||||
} else {
|
||||
IMSA_HILOGI("PerUserSession::onSetInputMethodCore End...[%{public}d]\n", userId_);
|
||||
}
|
||||
@@ -1400,16 +1402,16 @@ namespace MiscServices {
|
||||
\param msg the parameters from remote client are saved in msg->msgContent_
|
||||
\return ErrorCode
|
||||
*/
|
||||
void PerUserSession::OnStopInput(Message* msg)
|
||||
void PerUserSession::OnStopInput(Message *msg)
|
||||
{
|
||||
IMSA_HILOGI("PerUserSession::OnStopInput");
|
||||
MessageParcel* data = msg->msgContent_;
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
|
||||
sptr<IRemoteObject> clientObject = data->ReadRemoteObject();
|
||||
sptr<InputClientProxy> client = new InputClientProxy(clientObject);
|
||||
int ret = HideKeyboard(client);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("PerUserSession::OnStopInput Aborted! %{public}s [%{public}d]\n", ErrorCode::ToString(ret), userId_);
|
||||
IMSA_HILOGE("PerUserSession::OnStopInput Aborted! %{public}s", ErrorCode::ToString(ret));
|
||||
} else {
|
||||
IMSA_HILOGI("PerUserSession::OnStopInput End...[%{public}d]\n", userId_);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "unistd.h" //usleep
|
||||
#include "peruser_setting.h"
|
||||
#include "platform.h"
|
||||
@@ -39,11 +38,11 @@ namespace MiscServices {
|
||||
}
|
||||
}
|
||||
|
||||
/*! Initialize data for this user.
|
||||
\n It's called when this user is unlocked. The work includes:
|
||||
\li read all installed input method engine information from the system
|
||||
\li read input method setting data from the system
|
||||
*/
|
||||
/* Initialize data for this user.
|
||||
* It's called when this user is unlocked. The work includes:
|
||||
* read all installed input method engine information from the system
|
||||
* read input method setting data from the system
|
||||
*/
|
||||
void PerUserSetting::Initialize()
|
||||
{
|
||||
userState = UserState::USER_STATE_UNLOCKED;
|
||||
@@ -76,10 +75,10 @@ namespace MiscServices {
|
||||
\return ErrorCode::ERROR_NOT_IME_PACKAGE The installed package is not an IME package.
|
||||
\return ErrorCode::ERROR_IME_PACKAGE_DUPLICATED The installed package is duplicated.
|
||||
*/
|
||||
int PerUserSetting::OnPackageAdded(std::u16string& packageName, bool* isSecurityIme)
|
||||
int PerUserSetting::OnPackageAdded(std::u16string& packageName, bool isSecurityIme)
|
||||
{
|
||||
if (isSecurityIme) {
|
||||
*isSecurityIme = false;
|
||||
isSecurityIme = false;
|
||||
}
|
||||
std::u16string imeId = GetImeId(packageName);
|
||||
if (imeId.size() != 0) {
|
||||
@@ -97,7 +96,7 @@ namespace MiscServices {
|
||||
inputMethodProperties.push_back(property);
|
||||
if (CheckIfSecurityIme(*property)) {
|
||||
if (isSecurityIme) {
|
||||
*isSecurityIme = true;
|
||||
isSecurityIme = true;
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
@@ -123,10 +122,10 @@ namespace MiscServices {
|
||||
\return ErrorCode::NO_ERROR The removed package is an IME package, and is removed from the input method management system
|
||||
\return ErrorCode::ERROR_NOT_IME_PACKAGE The removed package is not an IME package.
|
||||
*/
|
||||
int PerUserSetting::OnPackageRemoved(std::u16string& packageName, bool* isSecurityIme)
|
||||
int PerUserSetting::OnPackageRemoved(std::u16string& packageName, bool isSecurityIme)
|
||||
{
|
||||
if (isSecurityIme) {
|
||||
*isSecurityIme = false;
|
||||
isSecurityIme = false;
|
||||
}
|
||||
std::u16string imeId = GetImeId(packageName);
|
||||
if (imeId.size() == 0) {
|
||||
@@ -136,7 +135,7 @@ namespace MiscServices {
|
||||
bool securityFlag = false;
|
||||
std::vector<InputMethodProperty*>::iterator it;
|
||||
for(it=inputMethodProperties.begin(); it<inputMethodProperties.end(); ++it) {
|
||||
InputMethodProperty* node = (InputMethodProperty*) *it;
|
||||
InputMethodProperty *node = (InputMethodProperty*) *it;
|
||||
if (node->mImeId == imeId) {
|
||||
if (CheckIfSecurityIme(*node)==true) {
|
||||
securityFlag = true;
|
||||
@@ -148,7 +147,7 @@ namespace MiscServices {
|
||||
}
|
||||
if (securityFlag) {
|
||||
if (isSecurityIme) {
|
||||
*isSecurityIme = true;
|
||||
isSecurityIme = true;
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
@@ -209,7 +208,7 @@ namespace MiscServices {
|
||||
std::u16string enabledInputMethods = inputMethodSetting.GetValue(InputMethodSetting::ENABLED_INPUT_METHODS_TAG);
|
||||
std::u16string imeId;
|
||||
std::u16string nextImeId = Utils::to_utf16("");
|
||||
InputMethodProperty* firstEnabledProperty = nullptr;
|
||||
InputMethodProperty *firstEnabledProperty = nullptr;
|
||||
for(int i=0; i<(int)inputMethodProperties.size(); i++) {
|
||||
imeId = inputMethodProperties[i]->mImeId;
|
||||
if (imeId == currentImeId) {
|
||||
@@ -240,11 +239,11 @@ namespace MiscServices {
|
||||
Platform::Instance()->SetInputMethodSetting(userId_, tmpSetting);
|
||||
}
|
||||
|
||||
/*! It's Called when this user is locked.
|
||||
\n Release data for this user including:
|
||||
\li release input method engine information
|
||||
\li release input method setting data
|
||||
*/
|
||||
/* It's Called when this user is locked.
|
||||
* Release data for this user including:
|
||||
* release input method engine information
|
||||
* release input method setting data
|
||||
*/
|
||||
void PerUserSetting::OnUserLocked()
|
||||
{
|
||||
if (userState == UserState::USER_STATE_STARTED) {
|
||||
@@ -256,7 +255,7 @@ namespace MiscServices {
|
||||
// release input method properties
|
||||
std::vector<InputMethodProperty*>::iterator it;
|
||||
for(it=inputMethodProperties.begin(); it<inputMethodProperties.end();) {
|
||||
InputMethodProperty* node = (InputMethodProperty*) *it;
|
||||
InputMethodProperty *node = (InputMethodProperty*) *it;
|
||||
if (node != nullptr) {
|
||||
it = inputMethodProperties.erase(it);
|
||||
delete node;
|
||||
@@ -267,13 +266,13 @@ namespace MiscServices {
|
||||
inputMethodSetting.ClearData();
|
||||
}
|
||||
|
||||
/*! Print the related information for this user into the given stream
|
||||
\n The information includes:
|
||||
\li The user id and user state
|
||||
\li The information of all input method engine installed in the system
|
||||
\li The input method setting data of this user.
|
||||
\param fd the raw file descriptor that the dump is being sent to
|
||||
*/
|
||||
/* Print the related information for this user into the given stream
|
||||
* The information includes:
|
||||
* The user id and user state
|
||||
* The information of all input method engine installed in the system
|
||||
* The input method setting data of this user.
|
||||
* param fd the raw file descriptor that the dump is being sent to
|
||||
*/
|
||||
void PerUserSetting::Dump(int fd)
|
||||
{
|
||||
int size = inputMethodProperties.size();
|
||||
@@ -312,7 +311,7 @@ namespace MiscServices {
|
||||
\return null when there is no enabled IME in the system.
|
||||
\note The returned pointer should NOT be freed by caller
|
||||
*/
|
||||
InputMethodProperty* PerUserSetting::GetCurrentInputMethod()
|
||||
InputMethodProperty *PerUserSetting::GetCurrentInputMethod()
|
||||
{
|
||||
for(int i=0; i<(int)inputMethodProperties.size(); i++) {
|
||||
if (currentImeId == inputMethodProperties[i]->mImeId) {
|
||||
@@ -328,9 +327,9 @@ namespace MiscServices {
|
||||
\return null when there is no security IME in the system.
|
||||
\note The returned pointer should NOT be freed by caller
|
||||
*/
|
||||
InputMethodProperty* PerUserSetting::GetSecurityInputMethod()
|
||||
InputMethodProperty *PerUserSetting::GetSecurityInputMethod()
|
||||
{
|
||||
InputMethodProperty* ime = nullptr;
|
||||
InputMethodProperty *ime = nullptr;
|
||||
std::u16string systemLocales = inputMethodSetting.GetValue(InputMethodSetting::SYSTEM_LOCALE_TAG);
|
||||
for(int i=0; i<(int)inputMethodProperties.size(); i++) {
|
||||
if (CheckIfSecurityIme(*inputMethodProperties[i])==false) {
|
||||
@@ -359,12 +358,12 @@ namespace MiscServices {
|
||||
\return null when the next enabled IME is not available.
|
||||
\note The returned pointer should NOT be freed by caller
|
||||
*/
|
||||
InputMethodProperty* PerUserSetting::GetNextInputMethod()
|
||||
InputMethodProperty *PerUserSetting::GetNextInputMethod()
|
||||
{
|
||||
bool flag = false;
|
||||
std::u16string enabledInputMethods = inputMethodSetting.GetValue(InputMethodSetting::ENABLED_INPUT_METHODS_TAG);
|
||||
std::u16string imeId;
|
||||
InputMethodProperty* firstEnabledProperty = nullptr;
|
||||
InputMethodProperty *firstEnabledProperty = nullptr;
|
||||
for(int i=0; i<(int)inputMethodProperties.size(); i++) {
|
||||
imeId = inputMethodProperties[i]->mImeId;
|
||||
if (imeId == currentImeId) {
|
||||
@@ -384,7 +383,7 @@ namespace MiscServices {
|
||||
\return a pointer of InputMethodSetting.
|
||||
\note The returned pointer should NOT be freed by caller
|
||||
*/
|
||||
InputMethodSetting* PerUserSetting::GetInputMethodSetting()
|
||||
InputMethodSetting *PerUserSetting::GetInputMethodSetting()
|
||||
{
|
||||
return &inputMethodSetting;
|
||||
}
|
||||
@@ -441,7 +440,7 @@ namespace MiscServices {
|
||||
\return null when the given IME is not available
|
||||
\note the returned pointer should not be freed by the caller.
|
||||
*/
|
||||
InputMethodProperty* PerUserSetting::GetInputMethodProperty(const std::u16string& imeId)
|
||||
InputMethodProperty *PerUserSetting::GetInputMethodProperty(const std::u16string& imeId)
|
||||
{
|
||||
for(int i=0; i<(int)inputMethodProperties.size(); i++) {
|
||||
if (inputMethodProperties[i]->mImeId == imeId) {
|
||||
@@ -457,7 +456,7 @@ namespace MiscServices {
|
||||
\return language value when the given hashCode is found
|
||||
\return an empty string when the given hashCode is not found
|
||||
*/
|
||||
std::u16string PerUserSetting::GetKeyboardTypeLanguage(const InputMethodProperty* property, int hashCode)
|
||||
std::u16string PerUserSetting::GetKeyboardTypeLanguage(const InputMethodProperty *property, int hashCode)
|
||||
{
|
||||
for(int i=0; i<(int)property->mTypes.size(); i++) {
|
||||
if (property->mTypes[i]->getHashCode() == hashCode) {
|
||||
@@ -511,7 +510,7 @@ namespace MiscServices {
|
||||
std::u16string systemLocales = inputMethodSetting.GetValue(InputMethodSetting::SYSTEM_LOCALE_TAG);
|
||||
std::u16string enabledInputMethods = inputMethodSetting.GetValue(InputMethodSetting::ENABLED_INPUT_METHODS_TAG);
|
||||
std::u16string imeId;
|
||||
InputMethodProperty* firstEnabledIme = nullptr;
|
||||
InputMethodProperty *firstEnabledIme = nullptr;
|
||||
bool flag = false;
|
||||
|
||||
for(int i=0; i<(int)inputMethodProperties.size(); i++) {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "global.h"
|
||||
#include "platform.h"
|
||||
#include "platform_callback_stub.h"
|
||||
@@ -41,9 +40,9 @@ namespace MiscServices {
|
||||
|
||||
/*! Single instance exists in the service
|
||||
*/
|
||||
Platform* Platform::Instance()
|
||||
Platform *Platform::Instance()
|
||||
{
|
||||
static Platform* platform = nullptr;
|
||||
static Platform *platform = nullptr;
|
||||
if (platform == nullptr) {
|
||||
platform = new Platform();
|
||||
}
|
||||
@@ -56,8 +55,8 @@ namespace MiscServices {
|
||||
\param intention the intention to start the service
|
||||
\return the remote object handler of started input method service.
|
||||
*/
|
||||
sptr < IInputMethodCore > Platform::BindInputMethodService(int userId, const std::u16string& packageName,
|
||||
const std::u16string& intention)
|
||||
sptr<IInputMethodCore> Platform::BindInputMethodService(int userId, const std::u16string& packageName,
|
||||
const std::u16string& intention)
|
||||
{
|
||||
if (platformApi == nullptr) {
|
||||
return nullptr;
|
||||
@@ -110,7 +109,7 @@ namespace MiscServices {
|
||||
\param[out] inputMethodProperties the input method engine list installed in the system for the given user
|
||||
\return ErrorCode
|
||||
*/
|
||||
int Platform::ListInputMethod(int userId, std::vector < InputMethodProperty* > * inputMethodProperties)
|
||||
int Platform::ListInputMethod(int userId, std::vector<InputMethodProperty*> *inputMethodProperties)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -121,7 +120,8 @@ namespace MiscServices {
|
||||
\param[out] inputMethodProperty the input method engine information for the given package
|
||||
\return ErrorCode
|
||||
*/
|
||||
int Platform::GetInputMethodProperty(int userId, const std::u16string& packageName, InputMethodProperty * inputMethodProperty)
|
||||
int Platform::GetInputMethodProperty(int userId, const std::u16string& packageName,
|
||||
InputMethodProperty *inputMethodProperty)
|
||||
{
|
||||
if (platformApi == nullptr) {
|
||||
return ErrorCode::ERROR_NULL_POINTER;
|
||||
@@ -134,7 +134,8 @@ namespace MiscServices {
|
||||
\param[out] inputMethodSetting the input method setting data for the given user
|
||||
\return ErrorCode
|
||||
*/
|
||||
int Platform::GetInputMethodSetting(int userId, InputMethodSetting * inputMethodSetting)
|
||||
|
||||
int Platform::GetInputMethodSetting(int userId, InputMethodSetting *inputMethodSetting)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,22 +24,19 @@
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/*! \class PlatformApiProxy
|
||||
\brief The proxy implementation of IPlatformApi
|
||||
|
||||
\todo This class will be deleted on target platform
|
||||
*/
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class PlatformApi : public IRemoteProxy < IPlatformApi > {
|
||||
class PlatformApiProxy : public IRemoteProxy < IPlatformApi > {
|
||||
public:
|
||||
PlatformApi(const sptr < IRemoteObject >& impl)
|
||||
PlatformApiProxy(const sptr<IRemoteObject>& impl)
|
||||
: IRemoteProxy < IPlatformApi >(impl)
|
||||
{
|
||||
}
|
||||
|
||||
~PlatformApi()
|
||||
~PlatformApiProxy()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,11 +57,13 @@ namespace MiscServices {
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
|
||||
std::u16string getInterfaceDescriptor() {
|
||||
std::u16string getInterfaceDescriptor()
|
||||
{
|
||||
return Utils::to_utf16("20210814");
|
||||
}
|
||||
|
||||
sptr < IInputMethodCore > bindInputMethodService(const std::u16string& packageName, const std::u16string& intention, int userId)
|
||||
sptr < IInputMethodCore > bindInputMethodService(const std::u16string& packageName,
|
||||
const std::u16string& intention, int userId)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
@@ -138,12 +137,14 @@ namespace MiscServices {
|
||||
return status;
|
||||
}
|
||||
int code = reply.ReadException();
|
||||
if (code != 0) // code=0, means no exception.
|
||||
if (code != 0) {
|
||||
// code=0, means no exception.
|
||||
return code;
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t listInputMethod(int userId, std::vector < InputMethodProperty* > * inputMethodProperties)
|
||||
int32_t listInputMethod(int userId, std::vector<InputMethodProperty*> *inputMethodProperties)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
@@ -154,11 +155,13 @@ namespace MiscServices {
|
||||
return status;
|
||||
}
|
||||
int code = reply.ReadException();
|
||||
if (code != 0) // code=0, means no exception.
|
||||
if (code != 0) {
|
||||
// code=0, means no exception.
|
||||
return code;
|
||||
}
|
||||
int size = reply.ReadInt32();
|
||||
for (int i = 0; i < size; i++) {
|
||||
InputMethodProperty * property = new InputMethodProperty();
|
||||
InputMethodProperty *property = new InputMethodProperty();
|
||||
property = reply.ReadParcelable<InputMethodProperty>();
|
||||
inputMethodProperties->push_back(property);
|
||||
}
|
||||
@@ -166,7 +169,8 @@ namespace MiscServices {
|
||||
}
|
||||
|
||||
|
||||
virtual int32_t getInputMethodProperty(int userId, const std::u16string& packageName, InputMethodProperty * inputMethodProperty)
|
||||
virtual int32_t getInputMethodProperty(int userId, const std::u16string& packageName,
|
||||
InputMethodProperty *inputMethodProperty)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
@@ -178,13 +182,15 @@ namespace MiscServices {
|
||||
return status;
|
||||
}
|
||||
int code = reply.ReadException();
|
||||
if (code != 0) // code=0, means no exception.
|
||||
if (code != 0) {
|
||||
// code=0, means no exception.
|
||||
return code;
|
||||
}
|
||||
inputMethodProperty = reply.ReadParcelable<InputMethodProperty>();
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t getInputMethodSetting(int userId, InputMethodSetting * inputMethodSetting)
|
||||
int32_t getInputMethodSetting(int userId, InputMethodSetting *inputMethodSetting)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
@@ -195,8 +201,10 @@ namespace MiscServices {
|
||||
return status;
|
||||
}
|
||||
int code = reply.ReadException();
|
||||
if (code != 0) // code=0, means no exception.
|
||||
if (code != 0) {
|
||||
// code=0, means no exception.
|
||||
return code;
|
||||
}
|
||||
inputMethodSetting = reply.ReadParcelable<InputMethodSetting>();
|
||||
return status;
|
||||
}
|
||||
@@ -213,8 +221,10 @@ namespace MiscServices {
|
||||
return status;
|
||||
}
|
||||
int code = reply.ReadException();
|
||||
if (code != 0) // code=0, means no exception.
|
||||
if (code != 0) {
|
||||
// code=0, means no exception.
|
||||
return code;
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,15 +19,12 @@
|
||||
#include "global.h"
|
||||
#include "i_platform_callback.h"
|
||||
|
||||
|
||||
|
||||
/*! \class PlatformCallbackProxy
|
||||
\brief The proxy of IPlatformCallback
|
||||
\todo This class will be deleted on target platform
|
||||
*/
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class PlatformCallbackProxy : public IRemoteProxy < IPlatformCallback > {
|
||||
class PlatformCallbackProxy : public IRemoteProxy<IPlatformCallback> {
|
||||
public:
|
||||
PlatformCallbackProxy(const sptr < IRemoteObject >& impl)
|
||||
: IRemoteProxy < IPlatformCallback >(impl)
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "message_handler.h"
|
||||
#include "message.h"
|
||||
#include "message_parcel.h"
|
||||
@@ -24,13 +23,17 @@
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
using namespace MessageID;
|
||||
PlatformCallbackStub::PlatformCallbackStub() {
|
||||
PlatformCallbackStub::PlatformCallbackStub()
|
||||
{
|
||||
}
|
||||
|
||||
PlatformCallbackStub::~PlatformCallbackStub() {
|
||||
PlatformCallbackStub::~PlatformCallbackStub()
|
||||
{
|
||||
}
|
||||
|
||||
int PlatformCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel & data, MessageParcel & reply, MessageOption & option) {
|
||||
int PlatformCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
|
||||
MessageOption& option)
|
||||
{
|
||||
switch (code) {
|
||||
case NOTIFY_EVENT: {
|
||||
int eventId = data.ReadInt32();
|
||||
@@ -50,7 +53,8 @@ namespace MiscServices {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void PlatformCallbackStub::notifyEvent(int eventId, int userId, const std::vector<std::u16string>& eventContent) {
|
||||
void PlatformCallbackStub::notifyEvent(int eventId, int userId, const std::vector<std::u16string>& eventContent)
|
||||
{
|
||||
int msgId = 0;
|
||||
switch (eventId) {
|
||||
case CommonEvent::COMMON_EVENT_USER_STARTED: {
|
||||
@@ -86,15 +90,15 @@ namespace MiscServices {
|
||||
}
|
||||
}
|
||||
|
||||
MessageParcel* parcel = new MessageParcel();
|
||||
MessageParcel *parcel = new MessageParcel();
|
||||
parcel->WriteInt32(userId);
|
||||
int size = eventContent.size();
|
||||
parcel->WriteInt32(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
parcel->WriteString16(eventContent[i]);
|
||||
}
|
||||
Message* msg = new Message(msgId, parcel);
|
||||
Message *msg = new Message(msgId, parcel);
|
||||
MessageHandler::Instance()->SendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -27,7 +27,7 @@ ohos_unittest("InputMethodControllerTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [
|
||||
"src/test_imc.cpp"]
|
||||
"src/input_method_controller_test.cpp"]
|
||||
|
||||
configs = [
|
||||
":module_private_config",
|
||||
@@ -60,7 +60,7 @@ ohos_unittest("InputMethodAbilityTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [
|
||||
"src/test_ima.cpp"]
|
||||
"src/input_method_ability_test.cpp"]
|
||||
|
||||
configs = [
|
||||
":module_private_config",
|
||||
|
||||
@@ -31,14 +31,12 @@
|
||||
#include "input_method_ability.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
|
||||
{
|
||||
class InputMethodAbilityTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void);
|
||||
static void TearDownTestCase(void);
|
||||
@@ -46,7 +44,6 @@ public:
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
|
||||
void InputMethodAbilityTest::SetUpTestCase(void)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbilityTest::SetUpTestCase");
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::MiscServices;
|
||||
@@ -39,20 +38,22 @@ class TextListener : public OnTextChangedListener {
|
||||
public:
|
||||
TextListener() {}
|
||||
~TextListener() {}
|
||||
void InsertText(const std::u16string& text) {
|
||||
void InsertText(const std::u16string& text)
|
||||
{
|
||||
IMSA_HILOGI("IMC TEST TextListener InsertText: %{public}s", MiscServices::Utils::to_utf8(text).c_str());
|
||||
}
|
||||
|
||||
void DeleteBackward(int32_t length){
|
||||
void DeleteBackward(int32_t length)
|
||||
{
|
||||
IMSA_HILOGI("IMC TEST TextListener DeleteBackward length: %{public}d", length);
|
||||
}
|
||||
|
||||
void SetKeyboardStatus(bool status) {
|
||||
void SetKeyboardStatus(bool status)
|
||||
{
|
||||
IMSA_HILOGI("IMC TEST TextListener SetKeyboardStatus %{public}d", status);
|
||||
}
|
||||
};
|
||||
class InputMethodControllerTest : public testing::Test
|
||||
{
|
||||
class InputMethodControllerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void);
|
||||
static void TearDownTestCase(void);
|
||||
Reference in New Issue
Block a user