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 16import UIAbility from '../@ohos.app.ability.UIAbility'; 17 18/** 19 * Provide methods for matching monitored Ability objects that meet specified conditions. 20 * The most recently matched Ability objects will be saved in the AbilityMonitor object. 21 * 22 * @interface AbilityMonitor 23 * @syscap SystemCapability.Ability.AbilityRuntime.Core 24 * @since 9 25 */ 26/** 27 * Provide methods for matching monitored Ability objects that meet specified conditions. 28 * The most recently matched Ability objects will be saved in the AbilityMonitor object. 29 * 30 * @interface AbilityMonitor 31 * @syscap SystemCapability.Ability.AbilityRuntime.Core 32 * @crossplatform 33 * @since 10 34 */ 35export interface AbilityMonitor { 36 /** 37 * The name of the ability to monitor. 38 * 39 * @type { string } 40 * @syscap SystemCapability.Ability.AbilityRuntime.Core 41 * @since 9 42 */ 43 /** 44 * The name of the ability to monitor. 45 * 46 * @type { string } 47 * @syscap SystemCapability.Ability.AbilityRuntime.Core 48 * @crossplatform 49 * @since 10 50 */ 51 abilityName: string; 52 53 /** 54 * The name of the module to monitor. 55 * 56 * @type { ?string } 57 * @syscap SystemCapability.Ability.AbilityRuntime.Core 58 * @since 9 59 */ 60 /** 61 * The name of the module to monitor. 62 * 63 * @type { ?string } 64 * @syscap SystemCapability.Ability.AbilityRuntime.Core 65 * @crossplatform 66 * @since 10 67 */ 68 moduleName?: string; 69 70 /** 71 * Called back when the ability is created for initialization. 72 * 73 * @syscap SystemCapability.Ability.AbilityRuntime.Core 74 * @since 9 75 */ 76 /** 77 * Called back when the ability is created for initialization. 78 * 79 * @syscap SystemCapability.Ability.AbilityRuntime.Core 80 * @crossplatform 81 * @since 10 82 */ 83 onAbilityCreate?: (ability: UIAbility) => void; 84 85 /** 86 * Called back when the state of the ability changes to foreground. 87 * 88 * @syscap SystemCapability.Ability.AbilityRuntime.Core 89 * @since 9 90 */ 91 /** 92 * Called back when the state of the ability changes to foreground. 93 * 94 * @syscap SystemCapability.Ability.AbilityRuntime.Core 95 * @crossplatform 96 * @since 10 97 */ 98 onAbilityForeground?: (ability: UIAbility) => void; 99 100 /** 101 * Called back when the state of the ability changes to background. 102 * 103 * @syscap SystemCapability.Ability.AbilityRuntime.Core 104 * @since 9 105 */ 106 /** 107 * Called back when the state of the ability changes to background. 108 * 109 * @syscap SystemCapability.Ability.AbilityRuntime.Core 110 * @crossplatform 111 * @since 10 112 */ 113 onAbilityBackground?: (ability: UIAbility) => void; 114 115 /** 116 * Called back before the ability is destroyed. 117 * 118 * @syscap SystemCapability.Ability.AbilityRuntime.Core 119 * @since 9 120 */ 121 /** 122 * Called back before the ability is destroyed. 123 * 124 * @syscap SystemCapability.Ability.AbilityRuntime.Core 125 * @crossplatform 126 * @since 10 127 */ 128 onAbilityDestroy?: (ability: UIAbility) => void; 129 130 /** 131 * Called back when an ability window stage is created. 132 * 133 * @syscap SystemCapability.Ability.AbilityRuntime.Core 134 * @since 9 135 */ 136 /** 137 * Called back when an ability window stage is created. 138 * 139 * @syscap SystemCapability.Ability.AbilityRuntime.Core 140 * @crossplatform 141 * @since 10 142 */ 143 onWindowStageCreate?: (ability: UIAbility) => void; 144 145 /** 146 * Called back when an ability window stage is restored. 147 * 148 * @syscap SystemCapability.Ability.AbilityRuntime.Core 149 * @since 9 150 */ 151 onWindowStageRestore?: (ability: UIAbility) => void; 152 153 /** 154 * Called back when an ability window stage is destroyed. 155 * 156 * @syscap SystemCapability.Ability.AbilityRuntime.Core 157 * @since 9 158 */ 159 /** 160 * Called back when an ability window stage is destroyed. 161 * 162 * @syscap SystemCapability.Ability.AbilityRuntime.Core 163 * @crossplatform 164 * @since 10 165 */ 166 onWindowStageDestroy?: (ability: UIAbility) => void; 167} 168 169export default AbilityMonitor; 170