• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.app.ability.quickFixManager (quickFixManager) (System API)
2
3The quickFixManager module provides APIs for quick fix. With quick fix, you can fix bugs in your application by applying patches, which is more efficient than by updating the entire application.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> The APIs of this module are system APIs and cannot be called by third-party applications.
9
10## Modules to Import
11
12```ts
13import { quickFixManager } from '@kit.AbilityKit';
14```
15
16## HapModuleQuickFixInfo
17
18Defines the quick fix information at the HAP file level.
19
20**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
21
22**System API**: This is a system API.
23
24| Name       | Type                | Read-only| Optional| Description                                                        |
25| ----------- | -------------------- | ---- | ---- | ------------------------------------------------------------ |
26| moduleName    | string               | Yes|  No  | Name of the HAP file.                              |
27| originHapHash    | string            | Yes|  No  | Hash value of the HAP file.                              |
28| quickFixFilePath    | string         | Yes|  No  | Installation path of the quick fix patch file.                              |
29
30## ApplicationQuickFixInfo
31
32Defines the quick fix information at the application level.
33
34**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
35
36**System API**: This is a system API.
37
38| Name       | Type                | Read-only| Optional| Description                                                        |
39| ----------- | -------------------- | ---- | ---- | ------------------------------------------------------------ |
40| bundleName    | string               | Yes| No  | Bundle name.                      |
41| bundleVersionCode    | number        | Yes| No  | Internal version number of the application.                              |
42| bundleVersionName    | string        | Yes| No  | Version number of the application that is shown to users.                              |
43| quickFixVersionCode    | number      | Yes| No  | Version code of the quick fix patch package.                              |
44| quickFixVersionName    | string      | Yes| No  | Text description of the version number of the quick fix patch package.                              |
45| hapModuleQuickFixInfo    | Array\<[HapModuleQuickFixInfo](#hapmodulequickfixinfo)>   | Yes| No  | Quick fix information at the HAP file level.    |
46
47## quickFixManager.applyQuickFix
48
49applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<void>): void;
50
51Applies a quick fix patch. This API uses an asynchronous callback to return the result.
52
53**Required permissions**: ohos.permission.INSTALL_BUNDLE
54
55**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
56
57**System API**: This is a system API.
58
59**Parameters**
60
61  | Parameter| Type| Mandatory| Description|
62  | -------- | -------- | -------- | -------- |
63  | hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
64  | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the quick fix patch is installed, **err** is **undefined**. Otherwise, **err** is an error object.|
65
66**Error codes**
67
68If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](../apis-basic-services-kit/common_event/commonEventManager-definitions.md#common_event_quick_fix_apply_result).
69
70For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
71
72| ID| Error Message|
73| ------- | -------- |
74| 201      | Permission denied. |
75| 202      | Not system application. |
76| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
77| 18500002 | Invalid patch package. |
78| 18500008 | Internal error. |
79
80> **NOTE**
81>
82> The file path passed in the API must be an application sandbox path. For details about how to obtain the sandbox path, see [Obtaining the Sandbox Path](js-apis-bundle-BundleInstaller-sys.md#obtaining-the-sandbox-path). The path mapped to the device is **/proc/<*applicationProcessId*>/root/*sandboxPath***.
83
84**Example**
85
86```ts
87import { quickFixManager } from '@kit.AbilityKit';
88
89try {
90  let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
91  quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => {
92    if (error) {
93      console.error( `applyQuickFix failed with error: ${error}`);
94    } else {
95      console.info(`applyQuickFix success`);
96    }
97  });
98} catch (paramError) {
99  console.error(`error.code: ${paramError.code}, error.message: ${paramError.message}`);
100}
101```
102
103## quickFixManager.applyQuickFix
104
105applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>;
106
107Applies a quick fix patch. This API uses a promise to return the result.
108
109**Required permissions**: ohos.permission.INSTALL_BUNDLE
110
111**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
112
113**System API**: This is a system API.
114
115**Parameters**
116
117  | Parameter| Type| Mandatory| Description|
118  | -------- | -------- | -------- | -------- |
119  | hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
120
121**Return value**
122
123  | Type| Description|
124  | -------- | -------- |
125  | Promise\<void> | Promise that returns no value.|
126
127**Error codes**
128
129If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](../apis-basic-services-kit/common_event/commonEventManager-definitions.md#common_event_quick_fix_apply_result).
130
131For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
132
133| ID| Error Message|
134| ------- | -------- |
135| 201      | Permission denied. |
136| 202      | Not system application. |
137| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
138| 18500002 | Invalid patch package. |
139| 18500008 | Internal error. |
140
141**Example**
142
143```ts
144import { quickFixManager } from '@kit.AbilityKit';
145import { BusinessError } from '@kit.BasicServicesKit';
146
147let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
148
149try {
150  quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => {
151    console.info(`applyQuickFix success`);
152  }).catch((error: BusinessError) => {
153    console.error(`applyQuickFix err: ${error}`);
154  });
155} catch (paramError) {
156  console.error(`error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`);
157}
158```
159
160## quickFixManager.getApplicationQuickFixInfo
161
162getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<ApplicationQuickFixInfo>): void;
163
164Obtains the quick fix information of the application. This API uses an asynchronous callback to return the result.
165
166**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
167
168**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
169
170**System API**: This is a system API.
171
172**Parameters**
173
174| Parameter| Type| Mandatory| Description|
175| -------- | -------- | -------- | -------- |
176| bundleName | string | Yes|Bundle name. |
177| callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Yes| Callback used to return the quick fix information.|
178
179**Error codes**
180
181For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
182
183| ID| Error Message|
184| ------- | -------- |
185| 201      | Permission denied. |
186| 202      | Not system application. |
187| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
188| 18500001 | The bundle does not exist or no patch has been applied. |
189| 18500008 | Internal error. |
190
191**Example**
192
193```ts
194import { quickFixManager } from '@kit.AbilityKit';
195import { BusinessError } from '@kit.BasicServicesKit';
196
197try {
198  let bundleName = 'bundleName';
199  quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
200    if (error) {
201      console.error(`getApplicationQuickFixInfo error: ${error}`);
202    } else {
203      console.info(`getApplicationQuickFixInfo success: ${data}`);
204    }
205  });
206} catch (paramError) {
207  console.error(`error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`);
208}
209```
210
211## quickFixManager.getApplicationQuickFixInfo
212
213getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo>;
214
215Obtains the quick fix information of the application. This API uses a promise to return the result.
216
217**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
218
219**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
220
221**System API**: This is a system API.
222
223**Parameters**
224
225| Parameter| Type| Mandatory| Description|
226| -------- | -------- | -------- | -------- |
227| bundleName | string | Yes| Bundle name.|
228
229**Return value**
230
231  | Type| Description|
232  | -------- | -------- |
233  | Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
234
235**Error codes**
236
237For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
238
239| ID| Error Message|
240| ------- | -------- |
241| 201      | Permission denied. |
242| 202      | Not system application. |
243| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
244| 18500001 | The bundle does not exist or no patch has been applied. |
245| 18500008 | Internal error. |
246
247**Example**
248
249```ts
250import { quickFixManager } from '@kit.AbilityKit';
251import { BusinessError } from '@kit.BasicServicesKit';
252
253try {
254  let bundleName = 'bundleName';
255  quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => {
256    console.info(`getApplicationQuickFixInfo success: ${data}`);
257  }).catch((error: BusinessError) => {
258    console.error(`getApplicationQuickFixInfo err: ${error}`);
259  });
260} catch (paramError) {
261  console.error(`error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`);
262}
263```
264
265## quickFixManager.revokeQuickFix<sup>10+<sup>
266
267revokeQuickFix(bundleName: string, callback: AsyncCallback\<void>): void;
268
269Revokes quick fix. This API uses an asynchronous callback to return the result.
270
271**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED and ohos.permission.INSTALL_BUNDLE
272
273**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
274
275**System API**: This is a system API.
276
277**Parameters**
278
279  | Parameter| Type| Mandatory| Description|
280  | -------- | -------- | -------- | -------- |
281  | bundleName | string | Yes| Name of the bundle for which the patch needs to be revoked.|
282  | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If quick fix is revoked, **err** is **undefined**. Otherwise, **err** is an error object.|
283
284**Error codes**
285
286For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
287
288| ID| Error Message|
289| ------- | -------- |
290| 201      | Permission denied. |
291| 202      | Not system application. |
292| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
293| 18500001 | The bundle does not exist or no patch has been applied. |
294| 18500009 | The application has an ongoing quick fix task. |
295
296If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_REVOKE_RESULT](../apis-basic-services-kit/common_event/commonEventManager-definitions.md#common_event_quick_fix_revoke_result10).
297
298**Example**
299
300```ts
301import { quickFixManager } from '@kit.AbilityKit';
302
303let bundleName = 'com.example.myapplication';
304
305quickFixManager.revokeQuickFix(bundleName, (err) => {
306  if (err.code) {
307    console.error(`revokeQuickFix ${bundleName} failed, err code: ${err.code}, err msg: ${err.message}.`);
308  }
309});
310```
311
312## quickFixManager.revokeQuickFix<sup>10+<sup>
313
314revokeQuickFix(bundleName: string): Promise\<void>;
315
316Revokes quick fix. This API uses a promise to return the result.
317
318**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED and ohos.permission.INSTALL_BUNDLE
319
320**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
321
322**System API**: This is a system API.
323
324**Parameters**
325
326  | Parameter| Type| Mandatory| Description|
327  | -------- | -------- | -------- | -------- |
328  | bundleName | string | Yes| Name of the bundle for which the patch needs to be revoked.|
329
330**Return value**
331
332  | Type| Description|
333  | -------- | -------- |
334  | Promise\<void> | Promise that returns no value.|
335
336**Error codes**
337
338For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
339
340| ID| Error Message|
341| ------- | -------- |
342| 201      | Permission denied. |
343| 202      | Not system application. |
344| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
345| 18500001 | The bundle does not exist or no patch has been applied. |
346| 18500009 | The application has an ongoing quick fix task. |
347
348If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_REVOKE_RESULT](../apis-basic-services-kit/common_event/commonEventManager-definitions.md#common_event_quick_fix_revoke_result10). The table below lists the possible error codes and messages.
349
350**Example**
351
352```ts
353import { quickFixManager } from '@kit.AbilityKit';
354import { BusinessError } from '@kit.BasicServicesKit';
355
356let bundleName = 'com.example.myapplication';
357
358quickFixManager.revokeQuickFix(bundleName).then(() => {
359  console.info(`revokeQuickFix ${bundleName} success.`);
360}).catch((err: BusinessError) => {
361  console.error(`revokeQuickFix ${bundleName} failed, err code: ${err.code}, err msg: ${err.message}.`);
362});
363```
364