Merge branch 'master' of gitee.com:openharmony/inputmethod_imf into master

Signed-off-by: 赵凌岚 <zhaolinglan1@huawei.com>
This commit is contained in:
赵凌岚 2024-04-29 10:58:19 +00:00 committed by zhaolinglan
commit 63e57c55d3
104 changed files with 1262 additions and 531 deletions

View File

@ -24,6 +24,7 @@ group("imf_packages") {
"frameworks/js/napi/inputmethodability:inputmethodengine",
"frameworks/js/napi/inputmethodclient:inputmethod",
"frameworks/js/napi/inputmethodlist:inputmethodlist",
"frameworks/js/napi/keyboardpanelmanager:keyboardpanelmanager",
"interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"interfaces/inner_api/inputmethod_controller:inputmethod_client",
"profile:inputmethod_inputmethod_sa_profiles",

View File

@ -56,13 +56,12 @@
},
"build": {
"group_type": {
"base_group": [ ],
"base_group": ["//base/inputmethod/imf/common:inputmethod_common"],
"fwk_group": [
"//base/inputmethod/imf/interfaces/inner_api/inputmethod_controller:inputmethod_client",
"//base/inputmethod/imf/frameworks/js/napi/inputmethodclient:inputmethod",
"//base/inputmethod/imf/frameworks/js/napi/inputmethodlist:inputmethodlist",
"//base/inputmethod/imf/frameworks/js/napi/inputmethodpanel:panel",
"//base/inputmethod/imf/services/dfx:inputmethod_dfx_static"
"//base/inputmethod/imf/frameworks/js/napi/inputmethodpanel:panel"
],
"service_group": [
"//base/inputmethod/imf/etc/init:inputmethodservice.cfg",
@ -75,7 +74,8 @@
"//base/inputmethod/imf/frameworks/kits/extension:inputmethod_extension_module",
"//base/inputmethod/imf/frameworks/js/napi/inputmethodability:inputmethodengine",
"//base/inputmethod/imf/frameworks/js/napi/inputmethod_extension_ability:inputmethodextensionability_napi",
"//base/inputmethod/imf/frameworks/js/napi/inputmethod_extension_context:inputmethodextensioncontext_napi"
"//base/inputmethod/imf/frameworks/js/napi/inputmethod_extension_context:inputmethodextensioncontext_napi",
"//base/inputmethod/imf/frameworks/js/napi/keyboardpanelmanager:keyboardpanelmanager"
]
},
"inner_api": [
@ -88,10 +88,8 @@
"../../../../frameworks/native/inputmethod_controller/include/input_method_property.h",
"../../../../frameworks/native/inputmethod_controller/include/input_method_utils.h",
"../../../../frameworks/native/inputmethod_controller/include/input_window_info.h",
"../../../../frameworks/native/inputmethod_controller/include/i_system_cmd_channel.h",
"ime_event_listener.h",
"ime_event_monitor_manager.h",
"ime_system_channel.h",
"input_method_controller.h"
],
"header_base": "//base/inputmethod/imf/interfaces/inner_api/inputmethod_controller/include"

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# 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
@ -14,34 +14,53 @@
import("//base/inputmethod/imf/inputmethod.gni")
import("//build/ohos.gni")
ohos_static_library("inputmethod_dfx_static") {
config("inputmethod_common_native_config") {
visibility = [ ":*" ]
include_dirs = [
"include",
"${inputmethod_path}/frameworks/native/inputmethod_controller/include",
"${inputmethod_path}/frameworks/native/inputmethod_ability/include",
]
}
ohos_shared_library("inputmethod_common") {
branch_protector_ret = "pac_ret"
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
cflags_cc = [
"-fdata-sections",
"-ffunction-sections",
"-Os",
]
sources = [
"src/global.cpp",
"src/input_death_recipient.cpp",
"src/inputmethod_dump.cpp",
"src/inputmethod_sysevent.cpp",
"src/inputmethod_trace.cpp",
"src/itypes_util.cpp",
"src/message.cpp",
"src/message_handler.cpp",
]
include_dirs = [
"include",
"${inputmethod_path}/services/include",
]
configs = [ ":inputmethod_common_native_config" ]
cflags_cc = [ "-fvisibility=hidden" ]
public_configs = [ ":inputmethod_common_native_config" ]
external_deps = [
"ability_base:want",
"c_utils:utils",
"hilog:libhilog",
"hisysevent:libhisysevent",
"hitrace:hitrace_meter",
"hitrace:libhitracechain",
"input:libmmi-client",
"ipc:ipc_single",
]
subsystem_name = "inputmethod"
part_name = "imf"
}

View File

@ -16,8 +16,6 @@
#include "itypes_util.h"
#include "global.h"
#include "input_client_proxy.h"
#include "input_data_channel_proxy.h"
#include "iremote_object.h"
namespace OHOS {
@ -122,6 +120,7 @@ bool ITypesUtil::Unmarshalling(sptr<IRemoteObject> &output, MessageParcel &data)
output = data.ReadRemoteObject();
return true;
}
bool ITypesUtil::Marshalling(const Property &input, MessageParcel &data)
{
if (!Marshal(data, input.name, input.id, input.label, input.labelId, input.icon, input.iconId)) {
@ -143,7 +142,7 @@ bool ITypesUtil::Unmarshalling(Property &output, MessageParcel &data)
bool ITypesUtil::Marshalling(const SubProperty &input, MessageParcel &data)
{
if (!Marshal(data, input.label, input.labelId, input.name, input.id, input.mode, input.locale, input.language,
input.icon, input.iconId)) {
input.icon, input.iconId)) {
IMSA_HILOGE("ITypesUtil::write SubProperty to message parcel failed");
return false;
}
@ -250,7 +249,7 @@ bool ITypesUtil::Unmarshalling(TextTotalConfig &output, MessageParcel &data)
bool ITypesUtil::Marshalling(const InputClientInfo &input, MessageParcel &data)
{
if (!Marshal(data, input.pid, input.uid, input.userID, input.isShowKeyboard, input.eventFlag, input.config,
input.state, input.isNotifyInputStart, input.client->AsObject(), input.channel->AsObject())) {
input.state, input.isNotifyInputStart)) {
IMSA_HILOGE("write InputClientInfo to message parcel failed");
return false;
}
@ -264,14 +263,6 @@ bool ITypesUtil::Unmarshalling(InputClientInfo &output, MessageParcel &data)
IMSA_HILOGE("read InputClientInfo from message parcel failed");
return false;
}
auto client = data.ReadRemoteObject();
auto channel = data.ReadRemoteObject();
if (client == nullptr || channel == nullptr) {
IMSA_HILOGE("read remote object failed");
return false;
}
output.client = iface_cast<IInputClient>(client);
output.channel = iface_cast<IInputDataChannel>(channel);
return true;
}

View File

@ -30,7 +30,6 @@ config("inputmethod_js_common_public_config") {
include_dirs = [
"./",
"${inputmethod_path}/frameworks/common",
"${inputmethod_path}/services/dfx/include",
]
}
@ -49,7 +48,7 @@ ohos_static_library("inputmethod_js_common") {
]
configs = [ ":inputmethod_js_common_config" ]
public_configs = [ ":inputmethod_js_common_public_config" ]
deps = [ "${inputmethod_path}/services/dfx:inputmethod_dfx_static" ]
deps = [ "${inputmethod_path}/common:inputmethod_common" ]
external_deps = [ "napi:ace_napi" ]
subsystem_name = "inputmethod"
part_name = "imf"

View File

@ -28,7 +28,8 @@ const std::unordered_map<EventSubscribeModule, std::unordered_set<std::string>>
"securityModeChange", "privateCommand" } },
{ EventSubscribeModule::KEYBOARD_DELEGATE, { "editorAttributeChanged", "keyDown", "keyUp", "keyEvent",
"cursorContextChange", "selectionChange", "textChange" } },
{ EventSubscribeModule::PANEL, { "show", "hide" } }
{ EventSubscribeModule::PANEL, { "show", "hide" } },
{ EventSubscribeModule::KEYBOARD_PANEL_MANAGER, { "panelPrivateCommand", "isPanelShow" } }
};
bool EventChecker::IsValidEventType(EventSubscribeModule module, const std::string &type)
{

View File

@ -26,6 +26,7 @@ enum class EventSubscribeModule : uint32_t {
INPUT_METHOD_SETTING,
INPUT_METHOD_ABILITY,
KEYBOARD_DELEGATE,
KEYBOARD_PANEL_MANAGER,
PANEL,
};
class EventChecker {

View File

@ -18,18 +18,19 @@ config("inputmethodengine_native_config") {
visibility = [ ":*" ]
include_dirs = [
"include",
"${inputmethod_path}/common",
"${inputmethod_path}/common/include",
"${inputmethod_path}/frameworks/common",
"${inputmethod_path}/frameworks/native/inputmethod_ability/include",
"${inputmethod_path}/frameworks/native/inputmethod_controller/include",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller/include",
"${inputmethod_path}/services/dfx/include",
]
ldflags = [ "-Wl,--exclude-libs=ALL" ]
cflags = [
cflags_cc = [
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
"-fdata-sections",
"-ffunction-sections",
"-fvisibility=hidden",
"-Os",
]
}
@ -37,7 +38,7 @@ config("inputmethodengine_native_public_config") {
visibility = [ "./*" ]
include_dirs = [
"include",
"${inputmethod_path}/common",
"${inputmethod_path}/common/include",
"${inputmethod_path}/frameworks/common",
"${inputmethod_path}/frameworks/js/napi/inputmethodclient",
"${inputmethod_path}/frameworks/js/napi/inputmethodability",
@ -55,7 +56,6 @@ ohos_shared_library("inputmethodengine") {
"${inputmethod_path}/frameworks/js/napi/inputmethodclient/async_call.cpp",
"${inputmethod_path}/frameworks/js/napi/inputmethodclient/js_utils.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
"${inputmethod_path}/services/src/global.cpp",
"input_method_engine_module.cpp",
"js_input_method_engine_setting.cpp",
"js_keyboard_controller_engine.cpp",
@ -68,9 +68,9 @@ ohos_shared_library("inputmethodengine") {
configs = [ ":inputmethodengine_native_config" ]
deps = [
"${inputmethod_path}/common:inputmethod_common",
"${inputmethod_path}/frameworks/js/napi/common:inputmethod_js_common",
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/services/dfx:inputmethod_dfx_static",
]
external_deps = [

View File

@ -24,7 +24,6 @@
#include "js_util.h"
#include "js_utils.h"
#include "key_event_napi.h"
#include "keyevent_consumer_proxy.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"

View File

@ -42,10 +42,6 @@ ohos_shared_library("inputmethod") {
debug = false
}
sources = [
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_data_channel_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/itypes_util.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
"async_call.cpp",
"input_method_module.cpp",
"js_get_input_method_controller.cpp",

View File

@ -24,7 +24,6 @@
#include "js_input_method.h"
#include "js_util.h"
#include "js_utils.h"
#include "keyevent_consumer_proxy.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"
#include "string_ex.h"

View File

@ -18,6 +18,7 @@ config("inputmethod_panel_config") {
visibility = [ ":*" ]
include_dirs = [
"./",
"${inputmethod_path}/common/include",
"${inputmethod_path}/frameworks/native/inputmethod_ability/include",
]
}
@ -30,7 +31,6 @@ ohos_shared_library("panel") {
debug = false
}
sources = [
"${inputmethod_path}/services/src/global.cpp",
"input_method_panel_module.cpp",
"js_input_method_panel.cpp",
]

View File

@ -0,0 +1,67 @@
# 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.
import("//base/inputmethod/imf/inputmethod.gni")
import("//build/ohos.gni")
config("keyboard_panel_manager_config") {
visibility = [ ":*" ]
include_dirs = [ "include" ]
}
config("keyboard_panel_manager_public_config") {
visibility = [ "./*" ]
include_dirs = [
"include",
"${inputmethod_path}/common",
"${inputmethod_path}/frameworks/common",
"${inputmethod_path}/frameworks/js/napi/inputmethodclient",
]
}
ohos_shared_library("keyboardpanelmanager") {
branch_protector_ret = "pac_ret"
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
sources = [
"${inputmethod_path}/frameworks/js/napi/inputmethodclient/async_call.cpp",
"${inputmethod_path}/frameworks/js/napi/inputmethodclient/js_utils.cpp",
"js_keyboard_panel_manager.cpp",
"keyboard_panel_manager_module.cpp",
]
configs = [ ":keyboard_panel_manager_config" ]
deps = [
"${inputmethod_path}/frameworks/js/napi/common:inputmethod_js_common",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client",
]
external_deps = [
"ability_runtime:abilitykit_native",
"c_utils:utils",
"eventhandler:libeventhandler",
"hilog:libhilog",
"input:libmmi-client",
"napi:ace_napi",
]
public_configs = [ ":keyboard_panel_manager_public_config" ]
relative_install_dir = "module"
subsystem_name = "inputmethod"
part_name = "imf"
}

View File

@ -0,0 +1,314 @@
/*
* 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 "js_keyboard_panel_manager.h"
#include "event_checker.h"
#include "input_method_utils.h"
#include "js_callback_handler.h"
#include "js_util.h"
#include "js_utils.h"
namespace OHOS {
namespace MiscServices {
constexpr int32_t MAX_WAIT_TIME_PRIVATE_COMMAND = 2000;
BlockQueue<PrivateCommandInfo> JsKeyboardPanelManager::privateCommandQueue_{ MAX_WAIT_TIME_PRIVATE_COMMAND };
std::mutex JsKeyboardPanelManager::managerMutex_;
sptr<JsKeyboardPanelManager> JsKeyboardPanelManager::keyboardPanelManager_{ nullptr };
JsKeyboardPanelManager::JsKeyboardPanelManager()
{
std::lock_guard<std::mutex> lock(eventHandlerMutex_);
handler_ = AppExecFwk::EventHandler::Current();
}
napi_value JsKeyboardPanelManager::Init(napi_env env, napi_value info)
{
napi_property_descriptor descriptor[] = {
DECLARE_NAPI_FUNCTION("sendPrivateCommand", SendPrivateCommand),
DECLARE_NAPI_FUNCTION("getSmartMenuCfg", GetSmartMenuCfg),
DECLARE_NAPI_FUNCTION("on", Subscribe),
DECLARE_NAPI_FUNCTION("off", UnSubscribe),
};
NAPI_CALL(
env, napi_define_properties(env, info, sizeof(descriptor) / sizeof(napi_property_descriptor), descriptor));
return info;
}
sptr<JsKeyboardPanelManager> JsKeyboardPanelManager::GetInstance()
{
if (keyboardPanelManager_ == nullptr) {
std::lock_guard<std::mutex> lock(managerMutex_);
if (keyboardPanelManager_ == nullptr) {
keyboardPanelManager_ = new (std::nothrow) JsKeyboardPanelManager();
}
}
return keyboardPanelManager_;
}
napi_value JsKeyboardPanelManager::Subscribe(napi_env env, napi_callback_info info)
{
size_t argc = 2; // has 2 param
napi_value argv[2] = { nullptr };
napi_value thisVar = nullptr;
void *data = nullptr;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
std::string type;
// 2 means least param num.
if (argc < 2 || !JsUtil::GetValue(env, argv[0], type)
|| !EventChecker::IsValidEventType(EventSubscribeModule::KEYBOARD_PANEL_MANAGER, type)
|| JsUtil::GetType(env, argv[1]) != napi_function) {
IMSA_HILOGE("Subscribe failed, type:%{public}s", type.c_str());
return nullptr;
}
auto manager = JsKeyboardPanelManager::GetInstance();
auto ret = ImeSystemCmdChannel::GetInstance()->ConnectSystemCmd(manager);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("Subscribe failed, type:%{public}s", type.c_str());
return nullptr;
}
IMSA_HILOGD("Subscribe type:%{public}s.", type.c_str());
std::shared_ptr<JSCallbackObject> callback =
std::make_shared<JSCallbackObject>(env, argv[1], std::this_thread::get_id());
manager->RegisterListener(argv[1], type, callback);
return JsUtil::Const::Null(env);
}
napi_value JsKeyboardPanelManager::UnSubscribe(napi_env env, napi_callback_info info)
{
size_t argc = 2; // has 2 param
napi_value argv[2] = { nullptr };
napi_value thisVar = nullptr;
void *data = nullptr;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
std::string type;
// 1 means least param num.
if (argc < 1 || !JsUtil::GetValue(env, argv[0], type)
|| !EventChecker::IsValidEventType(EventSubscribeModule::KEYBOARD_PANEL_MANAGER, type)) {
IMSA_HILOGE("UnSubscribe failed, type:%{public}s", type.c_str());
return nullptr;
}
auto manager = JsKeyboardPanelManager::GetInstance();
auto ret = ImeSystemCmdChannel::GetInstance()->ConnectSystemCmd(manager);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("UnSubscribe failed, type:%{public}s", type.c_str());
return nullptr;
}
// if the second param is not napi_function/napi_null/napi_undefined, return
auto paramType = JsUtil::GetType(env, argv[1]);
if (paramType != napi_function && paramType != napi_null && paramType != napi_undefined) {
return nullptr;
}
// if the second param is napi_function, delete it, else delete all
argv[1] = paramType == napi_function ? argv[1] : nullptr;
IMSA_HILOGD("UnSubscribe type:%{public}s.", type.c_str());
manager->UnRegisterListener(argv[1], type);
return JsUtil::Const::Null(env);
}
void JsKeyboardPanelManager::RegisterListener(
napi_value callback, std::string type, std::shared_ptr<JSCallbackObject> callbackObj)
{
IMSA_HILOGD("RegisterListener %{public}s", type.c_str());
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
IMSA_HILOGD("methodName: %{public}s not registered!", type.c_str());
}
auto callbacks = jsCbMap_[type];
bool ret = std::any_of(callbacks.begin(), callbacks.end(), [&callback](std::shared_ptr<JSCallbackObject> cb) {
return JsUtils::Equals(cb->env_, callback, cb->callback_, cb->threadId_);
});
if (ret) {
IMSA_HILOGD("JsKeyboardPanelManagerListener callback already registered!");
return;
}
IMSA_HILOGI("Add %{public}s callbackObj into jsCbMap_", type.c_str());
jsCbMap_[type].push_back(std::move(callbackObj));
}
void JsKeyboardPanelManager::UnRegisterListener(napi_value callback, std::string type)
{
IMSA_HILOGI("event: %{public}s", type.c_str());
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) {
IMSA_HILOGE("methodName: %{public}s already unRegistered!", type.c_str());
return;
}
if (callback == nullptr) {
jsCbMap_.erase(type);
IMSA_HILOGI("callback is nullptr");
return;
}
for (auto item = jsCbMap_[type].begin(); item != jsCbMap_[type].end(); item++) {
if (JsUtils::Equals((*item)->env_, callback, (*item)->callback_, (*item)->threadId_)) {
jsCbMap_[type].erase(item);
break;
}
}
if (jsCbMap_[type].empty()) {
jsCbMap_.erase(type);
}
}
napi_value JsKeyboardPanelManager::GetSmartMenuCfg(napi_env env, napi_callback_info info)
{
auto ctxt = std::make_shared<SmartMenuContext>();
auto output = [ctxt](napi_env env, napi_value *result) -> napi_status {
*result = JsUtil::GetValue(env, ctxt->smartMenu);
return napi_ok;
};
auto exec = [ctxt](AsyncCall::Context *ctx) {
ctxt->smartMenu = ImeSystemCmdChannel::GetInstance()->GetSmartMenuCfg();
ctxt->SetState(napi_ok);
};
ctxt->SetAction(nullptr, std::move(output));
// 1 means JsAPI:displayOptionalInputMethod has 1 params at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "GetSmartMenuCfg");
}
napi_value JsKeyboardPanelManager::SendPrivateCommand(napi_env env, napi_callback_info info)
{
auto ctxt = std::make_shared<SendPrivateCommandContext>();
auto input = [ctxt](napi_env env, size_t argc, napi_value *argv, napi_value self) -> napi_status {
PARAM_CHECK_RETURN(env, argc > 0, "should 1 parameter!", TYPE_NONE, napi_generic_failure);
CHECK_RETURN(JsUtils::GetValue(env, argv[0], ctxt->privateCommand) == napi_ok,
"GetValue privateCommand error", napi_generic_failure);
if (!TextConfig::IsPrivateCommandValid(ctxt->privateCommand)) {
PARAM_CHECK_RETURN(
env, false, "privateCommand size limit 32KB, count limit 5.", TYPE_NONE, napi_generic_failure);
}
ctxt->info = { std::chrono::system_clock::now(), ctxt->privateCommand };
privateCommandQueue_.Push(ctxt->info);
return napi_ok;
};
auto output = [ctxt](napi_env env, napi_value *result) -> napi_status { return napi_ok; };
auto exec = [ctxt](AsyncCall::Context *ctx) {
privateCommandQueue_.Wait(ctxt->info);
int32_t code = ImeSystemCmdChannel::GetInstance()->SendPrivateCommand(ctxt->privateCommand);
privateCommandQueue_.Pop();
if (code == ErrorCode::NO_ERROR) {
ctxt->SetState(napi_ok);
} else {
ctxt->SetErrorCode(code);
}
};
ctxt->SetAction(std::move(input), std::move(output));
// 1 means JsAPI:SendPrivateCommand has 1 params at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "SendPrivateCommand");
}
void JsKeyboardPanelManager::ReceivePrivateCommand(
const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
{
IMSA_HILOGD("JsKeyboardPanelManager, run in");
std::string type = "panelPrivateCommand";
auto entry = GetEntry(type, [&privateCommand](UvEntry &entry) { entry.privateCommand = privateCommand; });
if (entry == nullptr) {
return;
}
auto eventHandler = GetEventHandler();
if (eventHandler == nullptr) {
IMSA_HILOGE("eventHandler is nullptr!");
return;
}
auto task = [entry]() {
auto paramGetter = [entry](napi_env env, napi_value *args, uint8_t argc) -> bool {
if (argc < 1) {
return false;
}
napi_value jsObject = JsUtils::GetJsPrivateCommand(env, entry->privateCommand);
if (jsObject == nullptr) {
IMSA_HILOGE("GetJsPrivateCommand failed: jsObject is nullptr");
return false;
}
// 0 means the first param of callback.
args[0] = { jsObject };
return true;
};
// 1 means callback has 1 params.
JsCallbackHandler::Traverse(entry->vecCopy, { 1, paramGetter });
};
eventHandler->PostTask(task, type, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
void JsKeyboardPanelManager::NotifyIsShowSysPanel(bool shouldSysPanelShow)
{
IMSA_HILOGD("JsKeyboardPanelManager, run in");
std::string type = "isPanelShow";
auto entry =
GetEntry(type, [shouldSysPanelShow](UvEntry &entry) { entry.shouldSysPanelShow = shouldSysPanelShow; });
if (entry == nullptr) {
return;
}
auto eventHandler = GetEventHandler();
if (eventHandler == nullptr) {
IMSA_HILOGE("eventHandler is nullptr!");
return;
}
auto task = [entry]() {
auto paramGetter = [entry](napi_env env, napi_value *args, uint8_t argc) -> bool {
if (argc < 1) {
return false;
}
napi_value jsObject = JsUtil::GetValue(env, entry->shouldSysPanelShow);
args[0] = { jsObject };
return true;
};
// 1 means callback has 1 params.
JsCallbackHandler::Traverse(entry->vecCopy, { 1, paramGetter });
};
eventHandler->PostTask(task, type, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
std::shared_ptr<AppExecFwk::EventHandler> JsKeyboardPanelManager::GetEventHandler()
{
if (handler_ != nullptr) {
return handler_;
}
std::lock_guard<std::mutex> lock(eventHandlerMutex_);
if (handler_ == nullptr) {
handler_ = AppExecFwk::EventHandler::Current();
}
return handler_;
}
std::shared_ptr<JsKeyboardPanelManager::UvEntry> JsKeyboardPanelManager::GetEntry(
const std::string &type, EntrySetter entrySetter)
{
IMSA_HILOGD("type: %{public}s", type.c_str());
std::shared_ptr<UvEntry> entry = nullptr;
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (jsCbMap_[type].empty()) {
IMSA_HILOGD("%{public}s cb-vector is empty", type.c_str());
return nullptr;
}
entry = std::make_shared<UvEntry>(jsCbMap_[type], type);
}
if (entrySetter != nullptr) {
entrySetter(*entry);
}
return entry;
}
} // namespace MiscServices
} // namespace OHOS

View File

@ -0,0 +1,109 @@
/*
* 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 FRAMEWORKS_JS_NAPI_JS_KEYBOARD_PANEL_MANAGER_H
#define FRAMEWORKS_JS_NAPI_JS_KEYBOARD_PANEL_MANAGER_H
#include "async_call.h"
#include "block_queue.h"
#include "event_handler.h"
#include "js_callback_object.h"
#include "ime_system_channel.h"
namespace OHOS {
namespace MiscServices {
struct PrivateCommandInfo {
std::chrono::system_clock::time_point timestamp{};
std::unordered_map<std::string, PrivateDataValue> privateCommand;
bool operator==(const PrivateCommandInfo &info) const
{
return (timestamp == info.timestamp && privateCommand == info.privateCommand);
}
};
struct SendPrivateCommandContext : public AsyncCall::Context {
std::unordered_map<std::string, PrivateDataValue> privateCommand;
PrivateCommandInfo info;
SendPrivateCommandContext() : Context(nullptr, nullptr){};
napi_status operator()(napi_env env, napi_value *result) override
{
if (status_ != napi_ok) {
output_ = nullptr;
return status_;
}
return Context::operator()(env, result);
}
};
struct SmartMenuContext : public AsyncCall::Context {
std::string smartMenu;
SmartMenuContext() : Context(nullptr, nullptr){};
napi_status operator()(napi_env env, napi_value *result) override
{
if (status_ != napi_ok) {
output_ = nullptr;
return status_;
}
return Context::operator()(env, result);
}
};
class JsKeyboardPanelManager : public OnSystemCmdListener {
public:
JsKeyboardPanelManager();
~JsKeyboardPanelManager() = default;
static napi_value Init(napi_env env, napi_value info);
static sptr<JsKeyboardPanelManager> GetInstance();
static napi_value SendPrivateCommand(napi_env env, napi_callback_info info);
static napi_value GetSmartMenuCfg(napi_env env, napi_callback_info info);
static napi_value Subscribe(napi_env env, napi_callback_info info);
static napi_value UnSubscribe(napi_env env, napi_callback_info info);
void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
void NotifyIsShowSysPanel(bool shouldSysPanelShow) override;
private:
void RegisterListener(napi_value callback, std::string type, std::shared_ptr<JSCallbackObject> callbackObj);
void UnRegisterListener(napi_value callback, std::string type);
struct UvEntry {
std::vector<std::shared_ptr<JSCallbackObject>> vecCopy;
std::string type;
bool shouldSysPanelShow;
std::string smartMenu;
std::unordered_map<std::string, PrivateDataValue> privateCommand;
explicit UvEntry(const std::vector<std::shared_ptr<JSCallbackObject>> &cbVec, const std::string &type)
: vecCopy(cbVec), type(type)
{
}
};
using EntrySetter = std::function<void(UvEntry &)>;
std::shared_ptr<AppExecFwk::EventHandler> GetEventHandler();
std::shared_ptr<UvEntry> GetEntry(const std::string &type, EntrySetter entrySetter = nullptr);
std::recursive_mutex mutex_;
std::map<std::string, std::vector<std::shared_ptr<JSCallbackObject>>> jsCbMap_;
std::mutex eventHandlerMutex_;
std::shared_ptr<AppExecFwk::EventHandler> handler_;
static std::mutex managerMutex_;
static sptr<JsKeyboardPanelManager> keyboardPanelManager_;
static BlockQueue<PrivateCommandInfo> privateCommandQueue_;
};
} // namespace MiscServices
} // namespace OHOS
#endif // FRAMEWORKS_JS_NAPI_JS_KEYBOARD_PANEL_MANAGER_H

View File

@ -0,0 +1,44 @@
/*
* 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 "js_keyboard_panel_manager.h"
EXTERN_C_START
/*
* function for module exports
*/
static napi_value Init(napi_env env, napi_value exports)
{
OHOS::MiscServices::JsKeyboardPanelManager::Init(env, exports);
return exports;
}
EXTERN_C_END
/*
* module define
*/
static napi_module _module = { .nm_version = 1,
.nm_flags = 0,
.nm_filename = nullptr,
.nm_register_func = Init,
.nm_modname = "keyboardPanelManager",
.nm_priv = ((void *)0),
.reserved = { 0 } };
/*
* module register
*/
extern "C" __attribute__((constructor)) void Register()
{
napi_module_register(&_module);
}

View File

@ -39,12 +39,16 @@ ohos_shared_library("inputmethod_extension") {
cfi_cross_dso = true
debug = false
}
cflags_cc = [
"-fdata-sections",
"-ffunction-sections",
"-Os",
]
include_dirs = [
"${inputmethod_path}/frameworks/kits/extension/include",
"${inputmethod_path}/frameworks/native/inputmethod_controller/include",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller/include",
"${inputmethod_path}/services/include",
"${inputmethod_path}/services/dfx/include",
"${inputmethod_path}/common/include",
]
sources = [
@ -52,14 +56,13 @@ ohos_shared_library("inputmethod_extension") {
"${inputmethod_path}/frameworks/kits/extension/src/inputmethod_extension_context.cpp",
"${inputmethod_path}/frameworks/kits/extension/src/js_inputmethod_extension.cpp",
"${inputmethod_path}/frameworks/kits/extension/src/js_inputmethod_extension_context.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
]
configs = [ ":ability_config" ]
public_configs = [ ":ability_public_config" ]
deps = [
"${inputmethod_path}/common:inputmethod_common",
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/services/dfx:inputmethod_dfx_static",
]
external_deps = [
@ -75,7 +78,9 @@ ohos_shared_library("inputmethod_extension") {
"eventhandler:libeventhandler",
"hilog:libhilog",
"i18n:intl_util",
"input:libmmi-client",
"ipc:ipc_napi",
"ipc:ipc_single",
"napi:ace_napi",
"samgr:samgr_proxy",
"window_manager:libdm",
@ -92,7 +97,7 @@ ohos_shared_library("inputmethod_extension_module") {
cfi_cross_dso = true
debug = false
}
include_dirs = [ "${inputmethod_path}/services/include" ]
include_dirs = [ "${inputmethod_path}/common/include" ]
sources = [ "${inputmethod_path}/frameworks/kits/extension/src/inputmethod_extension_module_loader.cpp" ]

View File

@ -18,8 +18,6 @@
#include "global.h"
#include "i_input_control_channel.h"
#include "i_input_data_channel.h"
#include "i_system_cmd_channel.h"
#include "input_attribute.h"
#include "input_client_info.h"
#include "input_method_property.h"
@ -54,7 +52,7 @@ public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IInputMethodCore");
virtual int32_t StartInput(const InputClientInfo &clientInfo, bool isBindFromClient) = 0;
virtual int32_t StopInput(const sptr<IInputDataChannel> &channel) = 0;
virtual int32_t StopInput(const sptr<IRemoteObject> &channel) = 0;
virtual int32_t ShowKeyboard() = 0;
virtual int32_t HideKeyboard() = 0;
virtual int32_t InitInputControlChannel(const sptr<IInputControlChannel> &inputControlChannel) = 0;
@ -63,8 +61,8 @@ public:
virtual bool IsEnable() = 0;
virtual int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) = 0;
virtual int32_t OnSecurityChange(int32_t security) = 0 ;
virtual int32_t OnConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent) = 0 ;
virtual void OnClientInactive(const sptr<IInputDataChannel> &channel) = 0;
virtual int32_t OnConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent) = 0 ;
virtual void OnClientInactive(const sptr<IRemoteObject> &channel) = 0;
};
} // namespace MiscServices
} // namespace OHOS

View File

@ -25,14 +25,12 @@
#include "i_input_data_channel.h"
#include "i_input_method_agent.h"
#include "i_input_method_core.h"
#include "i_input_method_system_ability.h"
#include "input_attribute.h"
#include "input_control_channel_proxy.h"
#include "input_data_channel_proxy.h"
#include "input_method_agent_stub.h"
#include "input_method_core_stub.h"
#include "input_method_engine_listener.h"
#include "input_method_panel.h"
#include "input_method_system_ability_proxy.h"
#include "iremote_object.h"
#include "keyboard_listener.h"
#include "keyevent_consumer_proxy.h"
@ -159,9 +157,10 @@ private:
ConcurrentMap<PanelType, std::shared_ptr<InputMethodPanel>> panels_{};
std::atomic_bool isBound_{ false };
sptr<InputMethodCoreStub> coreStub_{ nullptr };
sptr<InputMethodAgentStub> agentStub_{ nullptr };
sptr<InputMethodAgentStub> systemAgentStub_{ nullptr };
sptr<IInputMethodCore> coreStub_{ nullptr };
sptr<IInputMethodAgent> agentStub_{ nullptr };
sptr<IInputMethodAgent> systemAgentStub_{ nullptr };
std::mutex imeCheckMutex_;
bool isCurrentIme_ = false;

View File

@ -24,7 +24,6 @@
#include "iremote_broker.h"
#include "iremote_object.h"
#include "iremote_proxy.h"
#include "keyevent_consumer_proxy.h"
#include "message_parcel.h"
#include "nocopyable.h"
#include "refbase.h"

View File

@ -18,7 +18,6 @@
#include "i_input_method_agent.h"
#include "iremote_stub.h"
#include "keyevent_consumer_proxy.h"
#include "message_handler.h"
#include "message_option.h"
#include "message_parcel.h"

View File

@ -16,8 +16,6 @@
#ifndef FRAMEWORKS_INPUTMETHOD_ABILITY_INCLUDE_INPUT_METHOD_CORE_PROXY_H
#define FRAMEWORKS_INPUTMETHOD_ABILITY_INCLUDE_INPUT_METHOD_CORE_PROXY_H
#include "i_input_control_channel.h"
#include "i_input_data_channel.h"
#include "i_input_method_core.h"
#include "input_attribute.h"
#include "input_method_property.h"
@ -36,7 +34,7 @@ public:
DISALLOW_COPY_AND_MOVE(InputMethodCoreProxy);
int32_t StartInput(const InputClientInfo &clientInfo, bool isBindFromClient) override;
int32_t StopInput(const sptr<IInputDataChannel> &channel) override;
int32_t StopInput(const sptr<IRemoteObject> &channel) override;
int32_t ShowKeyboard() override;
int32_t HideKeyboard() override;
int32_t InitInputControlChannel(const sptr<IInputControlChannel> &inputControlChannel) override;
@ -45,8 +43,8 @@ public:
bool IsEnable() override;
int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) override;
int32_t OnSecurityChange(int32_t security) override;
int32_t OnConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent) override;
void OnClientInactive(const sptr<IInputDataChannel> &channel) override;
int32_t OnConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent) override;
void OnClientInactive(const sptr<IRemoteObject> &channel) override;
private:
static inline BrokerDelegator<InputMethodCoreProxy> delegator_;

View File

@ -20,9 +20,6 @@
#include <cstdint>
#include <mutex>
#include "i_input_control_channel.h"
#include "i_input_data_channel.h"
#include "i_input_method_agent.h"
#include "i_input_method_core.h"
#include "input_attribute.h"
#include "iremote_broker.h"
@ -39,7 +36,7 @@ public:
virtual ~InputMethodCoreStub();
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
int32_t StartInput(const InputClientInfo &clientInfo, bool isBindFromClient) override;
int32_t StopInput(const sptr<IInputDataChannel> &channel) override;
int32_t StopInput(const sptr<IRemoteObject> &channel) override;
int32_t ShowKeyboard() override;
int32_t HideKeyboard() override;
int32_t InitInputControlChannel(const sptr<IInputControlChannel> &inputControlChannel) override;
@ -48,8 +45,8 @@ public:
bool IsEnable() override;
int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) override;
int32_t OnSecurityChange(int32_t security) override;
int32_t OnConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent) override;
void OnClientInactive(const sptr<IInputDataChannel> &channel) override;
int32_t OnConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent) override;
void OnClientInactive(const sptr<IRemoteObject> &channel) override;
void SetMessageHandler(MessageHandler *msgHandler);
private:

