• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.app.ability.quickFixManager (quickFixManager)
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
9## Modules to Import
10
11```ts
12import quickFixManager from '@ohos.app.ability.quickFixManager';
13```
14
15## HapModuleQuickFixInfo
16
17Defines the quick fix information at the HAP file level.
18
19**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
20
21**System API**: This is a system API and cannot be called by third-party applications.
22
23| Name       | Type                | Mandatory| Description                                                        |
24| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
25| moduleName    | string               | Yes  | Name of the HAP file.                              |
26| originHapHash    | string               | Yes  | Hash value of the HAP file.                              |
27| quickFixFilePath    | string               | Yes  | Installation path of the quick fix patch file.                              |
28
29## ApplicationQuickFixInfo
30
31Defines the quick fix information at the application level.
32
33**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
34
35**System API**: This is a system API and cannot be called by third-party applications.
36
37| Name       | Type                | Mandatory| Description                                                        |
38| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
39| bundleName    | string               | Yes  | Bundle name.                      |
40| bundleVersionCode    | number               | Yes  | Internal version number of the application.                              |
41| bundleVersionName    | string               | Yes  | Version number of the application that is shown to users.                              |
42| quickFixVersionCode    | number               | Yes  | Version code of the quick fix patch package.                              |
43| quickFixVersionName    | string               | Yes  | Text description of the version number of the quick fix patch package.                              |
44| hapModuleQuickFixInfo    | Array\<[HapModuleQuickFixInfo](#hapmodulequickfixinfo)>      | Yes  | Quick fix information at the HAP file level.    |
45
46## quickFixManager.applyQuickFix
47
48applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<void>): void;
49
50Applies a quick fix patch. This API uses an asynchronous callback to return the result.
51
52**Required permissions**: ohos.permission.INSTALL_BUNDLE
53
54**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
55
56**System API**: This is a system API and cannot be called by third-party applications.
57
58**Parameters**
59
60| Parameter| Type| Mandatory| Description|
61| -------- | -------- | -------- | -------- |
62| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
63| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
64
65> **NOTE**
66>
67> 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.md#obtaining-the-sandbox-path). The path mapped to the device is **/proc/<*applicationProcessId*>/root/*sandboxPath***.
68
69**Example**
70
71```ts
72  import quickFixManager from '@ohos.app.ability.quickFixManager';
73
74  try {
75    let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
76    quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => {
77      if (error) {
78          console.info( `applyQuickFix failed with error + ${error}`);
79      } else {
80          console.info( 'applyQuickFix success');
81      }
82    });
83  } catch (paramError) {
84    console.log('error: ' + paramError.code + ', ' + paramError.message);
85  }
86```
87
88## quickFixManager.applyQuickFix
89
90applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>;
91
92Applies a quick fix patch. This API uses a promise to return the result.
93
94**Required permissions**: ohos.permission.INSTALL_BUNDLE
95
96**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
97
98**System API**: This is a system API and cannot be called by third-party applications.
99
100**Parameters**
101
102| Parameter| Type| Mandatory| Description|
103| -------- | -------- | -------- | -------- |
104| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
105
106**Return value**
107
108| Type| Description|
109| -------- | -------- |
110| Promise\<void> | Promise used to return the result.|
111
112**Example**
113
114```ts
115  import quickFixManager from '@ohos.app.ability.quickFixManager';
116
117  let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
118  try {
119    quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => {
120      console.info('applyQuickFix success');
121    }).catch((error) => {
122      console.info(`applyQuickFix err: + ${error}`);
123    });
124  } catch (paramError) {
125    console.log('error: ' + paramError.code + ', ' + paramError.message);
126  }
127```
128
129## quickFixManager.getApplicationQuickFixInfo
130
131getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<ApplicationQuickFixInfo>): void;
132
133Obtains the quick fix information of the application. This API uses an asynchronous callback to return the result.
134
135**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
136
137**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
138
139**System API**: This is a system API and cannot be called by third-party applications.
140
141**Parameters**
142
143| Parameter| Type| Mandatory| Description|
144| -------- | -------- | -------- | -------- |
145| bundleName | string | Yes|Bundle name. |
146| callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Yes| Callback used to return the quick fix information.|
147
148**Example**
149
150```ts
151  import quickFixManager from '@ohos.app.ability.quickFixManager';
152
153  try {
154    let bundleName = 'bundleName'
155    quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
156      if (error) {
157        console.info(`getApplicationQuickFixInfo error: + ${error}`);
158      } else {
159        console.info(`getApplicationQuickFixInfo success: + ${data}`);
160      }
161    });
162  } catch (paramError) {
163    console.log('error: ' + paramError.code + ', ' + paramError.message);
164  }
165```
166
167## quickFixManager.getApplicationQuickFixInfo
168
169getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo>;
170
171Obtains the quick fix information of the application. This API uses a promise to return the result.
172
173**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
174
175**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
176
177**System API**: This is a system API and cannot be called by third-party applications.
178
179**Parameters**
180
181| Parameter| Type| Mandatory| Description|
182| -------- | -------- | -------- | -------- |
183| bundleName | string | Yes| Bundle name.|
184
185**Return value**
186
187| Type| Description|
188| -------- | -------- |
189| Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
190
191**Example**
192
193  ```ts
194  import quickFixManager from '@ohos.app.ability.quickFixManager';
195
196  try {
197    let bundleName = 'bundleName';
198    quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => {
199      console.info(`getApplicationQuickFixInfo success: + ${data}`);
200    }).catch((error) => {
201      console.info(`getApplicationQuickFixInfo err: + ${error}`);
202    });
203  } catch (paramError) {
204    console.log('error: ' + paramError.code + ', ' + paramError.message);
205  }
206```
207