mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 06:40:06 +00:00
Merge pull request !1078 from 赵凌岚/master
This commit is contained in:
commit
971be8d98b
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 INPUTMETHOD_IMF_I_INPUTMETHOD_EXTENSION_ABILITY_H
|
||||
#define INPUTMETHOD_IMF_I_INPUTMETHOD_EXTENSION_ABILITY_H
|
||||
|
||||
#include "iremote_broker.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class IInputMethodExtensionAbility : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IInputMethodExtensionAbility");
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // INPUTMETHOD_IMF_I_INPUTMETHOD_EXTENSION_ABILITY_H
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 INPUTMETHOD_IMF_INPUTMETHOD_EXTENSION_ABILITY_STUB_H
|
||||
#define INPUTMETHOD_IMF_INPUTMETHOD_EXTENSION_ABILITY_STUB_H
|
||||
#include "i_inputmethod_extension_ability.h"
|
||||
#include "iremote_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class InputMethodExtensionAbilityStub : public IRemoteStub<IInputMethodExtensionAbility> {
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // INPUTMETHOD_IMF_INPUTMETHOD_EXTENSION_ABILITY_STUB_H
|
@ -20,7 +20,6 @@
|
||||
#include "configuration_utils.h"
|
||||
#include "global.h"
|
||||
#include "input_method_ability.h"
|
||||
#include "inputmethod_extension_ability_stub.h"
|
||||
#include "inputmethod_trace.h"
|
||||
#include "js_extension_context.h"
|
||||
#include "js_inputmethod_extension_context.h"
|
||||
@ -266,12 +265,42 @@ void JsInputMethodExtension::OnStop()
|
||||
sptr<IRemoteObject> JsInputMethodExtension::OnConnect(const AAFwk::Want &want)
|
||||
{
|
||||
IMSA_HILOGI("JsInputMethodExtension OnConnect begin.");
|
||||
StartAsync("OnConnect", static_cast<int32_t>(TraceTaskId::ONCONNECT_EXTENSION));
|
||||
StartAsync("Extension::OnConnect", static_cast<int32_t>(TraceTaskId::ONCONNECT_MIDDLE_EXTENSION));
|
||||
Extension::OnConnect(want);
|
||||
auto remoteObj = new (std::nothrow) InputMethodExtensionAbilityStub();
|
||||
if (remoteObj == nullptr) {
|
||||
IMSA_HILOGE("failed to create InputMethodExtensionAbilityStub");
|
||||
FinishAsync("Extension::OnConnect", static_cast<int32_t>(TraceTaskId::ONCONNECT_MIDDLE_EXTENSION));
|
||||
IMSA_HILOGI("%{public}s begin.", __func__);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
napi_env env = (napi_env)jsRuntime_.GetNativeEnginePointer();
|
||||
napi_value napiWant = OHOS::AppExecFwk::WrapWant(env, want);
|
||||
napi_value argv[] = { napiWant };
|
||||
if (jsObj_ == nullptr) {
|
||||
IMSA_HILOGE("Not found InputMethodExtension.js");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value obj = jsObj_->GetNapiValue();
|
||||
if (obj == nullptr) {
|
||||
IMSA_HILOGE("Failed to get InputMethodExtension object");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value method = nullptr;
|
||||
napi_get_named_property(env, obj, "onConnect", &method);
|
||||
if (method == nullptr) {
|
||||
IMSA_HILOGE("Failed to get onConnect from InputMethodExtension object");
|
||||
return nullptr;
|
||||
}
|
||||
IMSA_HILOGI("JsInputMethodExtension::CallFunction onConnect, success");
|
||||
napi_value remoteNapi = nullptr;
|
||||
napi_call_function(env, obj, method, ARGC_ONE, argv, &remoteNapi);
|
||||
if (remoteNapi == nullptr) {
|
||||
IMSA_HILOGE("remoteNative nullptr.");
|
||||
}
|
||||
auto remoteObj = NAPI_ohos_rpc_getNativeRemoteObject(env, remoteNapi);
|
||||
if (remoteObj == nullptr) {
|
||||
IMSA_HILOGE("remoteObj nullptr.");
|
||||
}
|
||||
FinishAsync("OnConnect", static_cast<int32_t>(TraceTaskId::ONCONNECT_EXTENSION));
|
||||
return remoteObj;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ config("inputmethod_services_native_config") {
|
||||
"${inputmethod_path}/frameworks/native/inputmethod_controller/include",
|
||||
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability/include",
|
||||
"${inputmethod_path}/services/adapter/focus_monitor/include",
|
||||
"${inputmethod_path}/services/adapter/ime_connection_manager/include",
|
||||
"${inputmethod_path}/services/adapter/keyboard/include",
|
||||
"${inputmethod_path}/services/adapter/system_language_observer/include",
|
||||
"${inputmethod_path}/services/adapter/wms_connection_monitor/include",
|
||||
@ -48,7 +47,6 @@ ohos_shared_library("inputmethod_service") {
|
||||
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
|
||||
"${inputmethod_path}/services/adapter/focus_monitor/src/focus_change_listener.cpp",
|
||||
"${inputmethod_path}/services/adapter/focus_monitor/src/focus_monitor_manager.cpp",
|
||||
"${inputmethod_path}/services/adapter/ime_connection_manager/src/ime_connection.cpp",
|
||||
"${inputmethod_path}/services/adapter/system_language_observer/src/system_language_observer.cpp",
|
||||
"${inputmethod_path}/services/adapter/wms_connection_monitor/src/wms_connection_monitor_manager.cpp",
|
||||
"${inputmethod_path}/services/adapter/wms_connection_monitor/src/wms_connection_observer.cpp",
|
||||
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 INPUTMETHOD_IMF_IME_CONNECTION_H
|
||||
#define INPUTMETHOD_IMF_IME_CONNECTION_H
|
||||
|
||||
#include "ability_connect_callback_interface.h"
|
||||
#include "ability_connect_callback_stub.h"
|
||||
#include "iremote_object.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "nocopyable.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class ImeConnection : public AAFwk::AbilityConnectionStub {
|
||||
public:
|
||||
ImeConnection() = default;
|
||||
virtual ~ImeConnection() = default;
|
||||
|
||||
void OnAbilityConnectDone(
|
||||
const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int32_t resultCode) override;
|
||||
void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int32_t resultCode) override;
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // INPUTMETHOD_IMF_IME_CONNECTION_H
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#include "ime_connection.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
void ImeConnection::OnAbilityConnectDone(
|
||||
const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int32_t resultCode)
|
||||
{
|
||||
IMSA_HILOGI("ime: %{public}s/%{public}s, ret=%{public}d", element.GetBundleName().c_str(),
|
||||
element.GetAbilityName().c_str(), resultCode);
|
||||
}
|
||||
|
||||
void ImeConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int32_t resultCode)
|
||||
{
|
||||
IMSA_HILOGI("ime: %{public}s/%{public}s, ret=%{public}d", element.GetBundleName().c_str(),
|
||||
element.GetAbilityName().c_str(), resultCode);
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
@ -21,7 +21,6 @@
|
||||
#include "element_name.h"
|
||||
#include "ime_aging_manager.h"
|
||||
#include "ime_cfg_manager.h"
|
||||
#include "ime_connection.h"
|
||||
#include "ime_info_inquirer.h"
|
||||
#include "input_client_proxy.h"
|
||||
#include "input_control_channel_proxy.h"
|
||||
@ -970,12 +969,8 @@ bool PerUserSession::StartInputService(const std::shared_ptr<ImeNativeCfg> &ime,
|
||||
AAFwk::Want want;
|
||||
want.SetElementName(ime->bundleName, ime->extName);
|
||||
isImeStarted_.Clear(false);
|
||||
sptr<AAFwk::IAbilityConnection> connection = new (std::nothrow) ImeConnection();
|
||||
if (connection == nullptr) {
|
||||
IMSA_HILOGE("failed to create connection");
|
||||
return false;
|
||||
}
|
||||
auto ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectExtensionAbility(want, connection, userId_);
|
||||
auto ret = AAFwk::AbilityManagerClient::GetInstance()->StartExtensionAbility(
|
||||
want, nullptr, userId_, AppExecFwk::ExtensionAbilityType::INPUTMETHOD);
|
||||
if (ret != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("failed to start ability");
|
||||
InputMethodSysEvent::GetInstance().InputmethodFaultReporter(
|
||||
|
Loading…
Reference in New Issue
Block a user