Signed-off-by: ma-shaoyin <mashaoyin1@huawei.com>

Changes to be committed:
This commit is contained in:
ma-shaoyin 2022-11-09 15:31:46 +08:00
parent 1ea25b65c9
commit d262ecff3c
2 changed files with 6 additions and 7 deletions

View File

@ -19,7 +19,8 @@
namespace OHOS {
namespace MiscServices {
const char *ParaHandle::DEFAULT_IME_KEY = "persist.sys.default_ime";
const char *ParaHandle::DEFAULT_IME_NAME = "com.example.kikakeyboard/ServiceExtAbility";
const std::string ParaHandle::CURRENT_PACKAGE_NAME = "com.example.kikakeyboard";
const std::string ParaHandle::CURRRET_ABILITY_NAME = "ServiceExtAbility";
bool ParaHandle::SetDefaultIme(int32_t userId, const std::string &imeName)
{
if (userId != main_userId) {
@ -41,9 +42,9 @@ namespace OHOS {
if (code > 0) {
return value;
}
SetDefaultIme(userId, DEFAULT_IME_NAME);
return DEFAULT_IME_NAME;
std::string defaultName = CURRENT_PACKAGE_NAME + "/" + CURRRET_ABILITY_NAME;
SetDefaultIme(userId, defaultName);
return defaultName;
}
} // namespace MiscServices
} // namespace OHOS

View File

@ -1198,9 +1198,7 @@ namespace MiscServices {
std::string::size_type pos = defaultIme.find("/");
std::string currentIme = defaultIme.substr(0, pos);
if (packageName == currentIme) {
std::string packageName = "com.example.kikakeyboard";
std::string abilityName = "ServiceExtAbility";
int32_t ret = OnSwitchInputMethod(packageName, abilityName);
int32_t ret = OnSwitchInputMethod(ParaHandle::CURRENT_PACKAGE_NAME, ParaHandle::CURRRET_ABILITY_NAME);
IMSA_HILOGI("InputMethodSystemAbility::OnPackageRemoved ret = %{public}d", ret);
}
return 0;