1 /* 2 * Copyright (c) 2021-2022 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_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_H 18 19 #include "ability_manager_client.h" 20 #include "app_mgr_interface.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 using OHOS::AAFwk::AbilityManagerClient; 25 using OHOS::AAFwk::RECENT_IGNORE_UNAVAILABLE; 26 using OHOS::AAFwk::Want; 27 using OHOS::AppExecFwk::RunningProcessInfo; 28 29 class AbilityManager { 30 public: 31 AbilityManager() = default; 32 virtual ~AbilityManager() = default; 33 34 static AbilityManager &GetInstance(); 35 36 /** 37 * StartAbility with want, send want to ability manager service. 38 * 39 * @param want Ability want. 40 * @param requestCode Ability request code. 41 * @return Returns ERR_OK on success, others on failure. 42 */ 43 void StartAbility(const Want &want, int requestCode); 44 45 /** 46 * Clears user data of the application, which is equivalent to initializing the application. 47 * 48 * @param bundleName. 49 */ 50 int32_t ClearUpApplicationData(const std::string &bundleName); 51 52 /** 53 * Obtains information about application processes that are running on the device. 54 * 55 * @returns Returns a list of running processes. 56 */ 57 std::vector<RunningProcessInfo> GetAllRunningProcesses(); 58 59 /** 60 * Kill the process immediately. 61 * 62 * @param bundleName. 63 * @return Returns ERR_OK on success, others on failure. 64 */ 65 int KillProcessesByBundleName(const std::string &bundleName, const bool clearPageStack = true); 66 }; 67 } // namespace AppExecFwk 68 } // namespace OHOS 69 #endif // OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_H 70