!798 [Bug]: 修改StartAbility调用方法

Merge pull request !798 from 赵凌岚/master
This commit is contained in:
openharmony_ci 2023-07-12 09:39:38 +00:00 committed by Gitee
commit 0cd9984a70
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 3 additions and 28 deletions

View File

@ -22,8 +22,6 @@
#include <mutex>
#include <thread>
#include "ability_connect_callback_proxy.h"
#include "ability_manager_interface.h"
#include "block_data.h"
#include "event_handler.h"
#include "event_status_manager.h"
@ -137,7 +135,6 @@ private:
sptr<IInputMethodCore> GetImsCore(int32_t index);
void SetAgent(sptr<IInputMethodAgent> agent);
sptr<IInputMethodAgent> GetAgent();
sptr<AAFwk::IAbilityManager> GetAbilityManagerService();
bool IsCurrentClient(int32_t pid, int32_t uid);
void UnbindClient(const sptr<IInputClient> &client);

View File

@ -17,8 +17,7 @@
#include <vector>
#include "ability_connect_callback_proxy.h"
#include "ability_manager_interface.h"
#include "ability_manager_client.h"
#include "element_name.h"
#include "ime_cfg_manager.h"
#include "ime_info_inquirer.h"
@ -32,7 +31,6 @@
#include "message_parcel.h"
#include "parcel.h"
#include "sys/prctl.h"
#include "system_ability_definition.h"
#include "unistd.h"
#include "want.h"
@ -596,22 +594,6 @@ bool PerUserSession::IsCurrentClient(int32_t pid, int32_t uid)
return clientInfo->pid == pid && clientInfo->uid == uid;
}
sptr<AAFwk::IAbilityManager> PerUserSession::GetAbilityManagerService()
{
IMSA_HILOGD("InputMethodSystemAbility::GetAbilityManagerService start");
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (samgr == nullptr) {
IMSA_HILOGE("SystemAbilityManager is nullptr.");
return nullptr;
}
auto abilityMsObj = samgr->GetSystemAbility(ABILITY_MGR_SERVICE_ID);
if (abilityMsObj == nullptr) {
IMSA_HILOGE("Failed to get ability manager service.");
return nullptr;
}
return iface_cast<AAFwk::IAbilityManager>(abilityMsObj);
}
bool PerUserSession::StartInputService(const std::string &imeName, bool isRetry)
{
IMSA_HILOGI("start ime: %{public}s with isRetry: %{public}d", imeName.c_str(), isRetry);
@ -620,16 +602,12 @@ bool PerUserSession::StartInputService(const std::string &imeName, bool isRetry)
IMSA_HILOGE("invalid ime name");
return false;
}
auto abms = GetAbilityManagerService();
if (abms == nullptr) {
IMSA_HILOGE("failed to get ability manager service");
return false;
}
IMSA_HILOGI("ime: %{public}s", imeName.c_str());
AAFwk::Want want;
want.SetElementName(imeName.substr(0, pos), imeName.substr(pos + 1));
isImeStarted_.Clear(false);
if (abms->StartAbility(want) != ErrorCode::NO_ERROR) {
auto ret = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want);
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("failed to start ability");
} else if (isImeStarted_.GetValue()) {
IMSA_HILOGI("ime started successfully");