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 } from './basic'; 17 18/** 19 * Support install, upgrade, remove and recover bundles on the devices. 20 * @namespace installer 21 * @syscap SystemCapability.BundleManager.BundleFramework.Core 22 * @systemapi 23 * @since 9 24 */ 25declare namespace installer { 26 /** 27 * Obtains the interface used to install bundle. 28 * @param { AsyncCallback } callback - The callback of BundleInstaller object. 29 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 30 * @throws { BusinessError } 401 - Input parameters check failed. 31 * @syscap SystemCapability.BundleManager.BundleFramework.Core 32 * @systemapi 33 * @since 9 34 */ 35 function getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void 36 37 /** 38 * Obtains the interface used to install bundle. 39 * @param { AsyncCallback } callback - The callback of getting a list of BundleInstaller objects. 40 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 41 * @returns { Promise<BundleInstaller> } BundleInstaller object. 42 * @syscap SystemCapability.BundleManager.BundleFramework.Core 43 * @systemapi 44 * @since 9 45 */ 46 function getBundleInstaller(): Promise<BundleInstaller>; 47 48 /** 49 * Bundle installer interface, include install uninstall recover. 50 * @interface BundleInstaller 51 * @syscap SystemCapability.BundleManager.BundleFramework.Core 52 * @systemapi 53 * @since 9 54 */ 55 interface BundleInstaller { 56 /** 57 * Install haps for an application. 58 * @permission ohos.permission.INSTALL_BUNDLE 59 * @param { Array<string> } hapFilePaths - Indicates the path where the hap of the application is stored. 60 * @param { InstallParam } installParam - Indicates other parameters required for the installation. 61 * @param { AsyncCallback } callback - The callback of installing haps result. 62 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 63 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 64 * @throws { BusinessError } 401 - Input parameters check failed. 65 * @throws { BusinessError } 17700004 - The specified user ID is not found. 66 * @throws { BusinessError } 17700010 - Failed to install the HAP because the HAP fails to be parsed. 67 * @throws { BusinessError } 17700011 - Failed to install the HAP because the HAP signature fails to be verified. 68 * @throws { BusinessError } 17700012 - Failed to install the HAP because the HAP path is invalid or the HAP is too large. 69 * @throws { BusinessError } 17700015 - Failed to install the HAPs because they have different configuration information. 70 * @throws { BusinessError } 17700016 - Failed to install the HAP because of insufficient system disk space. 71 * @throws { BusinessError } 17700017 - Failed to install the HAP since the version of the HAP to install is too early. 72 * @throws { BusinessError } 17700018 - Failed to install because the dependent module does not exist. 73 * @syscap SystemCapability.BundleManager.BundleFramework.Core 74 * @systemapi 75 * @since 9 76 */ 77 install(hapFilePaths: Array<string>, installParam: InstallParam, callback: AsyncCallback<void>) : void; 78 install(hapFilePaths: Array<string>, callback: AsyncCallback<void>) : void; 79 80 /** 81 * Install haps for an application. 82 * @permission ohos.permission.INSTALL_BUNDLE 83 * @param { Array<string> } hapFilePaths - Indicates the path where the hap of the application is stored. 84 * @param { InstallParam } installParam - Indicates other parameters required for the installation. 85 * @param { AsyncCallback } callback - The callback of installing haps result. 86 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 87 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 88 * @throws { BusinessError } 401 - Input parameters check failed. 89 * @throws { BusinessError } 17700004 - The specified user ID is not found. 90 * @throws { BusinessError } 17700010 - Failed to install the HAP because the HAP fails to be parsed. 91 * @throws { BusinessError } 17700011 - Failed to install the HAP because the HAP signature fails to be verified. 92 * @throws { BusinessError } 17700012 - Failed to install the HAP because the HAP path is invalid or the HAP is too large. 93 * @throws { BusinessError } 17700015 - Failed to install the HAPs because they have different configuration information. 94 * @throws { BusinessError } 17700016 - Failed to install the HAP because of insufficient system disk space. 95 * @throws { BusinessError } 17700017 - Failed to install the HAP since the version of the HAP to install is too early. 96 * @throws { BusinessError } 17700018 - Failed to install because the dependent module does not exist. 97 * @syscap SystemCapability.BundleManager.BundleFramework.Core 98 * @systemapi 99 * @since 9 100 */ 101 install(hapFilePaths: Array<string>, installParam?: InstallParam) : Promise<void>; 102 103 /** 104 * Uninstall an application. 105 * @permission ohos.permission.INSTALL_BUNDLE 106 * @param { string } bundleName - Indicates the bundle name of the application to be uninstalled. 107 * @param { InstallParam } installParam - Indicates other parameters required for the uninstall. 108 * @param { AsyncCallback } callback - The callback of uninstalling application result. 109 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 110 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 111 * @throws { BusinessError } 401 - Input parameters check failed. 112 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 113 * @throws { BusinessError } 17700004 - The specified user ID is not found. 114 * @throws { BusinessError } 17700020 - The specified bundle is pre-installed bundle which cannot be uninstalled. 115 * @syscap SystemCapability.BundleManager.BundleFramework.Core 116 * @systemapi 117 * @since 9 118 */ 119 uninstall(bundleName: string, installParam: InstallParam, callback : AsyncCallback<void>) : void; 120 uninstall(bundleName: string, callback : AsyncCallback<void>) : void; 121 122 /** 123 * Uninstall an application. 124 * @permission ohos.permission.INSTALL_BUNDLE 125 * @param { string } bundleName - Indicates the bundle name of the application to be uninstalled. 126 * @param { InstallParam } installParam - Indicates other parameters required for the uninstall. 127 * @param { AsyncCallback } callback - The callback of uninstalling application result. 128 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 129 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 130 * @throws { BusinessError } 401 - Input parameters check failed. 131 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 132 * @throws { BusinessError } 17700004 - The specified userId is not existed. 133 * @throws { BusinessError } 17700020 - The specified bundle is pre-installed bundle which cannot be uninstalled. 134 * @syscap SystemCapability.BundleManager.BundleFramework.Core 135 * @systemapi 136 * @since 9 137 */ 138 uninstall(bundleName: string, installParam?: InstallParam) : Promise<void>; 139 140 /** 141 * Recover an application. 142 * @permission ohos.permission.INSTALL_BUNDLE 143 * @param { string } bundleName - Indicates the bundle name of the application to be recovered. 144 * @param { InstallParam } installParam - Indicates other parameters required for the recover. 145 * @param { AsyncCallback } callback - The callback of recovering application result. 146 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 147 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 148 * @throws { BusinessError } 401 - Input parameters check failed. 149 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 150 * @throws { BusinessError } 17700004 - The specified user ID is not found. 151 * @syscap SystemCapability.BundleManager.BundleFramework.Core 152 * @systemapi 153 * @since 9 154 */ 155 recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback<void>): void; 156 recover(bundleName: string, callback: AsyncCallback<void>): void; 157 158 /** 159 * Recover an application. 160 * @permission ohos.permission.INSTALL_BUNDLE 161 * @param { string } bundleName - Indicates the bundle name of the application to be recovered. 162 * @param { InstallParam } installParam - Indicates other parameters required for the recover. 163 * @param { AsyncCallback } callback - The callback of recovering application result. 164 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 165 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 166 * @throws { BusinessError } 401 - Input parameters check failed. 167 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 168 * @throws { BusinessError } 17700004 - The specified user ID is not found. 169 * @syscap SystemCapability.BundleManager.BundleFramework.Core 170 * @systemapi 171 * @since 9 172 */ 173 recover(bundleName: string, installParam?: InstallParam) : Promise<void>; 174 } 175 176 /** 177 * Provides parameters required for hashParam. 178 * @typedef HashParam 179 * @syscap SystemCapability.BundleManager.BundleFramework.Core 180 * @systemapi 181 * @since 9 182 */ 183 export interface HashParam { 184 /** 185 * Indicates the moduleName 186 * @syscap SystemCapability.BundleManager.BundleFramework.Core 187 * @since 9 188 */ 189 moduleName: string; 190 191 /** 192 * Indicates the hash value 193 * @syscap SystemCapability.BundleManager.BundleFramework.Core 194 * @since 9 195 */ 196 hashValue: string; 197 } 198 199 /** 200 * Provides parameters required for installing or uninstalling an application. 201 * @typedef InstallParam 202 * @syscap SystemCapability.BundleManager.BundleFramework.Core 203 * @systemapi 204 * @since 9 205 */ 206 export interface InstallParam { 207 /** 208 * Indicates the user id 209 * @syscap SystemCapability.BundleManager.BundleFramework.Core 210 * @since 9 211 */ 212 userId?: number; 213 214 /** 215 * Indicates the install flag, which 0x00 for normal, 0x10 for freeInstall 216 * @syscap SystemCapability.BundleManager.BundleFramework.Core 217 * @since 9 218 */ 219 installFlag?: number; 220 221 /** 222 * Indicates whether the param has data 223 * @syscap SystemCapability.BundleManager.BundleFramework.Core 224 * @since 9 225 */ 226 isKeepData?: boolean; 227 228 /** 229 * Indicates the hash params 230 * @syscap SystemCapability.BundleManager.BundleFramework.Core 231 * @since 9 232 */ 233 hashParams?: Array<HashParam>; 234 235 /** 236 * Indicates the deadline of the crowdtesting bundle 237 * @syscap SystemCapability.BundleManager.BundleFramework.Core 238 * @since 9 239 */ 240 crowdtestDeadline?: number; 241 } 242} 243 244export default installer;