mirror of
https://github.com/openharmony/miscservices_inputmethod.git
synced 2026-07-19 01:39:37 -04:00
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FM_IMMS_PROJECT_IINPUTCLIENT_H
|
||||
#define FM_IMMS_PROJECT_IINPUTCLIENT_H
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "i_input_method_agent.h"
|
||||
#include "input_channel.h"
|
||||
#include "global.h"
|
||||
|
||||
/**
|
||||
* brief Definition of interface IInputClient
|
||||
* It defines the remote calls from input method management service to input client.
|
||||
*/
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class IInputClient : public IRemoteBroker {
|
||||
public:
|
||||
enum {
|
||||
ON_INPUT_READY = 0,
|
||||
ON_INPUT_RELEASED ,
|
||||
SET_DISPLAY_MODE ,
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FM_IMMS_PROJECT_IINPUTCLIENT_H
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FM_IMMS_PROJECT_IINPUTDATACHANNEL_H
|
||||
#define FM_IMMS_PROJECT_IINPUTDATACHANNEL_H
|
||||
#include <errors.h>
|
||||
#include "iremote_broker.h"
|
||||
#include "global.h"
|
||||
|
||||
/**
|
||||
* brief Definition of interface IInputDataChannel
|
||||
* It defines the remote calls from input method service to input client
|
||||
*/
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class IInputDataChannel: public IRemoteBroker {
|
||||
public:
|
||||
enum {
|
||||
INSERT_TEXT = 0,
|
||||
DELETE_BACKWARD,
|
||||
CLOSE,
|
||||
};
|
||||
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IInputDataChannel");
|
||||
|
||||
virtual bool InsertText(const std::u16string& text) = 0;
|
||||
virtual bool DeleteBackward(int32_t length) = 0;
|
||||
virtual void Close() = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // FM_IMMS_PROJECT_IINPUTDATACHANNEL_H
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FM_IMC_PROJECT_INPUTCLIENTPROXY_H
|
||||
#define FM_IMC_PROJECT_INPUTCLIENTPROXY_H
|
||||
|
||||
#include "iremote_proxy.h"
|
||||
#include "i_input_client.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
|
||||
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 onInputReleased(int32_t retValue) override;
|
||||
int32_t setDisplayMode(int32_t mode) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<InputClientProxy> delegator_;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FM_IMC_PROJECT_INPUTCLIENTSTUB_H
|
||||
#define FM_IMC_PROJECT_INPUTCLIENTSTUB_H
|
||||
|
||||
#include "iremote_stub.h"
|
||||
#include "i_input_client.h"
|
||||
#include "message_handler.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class InputClientStub : public IRemoteStub<IInputClient> {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(InputClientStub);
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
InputClientStub();
|
||||
~InputClientStub();
|
||||
void SetHandler(MessageHandler* handler);
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef FM_IMC_PROJECT_INPUTDATACHANNELPROXY_H
|
||||
#define FM_IMC_PROJECT_INPUTDATACHANNELPROXY_H
|
||||
|
||||
#include "iremote_proxy.h"
|
||||
#include "i_input_data_channel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
|
||||
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;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<InputDataChannelProxy> delegator_;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FM_IMC_PROJECT_INPUTDATACHANNELSTUB_H
|
||||
#define FM_IMC_PROJECT_INPUTDATACHANNELSTUB_H
|
||||
|
||||
#include "i_input_data_channel.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "message_handler.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class InputDataChannelStub : public IRemoteStub<IInputDataChannel> {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(InputDataChannelStub);
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
InputDataChannelStub();
|
||||
~InputDataChannelStub();
|
||||
void SetHandler(MessageHandler* handler);
|
||||
|
||||
bool InsertText(const std::u16string& text) override;
|
||||
bool DeleteBackward(int32_t length) override;
|
||||
void Close() override;
|
||||
private:
|
||||
MessageHandler* msgHandler;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#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"
|
||||
#include "input_client_stub.h"
|
||||
#include "input_method_system_ability_proxy.h"
|
||||
#include "input_method_agent_proxy.h"
|
||||
#include "i_input_method_agent.h"
|
||||
#include "message_handler.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
|
||||
class OnTextChangedListener : public virtual RefBase {
|
||||
public:
|
||||
virtual void InsertText(const std::u16string& text) = 0;
|
||||
virtual void DeleteBackward(int32_t length) = 0;
|
||||
virtual void SetKeyboardStatus(bool status) = 0;
|
||||
};
|
||||
|
||||
class ImsaDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
explicit ImsaDeathRecipient();
|
||||
~ImsaDeathRecipient() = default;
|
||||
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &object) override;
|
||||
};
|
||||
|
||||
class InputMethodController : public RefBase {
|
||||
public:
|
||||
static sptr<InputMethodController> GetInstance();
|
||||
void Attach();
|
||||
void ShowTextInput(sptr<OnTextChangedListener> &listener);
|
||||
void HideTextInput();
|
||||
void Close();
|
||||
void OnRemoteSaDied(const wptr<IRemoteObject> &object);
|
||||
private:
|
||||
InputMethodController();
|
||||
~InputMethodController();
|
||||
|
||||
bool Initialize();
|
||||
sptr<InputMethodSystemAbilityProxy> GetImsaProxy();
|
||||
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);
|
||||
void WorkThread();
|
||||
|
||||
sptr<InputDataChannelStub> mInputDataChannel;
|
||||
sptr<InputClientStub> mClient;
|
||||
sptr<InputMethodSystemAbilityProxy> mImms;
|
||||
sptr<ImsaDeathRecipient> deathRecipient_;
|
||||
sptr<InputMethodAgentProxy> mAgent;
|
||||
sptr<OnTextChangedListener> textListener;
|
||||
InputAttribute mAttribute;
|
||||
|
||||
static std::mutex instanceLock_;
|
||||
static sptr<InputMethodController> instance_;
|
||||
std::thread workThreadHandler;
|
||||
MessageHandler* msgHandler;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FM_IMC_PROJECT_INPUTMETHODSYSTEMABILITYPROXY_H
|
||||
#define FM_IMC_PROJECT_INPUTMETHODSYSTEMABILITYPROXY_H
|
||||
|
||||
#include <vector>
|
||||
#include "iremote_proxy.h"
|
||||
#include "i_input_method_system_ability.h"
|
||||
#include "message_parcel.h"
|
||||
#include "keyboard_type.h"
|
||||
#include "input_method_property.h"
|
||||
#include "input_client_stub.h"
|
||||
#include "input_data_channel_stub.h"
|
||||
#include "input_attribute.h"
|
||||
#include "global.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<InputMethodSystemAbilityProxy> delegator_;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user