View File

@ -25,7 +25,7 @@
#include "js_runtime_utils.h"
#include "panel_info.h"
#include "panel_status_listener.h"
#include "window.h"
#include "foundation/window/window_manager/interfaces/innerkits/wm/window.h"
namespace OHOS {
namespace MiscServices {

View File

@ -20,8 +20,9 @@
#include <utility>
#include "global.h"
#include "input_method_agent_proxy.h"
#include "input_method_core_proxy.h"
#include "input_method_agent_stub.h"
#include "input_method_core_stub.h"
#include "input_method_system_ability_proxy.h"
#include "input_method_utils.h"
#include "inputmethod_sysevent.h"
#include "inputmethod_trace.h"
@ -119,7 +120,7 @@ int32_t InputMethodAbility::SetCoreAndAgent()
IMSA_HILOGE("imsa proxy is nullptr");
return ErrorCode::ERROR_NULL_POINTER;
}
int32_t ret = proxy->SetCoreAndAgent(coreStub_, agentStub_);
int32_t ret = proxy->SetCoreAndAgent(coreStub_, agentStub_->AsObject());
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("set failed, ret: %{public}d", ret);
return ret;
@ -143,13 +144,13 @@ int32_t InputMethodAbility::UnRegisteredProxyIme(UnRegisteredType type)
void InputMethodAbility::Initialize()
{
IMSA_HILOGD("IMA");
coreStub_ = new (std::nothrow) InputMethodCoreStub();
if (coreStub_ == nullptr) {
sptr<InputMethodCoreStub> coreStub = new (std::nothrow) InputMethodCoreStub();
if (coreStub == nullptr) {
IMSA_HILOGE("failed to create core");
return;
}
agentStub_ = new (std::nothrow) InputMethodAgentStub();
if (agentStub_ == nullptr) {
sptr<InputMethodAgentStub> agentStub = new (std::nothrow) InputMethodAgentStub();
if (agentStub == nullptr) {
IMSA_HILOGE("failed to create agent");
return;
}
@ -158,8 +159,10 @@ void InputMethodAbility::Initialize()
IMSA_HILOGE("failed to create message handler");
return;
}
coreStub_->SetMessageHandler(msgHandler_);
agentStub_->SetMessageHandler(msgHandler_);
coreStub->SetMessageHandler(msgHandler_);
agentStub->SetMessageHandler(msgHandler_);
agentStub_ = agentStub;
coreStub_ = coreStub;
workThreadHandler = std::thread([this] { WorkThread(); });
}
@ -233,13 +236,13 @@ void InputMethodAbility::OnInitInputControlChannel(Message *msg)
int32_t InputMethodAbility::StartInput(const InputClientInfo &clientInfo, bool isBindFromClient)
{
if (clientInfo.channel->AsObject() == nullptr) {
if (clientInfo.channel == nullptr) {
IMSA_HILOGE("channelObject is nullptr");
return ErrorCode::ERROR_CLIENT_NULL_POINTER;
}
IMSA_HILOGI(
"IMA isShowKeyboard: %{public}d, isBindFromClient: %{public}d", clientInfo.isShowKeyboard, isBindFromClient);
SetInputDataChannel(clientInfo.channel->AsObject());
SetInputDataChannel(clientInfo.channel);
isBindFromClient ? InvokeTextChangeCallback(clientInfo.config) : NotifyAllTextConfig();
SetInputAttribute(clientInfo.config.inputAttribute);
if (imeListener_ == nullptr) {

View File

@ -18,6 +18,7 @@
#include "global.h"
#include "input_method_ability.h"
#include "ipc_skeleton.h"
#include "itypes_util.h"
#include "message.h"
#include "message_handler.h"

View File

@ -42,7 +42,7 @@ int32_t InputMethodCoreProxy::StartInput(const InputClientInfo &clientInfo, bool
{
IMSA_HILOGI("CoreProxy");
return SendRequest(START_INPUT, [&clientInfo, isBindFromClient](MessageParcel &data) {
return ITypesUtil::Marshal(data, isBindFromClient, clientInfo);
return ITypesUtil::Marshal(data, isBindFromClient, clientInfo, clientInfo.channel);
});
}
@ -53,13 +53,11 @@ int32_t InputMethodCoreProxy::OnSecurityChange(int32_t security)
});
}
int32_t InputMethodCoreProxy::OnConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent)
int32_t InputMethodCoreProxy::OnConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent)
{
return SendRequest(ON_CONNECT_SYSTEM_CMD, [channel](MessageParcel& data) {
return data.WriteRemoteObject(channel->AsObject());
}, [&agent](MessageParcel &reply) {
return ITypesUtil::Unmarshal(reply, agent);
});
return SendRequest(
ON_CONNECT_SYSTEM_CMD, [channel](MessageParcel &data) { return data.WriteRemoteObject(channel); },
[&agent](MessageParcel &reply) { return ITypesUtil::Unmarshal(reply, agent); });
}
void InputMethodCoreProxy::StopInputService(bool isTerminateIme)
@ -83,10 +81,9 @@ int32_t InputMethodCoreProxy::SetSubtype(const SubProperty &property)
return SendRequest(SET_SUBTYPE, [&property](MessageParcel &data) { return ITypesUtil::Marshal(data, property); });
}
int32_t InputMethodCoreProxy::StopInput(const sptr<IInputDataChannel> &channel)
int32_t InputMethodCoreProxy::StopInput(const sptr<IRemoteObject> &channel)
{
return SendRequest(
STOP_INPUT, [&channel](MessageParcel &data) { return ITypesUtil::Marshal(data, channel->AsObject()); });
return SendRequest(STOP_INPUT, [&channel](MessageParcel &data) { return ITypesUtil::Marshal(data, channel); });
}
bool InputMethodCoreProxy::IsEnable()
@ -104,11 +101,11 @@ int32_t InputMethodCoreProxy::IsPanelShown(const PanelInfo &panelInfo, bool &isS
[&isShown](MessageParcel &reply) { return ITypesUtil::Unmarshal(reply, isShown); });
}
void InputMethodCoreProxy::OnClientInactive(const sptr<IInputDataChannel> &channel)
void InputMethodCoreProxy::OnClientInactive(const sptr<IRemoteObject> &channel)
{
SendRequest(
ON_CLIENT_INACTIVE, [&channel](MessageParcel &data) { return ITypesUtil::Marshal(data, channel->AsObject()); },
nullptr, MessageOption::TF_ASYNC);
ON_CLIENT_INACTIVE, [&channel](MessageParcel &data) { return ITypesUtil::Marshal(data, channel); }, nullptr,
MessageOption::TF_ASYNC);
}
int32_t InputMethodCoreProxy::SendRequest(int code, ParcelHandler input, ParcelHandler output, MessageOption option)

