161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci */ 1961847f8eSopenharmony_ci 2061847f8eSopenharmony_ciimport { AsyncCallback } from './@ohos.base'; 2161847f8eSopenharmony_ciimport ApplicationStateObserver from './application/ApplicationStateObserver'; 2261847f8eSopenharmony_ciimport AbilityStateData from './application/AbilityStateData'; 2361847f8eSopenharmony_ciimport AppStateData from './application/AppStateData'; 2461847f8eSopenharmony_ciimport { ProcessRunningInfo } from './application/ProcessRunningInfo'; 2561847f8eSopenharmony_ci 2661847f8eSopenharmony_ci/** 2761847f8eSopenharmony_ci * This module provides the function of app manager service. 2861847f8eSopenharmony_ci * 2961847f8eSopenharmony_ci * @namespace appManager 3061847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 3161847f8eSopenharmony_ci * @since 8 3261847f8eSopenharmony_ci * @deprecated since 9 3361847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager 3461847f8eSopenharmony_ci */ 3561847f8eSopenharmony_cideclare namespace appManager { 3661847f8eSopenharmony_ci /** 3761847f8eSopenharmony_ci * Register application state observer. 3861847f8eSopenharmony_ci * 3961847f8eSopenharmony_ci * @permission ohos.permission.RUNNING_STATE_OBSERVER 4061847f8eSopenharmony_ci * @param { ApplicationStateObserver } observer - The application state observer. 4161847f8eSopenharmony_ci * @returns { number } Returns the number code of the observer. 4261847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 4361847f8eSopenharmony_ci * @systemapi 4461847f8eSopenharmony_ci * @since 8 4561847f8eSopenharmony_ci * @deprecated since 9 4661847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#on 4761847f8eSopenharmony_ci */ 4861847f8eSopenharmony_ci function registerApplicationStateObserver(observer: ApplicationStateObserver): number; 4961847f8eSopenharmony_ci 5061847f8eSopenharmony_ci /** 5161847f8eSopenharmony_ci * Unregister application state observer. 5261847f8eSopenharmony_ci * 5361847f8eSopenharmony_ci * @permission ohos.permission.RUNNING_STATE_OBSERVER 5461847f8eSopenharmony_ci * @param { number } observerId - Indicates the number code of the observer. 5561847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - Represents the specified callback method. 5661847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 5761847f8eSopenharmony_ci * @systemapi 5861847f8eSopenharmony_ci * @since 8 5961847f8eSopenharmony_ci * @deprecated since 9 6061847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#off 6161847f8eSopenharmony_ci */ 6261847f8eSopenharmony_ci function unregisterApplicationStateObserver(observerId: number, callback: AsyncCallback<void>): void; 6361847f8eSopenharmony_ci 6461847f8eSopenharmony_ci /** 6561847f8eSopenharmony_ci * Unregister application state observer. 6661847f8eSopenharmony_ci * 6761847f8eSopenharmony_ci * @permission ohos.permission.RUNNING_STATE_OBSERVER 6861847f8eSopenharmony_ci * @param { number } observerId - Indicates the number code of the observer. 6961847f8eSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 7061847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 7161847f8eSopenharmony_ci * @systemapi 7261847f8eSopenharmony_ci * @since 8 7361847f8eSopenharmony_ci * @deprecated since 9 7461847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#off 7561847f8eSopenharmony_ci */ 7661847f8eSopenharmony_ci function unregisterApplicationStateObserver(observerId: number): Promise<void>; 7761847f8eSopenharmony_ci 7861847f8eSopenharmony_ci /** 7961847f8eSopenharmony_ci * getForegroundApplications. 8061847f8eSopenharmony_ci * 8161847f8eSopenharmony_ci * @permission ohos.permission.GET_RUNNING_INFO 8261847f8eSopenharmony_ci * @param { AsyncCallback<Array<AppStateData>> } callback - Return all application information currently in the 8361847f8eSopenharmony_ci * foreground in the form of callback. 8461847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 8561847f8eSopenharmony_ci * @systemapi 8661847f8eSopenharmony_ci * @since 8 8761847f8eSopenharmony_ci * @deprecated since 9 8861847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#getForegroundApplications 8961847f8eSopenharmony_ci */ 9061847f8eSopenharmony_ci function getForegroundApplications(callback: AsyncCallback<Array<AppStateData>>): void; 9161847f8eSopenharmony_ci 9261847f8eSopenharmony_ci /** 9361847f8eSopenharmony_ci * getForegroundApplications. 9461847f8eSopenharmony_ci * 9561847f8eSopenharmony_ci * @permission ohos.permission.GET_RUNNING_INFO 9661847f8eSopenharmony_ci * @returns { Promise<Array<AppStateData>> } Returns the list of AppStateData. 9761847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 9861847f8eSopenharmony_ci * @systemapi 9961847f8eSopenharmony_ci * @since 8 10061847f8eSopenharmony_ci * @deprecated since 9 10161847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#getForegroundApplications 10261847f8eSopenharmony_ci */ 10361847f8eSopenharmony_ci function getForegroundApplications(): Promise<Array<AppStateData>>; 10461847f8eSopenharmony_ci 10561847f8eSopenharmony_ci /** 10661847f8eSopenharmony_ci * Kill process with account. 10761847f8eSopenharmony_ci * 10861847f8eSopenharmony_ci * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES 10961847f8eSopenharmony_ci * @param { string } bundleName - The process bundle name. 11061847f8eSopenharmony_ci * @param { number } accountId - The account id. 11161847f8eSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 11261847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 11361847f8eSopenharmony_ci * @systemapi 11461847f8eSopenharmony_ci * @since 8 11561847f8eSopenharmony_ci * @deprecated since 9 11661847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#killProcessWithAccount 11761847f8eSopenharmony_ci */ 11861847f8eSopenharmony_ci function killProcessWithAccount(bundleName: string, accountId: number): Promise<void>; 11961847f8eSopenharmony_ci 12061847f8eSopenharmony_ci /** 12161847f8eSopenharmony_ci * Kill process with account. 12261847f8eSopenharmony_ci * 12361847f8eSopenharmony_ci * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES 12461847f8eSopenharmony_ci * @param { string } bundleName - The process bundle name. 12561847f8eSopenharmony_ci * @param { number } accountId - The account id. 12661847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - Cut off the callback function of the account process. 12761847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 12861847f8eSopenharmony_ci * @systemapi 12961847f8eSopenharmony_ci * @since 8 13061847f8eSopenharmony_ci * @deprecated since 9 13161847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#killProcessWithAccount 13261847f8eSopenharmony_ci */ 13361847f8eSopenharmony_ci function killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback<void>): void; 13461847f8eSopenharmony_ci 13561847f8eSopenharmony_ci /** 13661847f8eSopenharmony_ci * Is user running in stability test. 13761847f8eSopenharmony_ci * 13861847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - Returns whether the current stability testing scenario is in progress. 13961847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 14061847f8eSopenharmony_ci * @since 8 14161847f8eSopenharmony_ci * @deprecated since 9 14261847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#isRunningInStabilityTest 14361847f8eSopenharmony_ci */ 14461847f8eSopenharmony_ci function isRunningInStabilityTest(callback: AsyncCallback<boolean>): void; 14561847f8eSopenharmony_ci 14661847f8eSopenharmony_ci /** 14761847f8eSopenharmony_ci * Is user running in stability test. 14861847f8eSopenharmony_ci * 14961847f8eSopenharmony_ci * @returns { Promise<boolean> } Returns true if user is running stability test. 15061847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 15161847f8eSopenharmony_ci * @since 8 15261847f8eSopenharmony_ci * @deprecated since 9 15361847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#isRunningInStabilityTest 15461847f8eSopenharmony_ci */ 15561847f8eSopenharmony_ci function isRunningInStabilityTest(): Promise<boolean>; 15661847f8eSopenharmony_ci 15761847f8eSopenharmony_ci /** 15861847f8eSopenharmony_ci * Get information about running processes 15961847f8eSopenharmony_ci * 16061847f8eSopenharmony_ci * @permission ohos.permission.GET_RUNNING_INFO 16161847f8eSopenharmony_ci * @returns { Promise<Array<ProcessRunningInfo>> } Returns the array of {@link ProcessRunningInfo}. 16261847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 16361847f8eSopenharmony_ci * @since 8 16461847f8eSopenharmony_ci * @deprecated since 9 16561847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#getRunningProcessInformation 16661847f8eSopenharmony_ci */ 16761847f8eSopenharmony_ci function getProcessRunningInfos(): Promise<Array<ProcessRunningInfo>>; 16861847f8eSopenharmony_ci 16961847f8eSopenharmony_ci /** 17061847f8eSopenharmony_ci * Get information about running processes 17161847f8eSopenharmony_ci * 17261847f8eSopenharmony_ci * @permission ohos.permission.GET_RUNNING_INFO 17361847f8eSopenharmony_ci * @param { AsyncCallback<Array<ProcessRunningInfo>> } callback - Obtain information about running processes. 17461847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 17561847f8eSopenharmony_ci * @since 8 17661847f8eSopenharmony_ci * @deprecated since 9 17761847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#getRunningProcessInformation 17861847f8eSopenharmony_ci */ 17961847f8eSopenharmony_ci function getProcessRunningInfos(callback: AsyncCallback<Array<ProcessRunningInfo>>): void; 18061847f8eSopenharmony_ci 18161847f8eSopenharmony_ci /** 18261847f8eSopenharmony_ci * Kill processes by bundle name 18361847f8eSopenharmony_ci * 18461847f8eSopenharmony_ci * @permission ohos.permission.CLEAN_BACKGROUND_PROCESSES 18561847f8eSopenharmony_ci * @param { string } bundleName - bundle name. 18661847f8eSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 18761847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 18861847f8eSopenharmony_ci * @systemapi 18961847f8eSopenharmony_ci * @since 8 19061847f8eSopenharmony_ci * @deprecated since 9 19161847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#killProcessesByBundleName 19261847f8eSopenharmony_ci */ 19361847f8eSopenharmony_ci function killProcessesByBundleName(bundleName: string): Promise<void>; 19461847f8eSopenharmony_ci 19561847f8eSopenharmony_ci /** 19661847f8eSopenharmony_ci * Kill processes by bundle name 19761847f8eSopenharmony_ci * 19861847f8eSopenharmony_ci * @permission ohos.permission.CLEAN_BACKGROUND_PROCESSES 19961847f8eSopenharmony_ci * @param { string } bundleName - bundle name. 20061847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - cut off the callback function of the account process. 20161847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 20261847f8eSopenharmony_ci * @systemapi 20361847f8eSopenharmony_ci * @since 8 20461847f8eSopenharmony_ci * @deprecated since 9 20561847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#killProcessesByBundleName 20661847f8eSopenharmony_ci */ 20761847f8eSopenharmony_ci function killProcessesByBundleName(bundleName: string, callback: AsyncCallback<void>); 20861847f8eSopenharmony_ci 20961847f8eSopenharmony_ci /** 21061847f8eSopenharmony_ci * Clear up application data by bundle name 21161847f8eSopenharmony_ci * 21261847f8eSopenharmony_ci * @permission ohos.permission.CLEAN_APPLICATION_DATA 21361847f8eSopenharmony_ci * @param { string } bundleName - bundle name. 21461847f8eSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 21561847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 21661847f8eSopenharmony_ci * @systemapi 21761847f8eSopenharmony_ci * @since 8 21861847f8eSopenharmony_ci * @deprecated since 9 21961847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#clearUpApplicationData 22061847f8eSopenharmony_ci */ 22161847f8eSopenharmony_ci function clearUpApplicationData(bundleName: string): Promise<void>; 22261847f8eSopenharmony_ci 22361847f8eSopenharmony_ci /** 22461847f8eSopenharmony_ci * Clear up application data by bundle name 22561847f8eSopenharmony_ci * 22661847f8eSopenharmony_ci * @permission ohos.permission.CLEAN_APPLICATION_DATA 22761847f8eSopenharmony_ci * @param { string } bundleName - bundle name. 22861847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - Represents the specified callback method. 22961847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 23061847f8eSopenharmony_ci * @systemapi 23161847f8eSopenharmony_ci * @since 8 23261847f8eSopenharmony_ci * @deprecated since 9 23361847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#clearUpApplicationData 23461847f8eSopenharmony_ci */ 23561847f8eSopenharmony_ci function clearUpApplicationData(bundleName: string, callback: AsyncCallback<void>); 23661847f8eSopenharmony_ci 23761847f8eSopenharmony_ci /** 23861847f8eSopenharmony_ci * Is it a ram-constrained device 23961847f8eSopenharmony_ci * 24061847f8eSopenharmony_ci * @returns { Promise<boolean> } whether a ram-constrained device. 24161847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 24261847f8eSopenharmony_ci * @since 7 24361847f8eSopenharmony_ci * @deprecated since 9 24461847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#isRamConstrainedDevice 24561847f8eSopenharmony_ci */ 24661847f8eSopenharmony_ci function isRamConstrainedDevice(): Promise<boolean>; 24761847f8eSopenharmony_ci 24861847f8eSopenharmony_ci /** 24961847f8eSopenharmony_ci * Is it a ram-constrained device 25061847f8eSopenharmony_ci * 25161847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - Returns whether the current device is a RAM restricted device. 25261847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 25361847f8eSopenharmony_ci * @since 7 25461847f8eSopenharmony_ci * @deprecated since 9 25561847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#isRamConstrainedDevice 25661847f8eSopenharmony_ci */ 25761847f8eSopenharmony_ci function isRamConstrainedDevice(callback: AsyncCallback<boolean>): void; 25861847f8eSopenharmony_ci 25961847f8eSopenharmony_ci /** 26061847f8eSopenharmony_ci * Get the memory size of the application 26161847f8eSopenharmony_ci * 26261847f8eSopenharmony_ci * @returns { Promise<number> } application memory size. 26361847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 26461847f8eSopenharmony_ci * @since 7 26561847f8eSopenharmony_ci * @deprecated since 9 26661847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#getAppMemorySize 26761847f8eSopenharmony_ci */ 26861847f8eSopenharmony_ci function getAppMemorySize(): Promise<number>; 26961847f8eSopenharmony_ci 27061847f8eSopenharmony_ci /** 27161847f8eSopenharmony_ci * Get the memory size of the application 27261847f8eSopenharmony_ci * 27361847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - application memory size in M. 27461847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 27561847f8eSopenharmony_ci * @since 7 27661847f8eSopenharmony_ci * @deprecated since 9 27761847f8eSopenharmony_ci * @useinstead ohos.app.ability.appManager/appManager#getAppMemorySize 27861847f8eSopenharmony_ci */ 27961847f8eSopenharmony_ci function getAppMemorySize(callback: AsyncCallback<number>): void; 28061847f8eSopenharmony_ci} 28161847f8eSopenharmony_ci 28261847f8eSopenharmony_ciexport default appManager; 283