1 /* 2 * Copyright (c) 2021-2024 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_APP_MGR_PROXY_H 17 #define OHOS_ABILITY_RUNTIME_APP_MGR_PROXY_H 18 19 #include "app_jsheap_mem_info.h" 20 #include "app_malloc_info.h" 21 #include "app_mgr_interface.h" 22 #include "bundle_info.h" 23 #include "iremote_proxy.h" 24 #include "memory_level_info.h" 25 #include "running_process_info.h" 26 #include "want.h" 27 28 namespace OHOS { 29 namespace AppExecFwk { 30 class AppMgrProxy : public IRemoteProxy<IAppMgr> { 31 public: 32 explicit AppMgrProxy(const sptr<IRemoteObject> &impl); 33 virtual ~AppMgrProxy() = default; 34 35 /** 36 * AttachApplication, call AttachApplication() through proxy object, 37 * get all the information needed to start the Application (data related to the Application ). 38 * 39 * @param app, information needed to start the Application. 40 * @return 41 */ 42 virtual void AttachApplication(const sptr<IRemoteObject> &obj) override; 43 44 /** 45 * Preload application. 46 * 47 * @param bundleName The bundle name of the application to preload. 48 * @param userId Indicates the user identification. 49 * @param preloadMode Preload application mode. 50 * @param appIndex The index of application clone. 51 * @return Returns ERR_OK on success, others on failure. 52 */ 53 virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId, 54 AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0) override; 55 56 /** 57 * ApplicationForegrounded, call ApplicationForegrounded() through proxy object, 58 * set the application to Foreground State. 59 * 60 * @param recordId, a unique record that identifies this Application from others. 61 * @return 62 */ 63 virtual void ApplicationForegrounded(const int32_t recordId) override; 64 65 /** 66 * ApplicationBackgrounded, call ApplicationBackgrounded() through proxy object, 67 * set the application to Backgrounded State. 68 * 69 * @param recordId, a unique record that identifies this Application from others. 70 * @return 71 */ 72 virtual void ApplicationBackgrounded(const int32_t recordId) override; 73 74 /** 75 * ApplicationTerminated, call ApplicationTerminated() through proxy object, 76 * terminate the application. 77 * 78 * @param recordId, a unique record that identifies this Application from others. 79 * @return 80 */ 81 virtual void ApplicationTerminated(const int32_t recordId) override; 82 83 /** 84 * AbilityCleaned,call through AbilityCleaned() proxy project, clean Ability record. 85 * 86 * @param token, a unique record that identifies AbilityCleaned from others. 87 * @return 88 */ 89 virtual void AbilityCleaned(const sptr<IRemoteObject> &token) override; 90 91 /** 92 * GetAmsMgr, call GetAmsMgr() through proxy object, get AMS interface instance. 93 * 94 * @return sptr<IAmsMgr>, return to AMS interface instance. 95 */ 96 virtual sptr<IAmsMgr> GetAmsMgr() override; 97 98 /** 99 * ClearUpApplicationData, call ClearUpApplicationData() through proxy project, 100 * clear the application data. 101 * 102 * @param bundleName, bundle name in Application record. 103 * @param appCloneIndex the app clone id. 104 * @param userId the user id. 105 * @return ErrCode 106 */ 107 virtual int32_t ClearUpApplicationData(const std::string &bundleName, int32_t appCloneIndex, 108 int32_t userId = -1) override; 109 110 /** 111 * ClearUpApplicationData, call ClearUpApplicationData() through proxy project, 112 * clear the application data. 113 * 114 * @param bundleName, bundle name in Application record. 115 * @return 116 */ 117 virtual int32_t ClearUpApplicationDataBySelf(int32_t userId = -1) override; 118 119 /** 120 * GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project. 121 * Obtains information about application processes that are running on the device. 122 * 123 * @param info, app name in Application record. 124 * @return ERR_OK ,return back success,others fail. 125 */ 126 virtual int32_t GetAllRunningProcesses(std::vector<RunningProcessInfo> &info) override; 127 128 /** 129 * GetALLRunningMultiAppInfo, call GetALLRunningMultiAppInfo() through proxy project. 130 * Obtains information about multiapp that are running on the device. 131 * 132 * @param info, app name in multiappinfo. 133 * @return ERR_OK ,return back success,others fail. 134 */ 135 virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, 136 RunningMultiAppInfo &info) override; 137 138 /** 139 * GetAllRunningInstanceKeysBySelf, call GetAllRunningInstanceKeysBySelf() through proxy project. 140 * Obtains running instance keys of multi-instance app that are running on the device. 141 * 142 * @param instanceKeys, output instance keys of the multi-instance app. 143 * @return ERR_OK ,return back success,others fail. 144 */ 145 virtual int32_t GetAllRunningInstanceKeysBySelf(std::vector<std::string> &instanceKeys) override; 146 147 /** 148 * GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project. 149 * Obtains running instance keys of multi-instance app that are running on the device. 150 * 151 * @param bundlename, bundle name in Application record. 152 * @param instanceKeys, output instance keys of the multi-instance app. 153 * @param userId, user id. 154 * @return ERR_OK ,return back success,others fail. 155 */ 156 virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName, 157 std::vector<std::string> &instanceKeys, int32_t userId = -1) override; 158 159 /** 160 * GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project. 161 * Obtains information about application processes by bundle type that are running on the device. 162 * 163 * @param bundleType, bundle type of the processes 164 * @param info, app name in Application record. 165 * @return ERR_OK ,return back success,others fail. 166 */ 167 virtual int GetRunningProcessesByBundleType(const BundleType bundleType, 168 std::vector<RunningProcessInfo> &info) override; 169 170 /** 171 * GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project. 172 * Obtains information about render processes that are running on the device. 173 * 174 * @param info, render process info. 175 * @return ERR_OK, return back success, others fail. 176 */ 177 virtual int32_t GetAllRenderProcesses(std::vector<RenderProcessInfo> &info) override; 178 179 /** 180 * GetAllChildrenProcesses, call GetAllChildrenProcesses() through proxy project. 181 * Obtains information about children processes that are running on the device. 182 * 183 * @param info, child process info. 184 * @return ERR_OK, return back success, others fail. 185 */ 186 virtual int GetAllChildrenProcesses(std::vector<ChildProcessInfo> &info) override; 187 188 /** 189 * JudgeSandboxByPid, call JudgeSandboxByPid() through proxy project. 190 * Obtains information about application processes that are running on the device. 191 * 192 * @param pid, the pid of current app running record. 193 * @param isSandbox, current app is or not a sandbox. 194 * @return ERR_OK ,return back success,others fail. 195 */ 196 virtual int32_t JudgeSandboxByPid(pid_t pid, bool &isSandbox) override; 197 198 /** 199 * IsTerminatingByPid, call IsTerminatingByPid() through proxy project. 200 * Obtains information about application processes that are running on the device. 201 * 202 * @param pid, the pid of current app running record. 203 * @param isTerminating, current app is or not terminating. 204 * @return ERR_OK, return back success, others fail. 205 */ 206 virtual int32_t IsTerminatingByPid(pid_t pid, bool &isTerminating) override; 207 208 /** 209 * GetProcessRunningInfosByUserId, call GetProcessRunningInfosByUserId() through proxy project. 210 * Obtains information about application processes that are running on the device. 211 * 212 * @param info, app name in Application record. 213 * @return ERR_OK ,return back success,others fail. 214 */ 215 virtual int32_t GetProcessRunningInfosByUserId(std::vector<RunningProcessInfo> &info, int32_t userId) override; 216 217 /** 218 * GetProcessRunningInformation, call GetProcessRunningInformation() through proxy project. 219 * Obtains information about current application process which is running on the device. 220 * 221 * @param info, app name in Application record. 222 * @return ERR_OK ,return back success,others fail. 223 */ 224 virtual int32_t GetProcessRunningInformation(RunningProcessInfo &info) override; 225 226 /** 227 * NotifyMemoryLevel, call NotifyMemoryLevel() through proxy project. 228 * Notify abilities background the current memory level. 229 * 230 * @param level, the current memory level 231 * @return ERR_OK ,return back success,others fail. 232 */ 233 virtual int32_t NotifyMemoryLevel(int32_t level) override; 234 235 /** 236 * NotifyProcMemoryLevel, call NotifyMemoryLevel() through proxy project. 237 * Notify abilities the current memory level. 238 * 239 * @param procLevelMap ,<pid, level> map; 240 * @return ERR_OK ,return back success,others fail. 241 */ 242 virtual int32_t NotifyProcMemoryLevel(const std::map<pid_t, MemoryLevel> &procLevelMap) override; 243 244 /** 245 * DumpHeapMemory, call DumpHeapMemory() through proxy project. 246 * Get the application's memory allocation info. 247 * 248 * @param pid, pid input. 249 * @param mallocInfo, dynamic storage information output. 250 * @return ERR_OK ,return back success,others fail. 251 */ 252 virtual int32_t DumpHeapMemory(const int32_t pid, OHOS::AppExecFwk::MallocInfo &mallocInfo) override; 253 254 /** 255 * DumpJsHeapMemory, call DumpJsHeapMemory() through proxy project. 256 * triggerGC and dump the application's jsheap memory info. 257 * 258 * @param info, pid tid needGc needSnapshot 259 * @return ERR_OK ,return back success, others fail. 260 */ 261 virtual int32_t DumpJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info) override; 262 263 /** 264 * Notify that the ability stage has been updated 265 * @param recordId, the app record. 266 */ 267 virtual void AddAbilityStageDone(const int32_t recordId) override; 268 269 /** 270 * Start a resident process 271 */ 272 virtual void StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo> &bundleInfos) override; 273 274 /** 275 * Register application or process state observer. 276 * @param observer, ability token. 277 * @return Returns ERR_OK on success, others on failure. 278 */ 279 virtual int32_t RegisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer, 280 const std::vector<std::string> &bundleNameList = {}) override; 281 282 /** 283 * Unregister application or process state observer. 284 * @param observer, ability token. 285 * @return Returns ERR_OK on success, others on failure. 286 */ 287 virtual int32_t UnregisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer) override; 288 289 /** 290 * Register application or process state observer. 291 * @param observer, Is ability foreground state observer 292 * @return Returns ERR_OK on success, others on failure. 293 */ 294 int32_t RegisterAbilityForegroundStateObserver(const sptr<IAbilityForegroundStateObserver> &observer) override; 295 296 /** 297 * Unregister application or process state observer. 298 * @param observer, Is ability foreground state observer 299 * @return Returns ERR_OK on success, others on failure. 300 */ 301 int32_t UnregisterAbilityForegroundStateObserver(const sptr<IAbilityForegroundStateObserver> &observer) override; 302 303 /** 304 * Get foreground applications. 305 * @param list, foreground apps. 306 * @return Returns ERR_OK on success, others on failure. 307 */ 308 virtual int32_t GetForegroundApplications(std::vector<AppStateData> &list) override; 309 310 /** 311 * Start user test process. 312 * @param want, want object. 313 * @param observer, test observer remote object. 314 * @param bundleInfo, bundle info. 315 * @param userId the user id. 316 * @return Returns ERR_OK on success, others on failure. 317 */ 318 virtual int StartUserTestProcess(const AAFwk::Want &want, const sptr<IRemoteObject> &observer, 319 const BundleInfo &bundleInfo, int32_t userId) override; 320 321 /** 322 * @brief Finish user test. 323 * @param msg user test message. 324 * @param resultCode user test result Code. 325 * @param bundleName user test bundleName. 326 * 327 * @return Returns ERR_OK on success, others on failure. 328 */ 329 virtual int FinishUserTest( 330 const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override; 331 332 /** 333 * Schedule accept want done. 334 * 335 * @param recordId Application record. 336 * @param want Want. 337 * @param flag flag get from OnAcceptWant. 338 */ 339 virtual void ScheduleAcceptWantDone( 340 const int32_t recordId, const AAFwk::Want &want, const std::string &flag) override; 341 342 virtual void ScheduleNewProcessRequestDone( 343 const int32_t recordId, const AAFwk::Want &want, const std::string &flag) override; 344 345 /** 346 * Get the token of ability records by process ID. 347 * 348 * @param pid The process id. 349 * @param tokens The token of ability records. 350 * @return Returns true on success, others on failure. 351 */ 352 virtual int GetAbilityRecordsByProcessID(const int pid, std::vector<sptr<IRemoteObject>> &tokens) override; 353 354 /** 355 * Prestart nwebspawn process. 356 * 357 * @return Returns ERR_OK on success, others on failure. 358 */ 359 virtual int PreStartNWebSpawnProcess() override; 360 361 /** 362 * Start nweb render process, called by nweb host. 363 * 364 * @param renderParam, params passed to renderProcess. 365 * @param ipcFd, ipc file descriptor for web browser and render process. 366 * @param sharedFd, shared memory file descriptor. 367 * @param crashFd, crash signal file descriptor. 368 * @param renderPid, created render pid. 369 * @param isGPU, is or not GPU process 370 * @return Returns ERR_OK on success, others on failure. 371 */ 372 virtual int StartRenderProcess(const std::string &renderParam, 373 int32_t ipcFd, int32_t sharedFd, 374 int32_t crashFd, pid_t &renderPid, bool isGPU = false) override; 375 376 /** 377 * Render process call this to attach app manager service. 378 * 379 * @param renderApp, information needed to start the Application. 380 */ 381 virtual void AttachRenderProcess(const sptr<IRemoteObject> &renderApp) override; 382 383 /** 384 * Get render process termination status, called by nweb host. 385 * 386 * @param renderPid, target render pid. 387 * @param status, termination status of the render process. 388 * @return Returns ERR_OK on success, others on failure. 389 */ 390 virtual int GetRenderProcessTerminationStatus(pid_t renderPid, int &status) override; 391 392 /** 393 * Notify Fault Data 394 * 395 * @param faultData the fault data. 396 * @return Returns ERR_OK on success, others on failure. 397 */ 398 virtual int32_t NotifyAppFault(const FaultData &faultData) override; 399 400 /** 401 * Notify App Fault Data By SA 402 * 403 * @param faultData the fault data notified by SA. 404 * @return Returns ERR_OK on success, others on failure. 405 */ 406 virtual int32_t NotifyAppFaultBySA(const AppFaultDataBySA &faultData) override; 407 408 /** 409 * Set Appfreeze Detect Filter 410 * 411 * @param pid the process pid. 412 * @return Returns true on success, others on failure. 413 */ 414 virtual bool SetAppFreezeFilter(int32_t pid) override; 415 416 virtual int32_t GetConfiguration(Configuration& config) override; 417 418 virtual int32_t UpdateConfiguration(const Configuration &config, const int32_t userId = -1) override; 419 420 virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, 421 int32_t appIndex = 0) override; 422 423 virtual int32_t RegisterConfigurationObserver(const sptr<IConfigurationObserver> &observer) override; 424 425 virtual int32_t UnregisterConfigurationObserver(const sptr<IConfigurationObserver> &observer) override; 426 427 /** 428 * @brief Get the running state of application by bundle name. 429 * 430 * @param bundleName Bundle name 431 * @return Returns true if process is running, false if process isn't running. 432 */ 433 bool GetAppRunningStateByBundleName(const std::string &bundleName) override; 434 435 /** 436 * @brief Notify application load patch. 437 * 438 * @param bundleName Bundle name 439 * @param callback called when LoadPatch finished. 440 * @return Returns ERR_OK on success, error code on failure. 441 */ 442 int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override; 443 444 int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override; 445 446 int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override; 447 448 #ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE 449 int32_t SetContinuousTaskProcess(int32_t pid, bool isContinuousTask) override; 450 #endif 451 452 /** 453 * @brief Check whether the shared bundle is running. 454 * 455 * @param bundleName Shared bundle name. 456 * @param versionCode Shared bundle version code. 457 * @return Returns the shared bundle running result. The result is true if running, false otherwise. 458 */ 459 virtual bool IsSharedBundleRunning(const std::string &bundleName, uint32_t versionCode) override; 460 461 /** 462 * start native process for debugger. 463 * 464 * @param want param to start a process. 465 */ 466 virtual int32_t StartNativeProcessForDebugger(const AAFwk::Want &want) override; 467 468 /** 469 * Get bundleName by pid. 470 * 471 * @param pid process id. 472 * @param bundleName Output parameters, return bundleName. 473 * @param uid Output parameters, return userId. 474 * @return Returns ERR_OK on success, others on failure. 475 */ 476 virtual int32_t GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid) override; 477 478 /** 479 * Get running process information by pid. 480 * 481 * @param pid process id. 482 * @param info Output parameters, return runningProcessInfo. 483 * @return Returns ERR_OK on success, others on failure. 484 */ 485 virtual int32_t GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo &info) override; 486 487 /** 488 * Get running process information by child process pid. 489 * 490 * @param childPid child process id. 491 * @param info Output parameters, return runningProcessInfo. 492 * @return Returns ERR_OK on success, others on failure. 493 */ 494 virtual int32_t GetRunningProcessInfoByChildProcessPid(const pid_t childPid, 495 OHOS::AppExecFwk::RunningProcessInfo &info) override; 496 497 /** 498 * get memorySize by pid. 499 * 500 * @param pid process id. 501 * @param memorySize Output parameters, return memorySize in KB. 502 * @return Returns ERR_OK on success, others on failure. 503 */ 504 virtual int32_t GetProcessMemoryByPid(const int32_t pid, int32_t &memorySize) override; 505 506 /** 507 * get application processes information list by bundleName. 508 * 509 * @param bundleName Bundle name. 510 * @param userId user Id in Application record. 511 * @param info Output parameters, return running process info list. 512 * @return Returns ERR_OK on success, others on failure. 513 */ 514 virtual int32_t GetRunningProcessInformation( 515 const std::string &bundleName, int32_t userId, std::vector<RunningProcessInfo> &info) override; 516 517 /** 518 * @brief Notify AbilityManagerService the page show. 519 * @param token Ability identify. 520 * @param pageStateData The data of ability's page state. 521 * @return Returns ERR_OK on success, others on failure. 522 */ 523 virtual int32_t NotifyPageShow(const sptr<IRemoteObject> &token, const PageStateData &pageStateData) override; 524 525 /** 526 * @brief Notify AbilityManagerService the page hide. 527 * @param token Ability identify. 528 * @param pageStateData The data of ability's page state. 529 * @return Returns ERR_OK on success, others on failure. 530 */ 531 virtual int32_t NotifyPageHide(const sptr<IRemoteObject> &token, const PageStateData &pageStateData) override; 532 533 /** 534 * @brief Notify NativeEngine GC of status change. 535 * 536 * @param state GC state 537 * @param pid pid 538 * @return Returns ERR_OK on success, others on failure. 539 */ 540 virtual int32_t ChangeAppGcState(pid_t pid, int32_t state) override; 541 542 /** 543 * Register appRunning status listener. 544 * 545 * @param listener Running status listener. 546 * @return Returns ERR_OK on success, others on failure. 547 */ 548 int32_t RegisterAppRunningStatusListener(const sptr<IRemoteObject> &listener) override; 549 550 /** 551 * Unregister appRunning status listener. 552 * 553 * @param listener Running status listener. 554 * @return Returns ERR_OK on success, others on failure. 555 */ 556 int32_t UnregisterAppRunningStatusListener(const sptr<IRemoteObject> &listener) override; 557 558 /** 559 * Register application foreground state observer. 560 * @param observer, app Is app foreground state observer 561 * @return Returns ERR_OK on success, others on failure. 562 */ 563 int32_t RegisterAppForegroundStateObserver(const sptr<IAppForegroundStateObserver> &observer) override; 564 565 /** 566 * Unregister application foreground state observer. 567 * @param observer, app Is app foreground state observer 568 * @return Returns ERR_OK on success, others on failure. 569 */ 570 int32_t UnregisterAppForegroundStateObserver(const sptr<IAppForegroundStateObserver> &observer) override; 571 572 /** 573 * Check whether the bundle is running. 574 * 575 * @param bundleName Indicates the bundle name of the bundle. 576 * @param isRunning Obtain the running status of the application, the result is true if running, false otherwise. 577 * @return Return ERR_OK if success, others fail. 578 */ 579 int32_t IsApplicationRunning(const std::string &bundleName, bool &isRunning) override; 580 581 /** 582 * Check whether the bundle is running. 583 * 584 * @param bundleName Indicates the bundle name of the bundle. 585 * @param appCloneIndex the appindex of the bundle. 586 * @param isRunning Obtain the running status of the application, the result is true if running, false otherwise. 587 * @return Return ERR_OK if success, others fail. 588 */ 589 int32_t IsAppRunning(const std::string &bundleName, int32_t appCloneIndex, bool &isRunning) override; 590 591 /** 592 * Check whether the process of the application under the specified user exists. 593 * 594 * @param bundleName Indicates the bundle name of the bundle. 595 * @param userId the userId of the bundle. 596 * @param isRunning Obtain the running status of the application, the result is true if running, false otherwise. 597 * @return Return ERR_OK if success, others fail. 598 */ 599 int32_t IsAppRunningByBundleNameAndUserId(const std::string &bundleName, int32_t userId, bool &isRunning) override; 600 601 #ifdef SUPPORT_CHILD_PROCESS 602 /** 603 * Start child process, called by ChildProcessManager. 604 * 605 * @param childPid Created child process pid. 606 * @param request Child process start request params. 607 * @return Returns ERR_OK on success, others on failure. 608 */ 609 int32_t StartChildProcess(pid_t &childPid, const ChildProcessRequest &request) override; 610 611 /** 612 * Get child process record for self. 613 * 614 * @return child process info. 615 */ 616 int32_t GetChildProcessInfoForSelf(ChildProcessInfo &info) override; 617 618 /** 619 * Attach child process scheduler to app manager service. 620 * 621 * @param childScheduler scheduler of child process. 622 */ 623 void AttachChildProcess(const sptr<IRemoteObject> &childScheduler) override; 624 625 /** 626 * Exit child process, called by itself. 627 */ 628 void ExitChildProcessSafely() override; 629 #endif // SUPPORT_CHILD_PROCESS 630 631 /** 632 * Whether the current application process is the last surviving process. 633 * 634 * @return Returns true is final application process, others return false. 635 */ 636 bool IsFinalAppProcess() override; 637 638 /** 639 * Register render state observer. 640 * @param observer Render process state observer. 641 * @return Returns ERR_OK on success, others on failure. 642 */ 643 virtual int32_t RegisterRenderStateObserver(const sptr<IRenderStateObserver> &observer) override; 644 645 /** 646 * Unregister render state observer. 647 * @param observer Render process state observer. 648 * @return Returns ERR_OK on success, others on failure. 649 */ 650 virtual int32_t UnregisterRenderStateObserver(const sptr<IRenderStateObserver> &observer) override; 651 652 /** 653 * Register KIA interceptor. 654 * @param interceptor KIA interceptor. 655 * @return Returns ERR_OK on success, others on failure. 656 */ 657 virtual int32_t RegisterKiaInterceptor(const sptr<IKiaInterceptor> &interceptor) override; 658 659 /** 660 * Check if the given pid is a KIA process. 661 * @param pid process id. 662 * @return Returns true if it is a KIA process, false otherwise. 663 */ 664 virtual int32_t CheckIsKiaProcess(pid_t pid, bool &isKia) override; 665 666 /** 667 * Update render state. 668 * @param renderPid Render pid. 669 * @param state foreground or background state. 670 * @return Returns ERR_OK on success, others on failure. 671 */ 672 virtual int32_t UpdateRenderState(pid_t renderPid, int32_t state) override; 673 674 /** 675 * @brief mark a process which is going restart. 676 * @param uid the uid of the process. 677 * @param instanceKey the instance key of the process. 678 * 679 * @return Returns ERR_OK on success, others on failure. 680 */ 681 int32_t SignRestartAppFlag(int32_t uid, const std::string &instanceKey) override; 682 683 /** 684 * Get appRunningUniqueId by pid. 685 * @param pid pid. 686 * @param appRunningUniqueId appRunningUniqueId. 687 * @return Returns ERR_OK on success, others on failure. 688 */ 689 int32_t GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId) override; 690 691 /* 692 * Get all uiextension root host process id, need apply permission ohos.permission.GET_RUNNING_INFO. 693 * If specified pid mismatch UIExtensionAbility type, return empty vector. 694 * @param pid Process id. 695 * @param hostPids All host process id. 696 * @return Returns 0 on success, others on failure. 697 */ 698 int32_t GetAllUIExtensionRootHostPid(pid_t pid, std::vector<pid_t> &hostPids) override; 699 700 /** 701 * Get all uiextension provider process id, need apply permission ohos.permission.GET_RUNNING_INFO. 702 * If specified hostPid didn't start any UIExtensionAbility, return empty vector. 703 * @param hostPid Host process id. 704 * @param providerPids All provider process id started by specified hostPid. 705 * @return Returns 0 on success, others on failure. 706 */ 707 int32_t GetAllUIExtensionProviderPid(pid_t hostPid, std::vector<pid_t> &providerPids) override; 708 709 /** 710 * @brief Notify memory size state changed to sufficient or insufficient. 711 * @param isMemorySizeSufficient Indicates the memory size state. 712 * @return Returns ERR_OK on success, others on failure. 713 */ 714 virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficient) override; 715 716 /** 717 * Set application assertion pause state. 718 * 719 * @param flag assertion pause state. 720 */ 721 void SetAppAssertionPauseState(bool flag) override; 722 723 /** 724 * @brief set support process cache by self 725 */ 726 int32_t SetSupportedProcessCacheSelf(bool isSupport) override; 727 728 int32_t SetSupportedProcessCache(int32_t pid, bool isSupport) override; 729 730 /** 731 * set browser channel for caller 732 */ 733 virtual void SaveBrowserChannel(sptr<IRemoteObject> browser) override; 734 735 /** 736 * Check caller is test ability 737 * 738 * @param pid, the pid of ability. 739 * @return Returns ERR_OK is test ability, others is not test ability. 740 */ 741 int32_t CheckCallingIsUserTestMode(const pid_t pid, bool &isUserTest) override; 742 743 #ifdef SUPPORT_CHILD_PROCESS 744 /** 745 * Start native child process, callde by ChildProcessManager. 746 * @param libName lib file name to be load in child process 747 * @param childProcessCount current started child process count 748 * @param callback callback for notify start result 749 * @return Returns ERR_OK on success, others on failure. 750 */ 751 int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, 752 const sptr<IRemoteObject> &callback) override; 753 #endif // SUPPORT_CHILD_PROCESS 754 755 /** 756 * Notify that the process depends on web by itself. 757 */ 758 virtual int32_t NotifyProcessDependedOnWeb() override; 759 760 /** 761 * Kill process depended on web by sa. 762 */ 763 virtual void KillProcessDependedOnWeb() override; 764 765 /** 766 * Restart resident process depended on web. 767 */ 768 virtual void RestartResidentProcessDependedOnWeb() override; 769 770 /** 771 * Get pids of processes which belong to specific bundle name and support process cache feature. 772 * @param bundleName bundle name. 773 * @param pidList pid list of processes that support process cache.. 774 * @return Returns ERR_OK on success, others on failure. 775 */ 776 virtual int32_t GetSupportedProcessCachePids(const std::string &bundleName, 777 std::vector<int32_t> &pidList) override; 778 779 virtual int32_t KillAppSelfWithInstanceKey(const std::string &instanceKey, bool clearPageStack, 780 const std::string& reason) override; 781 782 virtual void UpdateInstanceKeyBySpecifiedId(int32_t specifiedId, std::string &instanceKey) override; 783 784 int32_t IsSpecifiedModuleLoaded(const AAFwk::Want &want, const AbilityInfo &abilityInfo, bool &result) override; 785 786 /** 787 * UpdateProcessMemoryState, call UpdateProcessMemoryState() through proxy object, 788 * update process rss and pss value. 789 * 790 * @param procMemStates, the memory states of all apps. 791 * @return ERR_OK, return back success, others fail. 792 */ 793 virtual int32_t UpdateProcessMemoryState(const std::vector<ProcessMemoryState> &procMemState) override; 794 795 /** 796 * Get killed process info by process id and uid. 797 * 798 * @param pid Process id. 799 * @param uid Process uid. 800 * @param info result KilledProcessInfo. 801 * @return Returns ERR_OK on success, others on failure. 802 */ 803 int32_t GetKilledProcessInfo(int pid, int uid, KilledProcessInfo &info) override; 804 private: 805 bool SendTransactCmd(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply); 806 bool WriteInterfaceToken(MessageParcel &data); 807 int32_t SendRequest(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply, 808 MessageOption& option); 809 template<typename T> 810 int GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos); 811 static inline BrokerDelegator<AppMgrProxy> delegator_; 812 }; 813 } // namespace AppExecFwk 814 } // namespace OHOS 815 #endif // OHOS_ABILITY_RUNTIME_APP_MGR_PROXY_H 816