1eace7efcSopenharmony_ci/* 2eace7efcSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License. 5eace7efcSopenharmony_ci * You may obtain a copy of the License at 6eace7efcSopenharmony_ci * 7eace7efcSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8eace7efcSopenharmony_ci * 9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and 13eace7efcSopenharmony_ci * limitations under the License. 14eace7efcSopenharmony_ci */ 15eace7efcSopenharmony_ci 16eace7efcSopenharmony_ci#include "ability_manager_client.h" 17eace7efcSopenharmony_ci 18eace7efcSopenharmony_ci#ifdef WITH_DLP 19eace7efcSopenharmony_ci#include "dlp_file_kits.h" 20eace7efcSopenharmony_ci#endif // WITH_DLP 21eace7efcSopenharmony_ci#include "hilog_tag_wrapper.h" 22eace7efcSopenharmony_ci#include "hitrace_meter.h" 23eace7efcSopenharmony_ci#include "iservice_registry.h" 24eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 25eace7efcSopenharmony_ci#include "scene_board_judgement.h" 26eace7efcSopenharmony_ci#include "session_manager_lite.h" 27eace7efcSopenharmony_ci#endif // SUPPORT_SCREEN 28eace7efcSopenharmony_ci#include "status_bar_delegate_interface.h" 29eace7efcSopenharmony_ci#include "system_ability_definition.h" 30eace7efcSopenharmony_ci 31eace7efcSopenharmony_cinamespace OHOS { 32eace7efcSopenharmony_cinamespace AAFwk { 33eace7efcSopenharmony_cinamespace { 34eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 35eace7efcSopenharmony_cistatic std::unordered_map<Rosen::WSError, int32_t> SCB_TO_MISSION_ERROR_CODE_MAP { 36eace7efcSopenharmony_ci { Rosen::WSError::WS_ERROR_INVALID_PERMISSION, CHECK_PERMISSION_FAILED }, 37eace7efcSopenharmony_ci { Rosen::WSError::WS_ERROR_NOT_SYSTEM_APP, ERR_NOT_SYSTEM_APP }, 38eace7efcSopenharmony_ci { Rosen::WSError::WS_ERROR_INVALID_PARAM, INVALID_PARAMETERS_ERR }, 39eace7efcSopenharmony_ci}; 40eace7efcSopenharmony_ci#endif // SUPPORT_SCREEN 41eace7efcSopenharmony_ci} 42eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 43eace7efcSopenharmony_ciusing OHOS::Rosen::SessionManagerLite; 44eace7efcSopenharmony_ci#endif // SUPPORT_SCREEN 45eace7efcSopenharmony_cistd::shared_ptr<AbilityManagerClient> AbilityManagerClient::instance_ = nullptr; 46eace7efcSopenharmony_cistd::once_flag AbilityManagerClient::singletonFlag_; 47eace7efcSopenharmony_ci#ifdef WITH_DLP 48eace7efcSopenharmony_ciconst std::string DLP_PARAMS_SANDBOX = "ohos.dlp.params.sandbox"; 49eace7efcSopenharmony_ci#endif // WITH_DLP 50eace7efcSopenharmony_ci 51eace7efcSopenharmony_ci#define CHECK_POINTER_RETURN(object) \ 52eace7efcSopenharmony_ci if (!object) { \ 53eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null proxy"); \ 54eace7efcSopenharmony_ci return; \ 55eace7efcSopenharmony_ci } 56eace7efcSopenharmony_ci 57eace7efcSopenharmony_ci#define CHECK_POINTER_RETURN_NOT_CONNECTED(object) \ 58eace7efcSopenharmony_ci if (!object) { \ 59eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null proxy"); \ 60eace7efcSopenharmony_ci return ABILITY_SERVICE_NOT_CONNECTED; \ 61eace7efcSopenharmony_ci } 62eace7efcSopenharmony_ci 63eace7efcSopenharmony_ci#define CHECK_POINTER_RETURN_INVALID_VALUE(object) \ 64eace7efcSopenharmony_ci if (!object) { \ 65eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null proxy"); \ 66eace7efcSopenharmony_ci return ERR_INVALID_VALUE; \ 67eace7efcSopenharmony_ci } 68eace7efcSopenharmony_ci 69eace7efcSopenharmony_cistd::shared_ptr<AbilityManagerClient> AbilityManagerClient::GetInstance() 70eace7efcSopenharmony_ci{ 71eace7efcSopenharmony_ci std::call_once(singletonFlag_, [] () { 72eace7efcSopenharmony_ci instance_ = std::shared_ptr<AbilityManagerClient>(new AbilityManagerClient()); 73eace7efcSopenharmony_ci }); 74eace7efcSopenharmony_ci return instance_; 75eace7efcSopenharmony_ci} 76eace7efcSopenharmony_ci 77eace7efcSopenharmony_ciAbilityManagerClient::AbilityManagerClient() 78eace7efcSopenharmony_ci{} 79eace7efcSopenharmony_ci 80eace7efcSopenharmony_ciAbilityManagerClient::~AbilityManagerClient() 81eace7efcSopenharmony_ci{ 82eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "Remove DeathRecipient"); 83eace7efcSopenharmony_ci RemoveDeathRecipient(); 84eace7efcSopenharmony_ci} 85eace7efcSopenharmony_ci 86eace7efcSopenharmony_ciErrCode AbilityManagerClient::AttachAbilityThread( 87eace7efcSopenharmony_ci sptr<IAbilityScheduler> scheduler, sptr<IRemoteObject> token) 88eace7efcSopenharmony_ci{ 89eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 90eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 91eace7efcSopenharmony_ci return abms->AttachAbilityThread(scheduler, token); 92eace7efcSopenharmony_ci} 93eace7efcSopenharmony_ci 94eace7efcSopenharmony_ciErrCode AbilityManagerClient::AbilityTransitionDone(sptr<IRemoteObject> token, int state, const PacMap &saveData) 95eace7efcSopenharmony_ci{ 96eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 97eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 98eace7efcSopenharmony_ci return abms->AbilityTransitionDone(token, state, saveData); 99eace7efcSopenharmony_ci} 100eace7efcSopenharmony_ci 101eace7efcSopenharmony_ciErrCode AbilityManagerClient::AbilityWindowConfigTransitionDone( 102eace7efcSopenharmony_ci sptr<IRemoteObject> token, const WindowConfig &windowConfig) 103eace7efcSopenharmony_ci{ 104eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 105eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 106eace7efcSopenharmony_ci return abms->AbilityWindowConfigTransitionDone(token, windowConfig); 107eace7efcSopenharmony_ci} 108eace7efcSopenharmony_ci 109eace7efcSopenharmony_ciErrCode AbilityManagerClient::ScheduleConnectAbilityDone( 110eace7efcSopenharmony_ci sptr<IRemoteObject> token, sptr<IRemoteObject> remoteObject) 111eace7efcSopenharmony_ci{ 112eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 113eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 114eace7efcSopenharmony_ci return abms->ScheduleConnectAbilityDone(token, remoteObject); 115eace7efcSopenharmony_ci} 116eace7efcSopenharmony_ci 117eace7efcSopenharmony_ciErrCode AbilityManagerClient::ScheduleDisconnectAbilityDone(sptr<IRemoteObject> token) 118eace7efcSopenharmony_ci{ 119eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 120eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 121eace7efcSopenharmony_ci return abms->ScheduleDisconnectAbilityDone(token); 122eace7efcSopenharmony_ci} 123eace7efcSopenharmony_ci 124eace7efcSopenharmony_ciErrCode AbilityManagerClient::ScheduleCommandAbilityDone(sptr<IRemoteObject> token) 125eace7efcSopenharmony_ci{ 126eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 127eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 128eace7efcSopenharmony_ci return abms->ScheduleCommandAbilityDone(token); 129eace7efcSopenharmony_ci} 130eace7efcSopenharmony_ci 131eace7efcSopenharmony_ciErrCode AbilityManagerClient::ScheduleCommandAbilityWindowDone( 132eace7efcSopenharmony_ci sptr<IRemoteObject> token, 133eace7efcSopenharmony_ci sptr<SessionInfo> sessionInfo, 134eace7efcSopenharmony_ci WindowCommand winCmd, 135eace7efcSopenharmony_ci AbilityCommand abilityCmd) 136eace7efcSopenharmony_ci{ 137eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 138eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 139eace7efcSopenharmony_ci return abms->ScheduleCommandAbilityWindowDone(token, sessionInfo, winCmd, abilityCmd); 140eace7efcSopenharmony_ci} 141eace7efcSopenharmony_ci 142eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbility(const Want &want, int requestCode, int32_t userId) 143eace7efcSopenharmony_ci{ 144eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 145eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 146eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 147eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "StartAbility ability:%{public}s, userId:%{public}d", 148eace7efcSopenharmony_ci want.GetElement().GetURI().c_str(), userId); 149eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 150eace7efcSopenharmony_ci return abms->StartAbility(want, userId, requestCode); 151eace7efcSopenharmony_ci} 152eace7efcSopenharmony_ci 153eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbility( 154eace7efcSopenharmony_ci const Want &want, sptr<IRemoteObject> callerToken, int requestCode, int32_t userId) 155eace7efcSopenharmony_ci{ 156eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 157eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 158eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 159eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "StartAbility ability:%{public}s, userId:%{public}d", 160eace7efcSopenharmony_ci want.GetElement().GetURI().c_str(), userId); 161eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 162eace7efcSopenharmony_ci return abms->StartAbility(want, callerToken, userId, requestCode); 163eace7efcSopenharmony_ci} 164eace7efcSopenharmony_ci 165eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbilityByInsightIntent( 166eace7efcSopenharmony_ci const Want &want, sptr<IRemoteObject> callerToken, uint64_t intentId, int32_t userId) 167eace7efcSopenharmony_ci{ 168eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 169eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 170eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 171eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "ability:%{public}s, bundle:%{public}s, intentId:%{public}" PRIu64, 172eace7efcSopenharmony_ci want.GetElement().GetAbilityName().c_str(), want.GetElement().GetBundleName().c_str(), intentId); 173eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 174eace7efcSopenharmony_ci return abms->StartAbilityByInsightIntent(want, callerToken, intentId, userId); 175eace7efcSopenharmony_ci} 176eace7efcSopenharmony_ci 177eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbility(const Want &want, const AbilityStartSetting &abilityStartSetting, 178eace7efcSopenharmony_ci sptr<IRemoteObject> callerToken, int requestCode, int32_t userId) 179eace7efcSopenharmony_ci{ 180eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 181eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 182eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 183eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "StartAbility ability:%{public}s, userId:%{public}d", 184eace7efcSopenharmony_ci want.GetElement().GetURI().c_str(), userId); 185eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 186eace7efcSopenharmony_ci return abms->StartAbility(want, abilityStartSetting, callerToken, userId, requestCode); 187eace7efcSopenharmony_ci} 188eace7efcSopenharmony_ci 189eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbility(const Want &want, const StartOptions &startOptions, 190eace7efcSopenharmony_ci sptr<IRemoteObject> callerToken, int requestCode, int32_t userId) 191eace7efcSopenharmony_ci{ 192eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 193eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 194eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 195eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "start ability, abilityName:%{public}s, userId:%{public}d.", 196eace7efcSopenharmony_ci want.GetElement().GetURI().c_str(), userId); 197eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 198eace7efcSopenharmony_ci return abms->StartAbility(want, startOptions, callerToken, userId, requestCode); 199eace7efcSopenharmony_ci} 200eace7efcSopenharmony_ci 201eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbilityAsCaller( 202eace7efcSopenharmony_ci const Want &want, sptr<IRemoteObject> callerToken, 203eace7efcSopenharmony_ci sptr<IRemoteObject> asCallerSourceToken, int requestCode, int32_t userId) 204eace7efcSopenharmony_ci{ 205eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 206eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 207eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 208eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "StartAbilityAsCaller ability:%{public}s, userId:%{public}d.", 209eace7efcSopenharmony_ci want.GetElement().GetURI().c_str(), userId); 210eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 211eace7efcSopenharmony_ci return abms->StartAbilityAsCaller(want, callerToken, asCallerSourceToken, userId, requestCode); 212eace7efcSopenharmony_ci} 213eace7efcSopenharmony_ci 214eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbilityAsCaller(const Want &want, const StartOptions &startOptions, 215eace7efcSopenharmony_ci sptr<IRemoteObject> callerToken, sptr<IRemoteObject> asCallerSourceToken, 216eace7efcSopenharmony_ci int requestCode, int32_t userId) 217eace7efcSopenharmony_ci{ 218eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 219eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 220eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 221eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "abilityName:%{public}s, userId:%{public}d", 222eace7efcSopenharmony_ci want.GetElement().GetURI().c_str(), userId); 223eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 224eace7efcSopenharmony_ci return abms->StartAbilityAsCaller(want, startOptions, callerToken, asCallerSourceToken, userId, requestCode); 225eace7efcSopenharmony_ci} 226eace7efcSopenharmony_ci 227eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbilityForResultAsCaller( 228eace7efcSopenharmony_ci const Want &want, sptr<IRemoteObject> callerToken, int requestCode, int32_t userId) 229eace7efcSopenharmony_ci{ 230eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 231eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 232eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 233eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "StartAbilityForResultAsCaller, The abilityName:%{public}s, userId:%{public}d", 234eace7efcSopenharmony_ci want.GetElement().GetURI().c_str(), userId); 235eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 236eace7efcSopenharmony_ci return abms->StartAbilityForResultAsCaller(want, callerToken, requestCode, userId); 237eace7efcSopenharmony_ci} 238eace7efcSopenharmony_ci 239eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbilityForResultAsCaller(const Want &want, const StartOptions &startOptions, 240eace7efcSopenharmony_ci sptr<IRemoteObject> callerToken, int requestCode, int32_t userId) 241eace7efcSopenharmony_ci{ 242eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 243eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 244eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 245eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "The abilityName:%{public}s, userId:%{public}d", 246eace7efcSopenharmony_ci want.GetElement().GetURI().c_str(), userId); 247eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 248eace7efcSopenharmony_ci return abms->StartAbilityForResultAsCaller(want, startOptions, callerToken, requestCode, userId); 249eace7efcSopenharmony_ci} 250eace7efcSopenharmony_ci 251eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbilityByUIContentSession(const Want &want, const StartOptions &startOptions, 252eace7efcSopenharmony_ci sptr<IRemoteObject> callerToken, sptr<AAFwk::SessionInfo> sessionInfo, 253eace7efcSopenharmony_ci int requestCode, int32_t userId) 254eace7efcSopenharmony_ci{ 255eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 256eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 257eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 258eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "abilityName:%{public}s, userId:%{public}d.", 259eace7efcSopenharmony_ci want.GetElement().GetAbilityName().c_str(), userId); 260eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 261eace7efcSopenharmony_ci return abms->StartAbilityByUIContentSession(want, startOptions, callerToken, sessionInfo, userId, requestCode); 262eace7efcSopenharmony_ci} 263eace7efcSopenharmony_ci 264eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbilityByUIContentSession(const Want &want, sptr<IRemoteObject> callerToken, 265eace7efcSopenharmony_ci sptr<AAFwk::SessionInfo> sessionInfo, int requestCode, int32_t userId) 266eace7efcSopenharmony_ci{ 267eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 268eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 269eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 270eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "ability:%{public}s, userId:%{public}d", 271eace7efcSopenharmony_ci want.GetElement().GetAbilityName().c_str(), userId); 272eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 273eace7efcSopenharmony_ci return abms->StartAbilityByUIContentSession(want, callerToken, sessionInfo, userId, requestCode); 274eace7efcSopenharmony_ci} 275eace7efcSopenharmony_ci 276eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbilityOnlyUIAbility(const Want &want, sptr<IRemoteObject> callerToken, 277eace7efcSopenharmony_ci uint32_t specifyTokenId) 278eace7efcSopenharmony_ci{ 279eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 280eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 281eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 282eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "ability:%{public}s", 283eace7efcSopenharmony_ci want.GetElement().GetAbilityName().c_str()); 284eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 285eace7efcSopenharmony_ci return abms->StartAbilityOnlyUIAbility(want, callerToken, specifyTokenId); 286eace7efcSopenharmony_ci} 287eace7efcSopenharmony_ci 288eace7efcSopenharmony_ciErrCode AbilityManagerClient::SendResultToAbility(int requestCode, int resultCode, Want& resultWant) 289eace7efcSopenharmony_ci{ 290eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 291eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 292eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 293eace7efcSopenharmony_ci return abms->SendResultToAbility(requestCode, resultCode, resultWant); 294eace7efcSopenharmony_ci} 295eace7efcSopenharmony_ci 296eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartExtensionAbility(const Want &want, sptr<IRemoteObject> callerToken, 297eace7efcSopenharmony_ci int32_t userId, AppExecFwk::ExtensionAbilityType extensionType) 298eace7efcSopenharmony_ci{ 299eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 300eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 301eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 302eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "name:%{public}s %{public}s, userId=%{public}d.", 303eace7efcSopenharmony_ci want.GetElement().GetAbilityName().c_str(), want.GetElement().GetBundleName().c_str(), userId); 304eace7efcSopenharmony_ci return abms->StartExtensionAbility(want, callerToken, userId, extensionType); 305eace7efcSopenharmony_ci} 306eace7efcSopenharmony_ci 307eace7efcSopenharmony_ciErrCode AbilityManagerClient::RequestModalUIExtension(const Want &want) 308eace7efcSopenharmony_ci{ 309eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 310eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 311eace7efcSopenharmony_ci return abms->RequestModalUIExtension(want); 312eace7efcSopenharmony_ci} 313eace7efcSopenharmony_ci 314eace7efcSopenharmony_ciErrCode AbilityManagerClient::PreloadUIExtensionAbility(const Want &want, std::string &hostBundleName, int32_t userId) 315eace7efcSopenharmony_ci{ 316eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 317eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 318eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "elementName:%{public}s, hostBundleName:%{public}s.", 319eace7efcSopenharmony_ci want.GetElement().GetURI().c_str(), hostBundleName.c_str()); 320eace7efcSopenharmony_ci return abms->PreloadUIExtensionAbility(want, hostBundleName, userId); 321eace7efcSopenharmony_ci} 322eace7efcSopenharmony_ci 323eace7efcSopenharmony_ciErrCode AbilityManagerClient::ChangeAbilityVisibility(sptr<IRemoteObject> token, bool isShow) 324eace7efcSopenharmony_ci{ 325eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 326eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 327eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 328eace7efcSopenharmony_ci return abms->ChangeAbilityVisibility(token, isShow); 329eace7efcSopenharmony_ci} 330eace7efcSopenharmony_ci 331eace7efcSopenharmony_ciErrCode AbilityManagerClient::ChangeUIAbilityVisibilityBySCB(sptr<SessionInfo> sessionInfo, bool isShow) 332eace7efcSopenharmony_ci{ 333eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 334eace7efcSopenharmony_ci if (sessionInfo == nullptr) { 335eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null sessionInfo"); 336eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 337eace7efcSopenharmony_ci } 338eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 339eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 340eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, ChangeUIAbilityVisibilityBySCB abilityName: %{public}s," 341eace7efcSopenharmony_ci "isShow: %{public}d", sessionInfo->want.GetElement().GetAbilityName().c_str(), isShow); 342eace7efcSopenharmony_ci return abms->ChangeUIAbilityVisibilityBySCB(sessionInfo, isShow); 343eace7efcSopenharmony_ci} 344eace7efcSopenharmony_ci 345eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartUIExtensionAbility(sptr<SessionInfo> extensionSessionInfo, int32_t userId) 346eace7efcSopenharmony_ci{ 347eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 348eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 349eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 350eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(extensionSessionInfo); 351eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "name:%{public}s %{public}s, persistentId:%{public}d, userId:%{public}d", 352eace7efcSopenharmony_ci extensionSessionInfo->want.GetElement().GetAbilityName().c_str(), 353eace7efcSopenharmony_ci extensionSessionInfo->want.GetElement().GetBundleName().c_str(), extensionSessionInfo->persistentId, userId); 354eace7efcSopenharmony_ci return abms->StartUIExtensionAbility(extensionSessionInfo, userId); 355eace7efcSopenharmony_ci} 356eace7efcSopenharmony_ci 357eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartUIAbilityBySCB(sptr<SessionInfo> sessionInfo, bool &isColdStart, uint32_t sceneFlag) 358eace7efcSopenharmony_ci{ 359eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 360eace7efcSopenharmony_ci if (sessionInfo == nullptr) { 361eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null sessionInfo"); 362eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 363eace7efcSopenharmony_ci } 364eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 365eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 366eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, StartUIAbilityBySCB target: %{public}s.", 367eace7efcSopenharmony_ci sessionInfo->want.GetElement().GetURI().c_str()); 368eace7efcSopenharmony_ci return abms->StartUIAbilityBySCB(sessionInfo, isColdStart, sceneFlag); 369eace7efcSopenharmony_ci} 370eace7efcSopenharmony_ci 371eace7efcSopenharmony_ciErrCode AbilityManagerClient::StopExtensionAbility(const Want &want, sptr<IRemoteObject> callerToken, 372eace7efcSopenharmony_ci int32_t userId, AppExecFwk::ExtensionAbilityType extensionType) 373eace7efcSopenharmony_ci{ 374eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 375eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 376eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "name:%{public}s %{public}s, userId=%{public}d.", 377eace7efcSopenharmony_ci want.GetElement().GetAbilityName().c_str(), want.GetElement().GetBundleName().c_str(), userId); 378eace7efcSopenharmony_ci return abms->StopExtensionAbility(want, callerToken, userId, extensionType); 379eace7efcSopenharmony_ci} 380eace7efcSopenharmony_ci 381eace7efcSopenharmony_ciErrCode AbilityManagerClient::TerminateAbility(sptr<IRemoteObject> token, int resultCode, const Want *resultWant) 382eace7efcSopenharmony_ci{ 383eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 384eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 385eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); 386eace7efcSopenharmony_ci return abms->TerminateAbility(token, resultCode, resultWant); 387eace7efcSopenharmony_ci} 388eace7efcSopenharmony_ci 389eace7efcSopenharmony_ciErrCode AbilityManagerClient::BackToCallerAbilityWithResult(const sptr<IRemoteObject> &token, int resultCode, 390eace7efcSopenharmony_ci const Want *resultWant, int64_t callerRequestCode) 391eace7efcSopenharmony_ci{ 392eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 393eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 394eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 395eace7efcSopenharmony_ci return abms->BackToCallerAbilityWithResult(token, resultCode, resultWant, callerRequestCode); 396eace7efcSopenharmony_ci} 397eace7efcSopenharmony_ci 398eace7efcSopenharmony_ciErrCode AbilityManagerClient::TerminateUIServiceExtensionAbility(sptr<IRemoteObject> token) 399eace7efcSopenharmony_ci{ 400eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 401eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 402eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); 403eace7efcSopenharmony_ci return abms->TerminateUIServiceExtensionAbility(token); 404eace7efcSopenharmony_ci} 405eace7efcSopenharmony_ci 406eace7efcSopenharmony_ciErrCode AbilityManagerClient::TerminateUIExtensionAbility(sptr<SessionInfo> extensionSessionInfo, 407eace7efcSopenharmony_ci int resultCode, const Want *resultWant) 408eace7efcSopenharmony_ci{ 409eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 410eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 411eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 412eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(extensionSessionInfo); 413eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "name: %{public}s %{public}s, persistentId: %{public}d", 414eace7efcSopenharmony_ci extensionSessionInfo->want.GetElement().GetAbilityName().c_str(), 415eace7efcSopenharmony_ci extensionSessionInfo->want.GetElement().GetBundleName().c_str(), extensionSessionInfo->persistentId); 416eace7efcSopenharmony_ci return abms->TerminateUIExtensionAbility(extensionSessionInfo, resultCode, resultWant); 417eace7efcSopenharmony_ci} 418eace7efcSopenharmony_ci 419eace7efcSopenharmony_ciErrCode AbilityManagerClient::MoveAbilityToBackground(sptr<IRemoteObject> token) 420eace7efcSopenharmony_ci{ 421eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 422eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 423eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 424eace7efcSopenharmony_ci return abms->MoveAbilityToBackground(token); 425eace7efcSopenharmony_ci} 426eace7efcSopenharmony_ci 427eace7efcSopenharmony_ciErrCode AbilityManagerClient::MoveUIAbilityToBackground(const sptr<IRemoteObject> token) 428eace7efcSopenharmony_ci{ 429eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "MoveUIAbilityToBackground call"); 430eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 431eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 432eace7efcSopenharmony_ci return abms->MoveUIAbilityToBackground(token); 433eace7efcSopenharmony_ci} 434eace7efcSopenharmony_ci 435eace7efcSopenharmony_ciErrCode AbilityManagerClient::CloseAbility(sptr<IRemoteObject> token, int resultCode, const Want *resultWant) 436eace7efcSopenharmony_ci{ 437eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 438eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 439eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 440eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 441eace7efcSopenharmony_ci sptr<AAFwk::SessionInfo> info = new AAFwk::SessionInfo(); 442eace7efcSopenharmony_ci info->want = *resultWant; 443eace7efcSopenharmony_ci info->resultCode = resultCode; 444eace7efcSopenharmony_ci info->sessionToken = token; 445eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, CloseAbility"); 446eace7efcSopenharmony_ci auto ret = static_cast<int>(sceneSessionManager->TerminateSessionNew(info, false)); 447eace7efcSopenharmony_ci if (ret != ERR_OK) { 448eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, CloseAbility err: %{public}d", ret); 449eace7efcSopenharmony_ci } 450eace7efcSopenharmony_ci return ret; 451eace7efcSopenharmony_ci } 452eace7efcSopenharmony_ci#endif // SUPPORT_SCREEN 453eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 454eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 455eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 456eace7efcSopenharmony_ci return abms->CloseAbility(token, resultCode, resultWant); 457eace7efcSopenharmony_ci} 458eace7efcSopenharmony_ci 459eace7efcSopenharmony_ciErrCode AbilityManagerClient::CloseUIAbilityBySCB(sptr<SessionInfo> sessionInfo) 460eace7efcSopenharmony_ci{ 461eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 462eace7efcSopenharmony_ci if (sessionInfo == nullptr) { 463eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null sessionInfo"); 464eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 465eace7efcSopenharmony_ci } 466eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 467eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 468eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, CloseUIAbilityBySCB target: %{public}s", 469eace7efcSopenharmony_ci sessionInfo->want.GetElement().GetURI().c_str()); 470eace7efcSopenharmony_ci return abms->CloseUIAbilityBySCB(sessionInfo); 471eace7efcSopenharmony_ci} 472eace7efcSopenharmony_ci 473eace7efcSopenharmony_ciErrCode AbilityManagerClient::MinimizeAbility(sptr<IRemoteObject> token, bool fromUser) 474eace7efcSopenharmony_ci{ 475eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 476eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 477eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 478eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "fromUser:%{public}d.", fromUser); 479eace7efcSopenharmony_ci return abms->MinimizeAbility(token, fromUser); 480eace7efcSopenharmony_ci} 481eace7efcSopenharmony_ci 482eace7efcSopenharmony_ciErrCode AbilityManagerClient::MinimizeUIExtensionAbility(sptr<SessionInfo> extensionSessionInfo, bool fromUser) 483eace7efcSopenharmony_ci{ 484eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 485eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 486eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 487eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(extensionSessionInfo); 488eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "name: %{public}s %{public}s, persistentId: %{public}d, fromUser: %{public}d", 489eace7efcSopenharmony_ci extensionSessionInfo->want.GetElement().GetAbilityName().c_str(), 490eace7efcSopenharmony_ci extensionSessionInfo->want.GetElement().GetBundleName().c_str(), extensionSessionInfo->persistentId, fromUser); 491eace7efcSopenharmony_ci return abms->MinimizeUIExtensionAbility(extensionSessionInfo, fromUser); 492eace7efcSopenharmony_ci} 493eace7efcSopenharmony_ci 494eace7efcSopenharmony_ciErrCode AbilityManagerClient::MinimizeUIAbilityBySCB(sptr<SessionInfo> sessionInfo, bool fromUser, uint32_t sceneFlag) 495eace7efcSopenharmony_ci{ 496eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 497eace7efcSopenharmony_ci if (sessionInfo == nullptr) { 498eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null sessionInfo"); 499eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 500eace7efcSopenharmony_ci } 501eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 502eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 503eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, MinimizeUIAbilityBySCB target: %{public}s", 504eace7efcSopenharmony_ci sessionInfo->want.GetElement().GetURI().c_str()); 505eace7efcSopenharmony_ci return abms->MinimizeUIAbilityBySCB(sessionInfo, fromUser, sceneFlag); 506eace7efcSopenharmony_ci} 507eace7efcSopenharmony_ci 508eace7efcSopenharmony_ciErrCode AbilityManagerClient::ConnectAbility(const Want &want, sptr<IAbilityConnection> connect, int32_t userId) 509eace7efcSopenharmony_ci{ 510eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 511eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 512eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 513eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "name:%{public}s %{public}s, userId:%{public}d", 514eace7efcSopenharmony_ci want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId); 515eace7efcSopenharmony_ci return abms->ConnectAbilityCommon(want, connect, nullptr, AppExecFwk::ExtensionAbilityType::SERVICE, userId); 516eace7efcSopenharmony_ci} 517eace7efcSopenharmony_ci 518eace7efcSopenharmony_ciErrCode AbilityManagerClient::ConnectAbility( 519eace7efcSopenharmony_ci const Want &want, sptr<IAbilityConnection> connect, sptr<IRemoteObject> callerToken, int32_t userId) 520eace7efcSopenharmony_ci{ 521eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 522eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 523eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 524eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "name:%{public}s %{public}s, userId:%{public}d", 525eace7efcSopenharmony_ci want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId); 526eace7efcSopenharmony_ci return abms->ConnectAbilityCommon(want, connect, callerToken, AppExecFwk::ExtensionAbilityType::SERVICE, userId); 527eace7efcSopenharmony_ci} 528eace7efcSopenharmony_ci 529eace7efcSopenharmony_ciErrCode AbilityManagerClient::ConnectUIServiceExtesnionAbility( 530eace7efcSopenharmony_ci const Want &want, sptr<IAbilityConnection> connect, sptr<IRemoteObject> callerToken, int32_t userId) 531eace7efcSopenharmony_ci{ 532eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 533eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 534eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 535eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "name:%{public}s %{public}s, userId:%{public}d", 536eace7efcSopenharmony_ci want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId); 537eace7efcSopenharmony_ci return abms->ConnectAbilityCommon(want, connect, callerToken, 538eace7efcSopenharmony_ci AppExecFwk::ExtensionAbilityType::UI_SERVICE, userId); 539eace7efcSopenharmony_ci} 540eace7efcSopenharmony_ci 541eace7efcSopenharmony_ciErrCode AbilityManagerClient::ConnectDataShareExtensionAbility(const Want &want, 542eace7efcSopenharmony_ci sptr<IAbilityConnection> connect, int32_t userId) 543eace7efcSopenharmony_ci{ 544eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 545eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 546eace7efcSopenharmony_ci if (abms == nullptr) { 547eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "failed,bundleName:%{public}s,abilityName:%{public}s,uri:%{public}s", 548eace7efcSopenharmony_ci want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), 549eace7efcSopenharmony_ci want.GetUriString().c_str()); 550eace7efcSopenharmony_ci return ABILITY_SERVICE_NOT_CONNECTED; 551eace7efcSopenharmony_ci } 552eace7efcSopenharmony_ci 553eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "name:%{public}s %{public}s, uri:%{public}s.", 554eace7efcSopenharmony_ci want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), 555eace7efcSopenharmony_ci want.GetUriString().c_str()); 556eace7efcSopenharmony_ci return abms->ConnectAbilityCommon(want, connect, nullptr, AppExecFwk::ExtensionAbilityType::DATASHARE, userId); 557eace7efcSopenharmony_ci} 558eace7efcSopenharmony_ci 559eace7efcSopenharmony_ciErrCode AbilityManagerClient::ConnectExtensionAbility(const Want &want, sptr<IAbilityConnection> connect, 560eace7efcSopenharmony_ci int32_t userId) 561eace7efcSopenharmony_ci{ 562eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 563eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 564eace7efcSopenharmony_ci if (abms == nullptr) { 565eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "failed,bundleName:%{public}s,abilityName:%{public}s", 566eace7efcSopenharmony_ci want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str()); 567eace7efcSopenharmony_ci return ABILITY_SERVICE_NOT_CONNECTED; 568eace7efcSopenharmony_ci } 569eace7efcSopenharmony_ci 570eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "name:%{public}s %{public}s, userId:%{public}d.", 571eace7efcSopenharmony_ci want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId); 572eace7efcSopenharmony_ci return abms->ConnectAbilityCommon(want, connect, nullptr, AppExecFwk::ExtensionAbilityType::UNSPECIFIED, userId); 573eace7efcSopenharmony_ci} 574eace7efcSopenharmony_ci 575eace7efcSopenharmony_ciErrCode AbilityManagerClient::ConnectUIExtensionAbility(const Want &want, sptr<IAbilityConnection> connect, 576eace7efcSopenharmony_ci sptr<SessionInfo> sessionInfo, int32_t userId, sptr<UIExtensionAbilityConnectInfo> connectInfo) 577eace7efcSopenharmony_ci{ 578eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 579eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 580eace7efcSopenharmony_ci if (abms == nullptr) { 581eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "failed,bundleName:%{public}s,abilityName:%{public}s,uri:%{public}s", 582eace7efcSopenharmony_ci want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), 583eace7efcSopenharmony_ci want.GetUriString().c_str()); 584eace7efcSopenharmony_ci return ABILITY_SERVICE_NOT_CONNECTED; 585eace7efcSopenharmony_ci } 586eace7efcSopenharmony_ci 587eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "name:%{public}s %{public}s, uri:%{public}s.", 588eace7efcSopenharmony_ci want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), 589eace7efcSopenharmony_ci want.GetUriString().c_str()); 590eace7efcSopenharmony_ci return abms->ConnectUIExtensionAbility(want, connect, sessionInfo, userId, connectInfo); 591eace7efcSopenharmony_ci} 592eace7efcSopenharmony_ci 593eace7efcSopenharmony_ciErrCode AbilityManagerClient::DisconnectAbility(sptr<IAbilityConnection> connect) 594eace7efcSopenharmony_ci{ 595eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 596eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 597eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 598eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "DisconnectAbility call"); 599eace7efcSopenharmony_ci return abms->DisconnectAbility(connect); 600eace7efcSopenharmony_ci} 601eace7efcSopenharmony_ci 602eace7efcSopenharmony_cisptr<IAbilityScheduler> AbilityManagerClient::AcquireDataAbility( 603eace7efcSopenharmony_ci const Uri &uri, bool tryBind, sptr<IRemoteObject> callerToken) 604eace7efcSopenharmony_ci{ 605eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 606eace7efcSopenharmony_ci if (!abms) { 607eace7efcSopenharmony_ci return nullptr; 608eace7efcSopenharmony_ci } 609eace7efcSopenharmony_ci return abms->AcquireDataAbility(uri, tryBind, callerToken); 610eace7efcSopenharmony_ci} 611eace7efcSopenharmony_ci 612eace7efcSopenharmony_ciErrCode AbilityManagerClient::ReleaseDataAbility( 613eace7efcSopenharmony_ci sptr<IAbilityScheduler> dataAbilityScheduler, sptr<IRemoteObject> callerToken) 614eace7efcSopenharmony_ci{ 615eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 616eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 617eace7efcSopenharmony_ci return abms->ReleaseDataAbility(dataAbilityScheduler, callerToken); 618eace7efcSopenharmony_ci} 619eace7efcSopenharmony_ci 620eace7efcSopenharmony_ciErrCode AbilityManagerClient::DumpState(const std::string &args, std::vector<std::string> &state) 621eace7efcSopenharmony_ci{ 622eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 623eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 624eace7efcSopenharmony_ci abms->DumpState(args, state); 625eace7efcSopenharmony_ci return ERR_OK; 626eace7efcSopenharmony_ci} 627eace7efcSopenharmony_ci 628eace7efcSopenharmony_ciErrCode AbilityManagerClient::DumpSysState( 629eace7efcSopenharmony_ci const std::string& args, std::vector<std::string>& state, bool isClient, bool isUserID, int UserID) 630eace7efcSopenharmony_ci{ 631eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 632eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 633eace7efcSopenharmony_ci abms->DumpSysState(args, state, isClient, isUserID, UserID); 634eace7efcSopenharmony_ci return ERR_OK; 635eace7efcSopenharmony_ci} 636eace7efcSopenharmony_ci 637eace7efcSopenharmony_ciErrCode AbilityManagerClient::Connect() 638eace7efcSopenharmony_ci{ 639eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 640eace7efcSopenharmony_ci std::lock_guard<std::recursive_mutex> lock(mutex_); 641eace7efcSopenharmony_ci if (proxy_ != nullptr) { 642eace7efcSopenharmony_ci return ERR_OK; 643eace7efcSopenharmony_ci } 644eace7efcSopenharmony_ci sptr<ISystemAbilityManager> systemManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); 645eace7efcSopenharmony_ci if (systemManager == nullptr) { 646eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "get registry failed"); 647eace7efcSopenharmony_ci return GET_ABILITY_SERVICE_FAILED; 648eace7efcSopenharmony_ci } 649eace7efcSopenharmony_ci sptr<IRemoteObject> remoteObj = systemManager->GetSystemAbility(ABILITY_MGR_SERVICE_ID); 650eace7efcSopenharmony_ci if (remoteObj == nullptr) { 651eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "connect failed"); 652eace7efcSopenharmony_ci return GET_ABILITY_SERVICE_FAILED; 653eace7efcSopenharmony_ci } 654eace7efcSopenharmony_ci 655eace7efcSopenharmony_ci deathRecipient_ = sptr<IRemoteObject::DeathRecipient>(new AbilityMgrDeathRecipient()); 656eace7efcSopenharmony_ci if (deathRecipient_ == nullptr) { 657eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "create abilityMgrDeathRecipient failed"); 658eace7efcSopenharmony_ci return GET_ABILITY_SERVICE_FAILED; 659eace7efcSopenharmony_ci } 660eace7efcSopenharmony_ci if ((remoteObj->IsProxyObject()) && (!remoteObj->AddDeathRecipient(deathRecipient_))) { 661eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "add deathRecipient failed"); 662eace7efcSopenharmony_ci return GET_ABILITY_SERVICE_FAILED; 663eace7efcSopenharmony_ci } 664eace7efcSopenharmony_ci 665eace7efcSopenharmony_ci proxy_ = iface_cast<IAbilityManager>(remoteObj); 666eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "Connect ability manager service success."); 667eace7efcSopenharmony_ci return ERR_OK; 668eace7efcSopenharmony_ci} 669eace7efcSopenharmony_ci 670eace7efcSopenharmony_civoid AbilityManagerClient::RemoveDeathRecipient() 671eace7efcSopenharmony_ci{ 672eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "RemoveDeathRecipient"); 673eace7efcSopenharmony_ci std::lock_guard<std::recursive_mutex> lock(mutex_); 674eace7efcSopenharmony_ci if (proxy_ == nullptr) { 675eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "null proxy_"); 676eace7efcSopenharmony_ci return; 677eace7efcSopenharmony_ci } 678eace7efcSopenharmony_ci if (deathRecipient_ == nullptr) { 679eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "null deathRecipient_"); 680eace7efcSopenharmony_ci return; 681eace7efcSopenharmony_ci } 682eace7efcSopenharmony_ci auto serviceRemote = proxy_->AsObject(); 683eace7efcSopenharmony_ci if (serviceRemote != nullptr && serviceRemote->RemoveDeathRecipient(deathRecipient_)) { 684eace7efcSopenharmony_ci proxy_ = nullptr; 685eace7efcSopenharmony_ci deathRecipient_ = nullptr; 686eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "remove success"); 687eace7efcSopenharmony_ci } 688eace7efcSopenharmony_ci} 689eace7efcSopenharmony_ci 690eace7efcSopenharmony_ciErrCode AbilityManagerClient::StopServiceAbility(const Want &want, sptr<IRemoteObject> token) 691eace7efcSopenharmony_ci{ 692eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 693eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 694eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 695eace7efcSopenharmony_ci return abms->StopServiceAbility(want, -1, token); 696eace7efcSopenharmony_ci} 697eace7efcSopenharmony_ci 698eace7efcSopenharmony_ciErrCode AbilityManagerClient::KillProcess(const std::string &bundleName, const bool clearPageStack) 699eace7efcSopenharmony_ci{ 700eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "enter"); 701eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 702eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 703eace7efcSopenharmony_ci return abms->KillProcess(bundleName, clearPageStack); 704eace7efcSopenharmony_ci} 705eace7efcSopenharmony_ci 706eace7efcSopenharmony_ci#ifdef ABILITY_COMMAND_FOR_TEST 707eace7efcSopenharmony_ciErrCode AbilityManagerClient::ForceTimeoutForTest(const std::string &abilityName, const std::string &state) 708eace7efcSopenharmony_ci{ 709eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "enter"); 710eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 711eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 712eace7efcSopenharmony_ci return abms->ForceTimeoutForTest(abilityName, state); 713eace7efcSopenharmony_ci} 714eace7efcSopenharmony_ci#endif 715eace7efcSopenharmony_ci 716eace7efcSopenharmony_ciErrCode AbilityManagerClient::ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, 717eace7efcSopenharmony_ci int32_t missionId, sptr<IRemoteObject> callback, AAFwk::WantParams &wantParams) 718eace7efcSopenharmony_ci{ 719eace7efcSopenharmony_ci if (srcDeviceId.empty() || dstDeviceId.empty() || callback == nullptr) { 720eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "srcDeviceId or dstDeviceId or callback null"); 721eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 722eace7efcSopenharmony_ci } 723eace7efcSopenharmony_ci 724eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 725eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 726eace7efcSopenharmony_ci int result = abms->ContinueMission(srcDeviceId, dstDeviceId, missionId, callback, wantParams); 727eace7efcSopenharmony_ci return result; 728eace7efcSopenharmony_ci} 729eace7efcSopenharmony_ci 730eace7efcSopenharmony_ciErrCode AbilityManagerClient::ContinueMission(AAFwk::ContinueMissionInfo continueMissionInfo, 731eace7efcSopenharmony_ci const sptr<IRemoteObject> &callback) 732eace7efcSopenharmony_ci 733eace7efcSopenharmony_ci{ 734eace7efcSopenharmony_ci if (continueMissionInfo.srcDeviceId.empty() || continueMissionInfo.dstDeviceId.empty() || callback == nullptr) { 735eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "srcDeviceId or dstDeviceId or callback null"); 736eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 737eace7efcSopenharmony_ci } 738eace7efcSopenharmony_ci 739eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 740eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 741eace7efcSopenharmony_ci int result = abms->ContinueMission(continueMissionInfo, callback); 742eace7efcSopenharmony_ci return result; 743eace7efcSopenharmony_ci} 744eace7efcSopenharmony_ci 745eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartContinuation(const Want &want, sptr<IRemoteObject> abilityToken, 746eace7efcSopenharmony_ci int32_t status) 747eace7efcSopenharmony_ci{ 748eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 749eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 750eace7efcSopenharmony_ci int result = abms->StartContinuation(want, abilityToken, status); 751eace7efcSopenharmony_ci return result; 752eace7efcSopenharmony_ci} 753eace7efcSopenharmony_ci 754eace7efcSopenharmony_civoid AbilityManagerClient::NotifyCompleteContinuation(const std::string &deviceId, 755eace7efcSopenharmony_ci int32_t sessionId, bool isSuccess) 756eace7efcSopenharmony_ci{ 757eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 758eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 759eace7efcSopenharmony_ci abms->NotifyCompleteContinuation(deviceId, sessionId, isSuccess); 760eace7efcSopenharmony_ci} 761eace7efcSopenharmony_ci 762eace7efcSopenharmony_ciErrCode AbilityManagerClient::ContinueAbility(const std::string &deviceId, int32_t missionId, uint32_t versionCode) 763eace7efcSopenharmony_ci{ 764eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 765eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 766eace7efcSopenharmony_ci return abms->ContinueAbility(deviceId, missionId, versionCode); 767eace7efcSopenharmony_ci} 768eace7efcSopenharmony_ci 769eace7efcSopenharmony_ciErrCode AbilityManagerClient::NotifyContinuationResult(int32_t missionId, int32_t result) 770eace7efcSopenharmony_ci{ 771eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 772eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 773eace7efcSopenharmony_ci return abms->NotifyContinuationResult(missionId, result); 774eace7efcSopenharmony_ci} 775eace7efcSopenharmony_ci 776eace7efcSopenharmony_ciErrCode AbilityManagerClient::LockMissionForCleanup(int32_t missionId) 777eace7efcSopenharmony_ci{ 778eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 779eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 780eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 781eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 782eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, LockMissionForCleanup"); 783eace7efcSopenharmony_ci auto err = sceneSessionManager->LockSession(missionId); 784eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 785eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, LockMissionForCleanup err"); 786eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 787eace7efcSopenharmony_ci } 788eace7efcSopenharmony_ci return static_cast<int>(err); 789eace7efcSopenharmony_ci } 790eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 791eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 792eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 793eace7efcSopenharmony_ci return abms->LockMissionForCleanup(missionId); 794eace7efcSopenharmony_ci} 795eace7efcSopenharmony_ci 796eace7efcSopenharmony_ciErrCode AbilityManagerClient::UnlockMissionForCleanup(int32_t missionId) 797eace7efcSopenharmony_ci{ 798eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 799eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 800eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 801eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 802eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 803eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, UnlockMissionForCleanup"); 804eace7efcSopenharmony_ci auto err = sceneSessionManager->UnlockSession(missionId); 805eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 806eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, UnlockMissionForCleanup err"); 807eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 808eace7efcSopenharmony_ci } 809eace7efcSopenharmony_ci return static_cast<int>(err); 810eace7efcSopenharmony_ci } 811eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 812eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 813eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 814eace7efcSopenharmony_ci return abms->UnlockMissionForCleanup(missionId); 815eace7efcSopenharmony_ci} 816eace7efcSopenharmony_ci 817eace7efcSopenharmony_civoid AbilityManagerClient::SetLockedState(int32_t sessionId, bool lockedState) 818eace7efcSopenharmony_ci{ 819eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 820eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 821eace7efcSopenharmony_ci abms->SetLockedState(sessionId, lockedState); 822eace7efcSopenharmony_ci} 823eace7efcSopenharmony_ci 824eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterMissionListener(sptr<IMissionListener> listener) 825eace7efcSopenharmony_ci{ 826eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 827eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 828eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 829eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 830eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, RegisterMissionListener"); 831eace7efcSopenharmony_ci auto err = sceneSessionManager->RegisterSessionListener(listener); 832eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 833eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, RegisterMissionListener err"); 834eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 835eace7efcSopenharmony_ci } 836eace7efcSopenharmony_ci return static_cast<int>(err); 837eace7efcSopenharmony_ci } 838eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 839eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 840eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 841eace7efcSopenharmony_ci return abms->RegisterMissionListener(listener); 842eace7efcSopenharmony_ci} 843eace7efcSopenharmony_ci 844eace7efcSopenharmony_ciErrCode AbilityManagerClient::UnRegisterMissionListener(sptr<IMissionListener> listener) 845eace7efcSopenharmony_ci{ 846eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 847eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 848eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 849eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 850eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, UnRegisterMissionListener"); 851eace7efcSopenharmony_ci auto err = sceneSessionManager->UnRegisterSessionListener(listener); 852eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 853eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, UnRegisterMissionListener err"); 854eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 855eace7efcSopenharmony_ci } 856eace7efcSopenharmony_ci return static_cast<int>(err); 857eace7efcSopenharmony_ci } 858eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 859eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 860eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 861eace7efcSopenharmony_ci return abms->UnRegisterMissionListener(listener); 862eace7efcSopenharmony_ci} 863eace7efcSopenharmony_ci 864eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterMissionListener(const std::string &deviceId, 865eace7efcSopenharmony_ci sptr<IRemoteMissionListener> listener) 866eace7efcSopenharmony_ci{ 867eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 868eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 869eace7efcSopenharmony_ci return abms->RegisterMissionListener(deviceId, listener); 870eace7efcSopenharmony_ci} 871eace7efcSopenharmony_ci 872eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterOnListener(const std::string &type, 873eace7efcSopenharmony_ci sptr<IRemoteOnListener> listener) 874eace7efcSopenharmony_ci{ 875eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 876eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 877eace7efcSopenharmony_ci return abms->RegisterOnListener(type, listener); 878eace7efcSopenharmony_ci} 879eace7efcSopenharmony_ci 880eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterOffListener(const std::string &type, 881eace7efcSopenharmony_ci sptr<IRemoteOnListener> listener) 882eace7efcSopenharmony_ci{ 883eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 884eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 885eace7efcSopenharmony_ci return abms->RegisterOffListener(type, listener); 886eace7efcSopenharmony_ci} 887eace7efcSopenharmony_ci 888eace7efcSopenharmony_ciErrCode AbilityManagerClient::UnRegisterMissionListener(const std::string &deviceId, 889eace7efcSopenharmony_ci sptr<IRemoteMissionListener> listener) 890eace7efcSopenharmony_ci{ 891eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 892eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 893eace7efcSopenharmony_ci return abms->UnRegisterMissionListener(deviceId, listener); 894eace7efcSopenharmony_ci} 895eace7efcSopenharmony_ci 896eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetMissionInfos(const std::string& deviceId, int32_t numMax, 897eace7efcSopenharmony_ci std::vector<MissionInfo> &missionInfos) 898eace7efcSopenharmony_ci{ 899eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 900eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 901eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 902eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 903eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 904eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, GetMissionInfos"); 905eace7efcSopenharmony_ci auto err = sceneSessionManager->GetSessionInfos(deviceId, numMax, missionInfos); 906eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 907eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, GetMissionInfos err"); 908eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 909eace7efcSopenharmony_ci } 910eace7efcSopenharmony_ci return static_cast<int>(err); 911eace7efcSopenharmony_ci } 912eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 913eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 914eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 915eace7efcSopenharmony_ci return abms->GetMissionInfos(deviceId, numMax, missionInfos); 916eace7efcSopenharmony_ci} 917eace7efcSopenharmony_ci 918eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetMissionInfo(const std::string& deviceId, int32_t missionId, 919eace7efcSopenharmony_ci MissionInfo &missionInfo) 920eace7efcSopenharmony_ci{ 921eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 922eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 923eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 924eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 925eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 926eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, GetMissionInfo"); 927eace7efcSopenharmony_ci auto err = sceneSessionManager->GetSessionInfo(deviceId, missionId, missionInfo); 928eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 929eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, GetMissionInfo err"); 930eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 931eace7efcSopenharmony_ci } 932eace7efcSopenharmony_ci return static_cast<int>(err); 933eace7efcSopenharmony_ci } 934eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 935eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 936eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 937eace7efcSopenharmony_ci return abms->GetMissionInfo(deviceId, missionId, missionInfo); 938eace7efcSopenharmony_ci} 939eace7efcSopenharmony_ci 940eace7efcSopenharmony_ciErrCode AbilityManagerClient::CleanMission(int32_t missionId) 941eace7efcSopenharmony_ci{ 942eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 943eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 944eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 945eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 946eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 947eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, CleanMission"); 948eace7efcSopenharmony_ci auto err = sceneSessionManager->ClearSession(missionId); 949eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 950eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, CleanMission err"); 951eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 952eace7efcSopenharmony_ci } 953eace7efcSopenharmony_ci return static_cast<int>(err); 954eace7efcSopenharmony_ci } 955eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 956eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 957eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 958eace7efcSopenharmony_ci return abms->CleanMission(missionId); 959eace7efcSopenharmony_ci} 960eace7efcSopenharmony_ci 961eace7efcSopenharmony_ciErrCode AbilityManagerClient::CleanAllMissions() 962eace7efcSopenharmony_ci{ 963eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 964eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 965eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 966eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 967eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 968eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, CleanAllMissions"); 969eace7efcSopenharmony_ci auto err = sceneSessionManager->ClearAllSessions(); 970eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 971eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, CleanAllMissions err"); 972eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 973eace7efcSopenharmony_ci } 974eace7efcSopenharmony_ci return static_cast<int>(err); 975eace7efcSopenharmony_ci } 976eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 977eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 978eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 979eace7efcSopenharmony_ci return abms->CleanAllMissions(); 980eace7efcSopenharmony_ci} 981eace7efcSopenharmony_ci 982eace7efcSopenharmony_ciErrCode AbilityManagerClient::MoveMissionToFront(int32_t missionId) 983eace7efcSopenharmony_ci{ 984eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 985eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 986eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 987eace7efcSopenharmony_ci return abms->MoveMissionToFront(missionId); 988eace7efcSopenharmony_ci} 989eace7efcSopenharmony_ci 990eace7efcSopenharmony_ciErrCode AbilityManagerClient::MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) 991eace7efcSopenharmony_ci{ 992eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 993eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 994eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 995eace7efcSopenharmony_ci return abms->MoveMissionToFront(missionId, startOptions); 996eace7efcSopenharmony_ci} 997eace7efcSopenharmony_ci 998eace7efcSopenharmony_ciErrCode AbilityManagerClient::MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) 999eace7efcSopenharmony_ci{ 1000eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call,topMissionId:%{public}d", topMissionId); 1001eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1002eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 1003eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1004eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 1005eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, MoveMissionsToForeground"); 1006eace7efcSopenharmony_ci auto err = sceneSessionManager->MoveSessionsToForeground(missionIds, topMissionId); 1007eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 1008eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, MoveMissionsToForeground err"); 1009eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 1010eace7efcSopenharmony_ci } 1011eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1012eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1013eace7efcSopenharmony_ci if (missionIds.empty()) { 1014eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 1015eace7efcSopenharmony_ci } 1016eace7efcSopenharmony_ci int32_t missionId = topMissionId; 1017eace7efcSopenharmony_ci if (topMissionId > 0) { 1018eace7efcSopenharmony_ci missionId = topMissionId; 1019eace7efcSopenharmony_ci } else { 1020eace7efcSopenharmony_ci missionId = missionIds[0]; 1021eace7efcSopenharmony_ci } 1022eace7efcSopenharmony_ci auto errAMS = abms->MoveMissionToFront(missionId); 1023eace7efcSopenharmony_ci return static_cast<int>(errAMS); 1024eace7efcSopenharmony_ci } 1025eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 1026eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1027eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1028eace7efcSopenharmony_ci return abms->MoveMissionsToForeground(missionIds, topMissionId); 1029eace7efcSopenharmony_ci} 1030eace7efcSopenharmony_ci 1031eace7efcSopenharmony_ciErrCode AbilityManagerClient::MoveMissionsToBackground(const std::vector<int32_t>& missionIds, 1032eace7efcSopenharmony_ci std::vector<int32_t>& result) 1033eace7efcSopenharmony_ci{ 1034eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1035eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1036eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 1037eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1038eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 1039eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, MoveMissionsToBackground"); 1040eace7efcSopenharmony_ci auto err = sceneSessionManager->MoveSessionsToBackground(missionIds, result); 1041eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 1042eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, MoveMissionsToBackground err"); 1043eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 1044eace7efcSopenharmony_ci } 1045eace7efcSopenharmony_ci return static_cast<int>(err); 1046eace7efcSopenharmony_ci } 1047eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 1048eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1049eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1050eace7efcSopenharmony_ci return abms->MoveMissionsToBackground(missionIds, result); 1051eace7efcSopenharmony_ci} 1052eace7efcSopenharmony_ci 1053eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetMissionIdByToken(sptr<IRemoteObject> token, int32_t &missionId) 1054eace7efcSopenharmony_ci{ 1055eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1056eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1057eace7efcSopenharmony_ci missionId = abms->GetMissionIdByToken(token); 1058eace7efcSopenharmony_ci if (missionId <= 0) { 1059eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "get missionid failed"); 1060eace7efcSopenharmony_ci return MISSION_NOT_FOUND; 1061eace7efcSopenharmony_ci } 1062eace7efcSopenharmony_ci return ERR_OK; 1063eace7efcSopenharmony_ci} 1064eace7efcSopenharmony_ci 1065eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbilityByCall(const Want &want, sptr<IAbilityConnection> connect) 1066eace7efcSopenharmony_ci{ 1067eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1068eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1069eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1070eace7efcSopenharmony_ci return abms->StartAbilityByCall(want, connect, nullptr, DEFAULT_INVAL_VALUE); 1071eace7efcSopenharmony_ci} 1072eace7efcSopenharmony_ci 1073eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartAbilityByCall(const Want &want, sptr<IAbilityConnection> connect, 1074eace7efcSopenharmony_ci sptr<IRemoteObject> callToken, int32_t accountId) 1075eace7efcSopenharmony_ci{ 1076eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1077eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1078eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1079eace7efcSopenharmony_ci return abms->StartAbilityByCall(want, connect, callToken, accountId); 1080eace7efcSopenharmony_ci} 1081eace7efcSopenharmony_ci 1082eace7efcSopenharmony_civoid AbilityManagerClient::CallRequestDone(sptr<IRemoteObject> token, sptr<IRemoteObject> callStub) 1083eace7efcSopenharmony_ci{ 1084eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1085eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1086eace7efcSopenharmony_ci abms->CallRequestDone(token, callStub); 1087eace7efcSopenharmony_ci} 1088eace7efcSopenharmony_ci 1089eace7efcSopenharmony_civoid AbilityManagerClient::GetAbilityTokenByCalleeObj(sptr<IRemoteObject> callStub, sptr<IRemoteObject> &token) 1090eace7efcSopenharmony_ci{ 1091eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1092eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1093eace7efcSopenharmony_ci abms->GetAbilityTokenByCalleeObj(callStub, token); 1094eace7efcSopenharmony_ci} 1095eace7efcSopenharmony_ci 1096eace7efcSopenharmony_ciErrCode AbilityManagerClient::ReleaseCall( 1097eace7efcSopenharmony_ci sptr<IAbilityConnection> connect, const AppExecFwk::ElementName &element) 1098eace7efcSopenharmony_ci{ 1099eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1100eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1101eace7efcSopenharmony_ci return abms->ReleaseCall(connect, element); 1102eace7efcSopenharmony_ci} 1103eace7efcSopenharmony_ci 1104eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info) 1105eace7efcSopenharmony_ci{ 1106eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1107eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1108eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1109eace7efcSopenharmony_ci return abms->GetAbilityRunningInfos(info); 1110eace7efcSopenharmony_ci} 1111eace7efcSopenharmony_ci 1112eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info) 1113eace7efcSopenharmony_ci{ 1114eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1115eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1116eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1117eace7efcSopenharmony_ci return abms->GetExtensionRunningInfos(upperLimit, info); 1118eace7efcSopenharmony_ci} 1119eace7efcSopenharmony_ci 1120eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info) 1121eace7efcSopenharmony_ci{ 1122eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1123eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1124eace7efcSopenharmony_ci return abms->GetProcessRunningInfos(info); 1125eace7efcSopenharmony_ci} 1126eace7efcSopenharmony_ci 1127eace7efcSopenharmony_ciErrCode AbilityManagerClient::RequestDialogService( 1128eace7efcSopenharmony_ci const Want &want, sptr<IRemoteObject> callerToken) 1129eace7efcSopenharmony_ci{ 1130eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1131eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1132eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1133eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "request:%{public}s", want.GetElement().GetURI().c_str()); 1134eace7efcSopenharmony_ci HandleDlpApp(const_cast<Want &>(want)); 1135eace7efcSopenharmony_ci return abms->RequestDialogService(want, callerToken); 1136eace7efcSopenharmony_ci} 1137eace7efcSopenharmony_ci 1138eace7efcSopenharmony_ciErrCode AbilityManagerClient::ReportDrawnCompleted(sptr<IRemoteObject> callerToken) 1139eace7efcSopenharmony_ci{ 1140eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1141eace7efcSopenharmony_ci auto abilityMgr = GetAbilityManager(); 1142eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abilityMgr); 1143eace7efcSopenharmony_ci return abilityMgr->ReportDrawnCompleted(callerToken); 1144eace7efcSopenharmony_ci} 1145eace7efcSopenharmony_ci 1146eace7efcSopenharmony_ci/** 1147eace7efcSopenharmony_ci * Start synchronizing remote device mission 1148eace7efcSopenharmony_ci * @param devId, deviceId. 1149eace7efcSopenharmony_ci * @param fixConflict, resolve synchronizing conflicts flag. 1150eace7efcSopenharmony_ci * @param tag, call tag. 1151eace7efcSopenharmony_ci * @return Returns ERR_OK on success, others on failure. 1152eace7efcSopenharmony_ci */ 1153eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartSyncRemoteMissions(const std::string &devId, bool fixConflict, int64_t tag) 1154eace7efcSopenharmony_ci{ 1155eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1156eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1157eace7efcSopenharmony_ci return abms->StartSyncRemoteMissions(devId, fixConflict, tag); 1158eace7efcSopenharmony_ci} 1159eace7efcSopenharmony_ci 1160eace7efcSopenharmony_ciErrCode AbilityManagerClient::StopSyncRemoteMissions(const std::string &devId) 1161eace7efcSopenharmony_ci{ 1162eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1163eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1164eace7efcSopenharmony_ci return abms->StopSyncRemoteMissions(devId); 1165eace7efcSopenharmony_ci} 1166eace7efcSopenharmony_ci 1167eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartUser(int accountId, sptr<IUserCallback> callback, bool isAppRecovery) 1168eace7efcSopenharmony_ci{ 1169eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "accountId:%{public}d, isAppRecovery:%{public}d", 1170eace7efcSopenharmony_ci accountId, isAppRecovery); 1171eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1172eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1173eace7efcSopenharmony_ci return abms->StartUser(accountId, callback, isAppRecovery); 1174eace7efcSopenharmony_ci} 1175eace7efcSopenharmony_ci 1176eace7efcSopenharmony_ciErrCode AbilityManagerClient::StopUser(int accountId, sptr<IUserCallback> callback) 1177eace7efcSopenharmony_ci{ 1178eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "accountId:%{public}d", accountId); 1179eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1180eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1181eace7efcSopenharmony_ci return abms->StopUser(accountId, callback); 1182eace7efcSopenharmony_ci} 1183eace7efcSopenharmony_ci 1184eace7efcSopenharmony_ciErrCode AbilityManagerClient::LogoutUser(int32_t accountId) 1185eace7efcSopenharmony_ci{ 1186eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1187eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1188eace7efcSopenharmony_ci return abms->LogoutUser(accountId); 1189eace7efcSopenharmony_ci} 1190eace7efcSopenharmony_ci 1191eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterSnapshotHandler(sptr<ISnapshotHandler> handler) 1192eace7efcSopenharmony_ci{ 1193eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1194eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1195eace7efcSopenharmony_ci return abms->RegisterSnapshotHandler(handler); 1196eace7efcSopenharmony_ci} 1197eace7efcSopenharmony_ci 1198eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetMissionSnapshot(const std::string& deviceId, int32_t missionId, 1199eace7efcSopenharmony_ci MissionSnapshot& snapshot, bool isLowResolution) 1200eace7efcSopenharmony_ci{ 1201eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1202eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1203eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 1204eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1205eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 1206eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, GetMissionSnapshot"); 1207eace7efcSopenharmony_ci auto err = sceneSessionManager->GetSessionSnapshot(deviceId, missionId, snapshot, isLowResolution); 1208eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 1209eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, GetMissionSnapshot err"); 1210eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 1211eace7efcSopenharmony_ci } 1212eace7efcSopenharmony_ci return static_cast<int>(err); 1213eace7efcSopenharmony_ci } 1214eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 1215eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1216eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1217eace7efcSopenharmony_ci return abms->GetMissionSnapshot(deviceId, missionId, snapshot, isLowResolution); 1218eace7efcSopenharmony_ci} 1219eace7efcSopenharmony_ci 1220eace7efcSopenharmony_ciErrCode AbilityManagerClient::StartUserTest(const Want &want, sptr<IRemoteObject> observer) 1221eace7efcSopenharmony_ci{ 1222eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1223eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1224eace7efcSopenharmony_ci return abms->StartUserTest(want, observer); 1225eace7efcSopenharmony_ci} 1226eace7efcSopenharmony_ci 1227eace7efcSopenharmony_ciErrCode AbilityManagerClient::FinishUserTest( 1228eace7efcSopenharmony_ci const std::string &msg, const int64_t &resultCode, const std::string &bundleName) 1229eace7efcSopenharmony_ci{ 1230eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1231eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1232eace7efcSopenharmony_ci return abms->FinishUserTest(msg, resultCode, bundleName); 1233eace7efcSopenharmony_ci} 1234eace7efcSopenharmony_ci 1235eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetTopAbility(sptr<IRemoteObject> &token) 1236eace7efcSopenharmony_ci{ 1237eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1238eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1239eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 1240eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1241eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 1242eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, GetTopAbility"); 1243eace7efcSopenharmony_ci auto ret = static_cast<int>(sceneSessionManager->GetFocusSessionToken(token)); 1244eace7efcSopenharmony_ci if (ret != ERR_OK) { 1245eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, GetTopAbility err: %{public}d", ret); 1246eace7efcSopenharmony_ci } 1247eace7efcSopenharmony_ci return ret; 1248eace7efcSopenharmony_ci } 1249eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 1250eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1251eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1252eace7efcSopenharmony_ci return abms->GetTopAbility(token); 1253eace7efcSopenharmony_ci} 1254eace7efcSopenharmony_ci 1255eace7efcSopenharmony_ciAppExecFwk::ElementName AbilityManagerClient::GetElementNameByToken(sptr<IRemoteObject> token, 1256eace7efcSopenharmony_ci bool isNeedLocalDeviceId) 1257eace7efcSopenharmony_ci{ 1258eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1259eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1260eace7efcSopenharmony_ci if (abms == nullptr) { 1261eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null abms"); 1262eace7efcSopenharmony_ci return {}; 1263eace7efcSopenharmony_ci } 1264eace7efcSopenharmony_ci return abms->GetElementNameByToken(token, isNeedLocalDeviceId); 1265eace7efcSopenharmony_ci} 1266eace7efcSopenharmony_ci 1267eace7efcSopenharmony_ciErrCode AbilityManagerClient::CheckUIExtensionIsFocused(uint32_t uiExtensionTokenId, bool& isFocused) 1268eace7efcSopenharmony_ci{ 1269eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1270eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1271eace7efcSopenharmony_ci return abms->CheckUIExtensionIsFocused(uiExtensionTokenId, isFocused); 1272eace7efcSopenharmony_ci} 1273eace7efcSopenharmony_ci 1274eace7efcSopenharmony_ciErrCode AbilityManagerClient::DelegatorDoAbilityForeground(sptr<IRemoteObject> token) 1275eace7efcSopenharmony_ci{ 1276eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1277eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 1278eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1279eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 1280eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, DelegatorDoAbilityForeground"); 1281eace7efcSopenharmony_ci sceneSessionManager->PendingSessionToForeground(token); 1282eace7efcSopenharmony_ci } 1283eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 1284eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1285eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1286eace7efcSopenharmony_ci return abms->DelegatorDoAbilityForeground(token); 1287eace7efcSopenharmony_ci} 1288eace7efcSopenharmony_ci 1289eace7efcSopenharmony_ciErrCode AbilityManagerClient::DelegatorDoAbilityBackground(sptr<IRemoteObject> token) 1290eace7efcSopenharmony_ci{ 1291eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1292eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 1293eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1294eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 1295eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, DelegatorDoAbilityBackground"); 1296eace7efcSopenharmony_ci sceneSessionManager->PendingSessionToBackgroundForDelegator(token); 1297eace7efcSopenharmony_ci } 1298eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 1299eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1300eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1301eace7efcSopenharmony_ci return abms->DelegatorDoAbilityBackground(token); 1302eace7efcSopenharmony_ci} 1303eace7efcSopenharmony_ci 1304eace7efcSopenharmony_ciErrCode AbilityManagerClient::SetMissionContinueState(sptr<IRemoteObject> token, 1305eace7efcSopenharmony_ci const AAFwk::ContinueState &state, sptr<IRemoteObject> sessionToken) 1306eace7efcSopenharmony_ci{ 1307eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, 1308eace7efcSopenharmony_ci "called state:%{public}d", state); 1309eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1310eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled() && sessionToken) { 1311eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1312eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 1313eace7efcSopenharmony_ci uint32_t value = static_cast<uint32_t>(state); 1314eace7efcSopenharmony_ci Rosen::ContinueState continueState = static_cast<Rosen::ContinueState>(value); 1315eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, SetMissionContinueState"); 1316eace7efcSopenharmony_ci auto ret = static_cast<int>(sceneSessionManager->SetSessionContinueState(sessionToken, continueState)); 1317eace7efcSopenharmony_ci if (ret != ERR_OK) { 1318eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, SetMissionContinueState err"); 1319eace7efcSopenharmony_ci } 1320eace7efcSopenharmony_ci return ret; 1321eace7efcSopenharmony_ci } 1322eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 1323eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1324eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1325eace7efcSopenharmony_ci return abms->SetMissionContinueState(token, state); 1326eace7efcSopenharmony_ci} 1327eace7efcSopenharmony_ci 1328eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1329eace7efcSopenharmony_ciErrCode AbilityManagerClient::SetMissionLabel(sptr<IRemoteObject> token, const std::string& label) 1330eace7efcSopenharmony_ci{ 1331eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 1332eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1333eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 1334eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, SetMissionLabel"); 1335eace7efcSopenharmony_ci auto err = sceneSessionManager->SetSessionLabel(token, label); 1336eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 1337eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, SetMissionLabel err"); 1338eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 1339eace7efcSopenharmony_ci } 1340eace7efcSopenharmony_ci return static_cast<int>(err); 1341eace7efcSopenharmony_ci } 1342eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1343eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1344eace7efcSopenharmony_ci return abms->SetMissionLabel(token, label); 1345eace7efcSopenharmony_ci} 1346eace7efcSopenharmony_ci 1347eace7efcSopenharmony_ciErrCode AbilityManagerClient::SetMissionIcon( 1348eace7efcSopenharmony_ci sptr<IRemoteObject> abilityToken, std::shared_ptr<OHOS::Media::PixelMap> icon) 1349eace7efcSopenharmony_ci{ 1350eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 1351eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1352eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 1353eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, SetMissionIcon"); 1354eace7efcSopenharmony_ci auto err = sceneSessionManager->SetSessionIcon(abilityToken, icon); 1355eace7efcSopenharmony_ci if (SCB_TO_MISSION_ERROR_CODE_MAP.count(err)) { 1356eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, SetMissionIcon err"); 1357eace7efcSopenharmony_ci return SCB_TO_MISSION_ERROR_CODE_MAP[err]; 1358eace7efcSopenharmony_ci } 1359eace7efcSopenharmony_ci return static_cast<int>(err); 1360eace7efcSopenharmony_ci } 1361eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1362eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1363eace7efcSopenharmony_ci return abms->SetMissionIcon(abilityToken, icon); 1364eace7efcSopenharmony_ci} 1365eace7efcSopenharmony_ci 1366eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterWindowManagerServiceHandler(sptr<IWindowManagerServiceHandler> handler, 1367eace7efcSopenharmony_ci bool animationEnabled) 1368eace7efcSopenharmony_ci{ 1369eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1370eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1371eace7efcSopenharmony_ci return abms->RegisterWindowManagerServiceHandler(handler, animationEnabled); 1372eace7efcSopenharmony_ci} 1373eace7efcSopenharmony_ci 1374eace7efcSopenharmony_civoid AbilityManagerClient::CompleteFirstFrameDrawing(sptr<IRemoteObject> abilityToken) 1375eace7efcSopenharmony_ci{ 1376eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1377eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1378eace7efcSopenharmony_ci abms->CompleteFirstFrameDrawing(abilityToken); 1379eace7efcSopenharmony_ci} 1380eace7efcSopenharmony_ci 1381eace7efcSopenharmony_civoid AbilityManagerClient::CompleteFirstFrameDrawing(int32_t sessionId) 1382eace7efcSopenharmony_ci{ 1383eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1384eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1385eace7efcSopenharmony_ci abms->CompleteFirstFrameDrawing(sessionId); 1386eace7efcSopenharmony_ci} 1387eace7efcSopenharmony_ci 1388eace7efcSopenharmony_ciErrCode AbilityManagerClient::PrepareTerminateAbility(sptr<IRemoteObject> token, 1389eace7efcSopenharmony_ci sptr<IPrepareTerminateCallback> callback) 1390eace7efcSopenharmony_ci{ 1391eace7efcSopenharmony_ci if (callback == nullptr) { 1392eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null callback"); 1393eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 1394eace7efcSopenharmony_ci } 1395eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1396eace7efcSopenharmony_ci if (abms == nullptr) { 1397eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null abms"); 1398eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 1399eace7efcSopenharmony_ci } 1400eace7efcSopenharmony_ci return abms->PrepareTerminateAbility(token, callback); 1401eace7efcSopenharmony_ci} 1402eace7efcSopenharmony_ci 1403eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetDialogSessionInfo(const std::string &dialogSessionId, sptr<DialogSessionInfo> &info) 1404eace7efcSopenharmony_ci{ 1405eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1406eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1407eace7efcSopenharmony_ci return abms->GetDialogSessionInfo(dialogSessionId, info); 1408eace7efcSopenharmony_ci} 1409eace7efcSopenharmony_ci 1410eace7efcSopenharmony_ciErrCode AbilityManagerClient::SendDialogResult(const Want &want, const std::string &dialogSessionId, const bool isAllow) 1411eace7efcSopenharmony_ci{ 1412eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1413eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1414eace7efcSopenharmony_ci return abms->SendDialogResult(want, dialogSessionId, isAllow); 1415eace7efcSopenharmony_ci} 1416eace7efcSopenharmony_ci#endif 1417eace7efcSopenharmony_ci 1418eace7efcSopenharmony_ciErrCode AbilityManagerClient::DoAbilityForeground(sptr<IRemoteObject> token, uint32_t flag) 1419eace7efcSopenharmony_ci{ 1420eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1421eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1422eace7efcSopenharmony_ci return abms->DoAbilityForeground(token, flag); 1423eace7efcSopenharmony_ci} 1424eace7efcSopenharmony_ci 1425eace7efcSopenharmony_ciErrCode AbilityManagerClient::DoAbilityBackground(sptr<IRemoteObject> token, uint32_t flag) 1426eace7efcSopenharmony_ci{ 1427eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1428eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1429eace7efcSopenharmony_ci return abms->DoAbilityBackground(token, flag); 1430eace7efcSopenharmony_ci} 1431eace7efcSopenharmony_ci 1432eace7efcSopenharmony_ciErrCode AbilityManagerClient::SetAbilityController(sptr<AppExecFwk::IAbilityController> abilityController, 1433eace7efcSopenharmony_ci bool imAStabilityTest) 1434eace7efcSopenharmony_ci{ 1435eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1436eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1437eace7efcSopenharmony_ci return abms->SetAbilityController(abilityController, imAStabilityTest); 1438eace7efcSopenharmony_ci} 1439eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1440eace7efcSopenharmony_civoid AbilityManagerClient::UpdateMissionSnapShot(sptr<IRemoteObject> token, 1441eace7efcSopenharmony_ci std::shared_ptr<Media::PixelMap> pixelMap) 1442eace7efcSopenharmony_ci{ 1443eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1444eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1445eace7efcSopenharmony_ci return abms->UpdateMissionSnapShot(token, pixelMap); 1446eace7efcSopenharmony_ci} 1447eace7efcSopenharmony_ci#endif // SUPPORT_SCREEN 1448eace7efcSopenharmony_civoid AbilityManagerClient::EnableRecoverAbility(sptr<IRemoteObject> token) 1449eace7efcSopenharmony_ci{ 1450eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1451eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1452eace7efcSopenharmony_ci return abms->EnableRecoverAbility(token); 1453eace7efcSopenharmony_ci} 1454eace7efcSopenharmony_ci 1455eace7efcSopenharmony_civoid AbilityManagerClient::ScheduleRecoverAbility(sptr<IRemoteObject> token, int32_t reason, const Want *want) 1456eace7efcSopenharmony_ci{ 1457eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1458eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1459eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1460eace7efcSopenharmony_ci return abms->ScheduleRecoverAbility(token, reason, want); 1461eace7efcSopenharmony_ci} 1462eace7efcSopenharmony_ci 1463eace7efcSopenharmony_civoid AbilityManagerClient::SubmitSaveRecoveryInfo(sptr<IRemoteObject> token) 1464eace7efcSopenharmony_ci{ 1465eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1466eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1467eace7efcSopenharmony_ci return abms->SubmitSaveRecoveryInfo(token); 1468eace7efcSopenharmony_ci} 1469eace7efcSopenharmony_ci 1470eace7efcSopenharmony_civoid AbilityManagerClient::ScheduleClearRecoveryPageStack() 1471eace7efcSopenharmony_ci{ 1472eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1473eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1474eace7efcSopenharmony_ci return abms->ScheduleClearRecoveryPageStack(); 1475eace7efcSopenharmony_ci} 1476eace7efcSopenharmony_ci 1477eace7efcSopenharmony_cisptr<IAbilityManager> AbilityManagerClient::GetAbilityManager() 1478eace7efcSopenharmony_ci{ 1479eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1480eace7efcSopenharmony_ci std::lock_guard<std::recursive_mutex> lock(mutex_); 1481eace7efcSopenharmony_ci if (!proxy_) { 1482eace7efcSopenharmony_ci (void)Connect(); 1483eace7efcSopenharmony_ci } 1484eace7efcSopenharmony_ci 1485eace7efcSopenharmony_ci return proxy_; 1486eace7efcSopenharmony_ci} 1487eace7efcSopenharmony_ci 1488eace7efcSopenharmony_civoid AbilityManagerClient::ResetProxy(wptr<IRemoteObject> remote) 1489eace7efcSopenharmony_ci{ 1490eace7efcSopenharmony_ci std::lock_guard<std::recursive_mutex> lock(mutex_); 1491eace7efcSopenharmony_ci if (!proxy_) { 1492eace7efcSopenharmony_ci return; 1493eace7efcSopenharmony_ci } 1494eace7efcSopenharmony_ci 1495eace7efcSopenharmony_ci auto serviceRemote = proxy_->AsObject(); 1496eace7efcSopenharmony_ci if ((serviceRemote != nullptr) && (serviceRemote == remote.promote())) { 1497eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "To remove death recipient."); 1498eace7efcSopenharmony_ci serviceRemote->RemoveDeathRecipient(deathRecipient_); 1499eace7efcSopenharmony_ci proxy_ = nullptr; 1500eace7efcSopenharmony_ci } 1501eace7efcSopenharmony_ci} 1502eace7efcSopenharmony_ci 1503eace7efcSopenharmony_civoid AbilityManagerClient::AbilityMgrDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote) 1504eace7efcSopenharmony_ci{ 1505eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilityMgrDeathRecipient handle remote died."); 1506eace7efcSopenharmony_ci AbilityManagerClient::GetInstance()->ResetProxy(remote); 1507eace7efcSopenharmony_ci} 1508eace7efcSopenharmony_ci 1509eace7efcSopenharmony_ciErrCode AbilityManagerClient::FreeInstallAbilityFromRemote(const Want &want, sptr<IRemoteObject> callback, 1510eace7efcSopenharmony_ci int32_t userId, int requestCode) 1511eace7efcSopenharmony_ci{ 1512eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1513eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1514eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1515eace7efcSopenharmony_ci return abms->FreeInstallAbilityFromRemote(want, callback, userId, requestCode); 1516eace7efcSopenharmony_ci} 1517eace7efcSopenharmony_ci 1518eace7efcSopenharmony_ciAppExecFwk::ElementName AbilityManagerClient::GetTopAbility(bool isNeedLocalDeviceId) 1519eace7efcSopenharmony_ci{ 1520eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1521eace7efcSopenharmony_ci { 1522eace7efcSopenharmony_ci std::lock_guard<std::mutex> lock_l(topAbilityMutex_); 1523eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1524eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 1525eace7efcSopenharmony_ci AppExecFwk::ElementName elementName = {}; 1526eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1527eace7efcSopenharmony_ci if (sceneSessionManager == nullptr) { 1528eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "get sceneSessionManager failed"); 1529eace7efcSopenharmony_ci return elementName; 1530eace7efcSopenharmony_ci } 1531eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, GetTopAbility element"); 1532eace7efcSopenharmony_ci (void)sceneSessionManager->GetFocusSessionElement(elementName); 1533eace7efcSopenharmony_ci return elementName; 1534eace7efcSopenharmony_ci } 1535eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 1536eace7efcSopenharmony_ci } 1537eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "enter."); 1538eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1539eace7efcSopenharmony_ci if (abms == nullptr) { 1540eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null abms"); 1541eace7efcSopenharmony_ci return {}; 1542eace7efcSopenharmony_ci } 1543eace7efcSopenharmony_ci 1544eace7efcSopenharmony_ci return abms->GetTopAbility(isNeedLocalDeviceId); 1545eace7efcSopenharmony_ci} 1546eace7efcSopenharmony_ci 1547eace7efcSopenharmony_ciErrCode AbilityManagerClient::DumpAbilityInfoDone(std::vector<std::string> &infos, 1548eace7efcSopenharmony_ci sptr<IRemoteObject> callerToken) 1549eace7efcSopenharmony_ci{ 1550eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1551eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1552eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1553eace7efcSopenharmony_ci return abms->DumpAbilityInfoDone(infos, callerToken); 1554eace7efcSopenharmony_ci} 1555eace7efcSopenharmony_ci 1556eace7efcSopenharmony_civoid AbilityManagerClient::HandleDlpApp(Want &want) 1557eace7efcSopenharmony_ci{ 1558eace7efcSopenharmony_ci#ifdef WITH_DLP 1559eace7efcSopenharmony_ci if (!want.GetParams().HasParam(DLP_PARAMS_SANDBOX)) { 1560eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "Security::DlpPermission::DlpFileKits::GetSandboxFlag"); 1561eace7efcSopenharmony_ci bool sandboxFlag = Security::DlpPermission::DlpFileKits::GetSandboxFlag(want); 1562eace7efcSopenharmony_ci want.SetParam(DLP_PARAMS_SANDBOX, sandboxFlag); 1563eace7efcSopenharmony_ci } 1564eace7efcSopenharmony_ci#endif // WITH_DLP 1565eace7efcSopenharmony_ci} 1566eace7efcSopenharmony_ci 1567eace7efcSopenharmony_ciErrCode AbilityManagerClient::AddFreeInstallObserver(const sptr<IRemoteObject> callerToken, 1568eace7efcSopenharmony_ci const sptr<AbilityRuntime::IFreeInstallObserver> observer) 1569eace7efcSopenharmony_ci{ 1570eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1571eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1572eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1573eace7efcSopenharmony_ci return abms->AddFreeInstallObserver(callerToken, observer); 1574eace7efcSopenharmony_ci} 1575eace7efcSopenharmony_ci 1576eace7efcSopenharmony_ciint32_t AbilityManagerClient::IsValidMissionIds( 1577eace7efcSopenharmony_ci const std::vector<int32_t> &missionIds, std::vector<MissionValidResult> &results) 1578eace7efcSopenharmony_ci{ 1579eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1580eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 1581eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 1582eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 1583eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 1584eace7efcSopenharmony_ci std::vector<bool> isValidList; 1585eace7efcSopenharmony_ci auto err = sceneSessionManager->IsValidSessionIds(missionIds, isValidList); 1586eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, IsValidSessionIds: %{public}d, size: %{public}d", 1587eace7efcSopenharmony_ci static_cast<int>(err), static_cast<int32_t>(isValidList.size())); 1588eace7efcSopenharmony_ci for (auto i = 0; i < static_cast<int32_t>(isValidList.size()); ++i) { 1589eace7efcSopenharmony_ci MissionValidResult missionResult = {}; 1590eace7efcSopenharmony_ci missionResult.missionId = missionIds.at(i); 1591eace7efcSopenharmony_ci missionResult.isValid = isValidList.at(i); 1592eace7efcSopenharmony_ci results.push_back(missionResult); 1593eace7efcSopenharmony_ci } 1594eace7efcSopenharmony_ci return static_cast<int>(err); 1595eace7efcSopenharmony_ci } 1596eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 1597eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1598eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1599eace7efcSopenharmony_ci return abms->IsValidMissionIds(missionIds, results); 1600eace7efcSopenharmony_ci} 1601eace7efcSopenharmony_ci 1602eace7efcSopenharmony_ciErrCode AbilityManagerClient::VerifyPermission(const std::string &permission, int pid, int uid) 1603eace7efcSopenharmony_ci{ 1604eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1605eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1606eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1607eace7efcSopenharmony_ci return abms->VerifyPermission(permission, pid, uid); 1608eace7efcSopenharmony_ci} 1609eace7efcSopenharmony_ci 1610eace7efcSopenharmony_ciErrCode AbilityManagerClient::AcquireShareData( 1611eace7efcSopenharmony_ci int32_t missionId, sptr<IAcquireShareDataCallback> shareData) 1612eace7efcSopenharmony_ci{ 1613eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1614eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1615eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1616eace7efcSopenharmony_ci return abms->AcquireShareData(missionId, shareData); 1617eace7efcSopenharmony_ci} 1618eace7efcSopenharmony_ci 1619eace7efcSopenharmony_ciErrCode AbilityManagerClient::ShareDataDone( 1620eace7efcSopenharmony_ci sptr<IRemoteObject> token, int32_t resultCode, int32_t uniqueId, WantParams &wantParam) 1621eace7efcSopenharmony_ci{ 1622eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1623eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1624eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1625eace7efcSopenharmony_ci return abms->ShareDataDone(token, resultCode, uniqueId, wantParam); 1626eace7efcSopenharmony_ci} 1627eace7efcSopenharmony_ci 1628eace7efcSopenharmony_ciErrCode AbilityManagerClient::ForceExitApp(const int32_t pid, const ExitReason &exitReason) 1629eace7efcSopenharmony_ci{ 1630eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1631eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1632eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1633eace7efcSopenharmony_ci return abms->ForceExitApp(pid, exitReason); 1634eace7efcSopenharmony_ci} 1635eace7efcSopenharmony_ci 1636eace7efcSopenharmony_ciErrCode AbilityManagerClient::RecordAppExitReason(const ExitReason &exitReason) 1637eace7efcSopenharmony_ci{ 1638eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "RecordAppExitReason reason:%{public}d, exitMsg: %{public}s", exitReason.reason, 1639eace7efcSopenharmony_ci exitReason.exitMsg.c_str()); 1640eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1641eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1642eace7efcSopenharmony_ci return abms->RecordAppExitReason(exitReason); 1643eace7efcSopenharmony_ci} 1644eace7efcSopenharmony_ci 1645eace7efcSopenharmony_ciErrCode AbilityManagerClient::RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason) 1646eace7efcSopenharmony_ci{ 1647eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "RecordProcessExitReason pid:%{public}d, reason:%{public}d, exitMsg: %{public}s", 1648eace7efcSopenharmony_ci pid, exitReason.reason, exitReason.exitMsg.c_str()); 1649eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1650eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1651eace7efcSopenharmony_ci return abms->RecordProcessExitReason(pid, exitReason); 1652eace7efcSopenharmony_ci} 1653eace7efcSopenharmony_ci 1654eace7efcSopenharmony_civoid AbilityManagerClient::SetRootSceneSession(sptr<IRemoteObject> rootSceneSession) 1655eace7efcSopenharmony_ci{ 1656eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1657eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1658eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1659eace7efcSopenharmony_ci abms->SetRootSceneSession(rootSceneSession); 1660eace7efcSopenharmony_ci} 1661eace7efcSopenharmony_ci 1662eace7efcSopenharmony_civoid AbilityManagerClient::CallUIAbilityBySCB(sptr<SessionInfo> sessionInfo, bool &isColdStart) 1663eace7efcSopenharmony_ci{ 1664eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1665eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1666eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, CallUIAbilityBySCB target: %{public}s", 1667eace7efcSopenharmony_ci sessionInfo->want.GetElement().GetURI().c_str()); 1668eace7efcSopenharmony_ci abms->CallUIAbilityBySCB(sessionInfo, isColdStart); 1669eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "scb call, CallUIAbilityBySCB, isColdStart: %{public}d", isColdStart); 1670eace7efcSopenharmony_ci} 1671eace7efcSopenharmony_ci 1672eace7efcSopenharmony_civoid AbilityManagerClient::StartSpecifiedAbilityBySCB(const Want &want) 1673eace7efcSopenharmony_ci{ 1674eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1675eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1676eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, StartSpecifiedAbilityBySCB, target: %{public}s", 1677eace7efcSopenharmony_ci want.GetElement().GetURI().c_str()); 1678eace7efcSopenharmony_ci abms->StartSpecifiedAbilityBySCB(want); 1679eace7efcSopenharmony_ci} 1680eace7efcSopenharmony_ci 1681eace7efcSopenharmony_ciErrCode AbilityManagerClient::NotifySaveAsResult(const Want &want, int resultCode, int requestCode) 1682eace7efcSopenharmony_ci{ 1683eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "call."); 1684eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1685eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1686eace7efcSopenharmony_ci return abms->NotifySaveAsResult(want, resultCode, requestCode); 1687eace7efcSopenharmony_ci} 1688eace7efcSopenharmony_ci 1689eace7efcSopenharmony_ciErrCode AbilityManagerClient::SetSessionManagerService(sptr<IRemoteObject> sessionManagerService) 1690eace7efcSopenharmony_ci{ 1691eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1692eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1693eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1694eace7efcSopenharmony_ci return abms->SetSessionManagerService(sessionManagerService); 1695eace7efcSopenharmony_ci} 1696eace7efcSopenharmony_ci 1697eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterIAbilityManagerCollaborator( 1698eace7efcSopenharmony_ci int32_t type, sptr<IAbilityManagerCollaborator> impl) 1699eace7efcSopenharmony_ci{ 1700eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1701eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1702eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1703eace7efcSopenharmony_ci return abms->RegisterIAbilityManagerCollaborator(type, impl); 1704eace7efcSopenharmony_ci} 1705eace7efcSopenharmony_ci 1706eace7efcSopenharmony_ciErrCode AbilityManagerClient::UnregisterIAbilityManagerCollaborator(int32_t type) 1707eace7efcSopenharmony_ci{ 1708eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1709eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1710eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1711eace7efcSopenharmony_ci return abms->UnregisterIAbilityManagerCollaborator(type); 1712eace7efcSopenharmony_ci} 1713eace7efcSopenharmony_ci 1714eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterStatusBarDelegate(sptr<AbilityRuntime::IStatusBarDelegate> delegate) 1715eace7efcSopenharmony_ci{ 1716eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1717eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1718eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1719eace7efcSopenharmony_ci return abms->RegisterStatusBarDelegate(delegate); 1720eace7efcSopenharmony_ci} 1721eace7efcSopenharmony_ci 1722eace7efcSopenharmony_ciErrCode AbilityManagerClient::KillProcessWithPrepareTerminate(const std::vector<int32_t>& pids) 1723eace7efcSopenharmony_ci{ 1724eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1725eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1726eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1727eace7efcSopenharmony_ci return abms->KillProcessWithPrepareTerminate(pids); 1728eace7efcSopenharmony_ci} 1729eace7efcSopenharmony_ci 1730eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterAutoStartupSystemCallback(sptr<IRemoteObject> callback) 1731eace7efcSopenharmony_ci{ 1732eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1733eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1734eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1735eace7efcSopenharmony_ci return abms->RegisterAutoStartupSystemCallback(callback); 1736eace7efcSopenharmony_ci} 1737eace7efcSopenharmony_ci 1738eace7efcSopenharmony_ciErrCode AbilityManagerClient::UnregisterAutoStartupSystemCallback(sptr<IRemoteObject> callback) 1739eace7efcSopenharmony_ci{ 1740eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1741eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1742eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1743eace7efcSopenharmony_ci return abms->UnregisterAutoStartupSystemCallback(callback); 1744eace7efcSopenharmony_ci} 1745eace7efcSopenharmony_ci 1746eace7efcSopenharmony_ciErrCode AbilityManagerClient::SetApplicationAutoStartup(const AutoStartupInfo &info) 1747eace7efcSopenharmony_ci{ 1748eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1749eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1750eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1751eace7efcSopenharmony_ci return abms->SetApplicationAutoStartup(info); 1752eace7efcSopenharmony_ci} 1753eace7efcSopenharmony_ci 1754eace7efcSopenharmony_ciErrCode AbilityManagerClient::CancelApplicationAutoStartup(const AutoStartupInfo &info) 1755eace7efcSopenharmony_ci{ 1756eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1757eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1758eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1759eace7efcSopenharmony_ci return abms->CancelApplicationAutoStartup(info); 1760eace7efcSopenharmony_ci} 1761eace7efcSopenharmony_ci 1762eace7efcSopenharmony_ciErrCode AbilityManagerClient::QueryAllAutoStartupApplications(std::vector<AutoStartupInfo> &infoList) 1763eace7efcSopenharmony_ci{ 1764eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1765eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1766eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1767eace7efcSopenharmony_ci return abms->QueryAllAutoStartupApplications(infoList); 1768eace7efcSopenharmony_ci} 1769eace7efcSopenharmony_ci 1770eace7efcSopenharmony_ciErrCode AbilityManagerClient::PrepareTerminateAbilityBySCB(sptr<SessionInfo> sessionInfo, 1771eace7efcSopenharmony_ci bool &isPrepareTerminate) 1772eace7efcSopenharmony_ci{ 1773eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1774eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1775eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, PrepareTerminateAbilityBySCB"); 1776eace7efcSopenharmony_ci return abms->PrepareTerminateAbilityBySCB(sessionInfo, isPrepareTerminate); 1777eace7efcSopenharmony_ci} 1778eace7efcSopenharmony_ci 1779eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterSessionHandler(sptr<IRemoteObject> object) 1780eace7efcSopenharmony_ci{ 1781eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); 1782eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1783eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1784eace7efcSopenharmony_ci return abms->RegisterSessionHandler(object); 1785eace7efcSopenharmony_ci} 1786eace7efcSopenharmony_ci 1787eace7efcSopenharmony_ciErrCode AbilityManagerClient::RegisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener) 1788eace7efcSopenharmony_ci{ 1789eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1790eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1791eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1792eace7efcSopenharmony_ci return abms->RegisterAppDebugListener(listener); 1793eace7efcSopenharmony_ci} 1794eace7efcSopenharmony_ci 1795eace7efcSopenharmony_ciErrCode AbilityManagerClient::UnregisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener) 1796eace7efcSopenharmony_ci{ 1797eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1798eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1799eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1800eace7efcSopenharmony_ci return abms->UnregisterAppDebugListener(listener); 1801eace7efcSopenharmony_ci} 1802eace7efcSopenharmony_ci 1803eace7efcSopenharmony_ciErrCode AbilityManagerClient::AttachAppDebug(const std::string &bundleName) 1804eace7efcSopenharmony_ci{ 1805eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1806eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1807eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1808eace7efcSopenharmony_ci return abms->AttachAppDebug(bundleName); 1809eace7efcSopenharmony_ci} 1810eace7efcSopenharmony_ci 1811eace7efcSopenharmony_ciErrCode AbilityManagerClient::DetachAppDebug(const std::string &bundleName) 1812eace7efcSopenharmony_ci{ 1813eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1814eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1815eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1816eace7efcSopenharmony_ci return abms->DetachAppDebug(bundleName); 1817eace7efcSopenharmony_ci} 1818eace7efcSopenharmony_ci 1819eace7efcSopenharmony_ciErrCode AbilityManagerClient::ExecuteIntent(uint64_t key, sptr<IRemoteObject> callerToken, 1820eace7efcSopenharmony_ci const InsightIntentExecuteParam ¶m) 1821eace7efcSopenharmony_ci{ 1822eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1823eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1824eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1825eace7efcSopenharmony_ci return abms->ExecuteIntent(key, callerToken, param); 1826eace7efcSopenharmony_ci} 1827eace7efcSopenharmony_ci 1828eace7efcSopenharmony_cibool AbilityManagerClient::IsAbilityControllerStart(const Want &want) 1829eace7efcSopenharmony_ci{ 1830eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); 1831eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1832eace7efcSopenharmony_ci if (abms == nullptr) { 1833eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null abms"); 1834eace7efcSopenharmony_ci return true; 1835eace7efcSopenharmony_ci } 1836eace7efcSopenharmony_ci return abms->IsAbilityControllerStart(want); 1837eace7efcSopenharmony_ci} 1838eace7efcSopenharmony_ci 1839eace7efcSopenharmony_ciErrCode AbilityManagerClient::ExecuteInsightIntentDone(sptr<IRemoteObject> token, uint64_t intentId, 1840eace7efcSopenharmony_ci const InsightIntentExecuteResult &result) 1841eace7efcSopenharmony_ci{ 1842eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1843eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1844eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1845eace7efcSopenharmony_ci return abms->ExecuteInsightIntentDone(token, intentId, result); 1846eace7efcSopenharmony_ci} 1847eace7efcSopenharmony_ci 1848eace7efcSopenharmony_ciint32_t AbilityManagerClient::GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> &list) 1849eace7efcSopenharmony_ci{ 1850eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1851eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1852eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(abms); 1853eace7efcSopenharmony_ci return abms->GetForegroundUIAbilities(list); 1854eace7efcSopenharmony_ci} 1855eace7efcSopenharmony_ci 1856eace7efcSopenharmony_ciint32_t AbilityManagerClient::OpenFile(const Uri& uri, uint32_t flag) 1857eace7efcSopenharmony_ci{ 1858eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "call OpenFile"); 1859eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1860eace7efcSopenharmony_ci if (abms == nullptr) { 1861eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null abms"); 1862eace7efcSopenharmony_ci return true; 1863eace7efcSopenharmony_ci } 1864eace7efcSopenharmony_ci return abms->OpenFile(uri, flag); 1865eace7efcSopenharmony_ci} 1866eace7efcSopenharmony_ci 1867eace7efcSopenharmony_ciint32_t AbilityManagerClient::RequestAssertFaultDialog( 1868eace7efcSopenharmony_ci const sptr<IRemoteObject> &callback, const AAFwk::WantParams &wantParams) 1869eace7efcSopenharmony_ci{ 1870eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "Request to display assert fault dialog."); 1871eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1872eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1873eace7efcSopenharmony_ci return abms->RequestAssertFaultDialog(callback, wantParams); 1874eace7efcSopenharmony_ci} 1875eace7efcSopenharmony_ci 1876eace7efcSopenharmony_ciint32_t AbilityManagerClient::NotifyDebugAssertResult(uint64_t assertFaultSessionId, AAFwk::UserStatus userStatus) 1877eace7efcSopenharmony_ci{ 1878eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "Notify user action result to assert fault callback."); 1879eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1880eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1881eace7efcSopenharmony_ci return abms->NotifyDebugAssertResult(assertFaultSessionId, userStatus); 1882eace7efcSopenharmony_ci} 1883eace7efcSopenharmony_ci 1884eace7efcSopenharmony_ciint32_t AbilityManagerClient::UpdateSessionInfoBySCB(std::list<SessionInfo> &sessionInfos, int32_t userId, 1885eace7efcSopenharmony_ci std::vector<int32_t> &sessionIds) 1886eace7efcSopenharmony_ci{ 1887eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1888eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1889eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "scb call, UpdateSessionInfoBySCB"); 1890eace7efcSopenharmony_ci return abms->UpdateSessionInfoBySCB(sessionInfos, userId, sessionIds); 1891eace7efcSopenharmony_ci} 1892eace7efcSopenharmony_ci 1893eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetUIExtensionRootHostInfo(const sptr<IRemoteObject> token, 1894eace7efcSopenharmony_ci UIExtensionHostInfo &hostInfo, int32_t userId) 1895eace7efcSopenharmony_ci{ 1896eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "Get ui extension host info."); 1897eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1898eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1899eace7efcSopenharmony_ci return abms->GetUIExtensionRootHostInfo(token, hostInfo, userId); 1900eace7efcSopenharmony_ci} 1901eace7efcSopenharmony_ci 1902eace7efcSopenharmony_ciErrCode AbilityManagerClient::GetUIExtensionSessionInfo(const sptr<IRemoteObject> token, 1903eace7efcSopenharmony_ci UIExtensionSessionInfo &uiExtensionSessionInfo, int32_t userId) 1904eace7efcSopenharmony_ci{ 1905eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "Get ui extension session info."); 1906eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1907eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1908eace7efcSopenharmony_ci return abms->GetUIExtensionSessionInfo(token, uiExtensionSessionInfo, userId); 1909eace7efcSopenharmony_ci} 1910eace7efcSopenharmony_ci 1911eace7efcSopenharmony_ciint32_t AbilityManagerClient::RestartApp(const AAFwk::Want &want) 1912eace7efcSopenharmony_ci{ 1913eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1914eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 1915eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1916eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(abms); 1917eace7efcSopenharmony_ci return abms->RestartApp(want); 1918eace7efcSopenharmony_ci} 1919eace7efcSopenharmony_ci 1920eace7efcSopenharmony_ciint32_t AbilityManagerClient::OpenAtomicService(Want& want, const StartOptions &options, 1921eace7efcSopenharmony_ci sptr<IRemoteObject> callerToken, int32_t requestCode, int32_t userId) 1922eace7efcSopenharmony_ci{ 1923eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1924eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1925eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(abms); 1926eace7efcSopenharmony_ci return abms->OpenAtomicService(want, options, callerToken, requestCode, userId); 1927eace7efcSopenharmony_ci} 1928eace7efcSopenharmony_ci 1929eace7efcSopenharmony_ciint32_t AbilityManagerClient::SetResidentProcessEnabled(const std::string &bundleName, bool enable) 1930eace7efcSopenharmony_ci{ 1931eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1932eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1933eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(abms); 1934eace7efcSopenharmony_ci return abms->SetResidentProcessEnabled(bundleName, enable); 1935eace7efcSopenharmony_ci} 1936eace7efcSopenharmony_ci 1937eace7efcSopenharmony_cibool AbilityManagerClient::IsEmbeddedOpenAllowed(sptr<IRemoteObject> callerToken, const std::string &appId) 1938eace7efcSopenharmony_ci{ 1939eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "Get ui extension host info."); 1940eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1941eace7efcSopenharmony_ci if (abms == nullptr) { 1942eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null abms"); 1943eace7efcSopenharmony_ci return false; 1944eace7efcSopenharmony_ci } 1945eace7efcSopenharmony_ci return abms->IsEmbeddedOpenAllowed(callerToken, appId); 1946eace7efcSopenharmony_ci} 1947eace7efcSopenharmony_ci 1948eace7efcSopenharmony_ciint32_t AbilityManagerClient::StartShortcut(const Want &want, const StartOptions &startOptions) 1949eace7efcSopenharmony_ci{ 1950eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "start short cut."); 1951eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1952eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(abms); 1953eace7efcSopenharmony_ci return abms->StartShortcut(want, startOptions); 1954eace7efcSopenharmony_ci} 1955eace7efcSopenharmony_ci 1956eace7efcSopenharmony_ciint32_t AbilityManagerClient::GetAbilityStateByPersistentId(int32_t persistentId, bool &state) 1957eace7efcSopenharmony_ci{ 1958eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); 1959eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1960eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(abms); 1961eace7efcSopenharmony_ci return abms->GetAbilityStateByPersistentId(persistentId, state); 1962eace7efcSopenharmony_ci} 1963eace7efcSopenharmony_ci 1964eace7efcSopenharmony_ciint32_t AbilityManagerClient::TransferAbilityResultForExtension(const sptr<IRemoteObject> &callerToken, 1965eace7efcSopenharmony_ci int32_t resultCode, const Want &want) 1966eace7efcSopenharmony_ci{ 1967eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1968eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(abms); 1969eace7efcSopenharmony_ci return abms->TransferAbilityResultForExtension(callerToken, resultCode, want); 1970eace7efcSopenharmony_ci} 1971eace7efcSopenharmony_ci 1972eace7efcSopenharmony_civoid AbilityManagerClient::NotifyFrozenProcessByRSS(const std::vector<int32_t> &pidList, int32_t uid) 1973eace7efcSopenharmony_ci{ 1974eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1975eace7efcSopenharmony_ci CHECK_POINTER_RETURN(abms); 1976eace7efcSopenharmony_ci return abms->NotifyFrozenProcessByRSS(pidList, uid); 1977eace7efcSopenharmony_ci} 1978eace7efcSopenharmony_ci 1979eace7efcSopenharmony_ciErrCode AbilityManagerClient::CleanUIAbilityBySCB(sptr<SessionInfo> sessionInfo) 1980eace7efcSopenharmony_ci{ 1981eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1982eace7efcSopenharmony_ci if (sessionInfo == nullptr) { 1983eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null sessionInfo"); 1984eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 1985eace7efcSopenharmony_ci } 1986eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1987eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1988eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "scb call, CleanUIAbilityBySCB"); 1989eace7efcSopenharmony_ci return abms->CleanUIAbilityBySCB(sessionInfo); 1990eace7efcSopenharmony_ci} 1991eace7efcSopenharmony_ci 1992eace7efcSopenharmony_ciErrCode AbilityManagerClient::PreStartMission(const std::string& bundleName, const std::string& moduleName, 1993eace7efcSopenharmony_ci const std::string& abilityName, const std::string& startTime) 1994eace7efcSopenharmony_ci{ 1995eace7efcSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); 1996eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 1997eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 1998eace7efcSopenharmony_ci return abms->PreStartMission(bundleName, moduleName, abilityName, startTime); 1999eace7efcSopenharmony_ci} 2000eace7efcSopenharmony_ci 2001eace7efcSopenharmony_ciErrCode AbilityManagerClient::OpenLink(const Want& want, sptr<IRemoteObject> callerToken, 2002eace7efcSopenharmony_ci int32_t userId, int requestCode) 2003eace7efcSopenharmony_ci{ 2004eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 2005eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(abms); 2006eace7efcSopenharmony_ci return abms->OpenLink(want, callerToken, userId, requestCode); 2007eace7efcSopenharmony_ci} 2008eace7efcSopenharmony_ci 2009eace7efcSopenharmony_ciErrCode AbilityManagerClient::TerminateMission(int32_t missionId) 2010eace7efcSopenharmony_ci{ 2011eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN 2012eace7efcSopenharmony_ci if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { 2013eace7efcSopenharmony_ci auto sceneSessionManager = SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); 2014eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(sceneSessionManager); 2015eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, TerminateMission"); 2016eace7efcSopenharmony_ci auto err = sceneSessionManager->TerminateSessionByPersistentId(missionId); 2017eace7efcSopenharmony_ci if (err != OHOS::Rosen::WMError::WM_OK) { 2018eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "scb call, TerminateMission err: %{public}d.", static_cast<int32_t>(err)); 2019eace7efcSopenharmony_ci } 2020eace7efcSopenharmony_ci if (err == Rosen::WMError::WM_ERROR_INVALID_PERMISSION) { 2021eace7efcSopenharmony_ci return CHECK_PERMISSION_FAILED; 2022eace7efcSopenharmony_ci } 2023eace7efcSopenharmony_ci if (err == Rosen::WMError::WM_ERROR_NOT_SYSTEM_APP) { 2024eace7efcSopenharmony_ci return ERR_NOT_SYSTEM_APP; 2025eace7efcSopenharmony_ci } 2026eace7efcSopenharmony_ci return static_cast<int32_t>(err); 2027eace7efcSopenharmony_ci } 2028eace7efcSopenharmony_ci#endif //SUPPORT_SCREEN 2029eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 2030eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(abms); 2031eace7efcSopenharmony_ci int32_t ret = abms->TerminateMission(missionId); 2032eace7efcSopenharmony_ci if (ret != ERR_OK) { 2033eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "failed,err:%{public}d", ret); 2034eace7efcSopenharmony_ci } 2035eace7efcSopenharmony_ci return ret; 2036eace7efcSopenharmony_ci} 2037eace7efcSopenharmony_ci 2038eace7efcSopenharmony_ciErrCode AbilityManagerClient::BlockAllAppStart(bool flag) 2039eace7efcSopenharmony_ci{ 2040eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 2041eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 2042eace7efcSopenharmony_ci CHECK_POINTER_RETURN_INVALID_VALUE(abms); 2043eace7efcSopenharmony_ci return abms->BlockAllAppStart(flag); 2044eace7efcSopenharmony_ci} 2045eace7efcSopenharmony_ci 2046eace7efcSopenharmony_ciErrCode AbilityManagerClient::UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs, 2047eace7efcSopenharmony_ci const std::list<std::string>& exportConfigs, int32_t flag) 2048eace7efcSopenharmony_ci{ 2049eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "call."); 2050eace7efcSopenharmony_ci auto abms = GetAbilityManager(); 2051eace7efcSopenharmony_ci CHECK_POINTER_RETURN_NOT_CONNECTED(abms); 2052eace7efcSopenharmony_ci return abms->UpdateAssociateConfigList(configs, exportConfigs, flag); 2053eace7efcSopenharmony_ci} 2054eace7efcSopenharmony_ci} // namespace AAFwk 2055eace7efcSopenharmony_ci} // namespace OHOS 2056