diff --git a/en/application-dev/faqs/Readme-EN.md b/en/application-dev/faqs/Readme-EN.md index 9606b7f526c00870a7ce76e2183d4fdb3d8ce45a..0f2738b7160dcc599c54ecbe1875d279d6f3661c 100644 --- a/en/application-dev/faqs/Readme-EN.md +++ b/en/application-dev/faqs/Readme-EN.md @@ -1,20 +1,19 @@ # FAQs - [Ability Framework Development](faqs-ability.md) +- [Bundle Management Development](faqs-bundle.md) - [ArkUI (eTS) Development](faqs-ui-ets.md) - [ArkUI (JavaScript) Development](faqs-ui-js.md) -- [Bundle Management Development](faqs-bundle.md) -- [Data Management Development](faqs-data-management.md) -- [Development Board](faqs-development-board.md) -- [Device Management Development](faqs-device-management.md) -- [DFX Development](faqs-dfx.md) - [Graphics and Image Development](faqs-graphics.md) -- [hdc_std Command Usage](faqs-ide.md) -- [IDE Usage](faqs-hdc-std.md) -- [Intl Development](faqs-international.md) - [File Management Development](faqs-file-management.md) - [Media Development](faqs-media.md) - [Network and Connection Development](faqs-connectivity.md) +- [Data Management Development](faqs-data-management.md) +- [Device Management Development](faqs-device-management.md) +- [DFX Development](faqs-dfx.md) +- [Intl Development](faqs-international.md) - [Native API Usage](faqs-native.md) - [Usage of Third- and Fourth-Party Libraries](faqs-third-party-library.md) - +- [IDE Usage](faqs-ide.md) +- [hdc_std Command Usage](faqs-hdc-std.md) +- [Development Board](faqs-development-board.md) \ No newline at end of file diff --git a/en/application-dev/faqs/faqs-data-management.md b/en/application-dev/faqs/faqs-data-management.md index a35f335d1db6f89033e4deb839cf9b7af0f544a2..47f0b7ce20cd54a1cee4eb521801d4e7ca94e04b 100644 --- a/en/application-dev/faqs/faqs-data-management.md +++ b/en/application-dev/faqs/faqs-data-management.md @@ -1,12 +1,10 @@ # Data Management Development - - -## How Do I Save PixelMap data to a database? +## How Do I Save PixelMap Data to a Database? Applicable to: OpenHarmony SDK 3.2.3.5 -You can convert a **PixelMap** into a **ArrayBuffer** and save the **ArrayBuffer** to your database. +You can convert a **PixelMap** into an **ArrayBuffer** and save the **ArrayBuffer** to your database. Reference: [readPixelsToBuffer](../reference/apis/js-apis-image.md#readpixelstobuffer7-1) @@ -14,11 +12,65 @@ Reference: [readPixelsToBuffer](../reference/apis/js-apis-image.md#readpixelstob Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9 -Run the hdc_std command to copy the .db, .db-shm, and .db-wal files from **/data/app/el2/100/database/Bundle name/entry/db/**, and then use the SQLite tool to open the files. +Run the hdc_std command to copy the .db, .db-shm, and .db-wal files in **/data/app/el2/100/database/*bundleName*/entry/db/**, and then use the SQLite tool to open the files. Example: - ``` hdc_std file recv /data/app/el2/100/database/com.xxxx.xxxx/entry/db/test.db ./test.db ``` + +## Does the Database Has a Lock Mechanism? + +Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 + +The distributed data service (DDS), relational database (RDB) store, and preferences provided OpenHarmony have a lock mechanism. You do not need to bother with the lock mechanism during the development. + +## What Is a Transaction in an RDB Store? + +Applicable to: all versions + +When a large number of operations are performed in an RDB store, an unexpected exception may cause a failure of some data operations and loss of certain data. As a result, the application may become abnormal or even crash. + +A transaction is a group of tasks serving as a single logical unit. It eliminates the failure of some of the operations and loss of associated data. + +## What Data Types Does an RDB Store Support? + +Applicable to: OpenHarmony SDK 3.0 or later, stage model of API version 9 + +An RDB store supports data of the number, string, and Boolean types. The number array supports data of the Double, Long, Float, Int, or Int64 type, with a maximum precision of 17 decimal digits. + +## How Do I View Database db Files? + +Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9 + +1. Run the **hdc_std shell** command. + +2. Obtain the absolute path or sandbox path of the database. + +The absolute path is **/data/app/el2//database/**. The default **** is **100**. + +To obtain the sandbox path, run the **ps -ef | grep hapName** command to obtain the process ID of the application. + +The database sandbox path is **/proc//root/data/storage/el2/database/**. + +3. Run the **find ./ -name "\*.db"** command in the absolute path or sandbox path of the database. + +## How Do I Store Long Text Data? + +Applicable to: OpenHarmony SDK 3.2.5.5, API version 9 + +- Preferences support a string of up to 8192 bytes. + +- The KV store supports a value of up to 4 MB. + +Reference: [Preference Overview](../database/database-preference-overview.md) and [Distributed Data Service Overview](../database/database-mdds-overview.md) + +## How Do I Develop DataShare on the Stage Model + +Applicable to: OpenHarmony SDK 3.2.5.5, API version 9 + +The DataShare on the stage model cannot be used with the **DataAbility** for the FA model. The connected server application must be implemented by using **DataShareExtensionAbility**. + +Reference: [DataShare Development](../database/database-datashare-guidelines.md) + diff --git a/en/application-dev/faqs/faqs-file-management.md b/en/application-dev/faqs/faqs-file-management.md index 1e3740047768d5d5fefa1420659c64da403ad587..adac2f5a6739a85c04005ef8068369776e90581c 100644 --- a/en/application-dev/faqs/faqs-file-management.md +++ b/en/application-dev/faqs/faqs-file-management.md @@ -1,15 +1,65 @@ # File Management Development +## Does fileio.rmdir Delete Files Recursively? +Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9 -## What If There is No Return Value or Error Captured After getAlbums Is Called? +Yes. **fileio.rmdir** deletes files recursively. + +## How Do I Create a File That Does Not Exist? + +Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9 + +You can use **fileio.open(filePath, 0o100, 0o666)**. The second parameter **0o100** means to create a file if it does not exist. The third parameter **mode** must also be specified. + +## What If "call fail callback fail, code: 202, data: json arguments illegal" Is Displayed? + +Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9 + +When the **fileio** module is used to copy files, the file path cannot start with "file:///". + +## How Do I Read Files Outside the App Sandbox? + +Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9 + +If the input parameter of the **fileio** API is **path**, only the sandbox directory of the current app obtained from the context can be accessed. To access data in other directories such as the user data, images, and videos, open the file as the data owner and operate with the file descriptor (FD) returned. + +For example, to read or write a file in Media Library, perform the following steps: + +1. Use **getFileAssets()** to obtain the **fileAsset** object. + +2. Use **fileAsset.open()** to obtain the FD. + +3. Use the obtained FD as the **fileIo** API parameter to read and write the file. + +## What If the File Contains Garbled Characters? + +Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 + +Read the file content from the buffer, and decode the file content using **util.TextDecoder**. + +Example: + +``` +import util from '@ohos.util' +async function readFile(path) { + let stream = fileio.createStreamSync(path, "r+"); + let readOut = await stream.read(new ArrayBuffer(4096)); + let textDecoder = new util.TextDecoder("utf-8", { ignoreBOM: true }); + let buffer = new Uint8Array(readOut.buffer) + let readString = textDecoder.decode(buffer, { stream: false }); + console.log ("[Demo] File content read: "+ readString); +} +``` + +## What Should I Do If There Is No Return Value or Error Captured After getAlbums Is Called? Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9 -The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbums**, and this permission needs user authorization. For details, see OpenHarmony [Application Permission List](../security/permission-list.md). +The **ohos.permission.READ_MEDIA** is required for using **getAlbums()**. In addition, this permission needs user authorization. For details, see [OpenHarmony Permission List](../security/permission-list.md). 1. Configure the required permission in the **module.json5** file. - + ``` "requestPermissions": [ { @@ -19,7 +69,7 @@ The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbum ``` 2. Add the code for user authorization before the **MainAbility.ts -> onWindowStageCreate** page is loaded. - + ``` private requestPermissions() { let permissionList: Array = [ @@ -34,3 +84,21 @@ The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbum }) } ``` + +## What Do I Do If the App Crashes When FetchFileResult() Is Called Multiple Times? + +Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 + +Each time after the **FetchFileResult** object is called, call **FetchFileResult.close()** to release and invalidate the **FetchFileResult** object . + +## What If An Error Is Reported by IDE When mediaLibrary.getMediaLibrary() Is Called in the Stage Model? + +Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 + +In the stage model, use **mediaLibrary.getMediaLibrary(context: Context)** to obtain the media library instance. + +## How Do I Sort the Data Returned by mediaLibrary.getFileAssets()? + +Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 + +Use the **order** attribute in **[MediaFetchOptions](../reference/apis/js-apis-medialibrary.md#mediafetchoptions7)** to sort the data returned. diff --git a/en/device-dev/driver/driver-peripherals-codec-des.md b/en/device-dev/driver/driver-peripherals-codec-des.md index fcc4ccf2c47a05a71e06bce9f5e695586024a12c..9dd9e1d07cfd7b964b10a3175095dc73dcd91228 100644 --- a/en/device-dev/driver/driver-peripherals-codec-des.md +++ b/en/device-dev/driver/driver-peripherals-codec-des.md @@ -3,9 +3,9 @@ ## Overview ### Function -The OpenHarmony codec Hardware Device Interface (HDI) driver framework implements the video hardware codec driver based on OpenMAX. It provides APIs for the upper-layer media services to obtain component encoding and decoding capabilities, create a component, set parameters, transfer data, and destroy a component. The codec driver can encode video data in YUV or RGB format to H.264 or H.265 format, and decode raw stream data from H.264 or H.265 format to YUV or RGB format. This document describes the codec functionality developed based on the OpenHarmony Hardware Driver Foundation (HDF). +The codec Hardware Device Interface (HDI) driver framework is implemented based on OpenHarmony Hardware Driver Foundation (HDF). The HDI driver framework implements the video hardware codec driver based on OpenMAX. It provides APIs for the upper-layer media services to obtain component encoding and decoding capabilities, create a component, set parameters, transfer data, and destroy a component. The codec driver can encode video data in YUV or RGB format to H.264 or H.265 format, and decode raw stream data from H.264 or H.265 format to YUV or RGB format. -The codec HDI driver framework is implemented based on the HDF. The figure below shows the codec HDI driver framework. +The figure below shows the codec HDI driver framework. **Figure 1** Codec HDI driver framework @@ -16,7 +16,7 @@ The codec HDI driver framework is implemented based on the HDF. The figure below - Codec HDI Adapter: HDI implementation layer, which implements HDI APIs and interacts with OpenMAX Integration layer (IL). - OpenMAX IL interface: provides OpenMAX IL APIs to directly interact with the codec HDI driver. - Vendor Impl: vendor adaptation layer, which is the OpenMAX implementation layer adapted by each vendor. -- Codec Hardware: hardware decoding device. +- Codec Hardware: hardware coding and decoding device. ### Basic Concepts Before you get started, understand the following concepts: @@ -39,7 +39,7 @@ Before you get started, understand the following concepts: - Component - An OpenMAX IL component, which is an abstraction of modules in video streams. The components in this document refer to codec components for video encoding and decoding. + An OpenMAX IL component, which is an abstraction of modules in video streams. The components in this document refer to codec components used for video encoding and decoding. ### Constraints @@ -56,20 +56,20 @@ The codec module implements hardware encoding and decoding of video data. It con - codec_component_manager.h - | API | Description | + | API | Description | | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------| | int32_t (*CreateComponent)(struct CodecComponentType **component, uint32_t *componentId, char *compName, int64_t appData, struct CodecCallbackType *callbacks) | Creates a codec component instance. | - | int32_t (*DestroyComponent)(uint32_t componentId) | Destroys a component instance. | + | int32_t (*DestroyComponent)(uint32_t componentId) | Destroys a codec component instance. | - codec_component _if.h | API | Description | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | | int32_t (*SendCommand)(struct CodecComponentType *self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t *cmdData, uint32_t cmdDataLen) | Sends commands to a component. | - | int32_t (*GetParameter)(struct CodecComponentType *self, uint32_t paramIndex, int8_t *paramStruct, uint32_t paramStructLen) | Obtains component parameter settings. | + | int32_t (*GetParameter)(struct CodecComponentType *self, uint32_t paramIndex, int8_t *paramStruct, uint32_t paramStructLen) | Obtains component parameter settings. | | int32_t (*SetParameter)(struct CodecComponentType *self, uint32_t index, int8_t *paramStruct, uint32_t paramStructLen) | Sets component parameters. | | int32_t (*GetState)(struct CodecComponentType *self, enum OMX_STATETYPE *state) | Obtains the component status. | - | int32_t (*UseBuffer)(struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) | Specifies the buffer of a component port. | + | int32_t (*UseBuffer)(struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) | Requests a port buffer for the component. | | int32_t (*FreeBuffer)(struct CodecComponentType *self, uint32_t portIndex, const struct OmxCodecBuffer *buffer) | Releases the buffer. | | int32_t (*EmptyThisBuffer)(struct CodecComponentType *self, const struct OmxCodecBuffer *buffer) | Empties this buffer. | | int32_t (*FillThisBuffer)(struct CodecComponentType *self, const struct OmxCodecBuffer *buffer) | Fills this buffer. | @@ -88,7 +88,7 @@ For more information, see [codec](https://gitee.com/openharmony/drivers_peripher The codec HDI driver development procedure is as follows: #### Registering and Initializing the Driver -Define the **HdfDriverEntry** structure (which defines the driver initialization method) and fill in the **g_codecComponentDriverEntry** structure to implement the **Bind()**, **Init()**, and **Release()** pointers. +Define the **HdfDriverEntry** structure (which defines the driver initialization method) and fill in the **g_codecComponentDriverEntry** structure to implement the pointers in **Bind()**, **Init()**, and **Release()**. ```c struct HdfDriverEntry g_codecComponentDriverEntry = { @@ -133,7 +133,7 @@ HDF_INIT(g_codecComponentDriverEntry); // Register HdfDriverEntry of the codec H } ``` -- **HdfCodecComponentTypeDriverInit**: loads the attribute configuration from the HDF configuration source (HCS). +- **HdfCodecComponentTypeDriverInit**: loads the attribute configuration in the HDF Configuration Source (HCS). ```c int32_t HdfCodecComponentTypeDriverInit(struct HdfDeviceObject *deviceObject) @@ -170,12 +170,11 @@ The HCS consists of the following: - Device configuration - Configuration of the supported components -The HCS includes the driver node, loading sequence, and service name. For details about the HCS syntax, see [Configuration Management](driver-hdf-manage.md). +You need to configure the driver node, loading sequence, and service name. For details about the HCS syntax, see [Configuration Management](driver-hdf-manage.md). -Configuration file Path of the standard system: -vendor/hihope/rk3568/hdf_config/uhdf/ +The following uses the RK3568 development board as an example. The configuration files of the standard system are in the **vendor/hihope/rk3568/hdf_config/uhdf/** directory. -1. Device configuration +1. Configure the device. Add the **codec_omx_service** configuration to **codec_host** in **device_info.hcs**. The following is an example: ```c @@ -189,31 +188,31 @@ vendor/hihope/rk3568/hdf_config/uhdf/ priority = 100; // Priority. moduleName = "libcodec_hdi_omx_server.z.so"; // Dynamic library of the driver. serviceName = "codec_hdi_omx_service"; // Service name of the driver. - deviceMatchAttr = "codec_component_capabilities"; //Attribute configuration. + deviceMatchAttr = "codec_component_capabilities"; // Attribute configuration. } } } ``` -2. Configuration of supported components +2. Configure supported components. - Add the component configuration to the **media_codec\codec_component_capabilities.hcs file**. The following is an example: + Add the component configuration to the **media_codec\codec_component_capabilities.hcs** file. The following is an example: ```c - /* node name explanation -- HDF_video_hw_enc_avc_rk: + /* Explanation to the node name HDF_video_hw_enc_avc_rk: ** ** HDF____________video__________________hw____________________enc____________avc_______rk ** | | | | | | - ** HDF or OMX video or audio hardware or software encoder or decoder mime vendor + ** HDF or OMX video or audio hardware or software encoder or decoder MIME vendor */ HDF_video_hw_enc_avc_rk { - role = 1; // Role of the AvCodec. + role = 1; // Role of the audio and video codec. type = 1; // Codec type. name = "OMX.rk.video_encoder.avc"; // Component name. supportProfiles = [1, 32768, 2, 32768, 8, 32768]; // Supported profiles. maxInst = 4; // Maximum number of instances. isSoftwareCodec = false; // Whether it is software codec. processModeMask = []; // Codec processing mode. - capsMask = [0x01]; // Codec playback capabilities. + capsMask = [0x01]; // CodecCapsMask configuration. minBitRate = 1; // Minimum bit rate. maxBitRate = 40000000; // Maximum bit rate. minWidth = 176; // Minimum video width. @@ -239,7 +238,7 @@ vendor/hihope/rk3568/hdf_config/uhdf/ ### Development Example After completing codec module driver adaptation, use the HDI APIs provided by the codec module for further development. The codec HDI provides the following features: -1. Provides codec HDI APIs for video services to implement encoding and decoding of video services. +1. Provides codec HDI APIs for video services to implement encoding and decoding for video services. 2. Provides standard interfaces for device developers to ensure that the OEM vendors comply with the HDI adapter standard. This promises a healthy evolution of the ecosystem. The development procedure is as follows: @@ -248,7 +247,7 @@ The development procedure is as follows: 2. Set codec parameters and information such as the video width, height, and bit rate. 3. Apply for input and output buffers. 4. Flip codec buffers, enable the component to enter the **OMX_Executing** state, and process the callbacks. -5. Deinitialize the interface instance, destroy the buffers, close the component, and releases all interface objects. +5. Deinitialize the interface instance, destroy the buffers, close the component, and releases all interface instances. #### Initializing the Driver Initialize the interface instance and callbacks, and create a component. @@ -352,7 +351,7 @@ Perform the following steps: 1. Use **UseBuffer()** to apply for input and output buffers and save the buffer IDs. The buffer IDs can be used for subsequent buffer flipping. 2. Check whether the corresponding port is enabled. If not, enable the port first. -3. Use **SendCommand()** to change the component status to OMX_StateIdle, and wait until the operation result is obtained. +3. Use **SendCommand()** to change the component status to **OMX_StateIdle**, and wait until the operation result is obtained. ```cpp // Apply for the input buffer. auto ret = UseBufferOnPort(PortIndex::PORT_INDEX_INPUT); @@ -376,7 +375,7 @@ HDF_LOGI("Wait for OMX_StateIdle status"); this->WaitForStatusChanged(); ``` -Implement **UseBufferOnPort** as follows: +Implement **UseBufferOnPort()** as follows: ```cpp bool CodecHdiDecode::UseBufferOnPort(enum PortIndex portIndex) @@ -392,22 +391,22 @@ bool CodecHdiDecode::UseBufferOnPort(enum PortIndex portIndex) auto err = client_->GetParameter(client_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param)); if (err != HDF_SUCCESS) { HDF_LOGE("%{public}s failed to GetParameter with OMX_IndexParamPortDefinition : portIndex[%{public}d]", - __func__, portIndex); + __func__, portIndex); return false; } bufferSize = param.nBufferSize; bufferCount = param.nBufferCountActual; bPortEnable = param.bEnabled; HDF_LOGI("buffer index [%{public}d], buffer size [%{public}d], " - "buffer count [%{public}d], portEnable[%{public}d], err [%{public}d]", - portIndex, bufferSize, bufferCount, bPortEnable, err); + "buffer count [%{public}d], portEnable[%{public}d], err [%{public}d]", + portIndex, bufferSize, bufferCount, bPortEnable, err); { OMX_PARAM_BUFFERSUPPLIERTYPE param; InitParam(param); param.nPortIndex = (uint32_t)portIndex; auto err = client_->GetParameter(client_, OMX_IndexParamCompBufferSupplier, (int8_t *)¶m, sizeof(param)); HDF_LOGI("param.eBufferSupplier[%{public}d] isSupply [%{public}d], err [%{public}d]", param.eBufferSupplier, - this->isSupply_, err); + this->isSupply_, err); } // Set the port buffer. UseBufferOnPort(portIndex, bufferCount, bufferSize); @@ -483,7 +482,7 @@ if (err != HDF_SUCCESS) { HDF_LOGE("%{public}s failed to SendCommand with OMX_CommandStateSet:OMX_StateIdle", __func__); return; } -// Set the output buffer. +// Set the output buffer to fill. for (auto bufferId : unUsedOutBuffers_) { HDF_LOGI("fill bufferid [%{public}d]", bufferId); auto iter = omxBuffers_.find(bufferId); @@ -536,7 +535,7 @@ while (!this->exit_) { client_->SendCommand(client_, OMX_CommandStateSet, OMX_StateIdle, NULL, 0); ``` -Automatic framing is not supported in rk OMX decoding. Therefore, you need to manually divide data into frames. Currently, data is divided into frames from code 0x000001 or 0x00000001 and sent to the server for processing. The sample code is as follows: +The RK3568 development board does not support data framing. Therefore, you need to manually divide the data into frames. Data is divided from code 0x000001 or 0x00000001 and sent to the server for processing. The sample code is as follows: ```cpp // Read a file by frame. @@ -581,8 +580,8 @@ bool OMXCore::ReadOnePacket(FILE* fp, char* buf, uint32_t& nFilled) The codec HDI provides the following callbacks: - **EventHandler**: Called when a command is executed. For example, when the command for changing the component state from **OMX_StateIdle** to **OMX_StateExecuting** is executed, this callback is invoked to return the result. -- **EmptyBufferDone**: Called when the input data is consumed. If the client needs to fill in data to encode or decode, call **EmptyThisBuffer()**. -- **FillBufferDone**: Called when the output data is filled. If the client needs to read the encoded or decoded data, call **FillThisBuffer()**. +- **EmptyBufferDone**: Called when the input data is consumed. If the client needs to fill data to encode or decode, it must call **EmptyThisBuffer()** again. +- **FillBufferDone**: Called when the output data is filled. If the client needs to read the encoded or decoded data, it must call **FillThisBuffer()** again. ```cpp // EmptyBufferDone example @@ -646,8 +645,7 @@ int32_t OMXCore::onFillBufferDone(struct OmxCodecBuffer* pBuffer) int32_t CodecHdiDecode::OnEvent(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info) { HDF_LOGI("onEvent: appData[0x%{public}p], eEvent [%{public}d], " - "nData1[%{public}d]", - info->appData, event, info->data1); + "nData1[%{public}d]", info->appData, event, info->data1); switch (event) { case OMX_EventCmdComplete: { OMX_COMMANDTYPE cmd = (OMX_COMMANDTYPE)info->data1; @@ -665,7 +663,7 @@ int32_t CodecHdiDecode::OnEvent(struct CodecCallbackType *self, enum OMX_EVENTTY ``` #### Destroying a Component -Change the component state to IDLE, release the input and output buffers, change the component state to **OMX_StateLoaded**, and call **DestoryComponent** to destroy the component. +Change the component state to **OMX_StateIdle**, release the input and output buffers, change the component state to **OMX_StateLoaded**, and call **DestoryComponent** to destroy the component. ##### Example of Releasing Buffers @@ -721,7 +719,7 @@ OpenMAX does not support framing. **Solution** -Transfer data frame by frame when **EmptyThisBuffer** is called. +Pass in one frame at a time when **EmptyThisBuffer** is call. ## Only Green Screen Displayed During the Decoding Process @@ -751,11 +749,11 @@ After the generated video stream (H.264 stream) is written to a file, the video **Solution** -View the **codec_host** log generated during encoding, search for "encode params init settings", and check for incorrect parameters. If **framerate** is **0**, **xFramerate** is incorrectly set. In this case, move the framerate leftwards by 16 bits. +View the **codec_host** log generated during encoding, search for "encode params init settings", and check for incorrect parameters. If **framerate** is **0**, **xFramerate** is incorrectly set. In this case, move the frame rate leftwards by 16 bits. -Check the value of **OMX_VIDEO_PARAM_AVCTYPE**, and set it correctly. +Check and correct the setting of **OMX_VIDEO_PARAM_AVCTYPE**. # Reference -For more information, see [Codec](https://gitee.com/openharmony/drivers_peripheral/tree/master/codec). +For more information, see [codec](https://gitee.com/openharmony/drivers_peripheral/tree/master/codec). diff --git a/en/device-dev/kernel/kernel-standard-build.md b/en/device-dev/kernel/kernel-standard-build.md index 3c950570cf2ae2638fd00a68756c3cefaaf3ddce..03abfc7b80146f9710c2711dbf650419b752e6ea 100644 --- a/en/device-dev/kernel/kernel-standard-build.md +++ b/en/device-dev/kernel/kernel-standard-build.md @@ -9,8 +9,8 @@ The following uses the Hi3516D V300 board and Ubuntu x86 server as an example. Perform a full build for the project to generate the **uImage** kernel image. -``` -./build.sh --product-name hispark_taurus_standard # Build the hispark_taurus_standard image. - --build-target build_kernel # Build the uImage kernel image of hispark_taurus_standard. - --gn-args linux_kernel_version=\"linux-5.10\" # Specify the kernel version. +```bash +./build.sh --product-name hispark_taurus_standard # Build the hispark_taurus_standard image. + --build-target build_kernel # Build the uImage kernel image of hispark_taurus_standard. + --gn-args linux_kernel_version=\"linux-5.10\" # Specify the kernel version. ``` diff --git a/en/device-dev/kernel/kernel-standard-mm-eswap.md b/en/device-dev/kernel/kernel-standard-mm-eswap.md index e44534ed70119aea30ec3b406f775d39732caaa0..86417cb169bac8ae5b84e7b9bc64df7313c9f51d 100644 --- a/en/device-dev/kernel/kernel-standard-mm-eswap.md +++ b/en/device-dev/kernel/kernel-standard-mm-eswap.md @@ -1,4 +1,4 @@ -# Enhanced Swap +# ESwap ## Basic Concepts @@ -8,30 +8,33 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and ## Configuring zram and ESwap +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> Enable ESwap before zram is enabled. If ESwap is not used, you can enable zram alone. If a device does not have the storage device for swap-out or have the corresponding storage partition created, you can enable zram to reclaim memory using **zswapd**. + ### Enabling ESwap 1. Enable related configuration items and dependencies. To enable ESwap, you must enable the corresponding configuration items and dependencies during kernel compilation. The configuration items related to ESwap are as follows: ``` - CONFIG_HYPERHOLD=y - CONFIG_HYPERHOLD_DEBUG=y - CONFIG_HYPERHOLD_ZSWAPD=y - CONFIG_HYPERHOLD_FILE_LRU=y - CONFIG_HYPERHOLD_MEMCG=y - CONFIG_ZRAM_GROUP=y - CONFIG_ZRAM_GROUP_DEBUG=y - CONFIG_ZLIST_DEBUG=y - CONFIG_ZRAM_GROUP_WRITEBACK=y + CONFIG_HYPERHOLD=y // Enable Hyperhold + CONFIG_HYPERHOLD_DEBUG=y // Enable Hyperhold debug + CONFIG_HYPERHOLD_ZSWAPD=y // Enable the zswapd thread to reclaim Anon pages in background + CONFIG_HYPERHOLD_FILE_LRU=y // Enable Hyperhold FILE LRU + CONFIG_HYPERHOLD_MEMCG=y // Enable Memcg management in Hyperhold + CONFIG_ZRAM_GROUP=y // Enable Manage Zram objs with mem_cgroup + CONFIG_ZRAM_GROUP_DEBUG=y // Enable Manage Zram objs with mem_cgroup Debug + CONFIG_ZLIST_DEBUG=y // Enable Debug info for zram group list + CONFIG_ZRAM_GROUP_WRITEBACK=y // Enable write back grouped zram objs to Hyperhold driver ``` Enable the following dependencies: ``` - CONFIG_MEMCG=y - CONFIG_SWAP=y - CONFIG_ZSMALLOC=y - CONFIG_ZRAM=y + CONFIG_MEMCG=y // Enable memory controller + CONFIG_SWAP=y // Enable paging of anonymous memory (swap) + CONFIG_ZSMALLOC=y // Enable memory allocator for compressed pages + CONFIG_ZRAM=y // Enable compressed RAM block device support ``` 2. Create an ESwap device. @@ -56,11 +59,11 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and By default, ESwap encrypts the data swapped out. If the ESwap device created in step 2 supports inline encryption, you can disable the ESwap software encryption function. ```Bash - // Check whether hardware-based encryption is supported and enabled. If yes, disable software encryption. Otherwise, do not perform this operation. + // Check whether hardware-based encryption is supported and enabled. If yes, disable software encryption. Otherwise, do not disable software encryption. echo 0 > /proc/sys/kernel/hyperhold/soft_crypt ``` - > ![icon-caution.gif](../public_sys-resources/icon-caution.gif) **CAUTION**
+ > ![icon-caution.gif](public_sys-resources/icon-caution.gif) **CAUTION**
> For security purposes, all swapped content must be encrypted. If the ESwap device created does not support inline encryption or the inline encryption macro is not enabled during compilation, ESwap cannot be enabled after software encryption is disabled. 4. Enable ESwap. @@ -72,9 +75,6 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and ``` -> ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**
-> Enable ESwap before zram is enabled. If ESwap is not used, you can enable zram only. If a device does not have the storage device for swap-out or have the corresponding storage partition created, you can enable zram to reclaim memory using **zswapd**. - ### Enabling zram 1. Initialize zram. @@ -88,7 +88,7 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and echo 512M > /sys/block/zram0/disksize ``` - > ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**
+ > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The parameters and functions of **/sys/block/zram0/group** are as follows: > > - **disable**: disables the function. @@ -115,7 +115,7 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and echo force_disable > /proc/sys/kernel/hyperhold/enable ``` - > ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**
+ > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The difference of the two commands is as follows: > > - **disable**: If there is no data in the ESwap partition, disable ESwap. Otherwise, changes ESwap to **readonly** mode. @@ -132,42 +132,46 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and ## ESwap APIs -ESwap provides APIs to control swap-in and swap-out policies and record the current status. These APIs are located in the directory to which memcg is mounted, for example, `/dev/memcg/`. +ESwap provides APIs to control swap-in and swap-out policies and record the current status. These APIs are located in the directory to which memcg is mounted, for example, **/dev/memcg/**. -| Category| API| Description| -| -------- | -------- | -------- | -| Control| [avail_buffers](#avail_buffers) | Sets the buffer range.| -| | [zswapd_single_memcg_param](#zswapd_single_memcg_param) | Sets memcg configuration.| -| | [zram_wm_ratio](#zram_wm_ratio) | Sets the zram swap-out waterline.| -| Status| [zswapd_pressure_show](#zswapd_pressure_show) | Records the current buffer and refault.| -| | [stat](#stat) | Checks the real-time status of ESwap.| -| | [zswapd_vmstat_show](#zswapd_vmstat_show) | Records events during the zswapd running.| +| Category| API| Description| Reference Value| +| -------- | -------- | -------- | -------- | +| Control| [avail_buffers](#avail_buffers) | Sets the buffer range.| 300 250 350 200 | +| | [zswapd_single_memcg_param](#zswapd_single_memcg_param) | Sets memcg configuration.| 300 40 0 0 | +| | [zram_wm_ratio](#zram_wm_ratio) | Sets the zram swap-out waterline.| 0 | +| Status| [zswapd_pressure_show](#zswapd_pressure_show) | Records the current buffer and refault.| NA | +| | [stat](#stat) | Checks the real-time status of ESwap.| NA | +| | [zswapd_vmstat_show](#zswapd_vmstat_show) | Records events during the zswapd running.| NA | -> ![icon-caution.gif](../public_sys-resources/icon-caution.gif) **CAUTION**
+> ![icon-caution.gif](public_sys-resources/icon-caution.gif) **CAUTION**
> Only **avail_buffers** proactively wakes up zswapd because the buffer waterline is adjusted. Other control APIs do not proactively wake up zswapd, but their configuration takes effect only after zswapd is woken up. -The APIs are described as follows: ### avail_buffers The **avail_buffers** API sets the buffer range [min_avail_buffers, high_avail_buffers]. When the current buffer is less than the value of **min_avail_buffers**, zswapd will be woken up to reclaim anonymous pages. The expected amount of memory to reclaim is the difference between the value of **high_avail_buffers** and the current system buffer value. In fact, less memory is reclaimed due to reasons such as reclamation failure. + The parameters include the following: -- **avail_buffers** indicates the expected buffer value. + +- **avail_buffers** indicates the expected buffer value. - **free_swap_threshold** indicates the threshold of the free capacity of the swap partition. After zswapd is woken up to reclaim memory, press events, such as medium press and critical press, will be recorded based on the current system status and the settings of these two parameters. -You can proactively adjust the values to trigger zswapd reclamation. -Example: + +You can proactively adjust the values to trigger zswapd reclamation. + +**Example**: + `echo 1000 950 1050 0 > /dev/memcg/memory.avail_buffers` -Default value: +**Default value**: ``` - avail_buffers: 0 - min_avail_buffers: 0 - high_avail_buffers: 0 - free_swap_threshold: 0 +avail_buffers: 0 +min_avail_buffers: 0 +high_avail_buffers: 0 +free_swap_threshold: 0 ``` -Limit: +**Limit**: 0<=min_avail_buffers<=avail_buffers<=high_avail_buffers @@ -177,25 +181,29 @@ The values are all integers. ### zswapd_single_memcg_param -The **zswapd_single_memcg_param** API sets the memcg configuration. The parameters include the following: +**zswapd_single_memcg_param** sets the memcg configuration. The parameters include the following: + - **score** indicates the current memcg reclamation priority. - **ub_mem2zram_ratio** indicates the memory compression ratio to zram. - **ub_zram2ufs_ratio** indicates the ratio of zram to ESwap. - **refault_threshold** indicates the refault threshold. + You can modify the parameters to control zram compression and ESwap. -Example: + +**Example**: + `echo 60 10 50 > memory.zswapd_single_memcg_param` -Default value: +**Default value**: ``` - memcg score: 300 - memcg ub_mem2zram_ratio: 60 - memcg ub_zram2ufs_ratio: 10 - memcg refault_threshold: 50 +memcg score: 300 +memcg ub_mem2zram_ratio: 60 +memcg ub_zram2ufs_ratio: 10 +memcg refault_threshold: 50 ``` -Limit: +**Limit**: 0<=ub_mem2zram_ratio<=100 @@ -207,17 +215,21 @@ The values are all integers. ### zram_wm_ratio -The **zram_wm_ratio** API sets the zram swap-out waterline. When the size of the compressed anonymous page in the zram partition is greater than the total size of zram multiplied by **zram_wm_ratio**, the page is swapped out to the ESwap partition. The swap is performed after zswapd is woken up by the buffer waterline. The system defaults the value **0** as **37**. You can change the value as required. -Example: +**zram_wm_ratio** sets the zram swap-out waterline. When the size of the compressed anonymous page in the zram partition is greater than the total size of zram multiplied by **zram_wm_ratio**, the page is swapped out to the ESwap partition. The swap is performed after zswapd is woken up by the buffer waterline. The system defaults the value **0** as **37**. + +You can change the value as required. + +**Example**: + `echo 30 > /dev/memcg/memory.zram_wm_ratio` -Default value: +**Default value**: ``` - zram_wm_ratio: 0 +zram_wm_ratio: 0 ``` -Limit: +**Limit**: 0<=zram_wm_ratio<=100 @@ -225,7 +237,7 @@ The value is an integer. ### zswapd_pressure_show -The **zswapd_pressure_show** API records the zswapd status. **buffer_size** indicates the current buffer size of the system, and **recent_refault** indicates the number of refaults occurred. +**zswapd_pressure_show** records the zswapd status. **buffer_size** indicates the current buffer size of the system, and **recent_refault** indicates the number of refaults occurred. ### stat @@ -235,12 +247,12 @@ In addition to **memcg.stat**, the **stat** API is added with **Anon**, **File** ### zswapd_vmstat_show -The **zswapd_vmstat_show** API records events occurred during the zswapd running. +**zswapd_vmstat_show** records events occurred during the zswapd running. ## Triggering zswapd -You can check the current buffer value by running `cat /dev/memcg/memory.zswapd_pressure_show`. For example, if the current buffer value is 1200, you can adjust the buffer range to wake up zswapd. +You can run **cat /dev/memcg/memory.zswapd_pressure_show** to check the current buffer value. For example, if the current buffer value is 1200, you can adjust the buffer range to a value greater than 1200 to wake up zswapd. ```Bash echo 1300 1250 1350 0 > /dev/memcg/memory.avail_buffers diff --git a/en/device-dev/kernel/kernel-standard-overview.md b/en/device-dev/kernel/kernel-standard-overview.md index 8c9fdc21f6e0eb3771f631843bb40e4dff2f42d4..619fbed21b20ef3fcc90e593e5c77b52c291e2c5 100644 --- a/en/device-dev/kernel/kernel-standard-overview.md +++ b/en/device-dev/kernel/kernel-standard-overview.md @@ -1,17 +1,18 @@ # Linux Kernel Overview +The standard-system devices come with application processors and memory greater than 128 MiB. OpenHarmony uses the Linux kernel as the base kernel so that appropriate OS kernels can be provided for devices with different resource limitations. -OpenHarmony adopts the Linux kernel as the basic kernel for standard-system devices \(reference memory ≥ 128 MiB\) so that appropriate OS kernels can be selected for the devices subject to resource limitations and therefore provide basic capabilities for upper-layer apps. ## Linux Kernel Versions -Linux kernel versions are classified into the stable version and long-term support \(LTS\) version. +- Linux kernel versions are classified into the stable version and long-term support (LTS) version. -The stable version is released approximately every 3 months to support the latest hardware, improve performance, and fix bugs. Its disadvantage is that the overall maintenance lifespan is short, making long-term stable support unavailable for software. +- The stable version is released approximately every 3 months to support the latest hardware, improve performance, and fix bugs. Its disadvantage is that the overall maintenance lifespan is short, making long-term stable support unavailable for software. -The LTS version provides long-term kernel maintenance \(in fixing bugs and security vulnerabilities\). Generally, the maintenance lifespan is six years. By contrast, non-LTS kernel versions whose maintenance lifespan ranges from six months to two years cannot cover the entire lifespan of their products and may leave the products open to security vulnerabilities. In addition, new features are not added in the LTS version update, which ensures the version stability. Therefore, LTS versions are more suitable for commercial products that pursue stability and security. -## OpenHarmony Kernel Version Selection +- The LTS version provides long-term kernel maintenance (in fixing bugs and security vulnerabilities). Generally, the maintenance lifespan is six years. By contrast, non-LTS kernel versions whose maintenance lifespan ranges from six months to two years cannot cover the entire lifespan of their products and may leave the products open to security vulnerabilities. In addition, new features are not added in the LTS version update, which ensures the version stability. Therefore, LTS versions are more suitable for commercial products that pursue stability and security. -The Linux kernel in OpenHarmony selects appropriate LTS versions as its basic versions. Currently, it supports Linux-4.19 and Linux-5.10. +## OpenHarmony Kernel Versions + +OpenHarmony uses Linux LTS versions as its base kernel. Currently, it supports Linux-4.19 and Linux-5.10. diff --git a/en/device-dev/kernel/kernel-standard-patch.md b/en/device-dev/kernel/kernel-standard-patch.md index 55448b5f893fc22fa938b8ea111fc42ce92d6068..549be494a1920ab16a199263cfd4aa6e56e0793c 100644 --- a/en/device-dev/kernel/kernel-standard-patch.md +++ b/en/device-dev/kernel/kernel-standard-patch.md @@ -1,39 +1,26 @@ # Applying Patches on Development Boards -1. Apply the HDF patches. - - Apply the HDF patches based on the kernel version in the **kernel/linux/build** repository. For details, see the method for applying the HDF patch in **kernel.mk**. - - ``` - $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME) - ``` - -2. Apply the chip driver patches. - - The following uses Hi3516D V300 as an example: - - In the **kernel/linux/build** repository, place the chip module patches in the corresponding path based on the patch path and naming rules for the chip module in **kernel.mk**. - - ``` - DEVICE_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}/$(DEVICE_NAME)_patch - DEVICE_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME).patch - ``` - - ``` - - ``` - -3. Modify the **config** file to be built. - - In the **kernel/linux/build** repository, place the chip module **config** file in the corresponding path based on the file path and naming rules for the chip module in **kernel.mk**. - - ``` - KERNEL_CONFIG_PATH := $(OHOS_BUILD_HOME)/kernel/linux/config/${KERNEL_VERSION} - DEFCONFIG_FILE := $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig - ``` - - >![](../public_sys-resources/icon-notice.gif) **NOTICE**
- >In the OpenHarmony project build process, patches are applied after the code environment of **kernel/linux/linux-\*.\*** is copied. Before running the OpenHarmony version-level build command, ensure that the source code environment of **kernel/linux/linux-\*.\*** is available. - >After the build is complete, the kernel is generated in the kernel directory in the **out** directory. Modify the **config** file based on the kernel generated, and copy the generated **.config** file to the corresponding path in the **config** repository. Then, the configuration takes effect. - - +1. Apply HDF patches. + Apply the HDF patches based on the kernel version. For details, see [kernel.mk](https://gitee.com/openharmony/kernel_linux_build/blob/master/kernel.mk). + ```makefile + $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME) + ``` + +2. Apply the chip driver patch. The following uses Hi3516D V300 as an example. + Place the chip component patches in the related directory. For details about the patch directory and naming rules, see [kernel.mk](https://gitee.com/openharmony/kernel_linux_build/blob/master/kernel.mk). + ```makefile + DEVICE_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}/$(DEVICE_NAME)_patch + DEVICE_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME).patch + ``` + +3. Modify the **config** file to build. + Place the chip component **config** in the related directory. For details about the patch directory and naming rules, see [kernel.mk](https://gitee.com/openharmony/kernel_linux_build/blob/master/kernel.mk). + ```makefile + KERNEL_CONFIG_PATH := $(OHOS_BUILD_HOME)/kernel/linux/config/${KERNEL_VERSION} + DEFCONFIG_FILE := $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig + ``` + + > **NOTICE**
+ > In the OpenHarmony project build process, patches are installed after "kernel/linux/linux-\*.\*" is copied. Before using the version-level build command of OpenHarmony, ensure that the "kernel/linux/linux-\*.\*" source code is available. + > + > After the build is complete, the kernel is generated in the kernel directory in the **out** directory. Modify the **config** file for the target platform based on the kernel generated, and copy the generated **.config** file to the corresponding path of the platform in the **config** repository. Then, the configuration takes effect. diff --git a/en/device-dev/kernel/kernel-standard-sched-rtg.md b/en/device-dev/kernel/kernel-standard-sched-rtg.md index 61a36ab5bb7aad13789b0ce053e3dbcd73be6b25..71bf4959b4b5772ec72aecac2945352de958bf43 100644 --- a/en/device-dev/kernel/kernel-standard-sched-rtg.md +++ b/en/device-dev/kernel/kernel-standard-sched-rtg.md @@ -48,14 +48,3 @@ STATE COMM PID PRIO CPU // Thread information, including th --------------------------------------------------------- S bash 436 120 1(0-3) ``` - -## Available APIs - -The RTG provides the device node and ioctl APIs for querying and configuring group information. The device node is in **/dev/sched_rtg_ctrl**. - -| Request | Description | -| ------------------- | ------------------- | -| CMD_ID_SET_RTG | Creates an RTG, and adds, updates, or deletes threads in the group. | -| CMD_ID_SET_CONFIG | Sets global group attributes, for example, the maximum number of real-time RTGs. | -| CMD_ID_SET_RTG_ATTR | Sets specified group attributes, for example, the thread priority. | -| CMD_ID_SET_MIN_UTIL | Sets the minimum utilization of an RTG. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index a9e649ed9f9ac8f5f92a10764beaf0f94d0162d6..474cfef39c850743caef3f719d682fd82d0d0022 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -112,11 +112,15 @@ uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask> files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }], data: [{ name: "name123", value: "123" }], }; - request.uploadFile(globalThis.abilityContext, uploadConfig).then((data) => { + try { + request.uploadFile(globalThis.abilityContext, uploadConfig).then((data) => { uploadTask = data; - }).catch((err) => { - console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); - }); + }).catch((err) => { + console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('err.code : ' + err.code + ', err.message : ' + err.message); + } ``` @@ -156,13 +160,17 @@ uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback&l files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }], data: [{ name: "name123", value: "123" }], }; - request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data) => { + try { + request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data) => { if (err) { console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); return; } uploadTask = data; - }); + }); + } catch (err) { + console.error('err.code : ' + err.code + ', err.message : ' + err.message); + } ``` ## request.upload(deprecated) @@ -363,8 +371,8 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => vo | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 | -| totalSize | number | 是 | 上传文件的总大小,单位为KB。 | +| uploadedSize | number | 是 | 当前已上传文件大小,单位为bit。 | +| totalSize | number | 是 | 上传文件的总大小,单位为bit。 | **示例:** @@ -472,8 +480,8 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 | -| totalSize | number | 是 | 上传文件的总大小,单位为KB。 | +| uploadedSize | number | 是 | 当前已上传文件的大小,单位为bit。 | +| totalSize | number | 是 | 上传文件的总大小,单位为bit。 | **示例:** @@ -775,11 +783,15 @@ downloadFile(context: BaseContext, config: DownloadConfig): Promise<DownloadT ```js let downloadTask; - request.downloadFile(globalThis.abilityContext, { url: 'https://xxxx/xxxx.hap' }).then((data) => { - downloadTask = data; - }).catch((err) => { - console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); - }) + try { + request.downloadFile(globalThis.abilityContext, { url: 'https://xxxx/xxxx.hap' }).then((data) => { + downloadTask = data; + }).catch((err) => { + console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); + }) + } catch (err) { + console.error('err.code : ' + err.code + ', err.message : ' + err.message); + } ``` @@ -814,14 +826,18 @@ downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallba ```js let downloadTask; - request.downloadFile(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap', - filePath: 'xxx/xxxxx.hap'}, (err, data) => { - if (err) { - console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); - return; - } - downloadTask = data; - }); + try { + request.downloadFile(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap', + filePath: 'xxx/xxxxx.hap'}, (err, data) => { + if (err) { + console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); + return; + } + downloadTask = data; + }); + } catch (err) { + console.error('err.code : ' + err.code + ', err.message : ' + err.message); + } ``` ## request.download(deprecated) @@ -995,8 +1011,8 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| receivedSize | number | 是 | 当前下载的进度,单位为KB。 | -| totalSize | number | 是 | 下载文件的总大小,单位为KB。 | +| receivedSize | number | 是 | 当前下载的进度,单位为bit。 | +| totalSize | number | 是 | 下载文件的总大小,单位为bit。 | **示例:** @@ -1029,8 +1045,8 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| receivedSize | number | 是 | 当前下载的进度。 | -| totalSize | number | 是 | 下载文件的总大小。 | +| receivedSize | number | 是 | 当前下载的进度,单位为bit。 | +| totalSize | number | 是 | 下载文件的总大小,单位为bit。 | **示例:** @@ -1805,7 +1821,7 @@ resume(callback: AsyncCallback<void>): void | enableMetered | boolean | 否 | 设置是否允许在按流量计费的连接下下载。
- true:是
- false:否 | | enableRoaming | boolean | 否 | 设置是否允许在漫游网络中下载。
- true:是
- false:否| | description | string | 否 | 设置下载会话的描述。 | -| filePath7+ | string | 否 | 设置下载路径(默认在'internal://cache/'路径下)。
- filePath:'workspace/test.txt':默认路径下创建workspace路径,并将文件存储在workspace路径下。
- filePath:'test.txt':将文件存储在默认路径下。
- filePath:'workspace/':默认路径下创建workspace路径,并将文件存储在workspace路径下。 | +| filePath7+ | string | 否 | 设置下载路径。
- filePath:'/data/storage/el2/base/haps/entry/files/test.txt':将文件存储在绝对路径下。
- FA模型下使用[context](js-apis-inner-app-context.md#contextgetcachedir) 获取应用存储路径,比如:'${featureAbility.getContext().getFilesDir()}/test.txt',并将文件存储在此路径下。
- Stage模型下使用[AbilityContext](js-apis-inner-application-context.md) 类获取文件路径,比如:'${globalThis.abilityContext.tempDir}/test.txt'并将文件存储在此路径下。| | networkType | number | 否 | 设置允许下载的网络类型。
- NETWORK_MOBILE:0x00000001
- NETWORK_WIFI:0x00010000| | title | string | 否 | 设置下载会话标题。 | | background9+ | boolean | 否 | 后台任务通知开关,开启后可在通知中显示下载状态。 | diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-account_os_account.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-account_os_account.md new file mode 100644 index 0000000000000000000000000000000000000000..1f4cd0b795b68596745ce9230485531e39c17c2d --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-account_os_account.md @@ -0,0 +1,20 @@ +# 帐号子系统ChangeLog + +## cl.account_os_account.1 分布式帐号昵称和头像规格扩大 + +已有分布式帐号的昵称长度和头像大小的规格过小,无法满足其他昵称较长、头像较大的使用场景。 + +因此,将分布式帐号昵称长度和头像大小的规格扩大。 + +**变更影响** + +该接口变更前向兼容,基于此前版本开发的应用可按照最新规格使用该接口,原有逻辑不受影响。 + +**关键接口/组件变更** + +变更前: + - 昵称长度限制为20个字符,头像大小限制为2M + +变更后: + - 昵称长度限制为1024个字符,头像大小限制为10M +