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 * @kit AbilityKit 19 */ 20 21import AppStateData from './AppStateData'; 22import AbilityStateData from './AbilityStateData'; 23import * as _ProcessData from './ProcessData'; 24 25/** 26 * The application state observer. 27 * 28 * @syscap SystemCapability.Ability.AbilityRuntime.Core 29 * @since 14 30 */ 31export default class ApplicationStateObserver { 32 /** 33 * Will be called when foreground or background application changed. 34 * 35 * @param { AppStateData } appStateData - State changed Application info. 36 * @syscap SystemCapability.Ability.AbilityRuntime.Core 37 * @since 14 38 */ 39 onForegroundApplicationChanged(appStateData: AppStateData): void; 40 41 /** 42 * Will be called when ability state changed. 43 * 44 * @param { AbilityStateData } abilityStateData - State changed ability info. 45 * @syscap SystemCapability.Ability.AbilityRuntime.Core 46 * @since 14 47 */ 48 onAbilityStateChanged(abilityStateData: AbilityStateData): void; 49 50 /** 51 * Will be called when process created. 52 * 53 * @param { ProcessData } processData - Process info. 54 * @syscap SystemCapability.Ability.AbilityRuntime.Core 55 * @since 14 56 */ 57 onProcessCreated(processData: ProcessData): void; 58 59 /** 60 * Will be called when process died. 61 * 62 * @param { ProcessData } processData - Process info. 63 * @syscap SystemCapability.Ability.AbilityRuntime.Core 64 * @since 14 65 */ 66 onProcessDied(processData: ProcessData): void; 67 68 /** 69 * Called when process state changes. 70 * 71 * @param { ProcessData } processData - Process info. 72 * @syscap SystemCapability.Ability.AbilityRuntime.Core 73 * @since 14 74 */ 75 onProcessStateChanged(processData: ProcessData): void; 76 77 /** 78 * Called when application is started. 79 * 80 * @param { AppStateData } appStateData - State changed Application info. 81 * @syscap SystemCapability.Ability.AbilityRuntime.Core 82 * @since 14 83 */ 84 onAppStarted(appStateData: AppStateData): void; 85 86 /** 87 * Called when application is stopped. 88 * 89 * @param { AppStateData } appStateData - State changed Application info. 90 * @syscap SystemCapability.Ability.AbilityRuntime.Core 91 * @since 14 92 */ 93 onAppStopped(appStateData: AppStateData): void; 94} 95 96/** 97 * The process data. 98 * @typedef { _ProcessData.default } 99 * @syscap SystemCapability.Ability.AbilityRuntime.Core 100 * @since 14 101 */ 102export type ProcessData = _ProcessData.default; 103