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 16import { AsyncCallback } from './basic'; 17import ApplicationStateObserver from './application/ApplicationStateObserver'; 18import AbilityStateData from './application/AbilityStateData'; 19import AppStateData from './application/AppStateData'; 20import { ProcessRunningInfo } from './application/ProcessRunningInfo'; 21 22/** 23 * This module provides the function of app manager service. 24 * 25 * @since 8 26 * @syscap SystemCapability.Ability.AbilityRuntime.Core 27 * @permission N/A 28 * @deprecated since 9 29 * @useinstead ohos.app.ability.appManager 30 */ 31declare namespace appManager { 32 /** 33 * Register application state observer. 34 * 35 * @default - 36 * @since 8 37 * @syscap SystemCapability.Ability.AbilityRuntime.Core 38 * @param observer The application state observer. 39 * @systemapi hide this for inner system use 40 * @returns Returns the number code of the observer. 41 * @permission ohos.permission.RUNNING_STATE_OBSERVER 42 */ 43 function registerApplicationStateObserver(observer: ApplicationStateObserver): number; 44 45 /** 46 * Unregister application state observer. 47 * 48 * @since 8 49 * @syscap SystemCapability.Ability.AbilityRuntime.Core 50 * @param observerId Indicates the number code of the observer. 51 * @systemapi hide this for inner system use 52 * @returns - 53 * @permission ohos.permission.RUNNING_STATE_OBSERVER 54 */ 55 function unregisterApplicationStateObserver(observerId: number, callback: AsyncCallback<void>): void; 56 function unregisterApplicationStateObserver(observerId: number): Promise<void>; 57 58 /** 59 * getForegroundApplications. 60 * 61 * @since 8 62 * @syscap SystemCapability.Ability.AbilityRuntime.Core 63 * @systemapi hide this for inner system use 64 * @returns Returns the list of AppStateData. 65 * @permission ohos.permission.GET_RUNNING_INFO 66 */ 67 function getForegroundApplications(callback: AsyncCallback<Array<AppStateData>>): void; 68 function getForegroundApplications(): Promise<Array<AppStateData>>; 69 70 /** 71 * Kill process with account. 72 * 73 * @since 8 74 * @syscap SystemCapability.Ability.AbilityRuntime.Core 75 * @param bundleName The process bundle name. 76 * @param accountId The account id. 77 * @systemapi hide this for inner system use 78 * @returns - 79 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES 80 */ 81 function killProcessWithAccount(bundleName: string, accountId: number): Promise<void>; 82 function killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback<void>): void; 83 84 /** 85 * Is user running in stability test. 86 * 87 * @since 8 88 * @syscap SystemCapability.Ability.AbilityRuntime.Core 89 * @returns Returns true if user is running stability test. 90 */ 91 function isRunningInStabilityTest(callback: AsyncCallback<boolean>): void; 92 function isRunningInStabilityTest(): Promise<boolean>; 93 94 /** 95 * Get information about running processes 96 * 97 * @since 8 98 * @syscap SystemCapability.Ability.AbilityRuntime.Core 99 * @returns Returns the array of {@link ProcessRunningInfo}. 100 * @permission ohos.permission.GET_RUNNING_INFO 101 * @deprecated since 9 102 * @useinstead ohos.app.ability.appManager#getRunningProcessInformation 103 */ 104 function getProcessRunningInfos(): Promise<Array<ProcessRunningInfo>>; 105 function getProcessRunningInfos(callback: AsyncCallback<Array<ProcessRunningInfo>>): void; 106 107 /** 108 * Kill processes by bundle name 109 * @since 8 110 * @syscap SystemCapability.Ability.AbilityRuntime.Core 111 * @param bundleName bundle name. 112 * @systemapi hide this for inner system use 113 * @permission ohos.permission.CLEAN_BACKGROUND_PROCESSES 114 */ 115 function killProcessesByBundleName(bundleName: string): Promise<void>; 116 function killProcessesByBundleName(bundleName: string, callback: AsyncCallback<void>); 117 118 /** 119 * Clear up application data by bundle name 120 * @since 8 121 * @syscap SystemCapability.Ability.AbilityRuntime.Core 122 * @param bundleName bundle name. 123 * @systemapi hide this for inner system use 124 * @permission ohos.permission.CLEAN_APPLICATION_DATA 125 */ 126 function clearUpApplicationData(bundleName: string): Promise<void>; 127 function clearUpApplicationData(bundleName: string, callback: AsyncCallback<void>); 128 129 /** 130 * Is it a ram-constrained device 131 * @since 7 132 * @syscap SystemCapability.Ability.AbilityRuntime.Core 133 * @returns whether a ram-constrained device. 134 */ 135 function isRamConstrainedDevice(): Promise<boolean>; 136 function isRamConstrainedDevice(callback: AsyncCallback<boolean>): void; 137 138 /** 139 * Get the memory size of the application 140 * @since 7 141 * @syscap SystemCapability.Ability.AbilityRuntime.Core 142 * @returns application memory size. 143 */ 144 function getAppMemorySize(): Promise<number>; 145 function getAppMemorySize(callback: AsyncCallback<number>): void; 146} 147 148export default appManager; 149