!932 修改xts中切换输入法失败问题

Merge pull request !932 from guojin31/master
This commit is contained in:
openharmony_ci 2023-10-23 14:26:57 +00:00 committed by Gitee
commit d2db8dbf63
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 5 additions and 18 deletions

View File

@ -942,20 +942,9 @@ bool InputMethodSystemAbility::IsSwitchPermitted(const SwitchInfo& switchInfo)
{
auto currentBundleName = ImeCfgManager::GetInstance().GetCurrentImeCfg(userId_)->bundleName;
// if currentIme is switching subtype, permission verification is not performed.
if (identityChecker_->IsBundleNameValid(IPCSkeleton::GetCallingTokenID(), currentBundleName) &&
switchInfo.bundleName == currentBundleName && !switchInfo.subName.empty()) {
return true;
}
if (!identityChecker_->HasPermission(IPCSkeleton::GetCallingTokenID(), PERMISSION_CONNECT_IME_ABILITY)) {
InputMethodSysEvent::GetInstance().InputmethodFaultReporter(
ErrorCode::ERROR_STATUS_PERMISSION_DENIED, switchInfo.bundleName, "switch inputmethod failed!");
return false;
}
if (switchInfo.subName.empty()) {
return true;
}
if (identityChecker_->IsSystemApp(IPCSkeleton::GetCallingFullTokenID()) ||
identityChecker_->IsBundleNameValid(IPCSkeleton::GetCallingTokenID(), currentBundleName)) {
if (identityChecker_->HasPermission(IPCSkeleton::GetCallingTokenID(), PERMISSION_CONNECT_IME_ABILITY) ||
(identityChecker_->IsBundleNameValid(IPCSkeleton::GetCallingTokenID(), currentBundleName) &&
!switchInfo.subName.empty())) {
return true;
}
InputMethodSysEvent::GetInstance().InputmethodFaultReporter(ErrorCode::ERROR_STATUS_PERMISSION_DENIED,

View File

@ -727,6 +727,7 @@ HWTEST_F(IdentityCheckerTest, testSwitchInputMethod_001, TestSize.Level0)
HWTEST_F(IdentityCheckerTest, testSwitchInputMethod_002, TestSize.Level0)
{
IMSA_HILOGI("IdentityCheckerTest testSwitchInputMethod_002 start");
EXPECT_CALL(*IdentityCheckerTest::identityCheckerMock_, HasPermission(_, _)).Times(1).WillRepeatedly(Return(false));
EXPECT_CALL(*IdentityCheckerTest::identityCheckerMock_, IsBundleNameValid(_, _))
.Times(1)
.WillRepeatedly(Return(true));
@ -744,11 +745,8 @@ HWTEST_F(IdentityCheckerTest, testSwitchInputMethod_002, TestSize.Level0)
HWTEST_F(IdentityCheckerTest, testSwitchInputMethod_003, TestSize.Level0)
{
IMSA_HILOGI("IdentityCheckerTest testSwitchInputMethod_003 start");
EXPECT_CALL(*IdentityCheckerTest::identityCheckerMock_, IsBundleNameValid(_, _))
.Times(1)
.WillRepeatedly(Return(false));
EXPECT_CALL(*IdentityCheckerTest::identityCheckerMock_, HasPermission(_, _)).Times(1).WillRepeatedly(Return(true));
EXPECT_CALL(*IdentityCheckerTest::identityCheckerMock_, IsSystemApp(_)).Times(1).WillRepeatedly(Return(true));
EXPECT_CALL(*IdentityCheckerTest::identityCheckerMock_, IsBundleNameValid(_, _)).WillRepeatedly(Return(false));
int32_t ret = IdentityCheckerTest::service_->SwitchInputMethod(CURRENT_BUNDLENAME, CURRENT_SUBNAME);
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
}