1/* 2 * Copyright (c) 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 , Callback} from './basic'; 17 18/** 19 * Provides methods for managing bundle usage statistics, 20 * including the methods for querying bundle usage information and state data. 21 * 22 * <p>You can use the methods defined in this class to query 23 * the usage history and states of bundles in a specified period. 24 * The system stores the query result in a {@link BundleStateInfo} or {@link BundleActiveState} instance and 25 * then returns it to you. 26 * 27 * @since 7 28 * @deprecated since 9 29 * @useinstead @ohos.resourceschedule.usageStatistics 30 */ 31declare namespace bundleState { 32 33 /** 34 * @since 7 35 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 36 * @deprecated since 9 37 * @useinstead @ohos.resourceschedule.usageStatistics 38 */ 39 interface BundleStateInfo { 40 /** 41 * the identifier of BundleStateInfo. 42 */ 43 id: number; 44 /** 45 * the total duration, in milliseconds. 46 */ 47 abilityInFgTotalTime?: number; 48 /** 49 * the last time when the application was accessed, in milliseconds. 50 */ 51 abilityPrevAccessTime?: number; 52 /** 53 * the last time when the application was visible in the foreground, in milliseconds. 54 */ 55 abilityPrevSeenTime?: number; 56 /** 57 * the total duration, in milliseconds. 58 */ 59 abilitySeenTotalTime?: number; 60 /** 61 * the bundle name of the application. 62 */ 63 bundleName?: string; 64 /** 65 * the total duration, in milliseconds. 66 */ 67 fgAbilityAccessTotalTime?: number; 68 /** 69 * the last time when the foreground application was accessed, in milliseconds. 70 */ 71 fgAbilityPrevAccessTime?: number; 72 /** 73 * the time of the first bundle usage record in this {@code BundleActiveInfo} object, 74 * in milliseconds. 75 */ 76 infosBeginTime?: number; 77 /** 78 * the time of the last bundle usage record in this {@code BundleActiveInfo} object, 79 * in milliseconds. 80 */ 81 infosEndTime?: number; 82 83 /** 84 * Merges a specified {@link BundleActiveInfo} object with this {@link BundleActiveInfo} object. 85 * The bundle name of both objects must be the same. 86 * 87 * @since 7 88 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 89 * @param toMerge Indicates the {@link BundleActiveInfo} object to merge. 90 * if the bundle names of the two {@link BundleActiveInfo} objects are different. 91 */ 92 merge(toMerge: BundleStateInfo): void; 93 } 94 95 /** 96 * @since 7 97 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 98 * @deprecated since 9 99 * @useinstead @ohos.resourceschedule.usageStatistics 100 */ 101 interface BundleActiveState { 102 /** 103 * the usage priority group of the application. 104 */ 105 appUsagePriorityGroup?: number; 106 /** 107 * the bundle name. 108 */ 109 bundleName?: string; 110 /** 111 * the shortcut ID. 112 */ 113 indexOfLink?: string; 114 /** 115 * the class name. 116 */ 117 nameOfClass?: string; 118 /** 119 * the time when this state occurred, in milliseconds. 120 */ 121 stateOccurredTime?: number; 122 /** 123 * the state type. 124 */ 125 stateType?: number; 126 } 127 128 /** 129 * Checks whether the application with a specified bundle name is in the idle state. 130 * 131 * @since 7 132 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 133 * @param bundleName Indicates the bundle name of the application to query. 134 * @return Returns {@code true} if the application is idle in a particular period; 135 * returns {@code false} otherwise. The time range of the particular period is defined by the system, 136 * which may be hours or days. 137 * @deprecated since 9 138 * @useinstead @ohos.resourceschedule.usageStatistics 139 */ 140 function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void; 141 function isIdleState(bundleName: string): Promise<boolean>; 142 143 /** 144 * Queries the usage priority group of the calling application. 145 * 146 * <p>The priority defined in a priority group restricts the resource usage of an application, 147 * for example, restricting the running of background tasks. </p> 148 * 149 * @since 7 150 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 151 * @return Returns the usage priority group of the calling application. 152 * @deprecated since 9 153 * @useinstead @ohos.resourceschedule.usageStatistics 154 */ 155 function queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void; 156 function queryAppUsagePriorityGroup(): Promise<number>; 157 158 /** 159 * @since 7 160 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 161 * @deprecated since 9 162 * @useinstead @ohos.resourceschedule.usageStatistics 163 */ 164 interface BundleActiveInfoResponse { 165 [key: string]: BundleStateInfo; 166 } 167 168 /** 169 * Queries usage information about each bundle within a specified period. 170 * 171 * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p> 172 * 173 * @since 7 174 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 175 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 176 * @systemapi Hide this for inner system use. 177 * @param begin Indicates the start time of the query period, in milliseconds. 178 * @param end Indicates the end time of the query period, in milliseconds. 179 * @return Returns the {@link BundleActiveInfoResponse} objects containing the usage information about each bundle. 180 * @deprecated since 9 181 * @useinstead @ohos.resourceschedule.usageStatistics 182 */ 183 function queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<BundleActiveInfoResponse>): void; 184 function queryBundleStateInfos(begin: number, end: number): Promise<BundleActiveInfoResponse>; 185 186 /** 187 * Declares interval type. 188 * 189 * @since 7 190 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 191 * @deprecated since 9 192 * @useinstead @ohos.resourceschedule.usageStatistics 193 */ 194 export enum IntervalType { 195 /** 196 * Indicates the interval type that will determine the optimal interval based on the start and end time. 197 */ 198 BY_OPTIMIZED = 0, 199 200 /** 201 * Indicates the daily interval. 202 */ 203 BY_DAILY = 1, 204 205 /** 206 * Indicates the weekly interval. 207 */ 208 BY_WEEKLY = 2, 209 210 /** 211 * Indicates the monthly interval. 212 */ 213 BY_MONTHLY = 3, 214 215 /** 216 * Indicates the annually interval. 217 */ 218 BY_ANNUALLY = 4 219 } 220 221 /** 222 * Queries usage information about each bundle within a specified period at a specified interval. 223 * 224 * @since 7 225 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 226 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 227 * @systemapi Hide this for inner system use. 228 * @param byInterval Indicates the interval at which the usage statistics are queried. 229 * The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY}, 230 * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}. 231 * @param begin Indicates the start time of the query period, in milliseconds. 232 * @param end Indicates the end time of the query period, in milliseconds. 233 * @return Returns the list of {@link BundleStateInfo} objects containing the usage information about each bundle. 234 * @deprecated since 9 235 * @useinstead @ohos.resourceschedule.usageStatistics 236 */ 237 function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback<Array<BundleStateInfo>>): void; 238 function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise<Array<BundleStateInfo>>; 239 240 /** 241 * Queries state data of all bundles within a specified period identified by the start and end time. 242 * 243 * @since 7 244 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 245 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 246 * @systemapi Hide this for inner system use. 247 * @param begin Indicates the start time of the query period, in milliseconds. 248 * @param end Indicates the end time of the query period, in milliseconds. 249 * @return Returns the list of {@link BundleActiveState} objects containing the state data of all bundles. 250 * @deprecated since 9 251 * @useinstead @ohos.resourceschedule.usageStatistics 252 */ 253 function queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void; 254 function queryBundleActiveStates(begin: number, end: number): Promise<Array<BundleActiveState>>; 255 256 /** 257 * Queries state data of the current bundle within a specified period. 258 * 259 * @since 7 260 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 261 * @param begin Indicates the start time of the query period, in milliseconds. 262 * @param end Indicates the end time of the query period, in milliseconds. 263 * @return Returns the {@link BundleActiveState} object Array containing the state data of the current bundle. 264 * @deprecated since 9 265 * @useinstead @ohos.resourceschedule.usageStatistics 266 */ 267 function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void; 268 function queryCurrentBundleActiveStates(begin: number, end: number): Promise<Array<BundleActiveState>>; 269} 270 271export default bundleState; 272 273