• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-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/**
17 * @file
18 */
19
20import { AsyncCallback } from './@ohos.base';
21import ApplicationStateObserver from './application/ApplicationStateObserver';
22import AbilityStateData from './application/AbilityStateData';
23import AppStateData from './application/AppStateData';
24import { ProcessRunningInfo } from './application/ProcessRunningInfo';
25
26/**
27 * This module provides the function of app manager service.
28 *
29 * @namespace appManager
30 * @syscap SystemCapability.Ability.AbilityRuntime.Core
31 * @since 8
32 * @deprecated since 9
33 * @useinstead ohos.app.ability.appManager/appManager
34 */
35declare namespace appManager {
36  /**
37   * Register application state observer.
38   *
39   * @permission ohos.permission.RUNNING_STATE_OBSERVER
40   * @param { ApplicationStateObserver } observer - The application state observer.
41   * @returns { number } Returns the number code of the observer.
42   * @syscap SystemCapability.Ability.AbilityRuntime.Core
43   * @systemapi
44   * @since 8
45   * @deprecated since 9
46   * @useinstead ohos.app.ability.appManager/appManager#on
47   */
48  function registerApplicationStateObserver(observer: ApplicationStateObserver): number;
49
50  /**
51   * Unregister application state observer.
52   *
53   * @permission ohos.permission.RUNNING_STATE_OBSERVER
54   * @param { number } observerId - Indicates the number code of the observer.
55   * @param { AsyncCallback<void> } callback - Represents the specified callback method.
56   * @syscap SystemCapability.Ability.AbilityRuntime.Core
57   * @systemapi
58   * @since 8
59   * @deprecated since 9
60   * @useinstead ohos.app.ability.appManager/appManager#off
61   */
62  function unregisterApplicationStateObserver(observerId: number, callback: AsyncCallback<void>): void;
63
64  /**
65   * Unregister application state observer.
66   *
67   * @permission ohos.permission.RUNNING_STATE_OBSERVER
68   * @param { number } observerId - Indicates the number code of the observer.
69   * @returns { Promise<void> } The promise returned by the function.
70   * @syscap SystemCapability.Ability.AbilityRuntime.Core
71   * @systemapi
72   * @since 8
73   * @deprecated since 9
74   * @useinstead ohos.app.ability.appManager/appManager#off
75   */
76  function unregisterApplicationStateObserver(observerId: number): Promise<void>;
77
78  /**
79   * getForegroundApplications.
80   *
81   * @permission ohos.permission.GET_RUNNING_INFO
82   * @param { AsyncCallback<Array<AppStateData>> } callback - Return all application information currently in the
83   *                                                          foreground in the form of callback.
84   * @syscap SystemCapability.Ability.AbilityRuntime.Core
85   * @systemapi
86   * @since 8
87   * @deprecated since 9
88   * @useinstead ohos.app.ability.appManager/appManager#getForegroundApplications
89   */
90  function getForegroundApplications(callback: AsyncCallback<Array<AppStateData>>): void;
91
92  /**
93   * getForegroundApplications.
94   *
95   * @permission ohos.permission.GET_RUNNING_INFO
96   * @returns { Promise<Array<AppStateData>> } Returns the list of AppStateData.
97   * @syscap SystemCapability.Ability.AbilityRuntime.Core
98   * @systemapi
99   * @since 8
100   * @deprecated since 9
101   * @useinstead ohos.app.ability.appManager/appManager#getForegroundApplications
102   */
103  function getForegroundApplications(): Promise<Array<AppStateData>>;
104
105  /**
106   * Kill process with account.
107   *
108   * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES
109   * @param { string } bundleName - The process bundle name.
110   * @param { number } accountId - The account id.
111   * @returns { Promise<void> } The promise returned by the function.
112   * @syscap SystemCapability.Ability.AbilityRuntime.Core
113   * @systemapi
114   * @since 8
115   * @deprecated since 9
116   * @useinstead ohos.app.ability.appManager/appManager#killProcessWithAccount
117   */
118  function killProcessWithAccount(bundleName: string, accountId: number): Promise<void>;
119
120  /**
121   * Kill process with account.
122   *
123   * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES
124   * @param { string } bundleName - The process bundle name.
125   * @param { number } accountId - The account id.
126   * @param { AsyncCallback<void> } callback - Cut off the callback function of the account process.
127   * @syscap SystemCapability.Ability.AbilityRuntime.Core
128   * @systemapi
129   * @since 8
130   * @deprecated since 9
131   * @useinstead ohos.app.ability.appManager/appManager#killProcessWithAccount
132   */
133  function killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback<void>): void;
134
135  /**
136   * Is user running in stability test.
137   *
138   * @param { AsyncCallback<boolean> } callback - Returns whether the current stability testing scenario is in progress.
139   * @syscap SystemCapability.Ability.AbilityRuntime.Core
140   * @since 8
141   * @deprecated since 9
142   * @useinstead ohos.app.ability.appManager/appManager#isRunningInStabilityTest
143   */
144  function isRunningInStabilityTest(callback: AsyncCallback<boolean>): void;
145
146  /**
147   * Is user running in stability test.
148   *
149   * @returns { Promise<boolean> } Returns true if user is running stability test.
150   * @syscap SystemCapability.Ability.AbilityRuntime.Core
151   * @since 8
152   * @deprecated since 9
153   * @useinstead ohos.app.ability.appManager/appManager#isRunningInStabilityTest
154   */
155  function isRunningInStabilityTest(): Promise<boolean>;
156
157  /**
158   * Get information about running processes
159   *
160   * @permission ohos.permission.GET_RUNNING_INFO
161   * @returns { Promise<Array<ProcessRunningInfo>> } Returns the array of {@link ProcessRunningInfo}.
162   * @syscap SystemCapability.Ability.AbilityRuntime.Core
163   * @since 8
164   * @deprecated since 9
165   * @useinstead ohos.app.ability.appManager/appManager#getRunningProcessInformation
166   */
167  function getProcessRunningInfos(): Promise<Array<ProcessRunningInfo>>;
168
169  /**
170   * Get information about running processes
171   *
172   * @permission ohos.permission.GET_RUNNING_INFO
173   * @param { AsyncCallback<Array<ProcessRunningInfo>> } callback - Obtain information about running processes.
174   * @syscap SystemCapability.Ability.AbilityRuntime.Core
175   * @since 8
176   * @deprecated since 9
177   * @useinstead ohos.app.ability.appManager/appManager#getRunningProcessInformation
178   */
179  function getProcessRunningInfos(callback: AsyncCallback<Array<ProcessRunningInfo>>): void;
180
181  /**
182   * Kill processes by bundle name
183   *
184   * @permission ohos.permission.CLEAN_BACKGROUND_PROCESSES
185   * @param { string } bundleName - bundle name.
186   * @returns { Promise<void> } The promise returned by the function.
187   * @syscap SystemCapability.Ability.AbilityRuntime.Core
188   * @systemapi
189   * @since 8
190   * @deprecated since 9
191   * @useinstead ohos.app.ability.appManager/appManager#killProcessesByBundleName
192   */
193  function killProcessesByBundleName(bundleName: string): Promise<void>;
194
195  /**
196   * Kill processes by bundle name
197   *
198   * @permission ohos.permission.CLEAN_BACKGROUND_PROCESSES
199   * @param { string } bundleName - bundle name.
200   * @param { AsyncCallback<void> } callback - cut off the callback function of the account process.
201   * @syscap SystemCapability.Ability.AbilityRuntime.Core
202   * @systemapi
203   * @since 8
204   * @deprecated since 9
205   * @useinstead ohos.app.ability.appManager/appManager#killProcessesByBundleName
206   */
207  function killProcessesByBundleName(bundleName: string, callback: AsyncCallback<void>);
208
209  /**
210   * Clear up application data by bundle name
211   *
212   * @permission ohos.permission.CLEAN_APPLICATION_DATA
213   * @param { string } bundleName - bundle name.
214   * @returns { Promise<void> } The promise returned by the function.
215   * @syscap SystemCapability.Ability.AbilityRuntime.Core
216   * @systemapi
217   * @since 8
218   * @deprecated since 9
219   * @useinstead ohos.app.ability.appManager/appManager#clearUpApplicationData
220   */
221  function clearUpApplicationData(bundleName: string): Promise<void>;
222
223  /**
224   * Clear up application data by bundle name
225   *
226   * @permission ohos.permission.CLEAN_APPLICATION_DATA
227   * @param { string } bundleName - bundle name.
228   * @param { AsyncCallback<void> } callback - Represents the specified callback method.
229   * @syscap SystemCapability.Ability.AbilityRuntime.Core
230   * @systemapi
231   * @since 8
232   * @deprecated since 9
233   * @useinstead ohos.app.ability.appManager/appManager#clearUpApplicationData
234   */
235  function clearUpApplicationData(bundleName: string, callback: AsyncCallback<void>);
236
237  /**
238   * Is it a ram-constrained device
239   *
240   * @returns { Promise<boolean> } whether a ram-constrained device.
241   * @syscap SystemCapability.Ability.AbilityRuntime.Core
242   * @since 7
243   * @deprecated since 9
244   * @useinstead ohos.app.ability.appManager/appManager#isRamConstrainedDevice
245   */
246  function isRamConstrainedDevice(): Promise<boolean>;
247
248  /**
249   * Is it a ram-constrained device
250   *
251   * @param { AsyncCallback<boolean> } callback - Returns whether the current device is a RAM restricted device.
252   * @syscap SystemCapability.Ability.AbilityRuntime.Core
253   * @since 7
254   * @deprecated since 9
255   * @useinstead ohos.app.ability.appManager/appManager#isRamConstrainedDevice
256   */
257  function isRamConstrainedDevice(callback: AsyncCallback<boolean>): void;
258
259  /**
260   * Get the memory size of the application
261   *
262   * @returns { Promise<number> } application memory size.
263   * @syscap SystemCapability.Ability.AbilityRuntime.Core
264   * @since 7
265   * @deprecated since 9
266   * @useinstead ohos.app.ability.appManager/appManager#getAppMemorySize
267   */
268  function getAppMemorySize(): Promise<number>;
269
270  /**
271   * Get the memory size of the application
272   *
273   * @param { AsyncCallback<number> } callback - application memory size in M.
274   * @syscap SystemCapability.Ability.AbilityRuntime.Core
275   * @since 7
276   * @deprecated since 9
277   * @useinstead ohos.app.ability.appManager/appManager#getAppMemorySize
278   */
279  function getAppMemorySize(callback: AsyncCallback<number>): void;
280}
281
282export default appManager;
283