!27 beta3.1问题回合master分支

Merge pull request !27 from jiangdayuan/OpenHarmony-3.1-Beta
This commit is contained in:
openharmony_ci 2021-12-26 06:36:35 +00:00 committed by Gitee
commit 6ab6820e4b
27 changed files with 151 additions and 83 deletions

View File

@ -45,9 +45,6 @@ namespace MiscServices {
napi_ref thisVarRef_;
EventListener *first_;
EventListener *last_;
private:
static const int LISTENER_TYPTE_MAX_LENGTH = 64;
};
}
}

View File

@ -19,10 +19,10 @@
#include "utils/log.h"
#include "input_method_ability.h"
#define LISTENER_TYPTE_MAX_LENGTH 64
namespace OHOS {
namespace MiscServices {
struct EventListener {
static const int LISTENER_TYPTE_MAX_LENGTH = 64;
char type[LISTENER_TYPTE_MAX_LENGTH] = { 0 };
bool isOnce = false;
napi_ref handlerRef = nullptr;
@ -181,7 +181,6 @@ namespace MiscServices {
uv_work_t *work = new (std::nothrow) uv_work_t;
if (work == nullptr) {
IMSA_HILOGI("EventTarget::Emit No memory work == nullptr");
delete work;
return;
}
@ -191,7 +190,7 @@ namespace MiscServices {
work->data = (void *)eventTargetCB;
int ret = uv_queue_work(loop, work, [](uv_work_t *work) {}, [](uv_work_t *work, int status) {
// Js Thread
//Js Thread
if (work == nullptr) {
IMSA_HILOGI("EventTarget::Emit work == nullptr");
return;
@ -203,15 +202,13 @@ namespace MiscServices {
napi_value thisVar = nullptr;
napi_get_reference_value(eventTargetCB->env, eventTargetCB->thisVarRef, &thisVar);
for (EventListener *eventListener = eventTargetCB->first; eventListener != nullptr;
eventListener = eventListener->next) {
for (EventListener *eventListener = eventTargetCB->first; eventListener != nullptr; eventListener = eventListener->next) {
if (strcmp(eventListener->type, eventTargetCB->type) == 0) {
napi_value jsEvent = eventTargetCB->event ? eventTargetCB->event->ToJsObject() : nullptr;
napi_value handler = nullptr;
napi_value result = nullptr;
napi_get_reference_value(eventTargetCB->env, eventListener->handlerRef, &handler);
napi_call_function(eventTargetCB->env, thisVar, handler,
jsEvent ? 1 : 0, jsEvent ? &jsEvent : nullptr, &result);
napi_call_function(eventTargetCB->env, thisVar, handler, jsEvent ? 1 : 0, jsEvent ? &jsEvent : nullptr, &result);
if (eventListener->isOnce) {
eventTargetCB->eventTarget->Off(eventTargetCB->type, handler);
}
@ -222,11 +219,12 @@ namespace MiscServices {
if (eventTargetCB) {
delete eventTargetCB;
}
delete work;
});
if (ret != 0) {
IMSA_HILOGI("EventTarget::Emit failed to execute libuv work queue");
delete work;
}
delete work;
}
}
}

View File

@ -32,7 +32,6 @@ namespace MiscServices {
InputMethodAbility::InputMethodAbility() : stop_(false)
{
writeInputChannel = nullptr;
editorAttribute = nullptr;
Initialize();
OnConnect();
}
@ -90,9 +89,8 @@ namespace MiscServices {
sptr<IInputMethodCore> stub2 = stub;
if (mImms != nullptr) {
mImms->setInputMethodCore(stub2);
} else {
IMSA_HILOGI("InputMethodAbility::OnConnect() mImms is nullptr");
}
IMSA_HILOGI("InputMethodAbility::OnConnect() mImms is nullptr");
return nullptr;
}

View File

@ -19,7 +19,7 @@ namespace OHOS {
namespace MiscServices {
using namespace ErrorCode;
InputMethodAgentProxy::InputMethodAgentProxy(const sptr<IRemoteObject> &object)
: IRemoteProxy<IInputMethodAgent>(object)
: IRemoteProxy<IInputMethodAgent>(object)
{
}

View File

@ -21,7 +21,7 @@
namespace OHOS {
namespace MiscServices {
InputMethodCoreProxy::InputMethodCoreProxy(const OHOS::sptr<OHOS::IRemoteObject> &impl)
: IRemoteProxy<IInputMethodCore>(impl)
: IRemoteProxy<IInputMethodCore>(impl)
{
}

View File

@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <chrono>
#include <cstdint>
#include "message_handler.h"
#include "i_input_data_channel.h"
#include "input_method_core_stub.h"

View File

@ -22,14 +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;

View File

@ -30,13 +30,15 @@
namespace OHOS {
namespace MiscServices {
class InputDataChannelStub;
class InputMethodSystemAbilityProxy;
class OnTextChangedListener : public virtual RefBase {
public:
virtual void InsertText(const std::u16string& text) = 0;
virtual void DeleteForward(int32_t length) = 0;
virtual void DeleteBackward(int32_t length) = 0;
virtual void sendKeyEventFromInputMethod(KeyEvent event) = 0;
virtual void sendKeyboardStatus(KeyboardStatus status) = 0;
virtual void SendKeyEventFromInputMethod(const KeyEvent& event) = 0;
virtual void SendKeyboardInfo(const KeyboardInfo& info) = 0;
virtual void SetKeyboardStatus(bool status) = 0;
};
@ -56,9 +58,9 @@ namespace MiscServices {
void HideTextInput();
void Close();
void OnRemoteSaDied(const wptr<IRemoteObject> &object);
void onCursorUpdate(CursorInfo cursorInfo);
void OnCursorUpdate(CursorInfo cursorInfo);
void OnSelectionChange(std::u16string text, int start, int end);
void onConfigurationChange(Configuration info);
void OnConfigurationChange(Configuration info);
private:
InputMethodController();
~InputMethodController();
@ -91,4 +93,4 @@ namespace MiscServices {
};
}
}
#endif
#endif

View File

@ -16,34 +16,102 @@
#ifndef FM_IMC_PROJECT_INPUT_METHOD_UTILS_H
#define FM_IMC_PROJECT_INPUT_METHOD_UTILS_H
#include <stdint.h>
namespace OHOS {
namespace MiscServices {
class Configuration {
public:
enum {
TEXT_FIELD_ACTION_UNSPECIFIED = 0,
TEXT_FIELD_ACTION_NONE,
TEXT_FIELD_ACTION_GO,
TEXT_FIELD_ACTION_SEARCH,
TEXT_FIELD_ACTION_SEND,
TEXT_FIELD_ACTION_NEXT,
TEXT_FIELD_ACTION_DONE,
TEXT_FIELD_ACTION_PREVIOUS
};
int mTextFieldAction;
};
class CursorInfo {
};
class KeyEvent {
};
class KeyboardStatus {
public:
enum {
KEYBOARD_STATUS_HIDE = 0,
KEYBOARD_STATUS_SHOW
};
int mKeyboardStatus;
};
}
namespace MiscServices {
enum class EnterKeyType {
UNSPECIFIED = 0,
NONE,
GO,
SEARCH,
SEND,
NEXT,
DONE,
PREVIOUS
};
enum class TextInputType {
TEXT = 0,
MULTILINE,
NUMBER,
PHONE,
DATETIME,
EMAIL_ADDRESS,
URL,
VISIBLE_PASSWORD,
};
class Configuration {
public:
EnterKeyType GetEnterKeyType() const
{
return enterKeyType;
}
void SetEnterKeyType(EnterKeyType keyType)
{
enterKeyType = keyType;
}
TextInputType GetTextInputType() const
{
return textInputType;
}
void SetTextInputType(TextInputType textType)
{
textInputType = textType;
}
private:
EnterKeyType enterKeyType = EnterKeyType::UNSPECIFIED;
TextInputType textInputType = TextInputType::TEXT;
};
struct CursorInfo {
double left = 0.0;
double top = 0.0;
double width = 0.0;
double height = 0.0;
};
class KeyEvent {
};
enum class KeyboardStatus {
NONE = 0,
HIDE,
SHOW
};
enum class FunctionKey {
NONE = 0,
CONFIRM,
};
class KeyboardInfo {
public:
KeyboardStatus GetKeyboardStatus() const
{
return keyboardStatus;
}
void SetKeyboardStatus(int32_t status)
{
keyboardStatus = static_cast<KeyboardStatus>(status);
}
FunctionKey GetFunctionKey() const
{
return functionKey;
}
void SetFunctionKey(int32_t key)
{
functionKey = static_cast<FunctionKey>(key);
}
private:
KeyboardStatus keyboardStatus = KeyboardStatus::NONE;
FunctionKey functionKey = FunctionKey::NONE;
};
}
#endif // FM_IMC_PROJECT_INPUT_METHOD_UTILS_H
}
#endif // FM_IMC_PROJECT_INPUT_METHOD_UTILS_H

View File

@ -113,7 +113,7 @@ using namespace MessageID;
MessageParcel *data = msg->msgContent_;
int32_t length = data->ReadInt32();
if (textListener != nullptr) {
textListener->DeleteBackward(length);
textListener->DeleteForward(length);
}
break;
}
@ -159,7 +159,7 @@ using namespace MessageID;
void InputMethodController::Attach(sptr<OnTextChangedListener> &listener)
{
PrepareInput(0, mClient, mInputDataChannel, mAttribute);
textListener = listener;
textListener=listener;
}
void InputMethodController::ShowTextInput()
@ -253,9 +253,9 @@ using namespace MessageID;
InputMethodController::GetInstance()->OnRemoteSaDied(object);
}
void InputMethodController::onCursorUpdate(CursorInfo cursorInfo)
void InputMethodController::OnCursorUpdate(CursorInfo cursorInfo)
{
IMSA_HILOGI("InputMethodController::onCursorUpdate");
IMSA_HILOGI("InputMethodController::OnCursorUpdate");
}
void InputMethodController::OnSelectionChange(std::u16string text, int start, int end)
@ -266,9 +266,9 @@ using namespace MessageID;
mSelectEnd = end;
}
void InputMethodController::onConfigurationChange(Configuration info)
void InputMethodController::OnConfigurationChange(Configuration info)
{
IMSA_HILOGI("InputMethodController::onConfigurationChange");
IMSA_HILOGI("InputMethodController::OnConfigurationChange");
}
}
}

View File

@ -12,4 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "input_method_utils.h"
namespace OHOS {
namespace MiscServices {
}
}

View File

@ -34,7 +34,7 @@ declare namespace inputMethodEngine {
function DeleteBackward(length: number, callback: () => void): void;
function DeleteBackward(length: number): Promise<void>;
function HideKeyboardSelf(callback: () => void): void;
function HideKeyboardSelf(callback: callback: () => void): void;
function HideKeyboardSelf(): Promise<void>;
}

View File

@ -56,6 +56,7 @@ namespace OHOS {
InputMethodProperty *inputMethodProperty) = 0;
virtual int32_t getInputMethodSetting(int userId, InputMethodSetting *inputMethodSetting) = 0;
virtual int32_t setInputMethodSetting(int userId, const InputMethodSetting& inputMethodSetting) = 0;
};
}
}

View File

@ -32,6 +32,7 @@ namespace MiscServices {
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();
~InputMethodSetting();
InputMethodSetting(const InputMethodSetting& inputMethodSetting);

View File

@ -26,8 +26,7 @@ namespace OHOS {
namespace MiscServices {
class InputMethodSystemAbilityStub : public IRemoteStub<IInputMethodSystemAbility> {
public:
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 void prepareInput(MessageParcel& data) override;
virtual void releaseInput(MessageParcel& data) override;

View File

@ -58,7 +58,7 @@ namespace MessageID {
MSG_ID_SHELL_COMMAND, // shell command
MSG_ID_EXIT_SERVICE, // exit service
// the request from IMSA to IMC
//the request from IMSA to IMC
MSG_ID_INSERT_CHAR,
MSG_ID_DELETE_BACKWARD,
MSG_ID_CLOSE,

View File

@ -125,7 +125,6 @@ namespace MiscServices {
int IME_ERROR_CODE = 3;
int COMMON_COUNT_THREE_HUNDRED = 300;
int SLEEP_TIME = 300000;
int SLEEP_TIME_MORE = 1600000;
InputMethodProperty *currentIme[MAX_IME]; // 0 - the default ime. 1 - security ime

View File

@ -19,6 +19,7 @@
#define FM_IMMS_PROJECT_UTILS_H
#include <string>
#include <codecvt>
#include <locale>
#include <iostream>
@ -26,12 +27,10 @@ namespace OHOS {
namespace MiscServices {
class Utils {
public:
static std::string to_utf8(std::u16string str16)
{
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)
{
static std::u16string to_utf16(std::string str) {
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> {}.from_bytes(str);
}
};

View File

@ -21,7 +21,6 @@ namespace MiscServices {
*/
InputAttribute::InputAttribute() : enterKeyType(0), inputOption(0)
{
inputPattern = PATTERN_TEXT;
}
/*! Constructor

View File

@ -22,7 +22,6 @@ namespace MiscServices {
InputMethodAbilityConnectionStub::InputMethodAbilityConnectionStub(const int index)
{
mIndex = index;
messageHandler = nullptr;
}
InputMethodAbilityConnectionStub::~InputMethodAbilityConnectionStub()

View File

@ -22,7 +22,6 @@ namespace MiscServices {
*/
InputMethodProperty::InputMethodProperty()
{
mDefaultImeId = 0;
}
/*! Destructor

View File

@ -58,7 +58,7 @@ namespace MiscServices {
}
std::map<int32_t, PerUserSession*>::const_iterator it;
for (it = userSessions.cbegin(); it != userSessions.cend(); ) {
for (it = userSessions.cbegin(); it != userSessions.cend();) {
PerUserSession *session = it->second;
it = userSessions.erase(it);
delete session;
@ -66,7 +66,7 @@ namespace MiscServices {
}
userSessions.clear();
std::map<int32_t, PerUserSetting*>::const_iterator it1;
for (it1 = userSettings.cbegin(); it1 != userSettings.cend(); ) {
for (it1 = userSettings.cbegin(); it1 != userSettings.cend();) {
PerUserSetting *setting = it1->second;
it1 = userSettings.erase(it1);
delete setting;
@ -74,7 +74,7 @@ namespace MiscServices {
}
userSettings.clear();
std::map<int32_t, MessageHandler*>::const_iterator it2;
for (it2 = msgHandlers.cbegin(); it2 != msgHandlers.cend(); ) {
for (it2 = msgHandlers.cbegin(); it2 != msgHandlers.cend();) {
MessageHandler *handler = it2->second;
it2 = msgHandlers.erase(it2);
delete handler;

View File

@ -110,6 +110,7 @@ namespace MiscServices {
} else {
mHashCode = ID_NONE;
}
}
void KeyboardType::setLabelId(int32_t labelId)

View File

@ -12,13 +12,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "unistd.h" // usleep
#include "unistd.h"
#include "platform.h"
#include "parcel.h"
#include "message_parcel.h"
#include "utils.h"
#include "want.h"
#include "input_method_ability_connection_stub.h"
#include <vector>
#include "peruser_session.h"
#include "ability_connect_callback_proxy.h"
#include "ability_manager_interface.h"
@ -711,7 +713,7 @@ namespace MiscServices {
parcel->WriteInt32(index);
parcel->WriteString16(currentIme[index]->mImeId);
Message *msg = new Message(MSG_ID_RESTART_IMS, parcel);
usleep(SLEEP_TIME_MORE); // wait that PACKAGE_REMOVED message is received if this ime has been removed
usleep(1600*1000); // wait that PACKAGE_REMOVED message is received if this ime has been removed
MessageHandler::Instance()->SendMessage(msg);
}
IMSA_HILOGI("End...[%{public}d]\n", userId_);
@ -993,7 +995,7 @@ namespace MiscServices {
time_t now = time(0);
double diffSeconds = difftime(now, past[imeIndex]);
// time difference is more than 5 minutes, reset time and error num;
//time difference is more than 5 minutes, reset time and error num;
if (diffSeconds > COMMON_COUNT_THREE_HUNDRED) {
past[imeIndex] = now;
errorNum[imeIndex] = 1;

View File

@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "unistd.h" // usleep
#include "unistd.h"
#include "peruser_setting.h"
#include "platform.h"
#include "utils.h"

View File

@ -76,7 +76,7 @@ namespace MiscServices {
return nullptr;
}
int code = reply.ReadException();
if (code != 0) { // code = 0, means no exception.
if (code != 0) {// code = 0, means no exception.
LOG_DEBUG("exception code : %d\n", code);
return nullptr;
}

View File

@ -56,13 +56,13 @@ namespace MiscServices {
{
IMSA_HILOGI("IMC TEST TextListener DeleteForward length: %{public}d", length);
}
void sendKeyEventFromInputMethod(KeyEvent event)
void SendKeyEventFromInputMethod(const KeyEvent& event)
{
IMSA_HILOGI("IMC TEST TextListener sendKeyEventFromInputMethod");
}
void sendKeyboardStatus(KeyboardStatus status)
void SendKeyboardInfo(const KeyboardInfo& info)
{
IMSA_HILOGI("IMC TEST TextListener sendKeyboardStatus");
IMSA_HILOGI("IMC TEST TextListener SendKeyboardInfo");
}
};
class InputMethodControllerTest : public testing::Test {