未验证 提交 e2d6f87a 编写于 作者: O openharmony_ci 提交者: Gitee

!18171 翻译完成:17221+17046+17614+17389 Fix error code of form + 限制拼接路径访问资源

Merge pull request !18171 from wusongqing/TR17221
...@@ -31,7 +31,14 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback ...@@ -31,7 +31,14 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
| Error Code ID| Error Message| | Error Code ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 401 | Incorrect input parameter.| | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
...@@ -41,12 +48,12 @@ import formProvider from '@ohos.app.form.formProvider'; ...@@ -41,12 +48,12 @@ import formProvider from '@ohos.app.form.formProvider';
let formId = '12400633174999288'; let formId = '12400633174999288';
try { try {
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => { formProvider.setFormNextRefreshTime(formId, 5, (error) => {
if (error) { if (error) {
console.error(`callback error, code: ${error.code}, message: ${error.message})`); console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else { return;
console.log(`formProvider setFormNextRefreshTime success`);
} }
console.log(`formProvider setFormNextRefreshTime success`);
}); });
} catch (error) { } catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`); console.error(`catch error, code: ${error.code}, message: ${error.message})`);
...@@ -78,7 +85,14 @@ Sets the next refresh time for a widget. This API uses a promise to return the r ...@@ -78,7 +85,14 @@ Sets the next refresh time for a widget. This API uses a promise to return the r
| Error Code ID| Error Message| | Error Code ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 401 | Incorrect input parameter.| | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
...@@ -118,7 +132,13 @@ Updates a widget. This API uses an asynchronous callback to return the result. ...@@ -118,7 +132,13 @@ Updates a widget. This API uses an asynchronous callback to return the result.
| Error Code ID| Error Message| | Error Code ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 401 | Incorrect input parameter.| | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
...@@ -130,12 +150,12 @@ import formProvider from '@ohos.app.form.formProvider'; ...@@ -130,12 +150,12 @@ import formProvider from '@ohos.app.form.formProvider';
let formId = '12400633174999288'; let formId = '12400633174999288';
try { try {
let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => { formProvider.updateForm(formId, obj, (error) => {
if (error) { if (error) {
console.error(`callback error, code: ${error.code}, message: ${error.message})`); console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else { return;
console.log(`formProvider updateForm success`);
} }
console.log(`formProvider updateForm success`);
}); });
} catch (error) { } catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`); console.error(`catch error, code: ${error.code}, message: ${error.message})`);
...@@ -167,7 +187,13 @@ Updates a widget. This API uses a promise to return the result. ...@@ -167,7 +187,13 @@ Updates a widget. This API uses a promise to return the result.
| Error Code ID| Error Message| | Error Code ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 401 | Incorrect input parameter.| | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
...@@ -204,10 +230,12 @@ Obtains the application's widget information on the device. This API uses an asy ...@@ -204,10 +230,12 @@ Obtains the application's widget information on the device. This API uses an asy
| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.| | callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
**Error codes** **Error codes**
| Error Code ID| Error Message| | Error Code ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 401 | Incorrect input parameter.| | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
...@@ -220,9 +248,9 @@ try { ...@@ -220,9 +248,9 @@ try {
formProvider.getFormsInfo((error, data) => { formProvider.getFormsInfo((error, data) => {
if (error) { if (error) {
console.error(`callback error, code: ${error.code}, message: ${error.message})`); console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else { return;
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
} }
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}); });
} catch (error) { } catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`); console.error(`catch error, code: ${error.code}, message: ${error.message})`);
...@@ -247,7 +275,10 @@ Obtains the application's widget information that meets a filter criterion on th ...@@ -247,7 +275,10 @@ Obtains the application's widget information that meets a filter criterion on th
| Error Code ID| Error Message| | Error Code ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 401 | Incorrect input parameter.| | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
...@@ -264,9 +295,9 @@ try { ...@@ -264,9 +295,9 @@ try {
formProvider.getFormsInfo(filter, (error, data) => { formProvider.getFormsInfo(filter, (error, data) => {
if (error) { if (error) {
console.error(`callback error, code: ${error.code}, message: ${error.message})`); console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else { return;
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
} }
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}); });
} catch (error) { } catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`); console.error(`catch error, code: ${error.code}, message: ${error.message})`);
...@@ -285,7 +316,7 @@ Obtains the application's widget information on the device. This API uses a prom ...@@ -285,7 +316,7 @@ Obtains the application's widget information on the device. This API uses a prom
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | No| Filter criterion.| | filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | No| Filter criterion. By default, no value is passed, indicating that no filtering is performed.|
**Return value** **Return value**
...@@ -297,7 +328,10 @@ Obtains the application's widget information on the device. This API uses a prom ...@@ -297,7 +328,10 @@ Obtains the application's widget information on the device. This API uses a prom
| Error Code ID| Error Message| | Error Code ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 401 | Incorrect input parameter.| | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
...@@ -343,7 +377,11 @@ Requests to publish a widget carrying data to the widget host. This API uses an ...@@ -343,7 +377,11 @@ Requests to publish a widget carrying data to the widget host. This API uses an
| Error Code ID| Error Message| | Error Code ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 401 | Incorrect input parameter.| | 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
...@@ -365,9 +403,9 @@ try { ...@@ -365,9 +403,9 @@ try {
formProvider.requestPublishForm(want, obj, (error, data) => { formProvider.requestPublishForm(want, obj, (error, data) => {
if (error) { if (error) {
console.error(`callback error, code: ${error.code}, message: ${error.message})`); console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else { return;
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
} }
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}); });
} catch (error) { } catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`); console.error(`catch error, code: ${error.code}, message: ${error.message})`);
...@@ -395,7 +433,11 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c ...@@ -395,7 +433,11 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c
| Error Code ID| Error Message| | Error Code ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 401 | Incorrect input parameter.| | 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
...@@ -415,9 +457,9 @@ try { ...@@ -415,9 +457,9 @@ try {
formProvider.requestPublishForm(want, (error, data) => { formProvider.requestPublishForm(want, (error, data) => {
if (error) { if (error) {
console.error(`callback error, code: ${error.code}, message: ${error.message})`); console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else { return;
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
} }
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}); });
} catch (error) { } catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`); console.error(`catch error, code: ${error.code}, message: ${error.message})`);
...@@ -439,7 +481,7 @@ Requests to publish a widget to the widget host. This API uses a promise to retu ...@@ -439,7 +481,7 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' | | want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. | | formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. By default, no value is passed, indicating that no data is provided. |
**Return value** **Return value**
...@@ -451,7 +493,11 @@ Requests to publish a widget to the widget host. This API uses a promise to retu ...@@ -451,7 +493,11 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Error Code ID| Error Message| | Error Code ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 401 | Incorrect input parameter.| | 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
...@@ -494,6 +540,16 @@ Checks whether a widget can be published to the widget host. This API uses an as ...@@ -494,6 +540,16 @@ Checks whether a widget can be published to the widget host. This API uses an as
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the widget can be published to the widget host.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the widget can be published to the widget host.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
```ts ```ts
...@@ -517,9 +573,9 @@ try { ...@@ -517,9 +573,9 @@ try {
formProvider.requestPublishForm(want, (error, data) => { formProvider.requestPublishForm(want, (error, data) => {
if (error) { if (error) {
console.error(`callback error, code: ${error.code}, message: ${error.message})`); console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else { return;
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
} }
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}); });
} catch (error) { } catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`); console.error(`catch error, code: ${error.code}, message: ${error.message})`);
...@@ -548,6 +604,15 @@ Checks whether a widget can be published to the widget host. This API uses a pro ...@@ -548,6 +604,15 @@ Checks whether a widget can be published to the widget host. This API uses a pro
| :------------ | :---------------------------------- | | :------------ | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return whether the widget can be published to the widget host.| | Promise&lt;boolean&gt; | Promise used to return whether the widget can be published to the widget host.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
```ts ```ts
......
...@@ -10,8 +10,7 @@ The **ModuleInfo** module provides module information of an application. ...@@ -10,8 +10,7 @@ The **ModuleInfo** module provides module information of an application.
> This API is deprecated since API version 9. You are advised to use [bundleManager-HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md) instead. > This API is deprecated since API version 9. You are advised to use [bundleManager-HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md) instead.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| --------------- | ------ | ---- | ---- | -------- | | --------------- | ------ | ---- | ---- | -------- |
| moduleName | string | Yes | No | Module name.| | moduleName | string | Yes | No | Module name.|
| moduleSourceDir | string | Yes | No | Installation directory.| | moduleSourceDir | string | Yes | No | Installation directory. Do not access resource files by concatenating paths. Use the [resourceManager API](js-apis-resource-manager.md) instead.|
...@@ -9,6 +9,12 @@ You can use the APIs of this module to start FormExtensionAbilities. ...@@ -9,6 +9,12 @@ You can use the APIs of this module to start FormExtensionAbilities.
> 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. > 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.
> The APIs of this module can be used only in the stage model. > The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
## Usage ## Usage
Before using the **ServiceExtensionContext** module, you must first obtain a **FormExtensionAbility** instance. Before using the **ServiceExtensionContext** module, you must first obtain a **FormExtensionAbility** instance.
...@@ -41,6 +47,18 @@ Starts an ability. This API uses an asynchronous callback to return the result. ...@@ -41,6 +47,18 @@ Starts an ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.Form **System capability**: SystemCapability.Ability.Form
**Error codes**
| ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16500101 | The application is not a system application. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
...@@ -65,7 +83,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility { ...@@ -65,7 +83,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
'message': message 'message': message
} }
}; };
this.context.startAbility(want, (error, data) => { this.context.startAbility(want, (error) => {
if (error) { if (error) {
console.error('FormExtensionContext startAbility, error:${JSON.stringify(error)}'); console.error('FormExtensionContext startAbility, error:${JSON.stringify(error)}');
} else { } else {
...@@ -98,6 +116,18 @@ Starts an ability. This API uses a promise to return the result. ...@@ -98,6 +116,18 @@ Starts an ability. This API uses a promise to return the result.
| ------------ | ---------------------------------- | | ------------ | ---------------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
| ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16500101 | The application is not a system application. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example** **Example**
```ts ```ts
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册