增加校验

Signed-off-by: cy7717 <chenyu301@huawei.com>
This commit is contained in:
cy7717 2024-09-03 16:00:52 +08:00
parent 18f7332bd1
commit 5fb5c9b3e7
5 changed files with 19 additions and 11 deletions

View File

@ -1352,7 +1352,7 @@ void PerUserSession::AddRestartIme()
bool PerUserSession::RestartIme()
{
auto task = [this]() {
if (IsReady(MEMORY_MANAGER_SA_ID) && IsWmsReady()) {
if (IsReady(MEMORY_MANAGER_SA_ID) && IsWmsReady() && runningIme_.empty()) {
auto ret = StartCurrentIme(true);
if (!ret) {
IMSA_HILOGE("start ime failed");

View File

@ -30,6 +30,7 @@ config("inputmethod_tdd_util_public_config") {
include_dirs = [
"include",
"${bundllemanager_path}/interfaces/inner_api/appexecfwk_core/include/bundlemgr",
"${inputmethod_path}/frameworks/native/inputmethod_ability/include",
"${inputmethod_path}/services/adapter/settings_data_provider/common/include",
]
}
@ -48,6 +49,7 @@ ohos_static_library("inputmethod_tdd_util") {
configs = [ ":inputmethod_tdd_util_config" ]
public_configs = [ ":inputmethod_tdd_util_public_config" ]
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",
"//third_party/cJSON:cjson",

View File

@ -21,6 +21,7 @@
#include "block_data.h"
#include "bundle_mgr_interface.h"
#include "foundation/window/window_manager/interfaces/innerkits/wm/window.h"
#include "input_method_ability.h"
#include "window_manager.h"
#include "window_option.h"
#include "wm_common.h"
@ -39,9 +40,6 @@ public:
};
class TddUtil {
public:
static const constexpr char *CURRENT_BUNDLENAME = "";
static const constexpr char *CURRENT_EXTNAME = "imeExtName";
static const constexpr char *CURRENT_SUBNAME = "imeSubName";
static int32_t GetCurrentUserId();
static void StorageSelfTokenID();
static uint64_t AllocTestTokenID(
@ -63,7 +61,7 @@ public:
static void DestroyWindow();
static bool GetFocused();
static bool GetUnfocused();
static void InitCurrentImePermissionInfo();
static void SetCoreAndAgent(const sptr<InputMethodAbility> &ima);
class WindowManager {
public:
static void CreateWindow();

View File

@ -32,6 +32,7 @@
#include "datashare_helper.h"
#include "global.h"
#include "if_system_ability_manager.h"
#include "input_method_controller.h"
#include "iservice_registry.h"
#include "nativetoken_kit.h"
#include "os_account_manager.h"
@ -366,8 +367,14 @@ bool TddUtil::GetUnfocused()
return unFocused;
}
void TddUtil::InitCurrentImePermissionInfo()
void TddUtil::SetCoreAndAgent(const sptr<InputMethodAbility> &ima)
{
std::shared_ptr<Property> property = nullptr;
InputMethodController::GetInstance()->GetDefaultInputMethod(property);
if (property == nullptr) {
IMSA_HILOGI("default ime is nullptr.");
return;
}
auto userId = GetCurrentUserId();
auto session = UserSessionManager::GetInstance().GetUserSession(userId);
if (session == nullptr) {
@ -378,9 +385,11 @@ void TddUtil::InitCurrentImePermissionInfo()
IMSA_HILOGE("session is nullptr.");
return;
}
session->InitImeData({ CURRENT_BUNDLENAME, CURRENT_EXTNAME });
ImeCfgManager::GetInstance().imeConfigs_ = { { userId,
std::string(CURRENT_BUNDLENAME) + "/" + std::string(CURRENT_EXTNAME), CURRENT_SUBNAME } };
auto defaultImeTokenId = TddUtil::GetTestTokenID(property->name);
AccessScope scope(defaultImeTokenId, 0);
session->InitImeData({ property->name, property->id });
ImeCfgManager::GetInstance().imeConfigs_ = { { userId, property->name + "/" + property->id, "" } };
ima->SetCoreAndAgent();
}
void TddUtil::WindowManager::CreateWindow()

View File

@ -140,8 +140,7 @@ public:
inputMethodAbility_ = InputMethodAbility::GetInstance();
inputMethodAbility_->abilityManager_ = imsaProxy_;
TddUtil::InitCurrentImePermissionInfo();
inputMethodAbility_->SetCoreAndAgent();
TddUtil::SetCoreAndAgent(inputMethodAbility_);
TaskManager::GetInstance().SetInited(true);
TextListener::ResetParam();