mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2025-02-08 00:20:02 +00:00
modify some code at 7/20 19:58
Signed-off-by: zhaolinglan <zhaolinglan@huawei.com>
This commit is contained in:
parent
e2d6bc6602
commit
7d7c866685
@ -75,7 +75,7 @@ namespace MiscServices {
|
||||
int32_t GetInputPattern();
|
||||
void HideCurrentInput();
|
||||
void SetCallingWindow(uint32_t windowId);
|
||||
int32_t SwitchInputMethod(InputMethodProperty *target);
|
||||
int32_t SwitchInputMethod(const InputMethodProperty &target);
|
||||
|
||||
private:
|
||||
InputMethodController();
|
||||
|
@ -56,7 +56,7 @@ namespace MiscServices {
|
||||
int32_t listInputMethodEnabled(std::vector<InputMethodProperty*> *properties) override;
|
||||
int32_t listInputMethod(std::vector<InputMethodProperty*> *properties) override;
|
||||
int32_t listKeyboardType(const std::u16string& imeId, std::vector<KeyboardType*> *types) override;
|
||||
int32_t SwitchInputMethod(InputMethodProperty* target);
|
||||
int32_t SwitchInputMethod(const InputMethodProperty &target);
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<InputMethodSystemAbilityProxy> delegator_;
|
||||
|
@ -444,7 +444,7 @@ using namespace MessageID;
|
||||
agent->SetCallingWindow(windowId);
|
||||
}
|
||||
|
||||
int32_t InputMethodController::SwitchInputMethod(InputMethodProperty *target)
|
||||
int32_t InputMethodController::SwitchInputMethod(const InputMethodProperty &target)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodController::SwitchInputMethod");
|
||||
if (!mImms) {
|
||||
|
@ -438,7 +438,7 @@ namespace MiscServices {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t InputMethodSystemAbilityProxy::SwitchInputMethod(InputMethodProperty* target)
|
||||
int32_t InputMethodSystemAbilityProxy::SwitchInputMethod(const InputMethodProperty &target)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbilityProxy::SwitchInputMethod");
|
||||
MessageParcel data, reply;
|
||||
@ -448,14 +448,12 @@ namespace MiscServices {
|
||||
return ERROR_EX_PARCELABLE;
|
||||
}
|
||||
|
||||
if (!target->Marshalling(data)) {
|
||||
if (!target.Marshalling(data)) {
|
||||
IMSA_HILOGE("InputMethodSystemAbilityProxy::switchInputMethod Failed to marshall target to data!");
|
||||
delete target;
|
||||
return ERROR_IME_PROPERTY_MARSHALL;
|
||||
}
|
||||
delete target;
|
||||
auto ret = Remote()->SendRequest(SWITCH_INPUT_METHOD, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
if (ret != 0) {
|
||||
return ERROR_STATUS_FAILED_TRANSACTION;
|
||||
}
|
||||
ret = reply.ReadInt32();
|
||||
|
@ -96,14 +96,14 @@ namespace MiscServices {
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
InputMethodProperty *target = new InputMethodProperty();
|
||||
InputMethodProperty target;
|
||||
NativeObject *object = ConvertNativeValueTo<NativeObject>(info.argv[0]);
|
||||
if (object == nullptr) {
|
||||
IMSA_HILOGE("JsInputMethodRegistry::OnSwitchInputMethod Failed to get object");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
if (!GetInputMethodPropertyFromJs(engine, object, *target)) {
|
||||
if (!GetInputMethodPropertyFromJs(engine, object, target)) {
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,18 @@ namespace MiscServices {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
std::shared_ptr<NativeReference> callbackRef(engine_->CreateReference(jsListenerObject, 1));
|
||||
if (callbackRef == nullptr) {
|
||||
IMSA_HILOGI("JsInputMethodEngineListener::AddCallback fail, callbackRef is nullptr.");
|
||||
IMSA_HILOGI("JsInputMethodEngineListener::AddCallback fail, callbackRef is nullptr");
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lk(mapMutex);
|
||||
jsCbMap_[type].push_back(callbackRef);
|
||||
IMSA_HILOGI("JsInputMethodEngineListener::AddCallback success");
|
||||
IMSA_HILOGI("jsCbMap_ size: %{public}d, and type[%{public}s] size: %{public}d!",
|
||||
IMSA_HILOGI("AddCallback success! jsCbMap_ size: %{public}d, and type[%{public}s] size: %{public}d",
|
||||
static_cast<uint32_t>(jsCbMap_.size()), type.c_str(), static_cast<uint32_t>(jsCbMap_[type].size()));
|
||||
}
|
||||
|
||||
void JsInputMethodEngineListener::UnregisterAllListenerWithType(std::string type)
|
||||
{
|
||||
IMSA_HILOGI("JsInputMethodEngineListener::UnregisterAllListenerWithType : %{public}s.", type.c_str());
|
||||
IMSA_HILOGI("JsInputMethodEngineListener::UnregisterAllListenerWithType : %{public}s", type.c_str());
|
||||
// should do type check
|
||||
std::lock_guard<std::recursive_mutex> lk(mapMutex);
|
||||
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
|
||||
@ -102,8 +101,8 @@ namespace MiscServices {
|
||||
}
|
||||
for (auto iter : jsCbMap_[methodName]) {
|
||||
if (iter == nullptr) {
|
||||
IMSA_HILOGE("JsInputMethodEngineListener::CallJsMethod iter is null!");
|
||||
return;
|
||||
IMSA_HILOGE("JsInputMethodEngineListener::CallJsMethod iter is null");
|
||||
continue;
|
||||
}
|
||||
engine_->CallFunction(engine_->CreateUndefined(), iter->Get(), argv, argc);
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ namespace MiscServices {
|
||||
want.SetElementName(imeId.substr(0, pos), imeId.substr(pos + 1));
|
||||
int32_t result = abms->StartAbility(want);
|
||||
if (result) {
|
||||
IMSA_HILOGE("InputMethodSystemAbility::StartInputService fail.");
|
||||
IMSA_HILOGE("InputMethodSystemAbility::StartInputService failed, result = %{public}d", result);
|
||||
isStartSuccess = false;
|
||||
} else {
|
||||
IMSA_HILOGE("InputMethodSystemAbility::StartInputService success.");
|
||||
@ -990,9 +990,7 @@ namespace MiscServices {
|
||||
}
|
||||
|
||||
std::string defaultIme = ParaHandle::GetDefaultIme(userId_);
|
||||
std::string targetIme;
|
||||
std::string imeId = Str16ToStr8(target->mPackageName) + "/" + Str16ToStr8(target->mAbilityName);
|
||||
targetIme += imeId;
|
||||
std::string targetIme = Str16ToStr8(target->mPackageName) + "/" + Str16ToStr8(target->mAbilityName);
|
||||
IMSA_HILOGI("InputMethodSystemAbility::OnSwitchInputMethod DefaultIme : %{public}s, TargetIme : %{public}s",
|
||||
defaultIme.c_str(), targetIme.c_str());
|
||||
if (defaultIme != targetIme) {
|
||||
@ -1004,9 +1002,11 @@ namespace MiscServices {
|
||||
}
|
||||
bool setResult = ParaHandle::SetDefaultIme(userId_, targetIme);
|
||||
if (setResult) {
|
||||
IMSA_HILOGI("SetDefaultIme Successfully.");
|
||||
IMSA_HILOGI("InputMethodSystemAbility::OnSwitchInputMethod SetDefaultIme Successfully.");
|
||||
} else {
|
||||
IMSA_HILOGI("SetDefaultIme Failed.");
|
||||
IMSA_HILOGI("InputMethodSystemAbility::OnSwitchInputMethod SetDefaultIme Failed. setResult = "
|
||||
"%{public}d",
|
||||
setResult);
|
||||
return ErrorCode::ERROR_STATUS_PERMISSION_DENIED;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user