modify switch

Signed-off-by: zhaolinglan <zhaolinglan@huawei.com>
This commit is contained in:
zhaolinglan 2023-05-24 00:09:34 +08:00
parent 5834ba33ed
commit e4375fe53b
3 changed files with 9 additions and 30 deletions

View File

@ -191,6 +191,7 @@ void InputMethodAbility::WorkThread()
if (imeListener_ != nullptr) {
imeListener_->OnInputStop(imeId);
}
isBound_.store(false);
break;
}
case MSG_ID_SET_SUBTYPE: {

View File

@ -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;

View File

@ -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.