View File

@ -23,6 +23,7 @@
#include "system_cmd_channel_proxy.h"
#include "input_method_ability.h"
#include "ipc_skeleton.h"
#include "itypes_util.h"
#include "message_handler.h"
#include "message_parcel.h"
@ -105,7 +106,8 @@ int32_t InputMethodCoreStub::StartInputOnRemote(MessageParcel &data, MessageParc
"CoreStub, callingPid/Uid: %{public}d/%{public}d", IPCSkeleton::GetCallingPid(), IPCSkeleton::GetCallingUid());
bool isBindFromClient = false;
InputClientInfo clientInfo = {};
if (!ITypesUtil::Unmarshal(data, isBindFromClient, clientInfo)) {
sptr<IRemoteObject> channel = nullptr;
if (!ITypesUtil::Unmarshal(data, isBindFromClient, clientInfo, clientInfo.channel)) {
IMSA_HILOGE("Unmarshal failed.");
return ErrorCode::ERROR_EX_PARCELABLE;
}
@ -124,7 +126,7 @@ int32_t InputMethodCoreStub::SecurityChangeOnRemote(MessageParcel &data, Message
return ITypesUtil::Marshal(reply, ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
}
int32_t InputMethodCoreStub::OnConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent)
int32_t InputMethodCoreStub::OnConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent)
{
return ErrorCode::NO_ERROR;
}
@ -230,7 +232,7 @@ int32_t InputMethodCoreStub::OnSecurityChange(int32_t security)
return ErrorCode::NO_ERROR;
}
int32_t InputMethodCoreStub::StopInput(const sptr<IInputDataChannel> &channel)
int32_t InputMethodCoreStub::StopInput(const sptr<IRemoteObject> &channel)
{
return ErrorCode::NO_ERROR;
}
@ -245,7 +247,7 @@ int32_t InputMethodCoreStub::IsPanelShown(const PanelInfo &panelInfo, bool &isSh
return InputMethodAbility::GetInstance()->IsPanelShown(panelInfo, isShown);
}
void InputMethodCoreStub::OnClientInactive(const sptr<IInputDataChannel> &channel)
void InputMethodCoreStub::OnClientInactive(const sptr<IRemoteObject> &channel)
{
}

View File

@ -16,7 +16,7 @@
#ifndef FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_LISTEN_EVENT_MANAGER_H
#define FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_LISTEN_EVENT_MANAGER_H
#include "ime_event_monitor_manager.h"
#include "ime_event_listener.h"
namespace OHOS {
namespace MiscServices {

View File

@ -17,7 +17,6 @@
#define FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_I_INPUT_CLIENT_H
#include "global.h"
#include "i_input_method_agent.h"
#include "input_method_property.h"
#include "input_window_info.h"
#include "iremote_broker.h"
@ -39,7 +38,7 @@ public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.InputClient");
virtual int32_t OnInputReady(const sptr<IInputMethodAgent> &agent) = 0;
virtual int32_t OnInputReady(const sptr<IRemoteObject> &agent) = 0;
virtual int32_t OnInputStop() = 0;
virtual int32_t OnSwitchInput(const Property &property, const SubProperty &subProperty) = 0;
virtual int32_t OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) = 0;

View File

@ -37,7 +37,7 @@ struct InputClientInfo {
uint32_t eventFlag{ NO_EVENT_ON }; // the flag of the all listen event
InputAttribute attribute; // the input client attribute
sptr<IInputClient> client{ nullptr }; // the remote object handler for service to callback input client
sptr<IInputDataChannel> channel{ nullptr }; // the remote object handler for ime to callback input client
sptr<IRemoteObject> channel{ nullptr }; // the remote object handler for ime to callback input client
sptr<InputDeathRecipient> deathRecipient{ nullptr }; // death recipient of client
ClientState state{ ClientState::INACTIVE }; // the state of input client
bool isNotifyInputStart { true };

View File

@ -20,7 +20,6 @@
#include <functional>
#include "i_input_client.h"
#include "i_input_method_agent.h"
#include "iremote_broker.h"
#include "iremote_object.h"
#include "iremote_proxy.h"
@ -35,7 +34,7 @@ public:
~InputClientProxy() = default;
DISALLOW_COPY_AND_MOVE(InputClientProxy);
int32_t OnInputReady(const sptr<IInputMethodAgent> &agent) override;
int32_t OnInputReady(const sptr<IRemoteObject> &agent) override;
int32_t OnInputStop() override;
int32_t OnSwitchInput(const Property &property, const SubProperty &subProperty) override;
int32_t OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) override;

View File

@ -19,7 +19,6 @@
#include <cstdint>
#include "i_input_client.h"
#include "i_input_method_agent.h"
#include "ime_event_monitor_manager.h"
#include "iremote_stub.h"
#include "message_handler.h"
@ -37,7 +36,7 @@ public:
InputClientStub();
~InputClientStub();
int32_t OnInputReady(const sptr<IInputMethodAgent> &agent) override;
int32_t OnInputReady(const sptr<IRemoteObject> &agent) override;
int32_t OnInputStop() override;
int32_t OnSwitchInput(const Property &property, const SubProperty &subProperty) override;
int32_t OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) override;

