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 16/** 17 * @file 18 * @kit AbilityKit 19 */ 20 21import { AsyncCallback } from './@ohos.base'; 22import { LauncherAbilityInfo as _LauncherAbilityInfo } from './bundleManager/LauncherAbilityInfo'; 23import { ShortcutInfo as _ShortcutInfo, ShortcutWant as _ShortcutWant } from './bundleManager/ShortcutInfo'; 24 25/** 26 * Launcher bundle manager. 27 * 28 * @namespace launcherBundleManager 29 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 30 * @systemapi 31 * @since 9 32 */ 33declare namespace launcherBundleManager { 34 /** 35 * Obtains launcher abilities info based on a given bundleName and userId. 36 * 37 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 38 * @param { string } bundleName - Indicates the application bundle name to be queried. 39 * @param { number } userId - Indicates the id for the user. 40 * @param { AsyncCallback<Array<LauncherAbilityInfo>> } callback -The callback of the LauncherAbilityInfo object result. 41 * @throws { BusinessError } 201 - Verify permission denied. 42 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 43 * @throws { BusinessError } 401 - The parameter check failed. 44 * @throws { BusinessError } 801 - Capability not support. 45 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 46 * @throws { BusinessError } 17700004 - The specified user ID is not found. 47 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 48 * @systemapi 49 * @since 9 50 */ 51 function getLauncherAbilityInfo(bundleName: string, 52 userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>): void; 53 54 /** 55 * Obtains launcher abilities info based on a given bundleName and userId. 56 * 57 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 58 * @param { string } bundleName - Indicates the application bundle name to be queried. 59 * @param { number } userId - Indicates the id for the user. 60 * @returns { Promise<Array<LauncherAbilityInfo>> } the LauncherAbilityInfo object. 61 * @throws { BusinessError } 201 - Verify permission denied. 62 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 63 * @throws { BusinessError } 401 - The parameter check failed. 64 * @throws { BusinessError } 801 - Capability not support. 65 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 66 * @throws { BusinessError } 17700004 - The specified user ID is not found. 67 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 68 * @systemapi 69 * @since 9 70 */ 71 function getLauncherAbilityInfo(bundleName: string, userId: number): Promise<Array<LauncherAbilityInfo>>; 72 73 /** 74 * Obtains launcher abilities info based on a given bundleName and userId. 75 * 76 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 77 * @param { string } bundleName - Indicates the application bundle name to be queried. 78 * @param { number } userId - Indicates the id for the user. 79 * @returns { Array<LauncherAbilityInfo> } the LauncherAbilityInfo object. 80 * @throws { BusinessError } 201 - Verify permission denied. 81 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 82 * @throws { BusinessError } 401 - The parameter check failed. 83 * @throws { BusinessError } 801 - Capability not support. 84 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 85 * @throws { BusinessError } 17700004 - The specified user ID is not found. 86 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 87 * @systemapi 88 * @since 10 89 */ 90 function getLauncherAbilityInfoSync(bundleName: string, userId: number): Array<LauncherAbilityInfo>; 91 92 /** 93 * Obtains launcher abilities info based on a given userId. 94 * 95 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 96 * @param { number } userId - Indicates the id for the user. 97 * @param { AsyncCallback<Array<LauncherAbilityInfo>> } callback -The callback of the LauncherAbilityInfo object result. 98 * @throws { BusinessError } 201 - Verify permission denied. 99 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 100 * @throws { BusinessError } 401 - The parameter check failed. 101 * @throws { BusinessError } 801 - Capability not support. 102 * @throws { BusinessError } 17700004 - The specified user ID is not found. 103 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 104 * @systemapi 105 * @since 9 106 */ 107 function getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>): void; 108 109 /** 110 * Obtains launcher abilities info based on a given userId. 111 * 112 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 113 * @param { number } userId - Indicates the id for the user. 114 * @returns { Promise<Array<LauncherAbilityInfo>> } the LauncherAbilityInfo object. 115 * @throws { BusinessError } 201 - Verify permission denied. 116 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 117 * @throws { BusinessError } 401 - The parameter check failed. 118 * @throws { BusinessError } 801 - Capability not support. 119 * @throws { BusinessError } 17700004 - The specified user ID is not found. 120 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 121 * @systemapi 122 * @since 9 123 */ 124 function getAllLauncherAbilityInfo(userId: number): Promise<Array<LauncherAbilityInfo>>; 125 126 /** 127 * Obtains shortcut info based on a given bundleName. 128 * 129 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 130 * @param { string } bundleName - Indicates the application bundle name to be queried. 131 * @param { AsyncCallback<Array<ShortcutInfo>> } callback -The callback of the ShortcutInfo object result. 132 * @throws { BusinessError } 201 - Verify permission denied. 133 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 134 * @throws { BusinessError } 401 - The parameter check failed. 135 * @throws { BusinessError } 801 - Capability not support. 136 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 137 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 138 * @systemapi 139 * @since 9 140 */ 141 function getShortcutInfo(bundleName: string, callback: AsyncCallback<Array<ShortcutInfo>>): void; 142 143 /** 144 * Obtains shortcut info based on a given bundleName. 145 * 146 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 147 * @param { string } bundleName - Indicates the application bundle name to be queried. 148 * @returns { Promise<Array<ShortcutInfo>> } the LauncherShortcutInfo object. 149 * @throws { BusinessError } 201 - Verify permission denied. 150 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 151 * @throws { BusinessError } 401 - The parameter check failed. 152 * @throws { BusinessError } 801 - Capability not support. 153 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 154 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 155 * @systemapi 156 * @since 9 157 */ 158 function getShortcutInfo(bundleName: string): Promise<Array<ShortcutInfo>>; 159 160 /** 161 * Obtains shortcut info based on a given bundleName. 162 * 163 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 164 * @param { string } bundleName - Indicates the application bundle name to be queried. 165 * @returns { Array<ShortcutInfo> } the LauncherShortcutInfo object. 166 * @throws { BusinessError } 201 - Verify permission denied. 167 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 168 * @throws { BusinessError } 401 - The parameter check failed. 169 * @throws { BusinessError } 801 - Capability not support. 170 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 171 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 172 * @systemapi 173 * @since 10 174 */ 175 function getShortcutInfoSync(bundleName: string): Array<ShortcutInfo>; 176 177 /** 178 * Contains basic launcher Ability information, which uniquely identifies an LauncherAbilityInfo. 179 * 180 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 181 * @systemapi 182 * @since 9 183 */ 184 export type LauncherAbilityInfo = _LauncherAbilityInfo; 185 186 /** 187 * Provides information about a shortcut, including the shortcut ID and label. 188 * 189 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 190 * @systemapi 191 * @since 9 192 */ 193 export type ShortcutInfo = _ShortcutInfo; 194 /** 195 * Obtains information about the ability that a shortcut will start. 196 * 197 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 198 * @systemapi 199 * @since 9 200 */ 201 export type ShortcutWant = _ShortcutWant; 202} 203 204export default launcherBundleManager; 205