回退 'Pull Request !21 : 修复告警问题'

This commit is contained in:
demon
2021-12-27 01:12:54 +00:00
committed by Gitee
parent 0576795b64
commit d6d936ac16
36 changed files with 113 additions and 129 deletions
@@ -45,9 +45,6 @@ namespace MiscServices {
napi_ref thisVarRef_;
EventListener *first_;
EventListener *last_;
private:
static const int LISTENER_TYPTE_MAX_LENGTH = 64;
};
}
}
@@ -16,13 +16,13 @@
#ifndef FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H
#define FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H
#include <mutex>
#include <condition_variable>
#include <cstdint>
#include "iremote_broker.h"
#include "iremote_stub.h"
#include "i_input_method_agent.h"
#include "input_channel.h"
#include <mutex>
#include <condition_variable>
#include <cstdint>
#include "message_parcel.h"
#include "input_attribute.h"
#include "i_input_data_channel.h"
@@ -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;
}
}
}
@@ -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;
}
@@ -19,7 +19,7 @@ namespace OHOS {
namespace MiscServices {
using namespace ErrorCode;
InputMethodAgentProxy::InputMethodAgentProxy(const sptr<IRemoteObject> &object)
: IRemoteProxy<IInputMethodAgent>(object)
: IRemoteProxy<IInputMethodAgent>(object)
{
}
@@ -24,7 +24,6 @@ namespace MiscServices {
InputMethodAgentStub::InputMethodAgentStub()
{
msgHandler_ = nullptr;
}
InputMethodAgentStub::~InputMethodAgentStub()
@@ -21,7 +21,7 @@
namespace OHOS {
namespace MiscServices {
InputMethodCoreProxy::InputMethodCoreProxy(const OHOS::sptr<OHOS::IRemoteObject> &impl)
: IRemoteProxy<IInputMethodCore>(impl)
: IRemoteProxy<IInputMethodCore>(impl)
{
}
@@ -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"
@@ -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;
@@ -33,7 +33,7 @@ namespace MiscServices {
void SetHandler(MessageHandler *handler);
int32_t onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent,
const InputChannel *channel) override;
const InputChannel *channel) override;
int32_t onInputReleased(int32_t retValue) override;
int32_t setDisplayMode(int32_t mode) override;
private:
@@ -29,7 +29,7 @@
namespace OHOS {
namespace MiscServices {
class InputMethodSystemAbilityProxy : public IRemoteProxy<IInputMethodSystemAbility> {
class InputMethodSystemAbilityProxy : public IRemoteProxy<IInputMethodSystemAbility> {
public:
explicit InputMethodSystemAbilityProxy(const sptr<IRemoteObject> &object);
~InputMethodSystemAbilityProxy() = default;
@@ -64,7 +64,7 @@ using namespace MessageID;
mInputDataChannel = new InputDataChannelStub();
mInputDataChannel->SetHandler(msgHandler);
workThreadHandler = std::thread([this] {WorkThread();});
workThreadHandler = std::thread([this]{WorkThread();});
mAttribute.SetInputPattern(InputAttribute::PATTERN_TEXT);
textListener = nullptr;
@@ -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>;
}
@@ -213,8 +213,8 @@ namespace MiscServices {
*/
extern "C" __attribute__((constructor)) void RegisterModule()
{
IMSA_HILOGI("RegisterModule() is called!");
napi_module_register(&inputMethodEngineModule);
IMSA_HILOGI("RegisterModule() is called!");
napi_module_register(&inputMethodEngineModule);
}
}
}
+1
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;
};
}
}
+11 -11
View File
@@ -23,17 +23,17 @@
#include "global.h"
namespace OHOS {
namespace MiscServices {
class IPlatformCallback : public IRemoteBroker {
public:
enum {
NOTIFY_EVENT = OHOS::FIRST_CALL_TRANSACTION,
namespace MiscServices {
class IPlatformCallback : public IRemoteBroker {
public:
enum {
NOTIFY_EVENT = OHOS::FIRST_CALL_TRANSACTION,
};
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IPlatformCallback");
virtual void notifyEvent(int eventId, int userId, const std::vector<std::u16string>& eventContent) = 0;
};
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IPlatformCallback");
virtual void notifyEvent(int eventId, int userId, const std::vector<std::u16string>& eventContent) = 0;
};
}
}
}
#endif // FM_IMMS_PROJECT_IPLATFORMCALLBACK_H
@@ -16,12 +16,12 @@
#ifndef FM_IMMS_PROJECT_INPUTCONTROLCHANNELSTUB_H
#define FM_IMMS_PROJECT_INPUTCONTROLCHANNELSTUB_H
#include <mutex>
#include <condition_variable>
#include "iremote_broker.h"
#include "iremote_stub.h"
#include "i_input_method_agent.h"
#include "input_channel.h"
#include <mutex>
#include <condition_variable>
#include "message_parcel.h"
#include "i_input_control_channel.h"
+1
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);
@@ -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;
@@ -36,7 +35,6 @@ namespace MiscServices {
void setInputMethodCoreFromHap(MessageParcel& data);
protected:
int32_t getUserId(int32_t uid);
int USER_ID_CHANGE_VALUE = 1000000;
};
}
}
+2 -2
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,
@@ -76,7 +76,7 @@ namespace MessageID {
};
}
class MessageHandler {
class MessageHandler {
public:
MessageHandler();
~MessageHandler();
+1 -4
View File
@@ -122,10 +122,6 @@ namespace MiscServices {
int currentIndex;
std::map<sptr<IRemoteObject>, ClientInfo*> mapClients;
int MIN_IME = 2;
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
@@ -150,6 +146,7 @@ namespace MiscServices {
std::mutex mtx; // mutex to lock the operations among multi work threads
sptr<AAFwk::AbilityConnectionProxy> connCallback;
sptr<InputMethodAbility> inputMethodAbility_;
int SLEEP_TIME = 300000;
PerUserSession(const PerUserSession&);
PerUserSession& operator =(const PerUserSession&);
-1
View File
@@ -58,7 +58,6 @@ namespace MiscServices {
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
int COMMON_COUNT_ONE_HUNDRED_THOUSAND = 100000;
PerUserSetting(const PerUserSetting&);
PerUserSetting& operator =(const PerUserSetting&);
+11 -10
View File
@@ -23,16 +23,17 @@
#include "i_platform_callback.h"
namespace OHOS {
namespace MiscServices {
class PlatformCallbackStub : public IRemoteStub<IPlatformCallback> {
public:
PlatformCallbackStub();
~PlatformCallbackStub();
namespace MiscServices {
class PlatformCallbackStub : public IRemoteStub<IPlatformCallback> {
public:
PlatformCallbackStub();
~PlatformCallbackStub();
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;
};
}
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;
};
}
}
#endif // FM_IMMS_PROJECT_PLATFORMCALLBACK_SK_H
+8 -9
View File
@@ -19,21 +19,20 @@
#define FM_IMMS_PROJECT_UTILS_H
#include <string>
#include <codecvt>
#include <locale>
#include <iostream>
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);
}
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);
}
};
}
}
-1
View File
@@ -21,7 +21,6 @@ namespace MiscServices {
*/
InputAttribute::InputAttribute() : enterKeyType(0), inputOption(0)
{
inputPattern = PATTERN_TEXT;
}
/*! Constructor
@@ -13,6 +13,8 @@
* limitations under the License.
*/
#include <chrono>
#include <cstdint>
#include "message_handler.h"
#include "input_control_channel_stub.h"
#include "i_input_control_channel.h"
@@ -22,7 +22,6 @@ namespace MiscServices {
InputMethodAbilityConnectionStub::InputMethodAbilityConnectionStub(const int index)
{
mIndex = index;
messageHandler = nullptr;
}
InputMethodAbilityConnectionStub::~InputMethodAbilityConnectionStub()
-1
View File
@@ -22,7 +22,6 @@ namespace MiscServices {
*/
InputMethodProperty::InputMethodProperty()
{
mDefaultImeId = 0;
}
/*! Destructor
+4 -4
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;
@@ -582,7 +582,7 @@ namespace MiscServices {
std::map<int32_t, MessageHandler*>::iterator it = msgHandlers.find(userId);
if (it != msgHandlers.end()) {
MessageHandler *handler = it->second;
Message *destMsg = new Message(MSG_ID_USER_LOCK, nullptr);
Message *destMsg = new Message(MSG_ID_USER_LOCK , nullptr);
if (destMsg != nullptr) {
handler->SendMessage(destMsg);
PerUserSession *userSession = GetUserSession(userId);
@@ -207,6 +207,7 @@ namespace MiscServices {
Message *msg = new Message(MSG_ID_RELEASE_INPUT, parcel);
MessageHandler::Instance()->SendMessage(msg);
}
/*! Start input
@@ -270,7 +271,7 @@ namespace MiscServices {
*/
int32_t InputMethodSystemAbilityStub::getUserId(int32_t uid)
{
return uid/USER_ID_CHANGE_VALUE;
return uid/1000000;
}
}
}
+3 -2
View File
@@ -106,10 +106,11 @@ namespace MiscServices {
{
mId = typeId;
if (typeId != ID_NONE) {
mHashCode = typeId;
mHashCode = typeId;
} else {
mHashCode = ID_NONE;
mHashCode = ID_NONE;
}
}
void KeyboardType::setLabelId(int32_t labelId)
+2 -2
View File
@@ -46,7 +46,7 @@ namespace MiscServices {
std::unique_lock<std::mutex> lock(mMutex);
mQueue.push(msg);
}
mCV.notify_one();
mCV.notify_one();
}
/*! Get a message
@@ -56,7 +56,7 @@ namespace MiscServices {
Message *MessageHandler::GetMessage()
{
std::unique_lock<std::mutex> lock(mMutex);
mCV.wait(lock, [this] {
mCV.wait(lock, [this]{
return !this->mQueue.empty();
});
+17 -24
View File
@@ -12,14 +12,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "unistd.h" // usleep
#include <vector>
#include "unistd.h" //usleep
#include "peruser_session.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 "peruser_session.h"
#include "ability_connect_callback_proxy.h"
#include "ability_manager_interface.h"
#include "sa_mgr_client.h"
@@ -99,7 +101,7 @@ namespace MiscServices {
void PerUserSession::CreateWorkThread(MessageHandler& handler)
{
msgHandler = &handler;
workThreadHandler = std::thread([this] {WorkThread();});
workThreadHandler = std::thread([this]{WorkThread();});
}
/*! Wait till work thread exits
@@ -264,12 +266,10 @@ namespace MiscServices {
}
if (flag) {
int ret = StartInputMethod(i);
if (ret != ErrorCode::NO_ERROR) {
needReshowClient = nullptr;
break;
}
if (needReshowClient && GetImeIndex(needReshowClient) == i) {
ShowKeyboard(needReshowClient);
if (ret == ErrorCode::NO_ERROR) {
ShowKeyboard(needReshowClient);
}
needReshowClient = nullptr;
}
}
@@ -502,13 +502,11 @@ namespace MiscServices {
ret = imsCore[index]->showKeyboard(1);
if (!ret) {
IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! showKeyboard has error : %{public}s",
ErrorCode::ToString(ret));
IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! showKeyboard has error : %{public}s", ErrorCode::ToString(ret));
int ret_client = clientInfo->client->onInputReady(1, nullptr, nullptr);
if (ret_client != ErrorCode::NO_ERROR) {
IMSA_HILOGE("PerUserSession::ShowKeyboard onInputReady has error : %{public}s",
ErrorCode::ToString(ret_client));
IMSA_HILOGE("PerUserSession::ShowKeyboard onInputReady has error : %{public}s", ErrorCode::ToString(ret_client));
}
return ErrorCode::ERROR_KBD_SHOW_FAILED;
}
@@ -519,8 +517,7 @@ namespace MiscServices {
int result = clientInfo->client->onInputReady(0, imsAgent, imsChannel);
if (result != ErrorCode::NO_ERROR) {
IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! onInputReady return : %{public}s",
ErrorCode::ToString(ret));
IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! onInputReady return : %{public}s", ErrorCode::ToString(ret));
return result;
}
currentClient = inputClient;
@@ -567,8 +564,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",
ErrorCode::ToString(ret_client_stop));
IMSA_HILOGE("PerUserSession::HideKeyboard onInputReady return : %{public}s", ErrorCode::ToString(ret_client_stop));
}
currentClient = nullptr;
imsAgent = nullptr;
@@ -696,7 +692,7 @@ namespace MiscServices {
StopInputMethod(1 - index);
}
if (IncreaseOrResetImeError(false, index) == IME_ERROR_CODE) {
if (IncreaseOrResetImeError(false, index) == 3) {
// call to disable the current input method.
MessageParcel *parcel = new MessageParcel();
parcel->WriteInt32(userId_);
@@ -711,7 +707,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_);
@@ -855,7 +851,7 @@ namespace MiscServices {
return;
}
int size = 0;
if (index == SECURITY_IME || currentIme[DEFAULT_IME] == currentIme[SECURITY_IME]) {
if (index == SECURITY_IME || currentIme[DEFAULT_IME] == currentIme[SECURITY_IME] ) {
size = currentIme[index]->mTypes.size();
} else {
std::u16string imeId = currentIme[index]->mImeId;
@@ -993,8 +989,8 @@ 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;
if (diffSeconds > COMMON_COUNT_THREE_HUNDRED) {
//time difference is more than 5 minutes, reset time and error num;
if (diffSeconds > 300) {
past[imeIndex] = now;
errorNum[imeIndex] = 1;
}
@@ -1040,9 +1036,6 @@ namespace MiscServices {
*/
void PerUserSession::ResetCurrentKeyboardType(int imeIndex)
{
if (imeIndex < 0 || imeIndex > 1) {
return;
}
currentKbdIndex[imeIndex] = 0;
int hashCode = 0;
if (imeIndex == DEFAULT_IME) {
+19 -21
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" //usleep
#include "peruser_setting.h"
#include "platform.h"
#include "utils.h"
@@ -67,15 +67,14 @@ namespace MiscServices {
}
}
/**
* Add an input method engine.It's called when a package is installed in the system.
* @param packageName the package name of installed package.
* @param isSecurityIme check if the added ime is a security ime.
* @return ErrorCode::NO_ERROR The installed package is an IME package,
* and is added in the input method management system
* ErrorCode::ERROR_NOT_IME_PACKAGE The installed package is not an IME package.
* ErrorCode::ERROR_IME_PACKAGE_DUPLICATED The installed package is duplicated.
*/
/*! Add an input method engine.
\n It's called when a package is installed in the system.
\param packageName the package name of installed package.
\param[out] isSecurityIme check if the added ime is a security ime.
\return ErrorCode::NO_ERROR The installed package is an IME package, and is added in the input method management system
\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)
{
if (isSecurityIme) {
@@ -117,15 +116,13 @@ namespace MiscServices {
return ErrorCode::NO_ERROR;
}
/**
* Remove an input method engine.
* It's called when a package is removed from the system.
* @param packageName the package name of installed package.
* @param isSecurityIme check if the removed ime is a security ime.
* @return ErrorCode::NO_ERROR The removed package is an IME package,
* and is removed from the input method management system
* ErrorCode::ERROR_NOT_IME_PACKAGE The removed package is not an IME package.
*/
/*! Remove an input method engine.
\n It's called when a package is removed from the system.
\param packageName the package name of installed package.
\param[out] isSecurityIme check if the removed ime is a security ime.
\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)
{
if (isSecurityIme) {
@@ -168,7 +165,8 @@ namespace MiscServices {
}
Platform::Instance()->SetInputMethodSetting(userId_, imSetting);
// wait for some time so that the setting change will not be overrided by the followed transact
usleep(COMMON_COUNT_ONE_HUNDRED_THOUSAND);
int32_t sleepTime = 100000;
usleep(sleepTime);
return ErrorCode::NO_ERROR;
}
+2 -1
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;
}
@@ -167,6 +167,7 @@ namespace MiscServices {
return ErrorCode::NO_ERROR;
}
virtual int32_t getInputMethodProperty(int userId, const std::u16string& packageName,
InputMethodProperty *inputMethodProperty)
{
+2
View File
@@ -43,6 +43,7 @@ ohos_unittest("InputMethodControllerTest") {
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
"//third_party/googletest:gtest_main",
"//utils/native/base:utils",
"//utils/native/base:utils",
]
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
@@ -70,6 +71,7 @@ ohos_unittest("InputMethodAbilityTest") {
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
"//third_party/googletest:gtest_main",
"//utils/native/base:utils",
"//utils/native/base:utils",
]
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]