mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 06:40:06 +00:00
commit
d2db8dbf63
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user