“8d1045584a3c7ec27138453635d741dd63b9212c”上不存在“...api-diff/v3.1-Release/js-apidiff-v3.1-release.md”
提交 f823b996 编写于 作者: zyjhandsome's avatar zyjhandsome

Merge branch 'master' of https://gitee.com/openharmony/docs

...@@ -275,6 +275,8 @@ zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md @little ...@@ -275,6 +275,8 @@ zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md @little
zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-Want.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-application-Want.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/application-models/windowextensionability.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-arraylist.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-arraylist.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-audio.md @liuyuehua1 @zengyawen @magekkkk @currydavids zh-cn/application-dev/reference/apis/js-apis-audio.md @liuyuehua1 @zengyawen @magekkkk @currydavids
...@@ -476,6 +478,7 @@ zh-cn/application-dev/reference/apis/js-apis-wifiext.md @cheng_guohong @RayShih ...@@ -476,6 +478,7 @@ zh-cn/application-dev/reference/apis/js-apis-wifiext.md @cheng_guohong @RayShih
zh-cn/application-dev/reference/apis/js-apis-window.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-window.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-worker.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-worker.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-taskpool.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001 zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001 zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-xml.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-xml.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
......
...@@ -2,124 +2,124 @@ ...@@ -2,124 +2,124 @@
## Introduction ## Introduction
Node-API provides APIs to encapsulate JavaScript capabilities as a native plug-in. It is independent of the underlying JavaScript and is maintained as part of Node.js. Node-API (NAPI) provides APIs to encapsulate JavaScript capabilities as a native plug-in. It is independent of the underlying JavaScript and is maintained as part of Node.js.
## Supported Capabilities ## Supported Capabilities
Node-API eliminates the differences between underlying JavaScript engines and provides a set of stable interfaces. NAPI eliminates the differences between underlying JavaScript engines and provides a set of stable interfaces.
The OpenHarmony Native API (NAPI) component optimizes the Node-API interface implementation and provides connection to underlying engines such as ArkJS. Currently, some APIs in the [Node-API](https://nodejs.org/docs/v14.9.0/api/n-api.html) standard library are supported. The OpenHarmony Native API component optimizes the NAPI interface implementation and provides connection to underlying engines such as ArkJS. Currently, some APIs in the [Node-API](https://nodejs.org/docs/v14.9.0/api/n-api.html) standard library are supported.
## Extended Symbols of NAPI ## Symbols Extended by the OpenHarmony API Component
|Type|Symbol|Remarks| |Type|Symbol|Description|
| --- | --- | --- | | --- | --- | --- |
|FUNC|napi_run_script_path|Runs a JavaScript file.| |FUNC|napi_run_script_path|Runs a JavaScript file.|
**Symbols Exported from the Standard Library** ** Symbols Exported from the NAPI Library**
|Type|Symbol|Remarks| |Type|Symbol|Description|
| --- | --- | --- | | --- | --- | --- |
|FUNC|napi_module_register|| |FUNC|napi_module_register|Registers the NAPI native module.|
|FUNC|napi_get_last_error_info|| |FUNC|napi_get_last_error_info|Obtains the **napi_extended_error_info** structure, which contains the latest error information.|
|FUNC|napi_throw|| |FUNC|napi_throw|Throws a JavaScript value.|
|FUNC|napi_throw_error|| |FUNC|napi_throw_error|Throws a JavaScript **Error** with text information.|
|FUNC|napi_throw_type_error|| |FUNC|napi_throw_type_error|Throws a JavaScript **TypeError** with text information.|
|FUNC|napi_throw_range_error|| |FUNC|napi_throw_range_error|Throws a JavaScript **RangeError** with text information.|
|FUNC|napi_is_error|| |FUNC|napi_is_error|Checks whether **napi_value** indicates an error object.|
|FUNC|napi_create_error|| |FUNC|napi_create_error|Creates and obtains a JavaScript **Error** with text information.|
|FUNC|napi_create_type_error|| |FUNC|napi_create_type_error|Creates and obtains a JavaScript **TypeError** with text information.|
|FUNC|napi_create_range_error|| |FUNC|napi_create_range_error|Creates and obtains a JavaScript **RangeError** with text information.|
|FUNC|napi_get_and_clear_last_exception|| |FUNC|napi_get_and_clear_last_exception|Obtains and clears the latest exception.|
|FUNC|napi_is_exception_pending|| |FUNC|napi_is_exception_pending|Checks whether an exception occurs.|
|FUNC|napi_fatal_error|| |FUNC|napi_fatal_error|Raises a fatal error to terminate the process immediately.|
|FUNC|napi_open_handle_scope|| |FUNC|napi_open_handle_scope|Creates a context environment.|
|FUNC|napi_close_handle_scope|| |FUNC|napi_close_handle_scope|Closes the context environment. After the context environment is closed, all references declared in it are closed.|
|FUNC|napi_open_escapable_handle_scope|| |FUNC|napi_open_escapable_handle_scope|Creates an escapable handle scope from which the declared values can be returned to the parent scope.|
|FUNC|napi_close_escapable_handle_scope|| |FUNC|napi_close_escapable_handle_scope|Closes the escapable handle scope passed in.|
|FUNC|napi_escape_handle|| |FUNC|napi_escape_handle|Promotes the handle to the input JavaScript object so that it is valid for the lifespan of its parent scope.|
|FUNC|napi_create_reference|| |FUNC|napi_create_reference|Creates a reference for an **Object** to extend its lifespan. The caller needs to manage the reference lifespan.|
|FUNC|napi_delete_reference|| |FUNC|napi_delete_reference|Deletes the reference passed in.|
|FUNC|napi_reference_ref|| |FUNC|napi_reference_ref|Increments the reference count for the reference passed in and returns the count.|
|FUNC|napi_reference_unref|| |FUNC|napi_reference_unref|Decrements the reference count for the reference passed in and returns the count.|
|FUNC|napi_get_reference_value|| |FUNC|napi_get_reference_value|Obtains the JavaScript **Object** associated with the reference.|
|FUNC|napi_create_array|| |FUNC|napi_create_array|Creates and obtains a JavaScript **Array**.|
|FUNC|napi_create_array_with_length|| |FUNC|napi_create_array_with_length|Creates and obtains a JavaScript **Array** of the specified length.|
|FUNC|napi_create_arraybuffer|| |FUNC|napi_create_arraybuffer|Creates and obtains a JavaScript **ArrayBuffer** of the specified size.|
|FUNC|napi_create_external|| |FUNC|napi_create_external|Allocates a JavaScript value with external data.|
|FUNC|napi_create_external_arraybuffer|| |FUNC|napi_create_external_arraybuffer|Allocates a JavaScript **ArrayBuffer** with external data.|
|FUNC|napi_create_object|| |FUNC|napi_create_object|Creates a default JavaScript **Object**.|
|FUNC|napi_create_symbol|| |FUNC|napi_create_symbol|Create a JavaScript **Symbol**.|
|FUNC|napi_create_typedarray|| |FUNC|napi_create_typedarray|Creates a JavaScript **TypeArray** from an existing **ArrayBuffer**.|
|FUNC|napi_create_dataview|| |FUNC|napi_create_dataview|Creates a JavaScript **DataView** from an existing **ArrayBuffer**.|
|FUNC|napi_create_int32|| |FUNC|napi_create_int32|Creates a JavaScript **Number** from C **int32_t** data.|
|FUNC|napi_create_uint32|| |FUNC|napi_create_uint32|Creates a JavaScript **Number** from C **uint32_t** data.|
|FUNC|napi_create_int64|| |FUNC|napi_create_int64|Creates a JavaScript **Number** from C **int64_t** data.|
|FUNC|napi_create_double|| |FUNC|napi_create_double|Creates a JavaScript **Number** from C **double** data.|
|FUNC|napi_create_string_latin1|| |FUNC|napi_create_string_latin1|Creates a JavaScript **String** from an ISO-8859-1-encoded C string.|
|FUNC|napi_create_string_utf8|| |FUNC|napi_create_string_utf8|Creates a JavaScript **String** from a UTF8-encoded C string.|
|FUNC|napi_get_array_length|| |FUNC|napi_get_array_length|Obtains the length of an array.|
|FUNC|napi_get_arraybuffer_info|| |FUNC|napi_get_arraybuffer_info|Obtains the underlying data buffer of the **ArrayBuffer** and its length.|
|FUNC|napi_get_prototype|| |FUNC|napi_get_prototype|Obtains the prototype of the specified JavaScript **Object**.|
|FUNC|napi_get_typedarray_info|| |FUNC|napi_get_typedarray_info|Obtains properties of the specified **TypedArray**.|
|FUNC|napi_get_dataview_info|| |FUNC|napi_get_dataview_info|Obtains properties of the specified **DataView**.|
|FUNC|napi_get_value_bool|| |FUNC|napi_get_value_bool|Obtains the C Boolean equivalent of the given JavaScript **Boolean**.|
|FUNC|napi_get_value_double|| |FUNC|napi_get_value_double|Obtains the C double equivalent of the given JavaScript **Number**.|
|FUNC|napi_get_value_external|| |FUNC|napi_get_value_external|Obtains the external data pointer previously passed through **napi_create_external()**.|
|FUNC|napi_get_value_int32|| |FUNC|napi_get_value_int32|Obtains the C int32 equivalent of the given JavaScript **Number**.|
|FUNC|napi_get_value_int64|| |FUNC|napi_get_value_int64|Obtains the C int64 equivalent of the given JavaScript **Number**.|
|FUNC|napi_get_value_string_latin1|| |FUNC|napi_get_value_string_latin1|Obtains the ISO-8859-1-encoded string corresponding to the given JavaScript value.|
|FUNC|napi_get_value_string_utf8|| |FUNC|napi_get_value_string_utf8|Obtains the UTF8-encoded string corresponding to the given JavaScript value.|
|FUNC|napi_get_value_uint32|| |FUNC|napi_get_value_uint32|Obtains the C uint32 equivalent of the given JavaScript **Number**.|
|FUNC|napi_get_boolean|| |FUNC|napi_get_boolean|Obtains the JavaScript Boolean object based on the given C Boolean value.|
|FUNC|napi_get_global|| |FUNC|napi_get_global|Obtains the **global** object.|
|FUNC|napi_get_null|| |FUNC|napi_get_null|Obtains the **null** object.|
|FUNC|napi_get_undefined|| |FUNC|napi_get_undefined|Obtains the **undefined** object.|
|FUNC|napi_coerce_to_bool|| |FUNC|napi_coerce_to_bool|Forcibly converts the given JavaScript value to a JavaScript Boolean value.|
|FUNC|napi_coerce_to_number|| |FUNC|napi_coerce_to_number|Forcibly converts the given JavaScript value to a JavaScript number.|
|FUNC|napi_coerce_to_object|| |FUNC|napi_coerce_to_object|Forcibly converts the given JavaScript value to a JavaScript object.|
|FUNC|napi_coerce_to_string|| |FUNC|napi_coerce_to_string|Forcibly converts the given JavaScript value to a JavaScript string.|
|FUNC|napi_typeof|| |FUNC|napi_typeof|Obtains the JavaScript type of the given JavaScript value.|
|FUNC|napi_instanceof|| |FUNC|napi_instanceof|Checks whether the given object is an instance of the specified constructor.|
|FUNC|napi_is_array|| |FUNC|napi_is_array|Checks whether the given JavaScript value is an array.|
|FUNC|napi_is_arraybuffer|| |FUNC|napi_is_arraybuffer|Checks whether the given JavaScript value is a `ArrayBuffer`.|
|FUNC|napi_is_typedarray|| |FUNC|napi_is_typedarray|Checks whether the given JavaScript value is a **TypedArray**.|
|FUNC|napi_is_dataview|| |FUNC|napi_is_dataview|Checks whether the given JavaScript value is a **DataView**.|
|FUNC|napi_is_date|| |FUNC|napi_is_date|Checks whether the given JavaScript value is a JavaScript **Date** object.|
|FUNC|napi_strict_equals|| |FUNC|napi_strict_equals|Checks whether two JavaScript values are strictly equal.|
|FUNC|napi_get_property_names|| |FUNC|napi_get_property_names|Obtains the names of the enumerable properties of **Object** in an array of strings.|
|FUNC|napi_set_property|| |FUNC|napi_set_property|Sets a property for the given **Object**.|
|FUNC|napi_get_property|| |FUNC|napi_get_property|Obtains the requested property of the given **Object**.|
|FUNC|napi_has_property|| |FUNC|napi_has_property|Checks whether the given **Object** has the specified property.|
|FUNC|napi_delete_property|| |FUNC|napi_delete_property|Deletes the **key** property from the given **Object**.|
|FUNC|napi_has_own_property|| |FUNC|napi_has_own_property|Checks whether the given **Object** has the own property named **key**.|
|FUNC|napi_set_named_property|| |FUNC|napi_set_named_property|Sets a property with the specified name for the given **Object**.|
|FUNC|napi_get_named_property|| |FUNC|napi_get_named_property|Obtains the property with the specified name in the given **Object**.|
|FUNC|napi_has_named_property|| |FUNC|napi_has_named_property|Checks whether the given **Object** has the property with the specified name.|
|FUNC|napi_set_element|| |FUNC|napi_set_element|Sets an element at the specified index of the given **Object**.|
|FUNC|napi_get_element|| |FUNC|napi_get_element|Obtains the element at the specified index of the given **Object**.|
|FUNC|napi_has_element|| |FUNC|napi_has_element|Obtains the element if the given **Object** has an element at the specified index.|
|FUNC|napi_delete_element|| |FUNC|napi_delete_element|Deletes the element at the specified index of the given **Object**.|
|FUNC|napi_define_properties|| |FUNC|napi_define_properties|Defines multiple properties for the given **Object**.|
|FUNC|napi_call_function|| |FUNC|napi_call_function|Calls a JavaScript function in a native method, that is, native call JavaScript.|
|FUNC|napi_create_function|| |FUNC|napi_create_function|Creates a native method for JavaScript to call.|
|FUNC|napi_get_cb_info|| |FUNC|napi_get_cb_info|Obtains detailed information about the call, such as the parameters and **this** pointer, from the given callback info.|
|FUNC|napi_get_new_target|| |FUNC|napi_get_new_target|Obtains the **new.target** of the constructor call.|
|FUNC|napi_new_instance|| |FUNC|napi_new_instance|Creates an instance based on the given constructor.|
|FUNC|napi_define_class|| |FUNC|napi_define_class|Defines a JavaScript class corresponding to the C++ class.|
|FUNC|napi_wrap|| |FUNC|napi_wrap|Wraps a native instance in a JavaScript object.|
|FUNC|napi_unwrap|| |FUNC|napi_unwrap|Obtains the native instance that was previously wrapped in a JavaScript object.|
|FUNC|napi_remove_wrap|| |FUNC|napi_remove_wrap|Obtains the native instance that was previously wrapped in a JavaScript object and removes the wrapping.|
|FUNC|napi_create_async_work|| |FUNC|napi_create_async_work|Creates a work object that executes logic asynchronously.|
|FUNC|napi_delete_async_work|| |FUNC|napi_delete_async_work|Releases an asynchronous work object.|
|FUNC|napi_queue_async_work|| |FUNC|napi_queue_async_work|Adds an asynchronous work object to the queue so that it can be scheduled for execution.|
|FUNC|napi_cancel_async_work|| |FUNC|napi_cancel_async_work|Cancels the queued asynchronous work if it has not been started.|
|FUNC|napi_get_node_version|| |FUNC|napi_get_node_version|Obtains the current Node-API version.|
|FUNC|napi_get_version|| |FUNC|napi_get_version|Obtains the latest Node-API version supported when the Node.js runtime.|
|FUNC|napi_create_promise|| |FUNC|napi_create_promise|Creates a deferred object and a JavaScript promise.|
|FUNC|napi_resolve_deferred|| |FUNC|napi_resolve_deferred|Resolves a deferred object that is associated with a JavaScript promise.|
|FUNC|napi_reject_deferred|| |FUNC|napi_reject_deferred|Rejects a deferred object that is associated with a JavaScript promise.|
|FUNC|napi_is_promise|| |FUNC|napi_is_promise|Checks whether the given JavaScript value is a promise object.|
|FUNC|napi_run_script|| |FUNC|napi_run_script|Executes a string of JavaScript code.|
|FUNC|napi_get_uv_event_loop|| |FUNC|napi_get_uv_event_loop|Obtains the current libuv loop instance.|
\ No newline at end of file
...@@ -79,8 +79,8 @@ function getRdbStoreV9(context: Context, config: StoreConfigV9, version: number) ...@@ -79,8 +79,8 @@ function getRdbStoreV9(context: Context, config: StoreConfigV9, version: number)
``` ```
The APIs are migrated from **@ohos.data.rdb.d.ts** to **@ohos.data.relationalStore.d.ts**. The APIs are migrated from **@ohos.data.rdb.d.ts** to **@ohos.data.relationalStore.d.ts**.
``` ```
function getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void; function getRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback<RdbStore>): void;
function getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore>; function getRdbStore(context: Context, config: StoreConfig): Promise<RdbStore>;
``` ```
**Adaptation Guide** **Adaptation Guide**
......
# User IAM Subsystem ChangeLog
## cl.useriam.1 API9 Authentication Result Code Class Name Change
The name of the authentication result code class of user IAM API version 9 is changed from **ResultCode** to **UserAuthResultCode**.
**Change Impacts**
Applications developed based on earlier versions are not affected. For the applications developed from this version, the class name of the error code needs to be adapted. Otherwise, the service logic is affected.
**Key API/Component Changes**
N/A
**Adaptation Guide**
Change the class name for invoking the authentication result code from **ResultCode** to **UserAuthResultCode**.
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
- [DataShareExtensionAbility(仅对系统应用开放)](datashareextensionability.md) - [DataShareExtensionAbility(仅对系统应用开放)](datashareextensionability.md)
- [FormExtensionAbility(服务卡片)](widget-development-stage.md) - [FormExtensionAbility(服务卡片)](widget-development-stage.md)
- [StaticSubscriberExtensionAbility](static-subscriber-extension-ability.md) - [StaticSubscriberExtensionAbility](static-subscriber-extension-ability.md)
- [WindowExtensionAbility](windowextensionability.md)
- [AbilityStage组件容器](abilitystage.md) - [AbilityStage组件容器](abilitystage.md)
- [应用上下文Context](application-context-stage.md) - [应用上下文Context](application-context-stage.md)
- 信息传递载体Want - 信息传递载体Want
......
...@@ -72,7 +72,7 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ...@@ -72,7 +72,7 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以
} }
await audioCapturer.start(); await audioCapturer.start();
let state = audioCapturer.state; state = audioCapturer.state;
if (state == audio.AudioState.STATE_RUNNING) { if (state == audio.AudioState.STATE_RUNNING) {
console.info('AudioRecLog: Capturer started'); console.info('AudioRecLog: Capturer started');
} else { } else {
...@@ -112,6 +112,7 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ...@@ -112,6 +112,7 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以
let numBuffersToCapture = 150; // 循环写入150次 let numBuffersToCapture = 150; // 循环写入150次
while (numBuffersToCapture) { while (numBuffersToCapture) {
let bufferSize = await audioCapturer.getBuffersize();
let buffer = await audioCapturer.read(bufferSize, true); let buffer = await audioCapturer.read(bufferSize, true);
if (typeof(buffer) == undefined) { if (typeof(buffer) == undefined) {
console.info('AudioRecLog: read buffer failed'); console.info('AudioRecLog: read buffer failed');
......
...@@ -20,15 +20,9 @@ ...@@ -20,15 +20,9 @@
- [@ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)](js-apis-application-staticSubscriberExtensionAbility.md) - [@ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)](js-apis-application-staticSubscriberExtensionAbility.md)
- Stage模型能力的接口(待停用) - Stage模型能力的接口(待停用)
- [@ohos.application.Ability (Ability)](js-apis-application-ability.md) - [@ohos.application.Ability (Ability)](js-apis-application-ability.md)
- [@ohos.application.AbilityConstant (AbilityConstant)](js-apis-application-abilityConstant.md)
- [@ohos.application.AbilityLifecycleCallback (AbilityLifecycleCallback)](js-apis-application-abilityLifecycleCallback.md) - [@ohos.application.AbilityLifecycleCallback (AbilityLifecycleCallback)](js-apis-application-abilityLifecycleCallback.md)
- [@ohos.application.AbilityStage (AbilityStage)](js-apis-application-abilityStage.md)
- [@ohos.application.context (Context)](js-apis-application-context.md)
- [@ohos.application.EnvironmentCallback (EnvironmentCallback)](js-apis-application-environmentCallback.md) - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](js-apis-application-environmentCallback.md)
- [@ohos.application.ExtensionAbility (ExtensionAbility)](js-apis-application-extensionAbility.md)
- [@ohos.application.FormExtension (FormExtension)](js-apis-application-formExtension.md) - [@ohos.application.FormExtension (FormExtension)](js-apis-application-formExtension.md)
- [@ohos.application.ServiceExtensionAbility (ServiceExtensionAbility)](js-apis-application-serviceExtensionAbility.md)
- [@ohos.application.StartOptions (StartOptions)](js-apis-application-startOptions.md)
- FA模型能力的接口 - FA模型能力的接口
- [@ohos.ability.ability (Ability)](js-apis-ability-ability.md) - [@ohos.ability.ability (Ability)](js-apis-ability-ability.md)
- [@ohos.ability.featureAbility (FeatureAbility模块)](js-apis-ability-featureAbility.md) - [@ohos.ability.featureAbility (FeatureAbility模块)](js-apis-ability-featureAbility.md)
...@@ -341,6 +335,7 @@ ...@@ -341,6 +335,7 @@
- [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.enterprise.adminManager (企业设备管理)](js-apis-enterprise-adminManager.md) - [@ohos.enterprise.adminManager (企业设备管理)](js-apis-enterprise-adminManager.md)
- [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md) - [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (设备控制管理)](js-apis-enterprise-deviceControl.md)
- 语言基础类库 - 语言基础类库
- [@ohos.buffer (Buffer)](js-apis-buffer.md) - [@ohos.buffer (Buffer)](js-apis-buffer.md)
......
...@@ -198,18 +198,23 @@ createAccountImplicitly(owner: string, callback: AuthCallback): void ...@@ -198,18 +198,23 @@ createAccountImplicitly(owner: string, callback: AuthCallback): void
**示例:** **示例:**
```js ```js
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) { function onResultCallback(code, result) {
console.log("resultCode: " + code); console.log("resultCode: " + code);
console.log("result: " + JSON.stringify(result)); console.log("result: " + JSON.stringify(result));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
let abilityStartSetting = {want: request}; let wantInfo = {
featureAbility.startAbility(abilityStartSetting, (err) => { deviceId: '',
bundleName: 'com.example.accountjsdemo',
action: 'ohos.want.action.viewData',
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully");
}).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err)); console.log("startAbility err: " + JSON.stringify(err));
}); })
} }
try { try {
...@@ -252,18 +257,23 @@ createAccountImplicitly(owner: string, options: CreateAccountImplicitlyOptions, ...@@ -252,18 +257,23 @@ createAccountImplicitly(owner: string, options: CreateAccountImplicitlyOptions,
**示例:** **示例:**
```js ```js
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) { function onResultCallback(code, result) {
console.log("resultCode: " + code); console.log("resultCode: " + code);
console.log("result: " + JSON.stringify(result)); console.log("result: " + JSON.stringify(result));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
let abilityStartSetting = {want: request}; let wantInfo = {
featureAbility.startAbility(abilityStartSetting, (err) => { deviceId: '',
bundleName: 'com.example.accountjsdemo',
action: 'ohos.want.action.viewData',
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully");
}).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err)); console.log("startAbility err: " + JSON.stringify(err));
}); })
} }
let options = { let options = {
...@@ -1346,7 +1356,7 @@ auth(name: string, owner: string, authType: string, callback: AuthCallback): voi ...@@ -1346,7 +1356,7 @@ auth(name: string, owner: string, authType: string, callback: AuthCallback): voi
**示例:** **示例:**
```js ```js
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, authResult) { function onResultCallback(code, authResult) {
console.log("resultCode: " + code); console.log("resultCode: " + code);
...@@ -1354,10 +1364,17 @@ auth(name: string, owner: string, authType: string, callback: AuthCallback): voi ...@@ -1354,10 +1364,17 @@ auth(name: string, owner: string, authType: string, callback: AuthCallback): voi
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
let abilityStartSetting = {want: request}; let wantInfo = {
featureAbility.startAbility(abilityStartSetting, (err) => { deviceId: '',
console.log("startAbility err: " + JSON.stringify(err)); bundleName: 'com.example.accountjsdemo',
}); action: 'ohos.want.action.viewData',
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully");
}).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err));
})
} }
try { try {
...@@ -1402,7 +1419,7 @@ auth(name: string, owner: string, authType: string, options: {[key: string]: Obj ...@@ -1402,7 +1419,7 @@ auth(name: string, owner: string, authType: string, options: {[key: string]: Obj
**示例:** **示例:**
```js ```js
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, authResult) { function onResultCallback(code, authResult) {
console.log("resultCode: " + code); console.log("resultCode: " + code);
...@@ -1410,10 +1427,17 @@ auth(name: string, owner: string, authType: string, options: {[key: string]: Obj ...@@ -1410,10 +1427,17 @@ auth(name: string, owner: string, authType: string, options: {[key: string]: Obj
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
let abilityStartSetting = {want: request}; let wantInfo = {
featureAbility.startAbility(abilityStartSetting, (err) => { deviceId: '',
console.log("startAbility err: " + JSON.stringify(err)); bundleName: 'com.example.accountjsdemo',
}); action: 'ohos.want.action.viewData',
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully");
}).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err));
})
} }
let options = { let options = {
...@@ -2802,7 +2826,7 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a ...@@ -2802,7 +2826,7 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a
**示例:** **示例:**
```js ```js
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) { function onResultCallback(code, result) {
console.log("resultCode: " + code); console.log("resultCode: " + code);
...@@ -2810,10 +2834,17 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a ...@@ -2810,10 +2834,17 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
let abilityStartSetting = {want: request}; let wantInfo = {
featureAbility.startAbility(abilityStartSetting, (err)=>{ deviceId: '',
bundleName: 'com.example.accountjsdemo',
action: 'ohos.want.action.viewData',
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully");
}).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err)); console.log("startAbility err: " + JSON.stringify(err));
}); })
} }
appAccountManager.addAccountImplicitly("com.example.accountjsdemo", "getSocialData", {}, { appAccountManager.addAccountImplicitly("com.example.accountjsdemo", "getSocialData", {}, {
...@@ -3750,18 +3781,23 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri ...@@ -3750,18 +3781,23 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri
**示例:** **示例:**
```js ```js
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) { function onResultCallback(code, result) {
console.log("resultCode: " + code); console.log("resultCode: " + code);
console.log("result: " + JSON.stringify(result)); console.log("result: " + JSON.stringify(result));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
let abilityStartSetting = {want: request}; let wantInfo = {
featureAbility.startAbility(abilityStartSetting, (err)=>{ deviceId: '',
console.log("startAbility err: " + JSON.stringify(err)); bundleName: 'com.example.accountjsdemo',
}); action: 'ohos.want.action.viewData',
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully");
}).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err));
})
} }
appAccountManager.authenticate("LiSi", "com.example.accountjsdemo", "getSocialData", {}, { appAccountManager.authenticate("LiSi", "com.example.accountjsdemo", "getSocialData", {}, {
...@@ -4520,10 +4556,13 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt; ...@@ -4520,10 +4556,13 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
| KEY_REQUIRED_LABELS<sup>9+</sup> | "requiredLabels" | 表示键名,必需的标签。 | | KEY_REQUIRED_LABELS<sup>9+</sup> | "requiredLabels" | 表示键名,必需的标签。 |
| KEY_BOOLEAN_RESULT<sup>9+</sup> | "booleanResult" | 表示键名,布尔返回值。 | | KEY_BOOLEAN_RESULT<sup>9+</sup> | "booleanResult" | 表示键名,布尔返回值。 |
## ResultCode<sup>8+</sup> ## ResultCode<sup>(deprecated)</sup>
表示返回码的枚举。 表示返回码的枚举。
> **说明:**<br/>
> 从API version 8开始支持,从API version 9开始废弃。建议查看[错误码文档](../errorcodes/errorcode-app-account.md)替代。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
......
...@@ -1559,6 +1559,239 @@ symlinkSync(target: string, srcPath: string): void ...@@ -1559,6 +1559,239 @@ symlinkSync(target: string, srcPath: string): void
fs.symlinkSync(srcFile, dstFile); fs.symlinkSync(srcFile, dstFile);
``` ```
## fs.listFile
listFile(path: string, options?: {
recursion?: boolean;
listNum?: number;
filter?: Filter;
}): Promise<string[]>;
列出文件夹下所有文件名,支持递归列出所有文件名(包含子目录下),支持文件过滤,使用Promise异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| path | string | 是 | 文件夹的应用沙箱路径。 |
| options | Object | 否 | 文件过滤选项。 |
**options参数说明:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| recursion | boolean | 否 | 是否递归子目录下文件名,默认为false。 |
| listNum | number | 否 | 列出文件名数量。当设置0时,列出所有文件,默认为0。 |
| filter | [Filter](#filter) | 否 | 文件过滤选项。当前仅支持后缀名匹配、文件名模糊查询、文件大小过滤、最近修改时间过滤。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------- |
| Promise&lt;string[]&gt; | Promise对象。返回文件名数组。 |
**示例:**
```js
let options = {
"recursion": false,
"listNum": 0,
"filter": {
"suffix": [".png", ".jpg", ".jpeg"],
"displayName": ["%abc", "efg%"],
"fileSizeOver": 1024,
"lastModifiedAfter": new Date().getTime(),
}
};
fs.listFile(pathDir, options).then((filenames) => {
console.info("listFile succeed");
for (let i = 0; i < filenames.size; i++) {
console.info("fileName: %s", filenames[i]);
}
}).catch((err) => {
console.info("list file failed with error message: " + err.message + ", error code: " + err.code);
});
```
## fs.listFile
listFile(path: string, options?: {
recursion?: boolean;
listNum?: number;
filter?: Filter;
}, callback: AsyncCallback<string[]>): void;
列出文件夹下所有文件名,支持递归列出所有文件名(包含子目录下),支持文件过滤,使用Callback异步回调。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| path | string | 是 | 文件夹的应用沙箱路径。 |
| options | Object | 否 | 文件过滤选项。 |
| callback | AsyncCallback&lt;string[]&gt; | 是 | 异步列出文件名数组之后的回调。 |
**options参数说明:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| recursion | boolean | 否 | 是否递归子目录下文件名,默认为false。 |
| listNum | number | 否 | 列出文件名数量。当设置0时,列出所有文件,默认为0。 |
| filter | [Filter](#filter) | 否 | 文件过滤选项。当前仅支持后缀名匹配、文件名模糊查询、文件大小过滤、最近修改时间过滤。 |
**示例:**
```js
let options = {
"recursion": false,
"listNum": 0,
"filter": {
"suffix": [".png", ".jpg", ".jpeg"],
"displayName": ["%abc", "efg%"],
"fileSizeOver": 1024,
"lastModifiedAfter": new Date().getTime(),
}
};
fs.listFile(pathDir, options, (err, filenames) => {
if (err) {
console.info("list file failed with error message: " + err.message + ", error code: " + err.code);
} else {
console.info("listFile succeed");
for (let i = 0; i < filenames.size; i++) {
console.info("filename: %s", filenames[i]);
}
}
});
```
## listFileSync
listFileSync(path: string, options?: {
recursion?: boolean;
listNum?: number;
filter?: Filter;
}): string[];
以同步方式列出文件夹下所有文件名,支持递归列出所有文件名(包含子目录下),支持文件过滤。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| path | string | 是 | 文件夹的应用沙箱路径。 |
| options | Object | 否 | 文件过滤选项。 |
**options参数说明:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| recursion | boolean | 否 | 是否递归子目录下文件名,默认为false。 |
| listNum | number | 否 | 列出文件名数量。当设置0时,列出所有文件,默认为0。 |
| filter | [Filter](#filter) | 否 | 文件过滤选项。当前仅支持后缀名匹配、文件名模糊查询、文件大小过滤、最近修改时间过滤。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------- |
| string[] | 返回文件名数组。 |
**示例:**
```js
let options = {
"recursion": false,
"listNum": 0,
"filter": {
"suffix": [".png", ".jpg", ".jpeg"],
"displayName": ["%abc", "efg%"],
"fileSizeOver": 1024,
"lastModifiedAfter": new Date().getTime(),
}
};
let filenames = fs.listFileSync(pathDir, options);
console.info("listFile succeed");
for (let i = 0; i < filenames.size; i++) {
console.info("filename: %s", filenames[i]);
}
```
## moveFile
moveFile(src: string, dest: string, mode?: number): Promise<void>;
移动文件,使用Promise异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| src | string | 是 | 源文件的应用沙箱路径。 |
| dest | string | 是 | 目的文件的应用沙箱路径。 |
| mode | number | 否 | 移动模式。若mode为0,移动位置存在同名文件时,强制移动覆盖。若mode为1,移动位置存在同名文件时,抛出异常。默认为0。 |
**示例:**
```js
fs.moveFile(srcPath, destPath, 0).then(() => {
console.info("move file succeed");
}).catch((err) => {
console.info("move file failed with error message: " + err.message + ", error code: " + err.code);
});
```
## moveFile
moveFile(src: string, dest: string, mode?: number, callback: AsyncCallback<void>): void;
移动文件,使用Callback异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| src | string | 是 | 源文件的应用沙箱路径。 |
| dest | string | 是 | 目的文件的应用沙箱路径。 |
| mode | number | 否 | 移动模式。若mode为0,移动位置存在同名文件时,强制移动覆盖。若mode为1,移动位置存在同名文件时,抛出异常。默认为0。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步移动文件之后的回调。 |
**示例:**
```js
fs.moveFile(srcPath, destPath, 0, (err) => {
if (err) {
console.info("move file failed with error message: " + err.message + ", error code: " + err.code);
} else {
console.info("move file succeed");
}
});
```
## moveFileSync
moveFile(src: string, dest: string, mode?: number): void;
以同步方式移动文件。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| src | string | 是 | 源文件的应用沙箱路径。 |
| dest | string | 是 | 目的文件的应用沙箱路径。 |
| mode | number | 否 | 移动模式。若mode为0,移动位置存在同名文件时,强制移动覆盖。若mode为1,移动位置存在同名文件时,抛出异常。默认为0。 |
**示例:**
```js
fs.moveFileSync(srcPath, destPath, 0);
console.info("move file succeed");
```
## fs.mkdtemp ## fs.mkdtemp
mkdtemp(prefix: string): Promise&lt;string&gt; mkdtemp(prefix: string): Promise&lt;string&gt;
...@@ -2353,6 +2586,104 @@ readSync(buffer: ArrayBuffer, options?: { offset?: number; length?: number; }): ...@@ -2353,6 +2586,104 @@ readSync(buffer: ArrayBuffer, options?: { offset?: number; length?: number; }):
| ---- | ------ | ---- | ---- | ------- | | ---- | ------ | ---- | ---- | ------- |
| fd | number | 是 | 否 | 打开的文件描述符。 | | fd | number | 是 | 否 | 打开的文件描述符。 |
### lock
lock(exclusive?: boolean): Promise<void>;
文件阻塞式施加共享锁或独占锁,使用Promise异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | 否 | 是否施加独占锁,默认false。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
file.lock(true).then(() => {
console.log("lock file successful");
}).catch((err) => {
console.info("lock file failed with error message: " + err.message + ", error code: " + err.code);
});
```
### lock
lock(exclusive?: boolean, callback: AsyncCallback<void>): void;
文件阻塞式施加共享锁或独占锁,使Callback异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | 否 | 是否施加独占锁,默认false。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步文件上锁之后的回调。 |
**示例:**
```js
let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
file.lock(true, (err) => {
if (err) {
console.info("lock file failed with error message: " + err.message + ", error code: " + err.code);
} else {
console.log("lock file successful");
}
});
```
### tryLock
tryLock(exclusive?: boolean): void;
文件非阻塞式施加共享锁或独占锁。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | 否 | 是否施加独占锁,默认false。 |
**示例:**
```js
let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
file.tryLock(true);
console.log("lock file successful");
```
### unlock
unlock(): void;
以同步方式给文件解锁。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**示例:**
```js
let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
file.tryLock(true);
file.unlock();
console.log("unlock file successful");
```
## OpenMode ## OpenMode
open接口flags参数常量。文件打开标签。 open接口flags参数常量。文件打开标签。
...@@ -2371,3 +2702,18 @@ open接口flags参数常量。文件打开标签。 ...@@ -2371,3 +2702,18 @@ open接口flags参数常量。文件打开标签。
| DIR | number | 0o200000 | 如果path不指向目录,则出错。 | | DIR | number | 0o200000 | 如果path不指向目录,则出错。 |
| NOFOLLOW | number | 0o400000 | 如果path指向符号链接,则出错。 | | NOFOLLOW | number | 0o400000 | 如果path指向符号链接,则出错。 |
| SYNC | number | 0o4010000 | 以同步IO的方式打开文件。 | | SYNC | number | 0o4010000 | 以同步IO的方式打开文件。 |
## Filter
**系统能力**:SystemCapability.FileManagement.File.FileIO
文件过滤配置项类型,支持listFile接口使用。
| 名称 | 类型 | 说明 |
| ----------- | --------------- | ------------------ |
| suffix | Array&lt;string&gt; | 文件后缀名完全匹配,各个关键词OR关系。 |
| displayName | Array&lt;string&gt; | 文件名模糊匹配,各个关键词OR关系。 |
| mimeType | Array&lt;string&gt; | mime类型完全匹配,各个关键词OR关系。 |
| fileSizeOver | number | 文件大小匹配,大于等于指定大小的文件。 |
| lastModifiedAfter | number | 文件最近修改时间匹配,在指定时间点及之后的文件。 |
| excludeMedia | boolean | 是否排除Media中已有的文件。 |
...@@ -92,6 +92,7 @@ hash(path: string, algorithm: string, callback: AsyncCallback&lt;string&gt;): vo ...@@ -92,6 +92,7 @@ hash(path: string, algorithm: string, callback: AsyncCallback&lt;string&gt;): vo
**示例:** **示例:**
```js ```js
let filePath = pathDir + "/test.txt";
Hash.hash(filePath, "sha256", (err, str) => { Hash.hash(filePath, "sha256", (err, str) => {
if (err) { if (err) {
console.info("calculate file hash failed with error message: " + err.message + ", error code: " + err.code); console.info("calculate file hash failed with error message: " + err.message + ", error code: " + err.code);
......
...@@ -35,7 +35,7 @@ getFreeSize(path:string):Promise&lt;number&gt; ...@@ -35,7 +35,7 @@ getFreeSize(path:string):Promise&lt;number&gt;
```js ```js
let path = "/dev"; let path = "/dev";
statfs.getFreeSize(path).then((number) => { statvfs.getFreeSize(path).then((number) => {
console.info("getFreeSize promise successfully, Size: " + number); console.info("getFreeSize promise successfully, Size: " + number);
}).catch((err) => { }).catch((err) => {
console.info("getFreeSize failed with error message: " + err.message + ", error code: " + err.code); console.info("getFreeSize failed with error message: " + err.message + ", error code: " + err.code);
...@@ -61,7 +61,7 @@ getFreeSize(path:string, callback:AsyncCallback&lt;number&gt;): void ...@@ -61,7 +61,7 @@ getFreeSize(path:string, callback:AsyncCallback&lt;number&gt;): void
```js ```js
let path = "/dev"; let path = "/dev";
statfs.getFreeSize(path, (err, number) => { statvfs.getFreeSize(path, (err, number) => {
if (err) { if (err) {
console.info("getFreeSize failed with error message: " + err.message + ", error code: " + err.code); console.info("getFreeSize failed with error message: " + err.message + ", error code: " + err.code);
} else { } else {
...@@ -94,7 +94,7 @@ getTotalSize(path: string): Promise&lt;number&gt; ...@@ -94,7 +94,7 @@ getTotalSize(path: string): Promise&lt;number&gt;
```js ```js
let path = "/dev"; let path = "/dev";
statfs.getTotalSize(path).then((number) => { statvfs.getTotalSize(path).then((number) => {
console.info("getTotalSize promise successfully, Size: " + number); console.info("getTotalSize promise successfully, Size: " + number);
}).catch((err) => { }).catch((err) => {
console.info("getTotalSize with error message: " + err.message + ", error code: " + err.code); console.info("getTotalSize with error message: " + err.message + ", error code: " + err.code);
...@@ -120,7 +120,7 @@ getTotalSize(path: string, callback: AsyncCallback&lt;number&gt;): void ...@@ -120,7 +120,7 @@ getTotalSize(path: string, callback: AsyncCallback&lt;number&gt;): void
```js ```js
let path = "/dev"; let path = "/dev";
statfs.getTotalSize(path, (err, number) => { statvfs.getTotalSize(path, (err, number) => {
if (err) { if (err) {
console.info("getTotalSize with error message: " + err.message + ", error code: " + err.code); console.info("getTotalSize with error message: " + err.message + ", error code: " + err.code);
} else { } else {
......
...@@ -3436,20 +3436,3 @@ isSymbolicLink(): boolean ...@@ -3436,20 +3436,3 @@ isSymbolicLink(): boolean
let dir = fileio.opendirSync(pathDir); let dir = fileio.opendirSync(pathDir);
let isSymbolicLink = dir.readSync().isSymbolicLink(); let isSymbolicLink = dir.readSync().isSymbolicLink();
``` ```
## Filter<sup>9+</sup>
**系统接口**:此接口为系统接口。
**系统能力**:SystemCapability.FileManagement.File.FileIO
文件过滤器配置项。
| 名称 | 类型 | 说明 |
| ----------- | --------------- | ------------------ |
| suffix | Array&lt;string&gt; | 文件后缀名,各个关键词OR关系。 |
| displayName | Array&lt;string&gt; | 文件名模糊匹配,各个关键词OR关系。 |
| mimeType | Array&lt;string&gt; | mime类型匹配,各个关键词OR关系。 |
| fileSizeOver | number | 文件大小匹配,大于等于指定大小的文件。 |
| lastModifiedAfter | Date | 修改时间匹配,在指定时间点后的文件。 |
| excludeMedia | Boolean | 是否排除Media中已有的文件。 |
...@@ -46,11 +46,11 @@ addCheckRule(rule: bigint): void ...@@ -46,11 +46,11 @@ addCheckRule(rule: bigint): void
```js ```js
try { try {
// 添加一条规则 // 添加一条规则
hichecker.addCheckRule(hichecker.RULE_CAUTION_PRINT_LOG);} hichecker.addCheckRule(hichecker.RULE_CAUTION_PRINT_LOG);
// 添加多条规则 // 添加多条规则
hichecker.addCheckRule( // hichecker.addCheckRule(
hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); // hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH);
catch (err) { } catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`); console.error(`code: ${err.code}, message: ${err.message}`);
} }
``` ```
...@@ -76,9 +76,9 @@ try { ...@@ -76,9 +76,9 @@ try {
// 删除一条规则 // 删除一条规则
hichecker.removeCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); hichecker.removeCheckRule(hichecker.RULE_CAUTION_PRINT_LOG);
// 删除多条规则 // 删除多条规则
hichecker.removeCheckRule( // hichecker.removeCheckRule(
hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); // hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH);
catch (err) { } catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`); console.error(`code: ${err.code}, message: ${err.message}`);
} }
``` ```
...@@ -113,7 +113,7 @@ try { ...@@ -113,7 +113,7 @@ try {
// 查询是否包含 // 查询是否包含
hichecker.containsCheckRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true; hichecker.containsCheckRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true;
hichecker.containsCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); // return false; hichecker.containsCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); // return false;
catch (err) { } catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`); console.error(`code: ${err.code}, message: ${err.message}`);
} }
``` ```
......
...@@ -297,7 +297,7 @@ import hidebug from '@ohos.hidebug' ...@@ -297,7 +297,7 @@ import hidebug from '@ohos.hidebug'
try { try {
hidebug.startJsCpuProfiling("cpu_profiling"); hidebug.startJsCpuProfiling("cpu_profiling");
... // ...
hidebug.stopJsCpuProfiling(); hidebug.stopJsCpuProfiling();
} catch (error) { } catch (error) {
console.info(error.code) console.info(error.code)
...@@ -326,7 +326,7 @@ import hidebug from '@ohos.hidebug' ...@@ -326,7 +326,7 @@ import hidebug from '@ohos.hidebug'
try { try {
hidebug.startJsCpuProfiling("cpu_profiling"); hidebug.startJsCpuProfiling("cpu_profiling");
... // ...
hidebug.stopJsCpuProfiling(); hidebug.stopJsCpuProfiling();
} catch (error) { } catch (error) {
console.info(error.code) console.info(error.code)
......
...@@ -30,6 +30,17 @@ on\(type: \'networkStateChange\', callback: Callback<NetworkState\>\): void; ...@@ -30,6 +30,17 @@ on\(type: \'networkStateChange\', callback: Callback<NetworkState\>\): void;
| type | string | 是 | 网络状态变化事件 | | type | string | 是 | 网络状态变化事件 |
| callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | 是 | 回调函数。参考radio的[NetworkState](js-apis-radio.md#networkstate) | | callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | 是 | 回调函数。参考radio的[NetworkState](js-apis-radio.md#networkstate) |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -57,6 +68,17 @@ on\(type: \'networkStateChange\', options: { slotId: number }, callback: Callbac ...@@ -57,6 +68,17 @@ on\(type: \'networkStateChange\', options: { slotId: number }, callback: Callbac
| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | | slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
| callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | 是 | 回调函数。参考radio的[NetworkState](js-apis-radio.md#networkstate) | | callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | 是 | 回调函数。参考radio的[NetworkState](js-apis-radio.md#networkstate) |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -85,6 +107,14 @@ off\(type: \'networkStateChange\', callback?: Callback<NetworkState\>\): void; ...@@ -85,6 +107,14 @@ off\(type: \'networkStateChange\', callback?: Callback<NetworkState\>\): void;
| type | string | 是 | 网络状态变化事件 | | type | string | 是 | 网络状态变化事件 |
| callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | 否 | 回调函数。参考radio的[NetworkState](js-apis-radio.md#networkstate) | | callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | 否 | 回调函数。参考radio的[NetworkState](js-apis-radio.md#networkstate) |
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -112,6 +142,17 @@ on\(type: \'signalInfoChange\', callback: Callback<Array<SignalInformation\>\>): ...@@ -112,6 +142,17 @@ on\(type: \'signalInfoChange\', callback: Callback<Array<SignalInformation\>\>):
| type | string | 是 | 信号状态变化事件 | | type | string | 是 | 信号状态变化事件 |
| callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | 是 | 回调函数。参考radio的[SignalInformation](js-apis-radio.md#signalinformation) | | callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | 是 | 回调函数。参考radio的[SignalInformation](js-apis-radio.md#signalinformation) |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -137,6 +178,17 @@ on\(type: \'signalInfoChange\', options: { slotId: number }, callback: Callback< ...@@ -137,6 +178,17 @@ on\(type: \'signalInfoChange\', options: { slotId: number }, callback: Callback<
| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | | slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
| callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | 是 | 回调函数。参考radio的[SignalInformation](js-apis-radio.md#signalinformation) | | callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | 是 | 回调函数。参考radio的[SignalInformation](js-apis-radio.md#signalinformation) |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -165,6 +217,16 @@ off\(type: \'signalInfoChange\', callback?: Callback<Array<SignalInformation\>\> ...@@ -165,6 +217,16 @@ off\(type: \'signalInfoChange\', callback?: Callback<Array<SignalInformation\>\>
| type | string | 是 | 信号状态变化事件 | | type | string | 是 | 信号状态变化事件 |
| callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | 否 | 回调函数。参考radio的[SignalInformation](js-apis-radio.md#signalinformation) | | callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | 否 | 回调函数。参考radio的[SignalInformation](js-apis-radio.md#signalinformation) |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -193,6 +255,16 @@ on(type: 'callStateChange', callback: Callback\<{ state: CallState, number: stri ...@@ -193,6 +255,16 @@ on(type: 'callStateChange', callback: Callback\<{ state: CallState, number: stri
| type | string | 是 | 通话状态变化事件 | | type | string | 是 | 通话状态变化事件 |
| callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | 是 | 回调函数,参考call的[CallState](js-apis-call.md#callstate)<br />number:电话号码 | | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | 是 | 回调函数,参考call的[CallState](js-apis-call.md#callstate)<br />number:电话号码 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -218,6 +290,16 @@ on(type: 'callStateChange', options: { slotId: number }, callback: Callback<{ st ...@@ -218,6 +290,16 @@ on(type: 'callStateChange', options: { slotId: number }, callback: Callback<{ st
| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | | slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
| callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | 是 | 回调函数,参考call的[CallState](js-apis-call.md#callstate)<br />number:电话号码 | | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | 是 | 回调函数,参考call的[CallState](js-apis-call.md#callstate)<br />number:电话号码 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -246,6 +328,16 @@ off(type: 'callStateChange', callback?: Callback<{ state: CallState, number: str ...@@ -246,6 +328,16 @@ off(type: 'callStateChange', callback?: Callback<{ state: CallState, number: str
| type | string | 是 | 通话状态变化事件 | | type | string | 是 | 通话状态变化事件 |
| callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | 否 | 回调函数,参考call的[CallState](js-apis-call.md#callstate)<br />number:电话号码 | | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | 否 | 回调函数,参考call的[CallState](js-apis-call.md#callstate)<br />number:电话号码 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -274,6 +366,16 @@ on\(type: 'cellularDataConnectionStateChange', callback: Callback\<{ state: Data ...@@ -274,6 +366,16 @@ on\(type: 'cellularDataConnectionStateChange', callback: Callback\<{ state: Data
| type | string | 是 | 蜂窝数据链路连接状态事件 | | type | string | 是 | 蜂窝数据链路连接状态事件 |
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | 是 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#dataconnectstate),radio的[RadioTechnology](js-apis-radio.md#radiotechnology)。 | | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | 是 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#dataconnectstate),radio的[RadioTechnology](js-apis-radio.md#radiotechnology)。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -299,6 +401,16 @@ on\(type: 'cellularDataConnectionStateChange', options: { slotId: number }, call ...@@ -299,6 +401,16 @@ on\(type: 'cellularDataConnectionStateChange', options: { slotId: number }, call
| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | | slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | 是 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#dataconnectstate),radio的[RadioTechnology](js-apis-radio.md#radiotechnology)。 | | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | 是 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#dataconnectstate),radio的[RadioTechnology](js-apis-radio.md#radiotechnology)。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -327,6 +439,16 @@ off\(type: 'cellularDataConnectionStateChange', callback?: Callback\<{ state: D ...@@ -327,6 +439,16 @@ off\(type: 'cellularDataConnectionStateChange', callback?: Callback\<{ state: D
| type | string | 是 | 蜂窝数据链路连接状态事件 | | type | string | 是 | 蜂窝数据链路连接状态事件 |
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | 否 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#dataconnectstate),radio的[RadioTechnology](js-apis-radio.md#radiotechnology)。 | | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | 否 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#dataconnectstate),radio的[RadioTechnology](js-apis-radio.md#radiotechnology)。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -355,6 +477,16 @@ on\(type: 'cellularDataFlowChange', callback: Callback\<DataFlowType\>\): void; ...@@ -355,6 +477,16 @@ on\(type: 'cellularDataFlowChange', callback: Callback\<DataFlowType\>\): void;
| type | string | 是 | 蜂窝数据业务的上下行数据流状态状态事件 | | type | string | 是 | 蜂窝数据业务的上下行数据流状态状态事件 |
| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | 是 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#dataflowtype)。 | | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | 是 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#dataflowtype)。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -380,6 +512,16 @@ on\(type: 'cellularDataFlowChange', options: { slotId: number }, callback: Call ...@@ -380,6 +512,16 @@ on\(type: 'cellularDataFlowChange', options: { slotId: number }, callback: Call
| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | | slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | 是 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#dataflowtype)。 | | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | 是 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#dataflowtype)。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -408,6 +550,16 @@ off\(type: 'cellularDataFlowChange', callback?: Callback\<DataFlowType\>\): void ...@@ -408,6 +550,16 @@ off\(type: 'cellularDataFlowChange', callback?: Callback\<DataFlowType\>\): void
| type | string | 是 | 蜂窝数据业务的上下行数据流状态事件 | | type | string | 是 | 蜂窝数据业务的上下行数据流状态事件 |
| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | 否 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#dataflowtype)。 | | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | 否 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#dataflowtype)。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -436,6 +588,16 @@ on\(type: 'simStateChange', callback: Callback\<SimStateData\>\): void; ...@@ -436,6 +588,16 @@ on\(type: 'simStateChange', callback: Callback\<SimStateData\>\): void;
| type | string | 是 | sim状态更改事件 | | type | string | 是 | sim状态更改事件 |
| callback | Callback\<[SimStateData](#simstatedata7)\> | 是 | 回调函数。 | | callback | Callback\<[SimStateData](#simstatedata7)\> | 是 | 回调函数。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -461,6 +623,16 @@ on\(type: 'simStateChange', options: { slotId: number }, callback: Callback\<Sim ...@@ -461,6 +623,16 @@ on\(type: 'simStateChange', options: { slotId: number }, callback: Callback\<Sim
| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | | slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
| callback | Callback\<[SimStateData](#simstatedata7)\> | 是 | 回调函数。 | | callback | Callback\<[SimStateData](#simstatedata7)\> | 是 | 回调函数。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -489,6 +661,16 @@ off\(type: 'simStateChange', callback?: Callback\<SimStateData\>\): void; ...@@ -489,6 +661,16 @@ off\(type: 'simStateChange', callback?: Callback\<SimStateData\>\): void;
| type | string | 是 | sim状态更改事件 | | type | string | 是 | sim状态更改事件 |
| callback | Callback\<[SimStateData](#simstatedata7)\> | 否 | 回调函数。 | | callback | Callback\<[SimStateData](#simstatedata7)\> | 否 | 回调函数。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
......
...@@ -476,7 +476,7 @@ RunningLock锁的类型。 ...@@ -476,7 +476,7 @@ RunningLock锁的类型。
**系统能力:** SystemCapability.PowerManager.PowerManager.Core **系统能力:** SystemCapability.PowerManager.PowerManager.Core
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ------------------------ | ---- | -------------------------------------- | | --------------------------------- | ---- | ------------------------------------------------------------ |
| BACKGROUND | 1 | 阻止系统休眠的锁。 | | BACKGROUND<sup>(deprecated)</sup> | 1 | 阻止系统休眠的锁。<br>**说明:** 从API version 7开始支持,从API version 10开始废弃。 |
| PROXIMITY_SCREEN_CONTROL | 2 | 通过接近或者远离状态来控制亮灭屏的锁。 | | PROXIMITY_SCREEN_CONTROL | 2 | 通过接近或者远离状态来控制亮灭屏的锁。 |
...@@ -3477,7 +3477,7 @@ try { ...@@ -3477,7 +3477,7 @@ try {
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | -------- | ---------------------- | ---------------------- | ---------------------- | | --------------- | -------- | ---------------------- | ---------------------- | ---------------------- |
| sensorName | string | 是 | 是 | 传感器名称。 | | sensorName | string | 是 | 是 | 传感器名称。 |
| venderName | string | 是 | 是 | 传感器供应商。 | | vendorName | string | 是 | 是 | 传感器供应商。 |
| firmwareVersion | string | 是 | 是 | 传感器固件版本。 | | firmwareVersion | string | 是 | 是 | 传感器固件版本。 |
| hardwareVersion | string | 是 | 是 | 传感器硬件版本。 | | hardwareVersion | string | 是 | 是 | 传感器硬件版本。 |
| sensorId | number | 是 | 是 | 传感器类型id。 | | sensorId | number | 是 | 是 | 传感器类型id。 |
......
...@@ -98,6 +98,19 @@ setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\<void\>): v ...@@ -98,6 +98,19 @@ setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\<void\>): v
| slotId | number | 是 | SIM卡槽ID。<br/>- 0:卡槽1。<br/>- 1:卡槽2。<br/>- -1:清除默认配置。 | | slotId | number | 是 | SIM卡槽ID。<br/>- 0:卡槽1。<br/>- 1:卡槽2。<br/>- -1:清除默认配置。 |
| callback | AsyncCallback\<void\> | 是 | 回调函数。 | | callback | AsyncCallback\<void\> | 是 | 回调函数。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. |
| 8301001 | SIM card is not activated. |
**示例:** **示例:**
```js ```js
...@@ -130,6 +143,19 @@ setDefaultCellularDataSlotId(slotId: number): Promise\<void\> ...@@ -130,6 +143,19 @@ setDefaultCellularDataSlotId(slotId: number): Promise\<void\>
| --------------- | ------------------------------- | | --------------- | ------------------------------- |
| Promise\<void\> | 以Promise形式异步返回设置结果。 | | Promise\<void\> | 以Promise形式异步返回设置结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. |
| 8301001 | SIM card is not activated. |
**示例:** **示例:**
```js ```js
...@@ -251,6 +277,17 @@ isCellularDataEnabled(callback: AsyncCallback\<boolean\>): void ...@@ -251,6 +277,17 @@ isCellularDataEnabled(callback: AsyncCallback\<boolean\>): void
| -------- | ------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<boolean\> | 是 | 回调函数。<br />true:蜂窝数据业务已启用。<br />false:蜂窝数据业务已禁用。 | | callback | AsyncCallback\<boolean\> | 是 | 回调函数。<br />true:蜂窝数据业务已启用。<br />false:蜂窝数据业务已禁用。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -275,6 +312,17 @@ isCellularDataEnabled(): Promise\<boolean\> ...@@ -275,6 +312,17 @@ isCellularDataEnabled(): Promise\<boolean\>
| ------------------ | ------------------------------------------------------------ | | ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回检查蜂窝数据业务是否启用。<br />true:蜂窝数据业务已启用。<br />false:蜂窝数据业务已禁用。 | | Promise\<boolean\> | 以Promise形式返回检查蜂窝数据业务是否启用。<br />true:蜂窝数据业务已启用。<br />false:蜂窝数据业务已禁用。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -303,6 +351,17 @@ isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\<boolean\>) ...@@ -303,6 +351,17 @@ isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\<boolean\>)
| slotId | number | 是 | 卡槽ID。<br />0:卡槽1。<br />1:卡槽2。 | | slotId | number | 是 | 卡槽ID。<br />0:卡槽1。<br />1:卡槽2。 |
| callback | AsyncCallback\<boolean\> | 是 | 回调函数。<br />true:蜂窝数据业务已启用漫游。<br />false:蜂窝数据业务已禁用漫游。 | | callback | AsyncCallback\<boolean\> | 是 | 回调函数。<br />true:蜂窝数据业务已启用漫游。<br />false:蜂窝数据业务已禁用漫游。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -333,6 +392,17 @@ isCellularDataRoamingEnabled(slotId: number): Promise\<boolean\> ...@@ -333,6 +392,17 @@ isCellularDataRoamingEnabled(slotId: number): Promise\<boolean\>
| ------------------ | ------------------------------------------------------------ | | ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回检查蜂窝数据业务是否启用漫游。<br />true:蜂窝数据业务已启用漫游。<br />false:蜂窝数据业务已禁用漫游。 | | Promise\<boolean\> | 以Promise形式返回检查蜂窝数据业务是否启用漫游。<br />true:蜂窝数据业务已启用漫游。<br />false:蜂窝数据业务已禁用漫游。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -362,6 +432,17 @@ enableCellularData(callback: AsyncCallback<void\>): void ...@@ -362,6 +432,17 @@ enableCellularData(callback: AsyncCallback<void\>): void
| -------- | --------------------- | ---- | ---------- | | -------- | --------------------- | ---- | ---------- |
| callback | AsyncCallback\<void\> | 是 | 回调函数。 | | callback | AsyncCallback\<void\> | 是 | 回调函数。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -388,6 +469,17 @@ enableCellularData(): Promise<void\> ...@@ -388,6 +469,17 @@ enableCellularData(): Promise<void\>
| --------------- | ----------------------- | | --------------- | ----------------------- |
| Promise\<void\> | 以Promise形式返回结果。 | | Promise\<void\> | 以Promise形式返回结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -417,6 +509,17 @@ disableCellularData(callback: AsyncCallback<void\>): void ...@@ -417,6 +509,17 @@ disableCellularData(callback: AsyncCallback<void\>): void
| -------- | --------------------- | ---- | ---------- | | -------- | --------------------- | ---- | ---------- |
| callback | AsyncCallback\<void\> | 是 | 回调函数。 | | callback | AsyncCallback\<void\> | 是 | 回调函数。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -443,6 +546,17 @@ disableCellularData(): Promise<void\> ...@@ -443,6 +546,17 @@ disableCellularData(): Promise<void\>
| --------------- | --------------------------- | | --------------- | --------------------------- |
| Promise\<void\> | 以Promise形式返回禁用结果。 | | Promise\<void\> | 以Promise形式返回禁用结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -473,6 +587,17 @@ enableCellularDataRoaming(slotId: number, callback: AsyncCallback<void\>): void ...@@ -473,6 +587,17 @@ enableCellularDataRoaming(slotId: number, callback: AsyncCallback<void\>): void
| slotId | number | 是 | 卡槽ID。<br />0:卡槽1。<br />1:卡槽2。 | | slotId | number | 是 | 卡槽ID。<br />0:卡槽1。<br />1:卡槽2。 |
| callback | AsyncCallback\<void\> | 是 | 回调函数。 | | callback | AsyncCallback\<void\> | 是 | 回调函数。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -505,6 +630,17 @@ enableCellularDataRoaming(slotId: number): Promise<void\> ...@@ -505,6 +630,17 @@ enableCellularDataRoaming(slotId: number): Promise<void\>
| --------------- | ------------------------- | | --------------- | ------------------------- |
| Promise\<void\> | 以Promise形式返回启用结果 | | Promise\<void\> | 以Promise形式返回启用结果 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -535,6 +671,17 @@ disableCellularDataRoaming(slotId: number, callback: AsyncCallback<void\>): void ...@@ -535,6 +671,17 @@ disableCellularDataRoaming(slotId: number, callback: AsyncCallback<void\>): void
| slotId | number | 是 | 卡槽ID。<br />0:卡槽1。<br />1:卡槽2。 | | slotId | number | 是 | 卡槽ID。<br />0:卡槽1。<br />1:卡槽2。 |
| callback | AsyncCallback\<void\> | 是 | 回调函数。 | | callback | AsyncCallback\<void\> | 是 | 回调函数。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
...@@ -567,6 +714,17 @@ disableCellularDataRoaming(slotId: number): Promise<void\> ...@@ -567,6 +714,17 @@ disableCellularDataRoaming(slotId: number): Promise<void\>
| --------------- | ------------------------- | | --------------- | ------------------------- |
| Promise\<void\> | 以Promise形式返回禁用结果 | | Promise\<void\> | 以Promise形式返回禁用结果 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:** **示例:**
```js ```js
......
...@@ -226,9 +226,9 @@ checkIsAbsolute(): boolean ...@@ -226,9 +226,9 @@ checkIsAbsolute(): boolean
```js ```js
const uriInstance = new uri.URI('https://username:password@www.qwer.com:8080?query=pppppp'); const uriInstance = new uri.URI('https://username:password@www.qwer.com:8080?query=pppppp');
console.log(uriInstance.checkIsAbsolute()); // true console.log(`${uriInstance.checkIsAbsolute()}`); // true
const uriInstance1 = new uri.URI('xxx.com/suppliers.htm'); const uriInstance1 = new uri.URI('xxx.com/suppliers.htm');
console.log(uriInstance1.checkIsAbsolute()); // false console.log(`${uriInstance1.checkIsAbsolute()}`); // false
``` ```
......
...@@ -4572,7 +4572,7 @@ try { ...@@ -4572,7 +4572,7 @@ try {
console.error('Failed to set the aspect ratio of window. Cause:' + JSON.stringify(err)); console.error('Failed to set the aspect ratio of window. Cause:' + JSON.stringify(err));
return; return;
} }
console.error('Failed to set the aspect ratio of window. Cause:' + JSON.stringify(err)); console.info('Succeeded in setting the aspect ratio of window.');
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the aspect ratio of window. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the aspect ratio of window. Cause: ' + JSON.stringify(exception));
......
...@@ -34,10 +34,10 @@ Stepper(value?: { index?: number }) ...@@ -34,10 +34,10 @@ Stepper(value?: { index?: number })
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| onFinish(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | 步骤导航器最后一个StepperItem的nextLabel被点击时触发该回调&nbsp;。 | | onFinish(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | 步骤导航器最后一个StepperItem的nextLabel被点击时,并且ItemState属性为Normal时,触发该回调&nbsp;。 |
| onSkip(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | 当前显示的StepperItem状态为ItemState.Skip时,nextLabel被点击时触发该回调。 | | onSkip(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | 当前显示的StepperItem状态为ItemState.Skip时,nextLabel被点击时触发该回调。 |
| onChange(callback:&nbsp;(prevIndex?:&nbsp;number,&nbsp;index?:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 点击当前StepperItem的prevLabel或nextLabel进行步骤切换时触发该回调。<br/>-&nbsp;prevIndex:切换前的步骤页索引值。<br/>-&nbsp;index:切换后的步骤页(前一页或者下一页)索引值。 | | onChange(callback:&nbsp;(prevIndex?:&nbsp;number,&nbsp;index?:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 点击当前StepperItem的prevLabel进行步骤切换时触发该回调;或点击当前StepperItem的nextLabel,当前页面不为步骤导航器最后一个StepperItem且ItemState属性为Normal时,触发该回调。<br/>-&nbsp;prevIndex:切换前的步骤页索引值。<br/>-&nbsp;index:切换后的步骤页(前一页或者下一页)索引值。 |
| onNext(callback:&nbsp;(index?:&nbsp;number,&nbsp;pendingIndex?:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 点击StepperItem的nextLabel切换下一步骤时触发该回调。<br/>-&nbsp;index:当前步骤页索引值。<br/>-&nbsp;pendingIndex:下一步骤页索引值。 | | onNext(callback:&nbsp;(index?:&nbsp;number,&nbsp;pendingIndex?:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 点击StepperItem的nextLabel切换下一步骤时,当前页面不为步骤导航器最后一个StepperItem且ItemState属性为Normal时,触发该回调。<br/>-&nbsp;index:当前步骤页索引值。<br/>-&nbsp;pendingIndex:下一步骤页索引值。 |
| onPrevious(callback:&nbsp;(index?:&nbsp;number,&nbsp;pendingIndex?:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 点击StepperItem的prevLabel切换上一步骤时触发该回调。<br/>-&nbsp;index:当前步骤页索引值。<br/>-&nbsp;pendingIndex:上一步骤页索引值。 | | onPrevious(callback:&nbsp;(index?:&nbsp;number,&nbsp;pendingIndex?:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 点击StepperItem的prevLabel切换上一步骤时触发该回调。<br/>-&nbsp;index:当前步骤页索引值。<br/>-&nbsp;pendingIndex:上一步骤页索引值。 |
......
...@@ -33,7 +33,7 @@ StepperItem() ...@@ -33,7 +33,7 @@ StepperItem()
| Normal | 0 |正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 | | Normal | 0 |正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 |
| Disabled | 1 |不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 | | Disabled | 1 |不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 |
| Waiting | 2 | 等待状态,右侧文本按钮不显示,显示等待进度条,不可点击进入下一个StepperItem。 | | Waiting | 2 | 等待状态,右侧文本按钮不显示,显示等待进度条,不可点击进入下一个StepperItem。 |
| Skip | 3 |跳过状态,右侧文本按钮显示“跳过”,此时可在Stepper的onSkip回调中自定义相关逻辑。 | | Skip | 3 |跳过状态,右侧文本按钮默认显示“跳过”,此时可在Stepper的onSkip回调中自定义相关逻辑。 |
## 示例 ## 示例
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册