View File

@ -60,7 +60,7 @@ public:
int32_t ListInputMethod(InputMethodStatus status, std::vector<Property> &props) override;
int32_t SwitchInputMethod(const std::string &name, const std::string &subName, SwitchTrigger trigger) override;
int32_t DisplayOptionalInputMethod() override;
int32_t SetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IInputMethodAgent> &agent) override;
int32_t SetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent) override;
int32_t UnRegisteredProxyIme(UnRegisteredType type, const sptr<IInputMethodCore> &core) override;
int32_t ListCurrentInputMethodSubtype(std::vector<SubProperty> &subProps) override;
int32_t ListInputMethodSubtype(const std::string &name, std::vector<SubProperty> &subProps) override;
@ -73,7 +73,7 @@ public:
int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) override;
int32_t GetSecurityMode(int32_t &security) override;
int32_t IsDefaultIme() override;
int32_t ConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent) override;
int32_t ConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent) override;
// Deprecated because of no permission check, kept for compatibility
int32_t HideCurrentInputDeprecated() override;
int32_t ShowCurrentInputDeprecated() override;

View File

@ -25,6 +25,7 @@
namespace OHOS {
namespace MiscServices {
constexpr const char *SMART_MENU_METADATA_NAME = "ohos.extension.smart_menu";
std::mutex ImeSystemCmdChannel::instanceLock_;
sptr<ImeSystemCmdChannel> ImeSystemCmdChannel::instance_;
ImeSystemCmdChannel::ImeSystemCmdChannel()
@ -34,6 +35,7 @@ ImeSystemCmdChannel::ImeSystemCmdChannel()
ImeSystemCmdChannel::~ImeSystemCmdChannel()
{
}
sptr<ImeSystemCmdChannel> ImeSystemCmdChannel::GetInstance()
{
if (instance_ == nullptr) {
@ -154,7 +156,7 @@ sptr<IInputMethodAgent> ImeSystemCmdChannel::GetSystemCmdAgent()
void ImeSystemCmdChannel::SetSystemCmdListener(const sptr<OnSystemCmdListener> &listener)
{
std::lock_guard<std::mutex> lock(systemCmdListenerLock_);
systemCmdListener_ = listener;
systemCmdListener_ = std::move(listener);
}
sptr<OnSystemCmdListener> ImeSystemCmdChannel::GetSystemCmdListener()
@ -180,11 +182,7 @@ int32_t ImeSystemCmdChannel::ReceivePrivateCommand(
IMSA_HILOGE("cmdlistener is nullptr");
return ErrorCode::ERROR_EX_NULL_POINTER;
}
auto ret = cmdlistener->ReceivePrivateCommand(privateCommand);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("ReceivePrivateCommand err, ret %{public}d", ret);
return ErrorCode::ERROR_CMD_LISTENER_ERROR;
}
cmdlistener->ReceivePrivateCommand(privateCommand);
return ErrorCode::NO_ERROR;
}
@ -224,5 +222,47 @@ int32_t ImeSystemCmdChannel::ShowSysPanel(bool shouldSysPanelShow)
listener->NotifyIsShowSysPanel(shouldSysPanelShow);
return ErrorCode::NO_ERROR;
}
std::string ImeSystemCmdChannel::GetSmartMenuCfg()
{
auto inputMethodController = InputMethodController::GetInstance();
if (inputMethodController == nullptr) {
return "";
}
std::shared_ptr<Property> defaultIme = nullptr;
int32_t ret = inputMethodController->GetDefaultInputMethod(defaultIme);
if (ret != ErrorCode::NO_ERROR || defaultIme == nullptr) {
IMSA_HILOGE("GetDefaultInputMethod failed");
return "";
}
BundleMgrClient client;
BundleInfo bundleInfo;
if (!client.GetBundleInfo(defaultIme->name, BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO, bundleInfo)) {
IMSA_HILOGE("GetBundleInfo failed");
return "";
}
ExtensionAbilityInfo extInfo;
GetExtensionInfo(bundleInfo.extensionInfos, extInfo);
std::vector<std::string> profiles;
if (!client.GetResConfigFile(extInfo, SMART_MENU_METADATA_NAME, profiles) || profiles.empty()) {
IMSA_HILOGE("GetResConfigFile failed");
return "";
}
return profiles[0];
}
void ImeSystemCmdChannel::GetExtensionInfo(std::vector<ExtensionAbilityInfo> extensionInfos,
ExtensionAbilityInfo &extInfo)
{
for (size_t i = 0; i < extensionInfos.size(); i++) {
auto metadata = extensionInfos[i].metadata;
for (size_t j = 0; j < metadata.size(); j++) {
if (metadata[j].name == SMART_MENU_METADATA_NAME) {
extInfo = extensionInfos[i];
return;
}
}
}
}
} // namespace MiscServices
} // namespace OHOS

View File

@ -27,10 +27,9 @@ InputClientProxy::InputClientProxy(const sptr<IRemoteObject> &object) : IRemoteP
{
}
int32_t InputClientProxy::OnInputReady(const sptr<IInputMethodAgent> &agent)
int32_t InputClientProxy::OnInputReady(const sptr<IRemoteObject> &agent)
{
return SendRequest(
ON_INPUT_READY, [agent](MessageParcel &data) { return ITypesUtil::Marshal(data, agent->AsObject()); });
return SendRequest(ON_INPUT_READY, [agent](MessageParcel &data) { return ITypesUtil::Marshal(data, agent); });
}
int32_t InputClientProxy::OnInputStop()

View File

@ -110,7 +110,7 @@ int32_t InputClientStub::DeactivateClientOnRemote(MessageParcel &data, MessagePa
return reply.WriteInt32(ErrorCode::NO_ERROR) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
}
int32_t InputClientStub::OnInputReady(const sptr<IInputMethodAgent> &agent)
int32_t InputClientStub::OnInputReady(const sptr<IRemoteObject> &agent)
{
return ErrorCode::NO_ERROR;
}

View File

@ -115,19 +115,18 @@ void InputMethodController::SetControllerListener(std::shared_ptr<ControllerList
int32_t InputMethodController::Initialize()
{
auto client = new (std::nothrow) InputClientStub();
sptr<IInputClient> client = new (std::nothrow) InputClientStub();
if (client == nullptr) {
IMSA_HILOGE("failed to new client");
return ErrorCode::ERROR_NULL_POINTER;
}
auto channel = new (std::nothrow) InputDataChannelStub();
sptr<IInputDataChannel> channel = new (std::nothrow) InputDataChannelStub();
if (channel == nullptr) {
delete client;
IMSA_HILOGE("failed to new channel");
return ErrorCode::ERROR_NULL_POINTER;
}
InputAttribute attribute = { .inputPattern = InputAttribute::PATTERN_TEXT };
clientInfo_ = { .attribute = attribute, .client = client, .channel = channel };
clientInfo_ = { .attribute = attribute, .client = client, .channel = channel->AsObject() };
// make AppExecFwk::EventHandler handler
handler_ = std::make_shared<AppExecFwk::EventHandler>(AppExecFwk::EventRunner::GetMainEventRunner());

View File

@ -34,22 +34,22 @@ int32_t InputMethodSystemAbilityProxy::StartInput(InputClientInfo &inputClientIn
{
return SendRequest(
static_cast<uint32_t>(InputMethodInterfaceCode::START_INPUT),
[&inputClientInfo](MessageParcel &data) { return ITypesUtil::Marshal(data, inputClientInfo); },
[&inputClientInfo](MessageParcel &data) {
return ITypesUtil::Marshal(
data, inputClientInfo, inputClientInfo.client->AsObject(), inputClientInfo.channel);
},
[&agent](MessageParcel &reply) {
agent = reply.ReadRemoteObject();
return true;
});
}
int32_t InputMethodSystemAbilityProxy::ConnectSystemCmd(
const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent)
int32_t InputMethodSystemAbilityProxy::ConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent)
{
return SendRequest(
static_cast<uint32_t>(InputMethodInterfaceCode::CONNECT_SYSTEM_CMD),
[channel](MessageParcel &data) { return data.WriteRemoteObject(channel->AsObject()); },
[&agent](MessageParcel &reply) {
return ITypesUtil::Unmarshal(reply, agent);
});
[channel](MessageParcel &data) { return data.WriteRemoteObject(channel); },
[&agent](MessageParcel &reply) { return ITypesUtil::Unmarshal(reply, agent); });
}
int32_t InputMethodSystemAbilityProxy::ShowCurrentInput()
@ -101,11 +101,11 @@ int32_t InputMethodSystemAbilityProxy::DisplayOptionalInputMethod()
}
int32_t InputMethodSystemAbilityProxy::SetCoreAndAgent(
const sptr<IInputMethodCore> &core, const sptr<IInputMethodAgent> &agent)
const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent)
{
return SendRequest(
static_cast<uint32_t>(InputMethodInterfaceCode::SET_CORE_AND_AGENT), [core, agent](MessageParcel &data) {
return data.WriteRemoteObject(core->AsObject()) && data.WriteRemoteObject(agent->AsObject());
return data.WriteRemoteObject(core->AsObject()) && data.WriteRemoteObject(agent);
});
}
@ -215,7 +215,9 @@ int32_t InputMethodSystemAbilityProxy::PanelStatusChange(const InputWindowStatus
int32_t InputMethodSystemAbilityProxy::UpdateListenEventFlag(InputClientInfo &clientInfo, uint32_t eventFlag)
{
return SendRequest(static_cast<uint32_t>(InputMethodInterfaceCode::UPDATE_LISTEN_EVENT_FLAG),
[&clientInfo, eventFlag](MessageParcel &data) { return ITypesUtil::Marshal(data, clientInfo, eventFlag); });
[&clientInfo, eventFlag](MessageParcel &data) {
return ITypesUtil::Marshal(data, clientInfo, clientInfo.client->AsObject(), clientInfo.channel, eventFlag);
});
}
bool InputMethodSystemAbilityProxy::IsCurrentIme()

View File

@ -22,7 +22,6 @@ config("inputmethod_ability_native_config") {
"${inputmethod_path}/frameworks/native/inputmethod_controller/include",
"${inputmethod_path}/frameworks/common",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller/include",
"${inputmethod_path}/services/dfx/include",
"${inputmethod_path}/services/include",
]
}
@ -32,11 +31,8 @@ config("inputmethod_ability_native_public_config") {
"include",
"${inputmethod_path}/frameworks/native/inputmethod_ability/include",
"${inputmethod_path}/frameworks/common",
"${inputmethod_path}/services/dfx/include",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller/include",
"${inputmethod_path}/services/include",
"${windowmanager_path}/interfaces/innerkits/dm",
"${windowmanager_path}/interfaces/innerkits/wm",
"${multimodalinput_path}/interfaces/native/innerkits/event/include",
]
}
@ -51,24 +47,20 @@ ohos_shared_library("inputmethod_ability") {
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_ability.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_ability_interface.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_ability_utils.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_agent_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_agent_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_panel.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_data_channel_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_death_recipient.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_system_ability_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/itypes_util.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/system_cmd_channel_proxy.cpp",
"${inputmethod_path}/services/src/global.cpp",
"${inputmethod_path}/services/src/input_control_channel_proxy.cpp",
"${inputmethod_path}/services/src/message.cpp",
"${inputmethod_path}/services/src/message_handler.cpp",
]
cflags_cc = [
"-fdata-sections",
"-ffunction-sections",
"-Os",
]
version_script = "inputmethod_ability.versionscript"
configs = [ ":inputmethod_ability_native_config" ]
@ -88,7 +80,7 @@ ohos_shared_library("inputmethod_ability") {
"window_manager:libwm",
]
deps = [ "${inputmethod_path}/services/dfx:inputmethod_dfx_static" ]
deps = [ "${inputmethod_path}/common:inputmethod_common" ]
public_configs = [ ":inputmethod_ability_native_public_config" ]
@ -96,3 +88,47 @@ ohos_shared_library("inputmethod_ability") {
innerapi_tags = [ "platformsdk" ]
part_name = "imf"
}
ohos_static_library("inputmethod_ability_static") {
branch_protector_ret = "pac_ret"
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
sources = [
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_ability.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_ability_interface.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_ability_utils.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_agent_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_panel.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_data_channel_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_system_ability_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/system_cmd_channel_proxy.cpp",
"${inputmethod_path}/services/src/input_control_channel_proxy.cpp",
]
external_deps = [
"ability_base:configuration",
"ability_base:want",
"ability_runtime:ability_context_native",
"c_utils:utils",
"graphic_2d:window_animation",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_single",
"napi:ace_napi",
"samgr:samgr_proxy",
"window_manager:libdm",
"window_manager:libwm",
]
deps = [ "${inputmethod_path}/common:inputmethod_common" ]
public_configs = [ ":inputmethod_ability_native_public_config" ]
subsystem_name = "inputmethod"
part_name = "imf"
}

View File

@ -16,14 +16,8 @@
*InputDataChannelProxy*;
*InputMethodAbility*;
*InputMethodAbilityInterface*;
*InputMethodAgentProxy*;
*InputMethodAgentStub*;
*InputMethodCoreProxy*;
*InputMethodCoreStub*;
*InputMethodPanel*;
*InputMethodSystemAbilityProxy*;
*ITypesUtil*;
*MessageHandler*;
*KeyEventConsumerProxy*;
*SystemCmdChannelProxy*;
local:
*;

View File

