Signed-off-by: wangdongqi <wangdongqi2@huawei.com>

Changes to be committed:
This commit is contained in:
wangdongqi 2024-11-02 15:47:34 +08:00
parent a85089250f
commit 721cb43882
11 changed files with 173 additions and 182 deletions

View File

@ -289,8 +289,7 @@ int32_t InputMethodPanel::AdjustPanelRect(const PanelFlag panelFlag, const Layou
IMSA_HILOGE("portrait invalid size!");
return ErrorCode::ERROR_PARAMETER_CHECK_FAILED;
}
if (!CheckSize(panelFlag, layoutParams.landscapeRect.width_,
layoutParams.landscapeRect.height_, false)) {
if (!CheckSize(panelFlag, layoutParams.landscapeRect.width_, layoutParams.landscapeRect.height_, false)) {
IMSA_HILOGE("landscape invalid size!");
return ErrorCode::ERROR_PARAMETER_CHECK_FAILED;
}
@ -465,8 +464,8 @@ int32_t InputMethodPanel::CalculatePanelRect(const PanelFlag panelFlag, PanelAdj
keyboardLayoutParams_.PortraitPanelRect_.height_ =
portraitDisplaySize.height * FIXED_SOFT_KEYBOARD_PANEL_RATIO;
}
keyboardLayoutParams_.PortraitPanelRect_.posY_ = static_cast<int32_t>(portraitDisplaySize.height -
keyboardLayoutParams_.PortraitPanelRect_.height_);
keyboardLayoutParams_.PortraitPanelRect_.posY_ =
static_cast<int32_t>(portraitDisplaySize.height - keyboardLayoutParams_.PortraitPanelRect_.height_);
keyboardLayoutParams_.PortraitPanelRect_.posX_ = NUMBER_ZERO;
//fixed Portraitkeyboard
keyboardLayoutParams_.PortraitKeyboardRect_.width_ = keyboardLayoutParams_.PortraitPanelRect_.width_ -
@ -789,7 +788,7 @@ bool InputMethodPanel::IsShowing()
bool InputMethodPanel::IsHidden()
{
WindowState windowState = window_->GetWindowState();
auto windowState = window_->GetWindowState();
if (windowState == WindowState::STATE_HIDDEN) {
return true;
}
@ -1038,12 +1037,12 @@ bool InputMethodPanel::IsSizeValid(PanelFlag panelFlag, uint32_t width, uint32_t
int32_t displayHeight)
{
if (width > INT32_MAX || height > INT32_MAX) {
IMSA_HILOGE("width or height over maximum");
IMSA_HILOGE("width or height over maximum!");
return false;
}
float ratio = panelType_ == PanelType::SOFT_KEYBOARD && panelFlag == PanelFlag::FLG_FIXED
? FIXED_SOFT_KEYBOARD_PANEL_RATIO
: NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO;
? FIXED_SOFT_KEYBOARD_PANEL_RATIO
: NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO;
if (static_cast<float>(height) > displayHeight * ratio) {
IMSA_HILOGE("height is invalid, defaultDisplay height: %{public}d, target height: %{public}u!", displayHeight,
height);

View File

@ -342,6 +342,7 @@ int32_t InputMethodController::Close()
if (IsBound()) {
IMSA_HILOGI("start.");
}
auto listener = GetTextListener();
if (listener != nullptr) {
listener->OnDetach();

View File

@ -112,7 +112,6 @@ private:
SubProperty GetExtends(const std::vector<OHOS::AppExecFwk::Metadata> &metaData);
std::string GetTargetString(
const AppExecFwk::ExtensionAbilityInfo &extension, ImeTargetString target, int32_t userId);
int32_t GetAppLabelFromRes(const AppExecFwk::ExtensionAbilityInfo &extension, std::string &label);
std::string GetStringById(const std::string &bundleName, const std::string &moduleName, const uint32_t labelId,
const int32_t userId);
bool GetBundleInfoByBundleName(int32_t userId, const std::string &bundleName, AppExecFwk::BundleInfo &bundleInfo);

View File

@ -123,7 +123,7 @@ public:
int32_t OnRegisterProxyIme(const sptr<IInputMethodCore> &core, const sptr<IRemoteObject> &agent);
int32_t OnUnRegisteredProxyIme(UnRegisteredType type, const sptr<IInputMethodCore> &core);
int32_t InitConnect(pid_t pid);
bool StartCurrentIme(bool isStopCurrentIme = false);
bool StartIme(const std::shared_ptr<ImeNativeCfg> &ime, bool isStopCurrentIme = false);
bool StopCurrentIme();

View File

@ -335,13 +335,13 @@ void ImCommonEventManager::EventSubscriber::HandlePackageEvent(int32_t messageId
return;
}
if (!ITypesUtil::Marshal(*parcel, userId, bundleName)) {
IMSA_HILOGE("Failed to write message parcel!");
IMSA_HILOGE("failed to write message parcel");
delete parcel;
return;
}
Message *msg = new (std::nothrow) Message(messageId, parcel);
if (msg == nullptr) {
IMSA_HILOGE("failed to create Message!");
IMSA_HILOGE("failed to create Message");
delete parcel;
return;
}
@ -366,9 +366,9 @@ void ImCommonEventManager::SystemAbilityStatusChangeListener::OnAddSystemAbility
int32_t systemAbilityId, const std::string &deviceId)
{
IMSA_HILOGD("systemAbilityId: %{public}d.", systemAbilityId);
if (systemAbilityId != COMMON_EVENT_SERVICE_ID && systemAbilityId != MULTIMODAL_INPUT_SERVICE_ID
&& systemAbilityId != WINDOW_MANAGER_SERVICE_ID && systemAbilityId != SUBSYS_ACCOUNT_SYS_ABILITY_ID_BEGIN
&& systemAbilityId != MEMORY_MANAGER_SA_ID) {
if (systemAbilityId != COMMON_EVENT_SERVICE_ID && systemAbilityId != MULTIMODAL_INPUT_SERVICE_ID &&
systemAbilityId != WINDOW_MANAGER_SERVICE_ID && systemAbilityId != SUBSYS_ACCOUNT_SYS_ABILITY_ID_BEGIN &&
systemAbilityId != MEMORY_MANAGER_SA_ID) {
return;
}
if (func_ != nullptr) {
@ -399,4 +399,4 @@ int32_t ImCommonEventManager::PublishPanelStatusChangeEvent(
return EventFwk::CommonEventManager::NewPublishCommonEvent(data, publicInfo);
}
} // namespace MiscServices
} // namespace OHOS
} // namespace OHOS

View File

@ -61,16 +61,16 @@ void ImeInfoInquirer::InitSystemConfig()
{
auto ret = SysCfgParser::ParseSystemConfig(systemConfig_);
if (!ret) {
IMSA_HILOGE("parse systemConfig failed!");
IMSA_HILOGE("parse systemConfig failed");
return;
}
}
bool ImeInfoInquirer::IsEnableInputMethod()
{
return systemConfig_.enableInputMethodFeature;
}
bool ImeInfoInquirer::IsEnableSecurityMode()
{
return systemConfig_.enableFullExperienceFeature;
@ -81,7 +81,7 @@ bool ImeInfoInquirer::QueryImeExtInfos(const int32_t userId, std::vector<Extensi
IMSA_HILOGD("userId: %{public}d.", userId);
auto bundleMgr = GetBundleMgr();
if (bundleMgr == nullptr) {
IMSA_HILOGE("failed to GetBundleMgr!");
IMSA_HILOGE("failed to GetBundleMgr");
return false;
}
if (!bundleMgr->QueryExtensionAbilityInfos(ExtensionAbilityType::INPUTMETHOD, userId, infos)) {
@ -139,7 +139,7 @@ std::shared_ptr<ImeInfo> ImeInfoInquirer::GetImeInfoFromCache(const int32_t user
auto iter = std::find_if(subProps.begin(), subProps.end(),
[&subName](const SubProperty &subProp) { return subProp.id == subName; });
if (iter == subProps.end()) {
IMSA_HILOGE("find subName: %{public}s failed!", subName.c_str());
IMSA_HILOGE("find subName: %{public}s failed", subName.c_str());
return nullptr;
}
info->subProp = *iter;
@ -293,13 +293,9 @@ int32_t ImeInfoInquirer::ListInputMethod(const int32_t userId, std::vector<Prope
if (IsTempInputMethod(extension)) {
continue;
}
std::string label;
if (GetAppLabelFromRes(extension, label) != ErrorCode::NO_ERROR) {
IMSA_HILOGE("GetAppLabelFromRes failed");
}
props.push_back({ .name = extension.bundleName,
.id = extension.name,
.label = label,
.label = GetTargetString(extension, ImeTargetString::LABEL, userId),
.labelId = extension.applicationInfo.labelId,
.iconId = extension.applicationInfo.iconId });
}
@ -319,7 +315,7 @@ int32_t ImeInfoInquirer::ListEnabledInputMethod(const int32_t userId, std::vecto
std::vector<std::string> enableVec;
ret = EnableImeDataParser::GetInstance()->GetEnableIme(userId, enableVec);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("get enable data failed!");
IMSA_HILOGE("get enable data failed");
return ret;
}
auto info = GetDefaultIme();
@ -376,7 +372,7 @@ int32_t ImeInfoInquirer::GetSwitchInfoBySwitchCount(
auto iter = std::find_if(props.begin(), props.end(),
[&currentImeBundle](const Property &property) { return property.name == currentImeBundle; });
if (iter == props.end()) {
IMSA_HILOGE("can not found current ime in enable list!");
IMSA_HILOGE("can not found current ime in enable list");
auto info = GetDefaultImeInfo(userId);
if (info != nullptr) {
switchInfo.bundleName = info->prop.name;
@ -437,13 +433,13 @@ int32_t ImeInfoInquirer::GetSubProperty(int32_t userId, const std::string &subNa
{
IMSA_HILOGD("oldIme, userId: %{public}d.", userId);
if (extInfos.empty()) {
IMSA_HILOGE("extInfos is empty!");
IMSA_HILOGE("extInfos is empty");
return ErrorCode::ERROR_PACKAGE_MANAGER;
}
auto extInfo = std::find_if(extInfos.begin(), extInfos.end(),
[&subName](const ExtensionAbilityInfo &info) { return info.name == subName; });
if (extInfo == extInfos.end()) {
IMSA_HILOGE("subtype %{public}s not found!", subName.c_str());
IMSA_HILOGE("subtype %{public}s not found", subName.c_str());
extInfo = extInfos.begin();
}
subProp.labelId = extInfo->labelId;
@ -493,13 +489,13 @@ int32_t ImeInfoInquirer::GetSubProperty(int32_t userId, const std::string &subNa
return ret;
}
if (subtypes.empty()) {
IMSA_HILOGE("subtypes is empty!");
IMSA_HILOGE("subtypes is empty");
return ErrorCode::ERROR_PACKAGE_MANAGER;
}
auto subtype = std::find_if(
subtypes.begin(), subtypes.end(), [&subName](const Subtype &subtype) { return subtype.id == subName; });
if (subtype == subtypes.end()) {
IMSA_HILOGE("subtype %{public}s not found!", subName.c_str());
IMSA_HILOGE("subtype %{public}s not found", subName.c_str());
subtype = subtypes.begin();
}
subProp.label = subtype->label;
@ -510,12 +506,18 @@ int32_t ImeInfoInquirer::GetSubProperty(int32_t userId, const std::string &subNa
subProp.icon = subtype->icon;
auto pos = subProp.label.find(':');
if (pos != std::string::npos && pos + 1 < subProp.label.size()) {
subProp.labelId = atoi(subProp.label.substr(pos + 1).c_str());
subProp.label = GetStringById(extInfo.bundleName, extInfo.moduleName, subProp.labelId, userId);
int32_t labelId = atoi(subProp.label.substr(pos + 1).c_str());
if (labelId > 0) {
subProp.labelId = static_cast<uint32_t>(labelId);
subProp.label = GetStringById(extInfo.bundleName, extInfo.moduleName, subProp.labelId, userId);
}
}
pos = subProp.icon.find(':');
if (pos != std::string::npos && pos + 1 < subProp.icon.size()) {
subProp.iconId = atoi(subProp.icon.substr(pos + 1).c_str());
int32_t iconId = atoi(subProp.icon.substr(pos + 1).c_str());
if (iconId > 0) {
subProp.iconId = static_cast<uint32_t>(iconId);
}
}
CovertToLanguage(subProp.locale, subProp.language);
return ErrorCode::NO_ERROR;
@ -549,7 +551,10 @@ int32_t ImeInfoInquirer::ListInputMethodSubtype(const int32_t userId, const Exte
.icon = subtype.icon};
auto pos = subProp.label.find(':');
if (pos != std::string::npos && pos + 1 < subProp.label.size()) {
subProp.labelId = atoi(subProp.label.substr(pos + 1).c_str());
int32_t labelId = atoi(subProp.label.substr(pos + 1).c_str());
if (labelId > 0) {
subProp.labelId = static_cast<uint32_t>(labelId);
}
}
if (resMgr != nullptr) {
auto errValue = resMgr->GetStringById(subProp.labelId, subProp.label);
@ -560,7 +565,10 @@ int32_t ImeInfoInquirer::ListInputMethodSubtype(const int32_t userId, const Exte
}
pos = subProp.icon.find(':');
if (pos != std::string::npos && pos + 1 < subProp.icon.size()) {
subProp.iconId = atoi(subProp.icon.substr(pos + 1).c_str());
int32_t iconId = atoi(subProp.icon.substr(pos + 1).c_str());
if (iconId > 0) {
subProp.iconId = static_cast<uint32_t>(iconId);
}
}
CovertToLanguage(subProp.locale, subProp.language);
subProps.emplace_back(subProp);
@ -568,19 +576,19 @@ int32_t ImeInfoInquirer::ListInputMethodSubtype(const int32_t userId, const Exte
return ErrorCode::NO_ERROR;
}
int32_t ImeInfoInquirer::ParseSubtype(
const OHOS::AppExecFwk::ExtensionAbilityInfo &extInfo, std::vector<Subtype> &subtypes)
int32_t ImeInfoInquirer::ParseSubtype(const OHOS::AppExecFwk::ExtensionAbilityInfo &extInfo,
std::vector<Subtype> &subtypes)
{
auto iter = std::find_if(extInfo.metadata.begin(), extInfo.metadata.end(),
[](const Metadata &metadata) { return metadata.name == SUBTYPE_PROFILE_METADATA_NAME; });
if (iter == extInfo.metadata.end()) {
IMSA_HILOGE("find metadata name: SUBTYPE_PROFILE_METADATA_NAME failed!");
IMSA_HILOGE("find metadata name: SUBTYPE_PROFILE_METADATA_NAME failed");
return ErrorCode::ERROR_BAD_PARAMETERS;
}
OHOS::AppExecFwk::BundleMgrClientImpl clientImpl;
std::vector<std::string> profiles;
if (!clientImpl.GetResConfigFile(extInfo, iter->name, profiles)) {
IMSA_HILOGE("failed to GetProfileFromExtension!");
IMSA_HILOGE("failed to GetProfileFromExtension ");
return ErrorCode::ERROR_PACKAGE_MANAGER;
}
SubtypeCfg subtypeCfg;
@ -932,18 +940,18 @@ std::shared_ptr<Property> ImeInfoInquirer::GetDefaultImeCfgProp()
std::shared_ptr<ResourceManager> ImeInfoInquirer::GetResMgr(const std::string &resourcePath)
{
if (resourcePath.empty()) {
IMSA_HILOGE("resourcePath is empty!");
IMSA_HILOGE("resourcePath is empty.");
return nullptr;
}
std::shared_ptr<ResourceManager> resMgr(CreateResourceManager());
if (resMgr == nullptr) {
IMSA_HILOGE("resMgr is nullptr!");
IMSA_HILOGE("resMgr is nullptr.");
return nullptr;
}
resMgr->AddResource(resourcePath.c_str());
std::unique_ptr<ResConfig> resConfig(CreateResConfig());
if (resConfig == nullptr) {
IMSA_HILOGE("resConfig is nullptr!");
IMSA_HILOGE("resConfig is nullptr.");
return nullptr;
}
std::map<std::string, std::string> configs;
@ -978,7 +986,7 @@ int32_t ImeInfoInquirer::QueryFullImeInfo(int32_t userId, std::vector<FullImeInf
std::vector<ExtensionAbilityInfo> extInfos;
auto ret = ImeInfoInquirer::GetInstance().QueryImeExtInfos(userId, extInfos);
if (!ret || extInfos.empty()) {
IMSA_HILOGE("%{public}d QueryImeExtInfos failed!", userId);
IMSA_HILOGE("%{public}d QueryImeExtInfos failed.", userId);
return ErrorCode::ERROR_PACKAGE_MANAGER;
}
std::map<std::string, std::vector<ExtensionAbilityInfo>> tempExtInfos;
@ -1034,7 +1042,7 @@ int32_t ImeInfoInquirer::GetFullImeInfo(
auto ret = imeInfo.isNewIme ? ListInputMethodSubtype(userId, extInfos[0], imeInfo.subProps)
: ListInputMethodSubtype(userId, extInfos, imeInfo.subProps);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("[%{public}d,%{public}s] list Subtype failed!", userId, extInfos[0].bundleName.c_str());
IMSA_HILOGE("[%{public}d,%{public}s] list Subtype failed.", userId, extInfos[0].bundleName.c_str());
return ret;
}
imeInfo.tokenId = extInfos[0].applicationInfo.accessTokenId;
@ -1069,7 +1077,7 @@ bool ImeInfoInquirer::IsInputMethod(int32_t userId, const std::string &bundleNam
}
return false;
}
bool ImeInfoInquirer::IsTempInputMethod(const ExtensionAbilityInfo &extInfo)
{
auto iter = std::find_if(extInfo.metadata.begin(), extInfo.metadata.end(),
@ -1160,11 +1168,8 @@ std::string ImeInfoInquirer::GetTargetString(
return GetStringById(extension.bundleName, extension.moduleName, extension.labelId, userId);
}
IMSA_HILOGD("Extension label is empty, get application label");
std::string label;
if (GetAppLabelFromRes(extension, label) != ErrorCode::NO_ERROR) {
IMSA_HILOGE("GetAppLabelFromRes failed");
}
return label;
return GetStringById(extension.bundleName, extension.applicationInfo.labelResource.moduleName,
extension.applicationInfo.labelResource.id, userId);
}
if (target == ImeTargetString::DESCRIPTION) {
if (extension.descriptionId != DEFAULT_BMS_VALUE) {
@ -1177,22 +1182,5 @@ std::string ImeInfoInquirer::GetTargetString(
IMSA_HILOGD("No match target string");
return "";
}
int32_t ImeInfoInquirer::GetAppLabelFromRes(const AppExecFwk::ExtensionAbilityInfo &extension, std::string &label)
{
std::string resPath = extension.hapPath.empty() ? extension.resourcePath : extension.hapPath;
auto resMgr = GetResMgr(resPath);
if (resMgr == nullptr) {
IMSA_HILOGE("failed to get resMgr");
return ErrorCode::NO_ERROR;
}
auto errValue = resMgr->GetStringById(extension.applicationInfo.labelId, label);
if (errValue != RState::SUCCESS) {
IMSA_HILOGE("GetStringById failed, bundleName:%{public}s, id:%{public}d", extension.bundleName.c_str(),
extension.applicationInfo.labelId);
return ErrorCode::ERROR_RES_ERROR;
}
return ErrorCode::NO_ERROR;
}
} // namespace MiscServices
} // namespace OHOS

View File

@ -48,15 +48,15 @@ int32_t InputControlChannelProxy::HideKeyboardSelf()
}
auto remote = Remote();
if (remote == nullptr) {
IMSA_HILOGE("remote is nullptr!");
IMSA_HILOGE("remote is nullptr");
return ErrorCode::ERROR_EX_NULL_POINTER;
}
auto ret = remote->SendRequest(HIDE_KEYBOARD_SELF, data, reply, option);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("send request failed!");
IMSA_HILOGE("send request failed");
return ErrorCode::ERROR_EX_PARCELABLE;
}
return reply.ReadInt32();
}
} // namespace MiscServices
} // namespace OHOS
} // namespace OHOS

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2021 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.
@ -41,7 +41,6 @@
#include "native_token_info.h"
#include "os_account_adapter.h"
#include "scene_board_judgement.h"
#include "system_ability.h"
#include "system_ability_definition.h"
#ifdef IMF_SCREENLOCK_MGR_ENABLE
#include "screenlock_manager.h"
@ -178,7 +177,7 @@ void InputMethodSystemAbility::InitServiceHandler()
{
IMSA_HILOGI("InitServiceHandler start.");
if (serviceHandler_ != nullptr) {
IMSA_HILOGE("InputMethodSystemAbility already init!");
IMSA_HILOGE("InputMethodSystemAbility already init.");
return;
}
std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create("OS_InputMethodSystemAbility");
@ -214,7 +213,7 @@ void InputMethodSystemAbility::SubscribeCommonEvent()
return;
}
IMSA_HILOGE("failed, try again 10s later!");
IMSA_HILOGE("failed, try again 10s later");
auto callback = [this]() { SubscribeCommonEvent(); };
serviceHandler_->PostTask(callback, INIT_INTERVAL);
}
@ -227,7 +226,7 @@ int32_t InputMethodSystemAbility::PrepareInput(int32_t userId, InputClientInfo &
}
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
return session->OnPrepareInput(clientInfo);
@ -264,11 +263,11 @@ int32_t InputMethodSystemAbility::ReleaseInput(sptr<IInputClient> client)
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
return session->OnReleaseInput(client);
};
}
int32_t InputMethodSystemAbility::StartInput(InputClientInfo &inputClientInfo, sptr<IRemoteObject> &agent)
{
@ -279,7 +278,7 @@ int32_t InputMethodSystemAbility::StartInput(InputClientInfo &inputClientInfo, s
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (session->GetCurrentClientPid() != IPCSkeleton::GetCallingPid()
@ -293,17 +292,17 @@ int32_t InputMethodSystemAbility::StartInput(InputClientInfo &inputClientInfo, s
if (!session->IsProxyImeEnable()) {
auto ret = CheckInputTypeOption(userId, inputClientInfo);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("%{public}d failed to CheckInputTypeOption!", userId);
IMSA_HILOGE("%{public}d failed to CheckInputTypeOption.", userId);
return ret;
}
}
int32_t ret = PrepareInput(userId, inputClientInfo);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("failed to PrepareInput!");
IMSA_HILOGE("failed to PrepareInput");
return ret;
}
return session->OnStartInput(inputClientInfo, agent);
};
}
int32_t InputMethodSystemAbility::CheckInputTypeOption(int32_t userId, InputClientInfo &inputClientInfo)
{
@ -336,7 +335,7 @@ int32_t InputMethodSystemAbility::CheckInputTypeOption(int32_t userId, InputClie
}
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (InputTypeManager::GetInstance().IsStarted()) {
@ -352,7 +351,7 @@ int32_t InputMethodSystemAbility::ShowInput(sptr<IInputClient> client)
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (!identityChecker_->IsBroker(tokenId)) {
@ -361,7 +360,7 @@ int32_t InputMethodSystemAbility::ShowInput(sptr<IInputClient> client)
}
}
if (client == nullptr) {
IMSA_HILOGE("client is nullptr!");
IMSA_HILOGE("client is nullptr");
return ErrorCode::ERROR_CLIENT_NULL_POINTER;
}
return session->OnShowInput(client);
@ -373,7 +372,7 @@ int32_t InputMethodSystemAbility::HideInput(sptr<IInputClient> client)
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (!identityChecker_->IsBroker(tokenId)) {
@ -382,11 +381,11 @@ int32_t InputMethodSystemAbility::HideInput(sptr<IInputClient> client)
}
}
if (client == nullptr) {
IMSA_HILOGE("client is nullptr!");
IMSA_HILOGE("client is nullptr");
return ErrorCode::ERROR_CLIENT_NULL_POINTER;
}
return session->OnHideInput(client);
};
}
int32_t InputMethodSystemAbility::StopInputSession()
{
@ -394,7 +393,7 @@ int32_t InputMethodSystemAbility::StopInputSession()
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (!identityChecker_->IsBroker(tokenId)) {
@ -415,7 +414,7 @@ int32_t InputMethodSystemAbility::RequestShowInput()
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
return session->OnRequestShowInput();
@ -431,7 +430,7 @@ int32_t InputMethodSystemAbility::RequestHideInput()
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
return session->OnRequestHideInput();
@ -443,7 +442,7 @@ int32_t InputMethodSystemAbility::SetCoreAndAgent(const sptr<IInputMethodCore> &
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (identityChecker_->IsNativeSa(IPCSkeleton::GetCallingTokenID())) {
@ -462,7 +461,7 @@ int32_t InputMethodSystemAbility::InitConnect()
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (!IsCurrentIme(userId)) {
@ -477,7 +476,7 @@ int32_t InputMethodSystemAbility::HideCurrentInput()
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (identityChecker_->IsBroker(tokenId)) {
@ -487,7 +486,7 @@ int32_t InputMethodSystemAbility::HideCurrentInput()
return ErrorCode::ERROR_STATUS_PERMISSION_DENIED;
}
return session->OnHideCurrentInput();
};
}
int32_t InputMethodSystemAbility::ShowCurrentInput()
{
@ -495,7 +494,7 @@ int32_t InputMethodSystemAbility::ShowCurrentInput()
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (identityChecker_->IsBroker(tokenId)) {
@ -505,7 +504,7 @@ int32_t InputMethodSystemAbility::ShowCurrentInput()
return ErrorCode::ERROR_STATUS_PERMISSION_DENIED;
}
return session->OnShowCurrentInput();
};
}
int32_t InputMethodSystemAbility::PanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info)
{
@ -521,7 +520,7 @@ int32_t InputMethodSystemAbility::PanelStatusChange(const InputWindowStatus &sta
}
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
return session->OnPanelStatusChange(status, info);
@ -531,9 +530,9 @@ int32_t InputMethodSystemAbility::UpdateListenEventFlag(InputClientInfo &clientI
{
IMSA_HILOGI("finalEventFlag: %{public}u, eventFlag: %{public}u.", clientInfo.eventFlag, eventFlag);
if (EventStatusManager::IsImeHideOn(eventFlag) || EventStatusManager::IsImeShowOn(eventFlag)) {
if (!identityChecker_->IsSystemApp(IPCSkeleton::GetCallingFullTokenID())
&& !identityChecker_->IsNativeSa(IPCSkeleton::GetCallingTokenID())) {
IMSA_HILOGE("not system application");
if (!identityChecker_->IsSystemApp(IPCSkeleton::GetCallingFullTokenID()) &&
!identityChecker_->IsNativeSa(IPCSkeleton::GetCallingTokenID())) {
IMSA_HILOGE("not system application!");
return ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION;
}
}
@ -544,7 +543,7 @@ int32_t InputMethodSystemAbility::UpdateListenEventFlag(InputClientInfo &clientI
}
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
return session->OnUpdateListenEventFlag(clientInfo);
@ -570,12 +569,12 @@ int32_t InputMethodSystemAbility::ExitCurrentInputType()
auto userId = GetCallingUserId();
auto ret = IsDefaultImeFromTokenId(userId, IPCSkeleton::GetCallingTokenID());
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("not default ime!");
return ret;
IMSA_HILOGE("not default ime.");
return ErrorCode::ERROR_NOT_DEFAULT_IME;
}
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (session->CheckSecurityMode()) {
@ -618,7 +617,7 @@ bool InputMethodSystemAbility::IsCurrentImeByPid(int32_t pid)
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return false;
}
return session->IsCurrentImeByPid(pid);
@ -633,7 +632,7 @@ int32_t InputMethodSystemAbility::IsPanelShown(const PanelInfo &panelInfo, bool
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
return session->IsPanelShown(panelInfo, isShown);
@ -657,7 +656,7 @@ int32_t InputMethodSystemAbility::SwitchInputMethod(
int32_t userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (enableImeOn_.load() && !EnableImeDataParser::GetInstance()->CheckNeedSwitch(switchInfo, userId)) {
@ -681,7 +680,7 @@ int32_t InputMethodSystemAbility::OnSwitchInputMethod(int32_t userId, const Swit
InputMethodSysEvent::GetInstance().RecordEvent(IMEBehaviour::CHANGE_IME);
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (!session->GetSwitchQueue().IsReady(switchInfo)) {
@ -736,13 +735,12 @@ void InputMethodSystemAbility::GetValidSubtype(const std::string &subName, const
}
}
int32_t InputMethodSystemAbility::OnStartInputType(int32_t userId, const SwitchInfo &switchInfo,
bool isCheckPermission)
{
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (!session->GetSwitchQueue().IsReady(switchInfo)) {
@ -777,7 +775,7 @@ bool InputMethodSystemAbility::IsNeedSwitch(int32_t userId, const std::string &b
currentImeCfg->bundleName.c_str(), currentImeCfg->subName.c_str(), bundleName.c_str(), subName.c_str());
if ((subName.empty() && bundleName == currentImeCfg->bundleName) ||
(!subName.empty() && subName == currentImeCfg->subName && currentImeCfg->bundleName == bundleName)) {
IMSA_HILOGI("no need to switch.");
IMSA_HILOGI("no need to switch");
return false;
}
return true;
@ -805,7 +803,7 @@ int32_t InputMethodSystemAbility::SwitchExtension(int32_t userId, const std::sha
{
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
std::string targetImeName = info->prop.name + "/" + info->prop.id;
@ -826,7 +824,7 @@ int32_t InputMethodSystemAbility::SwitchSubType(int32_t userId, const std::share
{
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
auto ret = session->SwitchSubtype(info->subProp);
@ -844,7 +842,7 @@ int32_t InputMethodSystemAbility::SwitchInputType(int32_t userId, const SwitchIn
{
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
auto targetIme = session->GetImeNativeCfg(userId, switchInfo.bundleName, switchInfo.subName);
@ -873,7 +871,7 @@ int32_t InputMethodSystemAbility::HideCurrentInputDeprecated()
int32_t userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (!identityChecker_->IsBroker(tokenId)) {
@ -882,7 +880,7 @@ int32_t InputMethodSystemAbility::HideCurrentInputDeprecated()
}
}
return session->OnHideCurrentInput();
};
}
int32_t InputMethodSystemAbility::ShowCurrentInputDeprecated()
{
@ -890,7 +888,7 @@ int32_t InputMethodSystemAbility::ShowCurrentInputDeprecated()
int32_t userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (!identityChecker_->IsBroker(tokenId)) {
@ -899,7 +897,7 @@ int32_t InputMethodSystemAbility::ShowCurrentInputDeprecated()
}
}
return session->OnShowCurrentInput();
};
}
std::shared_ptr<Property> InputMethodSystemAbility::GetCurrentInputMethod()
{
@ -1001,7 +999,7 @@ void InputMethodSystemAbility::WorkThread()
int32_t InputMethodSystemAbility::OnUserStarted(const Message *msg)
{
if (msg->msgContent_ == nullptr) {
IMSA_HILOGE("msgContent_ is nullptr!");
IMSA_HILOGE("msgContent_ is nullptr.");
return ErrorCode::ERROR_NULL_POINTER;
}
auto newUserId = msg->msgContent_->ReadInt32();
@ -1020,7 +1018,7 @@ int32_t InputMethodSystemAbility::OnUserStarted(const Message *msg)
int32_t InputMethodSystemAbility::OnUserRemoved(const Message *msg)
{
if (msg == nullptr || msg->msgContent_ == nullptr) {
IMSA_HILOGE("Aborted! Message is nullptr!");
IMSA_HILOGE("Aborted! Message is nullptr.");
return ErrorCode::ERROR_NULL_POINTER;
}
auto userId = msg->msgContent_->ReadInt32();
@ -1038,13 +1036,13 @@ int32_t InputMethodSystemAbility::OnUserRemoved(const Message *msg)
int32_t InputMethodSystemAbility::OnUserStop(const Message *msg)
{
if (msg == nullptr || msg->msgContent_ == nullptr) {
IMSA_HILOGE("Aborted! Message is nullptr!");
IMSA_HILOGE("Aborted! Message is nullptr.");
return ErrorCode::ERROR_NULL_POINTER;
}
auto userId = msg->msgContent_->ReadInt32();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
session->StopCurrentIme();
@ -1054,13 +1052,13 @@ int32_t InputMethodSystemAbility::OnUserStop(const Message *msg)
int32_t InputMethodSystemAbility::OnHideKeyboardSelf(const Message *msg)
{
if (msg == nullptr || msg->msgContent_ == nullptr) {
IMSA_HILOGE("Aborted! Message is nullptr!");
IMSA_HILOGE("Aborted! Message is nullptr.");
return ErrorCode::ERROR_NULL_POINTER;
}
auto userId = msg->msgContent_->ReadInt32();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
session->OnHideSoftKeyBoardSelf();
@ -1071,13 +1069,13 @@ int32_t InputMethodSystemAbility::HandlePackageEvent(const Message *msg)
{
MessageParcel *data = msg->msgContent_;
if (data == nullptr) {
IMSA_HILOGD("data is nullptr");
IMSA_HILOGD("data is nullptr.");
return ErrorCode::ERROR_NULL_POINTER;
}
int32_t userId = 0;
std::string packageName;
if (!ITypesUtil::Unmarshal(*data, userId, packageName)) {
IMSA_HILOGE("Failed to read message parcel!");
IMSA_HILOGE("failed to read message parcel");
return ErrorCode::ERROR_EX_PARCELABLE;
}
if (msg->msgId_ == MSG_ID_PACKAGE_CHANGED) {
@ -1165,7 +1163,7 @@ int32_t InputMethodSystemAbility::SwitchByCombinationKey(uint32_t state)
IMSA_HILOGD("InputMethodSystemAbility::SwitchByCombinationKey start.");
auto session = UserSessionManager::GetInstance().GetUserSession(userId_);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId_);
IMSA_HILOGE("%{public}d session is nullptr", userId_);
return ErrorCode::ERROR_NULL_POINTER;
}
if (session->IsProxyImeEnable()) {
@ -1192,7 +1190,7 @@ int32_t InputMethodSystemAbility::SwitchByCombinationKey(uint32_t state)
DealSwitchRequest();
return ErrorCode::NO_ERROR;
}
IMSA_HILOGE("keycode is undefined!");
IMSA_HILOGE("keycode is undefined");
return ErrorCode::ERROR_EX_UNSUPPORTED_OPERATION;
}
@ -1279,7 +1277,7 @@ int32_t InputMethodSystemAbility::SwitchMode()
SwitchInfo switchInfo = { std::chrono::system_clock::now(), target->name, target->id };
auto session = UserSessionManager::GetInstance().GetUserSession(userId_);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId_);
IMSA_HILOGE("%{public}d session is nullptr", userId_);
return ErrorCode::ERROR_NULL_POINTER;
}
session->GetSwitchQueue().Push(switchInfo);
@ -1311,7 +1309,7 @@ int32_t InputMethodSystemAbility::SwitchLanguage()
SwitchInfo switchInfo = { std::chrono::system_clock::now(), target->name, target->id };
auto session = UserSessionManager::GetInstance().GetUserSession(userId_);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId_);
IMSA_HILOGE("%{public}d session is nullptr", userId_);
return ErrorCode::ERROR_NULL_POINTER;
}
session->GetSwitchQueue().Push(switchInfo);
@ -1336,7 +1334,7 @@ int32_t InputMethodSystemAbility::SwitchType()
switchInfo.timestamp = std::chrono::system_clock::now();
auto session = UserSessionManager::GetInstance().GetUserSession(userId_);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId_);
IMSA_HILOGE("%{public}d session is nullptr", userId_);
return ErrorCode::ERROR_NULL_POINTER;
}
session->GetSwitchQueue().Push(switchInfo);
@ -1370,10 +1368,10 @@ void InputMethodSystemAbility::InitMonitors()
int32_t InputMethodSystemAbility::RegisterDataShareObserver()
{
IMSA_HILOGD("start.");
if (enableImeOn_) {
if (ImeInfoInquirer::GetInstance().IsEnableInputMethod()) {
RegisterEnableImeObserver();
}
if (enableSecurityMode_) {
if (ImeInfoInquirer::GetInstance().IsEnableSecurityMode()) {
RegisterSecurityModeObserver();
}
return ErrorCode::NO_ERROR;
@ -1424,18 +1422,18 @@ void InputMethodSystemAbility::InitFocusChangedMonitor()
void InputMethodSystemAbility::RegisterEnableImeObserver()
{
int32_t ret = SettingsDataUtils::GetInstance()->CreateAndRegisterObserver(
EnableImeDataParser::ENABLE_IME, [this]() { DatashareCallback(EnableImeDataParser::ENABLE_IME); });
int32_t ret = SettingsDataUtils::GetInstance()->CreateAndRegisterObserver(EnableImeDataParser::ENABLE_IME,
[this]() { DatashareCallback(EnableImeDataParser::ENABLE_IME); });
IMSA_HILOGI("register enable ime observer, ret: %{public}d.", ret);
ret = SettingsDataUtils::GetInstance()->CreateAndRegisterObserver(
EnableImeDataParser::ENABLE_KEYBOARD, [this]() { DatashareCallback(EnableImeDataParser::ENABLE_KEYBOARD); });
ret = SettingsDataUtils::GetInstance()->CreateAndRegisterObserver(EnableImeDataParser::ENABLE_KEYBOARD,
[this]() { DatashareCallback(EnableImeDataParser::ENABLE_KEYBOARD); });
IMSA_HILOGI("register enable keyboard observer, ret: %{public}d.", ret);
}
void InputMethodSystemAbility::RegisterSecurityModeObserver()
{
int32_t ret = SettingsDataUtils::GetInstance()->CreateAndRegisterObserver(
SecurityModeParser::SECURITY_MODE, [this]() { DatashareCallback(SecurityModeParser::SECURITY_MODE); });
int32_t ret = SettingsDataUtils::GetInstance()->CreateAndRegisterObserver(SecurityModeParser::SECURITY_MODE,
[this]() { DatashareCallback(SecurityModeParser::SECURITY_MODE); });
IMSA_HILOGI("register security mode observer, ret: %{public}d", ret);
}
@ -1480,7 +1478,7 @@ void InputMethodSystemAbility::OnSecurityModeChange()
static_cast<int32_t>(newMode));
auto session = UserSessionManager::GetInstance().GetUserSession(userId_);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId_);
IMSA_HILOGE("%{public}d session is nullptr", userId_);
return;
}
session->OnSecurityChange(static_cast<int32_t>(newMode));
@ -1514,7 +1512,7 @@ int32_t InputMethodSystemAbility::UnRegisteredProxyIme(UnRegisteredType type, co
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
if (type == UnRegisteredType::SWITCH_PROXY_IME_TO_IME) {
@ -1544,7 +1542,7 @@ int32_t InputMethodSystemAbility::CheckSwitchPermission(int32_t userId, const Sw
return ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION;
}
if (!identityChecker_->HasPermission(IPCSkeleton::GetCallingTokenID(), PERMISSION_CONNECT_IME_ABILITY)) {
IMSA_HILOGE("have not PERMISSION_CONNECT_IME_ABILITY!");
IMSA_HILOGE("have not PERMISSION_CONNECT_IME_ABILITY");
return ErrorCode::ERROR_STATUS_PERMISSION_DENIED;
}
return ErrorCode::NO_ERROR;
@ -1554,7 +1552,7 @@ int32_t InputMethodSystemAbility::CheckSwitchPermission(int32_t userId, const Sw
if (identityChecker_->HasPermission(IPCSkeleton::GetCallingTokenID(), PERMISSION_CONNECT_IME_ABILITY)) {
return ErrorCode::NO_ERROR;
}
IMSA_HILOGE("have not PERMISSION_CONNECT_IME_ABILITY!");
IMSA_HILOGE("have not PERMISSION_CONNECT_IME_ABILITY");
// switchInfo.subName.empty() check temporarily reserved for application adaptation, will be deleted soon
auto currentBundleName = ImeCfgManager::GetInstance().GetCurrentImeCfg(userId)->bundleName;
if (identityChecker_->IsBundleNameValid(IPCSkeleton::GetCallingTokenID(), currentBundleName) &&
@ -1585,7 +1583,7 @@ bool InputMethodSystemAbility::IsStartInputTypePermitted(int32_t userId)
}
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return false;
}
return identityChecker_->IsFocused(IPCSkeleton::GetCallingPid(), tokenId) && session->IsBoundToClient();
@ -1595,13 +1593,13 @@ int32_t InputMethodSystemAbility::ConnectSystemCmd(const sptr<IRemoteObject> &ch
{
auto tokenId = IPCSkeleton::GetCallingTokenID();
if (!identityChecker_->HasPermission(tokenId, PERMISSION_CONNECT_IME_ABILITY)) {
IMSA_HILOGE("have not PERMISSION_CONNECT_IME_ABILITY!");
IMSA_HILOGE("have not PERMISSION_CONNECT_IME_ABILITY");
return ErrorCode::ERROR_STATUS_SYSTEM_PERMISSION;
}
auto userId = GetCallingUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("have not PERMISSION_CONNECT_IME_ABILITY");
return ErrorCode::ERROR_NULL_POINTER;
}
return session->OnConnectSystemCmd(channel, agent);
@ -1626,7 +1624,7 @@ void InputMethodSystemAbility::HandleScbStarted(int32_t userId, int32_t screenId
}
session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return;
}
session->AddRestartIme();
@ -1641,7 +1639,7 @@ void InputMethodSystemAbility::HandleUserSwitched(int32_t userId)
}
session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return;
}
auto imeData = session->GetReadyImeData(ImeType::IME);
@ -1689,7 +1687,7 @@ void InputMethodSystemAbility::HandleWmsStarted()
}
session = UserSessionManager::GetInstance().GetUserSession(userId_);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId_);
IMSA_HILOGE("%{public}d session is nullptr", userId_);
return;
}
session->AddRestartIme();
@ -1701,7 +1699,7 @@ void InputMethodSystemAbility::HandleFocusChanged(bool isFocused, int32_t pid, i
int32_t userId = GetUserId(uid);
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("[%{public}d, %{public}d] session is nullptr!", uid, userId);
IMSA_HILOGE("[%{public}d, %{public}d] session is nullptr", uid, userId);
return;
}
isFocused ? session->OnFocused(pid, uid) : session->OnUnfocused(pid, uid);
@ -1718,7 +1716,7 @@ void InputMethodSystemAbility::HandleMemStarted()
}
session = UserSessionManager::GetInstance().GetUserSession(userId_);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId_);
IMSA_HILOGE("%{public}d session is nullptr", userId_);
return;
}
session->AddRestartIme();
@ -1773,7 +1771,7 @@ bool InputMethodSystemAbility::IsCurrentIme(int32_t userId)
{
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return false;
}
auto bundleName = FullImeInfoManager::GetInstance().Get(userId, IPCSkeleton::GetCallingTokenID());
@ -1789,7 +1787,7 @@ int32_t InputMethodSystemAbility::StartInputType(int32_t userId, InputType type)
{
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
IMSA_HILOGE("%{public}d session is nullptr!", userId);
IMSA_HILOGE("%{public}d session is nullptr", userId);
return ErrorCode::ERROR_NULL_POINTER;
}
ImeIdentification ime;
@ -1818,8 +1816,7 @@ void InputMethodSystemAbility::NeedHideWhenSwitchInputType(int32_t userId, bool
IMSA_HILOGI("currentImeCfg is nullptr");
return;
}
// same ime, need hide panel first.
needHide = currentImeCfg->bundleName == ime.bundleName;
}
} // namespace MiscServices
} // namespace OHOS
} // namespace OHOS

View File

@ -223,7 +223,7 @@ int32_t InputMethodSystemAbilityStub::GetCurrentInputMethodSubtypeOnRemote(Messa
: ErrorCode::ERROR_EX_PARCELABLE;
}
if (!ITypesUtil::Marshal(reply, ErrorCode::NO_ERROR, *property)) {
IMSA_HILOGE("marshal failed!");
IMSA_HILOGE("marshal failed");
return ErrorCode::ERROR_EX_PARCELABLE;
}
return ErrorCode::NO_ERROR;
@ -239,7 +239,7 @@ int32_t InputMethodSystemAbilityStub::ListInputMethodOnRemote(MessageParcel &dat
std::vector<Property> properties = {};
auto ret = ListInputMethod(InputMethodStatus(status), properties);
if (!ITypesUtil::Marshal(reply, ret, properties)) {
IMSA_HILOGE("marshal failed!");
IMSA_HILOGE("marshal failed");
return ErrorCode::ERROR_EX_PARCELABLE;
}
return ErrorCode::NO_ERROR;
@ -413,4 +413,4 @@ int32_t InputMethodSystemAbilityStub::InitConnectOnRemote(MessageParcel &data, M
return reply.WriteInt32(InitConnect()) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
}
} // namespace MiscServices
} // namespace OHOS
} // namespace OHOS

View File

@ -96,7 +96,7 @@ bool InputTypeManager::IsSecurityImeStarted()
if (!IsStarted()) {
return false;
}
std::lock_guard<std::mutex> lock(typesLock_);
return inputTypes_.find(InputType::SECURITY_INPUT) != inputTypes_.end() &&
inputTypes_[InputType::SECURITY_INPUT] == GetCurrentIme();
@ -107,7 +107,7 @@ bool InputTypeManager::IsCameraImeStarted()
if (!IsStarted()) {
return false;
}
std::lock_guard<std::mutex> lock(typesLock_);
return inputTypes_.find(InputType::CAMERA_INPUT) != inputTypes_.end() &&
inputTypes_[InputType::CAMERA_INPUT] == GetCurrentIme();
@ -128,7 +128,7 @@ bool InputTypeManager::IsVoiceImeStarted()
return inputTypes_.find(InputType::VOICE_INPUT) != inputTypes_.end() &&
inputTypes_[InputType::VOICE_INPUT] == currentTypeIme_;
}
InputType InputTypeManager::GetCurrentInputType()
{
if (IsSecurityImeStarted()) {

View File

@ -235,15 +235,22 @@ void PerUserSession::OnClientDied(sptr<IInputClient> remote)
if (remote == nullptr) {
return;
}
auto clientInfo = GetClientInfo(remote->AsObject());
IMSA_HILOGI("userId: %{public}d.", userId_);
if (IsSameClient(remote, GetCurrentClient())) {
auto clientInfo = GetClientInfo(remote->AsObject());
if (clientInfo != nullptr) {
StopImeInput(clientInfo->bindImeType, clientInfo->channel);
}
SetCurrentClient(nullptr);
RestoreCurrentImeSubType();
}
if (IsSameClient(remote, GetInactiveClient())) {
if (clientInfo != nullptr) {
StopImeInput(clientInfo->bindImeType, clientInfo->channel);
}
SetInactiveClient(nullptr);
RestoreCurrentImeSubType();
}
RemoveClientInfo(remote->AsObject(), true);
}
@ -624,8 +631,8 @@ void PerUserSession::StopImeInput(ImeType currentType, const sptr<IRemoteObject>
if (data == nullptr) {
return;
}
auto ret = RequestIme(
data, RequestType::STOP_INPUT, [&data, &currentChannel]() { return data->core->StopInput(currentChannel); });
auto ret = RequestIme(data, RequestType::STOP_INPUT,
[&data, &currentChannel]() { return data->core->StopInput(currentChannel); });
IMSA_HILOGI("stop ime input, ret: %{public}d.", ret);
if (ret == ErrorCode::NO_ERROR && currentType == ImeType::IME) {
InputMethodSysEvent::GetInstance().ReportImeState(
@ -641,7 +648,7 @@ void PerUserSession::OnSecurityChange(int32_t security)
{
auto data = GetReadyImeData(ImeType::IME);
if (data == nullptr) {
IMSA_HILOGE("ime: %{public}d is not exist", ImeType::IME);
IMSA_HILOGE("ime: %{public}d is not exist!", ImeType::IME);
return;
}
auto ret =
@ -952,8 +959,8 @@ bool PerUserSession::IsCurClientFocused(int32_t pid, int32_t uid)
return false;
}
auto identityChecker = std::make_shared<IdentityCheckerImpl>();
if (clientInfo->uiExtensionTokenId != IMF_INVALID_TOKENID
&& identityChecker->IsFocusedUIExtension(clientInfo->uiExtensionTokenId)) {
if (clientInfo->uiExtensionTokenId != IMF_INVALID_TOKENID &&
identityChecker->IsFocusedUIExtension(clientInfo->uiExtensionTokenId)) {
IMSA_HILOGI("UIExtension focused");
return true;
}
@ -968,9 +975,9 @@ bool PerUserSession::IsCurClientUnFocused(int32_t pid, int32_t uid)
return false;
}
auto identityChecker = std::make_shared<IdentityCheckerImpl>();
if (clientInfo->uiExtensionTokenId != IMF_INVALID_TOKENID
&& !identityChecker->IsFocusedUIExtension(clientInfo->uiExtensionTokenId)) {
IMSA_HILOGI("UIExtension UnFocused");
if (clientInfo->uiExtensionTokenId != IMF_INVALID_TOKENID &&
!identityChecker->IsFocusedUIExtension(clientInfo->uiExtensionTokenId)) {
IMSA_HILOGI("UIExtension UnFocused.");
return true;
}
return clientInfo->pid == pid && clientInfo->uid == uid;
@ -1016,7 +1023,7 @@ bool PerUserSession::GetCurrentUsingImeId(ImeIdentification &imeId)
}
auto currentImeCfg = ImeCfgManager::GetInstance().GetCurrentImeCfg(userId_);
if (currentImeCfg == nullptr) {
IMSA_HILOGE("currentImeCfg is nullptr!");
IMSA_HILOGE("currentImeCfg is nullptr");
return false;
}
imeId.bundleName = currentImeCfg->bundleName;
@ -1060,8 +1067,8 @@ bool PerUserSession::StartInputService(const std::shared_ptr<ImeNativeCfg> &ime)
auto ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectExtensionAbility(want, connection, userId_);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("connect %{public}s failed, ret: %{public}d!", ime->imeId.c_str(), ret);
InputMethodSysEvent::GetInstance().InputmethodFaultReporter(
ErrorCode::ERROR_IME_START_FAILED, ime->imeId, "StartInputService, failed to start ability.");
InputMethodSysEvent::GetInstance().InputmethodFaultReporter(ErrorCode::ERROR_IME_START_FAILED, ime->imeId,
"failed to start ability.");
return false;
}
InitImeData({ ime->bundleName, ime->extName });
@ -1131,7 +1138,7 @@ int32_t PerUserSession::OnUpdateListenEventFlag(const InputClientInfo &clientInf
auto remoteClient = clientInfo.client->AsObject();
auto ret = AddClientInfo(remoteClient, clientInfo, START_LISTENING);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("failed to AddClientInfo!");
IMSA_HILOGE("failed to AddClientInfo");
return ret;
}
auto info = GetClientInfo(remoteClient);
@ -1225,7 +1232,7 @@ bool PerUserSession::IsCurrentImeByPid(int32_t pid)
int32_t PerUserSession::IsPanelShown(const PanelInfo &panelInfo, bool &isShown)
{
if (GetCurrentClient() == nullptr) {
IMSA_HILOGD("not in bound state.");
IMSA_HILOGI("not in bound state.");
isShown = false;
return ErrorCode::NO_ERROR;
}
@ -1261,7 +1268,7 @@ int32_t PerUserSession::RequestIme(const std::shared_ptr<ImeData> &data, Request
return exec();
}
if (data == nullptr || data->freezeMgr == nullptr) {
IMSA_HILOGE("data is nullptr!");
IMSA_HILOGE("data is nullptr");
return ErrorCode::NO_ERROR;
}
if (!data->freezeMgr->IsIpcNeeded(type)) {
@ -1311,7 +1318,7 @@ int32_t PerUserSession::RemoveCurrentClient()
{
auto currentClient = GetCurrentClient();
if (currentClient == nullptr) {
IMSA_HILOGE("currentClient is nullptr!");
IMSA_HILOGE("currentClient is nullptr");
return ErrorCode::ERROR_CLIENT_NULL_POINTER;
}
return RemoveClient(currentClient, false);
@ -1336,7 +1343,7 @@ bool PerUserSession::IsReady(int32_t saId)
if (saMgr->CheckSystemAbility(saId) == nullptr) {
IMSA_HILOGE("sa:%{public}d not ready!", saId);
return false;
};
}
return true;
}
@ -1575,7 +1582,7 @@ bool PerUserSession::StopReadyCurrentIme()
return true;
}
if (imeData->core == nullptr) {
IMSA_HILOGE("core is nullptr!");
IMSA_HILOGE("core is nullptr.");
return ForceStopCurrentIme();
}
auto ret = RequestIme(imeData, RequestType::NORMAL, [&imeData] {
@ -1727,4 +1734,4 @@ bool PerUserSession::CheckInputTypeToStart(std::shared_ptr<ImeNativeCfg> &imeToS
return true;
}
} // namespace MiscServices
} // namespace OHOS
} // namespace OHOS