1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_PROXY_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_PROXY_H 18 19 #include "ability_manager_interface.h" 20 #include "hilog_wrapper.h" 21 #include "iremote_proxy.h" 22 #include "mission_info.h" 23 24 namespace OHOS { 25 namespace AAFwk { 26 /** 27 * @class AbilityManagerProxy 28 * AbilityManagerProxy. 29 */ 30 class AbilityManagerProxy : public IRemoteProxy<IAbilityManager> { 31 public: AbilityManagerProxy(const sptr<IRemoteObject> & impl)32 explicit AbilityManagerProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAbilityManager>(impl) 33 {} 34 ~AbilityManagerProxy()35 virtual ~AbilityManagerProxy() 36 {} 37 38 /** 39 * StartAbility with want, send want to ability manager service. 40 * 41 * @param want, the want of the ability to start. 42 * @param requestCode, Ability request code. 43 * @param userId, Designation User ID. 44 * @return Returns ERR_OK on success, others on failure. 45 */ 46 virtual int StartAbility( 47 const Want &want, 48 int32_t userId = DEFAULT_INVAL_VALUE, 49 int requestCode = DEFAULT_INVAL_VALUE) override; 50 51 /** 52 * StartAbility with want, send want to ability manager service. 53 * 54 * @param want, the want of the ability to start. 55 * @param callerToken, caller ability token. 56 * @param requestCode the resultCode of the ability to start. 57 * @param userId, Designation User ID. 58 * @return Returns ERR_OK on success, others on failure. 59 */ 60 virtual int StartAbility( 61 const Want &want, 62 const sptr<IRemoteObject> &callerToken, 63 int32_t userId = DEFAULT_INVAL_VALUE, 64 int requestCode = DEFAULT_INVAL_VALUE) override; 65 66 /** 67 * Starts a new ability with specific start settings. 68 * 69 * @param want Indicates the ability to start. 70 * @param callerToken caller ability token. 71 * @param abilityStartSetting Indicates the setting ability used to start. 72 * @param userId, Designation User ID. 73 * @return Returns ERR_OK on success, others on failure. 74 */ 75 virtual int StartAbility( 76 const Want &want, 77 const AbilityStartSetting &abilityStartSetting, 78 const sptr<IRemoteObject> &callerToken, 79 int32_t userId = DEFAULT_INVAL_VALUE, 80 int requestCode = DEFAULT_INVAL_VALUE) override; 81 82 /** 83 * Starts a new ability with specific start options. 84 * 85 * @param want, the want of the ability to start. 86 * @param startOptions Indicates the options used to start. 87 * @param callerToken, caller ability token. 88 * @param userId, Designation User ID. 89 * @param requestCode the resultCode of the ability to start. 90 * @return Returns ERR_OK on success, others on failure. 91 */ 92 virtual int StartAbility( 93 const Want &want, 94 const StartOptions &startOptions, 95 const sptr<IRemoteObject> &callerToken, 96 int32_t userId = DEFAULT_INVAL_VALUE, 97 int requestCode = DEFAULT_INVAL_VALUE) override; 98 99 /** 100 * Starts a new ability using the original caller information. 101 * 102 * @param want the want of the ability to start. 103 * @param callerToken caller ability token. 104 * @param userId Designation User ID. 105 * @param requestCode the resultCode of the ability to start. 106 * @return Returns ERR_OK on success, others on failure. 107 */ 108 virtual int StartAbilityAsCaller( 109 const Want &want, 110 const sptr<IRemoteObject> &callerToken, 111 int32_t userId = DEFAULT_INVAL_VALUE, 112 int requestCode = DEFAULT_INVAL_VALUE) override; 113 114 /** 115 * Starts a new ability using the original caller information. 116 * 117 * @param want the want of the ability to start. 118 * @param startOptions Indicates the options used to start. 119 * @param callerToken caller ability token. 120 * @param userId Designation User ID. 121 * @param requestCode the resultCode of the ability to start. 122 * @return Returns ERR_OK on success, others on failure. 123 */ 124 virtual int StartAbilityAsCaller( 125 const Want &want, 126 const StartOptions &startOptions, 127 const sptr<IRemoteObject> &callerToken, 128 int32_t userId = DEFAULT_INVAL_VALUE, 129 int requestCode = DEFAULT_INVAL_VALUE) override; 130 131 /** 132 * Start ui session ability with extension session info, send session info to ability manager service. 133 * 134 * @param want, the want of the ability to start. 135 * @param callerToken, caller ability token. 136 * @param sessionInfo the information of UIExtensionContentSession. 137 * @param userId, Designation User ID. 138 * @param requestCode, Ability request code. 139 * @return Returns ERR_OK on success, others on failure. 140 */ 141 virtual int StartAbilityByUIContentSession( 142 const Want &want, 143 const sptr<IRemoteObject> &callerToken, 144 const sptr<SessionInfo> &sessionInfo, 145 int32_t userId = DEFAULT_INVAL_VALUE, 146 int requestCode = DEFAULT_INVAL_VALUE) override; 147 148 /** 149 * Start ui session ability with extension session info, send session info to ability manager service. 150 * 151 * @param want, the want of the ability to start. 152 * @param startOptions Indicates the options used to start. 153 * @param callerToken, caller ability token. 154 * @param sessionInfo the information of UIExtensionContentSession. 155 * @param userId, Designation User ID. 156 * @param requestCode the resultCode of the ability to start. 157 * @return Returns ERR_OK on success, others on failure. 158 */ 159 virtual int StartAbilityByUIContentSession( 160 const Want &want, 161 const StartOptions &startOptions, 162 const sptr<IRemoteObject> &callerToken, 163 const sptr<SessionInfo> &sessionInfo, 164 int32_t userId = DEFAULT_INVAL_VALUE, 165 int requestCode = DEFAULT_INVAL_VALUE) override; 166 167 /** 168 * Start extension ability with want, send want to ability manager service. 169 * 170 * @param want, the want of the ability to start. 171 * @param callerToken, caller ability token. 172 * @param userId, Designation User ID. 173 * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started. 174 * @return Returns ERR_OK on success, others on failure. 175 */ 176 virtual int StartExtensionAbility( 177 const Want &want, 178 const sptr<IRemoteObject> &callerToken, 179 int32_t userId = DEFAULT_INVAL_VALUE, 180 AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override; 181 182 /** 183 * Start ui extension ability with extension session info, send extension session info to ability manager service. 184 * 185 * @param extensionSessionInfo the extension session info of the ability to start. 186 * @param userId, Designation User ID. 187 * @return Returns ERR_OK on success, others on failure. 188 */ 189 virtual int StartUIExtensionAbility( 190 const sptr<SessionInfo> &extensionSessionInfo, 191 int32_t userId = DEFAULT_INVAL_VALUE) override; 192 193 /** 194 * Start ui ability with want, send want to ability manager service. 195 * 196 * @param sessionInfo the session info of the ability to start. 197 * @return Returns ERR_OK on success, others on failure. 198 */ 199 virtual int StartUIAbilityBySCB(sptr<SessionInfo> sessionInfo) override; 200 201 /** 202 * Stop extension ability with want, send want to ability manager service. 203 * 204 * @param want, the want of the ability to stop. 205 * @param callerToken, caller ability token. 206 * @param userId, Designation User ID. 207 * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be stopped. 208 * @return Returns ERR_OK on success, others on failure. 209 */ 210 virtual int StopExtensionAbility( 211 const Want& want, 212 const sptr<IRemoteObject>& callerToken, 213 int32_t userId = DEFAULT_INVAL_VALUE, 214 AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override; 215 /** 216 * TerminateAbility, terminate the special ability. 217 * 218 * @param token, the token of the ability to terminate. 219 * @param resultCode, the resultCode of the ability to terminate. 220 * @param resultWant, the Want of the ability to return. 221 * @return Returns ERR_OK on success, others on failure. 222 */ 223 virtual int TerminateAbility( 224 const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) override; 225 226 /** 227 * TerminateUIExtensionAbility, terminate the special ui extension ability. 228 * 229 * @param extensionSessionInfo the extension session info of the ability to terminate. 230 * @param resultCode resultCode. 231 * @param Want Ability want returned. 232 * @return Returns ERR_OK on success, others on failure. 233 */ 234 virtual int TerminateUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, int resultCode, 235 const Want *resultWant) override; 236 237 /** 238 * CloseUIAbilityBySCB, close the special ability by scb. 239 * 240 * @param sessionInfo the session info of the ability to terminate. 241 * @return Returns ERR_OK on success, others on failure. 242 */ 243 virtual int CloseUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo) override; 244 245 /** 246 * SendResultToAbility with want, return want from ability manager service.(Only used for dms) 247 * 248 * @param requestCode, request code. 249 * @param resultCode, resultCode to return. 250 * @param resultWant, the Want of the ability to return. 251 * @return Returns ERR_OK on success, others on failure. 252 */ 253 virtual int SendResultToAbility(int32_t requestCode, int32_t resultCode, Want& resultWant) override; 254 255 /** 256 * MoveAbilityToBackground. 257 * 258 * @param token, the token of the ability to move. 259 * @return Returns ERR_OK on success, others on failure. 260 */ 261 virtual int MoveAbilityToBackground(const sptr<IRemoteObject> &token) override; 262 263 /** 264 * CloseAbility, close the special ability. 265 * 266 * @param token, the token of the ability to terminate. 267 * @param resultCode, the resultCode of the ability to terminate. 268 * @param resultWant, the Want of the ability to return. 269 * @return Returns ERR_OK on success, others on failure. 270 */ 271 virtual int CloseAbility( 272 const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) override; 273 274 /** 275 * MinimizeAbility, minimize the special ability. 276 * 277 * @param token, ability token. 278 * @param fromUser mark the minimize operation source. 279 * @return Returns ERR_OK on success, others on failure. 280 */ 281 virtual int MinimizeAbility(const sptr<IRemoteObject> &token, bool fromUser = false) override; 282 283 /** 284 * MinimizeUIExtensionAbility, minimize the special ui extension ability. 285 * 286 * @param extensionSessionInfo the extension session info of the ability to minimize. 287 * @param fromUser mark the minimize operation source. 288 * @return Returns ERR_OK on success, others on failure. 289 */ 290 virtual int MinimizeUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, 291 bool fromUser = false) override; 292 293 /** 294 * MinimizeUIAbilityBySCB, minimize the special ability by scb. 295 * 296 * @param sessionInfo the session info of the ability to minimize. 297 * @param fromUser, Whether form user. 298 * @return Returns ERR_OK on success, others on failure. 299 */ 300 virtual int MinimizeUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool fromUser = false) override; 301 302 /** 303 * ConnectAbility, connect session with service ability. 304 * 305 * @param want, Special want for service type's ability. 306 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 307 * @param callerToken, caller ability token. 308 * @param userId, Designation User ID. 309 * @return Returns ERR_OK on success, others on failure. 310 */ 311 virtual int ConnectAbility( 312 const Want &want, 313 const sptr<IAbilityConnection> &connect, 314 const sptr<IRemoteObject> &callerToken, 315 int32_t userId = DEFAULT_INVAL_VALUE) override; 316 317 virtual int ConnectAbilityCommon( 318 const Want &want, 319 const sptr<IAbilityConnection> &connect, 320 const sptr<IRemoteObject> &callerToken, 321 AppExecFwk::ExtensionAbilityType extensionType, 322 int32_t userId = DEFAULT_INVAL_VALUE) override; 323 324 virtual int ConnectUIExtensionAbility( 325 const Want &want, 326 const sptr<IAbilityConnection> &connect, 327 const sptr<SessionInfo> &sessionInfo, 328 int32_t userId = DEFAULT_INVAL_VALUE) override; 329 330 /** 331 * DisconnectAbility, connect session with service ability. 332 * 333 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 334 * @return Returns ERR_OK on success, others on failure. 335 */ 336 virtual int DisconnectAbility(const sptr<IAbilityConnection> &connect) override; 337 338 /** 339 * AcquireDataAbility, acquire a data ability by its authority, if it not existed, 340 * AMS loads it synchronously. 341 * 342 * @param uri, data ability uri. 343 * @param isKill, true: when a data ability is died, ams will kill this client, or do nothing. 344 * @param callerToken, specifies the caller ability token. 345 * @return returns the data ability ipc object, or nullptr for failed. 346 */ 347 virtual sptr<IAbilityScheduler> AcquireDataAbility( 348 const Uri &uri, bool isKill, const sptr<IRemoteObject> &callerToken) override; 349 350 /** 351 * ReleaseDataAbility, release the data ability that referenced by 'dataAbilityToken'. 352 * 353 * @param dataAbilityScheduler, specifies the data ability that will be released. 354 * @param callerToken, specifies the caller ability token. 355 * @return returns ERR_OK if succeeded, or error codes for failed. 356 */ 357 virtual int ReleaseDataAbility( 358 sptr<IAbilityScheduler> dataAbilityScheduler, const sptr<IRemoteObject> &callerToken) override; 359 360 /** 361 * AttachAbilityThread, ability call this interface after loaded. 362 * 363 * @param scheduler,.the interface handler of kit ability. 364 * @param token,.ability's token. 365 * @return Returns ERR_OK on success, others on failure. 366 */ 367 virtual int AttachAbilityThread( 368 const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token) override; 369 370 /** 371 * AbilityTransitionDone, ability call this interface after lift cycle was changed. 372 * 373 * @param token,.ability's token. 374 * @param state,.the state of ability lift cycle. 375 * @return Returns ERR_OK on success, others on failure. 376 */ 377 virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override; 378 379 /** 380 * ScheduleConnectAbilityDone, service ability call this interface while session was connected. 381 * 382 * @param token,.service ability's token. 383 * @param remoteObject,.the session proxy of service ability. 384 * @return Returns ERR_OK on success, others on failure. 385 */ 386 virtual int ScheduleConnectAbilityDone( 387 const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject) override; 388 389 /** 390 * ScheduleDisconnectAbilityDone, service ability call this interface while session was disconnected. 391 * 392 * @param token,.service ability's token. 393 * @return Returns ERR_OK on success, others on failure. 394 */ 395 virtual int ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> &token) override; 396 397 /** 398 * ScheduleCommandAbilityDone, service ability call this interface while session was commanded. 399 * 400 * @param token,.service ability's token. 401 * @return Returns ERR_OK on success, others on failure. 402 */ 403 virtual int ScheduleCommandAbilityDone(const sptr<IRemoteObject> &token) override; 404 405 virtual int ScheduleCommandAbilityWindowDone( 406 const sptr<IRemoteObject> &token, 407 const sptr<SessionInfo> &sessionInfo, 408 WindowCommand winCmd, 409 AbilityCommand abilityCmd) override; 410 411 /** 412 * dump ability stack info, about userID, mission stack info, 413 * mission record info and ability info. 414 * 415 * @param state Ability stack info. 416 * @return Returns ERR_OK on success, others on failure. 417 */ 418 virtual void DumpState(const std::string &args, std::vector<std::string> &state) override; 419 virtual void DumpSysState( 420 const std::string& args, std::vector<std::string>& state, bool isClient, bool isUserID, int UserID) override; 421 422 /** 423 * Destroys this Service ability by Want. 424 * 425 * @param want, Special want for service type's ability. 426 * @param token ability's token. 427 * @return Returns true if this Service ability will be destroyed; returns false otherwise. 428 */ 429 virtual int StopServiceAbility(const Want &want, int32_t userId = DEFAULT_INVAL_VALUE, 430 const sptr<IRemoteObject> &token = nullptr) override; 431 432 /** 433 * Get top ability. 434 * 435 * @return Returns front desk focus ability elementName. 436 */ 437 virtual AppExecFwk::ElementName GetTopAbility() override; 438 439 /** 440 * Get element name by token. 441 * 442 * @return Returns front desk focus ability elementName by token. 443 */ 444 virtual AppExecFwk::ElementName GetElementNameByToken(const sptr<IRemoteObject> &token) override; 445 446 /** 447 * Kill the process immediately. 448 * 449 * @param bundleName. 450 * @return Returns ERR_OK on success, others on failure. 451 */ 452 virtual int KillProcess(const std::string &bundleName) override; 453 454 #ifdef ABILITY_COMMAND_FOR_TEST 455 /** 456 * force timeout ability. 457 * 458 * @param abilityName. 459 * @param state. 460 * @return Returns ERR_OK on success, others on failure. 461 */ 462 virtual int ForceTimeoutForTest(const std::string &abilityName, const std::string &state) override; 463 #endif 464 465 /** 466 * ClearUpApplicationData, call ClearUpApplicationData() through proxy project, 467 * clear the application data. 468 * 469 * @param bundleName, bundle name in Application record. 470 * @return 471 */ 472 virtual int ClearUpApplicationData(const std::string &bundleName) override; 473 474 /** 475 * Uninstall app 476 * 477 * @param bundleName bundle name of uninstalling app. 478 * @param uid uid of bundle. 479 * @return Returns ERR_OK on success, others on failure. 480 */ 481 virtual int UninstallApp(const std::string &bundleName, int32_t uid) override; 482 483 virtual sptr<IWantSender> GetWantSender( 484 const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken) override; 485 486 virtual int SendWantSender(const sptr<IWantSender> &target, const SenderInfo &senderInfo) override; 487 488 virtual void CancelWantSender(const sptr<IWantSender> &sender) override; 489 490 virtual int GetPendingWantUid(const sptr<IWantSender> &target) override; 491 492 virtual int GetPendingWantUserId(const sptr<IWantSender> &target) override; 493 494 virtual std::string GetPendingWantBundleName(const sptr<IWantSender> &target) override; 495 496 virtual int GetPendingWantCode(const sptr<IWantSender> &target) override; 497 498 virtual int GetPendingWantType(const sptr<IWantSender> &target) override; 499 500 virtual void RegisterCancelListener(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver) override; 501 502 virtual void UnregisterCancelListener( 503 const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver) override; 504 505 virtual int GetPendingRequestWant(const sptr<IWantSender> &target, std::shared_ptr<Want> &want) override; 506 507 virtual int GetWantSenderInfo(const sptr<IWantSender> &target, std::shared_ptr<WantSenderInfo> &info) override; 508 509 virtual int GetAppMemorySize() override; 510 511 virtual bool IsRamConstrainedDevice() override; 512 virtual int ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, 513 int32_t missionId, const sptr<IRemoteObject> &callBack, AAFwk::WantParams &wantParams) override; 514 515 virtual int ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, 516 const std::string &bundleName, const sptr<IRemoteObject> &callBack, AAFwk::WantParams &wantParams) override; 517 518 virtual int ContinueAbility(const std::string &deviceId, int32_t missionId, uint32_t versionCode) override; 519 520 virtual int StartContinuation(const Want &want, const sptr<IRemoteObject> &abilityToken, int32_t status) override; 521 522 virtual void NotifyCompleteContinuation(const std::string &deviceId, int32_t sessionId, bool isSuccess) override; 523 524 virtual int NotifyContinuationResult(int32_t missionId, int32_t result) override; 525 526 virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override; 527 528 virtual int StopSyncRemoteMissions(const std::string& devId) override; 529 530 virtual int LockMissionForCleanup(int32_t missionId) override; 531 532 virtual int UnlockMissionForCleanup(int32_t missionId) override; 533 534 virtual int RegisterMissionListener(const sptr<IMissionListener> &listener) override; 535 536 virtual int UnRegisterMissionListener(const sptr<IMissionListener> &listener) override; 537 538 virtual int GetMissionInfos(const std::string& deviceId, int32_t numMax, 539 std::vector<MissionInfo> &missionInfos) override; 540 541 virtual int GetMissionInfo(const std::string& deviceId, int32_t missionId, 542 MissionInfo &missionInfos) override; 543 544 virtual int CleanMission(int32_t missionId) override; 545 546 virtual int CleanAllMissions() override; 547 548 virtual int MoveMissionToFront(int32_t missionId) override; 549 550 virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override; 551 552 virtual int MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) override; 553 554 virtual int MoveMissionsToBackground(const std::vector<int32_t>& missionIds, 555 std::vector<int32_t>& result) override; 556 557 /** 558 * Start Ability, connect session with common ability. 559 * 560 * @param want, Special want for service type's ability. 561 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 562 * @param accountId Indicates the account to start. 563 * @return Returns ERR_OK on success, others on failure. 564 */ 565 virtual int StartAbilityByCall(const Want &want, const sptr<IAbilityConnection> &connect, 566 const sptr<IRemoteObject> &callerToken, int32_t accountId = DEFAULT_INVAL_VALUE) override; 567 568 /** 569 * CallRequestDone, after invoke callRequest, ability will call this interface to return callee. 570 * 571 * @param token, ability's token. 572 * @param callStub, ability's callee. 573 */ 574 void CallRequestDone(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callStub) override; 575 576 /** 577 * Release the call between Ability, disconnect session with common ability. 578 * 579 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 580 * @param element, the element of target service. 581 * @return Returns ERR_OK on success, others on failure. 582 */ 583 virtual int ReleaseCall( 584 const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element) override; 585 586 virtual int StartUser(int userId) override; 587 588 virtual int StopUser(int userId, const sptr<IStopUserCallback> &callback) override; 589 590 virtual int SetMissionContinueState(const sptr<IRemoteObject> &token, const AAFwk::ContinueState &state) override; 591 592 #ifdef SUPPORT_GRAPHICS 593 virtual int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) override; 594 595 virtual int SetMissionIcon(const sptr<IRemoteObject> &token, 596 const std::shared_ptr<OHOS::Media::PixelMap> &icon) override; 597 598 virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override; 599 600 virtual void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) override; 601 602 virtual int PrepareTerminateAbility( 603 const sptr<IRemoteObject> &token, sptr<IPrepareTerminateCallback> &callback) override; 604 #endif 605 606 virtual int GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info) override; 607 608 virtual int GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info) override; 609 610 virtual int GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info) override; 611 612 virtual int RegisterMissionListener(const std::string &deviceId, 613 const sptr<IRemoteMissionListener> &listener) override; 614 615 virtual int RegisterOnListener(const std::string &type, 616 const sptr<IRemoteOnListener> &listener) override; 617 618 virtual int RegisterOffListener(const std::string &deviceId, 619 const sptr<IRemoteOnListener> &listener) override; 620 621 virtual int UnRegisterMissionListener(const std::string &deviceId, 622 const sptr<IRemoteMissionListener> &listener) override; 623 624 /** 625 * Set ability controller. 626 * 627 * @param abilityController, The ability controller. 628 * @return Returns ERR_OK on success, others on failure. 629 */ 630 virtual int SetAbilityController(const sptr<AppExecFwk::IAbilityController> &abilityController, 631 bool imAStabilityTest) override; 632 633 virtual int SetComponentInterception( 634 const sptr<AppExecFwk::IComponentInterception> &componentInterception) override; 635 636 virtual int32_t SendResultToAbilityByToken(const Want &want, const sptr<IRemoteObject> &abilityToken, 637 int32_t requestCode, int32_t resultCode, int32_t userId) override; 638 639 /** 640 * Is user a stability test. 641 * 642 * @return Returns true if user is a stability test. 643 */ 644 virtual bool IsRunningInStabilityTest() override; 645 646 virtual int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override; 647 648 virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId, 649 MissionSnapshot& snapshot, bool isLowResolution) override; 650 651 virtual int StartUserTest(const Want &want, const sptr<IRemoteObject> &observer) override; 652 653 virtual int FinishUserTest( 654 const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override; 655 656 /** 657 * GetTopAbility, get the token of top ability. 658 * 659 * @param token, the token of top ability. 660 * @return Returns ERR_OK on success, others on failure. 661 */ 662 virtual int GetTopAbility(sptr<IRemoteObject> &token) override; 663 664 virtual int CheckUIExtensionIsFocused(uint32_t uiExtensionTokenId, bool& isFocused) override; 665 666 /** 667 * The delegator calls this interface to move the ability to the foreground. 668 * 669 * @param token, ability's token. 670 * @return Returns ERR_OK on success, others on failure. 671 */ 672 virtual int DelegatorDoAbilityForeground(const sptr<IRemoteObject> &token) override; 673 674 /** 675 * The delegator calls this interface to move the ability to the background. 676 * 677 * @param token, ability's token. 678 * @return Returns ERR_OK on success, others on failure. 679 */ 680 virtual int DelegatorDoAbilityBackground(const sptr<IRemoteObject> &token) override; 681 682 /** 683 * Calls this interface to move the ability to the foreground. 684 * 685 * @param token, ability's token. 686 * @param flag, use for lock or unlock flag and so on. 687 * @return Returns ERR_OK on success, others on failure. 688 */ 689 virtual int DoAbilityForeground(const sptr<IRemoteObject> &token, uint32_t flag) override; 690 691 /** 692 * Calls this interface to move the ability to the background. 693 * 694 * @param token, ability's token. 695 * @param flag, use for lock or unlock flag and so on. 696 * @return Returns ERR_OK on success, others on failure. 697 */ 698 virtual int DoAbilityBackground(const sptr<IRemoteObject> &token, uint32_t flag) override; 699 700 /** 701 * Send not response process ID to ability manager service. 702 * 703 * @param pid The not response process ID. 704 * @return Returns ERR_OK on success, others on failure. 705 */ 706 virtual int SendANRProcessID(int pid) override; 707 708 /** 709 * Get mission id by ability token. 710 * 711 * @param token The token of ability. 712 * @return Returns -1 if do not find mission, otherwise return mission id. 713 */ 714 virtual int32_t GetMissionIdByToken(const sptr<IRemoteObject> &token) override; 715 716 /** 717 * Get ability token by connect. 718 * 719 * @param token The token of ability. 720 * @param callStub The callee object. 721 */ 722 void GetAbilityTokenByCalleeObj(const sptr<IRemoteObject> &callStub, sptr<IRemoteObject> &token) override; 723 724 #ifdef ABILITY_COMMAND_FOR_TEST 725 /** 726 * Block ability manager service. 727 * 728 * @return Returns ERR_OK on success, others on failure. 729 */ 730 virtual int BlockAmsService() override; 731 732 /** 733 * Block ability. 734 * 735 * @param abilityRecordId The Ability Record Id. 736 * @return Returns ERR_OK on success, others on failure. 737 */ 738 virtual int BlockAbility(int32_t abilityRecordId) override; 739 740 /** 741 * Block app service. 742 * 743 * @return Returns ERR_OK on success, others on failure. 744 */ 745 virtual int BlockAppService() override; 746 #endif 747 748 /** 749 * Call free install from remote. 750 * 751 * @param want, the want of the ability to start. 752 * @param userId, Designation User ID. 753 * @param requestCode, Ability request code. 754 * @param callback, Callback from remote. 755 * @return Returns ERR_OK on success, others on failure. 756 */ 757 virtual int FreeInstallAbilityFromRemote(const Want &want, const sptr<IRemoteObject> &callback, 758 int32_t userId, int requestCode = DEFAULT_INVAL_VALUE) override; 759 760 /** 761 * Add FreeInstall Observer 762 * 763 * @param observer the observer of ability free install start. 764 * @return Returns ERR_OK on success, others on failure. 765 */ 766 virtual int AddFreeInstallObserver(const sptr<AbilityRuntime::IFreeInstallObserver> &observer) override; 767 768 /** 769 * Called when client complete dump. 770 * 771 * @param infos The dump info. 772 * @return Returns ERR_OK on success, others on failure. 773 */ 774 virtual int DumpAbilityInfoDone(std::vector<std::string> &infos, const sptr<IRemoteObject> &callerToken) override; 775 776 /** 777 * Called to update mission snapshot. 778 * @param token The target ability. 779 * @param pixelMap The snapshot. 780 */ 781 virtual void UpdateMissionSnapShot(const sptr<IRemoteObject> &token, 782 const std::shared_ptr<Media::PixelMap> &pixelMap) override; 783 784 virtual void EnableRecoverAbility(const sptr<IRemoteObject>& token) override; 785 virtual void ScheduleRecoverAbility(const sptr<IRemoteObject> &token, int32_t reason, 786 const Want *want = nullptr) override; 787 788 /** 789 * Called to verify that the MissionId is valid. 790 * @param missionIds Query mission list. 791 * @param results Output parameters, return results up to 20 query results. 792 * @return Returns ERR_OK on success, others on failure. 793 */ 794 int32_t IsValidMissionIds( 795 const std::vector<int32_t> &missionIds, std::vector<MissionVaildResult> &results) override; 796 797 /** 798 * Query whether the application of the specified PID and UID has been granted a certain permission 799 * @param permission 800 * @param pid Process id 801 * @param uid 802 * @return Returns ERR_OK if the current process has the permission, others on failure. 803 */ 804 virtual int VerifyPermission(const std::string &permission, int pid, int uid) override; 805 806 /** 807 * Request dialog service with want, send want to ability manager service. 808 * 809 * @param want, the want of the dialog service to start. 810 * @param callerToken, caller ability token. 811 * @return Returns ERR_OK on success, others on failure. 812 */ 813 virtual int32_t RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken) override; 814 815 int32_t ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken) override; 816 817 virtual int32_t AcquireShareData( 818 const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData) override; 819 virtual int32_t ShareDataDone(const sptr<IRemoteObject> &token, 820 const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam) override; 821 822 /** 823 * Force app exit and record exit reason. 824 * @param pid Process id . 825 * @param exitReason The reason of app exit. 826 * @return Returns ERR_OK on success, others on failure. 827 */ 828 virtual int32_t ForceExitApp(const int32_t pid, Reason exitReason) override; 829 830 /** 831 * Record app exit reason. 832 * @param exitReason The reason of app exit. 833 * @return Returns ERR_OK on success, others on failure. 834 */ 835 virtual int32_t RecordAppExitReason(Reason exitReason) override; 836 837 /** 838 * Set rootSceneSession by SCB. 839 * 840 * @param rootSceneSession Indicates root scene session of SCB. 841 */ 842 virtual void SetRootSceneSession(const sptr<IRemoteObject> &rootSceneSession) override; 843 844 /** 845 * Call UIAbility by SCB. 846 * 847 * @param sessionInfo the session info of the ability to be called. 848 */ 849 virtual void CallUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo) override; 850 851 /** 852 * Start specified ability by SCB. 853 * 854 * @param want Want information. 855 */ 856 void StartSpecifiedAbilityBySCB(const Want &want) override; 857 858 /** 859 * Notify sandbox app the result of saving file. 860 * @param want Result of saving file, which contains the file's uri if success. 861 * @param resultCode Indicates the action's result. 862 * @param requestCode Pass the requestCode to match request. 863 * @return Returns ERR_OK on success, others on failure. 864 */ 865 virtual int32_t NotifySaveAsResult(const Want &want, int resultCode, int requestCode) override; 866 867 /** 868 * Set sessionManagerService 869 * @param sessionManagerService the point of sessionManagerService. 870 * 871 * @return Returns ERR_OK on success, others on failure. 872 */ 873 virtual int32_t SetSessionManagerService(const sptr<IRemoteObject> &sessionManagerService) override; 874 875 /** 876 * @brief Register collaborator. 877 * @param type collaborator type. 878 * @param impl collaborator. 879 * @return 0 or else. 880 */ 881 virtual int32_t RegisterIAbilityManagerCollaborator( 882 int32_t type, const sptr<IAbilityManagerCollaborator> &impl) override; 883 884 /** 885 * @brief Unregister collaborator. 886 * @param type collaborator type. 887 * @return 0 or else. 888 */ 889 virtual int32_t UnregisterIAbilityManagerCollaborator(int32_t type) override; 890 891 /** 892 * @brief Notify to move mission to backround. 893 * @param missionId missionId. 894 * @return 0 or else. 895 */ 896 virtual int32_t MoveMissionToBackground(int32_t missionId) override; 897 898 /** 899 * @brief Notify to terminate mission. it is not clear. 900 * @param missionId missionId. 901 * @return 0 or else. 902 */ 903 virtual int32_t TerminateMission(int32_t missionId) override; 904 905 /** 906 * PrepareTerminateAbilityBySCB, prepare to terminate ability by scb. 907 * 908 * @param sessionInfo the session info of the ability to start. 909 * @param isPrepareTerminate the result of ability onPrepareToTermiante. 910 * @return Returns ERR_OK on success, others on failure. 911 */ 912 virtual int PrepareTerminateAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool &isPrepareTerminate) override; 913 virtual int RegisterSessionHandler(const sptr<IRemoteObject> &object) override; 914 915 private: 916 template <typename T> 917 int GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos); 918 bool WriteInterfaceToken(MessageParcel &data); 919 // flag = true : terminate; flag = false : close 920 int TerminateAbility(const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant, bool flag); 921 ErrCode SendRequest(AbilityManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply, 922 MessageOption& option); 923 int CheckUISessionParams(MessageParcel &data, const sptr<IRemoteObject> &callerToken, 924 const sptr<SessionInfo> &sessionInfo, int32_t userId, int requestCode); 925 926 private: 927 static inline BrokerDelegator<AbilityManagerProxy> delegator_; 928 }; 929 } // namespace AAFwk 930 } // namespace OHOS 931 #endif 932