1/* 2 * Copyright (c) 2022-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 16/** 17 * @file 18 * @kit AbilityKit 19 */ 20 21import { AsyncCallback } from './@ohos.base'; 22 23/** 24 * Interface of quickFixManager. 25 * 26 * @namespace quickFixManager 27 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 28 * @systemapi 29 * @since 9 30 */ 31declare namespace quickFixManager { 32 /** 33 * Quick fix info of hap module. 34 * 35 * @typedef HapModuleQuickFixInfo 36 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 37 * @systemapi 38 * @since 9 39 */ 40 export interface HapModuleQuickFixInfo { 41 /** 42 * Indicates hap module name. 43 * 44 * @type { string } 45 * @readonly 46 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 47 * @systemapi 48 * @since 9 49 */ 50 readonly moduleName: string; 51 52 /** 53 * Indicates hash value of a hap. 54 * 55 * @type { string } 56 * @readonly 57 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 58 * @systemapi 59 * @since 9 60 */ 61 readonly originHapHash: string; 62 63 /** 64 * Indicates installed path of quick fix file. 65 * 66 * @type { string } 67 * @readonly 68 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 69 * @systemapi 70 * @since 9 71 */ 72 readonly quickFixFilePath: string; 73 } 74 75 /** 76 * Quick fix info of application. 77 * 78 * @typedef ApplicationQuickFixInfo 79 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 80 * @systemapi 81 * @since 9 82 */ 83 export interface ApplicationQuickFixInfo { 84 /** 85 * Bundle name. 86 * 87 * @type { string } 88 * @readonly 89 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 90 * @systemapi 91 * @since 9 92 */ 93 readonly bundleName: string; 94 95 /** 96 * The version number of the bundle. 97 * 98 * @type { number } 99 * @readonly 100 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 101 * @systemapi 102 * @since 9 103 */ 104 readonly bundleVersionCode: number; 105 106 /** 107 * The version name of the bundle. 108 * 109 * @type { string } 110 * @readonly 111 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 112 * @systemapi 113 * @since 9 114 */ 115 readonly bundleVersionName: string; 116 117 /** 118 * The version number of the quick fix. 119 * 120 * @type { number } 121 * @readonly 122 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 123 * @systemapi 124 * @since 9 125 */ 126 readonly quickFixVersionCode: number; 127 128 /** 129 * The version name of the quick fix. 130 * 131 * @type { string } 132 * @readonly 133 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 134 * @systemapi 135 * @since 9 136 */ 137 readonly quickFixVersionName: string; 138 139 /** 140 * Hap module quick fix info. 141 * 142 * @type { Array<HapModuleQuickFixInfo> } 143 * @readonly 144 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 145 * @systemapi 146 * @since 9 147 */ 148 readonly hapModuleQuickFixInfo: Array<HapModuleQuickFixInfo>; 149 } 150 151 /** 152 * Apply quick fix files. 153 * 154 * @permission ohos.permission.INSTALL_BUNDLE 155 * @param { Array<string> } hapModuleQuickFixFiles - Quick fix files need to apply, this value should include file 156 * path and file name. 157 * @param { AsyncCallback<void> } callback - The callback of applyQuickFix. 158 * @throws { BusinessError } 201 - Permission denied. 159 * @throws { BusinessError } 202 - Not system application. 160 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 161 * 2. Incorrect parameter types. 162 * @throws { BusinessError } 18500002 - Invalid patch package. 163 * @throws { BusinessError } 18500008 - Internal error. 164 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 165 * @systemapi 166 * @since 9 167 */ 168 function applyQuickFix(hapModuleQuickFixFiles: Array<string>, callback: AsyncCallback<void>): void; 169 170 /** 171 * Apply quick fix files. 172 * 173 * @permission ohos.permission.INSTALL_BUNDLE 174 * @param { Array<string> } hapModuleQuickFixFiles - Quick fix files need to apply, this value should include file 175 * path and file name. 176 * @returns { Promise<void> } The promise returned by the function. 177 * @throws { BusinessError } 201 - Permission denied. 178 * @throws { BusinessError } 202 - Not system application. 179 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 180 * 2. Incorrect parameter types. 181 * @throws { BusinessError } 18500002 - Invalid patch package. 182 * @throws { BusinessError } 18500008 - Internal error. 183 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 184 * @systemapi 185 * @since 9 186 */ 187 function applyQuickFix(hapModuleQuickFixFiles: Array<string>): Promise<void>; 188 189 /** 190 * Revoke quick fix by bundle name. 191 * 192 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED and ohos.permission.INSTALL_BUNDLE 193 * @param { string } bundleName - Bundle name wish to revoke quick fix. 194 * @param { AsyncCallback<void> } callback - The callback of revokeQuickFix. 195 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 196 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 197 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 198 * 2. Incorrect parameter types. 199 * @throws { BusinessError } 18500001 - The bundle does not exist or no patch has been applied. 200 * @throws { BusinessError } 18500009 - The application has an ongoing quick fix task. 201 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 202 * @systemapi 203 * @since 10 204 */ 205 function revokeQuickFix(bundleName: string, callback: AsyncCallback<void>): void; 206 207 /** 208 * Revoke quick fix by bundle name. 209 * 210 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED and ohos.permission.INSTALL_BUNDLE 211 * @param { string } bundleName - Bundle name wish to revoke quick fix. 212 * @returns { Promise<void> } 213 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 214 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 215 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 216 * 2. Incorrect parameter types. 217 * @throws { BusinessError } 18500001 - The bundle does not exist or no patch has been applied. 218 * @throws { BusinessError } 18500009 - The application has an ongoing quick fix task. 219 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 220 * @systemapi 221 * @since 10 222 */ 223 function revokeQuickFix(bundleName: string): Promise<void>; 224 225 /** 226 * Get application quick fix info by bundle name. 227 * 228 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 229 * @param { string } bundleName - Bundle name wish to query. 230 * @param { AsyncCallback<ApplicationQuickFixInfo> } callback - The callback is used to return the ApplicationQuickFixInfo. 231 * @throws { BusinessError } 201 - Permission denied. 232 * @throws { BusinessError } 202 - Not system application. 233 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 234 * 2. Incorrect parameter types. 235 * @throws { BusinessError } 18500001 - The bundle does not exist or no patch has been applied. 236 * @throws { BusinessError } 18500008 - Internal error. 237 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 238 * @systemapi 239 * @since 9 240 */ 241 function getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback<ApplicationQuickFixInfo>): void; 242 243 /** 244 * Get application quick fix info by bundle name. 245 * 246 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 247 * @param { string } bundleName - Bundle name wish to query. 248 * @returns { Promise<ApplicationQuickFixInfo> } Returns the ApplicationQuickFixInfo. 249 * @throws { BusinessError } 201 - Permission denied. 250 * @throws { BusinessError } 202 - Not system application. 251 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 252 * 2. Incorrect parameter types. 253 * @throws { BusinessError } 18500001 - The bundle does not exist or no patch has been applied. 254 * @throws { BusinessError } 18500008 - Internal error. 255 * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix 256 * @systemapi 257 * @since 9 258 */ 259 function getApplicationQuickFixInfo(bundleName: string): Promise<ApplicationQuickFixInfo>; 260} 261 262export default quickFixManager; 263