1/* 2 * Copyright (c) 2021 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'; 17import { ApplicationInfo } from './bundle/applicationInfo'; 18import { BundleInfo } from './bundle/bundleInfo'; 19import { AbilityInfo } from './bundle/abilityInfo'; 20import { Want } from './ability/want'; 21import { BundleInstaller } from './bundle/bundleInstaller'; 22import { ElementName } from './bundle/elementName'; 23import { ShortcutInfo } from './bundle/shortcutInfo'; 24import { ModuleUsageRecord } from './bundle/moduleUsageRecord'; 25 26/** 27 * bundle. 28 * @name bundle 29 * @since 7 30 * @sysCap SystemCapability.Appexecfwk 31 * @devices phone, tablet, tv, wearable 32 * @permission NA 33 */ 34declare namespace bundle { 35 36/** 37 * @name BundleFlag 38 * @since 7 39 * @SysCap SystemCapability.Appexecfwk 40 * @import NA 41 * @permission NA 42 * @devices phone, tablet, tv, wearable 43 */ 44 enum BundleFlag { 45 GET_BUNDLE_DEFAULT = 0x00000000, 46 GET_BUNDLE_WITH_ABILITIES = 0x00000001, 47 GET_APPLICATION_INFO_WITH_PERMISSION = 0x00000008, 48 } 49 50/** 51 * @name GrantStatus 52 * @since 7 53 * @SysCap SystemCapability.Appexecfwk 54 * @import NA 55 * @permission NA 56 * @devices phone, tablet, tv, wearable 57 */ 58 export enum GrantStatus { 59 PERMISSION_DENIED = -1, 60 PERMISSION_GRANTED = 0, 61 } 62 63 /** 64 * @name AbilityType 65 * @since 7 66 * @SysCap SystemCapability.Appexecfwk 67 * @import NA 68 * @permission NA 69 * @devices phone, tablet, tv, wearable 70 */ 71 export enum AbilityType { 72 /** 73 * @default Indicates an unknown ability type 74 * @since 7 75 * @SysCap SystemCapability.Appexecfwk 76 */ 77 UNKNOWN, 78 79 /** 80 * @default Indicates that the ability has a UI 81 * @since 7 82 * @SysCap SystemCapability.Appexecfwk 83 */ 84 PAGE, 85 86 /** 87 * @default Indicates that the ability does not have a UI 88 * @since 7 89 * @SysCap SystemCapability.Appexecfwk 90 */ 91 SERVICE, 92 93 /** 94 * @default Indicates that the ability is used to provide data access services 95 * @since 7 96 * @SysCap SystemCapability.Appexecfwk 97 */ 98 DATA, 99 } 100 101 /** 102 * @name AbilitySubType 103 * @since 7 104 * @SysCap SystemCapability.Appexecfwk 105 * @import NA 106 * @permission NA 107 * @devices phone, tablet, tv, wearable 108 */ 109 export enum AbilitySubType { 110 UNSPECIFIED = 0, 111 CA = 1, 112 } 113 114 /** 115 * @name DisplayOrientation 116 * @since 7 117 * @SysCap SystemCapability.Appexecfwk 118 * @import NA 119 * @permission NA 120 * @devices phone, tablet, tv, wearable 121 */ 122 export enum DisplayOrientation { 123 /** 124 * @default Indicates that the system automatically determines the display orientation 125 * @since 7 126 * @SysCap SystemCapability.Appexecfwk 127 */ 128 UNSPECIFIED, 129 130 /** 131 * @default Indicates the landscape orientation 132 * @since 7 133 * @SysCap SystemCapability.Appexecfwk 134 */ 135 LANDSCAPE, 136 137 /** 138 * @default Indicates the portrait orientation 139 * @since 7 140 * @SysCap SystemCapability.Appexecfwk 141 */ 142 PORTRAIT, 143 144 /** 145 * @default Indicates the page ability orientation is the same as that of the nearest ability in the stack 146 * @since 7 147 * @SysCap SystemCapability.Appexecfwk 148 */ 149 FOLLOW_RECENT, 150 } 151 152 /** 153 * @name LaunchMode 154 * @since 7 155 * @SysCap SystemCapability.Appexecfwk 156 * @import NA 157 * @permission NA 158 * @devices phone, tablet, tv, wearable 159 */ 160 export enum LaunchMode { 161 /** 162 * @default Indicates that the ability has only one instance 163 * @since 7 164 * @SysCap SystemCapability.Appexecfwk 165 */ 166 SINGLETON = 0, 167 168 /** 169 * @default Indicates that the ability can have multiple instances 170 * @since 7 171 * @SysCap SystemCapability.Appexecfwk 172 */ 173 STANDARD = 1, 174 } 175 176 /** 177 * @name InstallErrorCode 178 * @since 7 179 * @SysCap SystemCapability.Appexecfwk 180 * @import NA 181 * @permission NA 182 * @devices phone, tablet, tv, wearable 183 */ 184 export enum InstallErrorCode{ 185 SUCCESS = 0, 186 STATUS_INSTALL_FAILURE = 1, 187 STATUS_INSTALL_FAILURE_ABORTED = 2, 188 STATUS_INSTALL_FAILURE_INVALID = 3, 189 STATUS_INSTALL_FAILURE_CONFLICT = 4, 190 STATUS_INSTALL_FAILURE_STORAGE = 5, 191 STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6, 192 STATUS_UNINSTALL_FAILURE = 7, 193 STATUS_UNINSTALL_FAILURE_BLOCKED = 8, 194 STATUS_UNINSTALL_FAILURE_ABORTED = 9, 195 STATUS_UNINSTALL_FAILURE_CONFLICT = 10, 196 STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B, 197 STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C, 198 STATUS_ABILITY_NOT_FOUND = 0x40, 199 STATUS_BMS_SERVICE_ERROR = 0x41 200 } 201 202 /** 203 * Obtains based on a given networkId and bundle name. 204 * 205 * @devices phone, tablet, tv, wearable 206 * @since 7 207 * @SysCap SystemCapability.Appexecfwk 208 * @param networkId Indicates the device networkId in area network. 209 * @param bundleName Indicates the application bundle name to be queried. 210 * @param flags Indicates the flag used to specify information contained in that will be 211 * returned. 212 * @return Returns the BundleInfo object. 213 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO 214 */ 215 function getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback<BundleInfo>): void; 216 function getBundleInfo(bundleName: string, bundleFlags: number): Promise<BundleInfo>; 217 218 /** 219 * Obtains the interface used to install bundles. 220 * 221 * @devices phone, tablet, tv, wearable 222 * @since 7 223 * @SysCap SystemCapability.Appexecfwk 224 * @return Returns the IBundleInstaller interface. 225 * @permission ohos.permission.INSTALL_BUNDLE 226 */ 227 function getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void; 228 function getBundleInstaller(): Promise<BundleInstaller>; 229 230 /** 231 * Obtains based on a given bundle name. 232 * 233 * @devices phone, tablet, tv, wearable 234 * @since 7 235 * @SysCap SystemCapability.Appexecfwk 236 * @param bundleName Indicates the application bundle name to be queried. 237 * @param flags Indicates the flag used to specify information contained in the ApplicationInfo object 238 * that will be returned. 239 * @param userId Indicates the user ID. 240 * @return Returns the ApplicationInfo object. 241 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO 242 */ 243 function getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback<ApplicationInfo>) : void; 244 function getApplicationInfo(bundleName: string, bundleFlags: number, userId: number) : Promise<ApplicationInfo>; 245 246 /** 247 * Checks whether a specified bundle has been granted a specific permission. 248 * 249 * @devices phone, tablet, tv, wearable 250 * @since 7 251 * @SysCap SystemCapability.Appexecfwk 252 * @param bundleName Indicates the name of the bundle to check. 253 * @param permission Indicates the permission to check. 254 * @return Returns 0 if the bundle has the permission; returns -1 otherwise. 255 */ 256 function checkPermission(bundleName: string, permission: string, callback: AsyncCallback<GrantStatus>): void; 257 function checkPermission(bundleName: string, permission: string): Promise<GrantStatus>; 258 259 /** 260 * Query the AbilityInfo by the given Want. 261 * 262 * @devices phone, tablet, tv, wearable 263 * @since 7 264 * @SysCap SystemCapability.Appexecfwk 265 * @param intent Indicates the Intent containing the application bundle name to 266 * be queried. 267 * @param flags Indicates the flag used to specify information contained in the AbilityInfo objects that 268 * will be returned. 269 * @param userId Indicates the user ID. 270 * @return Returns a list of AbilityInfo objects. 271 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO 272 */ 273 function queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback<Array<AbilityInfo>>): void; 274 function queryAbilityByWant(want: Want, bundleFlags: number, userId:number): Promise<Array<AbilityInfo>>; 275 276 /** 277 * Obtains BundleInfo of all bundles available in the system. 278 * 279 * @devices phone, tablet, tv, wearable 280 * @since 7 281 * @SysCap SystemCapability.Appexecfwk 282 * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be 283 * returned. 284 * @return Returns a list of BundleInfo objects. 285 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 286 */ 287 function getAllBundleInfo(bundlelFlag: BundleFlag, callback: AsyncCallback<Array<BundleInfo>>) : void; 288 function getAllBundleInfo(bundlelFlag: BundleFlag) : Promise<Array<BundleInfo>>; 289 290 /** 291 * Obtains information about all installed applications of a specified user. 292 * 293 * @devices phone, tablet, tv, wearable 294 * @since 7 295 * @SysCap SystemCapability.Appexecfwk 296 * @param flags Indicates the flag used to specify information contained in the ApplicationInfo objects 297 * that will be returned. 298 * @param userId Indicates the user ID. 299 * @return Returns a list of ApplicationInfo objects. 300 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 301 */ 302 function getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback<Array<ApplicationInfo>>) : void; 303 function getAllApplicationInfo(bundleFlags: number, userId: number) : Promise<Array<ApplicationInfo>>; 304 305 /** 306 * Obtains information about an application bundle contained in an ohos Ability Package (HAP). 307 * 308 * @devices phone, tablet, tv, wearable 309 * @since 7 310 * @SysCap SystemCapability.Appexecfwk 311 * @param hapFilePath Indicates the path storing the HAP. The path should be the relative path to the data 312 * directory of the current application. 313 * @param flags Indicates the flag used to specify information contained in the BundleInfo object to be 314 * returned. 315 * @return Returns the BundleInfo object. 316 */ 317 function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback<BundleInfo>) : void 318 function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise<BundleInfo>; 319 320 /** 321 * Obtains information about the shortcuts of the application. 322 * 323 * @devices phone, tablet, tv, wearable 324 * @since 7 325 * @SysCap SystemCapability.Appexecfwk 326 * @param bundleName Indicates the bundle name of the application. 327 * @return Returns a list of ShortcutInfo objects containing shortcut information about the application. 328 * @permission ohos.permission.MANAGE_SHORTCUTS 329 */ 330 function getAllShortcutInfo(bundleName: string, callback: AsyncCallback<Array<ShortcutInfo>>): void; 331 function getAllShortcutInfo(bundleName: string): Promise<Array<ShortcutInfo>>; 332 333 /** 334 * get module usage record list in descending order of lastLaunchTime. 335 * 336 * @devices phone, tablet, tv, wearable 337 * @since 7 338 * @SysCap SystemCapability.Appexecfwk 339 * @param maxNum the return size of the records, must be in range of 1 to 1000. 340 * @return Returns ability usage record list. 341 * @systemapi hide this for inner system use 342 */ 343 function getModuleUsageRecords(maxNum: number, callback: AsyncCallback<Array<ModuleUsageRecord>>): void; 344 function getModuleUsageRecords(maxNum: number): Promise<Array<ModuleUsageRecord>>; 345} 346 347export default bundle; 348