mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-28 01:10:38 +00:00
modify switch
Signed-off-by: zhaolinglan <zhaolinglan@huawei.com>
This commit is contained in:
parent
5834ba33ed
commit
e4375fe53b
@ -191,6 +191,7 @@ void InputMethodAbility::WorkThread()
|
||||
if (imeListener_ != nullptr) {
|
||||
imeListener_->OnInputStop(imeId);
|
||||
}
|
||||
isBound_.store(false);
|
||||
break;
|
||||
}
|
||||
case MSG_ID_SET_SUBTYPE: {
|
||||
|
@ -370,14 +370,6 @@ int32_t InputMethodSystemAbility::SwitchInputMethod(const std::string &bundleNam
|
||||
{
|
||||
SwitchInfo switchInfo = { std::chrono::system_clock::now(), bundleName, subName };
|
||||
PushToSwitchQueue(switchInfo);
|
||||
|
||||
auto currentIme = ImeCfgManager::GetInstance().GetCurrentImeCfg(userId_)->bundleName;
|
||||
// if currentIme is switching subtype, permission verification is not performed.
|
||||
if (!BundleChecker::CheckPermission(IPCSkeleton::GetCallingTokenID(), PERMISSION_CONNECT_IME_ABILITY)
|
||||
&& !(bundleName == currentIme && BundleChecker::IsCurrentIme(IPCSkeleton::GetCallingTokenID(), currentIme))) {
|
||||
PopSwitchQueue();
|
||||
return ErrorCode::ERROR_STATUS_PERMISSION_DENIED;
|
||||
}
|
||||
return OnSwitchInputMethod(switchInfo);
|
||||
}
|
||||
|
||||
@ -391,6 +383,14 @@ int32_t InputMethodSystemAbility::OnSwitchInputMethod(const SwitchInfo &switchIn
|
||||
usleep(SWITCH_BLOCK_TIME);
|
||||
}
|
||||
IMSA_HILOGD("start switch %{public}s", (switchInfo.bundleName + '/' + switchInfo.subName).c_str());
|
||||
// if currentIme is switching subtype, permission verification is not performed.
|
||||
auto currentIme = ImeCfgManager::GetInstance().GetCurrentImeCfg(userId_)->bundleName;
|
||||
if (!BundleChecker::CheckPermission(IPCSkeleton::GetCallingTokenID(), PERMISSION_CONNECT_IME_ABILITY)
|
||||
&& !(switchInfo.bundleName == currentIme
|
||||
&& BundleChecker::IsCurrentIme(IPCSkeleton::GetCallingTokenID(), currentIme))) {
|
||||
PopSwitchQueue();
|
||||
return ErrorCode::ERROR_STATUS_PERMISSION_DENIED;
|
||||
}
|
||||
if (!IsNeedSwitch(switchInfo.bundleName, switchInfo.subName)) {
|
||||
PopSwitchQueue();
|
||||
return ErrorCode::NO_ERROR;
|
||||
|
@ -231,28 +231,6 @@ HWTEST_F(InputMethodSwitchTest, testSubTypeSwitch_002, TestSize.Level0)
|
||||
CheckCurrentSubProps();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testSubTypeSwitch_003
|
||||
* @tc.desc: switch subtype with extName1
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issuesI62BHB
|
||||
* @tc.author: chenyu
|
||||
*/
|
||||
HWTEST_F(InputMethodSwitchTest, testSubTypeSwitch_003, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("oldIme testSubTypeSwitch_002 Test START");
|
||||
std::unique_lock<std::mutex> lock(imeChangeFlagLock);
|
||||
imeChangeFlag = false;
|
||||
int32_t ret = imc_->SwitchInputMethod(bundleName, extName[0]);
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
conditionVar.wait_for(
|
||||
lock, std::chrono::milliseconds(SUBTYPE_SWITCH_DELAY_TIME), [] { return imeChangeFlag == true; });
|
||||
EXPECT_TRUE(imeChangeFlag);
|
||||
CheckCurrentProp(extName[0]);
|
||||
CheckCurrentSubProp(extName[0]);
|
||||
CheckCurrentSubProps();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testSubTypeSwitchWithErrorSubName
|
||||
* @tc.desc: switch subtype with error subName.
|
||||
|
Loading…
Reference in New Issue
Block a user