@ -18,10 +18,10 @@ config("inputmethod_client_native_config") {
visibility = [ ":*" ]
include_dirs = [
"include",
"${inputmethod_path}/common/include",
"${inputmethod_path}/frameworks/common",
"${inputmethod_path}/frameworks/native/inputmethod_controller/include",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller/include",
"${inputmethod_path}/services/dfx/include",
"${inputmethod_path}/services/include",
]
}
@ -30,14 +30,13 @@ config("inputmethod_client_native_public_config") {
visibility = [ "./*" ]
include_dirs = [
"include",
"${inputmethod_path}/common",
"${inputmethod_path}/common/include",
"${inputmethod_path}/frameworks/common",
"${inputmethod_path}/frameworks/native/inputmethod_controller/include",
"${inputmethod_path}/frameworks/native/inputmethod_ability/include",
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability/include",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller/include",
"${inputmethod_path}/services/include",
"${inputmethod_path}/services/dfx/include",
]
}
@ -53,27 +52,20 @@ ohos_shared_library("inputmethod_client") {
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/ime_event_monitor_manager.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/ime_event_monitor_manager_impl.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/ime_system_channel.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_client_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_data_channel_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_data_channel_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_death_recipient.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_controller.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_system_ability_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_utils.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/itypes_util.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/system_cmd_channel_stub.cpp",
"${inputmethod_path}/services/src/global.cpp",
"${inputmethod_path}/services/src/message.cpp",
"${inputmethod_path}/services/src/message_handler.cpp",
]
cflags = [
cflags_cc = [
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
"-fdata-sections",
"-ffunction-sections",
"-fvisibility=hidden",
"-Os",
]
@ -81,12 +73,12 @@ ohos_shared_library("inputmethod_client") {
innerapi_tags = [ "platformsdk" ]
deps = [ "${inputmethod_path}/services/dfx:inputmethod_dfx_static" ]
public_deps = [ "${inputmethod_path}/services/dfx:inputmethod_dfx_static" ]
deps = [ "${inputmethod_path}/common:inputmethod_common" ]
external_deps = [
"ability_base:want",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -116,28 +108,23 @@ ohos_static_library("inputmethod_client_static") {
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/ime_event_monitor_manager.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/ime_event_monitor_manager_impl.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/ime_system_channel.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_client_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_data_channel_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_data_channel_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_death_recipient.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_controller.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_system_ability_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_utils.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/itypes_util.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/system_cmd_channel_stub.cpp",
"${inputmethod_path}/services/src/message.cpp",
"${inputmethod_path}/services/src/message_handler.cpp",
]
public_configs = [ ":inputmethod_client_native_public_config" ]
public_deps = [ "${inputmethod_path}/services/dfx:inputmethod_dfx_static" ]
deps = [ "${inputmethod_path}/common:inputmethod_common" ]
external_deps = [
"ability_base:want",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"eventhandler:libeventhandler",
"hilog:libhilog",

View File

@ -13,10 +13,10 @@
* limitations under the License.
*/
#ifndef FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_IME_SYSTEM_CHANNEL_H
#define FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_IME_SYSTEM_CHANNEL_H
#ifndef INPUTMETHOD_CONTROLLER_IME_SYSTEM_CHANNEL_H
#define INPUTMETHOD_CONTROLLER_IME_SYSTEM_CHANNEL_H
#include "global.h"
#include "bundle_mgr_client.h"
#include "i_input_method_agent.h"
#include "i_input_method_system_ability.h"
#include "input_method_utils.h"
@ -28,11 +28,11 @@
namespace OHOS {
namespace MiscServices {
using namespace OHOS::AppExecFwk;
class OnSystemCmdListener : public virtual RefBase {
public:
virtual int32_t ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
virtual void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand)
{
return ErrorCode::NO_ERROR;
}
virtual void NotifyIsShowSysPanel(bool shouldSysPanelShow)
{
@ -74,25 +74,31 @@ public:
IMF_API int32_t SendPrivateCommand(
const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
/**
* @brief Get smart menu config from default input method.
*
* This function is used to get smart menu config from default input method.
*
* @return string.
* @since 12
*/
IMF_API std::string GetSmartMenuCfg();
int32_t ReceivePrivateCommand(
const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
int32_t ShowSysPanel(bool shouldSysPanelShow);
void OnConnectCmdReady(const sptr<IRemoteObject> &agentObject);
int32_t RunConnectSystemCmd();
private:
ImeSystemCmdChannel();
~ImeSystemCmdChannel();
int32_t RunConnectSystemCmd();
sptr<IInputMethodSystemAbility> GetSystemAbilityProxy();
void OnRemoteSaDied(const wptr<IRemoteObject> &object);
void SetSystemCmdListener(const sptr<OnSystemCmdListener> &listener);
sptr<IInputMethodAgent> GetSystemCmdAgent();
sptr<OnSystemCmdListener> GetSystemCmdListener();
void ClearSystemCmdAgent();
void GetExtensionInfo(std::vector<ExtensionAbilityInfo> extensionInfos, ExtensionAbilityInfo &extInfo);
static std::mutex instanceLock_;
static sptr<ImeSystemCmdChannel> instance_;
@ -110,4 +116,4 @@ private:
};
} // namespace MiscServices
} // namespace OHOS
#endif // FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_IME_SYSTEM_CHANNEL_H
#endif // INPUTMETHOD_CONTROLLER_IME_SYSTEM_CHANNEL_H

View File

@ -309,7 +309,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 6
*/
IMF_API int32_t GetEnterKeyType(int32_t &keyType);
int32_t GetEnterKeyType(int32_t &keyType);
/**
* @brief Get input pattern.
@ -320,7 +320,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 6
*/
IMF_API int32_t GetInputPattern(int32_t &inputPattern);
int32_t GetInputPattern(int32_t &inputPattern);
/**
* @brief Get text config.
@ -331,7 +331,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API int32_t GetTextConfig(TextTotalConfig &config);
int32_t GetTextConfig(TextTotalConfig &config);
/**
* @brief Get current input method property.
@ -508,7 +508,7 @@ public:
*
* @since 10
*/
IMF_API void OnInputReady(sptr<IRemoteObject> agentObject);
void OnInputReady(sptr<IRemoteObject> agentObject);
/**
* @brief Unbind IMC with Service.
@ -517,7 +517,7 @@ public:
*
* @since 10
*/
IMF_API void OnInputStop();
void OnInputStop();
/**
* @brief Insert text.
@ -528,7 +528,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API int32_t InsertText(const std::u16string &text);
int32_t InsertText(const std::u16string &text);
/**
* @brief Move cursor.
@ -539,7 +539,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API int32_t MoveCursor(Direction direction);
int32_t MoveCursor(Direction direction);
/**
* @brief Delete forward.
@ -550,7 +550,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API int32_t DeleteForward(int32_t length);
int32_t DeleteForward(int32_t length);
/**
* @brief Delete backward.
@ -561,7 +561,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API int32_t DeleteBackward(int32_t length);
int32_t DeleteBackward(int32_t length);
/**
* @brief Get text at the left of cursor.
@ -573,7 +573,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API int32_t GetLeft(int32_t length, std::u16string &text);
int32_t GetLeft(int32_t length, std::u16string &text);
/**
* @brief Get text at the right of cursor.
@ -585,7 +585,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API int32_t GetRight(int32_t length, std::u16string &text);
int32_t GetRight(int32_t length, std::u16string &text);
/**
* @brief Select text in editor by range.
@ -597,7 +597,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API void SelectByRange(int32_t start, int32_t end);
void SelectByRange(int32_t start, int32_t end);
/**
* @brief Select text in editor by cursor movement.
@ -609,7 +609,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API void SelectByMovement(int32_t direction, int32_t cursorMoveSkip);
void SelectByMovement(int32_t direction, int32_t cursorMoveSkip);
/**
* @brief Handle extend action code.
@ -620,7 +620,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API int32_t HandleExtendAction(int32_t action);
int32_t HandleExtendAction(int32_t action);
/**
* @brief Get the index number of text at cursor.
@ -631,7 +631,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API int32_t GetTextIndexAtCursor(int32_t &index);
int32_t GetTextIndexAtCursor(int32_t &index);
/**
* @brief Send keyboard status.
@ -641,7 +641,7 @@ public:
* @param status Indicates the status of keyboard.
* @since 10
*/
IMF_API void SendKeyboardStatus(KeyboardStatus status);
void SendKeyboardStatus(KeyboardStatus status);
/**
* @brief Send panel status info.
@ -652,7 +652,7 @@ public:
* @param info Indicates the status info of panel.
* @since 11
*/
IMF_API void NotifyPanelStatusInfo(const PanelStatusInfo &info);
void NotifyPanelStatusInfo(const PanelStatusInfo &info);
/**
* @brief Send panel height.
@ -662,7 +662,7 @@ public:
* @param info Indicates the panel height.
* @since 11
*/
IMF_API void NotifyKeyboardHeight(uint32_t height);
void NotifyKeyboardHeight(uint32_t height);
/**
* @brief Send function key.
@ -673,7 +673,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 10
*/
IMF_API int32_t SendFunctionKey(int32_t functionKey);
int32_t SendFunctionKey(int32_t functionKey);
/**
* @brief Deactivate the input client.
@ -682,7 +682,7 @@ public:
*
* @since 11
*/
IMF_API void DeactivateClient();
void DeactivateClient();
/**
* @brief Query whether an input type is supported.
@ -740,7 +740,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 12
*/
IMF_API int32_t ReceivePrivateCommand(
int32_t ReceivePrivateCommand(
const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override;
/**
@ -753,7 +753,7 @@ public:
* @return Returns 0 for success, others for failure.
* @since 12
*/
IMF_API int32_t SetPreviewText(const std::string &text, const Range &range);
int32_t SetPreviewText(const std::string &text, const Range &range);
/**
* @brief Finish text preview.
@ -762,7 +762,7 @@ public:
*
* @since 12
*/
IMF_API int32_t FinishTextPreview();
int32_t FinishTextPreview();
private:
InputMethodController();

View File

@ -18,7 +18,7 @@ config("inputmethod_services_native_config") {
visibility = [ ":*" ]
include_dirs = [
"include",
"${inputmethod_path}/common",
"${inputmethod_path}/common/include",
"${inputmethod_path}/frameworks/common",
"${inputmethod_path}/frameworks/native/inputmethod_ability/include",
"${inputmethod_path}/frameworks/native/inputmethod_controller/include",
@ -29,10 +29,7 @@ config("inputmethod_services_native_config") {
"${inputmethod_path}/services/adapter/system_language_observer/include",
"${inputmethod_path}/services/adapter/wms_connection_monitor/include",
"${inputmethod_path}/services/identity_checker/include",
"${inputmethod_path}/services/dfx/include",
]
cflags_cc = [ "-fexceptions" ]
}
ohos_shared_library("inputmethod_service") {
@ -42,10 +39,17 @@ ohos_shared_library("inputmethod_service") {
cfi_cross_dso = true
debug = false
}
cflags_cc = [
"-fexceptions",
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
"-fdata-sections",
"-ffunction-sections",
"-Os",
]
sources = [
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_death_recipient.cpp",
"${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/system_language_observer/src/system_language_observer.cpp",
@ -53,17 +57,13 @@ ohos_shared_library("inputmethod_service") {
"${inputmethod_path}/services/adapter/wms_connection_monitor/src/wms_connection_observer.cpp",
"${inputmethod_path}/services/identity_checker/src/identity_checker_impl.cpp",
"src/freeze_manager.cpp",
"src/global.cpp",
"src/im_common_event_manager.cpp",
"src/ime_cfg_manager.cpp",
"src/ime_info_inquirer.cpp",
"src/input_control_channel_proxy.cpp",
"src/input_control_channel_stub.cpp",
"src/input_method_system_ability.cpp",
"src/input_method_system_ability_stub.cpp",
"src/input_type_manager.cpp",
"src/message.cpp",
"src/message_handler.cpp",
"src/peruser_session.cpp",
"src/sys_cfg_parser.cpp",
]
@ -73,10 +73,9 @@ ohos_shared_library("inputmethod_service") {
public_configs = [ ":inputmethod_services_native_config" ]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/common:inputmethod_common",
"${inputmethod_path}/services/adapter/keyboard:keboard_event_static",
"${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static",
"${inputmethod_path}/services/dfx:inputmethod_dfx_static",
"${inputmethod_path}/services/file:imf_file_static",
"${inputmethod_path}/services/json:imf_json_static",
"//third_party/cJSON:cjson",
@ -90,7 +89,79 @@ ohos_shared_library("inputmethod_service") {
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_core",
"common_event_service:cesfwk_innerkits",
"config_policy:configpolicy_util",
"data_share:datashare_common",
"data_share:datashare_consumer",
"eventhandler:libeventhandler",
"hilog:libhilog",
"init:libbeget_proxy",
"init:libbegetutil",
"input:libmmi-client",
"ipc:ipc_single",
"os_account:os_account_innerkits",
"resource_schedule_service:ressched_client",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"window_manager:libwm",
"window_manager:libwsutils",
]
subsystem_name = "inputmethod"
part_name = "imf"
}
ohos_static_library("inputmethod_service_static") {
branch_protector_ret = "pac_ret"
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
cflags_cc = [
"-fdata-sections",
"-ffunction-sections",
"-Os",
]
sources = [
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp",
"adapter/focus_monitor/src/focus_change_listener.cpp",
"adapter/focus_monitor/src/focus_monitor_manager.cpp",
"adapter/system_language_observer/src/system_language_observer.cpp",
"adapter/wms_connection_monitor/src/wms_connection_monitor_manager.cpp",
"adapter/wms_connection_monitor/src/wms_connection_observer.cpp",
"identity_checker/src/identity_checker_impl.cpp",
"src/freeze_manager.cpp",
"src/im_common_event_manager.cpp",
"src/ime_cfg_manager.cpp",
"src/ime_info_inquirer.cpp",
"src/input_control_channel_stub.cpp",
"src/input_method_system_ability.cpp",
"src/input_method_system_ability_stub.cpp",
"src/input_type_manager.cpp",
"src/peruser_session.cpp",
"src/sys_cfg_parser.cpp",
]
public_configs = [ ":inputmethod_services_native_config" ]
public_deps = [
"${inputmethod_path}/common:inputmethod_common",
"adapter/keyboard:keboard_event_static",
"adapter/settings_data_provider:settings_data_static",
"file:imf_file_static",
"json:imf_json_static",
]
external_deps = [
"ability_base:want",
"ability_runtime:ability_manager",
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"config_policy:configpolicy_util",
"data_share:datashare_common",

View File

@ -18,7 +18,7 @@ config("inputmethod_adapter_native_config") {
visibility = [ ":*" ]
include_dirs = [
"include",
"${inputmethod_path}/services/include",
"${inputmethod_path}/common/include",
]
}

View File

@ -17,6 +17,7 @@ import("//build/ohos.gni")
config("settings_data_config") {
include_dirs = [
"include",
"${inputmethod_path}/common/include",
"${inputmethod_path}/services/include",
"${inputmethod_path}/services/adapter/settings_data_provider/common/include",
"${inputmethod_path}/services/json/include",

View File

@ -17,7 +17,7 @@ import("//build/ohos.gni")
config("imf_file_config") {
include_dirs = [
"include",
"${inputmethod_path}/services/include",
"${inputmethod_path}/common/include",
]
}

View File

@ -17,7 +17,6 @@
#define SERVICES_INCLUDE_I_INPUT_CONTROL_CHANNEL_H
#include "global.h"
#include "i_input_method_agent.h"
#include "iremote_broker.h"
namespace OHOS {

View File

@ -25,7 +25,6 @@
#include "event_status_manager.h"
#include "global.h"
#include "i_input_client.h"
#include "i_input_data_channel.h"
#include "i_input_method_core.h"
#include "i_system_cmd_channel.h"
#include "input_attribute.h"
@ -59,7 +58,7 @@ public:
virtual std::shared_ptr<SubProperty> GetCurrentInputMethodSubtype() = 0;
virtual int32_t ListInputMethod(InputMethodStatus status, std::vector<Property> &props) = 0;
virtual int32_t DisplayOptionalInputMethod() = 0;
virtual int32_t SetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IInputMethodAgent> &agent) = 0;
virtual int32_t SetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent) = 0;
virtual int32_t UnRegisteredProxyIme(UnRegisteredType type, const sptr<IInputMethodCore> &core) = 0;
virtual int32_t ListCurrentInputMethodSubtype(std::vector<SubProperty> &subProps) = 0;
virtual int32_t ListInputMethodSubtype(const std::string &name, std::vector<SubProperty> &subProps) = 0;
@ -74,7 +73,7 @@ public:
virtual int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) = 0;
virtual int32_t GetSecurityMode(int32_t &security) = 0;
virtual int32_t IsDefaultIme() = 0;
virtual int32_t ConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent) = 0;
virtual int32_t ConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent) = 0;
// Deprecated because of no permission check, and keep for compatibility
virtual int32_t HideCurrentInputDeprecated() = 0;

View File

@ -20,7 +20,6 @@
#include <mutex>
#include "i_input_control_channel.h"
#include "i_input_method_agent.h"
#include "iremote_broker.h"
#include "iremote_stub.h"
#include "message_parcel.h"

View File

@ -40,9 +40,6 @@
namespace OHOS {
namespace MiscServices {
using AbilityType = AppExecFwk::ExtensionAbilityType;
using namespace AppExecFwk;
using namespace Security::AccessToken;
enum class ServiceRunningState { STATE_NOT_START, STATE_RUNNING };
class InputMethodSystemAbility : public SystemAbility, public InputMethodSystemAbilityStub {
DECLARE_SYSTEM_ABILITY(InputMethodSystemAbility);
@ -72,7 +69,7 @@ public:
int32_t SwitchInputMethod(
const std::string &bundleName, const std::string &subName, SwitchTrigger trigger) override;
int32_t DisplayOptionalInputMethod() override;
int32_t SetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IInputMethodAgent> &agent) override;
int32_t SetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent) override;
int32_t UnRegisteredProxyIme(UnRegisteredType type, const sptr<IInputMethodCore> &core) override;
int32_t PanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) override;
int32_t UpdateListenEventFlag(InputClientInfo &clientInfo, uint32_t eventFlag) override;
@ -82,7 +79,7 @@ public:
int32_t ExitCurrentInputType() override;
int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) override;
int32_t GetSecurityMode(int32_t &security) override;
int32_t ConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent) override;
int32_t ConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent) override;
// Deprecated because of no permission check, kept for compatibility
int32_t HideCurrentInputDeprecated() override;
int32_t ShowCurrentInputDeprecated() override;

View File

@ -37,7 +37,6 @@
#include "ime_cfg_manager.h"
#include "input_attribute.h"
#include "input_client_info.h"
#include "input_control_channel_stub.h"
#include "input_death_recipient.h"
#include "input_method_info.h"
#include "input_method_property.h"
@ -53,10 +52,10 @@ namespace OHOS {
namespace MiscServices {
struct ImeData {
sptr<IInputMethodCore> core{ nullptr };
sptr<IInputMethodAgent> agent{ nullptr };
sptr<IRemoteObject> agent{ nullptr };
sptr<InputDeathRecipient> deathRecipient{ nullptr };
std::shared_ptr<FreezeManager> freezeMgr;
ImeData(sptr<IInputMethodCore> core, sptr<IInputMethodAgent> agent, sptr<InputDeathRecipient> deathRecipient,
ImeData(sptr<IInputMethodCore> core, sptr<IRemoteObject> agent, sptr<InputDeathRecipient> deathRecipient,
pid_t imePid)
: core(std::move(core)), agent(std::move(agent)), deathRecipient(std::move(deathRecipient)),
freezeMgr(std::make_shared<FreezeManager>(imePid))
@ -77,7 +76,7 @@ public:
int32_t OnPrepareInput(const InputClientInfo &clientInfo);
int32_t OnStartInput(const InputClientInfo &inputClientInfo, sptr<IRemoteObject> &agent);
int32_t OnReleaseInput(const sptr<IInputClient> &client);
int32_t OnSetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IInputMethodAgent> &agent);
int32_t OnSetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent);
int32_t OnHideCurrentInput();
int32_t OnShowCurrentInput();
int32_t OnShowInput(sptr<IInputClient> client);
@ -94,7 +93,7 @@ public:
int64_t GetCurrentClientPid();
int32_t OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info);
int32_t OnUpdateListenEventFlag(const InputClientInfo &clientInfo);
int32_t OnRegisterProxyIme(const sptr<IInputMethodCore> &core, const sptr<IInputMethodAgent> &agent);
int32_t OnRegisterProxyIme(const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent);
int32_t OnUnRegisteredProxyIme(UnRegisteredType type, const sptr<IInputMethodCore> &core);
bool StartCurrentIme(int32_t userId, bool isRetry);
void StopCurrentIme();
@ -105,7 +104,7 @@ public:
int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown);
bool CheckSecurityMode();
bool IsWmsReady();
int32_t OnConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent);
int32_t OnConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent);
private:
struct ResetManager {
@ -146,7 +145,7 @@ private:
const std::unordered_map<UpdateFlag, std::variant<bool, uint32_t, ImeType, ClientState, TextTotalConfig>>
&updateInfos);
int32_t AddImeData(ImeType type, sptr<IInputMethodCore> core, sptr<IInputMethodAgent> agent, pid_t pid);
int32_t AddImeData(ImeType type, sptr<IInputMethodCore> core, sptr<IRemoteObject> agent, pid_t pid);
void RemoveImeData(ImeType type, bool isImeDied);
int32_t RemoveIme(const sptr<IInputMethodCore> &core, ImeType type);
std::shared_ptr<ImeData> GetImeData(ImeType type);
@ -157,7 +156,7 @@ private:
void UnBindClientWithIme(
const std::shared_ptr<InputClientInfo> &currentClientInfo, bool isUnbindFromClient = false);
void StopClientInput(const sptr<IInputClient> &currentClient);
void StopImeInput(ImeType currentType, const sptr<IInputDataChannel> &currentChannel);
void StopImeInput(ImeType currentType, const sptr<IRemoteObject> &currentChannel);
int32_t HideKeyboard(const sptr<IInputClient> &currentClient);
int32_t ShowKeyboard(const sptr<IInputClient> &currentClient);
@ -176,8 +175,6 @@ private:
bool IsImeStartInBind(ImeType bindImeType, ImeType startImeType);
bool IsProxyImeStartInBind(ImeType bindImeType, ImeType startImeType);
bool IsProxyImeStartInImeBind(ImeType bindImeType, ImeType startImeType);
bool IsBindProxyImeInImeBind(ImeType bindImeType);
bool IsBindImeInProxyImeBind(ImeType bindImeType);
bool IsImeBindChanged(ImeType bindImeType);
std::map<sptr<IRemoteObject>, std::shared_ptr<InputClientInfo>> GetClientMap();
int32_t RequestIme(const std::shared_ptr<ImeData> &data, RequestType type, const IpcExec &exec);
@ -188,8 +185,6 @@ private:
BlockData<bool> isImeStarted_{ MAX_IME_START_TIME, false };
std::mutex imeDataLock_;
std::unordered_map<ImeType, std::shared_ptr<ImeData>> imeData_;
std::mutex attachLock_;
std::condition_variable imeAttachCv_;
std::mutex inactiveClientLock_;
sptr<IInputClient> inactiveClient_; // the inactive input client
std::mutex focusedClientLock_;

View File

@ -17,7 +17,7 @@ import("//build/ohos.gni")
config("imf_json_config") {
include_dirs = [
"include",
"${inputmethod_path}/services/include",
"${inputmethod_path}/common/include",
]
}
@ -34,7 +34,7 @@ ohos_static_library("imf_json_static") {
cflags_cc = [ "-fvisibility=hidden" ]
deps = [ "//third_party/cJSON:cjson" ]
public_deps = [ "//third_party/cJSON:cjson" ]
external_deps = [ "hilog:libhilog" ]
subsystem_name = "inputmethod"
part_name = "imf"

View File

@ -19,8 +19,6 @@
#include "global.h"
#include "ime_info_inquirer.h"
#include "input_method_system_ability.h"
#include "input_method_system_ability_stub.h"
#include "ipc_skeleton.h"
#include "iservice_registry.h"
#include "itypes_util.h"

View File

@ -15,8 +15,6 @@
#include "input_control_channel_stub.h"
#include "i_input_control_channel.h"
#include "input_method_agent_proxy.h"
#include "ipc_skeleton.h"
#include "message_handler.h"
#include "message_parcel.h"

View File

@ -45,6 +45,8 @@ namespace OHOS {
namespace MiscServices {
using namespace MessageID;
using namespace AccountSA;
using namespace AppExecFwk;
using namespace Security::AccessToken;
REGISTER_SYSTEM_ABILITY_BY_ID(InputMethodSystemAbility, INPUT_METHOD_SYSTEM_ABILITY_ID, true);
constexpr std::int32_t INIT_INTERVAL = 10000L;
constexpr std::int32_t MAIN_USER_ID = 100;
@ -269,6 +271,7 @@ int32_t InputMethodSystemAbility::PrepareInput(InputClientInfo &clientInfo)
int32_t InputMethodSystemAbility::GenerateClientInfo(InputClientInfo &clientInfo)
{
if (clientInfo.client == nullptr || clientInfo.channel == nullptr) {
IMSA_HILOGE("client or channel is nullptr");
return ErrorCode::ERROR_NULL_POINTER;
}
auto deathRecipient = new (std::nothrow) InputDeathRecipient();
@ -409,8 +412,7 @@ int32_t InputMethodSystemAbility::RequestHideInput()
return userSession_->OnRequestHideInput();
}
int32_t InputMethodSystemAbility::SetCoreAndAgent(
const sptr<IInputMethodCore> &core, const sptr<IInputMethodAgent> &agent)
int32_t InputMethodSystemAbility::SetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent)
{
IMSA_HILOGD("InputMethodSystemAbility run in");
if (IsCurrentIme()) {
@ -1238,7 +1240,7 @@ bool InputMethodSystemAbility::IsStartInputTypePermitted()
return identityChecker_->IsFocused(IPCSkeleton::GetCallingPid(), tokenId) && userSession_->IsBoundToClient();
}
int32_t InputMethodSystemAbility::ConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent)
int32_t InputMethodSystemAbility::ConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent)
{
auto tokenId = IPCSkeleton::GetCallingTokenID();
if (!identityChecker_->HasPermission(tokenId, PERMISSION_CONNECT_IME_ABILITY)) {

View File

@ -19,13 +19,9 @@
#include "element_name.h"
#include "input_client_proxy.h"
#include "system_cmd_channel_proxy.h"
#include "input_data_channel_proxy.h"
#include "input_method_agent_proxy.h"
#include "input_method_core_proxy.h"
#include "ipc_skeleton.h"
#include "itypes_util.h"
#include "os_account_manager.h"
namespace OHOS {
namespace MiscServices {
@ -49,10 +45,12 @@ int32_t InputMethodSystemAbilityStub::OnRemoteRequest(
int32_t InputMethodSystemAbilityStub::StartInputOnRemote(MessageParcel &data, MessageParcel &reply)
{
InputClientInfo clientInfo;
if (!ITypesUtil::Unmarshal(data, clientInfo)) {
sptr<IRemoteObject> client = nullptr;
if (!ITypesUtil::Unmarshal(data, clientInfo, client, clientInfo.channel)) {
IMSA_HILOGE("read clientInfo failed");
return ErrorCode::ERROR_EX_PARCELABLE;
}
clientInfo.client = iface_cast<IInputClient>(client);
sptr<IRemoteObject> agent = nullptr;
int32_t ret = StartInput(clientInfo, agent);
return reply.WriteInt32(ret) && reply.WriteRemoteObject(agent) ? ErrorCode::NO_ERROR
@ -138,7 +136,7 @@ int32_t InputMethodSystemAbilityStub::SetCoreAndAgentOnRemote(MessageParcel &dat
IMSA_HILOGE("agentObject is nullptr");
return ErrorCode::ERROR_EX_PARCELABLE;
}
int32_t ret = SetCoreAndAgent(iface_cast<IInputMethodCore>(coreObject), iface_cast<IInputMethodAgent>(agentObject));
int32_t ret = SetCoreAndAgent(iface_cast<IInputMethodCore>(coreObject), agentObject);
return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
}
@ -268,11 +266,13 @@ int32_t InputMethodSystemAbilityStub::PanelStatusChangeOnRemote(MessageParcel &d
int32_t InputMethodSystemAbilityStub::UpdateListenEventFlagOnRemote(MessageParcel &data, MessageParcel &reply)
{
InputClientInfo clientInfo;
sptr<IRemoteObject> client = nullptr;
uint32_t eventFlag = 0;
if (!ITypesUtil::Unmarshal(data, clientInfo, eventFlag)) {
if (!ITypesUtil::Unmarshal(data, clientInfo, client, clientInfo.channel, eventFlag)) {
IMSA_HILOGE("Unmarshal failed");
return ErrorCode::ERROR_EX_PARCELABLE;
}
clientInfo.client = iface_cast<IInputClient>(client);
int32_t ret = UpdateListenEventFlag(clientInfo, eventFlag);
return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
}
@ -358,7 +358,7 @@ int32_t InputMethodSystemAbilityStub::ConnectSystemCmdOnRemote(MessageParcel &da
return ErrorCode::ERROR_EX_PARCELABLE;
}
sptr<IRemoteObject> agent = nullptr;
int32_t ret = ConnectSystemCmd(iface_cast<ISystemCmdChannel>(systemCmdStub), agent);
int32_t ret = ConnectSystemCmd(systemCmdStub, agent);
return reply.WriteInt32(ret) && reply.WriteRemoteObject(agent) ? ErrorCode::NO_ERROR
: ErrorCode::ERROR_EX_PARCELABLE;
}

View File

@ -21,11 +21,7 @@
#include "element_name.h"
#include "ime_cfg_manager.h"
#include "ime_info_inquirer.h"
#include "input_client_proxy.h"
#include "input_control_channel_proxy.h"
#include "input_data_channel_proxy.h"
#include "input_method_agent_proxy.h"
#include "input_method_core_proxy.h"
#include "input_control_channel_stub.h"
#include "input_type_manager.h"
#include "ipc_skeleton.h"
#include "iservice_registry.h"
@ -493,7 +489,7 @@ int32_t PerUserSession::OnStartInput(const InputClientInfo &inputClientInfo, spt
IMSA_HILOGE("data or agent is nullptr.");
return ErrorCode::ERROR_IME_NOT_STARTED;
}
agent = data->agent->AsObject();
agent = data->agent;
return ErrorCode::NO_ERROR;
}
@ -549,7 +545,7 @@ void PerUserSession::StopClientInput(const sptr<IInputClient> &currentClient)
IMSA_HILOGI("stop client input, ret: %{public}d", ret);
}
void PerUserSession::StopImeInput(ImeType currentType, const sptr<IInputDataChannel> &currentChannel)
void PerUserSession::StopImeInput(ImeType currentType, const sptr<IRemoteObject> &currentChannel)
{
auto data = GetImeData(currentType);
if (data == nullptr) {
@ -572,7 +568,7 @@ void PerUserSession::OnSecurityChange(int32_t security)
IMSA_HILOGD("on security change, ret: %{public}d", ret);
}
int32_t PerUserSession::OnSetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IInputMethodAgent> &agent)
int32_t PerUserSession::OnSetCoreAndAgent(const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent)
{
IMSA_HILOGI("run in");
auto imeType = ImeType::IME;
@ -593,7 +589,7 @@ int32_t PerUserSession::OnSetCoreAndAgent(const sptr<IInputMethodCore> &core, co
return ErrorCode::NO_ERROR;
}
int32_t PerUserSession::OnRegisterProxyIme(const sptr<IInputMethodCore> &core, const sptr<IInputMethodAgent> &agent)
int32_t PerUserSession::OnRegisterProxyIme(const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent)
{
IMSA_HILOGD("run in");
auto imeType = ImeType::PROXY_IME;
@ -756,7 +752,7 @@ void PerUserSession::NotifyImeChangeToClients(const Property &property, const Su
}
}
int32_t PerUserSession::AddImeData(ImeType type, sptr<IInputMethodCore> core, sptr<IInputMethodAgent> agent, pid_t pid)
int32_t PerUserSession::AddImeData(ImeType type, sptr<IInputMethodCore> core, sptr<IRemoteObject> agent, pid_t pid)
{
if (core == nullptr || agent == nullptr) {
IMSA_HILOGE("core or agent is nullptr");
@ -1061,16 +1057,6 @@ bool PerUserSession::IsProxyImeStartInImeBind(ImeType bindImeType, ImeType start
return startImeType == ImeType::PROXY_IME && bindImeType == ImeType::IME;
}
bool PerUserSession::IsBindProxyImeInImeBind(ImeType bindImeType)
{
return bindImeType == ImeType::IME && IsProxyImeEnable();
}
bool PerUserSession::IsBindImeInProxyImeBind(ImeType bindImeType)
{
return bindImeType == ImeType::PROXY_IME && !IsProxyImeEnable();
}
bool PerUserSession::IsImeBindChanged(ImeType bindImeType)
{
return (bindImeType == ImeType::IME && IsProxyImeEnable())
@ -1174,7 +1160,7 @@ int32_t PerUserSession::RequestIme(const std::shared_ptr<ImeData> &data, Request
return ret;
}
int32_t PerUserSession::OnConnectSystemCmd(const sptr<ISystemCmdChannel> &channel, sptr<IRemoteObject> &agent)
int32_t PerUserSession::OnConnectSystemCmd(const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent)
{
auto data = GetImeData(ImeType::IME);
if (data == nullptr) {

View File

@ -50,7 +50,10 @@ ohos_static_library("inputmethod_test_common") {
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
]
external_deps = [ "hilog:libhilog" ]
external_deps = [
"hilog:libhilog",
"input:libmmi-client",
]
subsystem_name = "inputmethod"
part_name = "imf"

View File

@ -25,6 +25,7 @@ ohos_fuzztest("AgentStubFuzzTest") {
fuzz_config_file = "//base/inputmethod/imf/test/fuzztest/agentstub_fuzzer"
include_dirs = [
"${inputmethod_path}/common/include",
"${inputmethod_path}/frameworks/native/inputmethod_ability/include",
"${inputmethod_path}/frameworks/native/inputmethod_controller/include",
]
@ -36,16 +37,14 @@ ohos_fuzztest("AgentStubFuzzTest") {
"-fno-omit-frame-pointer",
]
sources = [
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
"agentstub_fuzzer.cpp",
]
sources = [ "agentstub_fuzzer.cpp" ]
deps = [ "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability" ]
deps = [ "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static" ]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_single",
]
}

View File

@ -18,7 +18,6 @@
#include <cstddef>
#include <cstdint>
#include "global.h"
#include "input_method_agent_stub.h"
#include "message_parcel.h"

View File

@ -36,7 +36,7 @@ ohos_fuzztest("ControlChannelStubFuzzTest") {
sources = [ "controlchannelstub_fuzzer.cpp" ]
deps = [ "${inputmethod_path}/services:inputmethod_service" ]
deps = [ "${inputmethod_path}/services:inputmethod_service_static" ]
external_deps = [
"c_utils:utils",

View File

@ -25,6 +25,7 @@ ohos_fuzztest("CoreStubFuzzTest") {
fuzz_config_file = "//base/inputmethod/imf/test/fuzztest/corestub_fuzzer"
include_dirs = [
"${inputmethod_path}/common/include",
"${inputmethod_path}/frameworks/native/inputmethod_controller/include",
"${inputmethod_path}/frameworks/native/inputmethod_ability/include",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller/include",
@ -37,12 +38,9 @@ ohos_fuzztest("CoreStubFuzzTest") {
"-fno-omit-frame-pointer",
]
sources = [
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
"corestub_fuzzer.cpp",
]
sources = [ "corestub_fuzzer.cpp" ]
deps = [ "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability" ]
deps = [ "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static" ]
external_deps = [
"c_utils:utils",

View File

@ -18,7 +18,6 @@
#include <cstddef>
#include <cstdint>
#include "global.h"
#include "input_method_core_stub.h"
#include "message_parcel.h"

View File

@ -37,7 +37,7 @@ ohos_fuzztest("InputClientStubFuzzTest") {
sources = [ "inputclientstub_fuzzer.cpp" ]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
"${inputmethod_path}/services:inputmethod_service",
]
@ -46,6 +46,7 @@ ohos_fuzztest("InputClientStubFuzzTest") {
"ability_runtime:ability_manager",
"c_utils:utils",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_single",
]
}

View File

@ -62,8 +62,7 @@ void TextOnInputReady()
MessageParcel data;
data.WriteRemoteObject(mInputMethodAgentStub->AsObject());
auto remoteObject = data.ReadRemoteObject();
sptr<IInputMethodAgent> iface = iface_cast<IInputMethodAgent>(remoteObject);
mClient->OnInputReady(iface);
mClient->OnInputReady(remoteObject);
}
void TestOnSwitchInput()

View File

@ -49,6 +49,7 @@ ohos_fuzztest("InputMethodAbilityFuzzTest") {
"input:libmmi-client",
"ipc:ipc_single",
"napi:ace_napi",
"window_manager:libwm",
]
}

View File

@ -38,25 +38,22 @@ ohos_fuzztest("PerUserSessionFuzzTest") {
"-fno-omit-frame-pointer",
]
sources = [
"${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp",
"perusersession_fuzzer.cpp",
]
sources = [ "perusersession_fuzzer.cpp" ]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/services/json:imf_json_static",
"//third_party/cJSON:cjson",
"${inputmethod_path}/services:inputmethod_service_static",
]
external_deps = [
"ability_runtime:ability_manager",
"c_utils:utils",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_single",
"napi:ace_napi",
"window_manager:libwm",
]
}

View File

@ -30,10 +30,12 @@
#include "i_input_method_agent.h"
#include "i_input_method_core.h"
#include "input_client_proxy.h"
#include "input_client_stub.h"
#include "input_method_ability.h"
#include "input_method_agent_proxy.h"
#include "input_method_agent_stub.h"
#include "input_method_core_proxy.h"
#include "input_method_core_stub.h"
#include "input_method_info.h"
#include "input_method_property.h"
#include "iremote_broker.h"
@ -56,16 +58,15 @@ uint32_t ConvertToUint32(const uint8_t *ptr)
bool InitializeClientInfo(InputClientInfo &clientInfo)
{
auto clientStub = new (std::nothrow) InputClientStub();
sptr<IInputClient> clientStub = new (std::nothrow) InputClientStub();
if (clientStub == nullptr) {
IMSA_HILOGE("failed to create client");
return false;
}
auto deathRecipient = new (std::nothrow) InputDeathRecipient();
sptr<InputDeathRecipient> deathRecipient = new (std::nothrow) InputDeathRecipient();
if (deathRecipient == nullptr) {
IMSA_HILOGE("failed to new deathRecipient");
delete clientStub;
return ErrorCode::ERROR_EX_NULL_POINTER;
return false;
}
clientInfo = { .userID = MAIN_USER_ID, .client = clientStub, .deathRecipient = deathRecipient };
return true;
@ -92,13 +93,13 @@ bool FuzzPerUserSession(const uint8_t *rawData, size_t size)
auto agent = iface_cast<IInputMethodAgent>(agentStub);
static std::shared_ptr<PerUserSession> userSessions = std::make_shared<PerUserSession>(MAIN_USER_ID);
userSessions->OnRegisterProxyIme(core, agent);
userSessions->OnRegisterProxyIme(core, agent->AsObject());
int32_t type = 4;
userSessions->OnUnRegisteredProxyIme(static_cast<UnRegisteredType>(type), core);
userSessions->IsProxyImeEnable();
userSessions->OnPrepareInput(clientInfo);
userSessions->OnSetCoreAndAgent(core, agent);
userSessions->OnSetCoreAndAgent(core, agent->AsObject());
userSessions->OnShowCurrentInput();
sptr<IRemoteObject> agentObject = nullptr;
clientInfo.isShowKeyboard = false;

View File

@ -41,10 +41,8 @@ ohos_fuzztest("SystemAbilityStubFuzzTest") {
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static",
"${inputmethod_path}/services:inputmethod_service_static",
"${inputmethod_path}/test/common:inputmethod_test_common",
"//third_party/cJSON:cjson",
]
external_deps = [

View File

@ -41,10 +41,8 @@ ohos_static_library("imf_sa_stub_fuzztest_common_static") {
public_deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static",
"${inputmethod_path}/services:inputmethod_service_static",
"${inputmethod_path}/test/common:inputmethod_test_common",
"//third_party/cJSON:cjson",
]
public_configs = [ ":imf_sa_stub_fuzztest_common_config" ]

View File

@ -23,6 +23,7 @@ group("unittest") {
"cpp_test:IdentityCheckerTest",
"cpp_test:ImeFreezeManagerTest",
"cpp_test:ImeProxyTest",
"cpp_test:ImeSystemChannelTest",
"cpp_test:InputMethodAbilityTest",
"cpp_test:InputMethodAttachTest",
"cpp_test:InputMethodControllerTest",
@ -32,7 +33,6 @@ group("unittest") {
"cpp_test:InputMethodPrivateMemberTest",
"cpp_test:InputMethodServiceTest",
"cpp_test:InputMethodSwitchTest",
"cpp_test:InputMethodUtilsTest",
"cpp_test:JsonOperateTest",
"cpp_test:NewImeSwitchTest",
"cpp_test:SecurityModeParseTest",

View File

@ -100,6 +100,7 @@ ohos_unittest("InputMethodAttachTest") {
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"hilog:libhilog",
"input:libmmi-client",
"napi:ace_napi",
"window_manager:libwm",
]
@ -114,17 +115,16 @@ ohos_unittest("InputMethodAbilityTest") {
module_out_path = module_output_path
sources = [
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_agent_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_proxy.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_stub.cpp",
"${inputmethod_path}/services/src/input_control_channel_proxy.cpp",
"src/input_method_ability_exception_test.cpp",
"src/input_method_ability_test.cpp",
]
configs = [ ":module_private_config" ]
include_dirs = [
"${windowmanager_path}/interfaces/innerkits/dm",
"${windowmanager_path}/interfaces/innerkits/wm",
]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
@ -164,11 +164,6 @@ ohos_unittest("InputMethodServiceTest") {
configs = [ ":module_private_config" ]
include_dirs = [
"${windowmanager_path}/interfaces/innerkits/dm",
"${windowmanager_path}/interfaces/innerkits/wm",
]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
@ -207,10 +202,10 @@ ohos_unittest("InputMethodDfxTest") {
configs = [ ":module_private_config" ]
deps = [
"${inputmethod_path}/common:inputmethod_common",
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client",
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/services/dfx:inputmethod_dfx_static",
"${inputmethod_path}/test/common:inputmethod_test_common",
"${inputmethod_path}/test/unittest/cpp_test/common:inputmethod_tdd_util",
"//third_party/googletest:gtest_main",
@ -247,11 +242,6 @@ ohos_unittest("InputMethodPanelTest") {
configs = [ ":module_private_config" ]
include_dirs = [
"${windowmanager_path}/interfaces/innerkits/dm",
"${windowmanager_path}/interfaces/innerkits/wm",
]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
@ -280,32 +270,6 @@ ohos_unittest("InputMethodPanelTest") {
]
}
ohos_unittest("InputMethodUtilsTest") {
branch_protector_ret = "pac_ret"
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
module_out_path = module_output_path
sources = [
"src/block_queue_test.cpp",
"src/input_method_utils_test.cpp",
]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
"//third_party/googletest:gtest_main",
]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
"ipc:ipc_core",
]
}
ohos_unittest("InputMethodSwitchTest") {
branch_protector_ret = "pac_ret"
sanitize = {
@ -350,17 +314,20 @@ ohos_unittest("InputMethodPrivateMemberTest") {
}
module_out_path = module_output_path
sources = [ "src/input_method_private_member_test.cpp" ]
sources = [
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_agent_stub.cpp",
"${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_stub.cpp",
"${inputmethod_path}/services/src/input_control_channel_proxy.cpp",
"src/input_method_private_member_test.cpp",
]
configs = [ ":module_private_config" ]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static",
"${inputmethod_path}/services:inputmethod_service_static",
"${inputmethod_path}/test/unittest/cpp_test/common:inputmethod_tdd_util",
"//third_party/cJSON:cjson",
"//third_party/googletest:gtest_main",
]
@ -376,6 +343,7 @@ ohos_unittest("InputMethodPrivateMemberTest") {
"input:libmmi-client",
"ipc:ipc_core",
"ipc:ipc_single",
"napi:ace_napi",
"os_account:os_account_innerkits",
"window_manager:libwm",
]
@ -468,19 +436,10 @@ ohos_unittest("IdentityCheckerTest") {
configs = [ ":module_private_config" ]
include_dirs = [
"${windowmanager_path}/interfaces/innerkits/dm",
"${windowmanager_path}/interfaces/innerkits/wm",
]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static",
"${inputmethod_path}/services:inputmethod_service_static",
"${inputmethod_path}/test/common:inputmethod_test_common",
"${inputmethod_path}/test/unittest/cpp_test/common:inputmethod_tdd_util",
"//third_party/cJSON:cjson",
"//third_party/googletest:gtest_main",
]
@ -556,11 +515,6 @@ ohos_unittest("ImeProxyTest") {
configs = [ ":module_private_config" ]
include_dirs = [
"${windowmanager_path}/interfaces/innerkits/dm",
"${windowmanager_path}/interfaces/innerkits/wm",
]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
@ -644,7 +598,6 @@ ohos_unittest("SecurityModeParseTest") {
include_dirs = [
"${inputmethod_path}/test/unittest/cpp_test/mock",
"${inputmethod_path}/common",
"${inputmethod_path}/services/include",
"${inputmethod_path}/services/identity_checker/include",
"${inputmethod_path}/services/adapter/settings_data_provider/include",
@ -662,9 +615,7 @@ ohos_unittest("SecurityModeParseTest") {
]
deps = [
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/services/json:imf_json_static",
"//third_party/cJSON:cjson",
"${inputmethod_path}/services:inputmethod_service_static",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest_main",
]
@ -697,12 +648,8 @@ ohos_unittest("ImeFreezeManagerTest") {
configs = [ ":module_private_config" ]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static",
"${inputmethod_path}/services:inputmethod_service_static",
"${inputmethod_path}/test/unittest/cpp_test/common:inputmethod_tdd_util",
"//third_party/cJSON:cjson",
"//third_party/googletest:gtest_main",
]
@ -735,9 +682,8 @@ ohos_unittest("JsonOperateTest") {
sources = [ "src/json_operate_test.cpp" ]
deps = [
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/services:inputmethod_service_static",
"${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static",
"${inputmethod_path}/services/file:imf_file_static",
"${inputmethod_path}/services/json:imf_json_static",
"//third_party/cJSON:cjson",
"//third_party/googletest:gtest_main",
@ -770,6 +716,7 @@ ohos_unittest("VirtualListenerTest") {
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/test/common:inputmethod_test_common",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest_main",
]
@ -791,3 +738,43 @@ ohos_unittest("VirtualListenerTest") {
"window_manager:libwm",
]
}
ohos_unittest("ImeSystemChannelTest") {
branch_protector_ret = "pac_ret"
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
blocklist = "./inputmethod_blocklist.txt"
}
module_out_path = module_output_path
sources = [ "src/ime_system_channel_test.cpp" ]
configs = [ ":module_private_config" ]
deps = [
"${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability",
"${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static",
"${inputmethod_path}/services:inputmethod_service",
"${inputmethod_path}/test/common:inputmethod_test_common",
"${inputmethod_path}/test/unittest/cpp_test/common:inputmethod_tdd_util",
"//third_party/googletest:gtest_main",
]
external_deps = [
"ability_base:want",
"ability_runtime:ability_context_native",
"ability_runtime:ability_manager",
"access_token:libaccesstoken_sdk",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"eventhandler:libeventhandler",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_single",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"window_manager:libwm",
]
}

View File

@ -20,7 +20,7 @@
#include "block_data.h"
#include "bundle_mgr_interface.h"
#include "window.h"
#include "foundation/window/window_manager/interfaces/innerkits/wm/window.h"
#include "window_manager.h"
#include "window_option.h"
#include "wm_common.h"

View File

@ -310,7 +310,7 @@ void TddUtil::PushEnableImeValue(const std::string &key, const std::string &valu
IMSA_HILOGI("data exits");
}
bool ret = SettingsDataUtils::GetInstance()->ReleaseDataShareHelper(helper);
IMSA_HILOGE("ReleaseDataShareHelper isSuccess: %{public}d", ret);
IMSA_HILOGI("ReleaseDataShareHelper isSuccess: %{public}d", ret);
}
int32_t TddUtil::GetEnableData(std::string &value)
@ -384,6 +384,7 @@ void TddUtil::WindowManager::ShowWindow()
IMSA_HILOGE("window is not exist.");
return;
}
TokenScope scope(windowTokenId_);
auto ret = window_->Show();
IMSA_HILOGI("Show window end, ret = %{public}d", ret);
}
@ -401,8 +402,9 @@ void TddUtil::WindowManager::HideWindow()
void TddUtil::WindowManager::DestroyWindow()
{
if (window_ != nullptr) {
IMSA_HILOGE("window nullptr");
if (window_ == nullptr) {
IMSA_HILOGE("window_ nullptr");
return;
}
TokenScope scope(windowTokenId_);
auto wmError = window_->Destroy();

View File

@ -178,7 +178,7 @@ std::mutex ImeFreezeManagerTest::mtx_;
HWTEST_F(ImeFreezeManagerTest, SingleThread_StartInput_001, TestSize.Level0)
{
IMSA_HILOGI("ImeFreezeManagerTest::SingleThread_StartInput_001");
EXPECT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ASSERT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ClearState();
TestAttach(false);
TestAttach(true);
@ -204,7 +204,7 @@ HWTEST_F(ImeFreezeManagerTest, SingleThread_StartInput_001, TestSize.Level0)
HWTEST_F(ImeFreezeManagerTest, SingleThread_StartAndStopInput_001, TestSize.Level0)
{
IMSA_HILOGI("ImeFreezeManagerTest::SingleThread_StartAndStopInput_001");
EXPECT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ASSERT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ClearState();
TestAttach(true);
TestDetach();
@ -227,7 +227,7 @@ HWTEST_F(ImeFreezeManagerTest, SingleThread_StartAndStopInput_001, TestSize.Leve
HWTEST_F(ImeFreezeManagerTest, SingleThread_StartInputAndRequestHide_001, TestSize.Level0)
{
IMSA_HILOGI("ImeFreezeManagerTest::SingleThread_StartInputAndRequestHide_001");
EXPECT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ASSERT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ClearState();
TestAttach(true);
TestRequestHideInput(true);
@ -245,7 +245,7 @@ HWTEST_F(ImeFreezeManagerTest, SingleThread_StartInputAndRequestHide_001, TestSi
HWTEST_F(ImeFreezeManagerTest, SingleThread_StartInputAndNormalIPC_001, TestSize.Level0)
{
IMSA_HILOGI("ImeFreezeManagerTest::SingleThread_StartInputAndNormalIPC_001");
EXPECT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ASSERT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ClearState();
TestNormalIPC();
@ -266,7 +266,7 @@ HWTEST_F(ImeFreezeManagerTest, SingleThread_StartInputAndNormalIPC_001, TestSize
HWTEST_F(ImeFreezeManagerTest, MultiThread_FullTest_001, TestSize.Level0)
{
IMSA_HILOGI("ImeFreezeManagerTest::MultiThread_FullTest_001");
EXPECT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ASSERT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
SET_THREAD_NUM(5);
GTEST_RUN_TASK(FullTestTask);
}
@ -279,7 +279,7 @@ HWTEST_F(ImeFreezeManagerTest, MultiThread_FullTest_001, TestSize.Level0)
HWTEST_F(ImeFreezeManagerTest, SingleThread_RequestShow_001, TestSize.Level0)
{
IMSA_HILOGI("ImeFreezeManagerTest::SingleThread_RequestShow_001");
EXPECT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ASSERT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
ClearState();
TestRequestShowInput(true);
}

View File

@ -0,0 +1,140 @@
/*
* 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.
*/
#define private public
#define protected public
#include "ime_system_channel.h"
#undef private
#include <gtest/gtest.h>
#include "scope_utils.h"
#include "tdd_util.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace MiscServices {
class OnSystemCmdListenerImpl : public OnSystemCmdListener {
void ReceivePrivateCommand(const std::unordered_map<std::string, PrivateDataValue> &privateCommand) override
{
}
void NotifyIsShowSysPanel(bool shouldSysPanelShow) override
{
}
};
class ImeSystemChannelTest : public testing::Test {
public:
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp();
void TearDown();
static sptr<ImeSystemCmdChannel> imeSystemChannel_;
static sptr<OnSystemCmdListener> sysCmdListener_;
static uint64_t permissionTokenId_;
};
sptr<ImeSystemCmdChannel> ImeSystemChannelTest::imeSystemChannel_;
sptr<OnSystemCmdListener> ImeSystemChannelTest::sysCmdListener_;
uint64_t ImeSystemChannelTest::permissionTokenId_ = 0;
void ImeSystemChannelTest::SetUpTestCase(void)
{
TddUtil::StorageSelfTokenID();
imeSystemChannel_ = ImeSystemCmdChannel::GetInstance();
sysCmdListener_ = new (std::nothrow) OnSystemCmdListenerImpl();
permissionTokenId_ =
TddUtil::AllocTestTokenID(true, "ohos.inputMethod.test", { "ohos.permission.CONNECT_IME_ABILITY" });
}
void ImeSystemChannelTest::TearDownTestCase(void)
{
IMSA_HILOGI("ImeSystemChannelTest::TearDownTestCase");
imeSystemChannel_->ConnectSystemCmd(nullptr);
imeSystemChannel_->ClearSystemCmdAgent();
TddUtil::RestoreSelfTokenID();
}
void ImeSystemChannelTest::SetUp(void)
{
IMSA_HILOGI("ImeSystemChannelTest::SetUp");
}
void ImeSystemChannelTest::TearDown(void)
{
IMSA_HILOGI("ImeSystemChannelTest::TearDown");
}
/**
* @tc.name: testConnectSystemCmd001
* @tc.desc: SystemCmdChannel ConnectSystemCmd.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(ImeSystemChannelTest, testConnectSystemCmd001, TestSize.Level0)
{
IMSA_HILOGD("ImeSystemChannelTest testConnectSystemCmd001 Test START");
auto ret = imeSystemChannel_->ConnectSystemCmd(sysCmdListener_);
EXPECT_EQ(ret, ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION);
}
/**
* @tc.name: testConnectSystemCmd002
* @tc.desc: SystemCmdChannel ConnectSystemCmd.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(ImeSystemChannelTest, testConnectSystemCmd002, TestSize.Level0)
{
IMSA_HILOGD("ImeSystemChannelTest testConnectSystemCmd002 Test START");
TokenScope scope(ImeSystemChannelTest::permissionTokenId_);
auto ret = imeSystemChannel_->ConnectSystemCmd(sysCmdListener_);
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
}
/**
* @tc.name: testSendPrivateCommand001
* @tc.desc: SystemCmdChannel SendPrivateCommand.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(ImeSystemChannelTest, testSendPrivateCommand001, TestSize.Level0)
{
IMSA_HILOGD("ImeSystemChannelTest testSendPrivateCommand001 Test START");
TokenScope scope(ImeSystemChannelTest::permissionTokenId_);
std::unordered_map<std::string, PrivateDataValue> privateCommand;
auto ret = imeSystemChannel_->SendPrivateCommand(privateCommand);
EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_PRIVATE_COMMAND);
}
/**
* @tc.name: testImeSystemChannel_nullptr
* @tc.desc: SystemCmdChannel ReceivePrivateCommand.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(ImeSystemChannelTest, testImeSystemChannel_nullptr, TestSize.Level0)
{
IMSA_HILOGD("ImeSystemChannelTest testImeSystemChannel_nullptr Test START");
std::unordered_map<std::string, PrivateDataValue> privateCommand;
PrivateDataValue privateDataValue1 = std::string("stringValue");
privateCommand.emplace("value1", privateDataValue1);
imeSystemChannel_->systemCmdListener_ = nullptr;
imeSystemChannel_->OnConnectCmdReady(nullptr);
imeSystemChannel_->GetSmartMenuCfg();
int32_t ret = imeSystemChannel_->ReceivePrivateCommand(privateCommand);
EXPECT_EQ(ret, ErrorCode::ERROR_EX_NULL_POINTER);
ret = imeSystemChannel_->ShowSysPanel(true);
EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
}
} // namespace MiscServices
} // namespace OHOS

View File

@ -145,7 +145,7 @@ public:
auto agent = inputMethodAbility_->agentStub_->AsObject();
imc_->SetAgent(agent);
sptr<IInputDataChannel> channel = iface_cast<IInputDataChannel>(imc_->clientInfo_.channel->AsObject());
sptr<IInputDataChannel> channel = iface_cast<IInputDataChannel>(imc_->clientInfo_.channel);
inputMethodAbility_->SetInputDataChannel(channel->AsObject());
IMSA_HILOGI("end");
}

View File

@ -552,7 +552,7 @@ HWTEST_F(InputMethodControllerTest, testIMCSetCallingWindow, TestSize.Level0)
HWTEST_F(InputMethodControllerTest, testGetIMSAProxy, TestSize.Level0)
{
auto systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
EXPECT_TRUE(systemAbilityManager != nullptr);
ASSERT_NE(systemAbilityManager, nullptr);
auto systemAbility = systemAbilityManager->GetSystemAbility(INPUT_METHOD_SYSTEM_ABILITY_ID, "");
EXPECT_TRUE(systemAbility != nullptr);
}

View File

@ -32,6 +32,7 @@
#include "common_event_support.h"
#include "display_manager.h"
#include "global.h"
#include "ime_event_monitor_manager.h"
#include "input_method_ability.h"
#include "input_method_controller.h"
#include "input_method_engine_listener_impl.h"
@ -362,8 +363,6 @@ void InputMethodPanelTest::ImcPanelShowInfoCheck(const InputWindowInfo &windowIn
IMSA_HILOGI("InputMethodPanelTest::name: %{public}s, ret:[%{public}d, %{public}d,%{public}d, %{public}d]",
windowInfo_.name.c_str(), windowInfo_.top, windowInfo_.left, windowInfo_.width, windowInfo_.height);
EXPECT_FALSE(windowInfo_.name.empty());
EXPECT_EQ(windowInfo_.width, windowInfo.width);
EXPECT_EQ(windowInfo_.height, windowInfo.height);
}
void InputMethodPanelTest::ImcPanelHideInfoCheck(const InputWindowInfo &windowInfo)
@ -375,8 +374,6 @@ void InputMethodPanelTest::ImcPanelHideInfoCheck(const InputWindowInfo &windowIn
IMSA_HILOGI("InputMethodPanelTest::name: %{public}s, ret:[%{public}d, %{public}d,%{public}d, %{public}d]",
windowInfo_.name.c_str(), windowInfo_.top, windowInfo_.left, windowInfo_.width, windowInfo_.height);
EXPECT_FALSE(windowInfo_.name.empty());
EXPECT_EQ(windowInfo_.width, windowInfo.width);
EXPECT_EQ(windowInfo_.height, windowInfo.height);
}
void InputMethodPanelTest::ImcPanelListeningTestRestore()
@ -464,7 +461,7 @@ HWTEST_F(InputMethodPanelTest, testResizePanel001, TestSize.Level0)
ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
EXPECT_TRUE(defaultDisplay != nullptr);
ASSERT_TRUE(defaultDisplay != nullptr);
int32_t width = defaultDisplay->GetWidth();
int32_t height = defaultDisplay->GetHeight();
@ -505,7 +502,7 @@ HWTEST_F(InputMethodPanelTest, testResizePanel002, TestSize.Level0)
ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
EXPECT_TRUE(defaultDisplay != nullptr);
ASSERT_TRUE(defaultDisplay != nullptr);
int32_t width = defaultDisplay->GetWidth();
int32_t height = defaultDisplay->GetHeight();

View File

@ -43,6 +43,7 @@
using namespace testing::ext;
namespace OHOS {
namespace MiscServices {
using namespace AppExecFwk;
class InputMethodPrivateMemberTest : public testing::Test {
public:
static void SetUpTestCase(void);
@ -591,7 +592,7 @@ HWTEST_F(InputMethodPrivateMemberTest, III_TestGetCurrentSubtype_001, TestSize.L
ImeCfgManager::GetInstance().imeConfigs_.push_back(
{ currentUserId, currentProp->name + "/" + currentProp->id, "tt" });
subProp = ImeInfoInquirer::GetInstance().GetCurrentSubtype(currentUserId);
EXPECT_TRUE(subProp != nullptr);
ASSERT_TRUE(subProp != nullptr);
EXPECT_TRUE(subProp->name == currentProp->name);
// get correct subProp

View File

@ -22,7 +22,6 @@
#include "global.h"
#include "ime_event_monitor_manager_impl.h"
#include "ime_info_inquirer.h"
#include "ime_setting_listener_test_impl.h"
#include "input_method_controller.h"
#include "input_method_property.h"
@ -47,7 +46,6 @@ public:
static std::vector<std::string> extName;
static std::vector<std::string> language;
static std::vector<std::string> locale;
static bool enableOn_;
static std::string beforeValue;
static std::string allEnableIme;
};
@ -58,7 +56,6 @@ std::string InputMethodSwitchTest::bundleName = "com.example.testIme";
std::vector<std::string> InputMethodSwitchTest::extName{ "InputMethodExtAbility", "InputMethodExtAbility2" };
std::vector<std::string> InputMethodSwitchTest::language{ "chinese", "english" };
std::vector<std::string> InputMethodSwitchTest::locale{ "zh-CN", "en-US" };
bool InputMethodSwitchTest::enableOn_ = false;
std::string InputMethodSwitchTest::beforeValue;
std::string InputMethodSwitchTest::allEnableIme = "{\"enableImeList\" : {\"100\" : [ \"com.example.newTestIme\", "
"\"com.example.testIme\"]}}";
@ -71,15 +68,11 @@ constexpr const char *ENABLE_IME_KEYWORD = "settings.inputmethod.enable_ime";
void InputMethodSwitchTest::SetUpTestCase(void)
{
IMSA_HILOGI("InputMethodSwitchTest::SetUpTestCase");
ImeInfoInquirer::GetInstance().InitSystemConfig();
enableOn_ = ImeInfoInquirer::GetInstance().IsEnableInputMethod();
IMSA_HILOGI("enableOn: %{public}d", enableOn_);
TddUtil::GrantNativePermission();
if (enableOn_) {
int32_t ret = TddUtil::GetEnableData(beforeValue);
if (ret == ErrorCode::NO_ERROR) {
TddUtil::PushEnableImeValue(ENABLE_IME_KEYWORD, allEnableIme);
}
int32_t ret = TddUtil::GetEnableData(beforeValue);
if (ret == ErrorCode::NO_ERROR) {
IMSA_HILOGI("Enable ime switch test.");
TddUtil::PushEnableImeValue(ENABLE_IME_KEYWORD, allEnableIme);
}
TddUtil::StorageSelfTokenID();
TddUtil::SetTestTokenID(
@ -92,10 +85,8 @@ void InputMethodSwitchTest::SetUpTestCase(void)
void InputMethodSwitchTest::TearDownTestCase(void)
{
IMSA_HILOGI("InputMethodSwitchTest::TearDownTestCase");
if (enableOn_) {
TddUtil::GrantNativePermission();
TddUtil::PushEnableImeValue(ENABLE_IME_KEYWORD, beforeValue);
}
TddUtil::GrantNativePermission();
TddUtil::PushEnableImeValue(ENABLE_IME_KEYWORD, beforeValue);
InputMethodController::GetInstance()->Close();
TddUtil::RestoreSelfTokenID();
}
@ -268,11 +259,7 @@ HWTEST_F(InputMethodSwitchTest, testSwitchImeWithErrorBundleName, TestSize.Level
IMSA_HILOGI("oldIme testSwitchImeWithErrorBundleName Test START");
std::string subName = InputMethodSwitchTest::imc_->GetCurrentInputMethodSubtype()->id;
int32_t ret = imc_->SwitchInputMethod(SwitchTrigger::CURRENT_IME, "error bundleName", extName[0]);
if (InputMethodSwitchTest::enableOn_) {
EXPECT_EQ(ret, ErrorCode::ERROR_ENABLE_IME);
} else {
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
}
EXPECT_TRUE(ret == ErrorCode::ERROR_ENABLE_IME || ret == ErrorCode::ERROR_BAD_PARAMETERS);
CheckCurrentProp(subName);
CheckCurrentSubProp(subName);
CheckCurrentSubProps();
@ -290,11 +277,7 @@ HWTEST_F(InputMethodSwitchTest, testSwitchImeWithErrorBundleNameWitchEmptySubNam
IMSA_HILOGI("oldIme testSwitchImeWithErrorBundleNameWitchEmptySubName Test START");
std::string subName = InputMethodSwitchTest::imc_->GetCurrentInputMethodSubtype()->id;
int32_t ret = imc_->SwitchInputMethod(SwitchTrigger::CURRENT_IME, "error bundleName", " ");
if (InputMethodSwitchTest::enableOn_) {
EXPECT_EQ(ret, ErrorCode::ERROR_ENABLE_IME);
} else {
EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
}
EXPECT_TRUE(ret == ErrorCode::ERROR_ENABLE_IME || ret == ErrorCode::ERROR_BAD_PARAMETERS);
CheckCurrentProp(subName);
CheckCurrentSubProp(subName);
CheckCurrentSubProps();

Some files were not shown because too many files have changed in this diff Show More