diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md index 3fffc71c0d054e00447f6e1eecf567a85b17bf5e..b63d065efbc3f1243745d33592e9e65a26ad89ec 100644 --- a/en/application-dev/database/database-mdds-guidelines.md +++ b/en/application-dev/database/database-mdds-guidelines.md @@ -1,235 +1,181 @@ -# Distributed Data Service Development +# Distributed Data Service Development -## When to Use +## When to Use -The DDS implements synchronization of application data across user devices. When data is added, deleted, or modified for an application on a device, the same application on another device can obtain the data changes. The DDS applies to the distributed gallery, messages, contacts, and file manager. +The Distributed Data Service (DDS) implements synchronization of application data across user devices. When data is added, deleted, or modified for an application on a device, the same application on another device can obtain the updated data. The DDS applies to the distributed gallery, messages, Contacts, and file manager. -## Available APIs -The following table describes the APIs provided by the OpenHarmony DDS module. +## Available APIs + +The table below describes the APIs provided by the OpenHarmony DDS module. **Table 1** APIs provided by the DDS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Function

-

API

-

Description

-

Creating a distributed database

-

createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void

-

createKVManager(config: KVManagerConfig): Promise<KVManager>

-

Creates a KVManager object for database management.

-

getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void

-

getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T>

-

Obtains the KV store with specified Options and storeId.

-

Managing data in a distributed database

-

put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback<void>): void

-

put(key: string, value: Uint8Array | string | number | boolean): Promise<void>

-

Inserts and updates data.

-

delete(key: string, callback: AsyncCallback<void>): void

-

delete(key: string): Promise<void>

-

Deletes data.

-

get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | number>): void

-

get(key: string): Promise<Uint8Array | string | boolean | number>

-

Queries data.

-

Subscribing to changes in the distributed data

-

on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void

-

on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void

-

Subscribes to data changes in the database.

-

Synchronizing distributed data

-

sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void

-

Triggers database synchronization in manual mode.

-
- -## How to Develop +| Category | API | Description | +| -------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | +| Creating a distributed database | createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void
createKVManager(config: KVManagerConfig): Promise<KVManager> | Creates a **KVManager** object for database management.| +| Obtaining a distributed KV store | getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void
getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> | Obtains the KV store with the specified **Options** and **storeId**.| +| Managing data in a distributed KV store| put(key: string, value: Uint8Array \| string \| number \| boolean, callback: AsyncCallback<void>): void
put(key: string, value: Uint8Array \| string \| number \| boolean): Promise<void> | Inserts or updates data. | +| Managing data in a distributed KV store| delete(key: string, callback: AsyncCallback<void>): void
delete(key: string): Promise<void> | Deletes data. | +| Managing data in a distributed KV store| get(key: string, callback: AsyncCallback<Uint8Array \| string \| boolean \| number>): void
get(key: string): Promise<Uint8Array \| string \| boolean \| number> | Queries data. | +| Subscribing to changes in the distributed data | on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void
on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void | Subscribes to data changes in the KV store. | +| Synchronizing data across devices | sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | Triggers database synchronization in manual mode. | + -The following uses a single KV store as an example to describe the development procedure. -1. Import the distributed database module. - - ```js - import distributedData from '@ohos.data.distributedData'; - ``` - -2. Create a **KvManager** instance based on the specified **KvManagerConfig** object. - - 1. Create a **KvManagerConfig** object based on the application context. - 2. Create a **KvManager** instance. - - The sample code is as follows: - - ```js - let kvManager; - try { - const kvManagerConfig = { - bundleName : 'com.example.datamanagertest', - userInfo : { - userId : '0', - userType : distributedData.UserType.SAME_USER_ID - } - } - distributedData.createKVManager(kvManagerConfig, function (err, manager) { - if (err) { - console.log("createKVManager err: " + JSON.stringify(err)); - return; - } - console.log("createKVManager success"); - kvManager = manager; - }); - } catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` - -3. Create and obtain a single KV store. - - 1. Declare the ID of the single KV store to create. - 2. Create a single KV store. You are advised to disable automatic synchronization \(**autoSync:false**\) and call **sync** if a synchronization is required. - - The sample code is as follows: - - ```js - let kvStore; - try { - const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : false, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - securityLevel : distributedData.SecurityLevel.S2, - }; - kvManager.getKVStore('storeId', options, function (err, store) { - if (err) { - console.log("getKVStore err: " + JSON.stringify(err)); - return; - } - console.log("getKVStore success"); - kvStore = store; - }); - } catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For data synchronization between networked devices, you are advised to open the distributed database during application startup to obtain the database handle. With this database handle \(**kvStore** in this example\), you can perform operations, such as inserting data into the database, without creating the database repeatedly during the lifecycle of the handle. - -4. Subscribe to changes in the distributed data. - - The following is the sample code for subscribing to the data changes of a single KV store: - - ```js - kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { - console.log("dataChange callback call data: " + JSON.stringify(data)); - }); - ``` - -5. Write data to the single KV store. - - 1. Construct the key and value to be written into the single KV store. - 2. Write key-value pairs into the single KV store. - - The following is the sample code for writing key-value pairs of the string type into the single KV store: - - ```js - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { - if (err != undefined) { - console.log("put err: " + JSON.stringify(err)); - return; - } - console.log("put success"); - }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` - -6. Query data in the single KV store. - - 1. Construct the key to be queried from the single KV store. - 2. Query data from the single KV store. - - The following is the sample code for querying data of the string type from the single KV store: - - ```js - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { - if (err != undefined) { - console.log("put err: " + JSON.stringify(err)); - return; - } - console.log("put success"); - kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) { - console.log("get success data: " + data); - }); - }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` - -7. Synchronize data to other devices. - - Select the devices in the same network and the synchronization mode to synchronize data. - - The following is the sample code for data synchronization in a single KV store. **deviceIds** can be obtained by deviceManager by calling **getTrustedDeviceListSync\(\)**, and **1000** indicates that the maximum delay time is 1000 ms. - - ```js - import deviceManager from '@ohos.distributedHardware.deviceManager'; - - let devManager; - // create deviceManager - deviceManager.createDeviceManager("bundleName", (err, value) => { - if (!err) { - devManager = value; - } - }); - - // get deviceIds - let deviceIds = []; - if (devManager != null) { - var deviceList = devManager.getTrustedDeviceListSync(); - for (var i = 0; i < deviceList.length; i++) { - deviceIds[i] = deviceList[i].deviceId; - } - } - kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000); - ``` +## How to Develop + +The following uses a single KV store as an example to describe the development procedure. +1. Import the distributed data module. + ```js + import distributedData from '@ohos.data.distributedData'; + ``` + +2. Create a **KvManager** instance based on the specified **KvManagerConfig** object. + 1. Create a **KvManagerConfig** object based on the application context. + 2. Create a **KvManager** instance. + + The sample code is as follows: + ```js + let kvManager; + try { + const kvManagerConfig = { + bundleName : 'com.example.datamanagertest', + userInfo : { + userId : '0', + userType : distributedData.UserType.SAME_USER_ID + } + } + distributedData.createKVManager(kvManagerConfig, function (err, manager) { + if (err) { + console.log("createKVManager err: " + JSON.stringify(err)); + return; + } + console.log("createKVManager success"); + kvManager = manager; + }); + } catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + +3. Create and obtain a single KV store. + 1. Declare the ID of the single KV store to create. + 2. Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** if a synchronization is required. + + The sample code is as follows: + ```js + let kvStore; + try { + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : false, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + securityLevel : distributedData.SecurityLevel.S0, + }; + kvManager.getKVStore('storeId', options, function (err, store) { + if (err) { + console.log("getKVStore err: " + JSON.stringify(err)); + return; + } + console.log("getKVStore success"); + kvStore = store; + }); + } catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + + > ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**
+ > For data synchronization between networked devices, you are advised to open the distributed KV store during application startup to obtain the database handle. With this database handle (**kvStore** in this example), you can perform operations, such as inserting data into the KV store, without creating the KV store repeatedly during the lifecycle of the handle. + +4. Subscribe to changes in the distributed data.
+ The following is the sample code for subscribing to the data changes of a single KV store: + ```js + kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { + console.log("dataChange callback call data: " + JSON.stringify(data)); + }); + ``` + +5. Write data to the single KV store. + 1. Construct the key and value to be written into the single KV store. + 2. Write key-value pairs into the single KV store. + + The following is the sample code for writing key-value pairs of the string type into the single KV store: + + ```js + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + }); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + +6. Query data in the single KV store. + 1. Construct the key to be queried from the single KV store. + 2. Query data from the single KV store. + + The following is the sample code for querying data of the string type from the single KV store: + ```js + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) { + console.log("get success data: " + data); + }); + }); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + +7. Synchronize data to other devices.
+ Select the devices in the same network and the synchronization mode to synchronize data. + + The following is the sample code for data synchronization in a single KV store. **deviceIds** can be obtained by deviceManager by calling **getTrustedDeviceListSync()**, and **1000** indicates that the maximum delay time is 1000 ms. + ```js + import deviceManager from '@ohos.distributedHardware.deviceManager'; + + let devManager; + // Create deviceManager. + deviceManager.createDeviceManager("bundleName", (err, value) => { + if (!err) { + devManager = value; + // get deviceIds + let deviceIds = []; + if (devManager != null) { + var devices = devManager.getTrustedDeviceListSync(); + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } + } + try{ + kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + } + }); + ``` +## Samples +The following samples are provided to help you better understand the distributed data development: +- [`KvStore`: distributed database (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore) +- [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 351ff72424bbe595466d4df872b42f73e5cdff91..0ba40ae0415eada3cbbe57a5b54a6ce5aeffd345 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -94,6 +94,7 @@ - File Management + - [@ohos.document](js-apis-document.md) - [@ohos.environment](js-apis-environment.md) - [@ohos.fileio](js-apis-fileio.md) - [@ohos.fileManager](js-apis-filemanager.md) diff --git a/en/application-dev/reference/apis/js-apis-featureAbility.md b/en/application-dev/reference/apis/js-apis-featureAbility.md index 430e3a52acb154b0bacfb15e1b7aab238d4f094c..e691213be25a5fc1576dc018544165459d012c84 100644 --- a/en/application-dev/reference/apis/js-apis-featureAbility.md +++ b/en/application-dev/reference/apis/js-apis-featureAbility.md @@ -917,8 +917,8 @@ Enumerates operation types of the Data ability. | Name | Readable/Writable| Type | Mandatory| Description | | -------------------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | | deviceId | Read-only | string | No | ID of the device that runs the ability. | -| bundleName | Read-only | string | No | Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| -| abilityName | Read-only | string | No | Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| +| bundleName | Read-only | string | No | Bundle name of the ability to start.| +| abilityName | Read-only | string | No | Name of the ability to start. If both **package** and **AbilityName** are specified in this field in a **Want** object, the **Want** object can directly match the specified ability.| | uri | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| | type | Read-only | string | No | MIME type, for example, text/plain or image/*. | | flags | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).| diff --git a/en/application-dev/reference/apis/js-apis-fileio.md b/en/application-dev/reference/apis/js-apis-fileio.md index f574cc158968757560d2821e960819e3ea4e9b49..451d5e4f40ce2f23d128ad162a688d9bb58f3621 100644 --- a/en/application-dev/reference/apis/js-apis-fileio.md +++ b/en/application-dev/reference/apis/js-apis-fileio.md @@ -503,9 +503,7 @@ Asynchronously creates a directory. This method uses a callback to return the re - Example ```js fileio.mkdir(path, function(err) { - if (!err) { - // Do something. - } + console.info("mkdir successfully"); }); ``` @@ -639,7 +637,8 @@ Asynchronously reads data from a file. This method uses a promise to return the let fd = fileio.openSync(path, 0o2); let buf = new ArrayBuffer(4096); fileio.read(fd, buf).then(function(readout){ - console.info("read file data successfully:"+ JSON.stringify(readout)); + console.info("read file data successfully"); + console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); }).catch(function(error){ console.info("read file data failed with error:"+ error); }); @@ -671,8 +670,9 @@ Asynchronously reads data from a file. This method uses a callback to return the let fd = fileio.openSync(path, 0o2); let buf = new ArrayBuffer(4096); fileio.read(fd, buf, function (err, readOut) { - if (!err) { - console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))) + if (readOut) { + console.info("read file data successfully"); + console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); } }); ``` @@ -756,6 +756,7 @@ Asynchronously deletes a directory. This method uses a callback to return the re ```js fileio.rmdir(path, function(err){ // Do something. + console.info("rmdir successfully"); }); ``` @@ -824,9 +825,7 @@ Asynchronously deletes a file. This method uses a callback to return the result. - Example ```js fileio.unlink(path, function(err) { - if (!err) { - // Do something. - } + console.info("remove file successfully"); }); ``` @@ -879,7 +878,7 @@ Asynchronously writes data into a file. This method uses a promise to return the ```js let fd = fileio.openSync(fpath, 0o100 | 0o2, 0o666); fileio.write(fd, "hello, world").then(function(number){ - console.info("write data to file successfully:"+ number); + console.info("write data to file successfully and size is:"+ number); }).catch(function(err){ console.info("write data to file failed with error:"+ err); }); @@ -911,8 +910,8 @@ Asynchronously writes data into a file. This method uses a callback to return th ```js let fd = fileio.openSync(path, 0o100 | 0o2, 0o666); fileio.write(fd, "hello, world", function (err, bytesWritten) { - if (!err) { - console.log(bytesWritten) + if (bytesWritten) { + console.info("write data to file successfully and size is:"+ bytesWritten); } }); ``` @@ -962,7 +961,7 @@ Asynchronously calculates the hash value of a file. This method uses a promise t | Name | Type | Mandatory | Description | | --------- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | - | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**.**sha256** is recommended for security purposes.| + | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**. **sha256** is recommended for security purposes.| - Return value | Type | Description | @@ -991,14 +990,14 @@ Asynchronously calculates the hash value of a file. This method uses a callback | Name | Type | Mandatory | Description | | --------- | --------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | - | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**.**sha256** is recommended for security purposes.| + | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**. **sha256** is recommended for security purposes.| | callback | AsyncCallback<string> | Yes | Callback used to return the hash value. The hash value is a hexadecimal string consisting of digits and uppercase letters.| - Example ```js fileio.hash(fpath, "sha256", function(err, hashStr) { - if (!err) { - console.log(hashStr) + if (hashStr) { + console.info("calculate file hash successfully:"+ hashStr); } }); ``` @@ -1091,7 +1090,7 @@ Asynchronously obtains file status information based on the file descriptor. Thi - Return value | Type | Description | - | -------- | -------- | + | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | Promise used to return the file status information obtained.| - Example @@ -1221,7 +1220,7 @@ Synchronously truncates a file based on the file descriptor. - Example ```js - fileio.ftruncate(fd, len); + fileio.ftruncateSync(fd, len); ``` @@ -1293,7 +1292,7 @@ Synchronously truncates a file based on the file path. - Example ```js - fileio.ftruncate(path, len); + fileio.truncateSync(path, len); ``` @@ -1486,7 +1485,8 @@ Asynchronously reads data from a file. This method uses a promise to return the - Example ```js fileio.read(new ArrayBuffer(4096)).then(function(readout){ - console.info("File data read successfully:"+ String.fromCharCode.apply(null, new Uint8Array(readout.buffer))); + console.info("read file data successfully"); + console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); }).catch(function(err){ console.info("Failed to read file data. Error:"+ err); }); @@ -1516,8 +1516,9 @@ Asynchronously reads data from a file. This method uses a callback to return the ```js let buf = new ArrayBuffer(4096); fileio.read(buf, function (err, readOut) { - if (!err) { - console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))) + if (readOut) { + console.info("read file data successfully"); + console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); } }); ``` @@ -2407,14 +2408,14 @@ Provides detailed file information. Before calling a method of the **Stat** clas isBlockDevice(): boolean -Checks whether the current directory entry is a block special file. A block special file supports access by block only, and it is cached when accessed. +Checks whether this file is a block special file. A block special file supports access by block only, and it is cached when accessed. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value | Type | Description | | ------- | ---------------- | - | boolean | Whether the directory entry is a block special file.| + | boolean | Whether the file is a block special file.| - Example ```js @@ -2426,14 +2427,14 @@ Checks whether the current directory entry is a block special file. A block spec isCharacterDevice(): boolean -Checks whether the current directory entry is a character special file. A character special file supports random access, and it is not cached when accessed. +Checks whether this file is a character special file. A character special file supports random access, and it is not cached when accessed. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value | Type | Description | | ------- | ----------------- | - | boolean | Whether the directory entry is a character special file.| + | boolean | Whether the file is a character special file.| - Example ```js @@ -2445,14 +2446,14 @@ Checks whether the current directory entry is a character special file. A charac isDirectory(): boolean -Checks whether a directory entry is a directory. +Checks whether this file is a directory. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value | Type | Description | | ------- | ------------- | - | boolean | Whether the directory entry is a directory.| + | boolean | Whether the file is a directory.| - Example ```js @@ -2464,14 +2465,14 @@ Checks whether a directory entry is a directory. isFIFO(): boolean -Checks whether the current directory entry is a named pipe (or FIFO). Named pipes are used for inter-process communication. +Checks whether this file is a named pipe (or FIFO). Named pipes are used for inter-process communication. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value | Type | Description | | ------- | --------------------- | - | boolean | Whether the directory entry is a FIFO.| + | boolean | Whether the file is an FIFO.| - Example ```js @@ -2483,14 +2484,14 @@ Checks whether the current directory entry is a named pipe (or FIFO). Named pipe isFile(): boolean -Checks whether a directory entry is a regular file. +Checks whether this file is a regular file. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value | Type | Description | | ------- | --------------- | - | boolean | Whether the directory entry is a regular file.| + | boolean | Whether the file is a regular file.| - Example ```js @@ -2502,14 +2503,14 @@ Checks whether a directory entry is a regular file. isSocket(): boolean -Checks whether a directory entry is a socket. +Checks whether this file is a socket. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value | Type | Description | | ------- | -------------- | - | boolean | Whether the directory entry is a socket.| + | boolean | Whether the file is a socket.| - Example ```js @@ -2521,14 +2522,14 @@ Checks whether a directory entry is a socket. isSymbolicLink(): boolean -Checks whether a directory entry is a symbolic link. +Checks whether this file is a symbolic link. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value | Type | Description | | ------- | --------------- | - | boolean | Whether the directory entry is a symbolic link.| + | boolean | Whether the file is a symbolic link.| - Example ```js @@ -2731,7 +2732,7 @@ Asynchronously writes data into the stream. This method uses a promise to return ```js let ss= fileio.createStreamSync(fpath, "r+"); ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number){ - console.info("write successfully:"+ number); + console.info("write successfully and size is:"+ number); }).catch(function(err){ console.info("write failed with error:"+ err); }); @@ -2762,9 +2763,9 @@ Asynchronously writes data into the stream. This method uses a callback to retur ```js let ss= fileio.createStreamSync(fpath, "r+"); ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) { - if (!err) { + if (bytesWritten) { // do something - console.log(bytesWritten); + console.info("write successfully and size is:"+ bytesWritten); } }); ``` @@ -2829,6 +2830,7 @@ Asynchronously reads data from the stream. This method uses a promise to return let ss = fileio.createStreamSync(fpath, "r+"); ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readout){ console.info("read data successfully"); + console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); }).catch(function(err){ console.info("read data failed with error:"+ err); }); @@ -2858,8 +2860,9 @@ Asynchronously reads data from the stream. This method uses a callback to return ```js let ss = fileio.createStreamSync(fpath, "r+"); ss.read(new ArrayBuffer(4096),{offset: 1, length: 5, position: 5},function (err, readOut) { - if (!err) { - // do something + if (readOut) { + console.info("read data successfully"); + console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); } }); ``` @@ -2917,7 +2920,7 @@ Asynchronously reads the next directory entry. This method uses a promise to ret ```js let dir = fileio.opendirSync(path); dir.read().then(function (dirent){ - console.info("read successfully:"+ dirent.name); + console.log("read successfully:"+JSON.stringify(dirent)); }).catch(function(err){ console.info("read failed with error:"+ err); }); @@ -2941,9 +2944,9 @@ Asynchronously reads the next directory entry. This method uses a callback to re ```js let dir = fileio.opendirSync(path); dir.read(function (err, dirent) { - if (!err) { + if (dirent) { // do something - console.log(dirent.name) + console.log("read successfully:"+JSON.stringify(dirent)); } }); ``` diff --git a/en/application-dev/reference/apis/js-apis-huks.md b/en/application-dev/reference/apis/js-apis-huks.md index 3d8e138fd13e472bc44da7d892852173f594bedd..790802ba3422dee736f7a6d08ec910b97c9e24b2 100644 --- a/en/application-dev/reference/apis/js-apis-huks.md +++ b/en/application-dev/reference/apis/js-apis-huks.md @@ -362,16 +362,17 @@ Generates a key. This method uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Alias of the key. | | options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. For details about the error codes, see **HuksResult**.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If any other result is returned, see **HuksResult**.| **Example** ```js -var alias = 'alias'; +/* Generate an RSA key of 512 bits. */ +var keyAlias = 'keyAlias'; var properties = new Array(); properties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huksHuksKeyAlg.HUKS_ALG_RSA + value: huks.HuksKeyAlg.HUKS_ALG_RSA }; properties[1] = { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, @@ -379,24 +380,22 @@ properties[1] = { }; properties[2] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + value: +huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | +huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT }; properties[3] = { tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE + value: huks.HuksKeyPadding.HUKS_PADDING_OAEP }; properties[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB -}; -properties[5] = { tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 }; var options = { properties: properties }; -huks.generateKey(alias, options, function (err, data){}); +huks.generateKey(keyAlias, options, function (err, data){}); ``` ## huks.generateKey @@ -418,41 +417,36 @@ Generates a key. This method uses a promise to return the result. | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. For details about the error codes, see **HuksResult**.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.| **Example** ```js -var alias = 'alias'; +/* Generate an ECC key of 256 bits. */ +var keyAlias = 'keyAlias'; var properties = new Array(); properties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huksHuksKeyAlg.HUKS_ALG_RSA + value: huks.HuksKeyAlg.HUKS_ALG_ECC }; properties[1] = { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512 + value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256 }; properties[2] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + value: +huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | +huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY }; properties[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE -}; -properties[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB -}; -properties[5] = { tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 }; var options = { properties: properties }; -var result = huks.generateKey(alias, options); +var result = huks.generateKey(keyAlias, options); ``` ## huks.deleteKey @@ -474,11 +468,12 @@ Deletes a key. This method uses an asynchronous callback to return the result. **Example** ```js -var alias = 'alias'; +/* Set options to emptyOptions. */ +var keyAlias = 'keyAlias'; var emptyOptions = { properties: [] }; -huks.deleteKey(alias, emptyOptions, function (err, data) {}); +huks.deleteKey(keyAlias, emptyOptions, function (err, data) {}); ``` ## huks.deleteKey @@ -494,22 +489,23 @@ Deletes a key. This method uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | ----------- | ---- | ----------------------------------------------------- | | keyAlias | string | Yes | Key alias passed in when the key was generated.| -| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).| +| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).| **Return value** | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. For details about the error codes, see **HuksResult**.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.| **Example** ```js -var alias = 'alias'; +/* Set options to emptyOptions. */ +var keyAlias = 'keyAlias'; var emptyOptions = { properties: [] }; -var result = huks.deleteKey(alias, emptyOptions); +var result = huks.deleteKey(keyAlias, emptyOptions); ``` ## huks.getSdkVersion @@ -535,6 +531,7 @@ Obtains the SDK version of the current system. **Example** ```js +/* Set options to emptyOptions. */ var emptyOptions = { properties: [] }; @@ -560,31 +557,41 @@ Imports a key. This method uses an asynchronous callback to return the result. **Example** ```js +/* Import an AES key of 256 bits. */ +var plainTextSize32 = makeRandomArr(32); +function makeRandomArr(size) { + var arr = new Uint8Array(size); + for (var i = 0; i < size; i++) { + arr[i] = Math.floor(Math.random() * 10); + } + return arr; +}; var keyAlias = 'keyAlias'; var properties = new Array(); properties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DSA + value: huks.HuksKeyAlg.HUKS_ALG_AES }; properties[1] = { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: 1024 + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 }; properties[2] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + value: +huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT }; properties[3] = { tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE + value:huks.HuksKeyPadding.HUKS_PADDING_PKCS7 }; properties[4] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: HUKS_DIGEST_SHA1 + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB }; var options = { properties: properties, - inData: importText + inData: plainTextSize32 }; huks.importKey(keyAlias, options, function (err, data){}); ``` @@ -608,38 +615,50 @@ Imports a key. This method uses a promise to return the result. | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. For details about the error codes, see **HuksResult**.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.| **Example** ```js +/* Import an AES key of 128 bits. */ +var plainTextSize32 = makeRandomArr(32); + +function makeRandomArr(size) { + var arr = new Uint8Array(size); + for (var i = 0; i < size; i++) { + arr[i] = Math.floor(Math.random() * 10); + } + return arr; +}; + +/* Step 1 Generate a key. */ var keyAlias = 'keyAlias'; var properties = new Array(); properties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DSA + value: huks.HuksKeyAlg.HUKS_ALG_AES }; properties[1] = { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: 1024 + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 }; properties[2] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT }; properties[3] = { tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE + value:huks.HuksKeyPadding.HUKS_PADDING_PKCS7 }; properties[4] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: HUKS_DIGEST_SHA1 + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB }; -var options = { +var huksoptions = { properties: properties, - inData: importText + inData: plainTextSize32 }; -var result = huks.importKey(keyAlias, options); +var result = huks.importKey(keyAlias, huksoptions); ``` ## huks.exportKey @@ -656,11 +675,12 @@ Exports a key. This method uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. For details about the error codes, see **HuksResult**.
**outData** contains the public key exported.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. **outData** contains the public key exported.| **Example** ```js +/* Set options to emptyOptions. */ var keyAlias = 'keyAlias'; var emptyOptions = { properties: [] @@ -692,6 +712,7 @@ Exports a key. This method uses a promise to return the result. **Example** ```js +/* Set options to emptyOptions. */ var keyAlias = 'keyAlias'; var emptyOptions = { properties: [] @@ -713,11 +734,12 @@ Obtains key properties. This method uses an asynchronous callback to return the | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. In **errorCode**, **HUKS_SUCCESS** will be returned if the operation is successful; an error code will be returned otherwise. For details about the error codes, see **HuksResult**.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. **HUKS_SUCCESS** will be returned if the operation is successful; an error code will be returned otherwise.| **Example** ```js +/* Set options to emptyOptions. */ var keyAlias = 'keyAlias'; var emptyOptions = { properties: [] @@ -744,11 +766,12 @@ Obtains key properties. This method uses a promise to return the result. | Type | Description | | ------------------ | ------------------------------------------------------------ | -| Promise\<[HuksResult](#huksoptions)> | Promise used to return the result. In **errorCode**, **HUKS_SUCCESS** will be returned if the operation is successful; an error code will be returned otherwise. For details about the error codes, see **HuksResult**.| +| Promise\<[HuksResult](#huksoptions)> | Promise used to return the result. In the return result, **HUKS_SUCCESS** will be returned for **errorCode** if the operation is successful; an error code will be returned otherwise. **properties** returns the parameters required for generating the key.| **Example** ```js +/* Set options to emptyOptions. */ var keyAlias = 'keyAlias'; var emptyOptions = { properties: [] @@ -775,6 +798,7 @@ Checks whether a key exists. This method uses an asynchronous callback to return **Example** ```js +/* Set options to emptyOptions. */ var keyAlias = 'keyAlias'; var emptyOptions = { properties: [] @@ -806,6 +830,7 @@ Checks whether a key exists. This method uses a promise to return the result. **Example** ```js +/* Set options to emptyOptions. */ var keyAlias = 'keyAlias'; var emptyOptions = { properties: [] @@ -814,6 +839,7 @@ var result = huks.isKeyExist(keyAlias, emptyOptions); ``` + ## huks.init init(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void @@ -830,34 +856,6 @@ Initializes a key. This method uses an asynchronous callback to return the resul | options | [HuksOptions](#huksoptions) | Yes | Parameter set of the **Init** operation.| | callback | AsyncCallback\<[HuksHandle](#hukshandle)> | Yes | Callback used to return the handle of the **Init** operation.| -**Example** - -```js -var alias = 'test001' -var properties = new Array(); -properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HksKeyAlg.HKS_ALG_DH -}; -properties[1] = { - tag: huks.HksTag.HKS_TAG_PURPOSE, - value: huks.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE -}; -properties[2] = { - tag: huks.HksTag.HKS_TAG_KEY_SIZE, - value: huks.HksKeySize.HKS_DH_KEY_SIZE_4096 -}; -var options = { - properties: properties -}; -huks.init(alias, options, function(err, data) { - if (err.code !== 0) { - console.log("test init err information: " + JSON.stringify(err)); - } else { - console.log(`test init data: ${JSON.stringify(data)}`); - } -}) -``` ## huks.init @@ -875,39 +873,6 @@ Initializes a key. This method uses a promise to return the result. | options | [HuksOptions](#huksoptions) | Yes | Parameter set of the **Init** operation.| | promise | Promise\<[HuksHandle](#hukshandle)> | Yes | Promise used to return the handle of the **Init** operation.| -**Example** - -```js -var alias = 'test001' -var properties = new Array(); -properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HksKeyAlg.HKS_ALG_DH -}; -properties[1] = { - tag: huks.HksTag.HKS_TAG_PURPOSE, - value: huks.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE -}; -properties[2] = { - tag: huks.HksTag.HKS_TAG_KEY_SIZE, - value: huks.HksKeySize.HKS_DH_KEY_SIZE_4096 -}; -var options = { - properties: properties -}; -huks.init(alias, options).then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`); - handle1 = data.handle1; - handle2 = data.handle2; - handle = { - "handle1": handle1, - "handle2": handle2 - }; -}).catch((err) => { - console.log("test init err information: " + JSON.stringify(err)) -}) -``` - ## huks.update @@ -926,27 +891,6 @@ Updates a key. This method uses an asynchronous callback to return the result. | options | [HuksOptions](#huksoptions) | Yes | Parameter set of the **Update** operation.| | callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result.| -**Example** - -```js -var properties = new Array(); -properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HksKeyAlg.HKS_ALG_DH -}; -properties[1] = { - tag: huks.HksTag.HKS_TAG_PURPOSE, - value: huks.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE -}; -properties[2] = { - tag: huks.HksTag.HKS_TAG_KEY_SIZE, - value: huks.HksKeySize.HKS_DH_KEY_SIZE_4096 -}; -var options = { - properties: properties -}; -huks.update(handle, options, function (err, data){}); -``` ## huks.update @@ -965,27 +909,6 @@ Updates a key. This method uses a promise to return the result. | options | [HuksOptions](#huksoptions) | Yes | Parameter set of the **Update** operation.| | promise | Promise\<[HuksResult](#huksresult)> | Yes| Promise used to return the operation result.| -**Example** - -```js -var properties = new Array(); -properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HksKeyAlg.HKS_ALG_DH -}; -properties[1] = { - tag: huks.HksTag.HKS_TAG_PURPOSE, - value: huks.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE -}; -properties[2] = { - tag: huks.HksTag.HKS_TAG_KEY_SIZE, - value: huks.HksKeySize.HKS_DH_KEY_SIZE_4096 -}; -var options = { - properties: properties -}; -var result = huks.update(handle, options) -``` ## huks.finish @@ -1003,27 +926,6 @@ Completes the key operation and releases resources. This method uses an asynchro | options | [HuksOptions](#huksoptions) | Yes | Parameter set of the **Finish** operation.| | callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result.| -**Example** - -```js -var properties = new Array(); -properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HksKeyAlg.HKS_ALG_DH -}; -properties[1] = { - tag: huks.HksTag.HKS_TAG_PURPOSE, - value: huks.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE -}; -properties[2] = { - tag: huks.HksTag.HKS_TAG_KEY_SIZE, - value: huks.HksKeySize.HKS_DH_KEY_SIZE_4096 -}; -var options = { - properties: properties -}; -huks.finish(handle, options, function (err, data){}); -``` ## huks.finish @@ -1041,28 +943,6 @@ Completes the key operation and releases resources. This method uses a promise t | options | [HuksOptions](#huksoptions) | Yes | Parameter set of the **Finish** operation.| | promise | Promise\<[HuksResult](#HuksResult)> | Yes| Promise used to return the operation result.| -**Example** - -```js -var properties = new Array(); -properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HksKeyAlg.HKS_ALG_DH -}; -properties[1] = { - tag: huks.HksTag.HKS_TAG_PURPOSE, - value: huks.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE -}; -properties[2] = { - tag: huks.HksTag.HKS_TAG_KEY_SIZE, - value: huks.HksKeySize.HKS_DH_KEY_SIZE_4096 -}; -var options = { - properties: properties -}; -var result = huks.finish(handle, options) -``` - ## huks.abort @@ -1083,23 +963,213 @@ Aborts the use of the key. This method uses an asynchronous callback to return t **Example** ```js +/* huks.init, huks.update, and huks.finish must be used together. + * If an error occurs in any of them, huks.abort must be called to terminate the use of the key. + * + * The following uses the callback of an RSA 1024-bit key as an example. + */ +import router from '@system.router'; +import huks from '@ohos.security.huks'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} +var alias = "HuksDemoRSA"; var properties = new Array(); -properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HksKeyAlg.HKS_ALG_DH -}; -properties[1] = { - tag: huks.HksTag.HKS_TAG_PURPOSE, - value: huks.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE -}; -properties[2] = { - tag: huks.HksTag.HKS_TAG_KEY_SIZE, - value: huks.HksKeySize.HKS_DH_KEY_SIZE_4096 -}; var options = { - properties: properties -}; -huks.abort(handle, options, function (err, data){}); + properties: properties, + inData: new Uint8Array(0) +}; +var handle = {}; +var resultMessage = ""; +async function generateKey() { + properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }; + properties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024 + }; + properties[2] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + }; + properties[3] = { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_OAEP + }; + properties[4] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }; + huks.generateKey(alias, options); +} +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + var tmpUint8Array = new Uint8Array(arr); + return tmpUint8Array; +} +async function huksInit() { + await huks.init(alias, options).then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = { + "handle1": data.handle1, + "handle2": data.handle2 + }; + }).catch((err) => { + console.log("test init err information: " + JSON.stringify(err)) + }) +} +async function huksUpdate() { + let count = 2; + for (let i = 0; i < count; i++) { + options.inData = stringToUint8Array("huksHmacTest"); + await huks.update(handle, options).then((data) => { + if (data.errorCode === 0) { + resultMessage += "update success!"; + } else { + resultMessage += "update fail!"; + } + }).catch((err) => { + resultMessage += "update times: " + count + (i + 1) + " fail catch errorMessage:" + JSON.stringify(err) + " " + }); + console.log(resultMessage); + } +} +function huksFinish() { + options.inData = stringToUint8Array("HuksDemoHMAC"); + huks.finish(handle, options).then((data) => { + if (data.errorCode === 0) { + resultMessage = "finish success!"; + } else { + resultMessage = "finish fail errorCode: " + data.errorCode; + } + }).catch((err) => { + resultMessage = "Failed to complete the key operation. catch errorMessage:" + JSON.stringify(err) + }); + console.log(resultMessage); +} +async function huksAbort() { + huks.abort(handle, options).then((data) => { + if (data.errorCode === 0) { + resultMessage = "abort success!"; + } else { + resultMessage = "abort fail errorCode: " + data.errorCode; + } + }).catch((err) => { + resultMessage = "Failed to abort the use of the key. catch errorMessage:" + JSON.stringify(err) + }); + console.log(resultMessage); +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('Tocallback') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + Button() { + Text('generateKey') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + generateKey() + }) + Button() { + Text('huksInit') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + huksInit() + }) + Button() { + Text('huksUpdate') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + huksUpdate() + }) + Button() { + Text('huksFinish') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + huksFinish() + }) + Button() { + Text('huksAbort') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + huksAbort() + }) + } + .width('100%') + .height('100%') + } +} ``` ## huks.abort @@ -1121,23 +1191,216 @@ Aborts the use of the key. This method uses a promise to return the result. **Example** ```js +/* huks.init, huks.update, and huks.finish must be used together. + * If an error occurs in any of them, huks.abort must be called to terminate the use of the key. + * + * The following uses the promise of an RSA 1024-bit key as an example. + */ +import router from '@system.router'; +import huks from '@ohos.security.huks'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +var alias = "HuksDemoRSA"; var properties = new Array(); -properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HksKeyAlg.HKS_ALG_DH -}; -properties[1] = { - tag: huks.HksTag.HKS_TAG_PURPOSE, - value: huks.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE -}; -properties[2] = { - tag: huks.HksTag.HKS_TAG_KEY_SIZE, - value: huks.HksKeySize.HKS_DH_KEY_SIZE_4096 -}; var options = { - properties: properties -}; -var result = huks.abort(handle, options); + properties: properties, + inData: new Uint8Array(0) +}; +var handle = {}; +var resultMessage = ""; +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + var tmpUint8Array = new Uint8Array(arr); + return tmpUint8Array; +} + +async function generateKey() { + properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }; + properties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024 + }; + properties[2] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + }; + properties[3] = { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_OAEP + }; + properties[4] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }; + huks.generateKey(alias, options, function (err, data) { }); +} +async function huksInit() { + return new Promise((resolve, reject) => { + huks.init(alias, options, async function (err, data) { + if (data.errorCode === 0) { + resultMessage = "Initialization successful!" + handle = { + "handle1": data.handle1, + "handle2": data.handle2 + } + } else { + resultMessage = "init fail errorCode: " + data.errorCode + } + }); + }); +} + +async function huksUpdate() { + let count = 2; + for (let i = 0; i < count; i++) { + options.inData = stringToUint8Array("huksHmacTest"); + new Promise((resolve, reject) => { + huks.update(handle, options, function (err, data) { + if (data.errorCode === 0) { + resultMessage += "update success!"; + } else { + resultMessage += "update fail!"; + } + }); + }); + console.log(resultMessage); + } +} + +async function huksFinish() { + options.inData = stringToUint8Array("0"); + new Promise((resolve, reject) => { + huks.finish(handle, options, function (err, data) { + if (data.errorCode === 0) { + resultMessage = "finish success!"; + } else { + resultMessage = "finish fail errorCode: " + data.errorCode; + } + }); + }); +} + +function huksAbort() { + new Promise((resolve, reject) => { + huks.abort(handle, options, function (err, data) { + console.log(`Huks_Demo hmac huksAbort1 data ${JSON.stringify(data)}`); + console.log(`Huks_Demo hmac huksAbort1 err ${JSON.stringify(err)}`); + }); + }); +} +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('to Promise') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + Button() { + Text('generateKey') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + generateKey() + }) + Button() { + Text('huksInit') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + huksInit() + }) + Button() { + Text('huksUpdate') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + huksUpdate() + }) + Button() { + Text('huksFinish') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + huksFinish() + }) + Button() { + Text('huksAbort') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('50%') + .height('10%') + .backgroundColor('#0D9FFB') + .onClick(() => { + huksAbort() + }) + } + .width('100%') + .height('100%') + } +} ``` ## HuksParam diff --git a/en/application-dev/reference/apis/js-apis-statfs.md b/en/application-dev/reference/apis/js-apis-statfs.md index 137f4cbc55ee2a9e0631e9f94e0244730a14ac87..5a4cbbe84de4a253dac594f76a50442de3db3eef 100644 --- a/en/application-dev/reference/apis/js-apis-statfs.md +++ b/en/application-dev/reference/apis/js-apis-statfs.md @@ -1,6 +1,6 @@ # statfs -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -44,9 +44,9 @@ Obtains the number of free bytes of the specified file system in asynchronous mo - Example ```js - let path = "/data"; + let path = "/dev"; statfs.getFreeBytes(path).then(function (number){ - console.info("getFreeBytes successfully:"+ number); + console.info("getFreeBytes promise successfully:"+ number); }).catch(function(err){ console.info("getFreeBytes failed with error:"+ err); }); @@ -71,7 +71,7 @@ Obtains the number of free bytes of the specified file system in asynchronous mo ```js statfs.getFreeBytes(path, function(err, number){ - //do something + console.info("getFreeBytes callback successfully:"+ number); }); ``` @@ -98,9 +98,9 @@ Obtains the total number of bytes of the specified file system in asynchronous m - Example ```js - let path = "/data"; + let path = "/dev"; statfs.getTotalBytes(path).then(function (number){ - console.info("getTotalBytes successfully:"+ number); + console.info("getTotalBytes promise successfully:"+ number); }).catch(function(err){ console.info("getTotalBytes failed with error:"+ err); }); @@ -125,6 +125,6 @@ Obtains the total number of bytes of the specified file system in asynchronous m ```js statfs.getTotalBytes(path, function(err, number){ - //do something + console.info("getTotalBytes callback successfully:"+ number); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md index c8ae2e39fdcd5ef9abcb9062c2abf70315302df8..9ab0755c3c1ec46b9f3ec4d6eff740ffce6530a3 100644 --- a/en/application-dev/reference/apis/js-apis-window.md +++ b/en/application-dev/reference/apis/js-apis-window.md @@ -490,7 +490,7 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Listening type.
Set it to **systemBarTintChange**, which indicates listening for properties changes of the status bar and navigation bar.| - | callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the listened information. | + | callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the information. | - Example @@ -516,7 +516,7 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Listening type.
Set it to **systemBarTintChange**, which indicates listening for properties changes of the status bar and navigation bar.| - | callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the listened information. | + | callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the information. | - Example @@ -934,7 +934,7 @@ Obtains the area where this window cannot be displayed, for example, the system | Name | Type | Mandatory| Description | | -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | - | type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area.**TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| + | type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch. | | callback | AsyncCallback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | - Example @@ -962,7 +962,7 @@ Obtains the area where this window cannot be displayed, for example, the system | Name| Type | Mandatory| Description | | ------ | ------------------------------- | ---- | ------------------------------------------------------------ | - | type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area.**TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| + | type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch. | - Return value @@ -1251,7 +1251,7 @@ Loads content to this window. This API uses an asynchronous callback to return t | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | -------------------- | - | path | string | Yes | Path of the page to which the content will be loaded.| + | path | string | Yes | Path of the page from which the content will be loaded. | | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | - Example @@ -1278,7 +1278,7 @@ Loads content to this window. This API uses a promise to return the result. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------- | - | path | string | Yes | Path of the page to which the content will be loaded.| + | path | string | Yes | Path of the page from which the content will be loaded. | - Return value @@ -1361,7 +1361,7 @@ Enables listening for window size changes. | Name | Type | Mandatory| Description | | -------- | ----------------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Listening type.
Set it to **windowSizeChange**, which indicates listening for window size changes.| - | callback | Callback<[Size](#size)> | Yes | Callback used to return the listened information. | + | callback | Callback<[Size](#size)> | Yes | Callback used to return the information. | - Example @@ -1385,7 +1385,7 @@ Disables listening for window size changes. | Name | Type | Mandatory| Description | | -------- | ----------------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Listening type.
Set it to **windowSizeChange7+**, which indicates listening for window size changes.| - | callback | Callback<[Size](#size)> | No | Callback used to return the listened information. | + | callback | Callback<[Size](#size)> | No | Callback used to return the information. | - Example @@ -1407,7 +1407,7 @@ Enables listening for changes to the area where the window cannot be displayed. | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Listening type.
Set it to **systemAvoidAreaChange**, which indicates listening for changes to the area where the window cannot be displayed.| - | callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the listened information. | + | callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the information. | - Example @@ -1431,7 +1431,7 @@ Disables listening for changes to the area where the window cannot be displayed. | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Listening type.
Set it to **systemAvoidAreaChange**, which indicates listening for changes to the area where the window cannot be displayed.| - | callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the listened information. | + | callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the information. | - Example @@ -1455,7 +1455,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Listening type.
Set it to **keyboardHeightChange**, which indicates listening for keyboard height changes.| - | callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the listened information. | + | callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the information. | - Example @@ -1481,7 +1481,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Listening type.
Set it to **keyboardHeightChange**, which indicates listening for keyboard height changes.| - | callback | Callback<number> | No | Callback used to return the listened information. | + | callback | Callback<number> | No | Callback used to return the information. | - Example diff --git a/en/device-dev/quick-start/Readme-EN.md b/en/device-dev/quick-start/Readme-EN.md index a95d57b8143f6d9d41c8b4612f7e421a74796e21..93481265a2d9310ffdb1818a4393804f0fe37b2e 100644 --- a/en/device-dev/quick-start/Readme-EN.md +++ b/en/device-dev/quick-start/Readme-EN.md @@ -12,7 +12,7 @@ - [Burning](quickstart-ide-lite-steps-hi3861-burn.md) - [Networking](quickstart-ide-lite-steps-hi3861-netconfig.md) - [Debugging and Verification](quickstart-ide-lite-steps-hi3861-debug.md) - - [Running](quickstart-ide-lite-steps-hi3816-running.md) + - [Running](quickstart-ide-lite-steps-hi3861-running.md) - Hi3516 Development Board - [Writing a Hello World Program](quickstart-ide-lite-steps-hi3516-application-framework.md) - [Building](quickstart-ide-lite-steps-hi3516-building.md) diff --git a/en/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md b/en/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md index 8c482fb6e0fe688c52e6dcca1dfeda2ed9a53380..5505b7a89788aafaf1a4ed41326792bf62e4f871 100644 --- a/en/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md +++ b/en/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md @@ -24,7 +24,7 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G 1. Make sure the Ubuntu shell environment is **bash**. 1. Run the following command and check whether the command output is **bash**. If the command output is not **bash**, go to step 2. - + ``` ls -l /bin/sh ``` @@ -32,7 +32,7 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G ![en-us_image_0000001226764302](figures/en-us_image_0000001226764302.png) 2. Start the command-line tool, run the following command, enter your password, and select **No** to set **Ubuntu shell** to **bash**. - + ``` sudo dpkg-reconfigure dash ``` @@ -44,13 +44,13 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G 3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression. 1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.400.zip** to the actual software package name. - + ``` unzip devicetool-linux-tool-3.0.0.400.zip ``` 2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.400.sh** to the actual installation file name. - + ``` chmod u+x devicetool-linux-tool-3.0.0.400.sh ``` @@ -60,7 +60,7 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python. - + ``` sudo ./devicetool-linux-tool-3.0.0.400.sh ``` @@ -126,19 +126,19 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server. - + ``` sudo apt-get install openssh-server ``` 2. Run the following command to start the SSH service: - + ``` sudo systemctl start ssh ``` 3. Run the following command to obtain the IP address of the current user for remote access to the Ubuntu environment from Windows: - + ``` ifconfig ``` @@ -148,7 +148,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits ### Installing Remote SSH -1. Open Visual Studio Code in Windows, click ![en-us_image_0000001239080359](figures/en-us-cn_image_0000001239080359.png), and search for **remote-ssh** in the Extension Marketplace. +1. Open Visual Studio Code in Windows, click ![en-us_image_0000001239080359](figures/en-us_image_0000001239080359.png), and search for **remote-ssh** in the Extension Marketplace. ![en-us_image_0000001193920448](figures/en-us_image_0000001193920448.png) @@ -187,7 +187,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits After the preceding operations are complete, you can remotely connect to the Ubuntu environment through Windows for development. However, you need to frequently enter the remote connection password. To eliminate this need, you can use the SSH public key. 1. Open the Git bash CLI and run the following command to generate an SSH public key. During command execution, perform operations as prompted. Set **username** and **ip** to the user name and IP address you use for connecting to the Ubuntu system. - + ``` ssh-keygen -t rsa ssh-copy-id -i ~/.ssh/id_rsa.pub username@ip diff --git a/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-burn.md b/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-burn.md index e80143299bf65cb4693d77413af5b60932011f37..3ebd031b51f4d1b0273c1ccb45990b0293c43436 100644 --- a/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-burn.md +++ b/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-burn.md @@ -53,4 +53,4 @@ Hi3861 V100 supports burning through the serial port. To burn source code throug 10. Wait until the burning is complete. When the following message is displayed, the burning is successful. - ![en-us_image_0000001216761476](figures/en-us_image_0000001216761476.png) + ![en-us_image_0000001216761476](figures/en-us_image_0000001216761476.png) \ No newline at end of file diff --git a/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3816-running.md b/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-running.md similarity index 100% rename from en/device-dev/quick-start/quickstart-ide-lite-steps-hi3816-running.md rename to en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-running.md diff --git a/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861.md b/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861.md index 0c22b10cbab66b1c784ccbe56e239f77970add95..76066f541d0deb0be63aa4906d7edcfe6cf4f769 100644 --- a/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861.md +++ b/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861.md @@ -12,4 +12,4 @@ - **[Debugging and Verification](quickstart-ide-lite-steps-hi3861-debug.md)** -- **[Running](quickstart-ide-lite-steps-hi3816-running.md)** +- **[Running](quickstart-ide-lite-steps-hi3861-running.md)** diff --git a/en/device-dev/quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md b/en/device-dev/quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md index e394e476263d107815b0f6da6a02ad8f5a2b2353..affb9ae21b952f76b1e992e959630493abc90e43 100644 --- a/en/device-dev/quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md +++ b/en/device-dev/quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md @@ -25,7 +25,7 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G 1. Make sure the Ubuntu shell environment is **bash**. 1. Run the following command and check whether the command output is **bash**. If the command output is not **bash**, go to step 2. - + ``` ls -l /bin/sh ``` @@ -33,7 +33,7 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G ![en-us_image_0000001226764302](figures/en-us_image_0000001226764302.png) 2. Start the command-line tool, run the following command, enter your password, and select **No** to set **Ubuntu shell** to **bash**. - + ``` sudo dpkg-reconfigure dash ``` @@ -45,12 +45,12 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G 3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression. 1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.400.zip** to the actual software package name. - + ``` unzip devicetool-linux-tool-3.0.0.400.zip ``` 2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.400.sh** to the actual installation file name. - + ``` chmod u+x devicetool-linux-tool-3.0.0.400.sh ``` @@ -60,7 +60,7 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python. - + ``` sudo ./devicetool-linux-tool-3.0.0.400.sh ``` @@ -126,19 +126,19 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server. - + ``` sudo apt-get install openssh-server ``` 2. Run the following command to start the SSH service: - + ``` sudo systemctl start ssh ``` 3. Run the following command to obtain the IP address of the current user for remote access to the Ubuntu environment from Windows: - + ``` ifconfig ``` @@ -148,7 +148,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits ### Installing Remote SSH -1. Open Visual Studio Code in Windows, click ![en-us_image_0000001239080359](figures/en-us-cn_image_0000001239080359.png), and search for **remote-ssh** in the Extension Marketplace. +1. Open Visual Studio Code in Windows, click ![en-us_image_0000001239080359](figures/en-us_image_0000001239080359.png), and search for **remote-ssh** in the Extension Marketplace. ![en-us_image_0000001193920448](figures/en-us_image_0000001193920448.png) @@ -187,7 +187,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits After the preceding operations are complete, you can remotely connect to the Ubuntu environment through Windows for development. However, you need to frequently enter the remote connection password. To eliminate this need, you can use the SSH public key. 1. Open the Git bash CLI and run the following command to generate an SSH public key. During command execution, perform operations as prompted. Set **username** and **ip** to the user name and IP address you use for connecting to the Ubuntu system. - + ``` ssh-keygen -t rsa ssh-copy-id -i ~/.ssh/id_rsa.pub username@ip diff --git a/en/device-dev/quick-start/quickstart-lite-env-setup-linux.md b/en/device-dev/quick-start/quickstart-lite-env-setup-linux.md deleted file mode 100644 index 826404d57653e3b269d24f22d888f4c4907c0dfc..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-env-setup-linux.md +++ /dev/null @@ -1,248 +0,0 @@ -# Setting Up Ubuntu Development Environment - -Operating system: 64-bit version of Ubuntu 16.04 or later. - -Perform the following steps to set up the development environment: - -1. Obtain source code. -2. Install necessary libraries and tools. -3. Install Python3. -4. Install LLVM \(required only for OpenHarmony\_v1.x\). -5. Install hb. - ->![](../public_sys-resources/icon-notice.gif) **NOTICE:** ->- Docker is provided for the Ubuntu build environment, which encapsulates related build tools. If you use Docker to prepare the build environment, you do not need to perform the following steps in this section. For details, see [Using Docker to Prepare the Build Environment](../get-code/gettools-acquire.md#section107932281315). ->- By default, basic software, such as Samba and Vim, is installed in the system. Adaptation on the software is required to support file sharing between the Linux server and the Windows workstation. ->- For details about the compilation and building subsystem of OpenHarmony, see [Compilation and Building Overview](../subsystems/subsys-build-mini-lite.md). - -## Obtaining Source Code and Tools - -The following table describes the tools and source code required for setting up the general environment for a Linux server and how to obtain these tools and the source code. - -**Table 1** Source code and development tools and their obtaining methods - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Item

-

Description

-

How to Obtain

-

Source code

-

Develops functions.

-

See Source Code Acquisition.

-

Necessary libraries and tools

-

Used for compilation (such as packaging and image creation).

-

Internet

-

Python3.7+

-

Executes script compilation.

-

Internet

-

LLVM (required only for OpenHarmony_v1.x)

-

Functions as the compiler toolchain.

-

Internet

-

hb

-

Compiles the OpenHarmony source code.

-

Internet

-
- ->![](../public_sys-resources/icon-notice.gif) **NOTICE:** ->- If you acquire the source code using an HPM component or HPM CLI tool, you do not need to install compilation tools like **gn** and **ninja**. ->- \(Recommended\) If you obtain the source code via the mirror site or code repository, install compilation tools such as **gn**, **ninja**, and LLVM. When installing these tools, ensure that their environment variable paths are unique. - -## Obtaining Source Code - -You need to acquire [source code](../get-code/sourcecode-acquire.md), download it on a Linux server, and decompress it. - -## Installing Necessary Libraries and Tools - -Run the following command to install the libraries and tools required for compilation: - -``` -sudo apt-get install build-essential gcc g++ make zlib* libffi-dev e2fsprogs pkg-config flex bison perl bc openssl libssl-dev libelf-dev libc6-dev-amd64 binutils binutils-dev libdwarf-dev u-boot-tools mtd-utils gcc-arm-linux-gnueabi cpio device-tree-compiler -``` - -## Installing Python3 - -1. Start a Linux server. -2. Run the following command to check the Python version: - - ``` - python3 --version - ``` - - If Python version is earlier than 3.7, reinstall Python. Do as follows to install Python, for example, Python 3.8. - - 1. Check the Ubuntu version. - - ``` - cat /etc/issue - ``` - - 2. Install Python based on the Ubuntu version. - - If the Ubuntu version is 18 or later, run the following command: - - ``` - sudo apt-get install python3.8 - ``` - - - If the Ubuntu version is 16, perform the following steps: - - a. Install dependency packages. - - ``` - sudo apt update && sudo apt install software-properties-common - ``` - - b. Add the source of deadsnakes PPA and press **Enter**. - - ``` - sudo add-apt-repository ppa:deadsnakes/ppa - ``` - - c. Install Python 3.8. - - ``` - sudo apt upgrade && sudo apt install python3.8 - ``` - - -3. Set the soft link of **python** and **python3** to **python3.8**. - - ``` - sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 - sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 - ``` - -4. Install and upgrade the Python package management tool \(pip3\) using either of the following methods: - - **Command line:** - - ``` - sudo apt-get install python3-setuptools python3-pip -y - sudo pip3 install --upgrade pip - ``` - - - **Installation package:** - - ``` - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python get-pip.py - ``` - - - -## Installing LLVM \(Required only for OpenHarmony\_v1.x\) - ->![](../public_sys-resources/icon-notice.gif) **NOTICE:** ->When downloading source code under the OpenHarmony\_v1.x branches or tags, perform the operation procedure described in this section to install LLVM 9.0.0. ->When downloading source code under the Master and OpenHarmony\_v2.x branches or tags, skip this section. The hb automatically downloads the latest version of LLVM. - -1. Start a Linux server. -2. [Download LLVM](https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-36191/linux/llvm-linux-9.0.0-36191.tar). -3. Decompress the LLVM installation package to **\~/llvm**. - - ``` - tar -zxvf llvm.tar -C ~/ - ``` - -4. Set an environment variable. - - ``` - vim ~/.bashrc - ``` - - Copy the following command to the last line of the **.bashrc** file, save the file, and exit. - - ``` - export PATH=~/llvm/bin:$PATH - ``` - -5. Validate the environment variable. - - ``` - source ~/.bashrc - ``` - - -## Installing hb - -### Prerequisites - -Python 3.7.4 or later has been installed. For details, see [Installing Python3](#section1238412211211). - -### Installation Procedure - -1. Install **hb**. - - ``` - python3 -m pip install --user ohos-build - ``` - -2. Set an environment variable. - - ``` - vim ~/.bashrc - ``` - - Copy the following command to the last line of the **.bashrc** file, save the file, and exit. - - ``` - export PATH=~/.local/bin:$PATH - ``` - - Update the environment variable. - - ``` - source ~/.bashrc - ``` - -3. Run the **hb -h** command. If the following information is displayed, the installation is successful: - - ``` - usage: hb - - OHOS build system - - positional arguments: - {build,set,env,clean} - build Build source code - set OHOS build settings - env Show OHOS build env - clean Clean output - - optional arguments: - -h, --help Show this help message and exit - ``` - - -### Uninstalling hb - -``` -python3 -m pip uninstall ohos-build -``` - ->![](../public_sys-resources/icon-notice.gif) **NOTICE:** ->If you encounter any problem during the installation, resort to the [FAQs](quickstart-lite-env-setup-faqs.md). - diff --git a/en/device-dev/quick-start/quickstart-lite-env-setup-overview.md b/en/device-dev/quick-start/quickstart-lite-env-setup-overview.md deleted file mode 100644 index 5b5feef48c5ae0f1668069c6cb4fce756fe4b2b6..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-env-setup-overview.md +++ /dev/null @@ -1,10 +0,0 @@ -# Overview - -Use the DevEco Device Tool for development, build, burning, and debugging of OpenHarmony. - -The DevEco Device Tool is currently available on Windows and Ubuntu. This document takes the Windows version as an example. - -For details about how to use the Ubuntu version, see the [HUAWEI DevEco Device Tool User Guide](https://device.harmonyos.com/en/docs/ide/user-guides/service_introduction-0000001050166905). - -The Windows version supports build for the Hi3861 development board only. For other development boards, you should use the Ubuntu version and switch to the Ubuntu platform. The following describes how to set up the development environment and build environment for mini and small OpenHarmony. - diff --git a/en/device-dev/quick-start/quickstart-lite-env-setup-windows.md b/en/device-dev/quick-start/quickstart-lite-env-setup-windows.md deleted file mode 100644 index dc2276c10492f47d318ec9b65b95440f69f4bece..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-env-setup-windows.md +++ /dev/null @@ -1,63 +0,0 @@ -# Setting Up Windows Development Environment - -System requirements: - -- OS: 64-bit Windows 10 -- User name: cannot contain Chinese characters - -## Installing DevEco Device Tool - -DevEco Device Tool is installed in Visual Studio Code as a plug-in and depends on Python, Node.js, and HPM for running. - -DevEco Device Tool supports integrated installation. The DevEco Device Tool setup wizard checks whether the adaptation versions of Visual Studio Code, Python, Node.js and HPM tools have been installed. If any of the tools is not installed, you'll be prompted to select the tool to be automatically installed. - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->Before installing DevEco Device Tool, make sure the user name of the host does not contain Chinese characters. Otherwise, the **DevEco Home** page will be stuck loading and the DevEco Device Tool cannot work. - -1. Log in to the [HarmonyOS Device website](https://device.harmonyos.com/cn/ide#download_beta) with your HUAWEI ID and download DevEco Device Tool V3.0 Beta1 or a later version. If you do not have a HUAWEI ID, [register](https://developer.huawei.com/consumer/en/doc/start/registration-and-verification-0000001053628148) one first. -2. Decompress the DevEco Device Tool package, double-click the installer, and then click **Next**. -3. Set the installation path of DevEco Device Tool and click **Next**. -4. When prompted, select the tools to be automatically installed and click **Next**. - - ![](figures/snap28.png) - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >When the setup wizard detects that a compatible Python version has been installed, it prompts you to select the installed Python version or download the recommended Python version. - -5. In the dialog box shown below, click **Next** to download and install the tools. - - ![](figures/snap8.png) - -6. In the displayed Python setup wizard, select **Add Python 3.8 to PATH** and click **Install Now**. After the installation is complete, click **Close**. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you have selected the compatible Python version installed on your device, the Python setup wizard will not be displayed. In this case, you skip this step. - >If DevEco Device Tool 2.1 Release is installed, the Python version must be 3.8.x. If DevEco Device Tool V3.0 Beta1 or a later version is installed, the Python version must be 3.8.x or 3.9.x. - - ![](figures/snap34.png) - -7. In the Visual Studio Code setup wizard, install Visual Studio Code as prompted. During the installation, select **Add to PATH \(requires shell restart\)**. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you are using the correct version of Visual Studio Code, the Visual Studio Code setup wizard will not be displayed. In this case, you skip this step. - - ![](figures/snap33.png) - -8. In the Node.js setup wizard, retain the default settings and click **Next** until **Finish** is displayed. During the installation, Node.js will automatically set the system Path environment variable to the installation directory of **node.exe**. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you are using the correct version of Node.js, the Node.js setup wizard will not be displayed. In this case, you skip this step. - -9. Wait for the DevEco Device Tool setup wizard to automatically install the HPM and DevEco Device Tool. After the installation is complete, click **Finish** to close the setup wizard. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you are using the correct version of HPM, the setup wizard does not download or install HPM. - -10. Start Visual Studio Code. The C/C++ and CodeLLDB plug-ins on which DevEco Device Tool depends will be automatically installed. After the installation is complete, click ![](figures/button.png) on the left of Visual Studio Code to check whether C/C++, CodeLLDB, and DevEco Device Tool are included in the **INSTALLED** list. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If the C/C++ and CodeLLDB plug-ins fail to be installed, DevEco Device Tool cannot run properly. To solve the issue, see [Installing the C/C++ and CodeLLDB Plug-ins Offline](https://device.harmonyos.com/en/docs/ide/user-guides/offline_plugin_install-0000001074376846). - - ![](figures/deveco-device-tool-install-sucessful.png) - - diff --git a/en/device-dev/quick-start/quickstart-lite-env-setup.md b/en/device-dev/quick-start/quickstart-lite-env-setup.md index fd013b163beb08a634b3f26569b21c42935d67ac..978e50123ceb0baf592c27593c2869c7d232f59f 100644 --- a/en/device-dev/quick-start/quickstart-lite-env-setup.md +++ b/en/device-dev/quick-start/quickstart-lite-env-setup.md @@ -19,7 +19,7 @@ To install the necessary libraries and tools, perform the following steps. On Ubuntu: 1. Run the following **apt-get** command: - + ``` sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales ``` @@ -35,13 +35,13 @@ On Ubuntu: Check the location of Python 3.8: - + ``` which python3.8 ``` Change python and python3 to python3.8. - + ``` sudo update-alternatives --install /usr/bin/python python {python3.8 path} 1 #{Python3.8 path} is the location of Python 3.8 obtained in the previous step. sudo update-alternatives --install /usr/bin/python3 python3 {python3.8 path} 1 #{Python3.8 path} is the location of Python 3.8 obtained in the previous step. @@ -104,14 +104,14 @@ To remotely access the Ubuntu environment through Windows to perform operations 1. Make sure the Ubuntu shell environment is **bash**. 1. Run the following command and check whether the command output is **bash**. If the command output is not **bash**, go to step 2. - + ``` ls -l /bin/sh ``` ![en-us_image_0000001226764302](figures/en-us_image_0000001226764302.png) 2. Start the command-line tool, run the following command, enter your password, and select **No** to set **Ubuntu shell** to **bash**. - + ``` sudo dpkg-reconfigure dash ``` @@ -123,12 +123,12 @@ To remotely access the Ubuntu environment through Windows to perform operations 3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression. 1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.400.zip** to the actual software package name. - + ``` unzip devicetool-linux-tool-3.0.0.400.zip ``` 2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.400.sh** to the actual installation file name. - + ``` chmod u+x devicetool-linux-tool-3.0.0.400.sh ``` @@ -138,7 +138,7 @@ To remotely access the Ubuntu environment through Windows to perform operations > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python. - + ``` sudo ./devicetool-linux-tool-3.0.0.400.sh ``` @@ -158,19 +158,19 @@ To remotely access the Ubuntu environment through Windows to perform operations > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server. - + ``` sudo apt-get install openssh-server ``` 2. Run the following command to start the SSH service: - + ``` sudo systemctl start ssh ``` 3. Run the following command to obtain the IP address of the current user for remote access to the Ubuntu environment from Windows: - + ``` ifconfig ``` @@ -180,7 +180,7 @@ To remotely access the Ubuntu environment through Windows to perform operations ### Installing Remote SSH -1. Open Visual Studio Code in Windows, click ![en-us_image_0000001239080359](figures/en-us-cn_image_0000001239080359.png), and search for **remote-ssh** in the Extension Marketplace. +1. Open Visual Studio Code in Windows, click ![en-us_image_0000001239080359](figures/en-us_image_0000001239080359.png), and search for **remote-ssh** in the Extension Marketplace. ![en-us_image_0000001193920448](figures/en-us_image_0000001193920448.png) @@ -219,7 +219,7 @@ To remotely access the Ubuntu environment through Windows to perform operations After the preceding operations are complete, you can remotely connect to the Ubuntu environment through Windows for development. However, you need to frequently enter the remote connection password. To eliminate this need, you can use the SSH public key. 1. Open the Git bash CLI and run the following command to generate an SSH public key. During command execution, perform operations as prompted. Set **username** and **ip** to the user name and IP address you use for connecting to the Ubuntu system. - + ``` ssh-keygen -t rsa ssh-copy-id -i ~/.ssh/id_rsa.pub username@ip @@ -256,13 +256,13 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony ``` Run the following command to install the tools: - + ``` sudo apt-get install git git-lfs ``` 4. Configure user information. - + ``` git config --global user.name "yourname" git config --global user.email "your-email-address" @@ -270,7 +270,7 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony ``` 5. Run the following commands to install the **repo** tool: - + ``` curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo # If you do not have the access permission to this directory, download the tool to any other accessible directory and configure the directory to the environment variable. chmod a+x /usr/local/bin/repo @@ -295,7 +295,7 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony Method 2: Use the **repo** tool to download the source code over HTTPS. - + ``` repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify repo sync -c @@ -310,7 +310,7 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony ### Running prebuilts Go to the root directory of the source code and run the following script to install the compiler and binary tool: - + ``` bash build/prebuilts_download.sh ``` @@ -326,34 +326,34 @@ Perform the following steps in Ubuntu: ### Install hb. > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> To install a proxy, see [Configuring a Proxy](../quick-start/quickstart-lite-reference.md#configuring-a-proxy). +> To install a proxy, see [Configuring the Proxy](../quick-start/quickstart-lite-reference.md#section6204129143010). 1. Run the following command to install hb and update it to the latest version: - + ``` pip3 install --user build/lite ``` 2. Set the environment variable. - + ``` vim ~/.bashrc ``` Copy the following command to the last line of the .bashrc file, save the file, and exit. - + ``` export PATH=~/.local/bin:$PATH ``` Update the environment variable. - + ``` source ~/.bashrc ``` 3. Run the **hb -h** command in the source code directory. If the following information is displayed, the installation is successful: - + ``` usage: hb @@ -372,7 +372,7 @@ Perform the following steps in Ubuntu: > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE** > - Run the following command to uninstall hb: -> +> > ``` > pip3 uninstall ohos-build > ``` @@ -392,26 +392,26 @@ Perform the following steps in Ubuntu: 2. [Download LLVM](https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-36191/linux/llvm-linux-9.0.0-36191.tar) 3. Decompress the LLVM installation package to **~/llvm**. - + ``` tar -zxvf llvm.tar -C ~/ ``` 4. Set the environment variable. - + ``` vim ~/.bashrc ``` Copy the following command to the last line of the .bashrc file, save the file, and exit. - + ``` export PATH=~/llvm/bin:$PATH ``` 5. Validate the environment variable. - + ``` source ~/.bashrc ``` diff --git a/en/device-dev/quick-start/quickstart-lite-ide-directory.md b/en/device-dev/quick-start/quickstart-lite-ide-directory.md index ba40d1a3798c96010c8ebd16a78d2ea9ed474013..88773504a4830ba8b23f3265f197630b853d8d74 100644 --- a/en/device-dev/quick-start/quickstart-lite-ide-directory.md +++ b/en/device-dev/quick-start/quickstart-lite-ide-directory.md @@ -11,7 +11,7 @@ - [Burning](quickstart-ide-lite-steps-hi3861-burn.md) - [Networking](quickstart-ide-lite-steps-hi3861-netconfig.md) - [Debugging and Verification](quickstart-ide-lite-steps-hi3861-debug.md) - - [Running](quickstart-ide-lite-steps-hi3816-running.md) + - [Running](quickstart-ide-lite-steps-hi3861-running.md) - Hi3516 Development Board - [Writing a Hello World Program](quickstart-ide-lite-steps-hi3516-application-framework.md) - [Building](quickstart-ide-lite-steps-hi3516-building.md) diff --git a/en/device-dev/quick-start/quickstart-lite-introduction-hi3518.md b/en/device-dev/quick-start/quickstart-lite-introduction-hi3518.md deleted file mode 100644 index 384aac6f3f65578a01355895faf7f20e3adb4c91..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-introduction-hi3518.md +++ /dev/null @@ -1,52 +0,0 @@ -# Hi3518 Development Board - -## Introduction - -Hi3518E V300 is a next-generation system on chip \(SoC\) designed for the industry-dedicated smart HD IP camera. It introduces a next-generation image signal processor \(ISP\), the H.265 video compression encoder, and the advanced low-power process and architecture design, leading the industry in terms of low bit rate, high image quality, and low power consumption. - -**Figure 1** Hi3518E V300 front view -![](figures/hi3518e-v300-front-view.png "hi3518e-v300-front-view") - -**Figure 2** Hi3518E V300 rear view -![](figures/hi3518e-v300-rear-view.png "hi3518e-v300-rear-view") - -## Development Board Specifications - -**Table 1** Specifications of the Hi3518 development board - - - - - - - - - - - - - - - - - - - - - - -

Type

-

Description

-

Processor core

-
  • Hi3518E V300
-

Imaging device

-
  • 1/2.9 F23
-

External interfaces

-
  • External microphone
  • External 8 Ω/1.5 W speaker
-

External memory interface

-
  • TF card

    A maximum file size of 128 GB is allowed (FAT32 format).

    -
-

WLAN protocol

-
  • 802.11 b/g/n
-
- diff --git a/en/device-dev/quick-start/quickstart-lite-introduction.md b/en/device-dev/quick-start/quickstart-lite-introduction.md deleted file mode 100644 index 2f95599480263e87e5077096ae36d927d50e4b60..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-introduction.md +++ /dev/null @@ -1,9 +0,0 @@ -# Introduction - -- **[Hi3861 Development Board](quickstart-lite-introduction-hi3861.md)** - -- **[Hi3516 Development Board](quickstart-lite-introduction-hi3516.md)** - -- **[Hi3518 Development Board](quickstart-lite-introduction-hi3518.md)** - - diff --git a/en/device-dev/quick-start/quickstart-lite-reference.md b/en/device-dev/quick-start/quickstart-lite-reference.md index a1bb41dcfd09fd8b5c0419a11cbd8ca6b494c06a..c6fa6d023fbb1468e99b3c2ad2274ec64b5799bf 100644 --- a/en/device-dev/quick-start/quickstart-lite-reference.md +++ b/en/device-dev/quick-start/quickstart-lite-reference.md @@ -5,7 +5,7 @@ 1. Go to the root directory of the source code and run the build command. - + ``` ./build.sh --product-name name --ccache ``` @@ -14,7 +14,7 @@ > _name_ indicates the product name, for example, **Hi3516D V300** and **rk3568**. 2. Check the build result. After the build is complete, the following information is displayed in the log: - + ``` post_process =====build name successful. @@ -25,19 +25,19 @@ > For details about other modular compilation operations, see [Building a Standard System](../subsystems/subsys-build-standard-large.md). -## Configuring the Proxy +## Configuring the Proxy ### Setting Up the Python Proxy 1. Create a proxy configuration file. - + ``` mkdir ~/.pipvim ~/.pip/pip.conf ``` 2. Add the following proxy information to the file, save the file, and exit: - + ``` [global] index-url = http:// Proxy URL @@ -49,20 +49,20 @@ ### Setting Up the npm Proxy 1. Create a proxy configuration file. - + ``` vim ~/.npmrc ``` 2. Add the following proxy information to the file, save the file, and exit: - + ``` Registry=http:// Proxy URL strict-ssl=false ``` 3. Add the following content to the **.bashrc** file, save the file, and exit: - + ``` export NPM_REGISTRY=http:// Proxy URL source .bashrc diff --git a/en/device-dev/quick-start/quickstart-lite-sourcecode-acquire.md b/en/device-dev/quick-start/quickstart-lite-sourcecode-acquire.md deleted file mode 100644 index 3e1f2ec05f12a3b1d1e51d162a6ecd98167b1f0c..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-sourcecode-acquire.md +++ /dev/null @@ -1,50 +0,0 @@ -# Obtaining Source Code - - -## Prerequisites - -1. Register your account with Gitee. -2. Register an SSH public key for access to Gitee. -3. Install the [git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure basic user information. - - ``` - git config --global user.name "yourname" - git config --global user.email "your-email-address" - git config --global credential.helper store - ``` - -4. Run the following commands to install the **repo** tool: - - ``` - curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo # If you do not have the access permission to this directory, download the tool to any other accessible directory and configure the directory to the environment variable. - chmod a+x /usr/local/bin/repo - pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests - ``` - - -## How to Obtain - ->![](../public_sys-resources/icon-note.gif) **NOTE**
->Download the master code if you want to get quick access to the latest features for your development. Download the release code, which is more stable, if you want to develop commercial functionalities. - -- **Obtaining OpenHarmony master code** - - Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to Gitee.\) - - ``` - repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - - Method 2: Use the **repo** tool to download the source code over HTTPS. - - ``` - repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - -- **Obtaining OpenHarmony release code** - - For details about how to obtain the source code of an OpenHarmony release, see the [Release-Notes](../get-code/../../release-notes/Readme.md). diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3516-faqs.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3516-faqs.md deleted file mode 100644 index 98248bf57fd6da21b889d30fb35732c49c9499a1..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3516-faqs.md +++ /dev/null @@ -1,152 +0,0 @@ -# FAQs - -## "Error: Opening COMxx: Access denied" Is Displayed After a Serial Port Is Selected for Burning - -- **Symptom** - - **Error: Opening COMxx: Access denied** is displayed after clicking **Burn** and selecting a serial port. - - ![](figures/failed-to-open-the-serial-port.png) - -- **Possible Causes** - - The serial port has been used. - -- Solution - - The serial port may be in use. Perform the following steps to troubleshoot: - - 1. Search for the serial port from the drop-down list in the **TERMINAL** panel. - - ![](figures/terminal-list.png) - - 2. Click the dustbin for the terminal using the serial port to disable the terminal. - - -## What should I do when Windows-based PC failed to be connected to the board? - -- **Symptom** - - The file image cannot be obtained after clicking **Burn** and selecting a serial port. - - **Figure 1** Failed to obtain the image file due to unavailable connection - ![](figures/failed-to-obtain-the-image-file-due-to-unavailable-connection.png "failed-to-obtain-the-image-file-due-to-unavailable-connection") - -- **Possible Causes** - - The board is disconnected from the Windows-based PC. - - Windows Firewall does not allow Visual Studio Code to access the network. - -- **Solutions** - -1. Check whether the network cable is properly connected. -2. Click **Windows Firewall**. - - ![](figures/hi3516-network-and-firewall-setting.png) - -3. Click **Firewall & network protection**, and on the displayed page, click **Allow applications to communicate through Windows Firewall**. - - ![](figures/hi3516-firewall-and-network-protection.png) - -4. Select the Visual Studio Code application. - - ![](figures/hi3516-selecting-the-visual-studio-code-application.png) - -5. Select the **Private** and **Public** network access rights for the Visual Studio Code application. - - ![](figures/hi3516-allowing-the-visual-studio-code-application-to-access-the-network.png) - - -## What should I do when the image failed to be burnt? - -- **Symptom** - - The burning status is not displayed after clicking **Burn** and selecting a serial port. - -- **Possible Causes** - - The IDE is not restarted after the DevEco plug-in is installed. - -- **Solutions** - - Restart the IDE. - - -## What should I do when the message indicating Python cannot be found is displayed during compilation and building? - -- **Symptom** - - ![](figures/symptom-for-not-finding-python.png) - - -- **Possible Cause 1**: Python is not installed. -- **Solutions** - - [Install Python](../quick-start/quickstart-lite-env-setup-linux.md). - -- **Possible Cause 2**: The soft link that points to the Python does not exist in the usr/bin directory. - - ![](figures/reason-for-not-finding-python.png) - -- **Solutions** - - Run the following commands: - - ``` - # cd /usr/bin/ - # which python3 - # ln -s /usr/local/bin/python3 python - # python --version - ``` - - Example: - - ![](figures/solution.png) - - -## What should I do when no command output is displayed? - -- **Symptom** - - The serial port shows that the connection has been established. After the board is restarted, nothing is displayed when you press **Enter**. - -- **Possible Cause 1** - - The serial port is connected incorrectly. - -- **Solutions** - - Change the serial port number. - - Start **Device Manager** to check whether the serial port connected to the board is the same as that connected to the terminal device. If the serial ports are different, perform step 1 in the **Running an Image** section to change the serial port number. - - -- **Possible Cause 2** - - The U-Boot of the board is damaged. - -- **Solutions** - - Burn the U-Boot. - - If the fault persists after you perform the preceding operations, the U-Boot of the board may be damaged. You can burn the U-Boot by performing the following steps: - - -1. Obtain the U-Boot file. - - >![](../public_sys-resources/icon-notice.gif) **NOTICE:** - >The U-Boot file of the two boards can be obtained from the following paths, respectively. - >Hi3516D V300: **device\\hisilicon\\hispark\_taurus\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3516dv300.bin** - >Hi3518E V300: **device\\hisilicon\\hispark\_aries\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3518ev300.bin** - -2. Burn the U-Boot file by following the procedures for burning a U-Boot file over USB. - - Select the U-Boot files of corresponding development boards for burning by referring to [Programming Flash Memory on the Hi3516](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_upload-0000001052148681)/[Programming Flash Memory on the Hi3518](https://device.harmonyos.com/en/docs/ide/user-guides/hi3518_upload-0000001057313128) - -3. Log in to the serial port after the burning is complete. - - **Figure 2** Serial port displayed after the U-Boot is burnt - ![](figures/serial-port-displayed-after-the-u-boot-is-burnt.png "serial-port-displayed-after-the-u-boot-is-burnt") - - diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3516-program.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3516-program.md deleted file mode 100644 index f4d84ab80397fef3cfac9cd5247876782fd41a4a..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3516-program.md +++ /dev/null @@ -1,494 +0,0 @@ -# Developing a Driver - -This section describes how to develop a driver on the board, including introduction, compilation, burning, and running of the driver. - -## Introduction to Driver - -The following operations take a HDF-based UART driver as an example to show how to add configuration files, code the driver, and compile the code for interactions between the user-space applications and the driver. The driver source code is stored in the **drivers/framework/sample** directory. - -1. Add Configurations. - - Add driver configurations to the HDF driver configuration file \(for example, **device/hisilicon/hi3516dv300/sdk\_liteos/config/uart/uart\_config.hcs**\). - - ``` - root { - platform { - uart_sample { - num = 5; // UART device number - base = 0x120a0000; // Base address of the UART register - irqNum = 38; - baudrate = 115200; - uartClk = 24000000; - wlen = 0x60; - parity = 0; - stopBit = 0; - match_attr = "sample_uart_5"; - } - } - } - ``` - - Add the device node information to the HDF device configuration file \(for example, **vendor/hisilicon/ipcamera\_hi3516dv300\_liteos/config/device\_info/device\_info.hcs**\) - - ``` - root { - device_info { - platform :: host { - hostName = "platform_host"; - priority = 50; - device_uart :: device { - device5 :: deviceNode { - policy = 2; - priority = 10; - permission = 0660; - moduleName = "UART_SAMPLE"; - serviceName = "HDF_PLATFORM_UART_5"; - deviceMatchAttr = "sample_uart_5"; - } - } - } - } - } - ``` - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >The configuration files are in the same path as the source code of the UART driver. You need to manually add the files to the path of the Hi3516D V300 development board. - -2. Register a UART driver entry. - - Register the **HdfDriverEntry** of the UART driver with the HDF. - - ``` - // Bind the UART driver interface to the HDF. - static int32_t SampleUartDriverBind(struct HdfDeviceObject *device) - { - struct UartHost *uartHost = NULL; - - if (device == NULL) { - return HDF_ERR_INVALID_OBJECT; - } - HDF_LOGI("Enter %s:", __func__); - - uartHost = UartHostCreate(device); - if (uartHost == NULL) { - HDF_LOGE("%s: UartHostCreate failed", __func__); - return HDF_FAILURE; - } - uartHost->service.Dispatch = SampleDispatch; - return HDF_SUCCESS; - } - - // Obtain configuration information from the HCS of the UART driver. - static uint32_t GetUartDeviceResource( - struct UartDevice *device, const struct DeviceResourceNode *resourceNode) - { - struct UartResource *resource = &device->resource; - struct DeviceResourceIface *dri = NULL; - dri = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); - if (dri == NULL || dri->GetUint32 == NULL) { - HDF_LOGE("DeviceResourceIface is invalid"); - return HDF_FAILURE; - } - - if (dri->GetUint32(resourceNode, "num", &resource->num, 0) != HDF_SUCCESS) { - HDF_LOGE("uart config read num fail"); - return HDF_FAILURE; - } - if (dri->GetUint32(resourceNode, "base", &resource->base, 0) != HDF_SUCCESS) { - HDF_LOGE("uart config read base fail"); - return HDF_FAILURE; - } - resource->physBase = (unsigned long)OsalIoRemap(resource->base, 0x48); - if (resource->physBase == 0) { - HDF_LOGE("uart config fail to remap physBase"); - return HDF_FAILURE; - } - if (dri->GetUint32(resourceNode, "irqNum", &resource->irqNum, 0) != HDF_SUCCESS) { - HDF_LOGE("uart config read irqNum fail"); - return HDF_FAILURE; - } - if (dri->GetUint32(resourceNode, "baudrate", &resource->baudrate, 0) != HDF_SUCCESS) { - HDF_LOGE("uart config read baudrate fail"); - return HDF_FAILURE; - } - if (dri->GetUint32(resourceNode, "wlen", &resource->wlen, 0) != HDF_SUCCESS) { - HDF_LOGE("uart config read wlen fail"); - return HDF_FAILURE; - } - if (dri->GetUint32(resourceNode, "parity", &resource->parity, 0) != HDF_SUCCESS) { - HDF_LOGE("uart config read parity fail"); - return HDF_FAILURE; - } - if (dri->GetUint32(resourceNode, "stopBit", &resource->stopBit, 0) != HDF_SUCCESS) { - HDF_LOGE("uart config read stopBit fail"); - return HDF_FAILURE; - } - if (dri->GetUint32(resourceNode, "uartClk", &resource->uartClk, 0) != HDF_SUCCESS) { - HDF_LOGE("uart config read uartClk fail"); - return HDF_FAILURE; - } - return HDF_SUCCESS; - } - - // Attach the configuration and interface of the UART driver to the HDF. - static int32_t AttachUartDevice(struct UartHost *host, struct HdfDeviceObject *device) - { - int32_t ret; - struct UartDevice *uartDevice = NULL; - if (device->property == NULL) { - HDF_LOGE("%s: property is NULL", __func__); - return HDF_FAILURE; - } - uartDevice = (struct UartDevice *)OsalMemCalloc(sizeof(struct UartDevice)); - if (uartDevice == NULL) { - HDF_LOGE("%s: OsalMemCalloc uartDevice error", __func__); - return HDF_ERR_MALLOC_FAIL; - } - ret = GetUartDeviceResource(uartDevice, device->property); - if (ret != HDF_SUCCESS) { - (void)OsalMemFree(uartDevice); - return HDF_FAILURE; - } - host->num = uartDevice->resource.num; - host->priv = uartDevice; - AddUartDevice(host); - return InitUartDevice(uartDevice); - } - - // Initialize the UART driver. - static int32_t SampleUartDriverInit(struct HdfDeviceObject *device) - { - int32_t ret; - struct UartHost *host = NULL; - - if (device == NULL) { - HDF_LOGE("%s: device is NULL", __func__); - return HDF_ERR_INVALID_OBJECT; - } - HDF_LOGI("Enter %s:", __func__); - host = UartHostFromDevice(device); - if (host == NULL) { - HDF_LOGE("%s: host is NULL", __func__); - return HDF_FAILURE; - } - ret = AttachUartDevice(host, device); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: attach error", __func__); - return HDF_FAILURE; - } - host->method = &g_sampleUartHostMethod; - return ret; - } - - static void DeinitUartDevice(struct UartDevice *device) - { - struct UartRegisterMap *regMap = (struct UartRegisterMap *)device->resource.physBase; - /* Wait for the UART to enter the idle state. */ - while (UartPl011IsBusy(regMap)); - UartPl011ResetRegisters(regMap); - uart_clk_cfg(0, false); - OsalIoUnmap((void *)device->resource.physBase); - device->state = UART_DEVICE_UNINITIALIZED; - } - - // Detach and release the UART driver. - static void DetachUartDevice(struct UartHost *host) - { - struct UartDevice *uartDevice = NULL; - - if (host->priv == NULL) { - HDF_LOGE("%s: invalid parameter", __func__); - return; - } - uartDevice = host->priv; - DeinitUartDevice(uartDevice); - (void)OsalMemFree(uartDevice); - host->priv = NULL; - } - - // Release the UART driver. - static void SampleUartDriverRelease(struct HdfDeviceObject *device) - { - struct UartHost *host = NULL; - HDF_LOGI("Enter %s:", __func__); - - if (device == NULL) { - HDF_LOGE("%s: device is NULL", __func__); - return; - } - host = UartHostFromDevice(device); - if (host == NULL) { - HDF_LOGE("%s: host is NULL", __func__); - return; - } - if (host->priv != NULL) { - DetachUartDevice(host); - } - UartHostDestroy(host); - } - - struct HdfDriverEntry g_sampleUartDriverEntry = { - .moduleVersion = 1, - .moduleName = "UART_SAMPLE", - .Bind = SampleUartDriverBind, - .Init = SampleUartDriverInit, - .Release = SampleUartDriverRelease, - }; - - HDF_INIT(g_sampleUartDriverEntry); - ``` - -3. Register a UART driver interface. - - Implement the UART driver interface using the template **UartHostMethod** provided by the HDF. - - ``` - static int32_t SampleUartHostInit(struct UartHost *host) - { - HDF_LOGI("%s: Enter", __func__); - if (host == NULL) { - HDF_LOGE("%s: invalid parameter", __func__); - return HDF_ERR_INVALID_PARAM; - } - return HDF_SUCCESS; - } - - static int32_t SampleUartHostDeinit(struct UartHost *host) - { - HDF_LOGI("%s: Enter", __func__); - if (host == NULL) { - HDF_LOGE("%s: invalid parameter", __func__); - return HDF_ERR_INVALID_PARAM; - } - return HDF_SUCCESS; - } - - // Write data into the UART device. - static int32_t SampleUartHostWrite(struct UartHost *host, uint8_t *data, uint32_t size) - { - HDF_LOGI("%s: Enter", __func__); - uint32_t idx; - struct UartRegisterMap *regMap = NULL; - struct UartDevice *device = NULL; - - if (host == NULL || data == NULL || size == 0) { - HDF_LOGE("%s: invalid parameter", __func__); - return HDF_ERR_INVALID_PARAM; - } - device = (struct UartDevice *)host->priv; - if (device == NULL) { - HDF_LOGE("%s: device is NULL", __func__); - return HDF_ERR_INVALID_PARAM; - } - regMap = (struct UartRegisterMap *)device->resource.physBase; - for (idx = 0; idx < size; idx++) { - UartPl011Write(regMap, data[idx]); - } - return HDF_SUCCESS; - } - - // Set the baud rate for the UART device. - static int32_t SampleUartHostSetBaud(struct UartHost *host, uint32_t baudRate) - { - HDF_LOGI("%s: Enter", __func__); - struct UartDevice *device = NULL; - struct UartRegisterMap *regMap = NULL; - UartPl011Error err; - - if (host == NULL) { - HDF_LOGE("%s: invalid parameter", __func__); - return HDF_ERR_INVALID_PARAM; - } - device = (struct UartDevice *)host->priv; - if (device == NULL) { - HDF_LOGE("%s: device is NULL", __func__); - return HDF_ERR_INVALID_PARAM; - } - regMap = (struct UartRegisterMap *)device->resource.physBase; - if (device->state != UART_DEVICE_INITIALIZED) { - return UART_PL011_ERR_NOT_INIT; - } - if (baudRate == 0) { - return UART_PL011_ERR_INVALID_BAUD; - } - err = UartPl011SetBaudrate(regMap, device->uartClk, baudRate); - if (err == UART_PL011_ERR_NONE) { - device->baudrate = baudRate; - } - return err; - } - - // Obtain the baud rate of the UART device. - static int32_t SampleUartHostGetBaud(struct UartHost *host, uint32_t *baudRate) - { - HDF_LOGI("%s: Enter", __func__); - struct UartDevice *device = NULL; - - if (host == NULL) { - HDF_LOGE("%s: invalid parameter", __func__); - return HDF_ERR_INVALID_PARAM; - } - device = (struct UartDevice *)host->priv; - if (device == NULL) { - HDF_LOGE("%s: device is NULL", __func__); - return HDF_ERR_INVALID_PARAM; - } - *baudRate = device->baudrate; - return HDF_SUCCESS; - } - - // Bind the UART device using HdfUartSampleInit. - struct UartHostMethod g_sampleUartHostMethod = { - .Init = SampleUartHostInit, - .Deinit = SampleUartHostDeinit, - .Read = NULL, - .Write = SampleUartHostWrite, - .SetBaud = SampleUartHostSetBaud, - .GetBaud = SampleUartHostGetBaud, - .SetAttribute = NULL, - .GetAttribute = NULL, - .SetTransMode = NULL, - }; - ``` - - Add the sample module of the UART driver to the compilation script **device/hisilicon/drivers/lite.mk**. - - ``` - LITEOS_BASELIB += -lhdf_uart_sample - LIB_SUBDIRS += $(LITEOS_SOURCE_ROOT)/drivers/framework/sample/platform/uart - ``` - -4. Implement the code for interaction between the user-space applications and driver. - - Create the **/dev/uartdev-5** node after the UART driver is initialized successfully. The following example shows how to interact with the UART driver through the node. - - ``` - #include - #include - #include - #include "hdf_log.h" - - #define HDF_LOG_TAG "hello_uart" - #define INFO_SIZE 16 - - int main(void) - { - int ret; - int fd; - const char info[INFO_SIZE] = {" HELLO UART! "}; - - fd = open("/dev/uartdev-5", O_RDWR); - if (fd < 0) { - HDF_LOGE("hello_uart uartdev-5 open failed %d", fd); - return -1; - } - ret = write(fd, info, INFO_SIZE); - if (ret != 0) { - HDF_LOGE("hello_uart write uartdev-5 ret is %d", ret); - } - ret = close(fd); - if (ret != 0) { - HDF_LOGE("hello_uart uartdev-5 close failed %d", fd); - return -1; - } - return ret; - } - ``` - - Add the **hello\_uart\_sample** component to **targets** of the **hdf\_hi3516dv300\_liteos\_a** component in the **build/lite/components/hdf.json** file. - - ``` - { - "components": [ - { - "component": "hdf_hi3516dv300_liteos_a", - ... - "targets": [ - "//drivers/framework/sample/platform/uart:hello_uart_sample" - ] - } - ] - } - ``` - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >Preceding code snippets are for reference only. You can view the complete sample code in **drivers/framework/sample**. - >The sample code is not automatically compiled by default. You can add it to the compilation script. - - -## Building Source Code and Burning Images - -Perform the [building](quickstart-lite-steps-hi3516-running.md#section1077671315253) and [burning](quickstart-lite-steps-hi3516-running.md#section1347011412201) as instructed in **Running a Hello OHOS Program**. - -## Running an Image - -1. Connect to a serial port. - - >![](../public_sys-resources/icon-notice.gif) **NOTICE:** - >If the connection fails, rectify the fault by referring to [FAQs](quickstart-lite-steps-hi3516-faqs.md#section14871149155911). - - **Figure 1** Serial port connection - ![](figures/serial-port-connection.png "serial-port-connection") - - 1. Click **Monitor** to enable the serial port. - 2. Press **Enter** repeatedly until **hisilicon** displays. - 3. Go to step [2](#li109940111259) if the board is started for the first time or the startup parameters need to be modified; go to step [3](#li448312542515) otherwise. - -2. \(Mandatory when the board is started for the first time\) Modify the **bootcmd** and **bootargs** parameters of U-Boot. You need to perform this step only once if the parameters need not to be modified during the operation. The board automatically starts after it is reset. - - >![](../public_sys-resources/icon-notice.gif) **NOTICE:** - >The default waiting time in the U-Boot is 2s. You can press **Enter** to interrupt the waiting and run the **reset** command to restart the system after "hisilicon" is displayed. - - **Table 1** Parameters of the U-Boot - - - - - - - - - - - - - - - - - - - -

Command

-

Description

-

setenv bootcmd "mmc read 0x0 0x80000000 0x800 0x4800; go 0x80000000";

-

Run this command to read content that has a size of 0x4800 (9 MB) and a start address of 0x800 (1 MB) to the memory address 0x80000000. The file size must be the same as that of the OHOS_Image.bin file in the IDE.

-

setenv bootargs "console=ttyAMA0,115200n8 root=emmc fstype=vfat rootaddr=10M rootsize=20M rw";

-

Run this command to set the output mode to serial port output, baud rate to 115200, data bit to 8, rootfs to be mounted to the emmc component, and file system type to vfat.

-

rootaddr=10M rootsize=20M rw indicates the start address and size of the rootfs.img file to be burnt, respectively. The file size must be the same as that of the rootfs.img file in the IDE.

-

saveenv

-

saveenv means to save the current configuration.

-

reset

-

reset means to reset the board.

-
- - >![](../public_sys-resources/icon-notice.gif) **NOTICE:** - >**go 0x80000000** is optional. It indicates that the command is fixed in the startup parameters by default and the board automatically starts after it is reset. If you want to manually start the board, press **Enter** in the countdown phase of the U-Boot startup to interrupt the automatic startup. - -3. Run the **reset** command and press **Enter** to restart the board. After the board is restarted, **OHOS** is displayed when you press **Enter**. - - **Figure 2** System startup - ![](figures/system-startup.png "system-startup") - -4. In the root directory, run the **./bin/hello\_uart** command line to execute the demo program. The compilation result is shown in the following example. - - ``` - OHOS # ./bin/hello_uart - OHOS # HELLO UART! - ``` - - -## Follow-up Learning - -Congratulations! You have finished all steps! You are advised to go on learning how to develop [Cameras with a Screen](../guide/device-iotcamera.md). - diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3518-faqs.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3518-faqs.md deleted file mode 100644 index 0ffca08c5437185237e93fed259b4458e84dbd9c..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3518-faqs.md +++ /dev/null @@ -1,154 +0,0 @@ -# FAQs - -## "Error: Opening COMxx: Access denied" Is Displayed After a Serial Port Is Selected for Burning - -- **Symptom** - - **Error: Opening COMxx: Access denied** is displayed after clicking **Burn** and selecting a serial port. - - ![](figures/failed-to-open-the-serial-port.png) - -- **Possible Causes** - - The serial port has been used. - -- Solution - - The serial port may be in use. Perform the following steps to troubleshoot: - - 1. Search for the serial port from the drop-down list in the **TERMINAL** panel. - - ![](figures/terminal-list.png) - - 2. Click the dustbin for the terminal using the serial port to disable the terminal. - - -## What should I do when Windows-based PC failed to be connected to the board? - -- **Symptom** - - The file image cannot be obtained after clicking **Burn** and selecting a serial port. - - **Figure 1** Failed to obtain the image file due to unavailable connection - ![](figures/failed-to-obtain-the-image-file-due-to-unavailable-connection-0.png "failed-to-obtain-the-image-file-due-to-unavailable-connection-0") - -- **Possible Causes** - - The board is disconnected from the Windows-based PC. - - Windows Firewall does not allow Visual Studio Code to access the network. - -- **Solutions** - -1. Check whether the network cable is properly connected. -2. Click **Windows Firewall**. - - ![](figures/hi3518-network-and-firewall-setting.png) - -3. Click **Firewall & network protection**, and on the displayed page, click **Allow applications to communicate through Windows Firewall**. - - ![](figures/hi3518-firewall-and-network-protection.png) - -4. Select the Visual Studio Code application. - - ![](figures/hi3518-selecting-the-visual-studio-code-application.png) - -5. Select the **Private** and **Public** network access rights for the Visual Studio Code application. - - ![](figures/hi3518-allowing-the-visual-studio-code-application-to-access-the-network.png) - - -## What should I do when the image failed to be burnt? - -- **Symptom** - - The burning status is not displayed after clicking **Burn** and selecting a serial port. - -- **Possible Causes** - - The IDE is not restarted after the DevEco plug-in is installed. - -- **Solutions** - - Restart the IDE. - - -## What should I do when the message indicating Python cannot be found is displayed during compilation and building? - -- **Symptom** - - ![](figures/hi3518-error-for-not-finding-python.png) - - -- **Possible Cause 1** - - Python is not installed. - -- **Solutions** - - [Install Python](../quick-start/quickstart-lite-env-setup-linux.md). - -- **Possible Cause 2**: The soft link that points to the Python does not exist in the usr/bin directory. - - ![](figures/hi3518-reason-no-python-soft-link.png) - -- **Solutions** - - Run the following commands: - - ``` - # cd /usr/bin/ - # which python3 - # ln -s /usr/local/bin/python3 python - # python --version - ``` - - Example: - - ![](figures/hi3518-solution-set-python-soft-link.png) - - -## What should I do when no command output is displayed? - -- **Symptom** - - The serial port shows that the connection has been established. After the board is restarted, nothing is displayed when you press **Enter**. - -- **Possible Cause 1** - - The serial port is connected incorrectly. - -- **Solutions** - - Change the serial port number. - - Start **Device Manager** to check whether the serial port connected to the board is the same as that connected to the terminal device. If the serial ports are different, perform step 1 in the **Running an Image** section to change the serial port number. - - -- **Possible Cause 2** - - The U-Boot of the board is damaged. - -- **Solutions** - - Burn the U-Boot. - - If the fault persists after you perform the preceding operations, the U-Boot of the board may be damaged. You can burn the U-Boot by performing the following steps: - - -1. Obtain the U-Boot file. - - >![](../public_sys-resources/icon-notice.gif) **NOTICE:** - >The U-Boot file of the two boards can be obtained from the following paths, respectively. - >Hi3516D V300: **device\\hisilicon\\hispark\_taurus\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3516dv300.bin** - >Hi3518E V300: **device\\hisilicon\\hispark\_aries\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3518ev300.bin** - -2. Burn the U-Boot file by following the procedures for burning a U-Boot file over USB. - - Select the U-Boot files of corresponding development boards for burning by referring to [Programming Flash Memory on the Hi3516](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_upload-0000001052148681)/[Programming Flash Memory on the Hi3518](https://device.harmonyos.com/en/docs/ide/user-guides/hi3518_upload-0000001057313128) - -3. Log in to the serial port after the burning is complete. - - ![](figures/login-serial-port.png) - - diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md deleted file mode 100644 index 6d16d33c4c096102a81da70cb86ea0b1e84e45b6..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md +++ /dev/null @@ -1,233 +0,0 @@ -# Running a Hello OHOS Program - -This section describes how to create, compile, burn, and run the first program, and finally print **Hello OHOS!** on the develop board. - -## Creating a Program - -1. Create a directory and the program source code. - - Create the **applications/sample/camera/apps/src/helloworld.c** directory and file whose code is shown in the following example. You can customize the content to be printed. For example, you can change **OHOS** to **World**. You can use either C or C++ to develop a program. - - ``` - #include - - int main(int argc, char **argv) - { - printf("\n************************************************\n"); - printf("\n\t\tHello OHOS!\n"); - printf("\n************************************************\n\n"); - - return 0; - } - ``` - -2. Create a build file. - - Create the **applications/sample/camera/apps/BUILD.gn** file. The file content is as follows: - - ``` - import("//build/lite/config/component/lite_component.gni") - lite_component("hello-OHOS") { - features = [ ":helloworld" ] - } - executable("helloworld") { - output_name = "helloworld" - sources = [ "src/helloworld.c" ] - include_dirs = [] - defines = [] - cflags_c = [] - ldflags = [] - } - ``` - -3. Add a component. - - Add the configuration of the **hello\_world\_app** component to the **build/lite/components/applications.json** file. The sample code below shows some configurations defined in the **applications.json** file, and the code between **"\#\#start\#\#"** and **"\#\#end\#\#"** is the new configuration \(Delete the rows where **"\#\#start\#\#"** and **"\#\#end\#\#"** are located after the configurations are added.\) - - ``` - { - "components": [ - { - "component": "camera_sample_communication", - "description": "Communication related samples.", - "optional": "true", - "dirs": [ - "applications/sample/camera/communication" - ], - "targets": [ - "//applications/sample/camera/communication:sample" - ], - "rom": "", - "ram": "", - "output": [], - "adapted_kernel": [ "liteos_a" ], - "features": [], - "deps": { - "components": [], - "third_party": [] - } - }, - ##start## - { - "component": "hello_world_app", - "description": "Communication related samples.", - "optional": "true", - "dirs": [ - "applications/sample/camera/apps" - ], - "targets": [ - "//applications/sample/camera/apps:hello-OHOS" - ], - "rom": "", - "ram": "", - "output": [], - "adapted_kernel": [ "liteos_a" ], - "features": [], - "deps": { - "components": [], - "third_party": [] - } - }, - ##end## - { - "component": "camera_sample_app", - "description": "Camera related samples.", - "optional": "true", - "dirs": [ - "applications/sample/camera/launcher", - "applications/sample/camera/cameraApp", - "applications/sample/camera/setting", - "applications/sample/camera/gallery", - "applications/sample/camera/media" - ], - ``` - -4. Modify the board configuration file. - - Add the **hello\_world\_app** component to the **vendor/hisilicon/hispark\_aries/config.json** file. The sample code below shows the configurations of the **applications** subsystem, and the code between **\#\#start\#\#** and **\#\#end\#\#** is the new configuration \(Delete the rows where **\#\#start\#\#** and **\#\#end\#\#** are located after the configurations are added.\) - - ``` - { - "subsystem": "applications", - "components": [ - ##start## - { "component": "hello_world_app", "features":[] }, - ##end## - { "component": "camera_sample_app", "features":[] } - - ] - }, - ``` - - -## Building - -If the Linux environment is installed using Docker, perform the building by referring to [Using Docker to Prepare the Build Environment](../get-code/gettools-acquire.md#section107932281315). If the Linux environment is installed using a software package, go to the root directory of the source code and run the following commands for source code compilation: - -``` -hb set (Set the building path.) -. (Select the current path.) -Select ipcamera_hispark_aries@hisilicon and press Enter. -hb build -f (Start building.) -``` - -The result files are generated in the **out/hispark\_aries/ipcamera\_hispark\_aries** directory. - -**Figure 1** Hi3518 settings -![](figures/hi3518-settings.png "hi3518-settings") - ->![](../public_sys-resources/icon-notice.gif) **NOTICE:** ->The U-Boot file of the Hi3518E V300 development board can be obtained from the following path: device/hisilicon/hispark\_aries/sdk\_liteos/uboot/out/boot/u-boot-hi3518ev300.bin - -## Burning - -Burning is the process of downloading compiled program files to a chipset development board to provide a basis for subsequent debugging. With the one-click burning function of DevEco Device Tool, you can burn development boards quickly and efficiently. - -You can burn the Hi3518E V300 development board through the USB port or serial port. - -- **Windows system: Supports burning through the USB port or serial port** -- **Linux system: Supports burning through the serial port \(Linux+Windows dual system: Supports burning through the serial port or USB port\)** - -Except for environment setup, the operations of burning are the same for Windows and Linux. - -The following uses the USB port burning as an example. - -1. Connect the PC and the target development board through the serial port and USB port. For details, see [Introduction to the Hi3518 Development Board](https://device.harmonyos.com/en/docs/start/introduce/oem_minitinier_des_3518-0000001105201138). -2. Open Device Manager, then check and record the serial port number corresponding to the development board. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If the serial port number is not displayed correctly, follow the steps described in [Installing the Serial Port Driver on the Hi3516 or Hi3518 Series Development Boards](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_hi3518-drivers-0000001050743695). - - ![](figures/hi3518-record-the-serial-port-number.png) - -3. Open DevEco Device Tool, choose **QUICK ACCESS** \> **DevEco Home** \> **Projects**, and then click **Settings**. - - ![](figures/hi3518-deveco-device-tool-setting.png) - -4. On the **Partition Configuration** tab page, modify the settings. In general cases, you can leave the fields at their default settings. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If the file to be burnt is obtained by copying, you must manually change the path of the file to be burnt: Click the tab of the file to be burnt, select **Partition\_bin** from the **New Option** drop-down list box in **Partition Settings**, and set the path of the file to be burnt in **Partition\_bin**. - -5. On the **hi3518ev300** tab page, set the burning options. - - - **upload\_port**: Select the serial port number obtained in step [2](#en-us_topic_0000001057313128_li46411811196). - - **upload\_protocol**: Select the burning protocol **hiburn-usb**. - - **upload\_partitions**: Select the files to be burnt. By default, the **fastboot**, **kernel**, **rootfs**, and **userfs** files are burnt at the same time. - - ![](figures/upload-options.png) - -6. When you finish modifying, click **Save** in the upper right corner. -7. Open the project file, go to ![](figures/hi3518-deveco-device-tool-logo.png) \> **PROJECT TASKS** \> **hi3518ev300\_fastboot** \> **Erase** to erase U-Boot. - - ![](figures/erase-u-boot.png) - -8. When the following message is displayed, power off the development board and then power it on. - - ![](figures/hi3518-restart-the-development-board.png) - -9. If the following message is displayed, it indicates that U-Boot is erased successfully. - - ![](figures/u-boot-erased-successfully.png) - -10. Go to **hi3518ev300** \> **Upload** to start burning. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If this is the first time you burn the Hi3516D V300 or Hi3518E V300 board, the message "not find the Devices" may be displayed. In this case, follow the steps in [Installing the USB Driver on the Hi3516 or Hi3518 Series Development Boards](https://device.harmonyos.com/en/docs/ide/user-guides/usb_driver-0000001058690393) and start burning again. - - ![](figures/hi3518-upload.png) - -11. If the following message is displayed, it indicates that the burning is successful. - - ![](figures/hi3518-burning-succeeded.png) - -12. When the burning is successful, perform the operations in Running an Image to start the system. - -## Running an Image - -After burning is completed, you need to configure the bootloader to run the OpenHarmony system. - -1. In the Hi3518E V300 task, click **Configure bootloader \(Boot OS\)** to configure the bootloader. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >The bootloader configuration in DevEco Device Tool has been adapted to Hi3518E V300. Therefore, no manual modification is needed. - - ![](figures/hi3518-bootloader.png) - -2. When the message shown below is displayed, restart the development board. If **SUCCESS** is displayed, it indicates that the configuration is successful. - - ![](figures/hi3518-reset-success.png) - -3. Click **Monitor** on the taskbar to start the serial port tool. - - ![](figures/hi3518-monitor.png) - -4. Follow the onscreen instructions until **OHOS \#** is displayed, indicating that the system is started successfully. - - ![](figures/hi3518-reboot-success.png) - - -## Follow-up Learning - -Congratulations! You have finished all steps! You are advised to go on learning how to develop [Cameras with a Screen](../guide/device-iotcamera.md). - diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md deleted file mode 100644 index f1b4e562e84bae067403d0d62d967d758781ecd0..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md +++ /dev/null @@ -1,104 +0,0 @@ -# Setting Up the Environment - -## Environment Requirements - -### Hardware - -- Hi3518E V300 IoT camera development board -- USB-to-serial cable and network cable \(The Windows workstation is connected to the Hi3518E V300 development board through the USB-to-serial cable and network cable.\) - - The following figure shows the hardware connections. - - **Figure 1** Hi3518 hardware connections - ![](figures/hi3518-hardware-connections.png "hi3518-hardware-connections") - - -### Software - ->![](../public_sys-resources/icon-notice.gif) **NOTICE:** ->This section describes how to use an installation package to set up the compilation and development environment. If you are going to use Docker to set up the environment, skip this section and [Installing Linux Build Tools](#section8831868501). - -The following table describes the tools required for setting up the general environment for a Linux server of the Hi3518 development board and how to obtain these tools. - -**Table 1** Development tools and obtaining methods - - - - - - - - - - - - - - - - - - - - -

Development Tool

-

Description

-

How to Obtain

-

bash

-

Processes CLI commands.

-

System configuration

-

Basic software package for compilation and building (required only for Ubuntu 20+)

-

Provides a basic software package for compilation and building.

-

Internet

-

dosfstools, mtools, and mtd-utils

-

Pack files.

-

apt-get install

-
- -## Installing Linux Build Tools - ->![](../public_sys-resources/icon-notice.gif) **NOTICE:** ->- If you acquire the source code using an HPM component or HPM CLI tool, you do not need to install **hc-gen**. ->- \(Recommended\) If you obtain the source code via the mirror site or code repository, install **hc-gen**. When installing the compilation tool, ensure that its environment variable path is unique. - -### Changing Linux Shell to Bash - -Check whether bash is used as the shell. - -``` -ls -l /bin/sh -``` - -If **/bin/sh -\> bash** is not displayed, do as follows to change shell to bash. - -**Method 1:** Run the following command on the device and then click **No**. - -``` -sudo dpkg-reconfigure dash -``` - -**Method 2:** Run the first command to delete **sh** and then run the second command to create a new soft link. - -``` -sudo rm -rf /bin/sh -sudo ln -s /bin/bash /bin/sh -``` - -### Installing Basic Software Used for Compilation and Building \(Required Only for Ubuntu 20+\) - -Install the software. - -``` -sudo apt-get install build-essential gcc g++ make zlib* libffi-dev -``` - -### Installing File Packing Tools - -1. Start a Linux server. -2. Install dosfstools, mtools, and mtd-utils. - - ``` - sudo apt-get install dosfstools mtools mtd-utils - ``` - - diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3518.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3518.md deleted file mode 100644 index c9b43c657d9a8306aead9d7f6b817da3050f13b0..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3518.md +++ /dev/null @@ -1,9 +0,0 @@ -# Hi3518 - -- **[Setting Up the Environment](quickstart-lite-steps-hi3518-setting.md)** - -- **[Running a Hello OHOS Program](quickstart-lite-steps-hi3518-running.md)** - -- **[FAQs](quickstart-lite-steps-hi3518-faqs.md)** - - diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md index 41c5b7ae4154042585c3dc5cb075ecaf315dc935..5a2d1a31a5d0ebfe4a890f41441e0aab0f37061d 100644 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md +++ b/en/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md @@ -87,4 +87,4 @@ After the source code is imported, perform the following steps: 10. Wait until the burning is complete. When the following message is displayed, the burning is successful. - ![en-us_image_0000001216761476](figures/en-us_image_0000001216761476.png) + ![en-us_image_0000001216761476](figures/en-us_image_0000001216761476.png) \ No newline at end of file diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3861-connection.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3861-connection.md deleted file mode 100644 index c1ef04f6545a6c7a98a37798118c4d1678a45dee..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3861-connection.md +++ /dev/null @@ -1,131 +0,0 @@ -# Setting Up WLAN Connection - -This example shows how to connect the WLAN module to the gateway using attention \(AT\) commands. - -## Building Source Code - -This section describes how to perform the WLAN module building on a Linux server. - -If the Linux environment is installed using Docker, perform the building by referring to [Using Docker to Prepare the Build Environment](../get-code/gettools-acquire.md#section107932281315). If the Linux environment is installed using a software package, perform the following steps: - -1. Open the HUAWEI DevEco Device Tool and choose **View** \> **Terminal**. - - **Figure 1** Starting the IDE terminal tool - ![](figures/starting-the-ide-terminal-tool.png "starting-the-ide-terminal-tool") - - On the **TERMINAL** panel, run the ssh command, for example, **ssh** **_user_@_ipaddr_**, to connect to the Linux server. - - **Figure 2** TERMINAL panel - ![](figures/terminal-panel.png "terminal-panel") - -2. Go to the root directory of the code, run the **hb set** and **.** commands on the **TERMINAL** panel, and select the **wifiiot\_hispark\_pegasus** version. - - **Figure 3** Selecting the target build version - ![](figures/selecting-the-target-build-version.png "selecting-the-target-build-version") - -3. Run the **hb build** command to start building. - - **Figure 4** Running commands on the TERMINAL panel - ![](figures/running-commands-on-the-terminal-panel.png "running-commands-on-the-terminal-panel") - -4. Check whether the building is successful. If yes, **wifiiot\_hispark\_pegasus build success** will be displayed, as shown in the following figure. - - **Figure 5** Successful building - ![](figures/successful-building.png "successful-building") - -5. Check whether the following files are generated in the **./out/wifiiot/** directory. - - ``` - ls -l out/hispark_pegasus/wifiiot_hispark_pegasus/ - ``` - - **Figure 6** Directory for storing the generated files - ![](figures/directory-for-storing-the-generated-files.png "directory-for-storing-the-generated-files") - - -## Burning Images - -Burning is the process of downloading compiled program files to a chipset development board to provide a basis for subsequent debugging. With the one-click burning function of DevEco Device Tool, you can burn development boards quickly and efficiently. - -**You can burn to the Hi3861 V100 development board through the serial port using the burn-serial or hiburn-serial protocol. The hiburn-serial protocol is applicable to both Windows and Linux systems, while the burn-serial is applicable to Linux only.** - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The burn-serial protocol is used for compatibility with the projects of historical versions. It does not differ from hiburn-serial in operations. - -The operations for burning in Windows and Linux are the same. The only difference lies in the environment setup for DevEco Device Tool. - -1. Connect the PC and the target development board through the USB port. For details, see [Introduction to the Hi3861 Development Board](https://device.harmonyos.com/en/docs/start/introduce/oem_minitinier_des_3861-0000001105041324). -2. Open Device Manager, then check and record the serial port number corresponding to the development board. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If the serial port number is not displayed correctly, follow the steps described in [Installing the Serial Port Driver on the Hi3861 Series Development Board](https://device.harmonyos.com/en/docs/ide/user-guides/hi3861-drivers-0000001058153433). - - ![](figures/hi3861-record-the-serial-port-number.png) - -3. Open DevEco Device Tool, choose **QUICK ACCESS** \> **DevEco Home** \> **Projects**, and then click **Settings**. - - ![](figures/hi3861-deveco-device-tool-setting.png) - -4. On the **Partition Configuration** tab page, modify the settings. In general cases, you can leave the fields at their default settings. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If the file to be burnt is obtained by copying, you must manually change the path of the file to be burnt: Click the tab of the file to be burnt, select **Partition\_bin** from the **New Option** drop-down list box in **Partition Settings**, and set the path of the file to be burnt in **Partition\_bin**. - -5. On the **hi3861** tab page, set the burning options. - - - **upload\_port**: Select the serial port number obtained in step [2](#en-us_topic_0000001056563976_li848662117291). - - **upload\_protocol**: Select the burning protocol. For Windows, set this parameter to **burn-serial** or **hiburn-serial**. For Linux, set this parameter to **hiburn-serial**. - - **upload\_partitions**: Select the files to be burnt. **hi3861\_app** is selected by default. - - ![](figures/options.png) - -6. When you finish modifying, click **Save** in the upper right corner. -7. Open the project file. In the DevEco Device Tool window, go to **PROJECT TASKS** \> **hi3861** \> **Upload** to start burning. - - ![](figures/hi3861-upload.png) - -8. When the following information is displayed, press the RST button on the development board to restart it. - - ![](figures/hi3861-restart-the-development-board.png) - -9. If the following message is displayed, it indicates that the burning is successful. - - ![](figures/hi3861-burning-succeeded.png) - - -## Connecting WLAN Module to the Internet. - -After completing version building and burning, do as follows to connect the WLAN module to the Internet using AT commands. - -1. Click the icon of **DevEco: Serial Monitor** at the bottom of DevEco Studio to keep the connection between the Windows workstation and the WLAN module. - - **Figure 7** Opening the DevEco serial port - ![](figures/opening-the-deveco-serial-port.png "opening-the-deveco-serial-port") - -2. Reset the WLAN module. The message **ready to OS start** is displayed on the **TERMINAL** panel, indicating that the WLAN module is started successfully. - - **Figure 8** Successful resetting of the WLAN module - ![](figures/successful-resetting-of-the-wlan-module.png "successful-resetting-of-the-wlan-module") - -3. Run the following AT commands in sequence via the DevEco serial port terminal to start the STA mode, connect to the specified AP, and enable Dynamic Host Configuration Protocol \(DHCP\). - - ``` - AT+STARTSTA # Start the STA mode. - AT+SCAN # Scan for available APs. - AT+SCANRESULT # Display the scanning result. - AT+CONN="SSID",,2,"PASSWORD" # Connect to the specified AP. (SSID and PASSWORD represent the name and password of the hotspot to be connected, respectively.) - AT+STASTAT # View the connection result. - AT+DHCP=wlan0,1 # Request the IP address of wlan0 from the AP using DHCP. - ``` - -4. Check whether the WLAN module is properly connected to the gateway, as shown in the following figure. - - ``` - AT+IFCFG # View the IP address assigned to an interface of the module. - AT+PING=X.X.X.X # Check the connectivity between the module and the gateway. Replace X.X.X.X with the actual gateway address. - ``` - - **Figure 9** Successful networking of the WLAN module - ![](figures/successful-networking-of-the-wlan-module.png "successful-networking-of-the-wlan-module") - - diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3861-faqs.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3861-faqs.md deleted file mode 100644 index 3d9f4c7890205090e788c746bcfa9b953961f028..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3861-faqs.md +++ /dev/null @@ -1,291 +0,0 @@ -# FAQs - -## What should I do when the message **configure: error: no acceptable C compiler found in $PATH** is displayed during Python 3 installation? - -- **Symptom** - - The following error occurs during Python 3 installation: - - ``` - configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details - ``` - -- **Possible Causes** - - **GCC** is not installed. - -- **Solutions** - - 1. Run the **apt-get install gcc** command to install **GCC** online. - - 2. After the installation, reinstall Python 3. - - -## What should I do when the message **-bash: make: command not found** is displayed during Python 3 installation? - -- **Symptom** - - The following error occurs during Python 3 installation: - - ``` - -bash: make: command not found - ``` - -- **Possible Causes** - - **Make** is not installed. - -- **Solutions** - - 1. Run the **apt-get install make** command to install **Make** online. - - 2. After the installation, reinstall Python 3. - - -## What should I do when the message **zlib not available** is displayed during Python 3 installation? - -- **Symptom** - - The following error occurs during Python 3 installation: - - ``` - zipimport.ZipImportError: can't decompress data; zlib not available - ``` - -- **Possible Causes** - - **zlib** is not installed. - -- **Solutions** - - Solution 1: Run the **apt-get install zlib** command to install **zlib** online. - - Solution 2: If the software source does not contain **zlib**, download the source code from [http://www.zlib.net/](http://www.zlib.net/). - - ![](figures/download-zlib.png) - - Then run the following commands to install **zlib** offline: - - ``` - # tar xvf zlib-1.2.11.tar.gz - # cd zlib-1.2.11 - # ./configure - # make && make install - ``` - - After the installation, reinstall Python 3. - - -## What should I do when the message **No module named '\_ctypes'** is displayed during Python 3 installation? - -- **Symptom** - - The following error occurs during Python 3 installation: - - ``` - ModuleNotFoundError: No module named '_ctypes' - ``` - - -- **Possible Causes** - - **libffi** and **libffi-devel** are not installed. - - -- **Solutions** - - 1. Run the **apt-get install libffi\* -y** command to install **libffi** and **libffi-devel** online. - - 2. After the installation, reinstall Python 3. - - -## What should I do when the message **No module named 'Crypto'** is displayed during compilation and building? - -- **Symptom** - - The following error occurs during compilation and building: - - ``` - ModuleNotFoundError: No module named 'Crypto' - ``` - - -- **Possible Causes** - - **Crypto** is not installed. - - -- **Solutions** - - Solution 1: Run the **pip3 install Crypto** command to install **Crypto** online. - - Solution 2: Install **Crypto** offline. - - - Download the source code from [https://pypi.org/project/pycrypto/\#files](https://pypi.org/project/pycrypto/#files). - - ![](figures/download-the-source-code.png) - - - Save the source code package to the Linux server, decompress the package, and run the **python3 setup.py install** command to install **Crypto**. - - Rebuild an environment. - - -## What should I do when the message **No module named 'ecdsa'** is displayed during compilation and building? - -- **Symptom** - - The following error occurs during compilation and building: - - ``` - ModuleNotFoundError: No module named 'ecdsa' - ``` - - -- **Possible Causes** - - **ecdsa** is not installed. - - -- **Solutions** - - Solution 1: Run the **pip3 install ecdsa** command to install **ecdsa** online. - - Solution 2: Install **ecdsa** offline. - - - Download the installation package from [https://pypi.org/project/ecdsa/\#files](https://pypi.org/project/ecdsa/#files). - - ![](figures/download-ecdsa.png) - - - Save the installation package to the Linux server and run the **pip3 install ecdsa-0.15-py2.py3-none-any.whl** command to install **ecdsa**. - - Rebuild an environment. - - -## What should I do when the message **Could not find a version that satisfies the requirement six\>=1.9.0** is displayed during compilation and building? - -- **Symptom** - - The following error occurs during compilation and building: - - ``` - Could not find a version that satisfies the requirement six>=1.9.0 - ``` - - -- **Possible Causes** - - **six** is not installed. - - -- **Solutions** - - Solution 1: Run the **pip3 install six** command to install **six** online. - - Solution 2: Install **six** offline. - - - Download the installation package from [https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files). - - ![](figures/download-six.png) - - - Save the source code to the Linux server and run the **pip3 install six-1.14.0-py2.py3-none-any.whl** command to install **six**. - - Rebuild an environment. - - -## What should I do when the message **cannot find -lgcc** is displayed during compilation and building? - -- **Symptom** - - The following error occurs during compilation and building: - - ``` - riscv32-unknown-elf-ld: cannot find -lgcc - ``` - - -- **Possible Causes** - - The PATH is incorrectly written by **gcc\_riscv32**. There is an extra slash \(/\). - - ``` - ~/gcc_riscv32/bin/:/data/toolchain/ - ``` - - -- **Solutions** - - Modify the PATH by deleting the slash \(/\). - - ``` - ~/gcc_riscv32/bin:/data/toolchain/ - ``` - - -## What should I do when the message indicating Python cannot be found is displayed during compilation and building? - -- **Symptom** - - The following error occurs during compilation and building: - - ``` - -bash: /usr/bin/python: No such file or directory - ``` - - -- **Possible Cause 1:** Python is not installed. -- **Solutions** - - [Install Python](../quick-start/quickstart-lite-env-setup-linux.md). - -- **Possible Cause 2:** The soft link that points to the Python does not exist in the **usr/bin** directory. - - ![](figures/reason-no-python-soft-link.png) - -- **Solutions** - - Run the following commands to add a soft link: - - ``` - # cd /usr/bin/ - # which python3 - # ln -s /usr/local/bin/python3 python - # python --version - ``` - - Example: - - ![](figures/solution-add-soft-link.png) - - -## What should I do when the message indicating Python3 cannot be found is displayed during compilation and building? - -- **Symptom** - - ![](figures/11.png) - - -- **Possible Causes** - - Python 3 is not installed. - -- **Solutions** - - [Install Python](../quick-start/quickstart-lite-env-setup-linux.md). - - -## What should I do when an error with **lsb\_release** occurs during **kconfiglib** installation? - -- **Symptom** - - The following error occurs during **kconfiglib** installation: - - ``` - subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1. - ``` - -- **Possible Causes** - - The Python version matched with the **lsb\_release** module is different from the current Python version. - -- **Solutions** - - Run the **find / -name lsb\_release** command, for example, **sudo rm -rf /usr/bin/lsb\_release** to locate and delete **lsb\_release**. - - diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md deleted file mode 100644 index ba2c045de307429e49dcf4ddef31b602eabaa8cf..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md +++ /dev/null @@ -1,149 +0,0 @@ -# Running a Hello World Program - -This example shows how to compile a simple service and print **Hello World** to help you preliminarily understand how to run OpenHarmony on Hi3861. - -## Modifying Source Code - -The source code needs to be modified when fixing bugs or compiling a new service. The following describes how to modify the source code when compiling a new service, for example, **my\_first\_app**. - -1. Determine the directory structure. - - Before compiling a service, you must create a directory \(or a directory structure\) in **./applications/sample/wifi-iot/app** to store source code files. - - For example, add the **my\_first\_app** service to the **app** directory, where **hello\_world.c** is the service code and **BUILD.gn** is the compilation script. The directory structure is shown as follows: - - ``` - . - └── applications - └── sample - └── wifi-iot - └── app - │── my_first_app - │ │── hello_world.c - │ └── BUILD.gn - └── BUILD.gn - ``` - -2. Compile the service code. - - Create the **hello\_world.c** file in **./applications/sample/wifi-iot/app/my\_first\_app**. Then, create the service entry function **HelloWorld** in **hello\_world.c** and implement service logic. Use the SYS\_RUN\(\) of the OpenHarmony **bootstrap** module to start services. \(**SYS\_RUN** is defined in the **ohos\_init.h** file.\) - - ``` - #include - #include "ohos_init.h" - #include "ohos_types.h" - - void HelloWorld(void) - { - printf("[DEMO] Hello world.\n"); - } - SYS_RUN(HelloWorld); - ``` - -3. Compile the **BUILD.gn** file for building services into a static library. - - Create the **BUILD.gn** file in **./applications/sample/wifi-iot/app/my\_first\_app** and fill in three parts \(target, source file, and header file path\) of the **BUILD.gn** file. - - ``` - static_library("myapp") { - sources = [ - "hello_world.c" - ] - include_dirs = [ - "//utils/native/lite/include" - ] - } - ``` - - - Specify the compilation result named libmyapp.a in **static\_library**. You can fill in this part based on your need. - - Specify the .c file on which a file depends and its path in **sources**. The path that contains **//** represents an absolute path \(the code root path\), otherwise it is a relative path. - - Specify the path of .h file on which **sources** depends in **include\_dirs**. - -4. Compile the **BUILD.gn** file and specify the feature modules to be built. - - Configure the **./applications/sample/wifi-iot/app/BUILD.gn** file and add an index to the **features** field to enable the target to be involved in compilation. Specify the path and target of a service module in **features**. The following uses **my\_first\_app** as an example and the **features** is configured as follows: - - ``` - import("//build/lite/config/component/lite_component.gni") - - lite_component("app") { - features = [ - "my_first_app:myapp", - ] - } - ``` - - - **my\_first\_app** is a relative path that points to **./applications/sample/wifi-iot/app/my\_first\_app/BUILD.gn**. - - **myapp** represents the **static\_library\("myapp"\)** in **./applications/sample/wifi-iot/app/my\_first\_app/BUILD.gn**. - - -## Debugging and Verification - -Currently, there are two debugging and verification methods: using printf to print logs and using ASM files to locate **panic** problems. You can select one of them based on your need. - -As the service shown is simple, use the printf method. The following describes the two debugging methods. - -### printf - -Add the **printf** function to the code, which helps print data to the serial port. You can add log printing in key service paths or service exception locations, as shown in the following figure. - -``` -void HelloWorld(void) -{ - printf("[DEMO] Hello world.\n"); -} -``` - -### Locating Exceptions Using the ASM File - -When the system exits abnormally, the call stack information about the abnormal exit is displayed on the serial port. The following is an example: You can locate the exception by parsing the exception stack information. - -``` -=======KERNEL PANIC======= -**********************Call Stack********************* -Call Stack 0 -- 4860d8 addr:f784c -Call Stack 1 -- 47b2b2 addr:f788c -Call Stack 2 -- 3e562c addr:f789c -Call Stack 3 -- 4101de addr:f78ac -Call Stack 4 -- 3e5f32 addr:f78cc -Call Stack 5 -- 3f78c0 addr:f78ec -Call Stack 6 -- 3f5e24 addr:f78fc -********************Call Stack end******************* -``` - -To parse the call stack information, the **Hi3861\_wifiiot\_app.asm** file is required. This file records the symbol addresses of the functions in the code in the flash memory and the disassembly information. The ASM file is built and output together with the version software package and is stored in the **./out/wifiiot/** directory. - -1. \(Optional\) Save the call stack information to a TXT file for later editing. -2. Open the ASM file, search for the function address in each call stack, and list the corresponding function. Generally, you only need to find the functions matching the first several stacks to locate exceptions. - - ``` - Call Stack 0 -- 4860d8 addr:f784c -- WadRecvCB - Call Stack 1 -- 47b2b2 addr:f788c -- wal_sdp_process_rx_data - Call Stack 2 -- 3e562c addr:f789c - Call Stack 3 -- 4101de addr:f78ac - Call Stack 4 -- 3e5f32 addr:f78cc - Call Stack 5 -- 3f78c0 addr:f78ec - Call Stack 6 -- 3f5e24 addr:f78fc - ``` - -3. Based on the above call stack information, it can be determined that an exception occurs in the **WadRecvCB** function. - - ![](figures/wadrecvcb-function.png) - -4. Check and modify the code. - -## Viewing Execution Result - -After the sample code is compiled, burnt, run, and debugged, the following information is displayed on the serial port interface: - -``` -ready to OS start -FileSystem mount ok. -wifi init success! -[DEMO] Hello world. -``` - -## Follow-up Learning - -Congratulations! You have finished all steps! You are advised to go on learning how to develop [WLAN-connected products](../guide/device-wlan.md). - diff --git a/en/device-dev/quick-start/quickstart-standard-burn.md b/en/device-dev/quick-start/quickstart-standard-burn.md deleted file mode 100644 index 8d06a9d39465543c2b02d21b72847750772b7bdd..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-standard-burn.md +++ /dev/null @@ -1,69 +0,0 @@ -# Burning Images - -Burning of a regular system requires DevEco Device Tool v2.2 Beta1 or later. - -Hi3516D V300 supports burning of the standard system through the USB port, network port, or serial port, where: - -- **Windows system: Supports burning through the USB port, serial port, or network port** -- **Linux system: Supports burning through the network port or serial port** - -Except for environment setup, the operations of burning are the same for Windows and Linux. - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->Currently, the Hi3516D V300 development board supports programming flash memory of the standard system through the USB port, network port, or serial port. This document uses the network port as an example. For details about programming flash memory over other ports, see [Programming Flash Memory on Hi3516D V300](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_upload-0000001052148681). - -## Prerequisites - -In DevEco Device Tool, select **Import Project** to open the folder where the target file is located. Set **MCU** to **Hi3516DV300** under **HiSilicon\_Arm\_Linux** and **Framework** to **Ohos-sources** or **Hpm**. - -![](figures/hisilicon-arm-linux.png) - -## Programming Flash Memory Through the Network Port - -The Hi3516DV300 supports burning through the network port in Windows or Linux. - -1. Connect the PC and the target development board through the serial port, network port, and power port. For details, see [Introduction to the Hi3516 Development Board](https://device.harmonyos.com/en/docs/start/introduce/oem_minitinier_des_3516-0000001152041033). -2. Open Device Manager, then check and record the serial port number corresponding to the development board. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If the serial port number is not displayed correctly, follow the steps described in [Installing the Serial Port Driver on the Hi3516 or Hi3518 Series Development Boards](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_hi3518-drivers-0000001050743695). - - ![](figures/hi3516-record-the-serial-port-number.png) - -3. Open DevEco Device Tool, choose **QUICK ACCESS** \> **DevEco Home** \> **Projects**, and then click **Settings**. - - ![](figures/hi3516-deveco-device-tool-setting.png) - -4. On the **hi3516dv300** tab page, configure the burning options. - - - **upload\_port**: Select the serial port number obtained in step [2](#en-us_topic_0000001056443961_li1050616379507). - - **upload\_protocol**: Select the burning protocol **hiburn-net**. - - **upload\_partitions**: Select the files to be burnt. By default, **fastboot**, **boot**, **updater**, **misc**, **system**, **vendor**, and **userdata** are burnt at the same time. - - ![](figures/upload-options-2.png) - -5. Check and set the IP address of the network adapter connected to the development board. For details, see [Setting the IP Address of the Network Port for Burning to Hi3516](https://device.harmonyos.com/en/docs/ide/user-guides/set_ipaddress-0000001141825075). -6. Set the IP address of the network port for burning: - - - **upload\_net\_server\_ip**: Select the IP address set in step [5](#en-us_topic_0000001056443961_li85106114532), such as 192.168.1.2. - - **upload\_net\_client\_mask**: Set the subnet mask of the development board, such as 255.255.255.0. Once the **upload\_net\_server\_ip** field is set, this field will be automatically populated. Example: 255.255.255.0. - - **upload\_net\_client\_gw**: Set the gateway of the development board, such as 192.168.1.1. Once the **upload\_net\_server\_ip** field is set, this field will be automatically populated. Example: 192.168.1.1. - - **upload\_net\_client\_ip**: Set the IP address of the development board, such as 192.168.1.3. Once the **upload\_net\_server\_ip** field is set, this field will be automatically populated. Example: 192.168.1.3. - - ![](figures/ip-address-information-3.png) - -7. When you finish modifying, click **Save** in the upper right corner. -8. Open the project file and go to ![](figures/2021-01-27_170334.png) \> **PROJECT TASKS** \> **hi3516dv300** \> **Upload** to start burning. - - ![](figures/en-us_image_0000001215342695.png) - -9. When the following message is displayed, power off the development board and then power it on. - - ![](figures/hi3516-restart-the-development-board.png) - -10. If the following message is displayed, it indicates that the burning is successful. - - ![](figures/hi3516-burning-succeeded-net.png) - -11. When the burning is successful, perform the operations in [Running an Image](https://device.harmonyos.com/en/docs/start/introduce/quickstart-standard-running-0000001142160948) to start the system. - diff --git a/en/device-dev/quick-start/quickstart-standard-docker-environment.md b/en/device-dev/quick-start/quickstart-standard-docker-environment.md deleted file mode 100644 index ab1534cdd01ad90681fd2f1d5cbc0f274d170147..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-standard-docker-environment.md +++ /dev/null @@ -1,93 +0,0 @@ -# Setting Up a Ubuntu Development Environment in Docker Mode - -The standard OpenHarmony system provides a Docker environment which encapsulates build tools. - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- Before using Docker, install it by following instructions in [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/). ->- You can also use the [installation package](quickstart-standard-package-environment.md) to set up the Ubuntu development environment. - -## Obtaining Standard-System Source Code - -### Prerequisites - -1. Register your account with Gitee. -2. Register an SSH public key for access to Gitee. -3. Install the [git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure basic user information. - - ``` - git config --global user.name "yourname" - git config --global user.email "your-email-address" - git config --global credential.helper store - ``` - -4. Run the following commands to install the **repo** tool: - - ``` - curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo # If you do not have the access permission to this directory, download the tool to any other accessible directory and configure the directory to the environment variable. - chmod a+x /usr/local/bin/repo - pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests - ``` - - -### Procedure - -Two methods are provided for you to obtain the OpenHarmony master code. You are advised to create a new folder and run the related commands in this folder to download the source code. This folder will then be the root directory of the source code. - -Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to Gitee.\) - -``` -repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify -repo sync -c -repo forall -c 'git lfs pull' -``` - -Method 2: Use the **repo** tool to download the source code over HTTPS. - -``` -repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify -repo sync -c -repo forall -c 'git lfs pull' -``` - -## Running prebuilts - -Go to the root directory of the source code and run the following script to install the compiler and binary tool: - -``` -bash build/prebuilts_download.sh -``` - -By default, the downloaded prebuilts binary file is stored in **OpenHarmony\_2.0\_canary\_prebuilts** \(which is in the same directory as **OpenHarmony**\). - -## Obtaining the Docker Environment - -1. Obtain the Docker image. - - ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 - ``` - -2. Go to the root directory of source code and run the following command to access the Docker build environment: - - ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 - ``` - - -## Building Source Code - -1. Run the following script to start building for standard-system devices \(reference memory ≥ 128 MB\). - - ``` - ./build.sh --product-name {product_name} --ccache - ``` - - **product\_name** indicates the platform supported by the current distribution, for example, Hi3516DV300 and rk3568. - - Files generated during building are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory. - -2. Burn the image. For details, see [Burning Images](quickstart-standard-burn.md). - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->You can exit Docker by simply running the **exit** command. - diff --git a/en/device-dev/quick-start/quickstart-standard-env-setup.md b/en/device-dev/quick-start/quickstart-standard-env-setup.md index 945ab49e468f7100490472343ec41146a5322be9..068cd76a9842fee329b2451b1b3d7288c8290311 100644 --- a/en/device-dev/quick-start/quickstart-standard-env-setup.md +++ b/en/device-dev/quick-start/quickstart-standard-env-setup.md @@ -19,7 +19,7 @@ To install the necessary libraries and tools, perform the following steps. In Ubuntu: 1. Run the following **apt-get** command: - + ``` sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales ``` @@ -34,13 +34,13 @@ In Ubuntu: 2. Set Python 3.8 as the default Python version. Check the location of Python 3.8: - + ``` which python3.8 ``` Change python and python3 to python3.8. - + ``` sudo update-alternatives --install /usr/bin/python python {python3.8 path} 1 #{Python3.8 path} is the location of Python 3.8 obtained in the previous step. sudo update-alternatives --install /usr/bin/python3 python3 {python3.8 path} 1 #{Python3.8 path} is the location of Python 3.8 obtained in the previous step. @@ -98,14 +98,14 @@ To remotely access the Ubuntu environment through Windows to perform operations 1. Make sure the Ubuntu shell environment is **bash**. 1. Run the following command and check whether the command output is **bash**. If the command output is not **bash**, go to step 2. - + ``` ls -l /bin/sh ``` ![en-us_image_0000001226764302](figures/en-us_image_0000001226764302.png) 2. Start the command-line tool, run the following command, enter your password, and select **No** to set **Ubuntu shell** to **bash**. - + ``` sudo dpkg-reconfigure dash ``` @@ -116,12 +116,12 @@ To remotely access the Ubuntu environment through Windows to perform operations 3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression. 1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.400.zip** to the actual software package name. - + ``` unzip devicetool-linux-tool-3.0.0.400.zip ``` 2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.400.sh** to the actual installation file name. - + ``` chmod u+x devicetool-linux-tool-3.0.0.400.sh ``` @@ -130,7 +130,7 @@ To remotely access the Ubuntu environment through Windows to perform operations > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python. - + ``` sudo ./devicetool-linux-tool-3.0.0.400.sh ``` @@ -149,19 +149,19 @@ To remotely access the Ubuntu environment through Windows to perform operations > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server. - + ``` sudo apt-get install openssh-server ``` 2. Run the following command to start the SSH service: - + ``` sudo systemctl start ssh ``` 3. Run the following command to obtain the IP address of the current user for remote access to the Ubuntu environment from Windows: - + ``` ifconfig ``` @@ -171,7 +171,7 @@ To remotely access the Ubuntu environment through Windows to perform operations ### Installing Remote SSH -1. Open Visual Studio Code in Windows, click ![en-us_image_0000001239080359](figures/en-us-cn_image_0000001239080359.png), and search for **remote-ssh** in the Extension Marketplace. +1. Open Visual Studio Code in Windows, click ![en-us_image_0000001239080359](figures/en-us_image_0000001239080359.png), and search for **remote-ssh** in the Extension Marketplace. ![en-us_image_0000001193920448](figures/en-us_image_0000001193920448.png) @@ -210,7 +210,7 @@ To remotely access the Ubuntu environment through Windows to perform operations After the preceding operations are complete, you can remotely connect to the Ubuntu environment through Windows for development. However, you need to frequently enter the remote connection password. To eliminate this need, you can use the SSH public key. 1. Open the Git bash CLI and run the following command to generate an SSH public key. During command execution, perform operations as prompted. Set **username** and **ip** to the user name and IP address you use for connecting to the Ubuntu system. - + ``` ssh-keygen -t rsa ssh-copy-id -i ~/.ssh/id_rsa.pub username@ip @@ -245,13 +245,13 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony ``` Run the following command to install the tools: - + ``` sudo apt-get install git git-lfs ``` 4. Configure user information. - + ``` git config --global user.name "yourname" git config --global user.email "your-email-address" @@ -259,7 +259,7 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony ``` 5. Run the following commands to install the **repo** tool: - + ``` curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo # If you do not have the access permission to this directory, download the tool to any other accessible directory and configure the directory to the environment variable. chmod a+x /usr/local/bin/repo @@ -284,7 +284,7 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony Method 2: Use the **repo** tool to download the source code over HTTPS. - + ``` repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify repo sync -c @@ -299,7 +299,7 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony ### Running prebuilts Go to the root directory of the source code and run the following script to install the compiler and binary tool: - + ``` bash build/prebuilts_download.sh ``` @@ -311,35 +311,35 @@ hb is a compilation tool of OpenHarmony. To install hb in Ubuntu, perform the fo > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> To install a proxy, see [Configuring a Proxy](../quick-start/quickstart-standard-reference.md#configuring-a-proxy). +> To install a proxy, see [Configuring the Proxy](../quick-start/quickstart-standard-reference.md#section6204129143012). 1. Run the following command to install hb and update it to the latest version: - + ``` pip3 install --user build/lite ``` 2. Set the environment variable. - + ``` vim ~/.bashrc ``` Copy the following command to the last line of the .bashrc file, save the file, and exit. - + ``` export PATH=~/.local/bin:$PATH ``` Update the environment variable. - + ``` source ~/.bashrc ``` 3. Run the **hb -h** command in the source code directory. If the following information is displayed, the installation is successful: - + ``` usage: hb @@ -359,7 +359,7 @@ hb is a compilation tool of OpenHarmony. To install hb in Ubuntu, perform the fo > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE** > - Run the following command to uninstall hb: -> +> > ``` > pip3 uninstall ohos-build > ``` diff --git a/en/device-dev/quick-start/quickstart-standard-package-environment.md b/en/device-dev/quick-start/quickstart-standard-package-environment.md deleted file mode 100644 index 21f07874275ca4c875383feec9ef61d068263394..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-standard-package-environment.md +++ /dev/null @@ -1,92 +0,0 @@ -# Setting Up a Ubuntu Development Environment Using the Installation Package - -## Installing Dependent Tools - -The installation command is as follows: - -``` -sudo apt-get update && sudo apt-get install binutils git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby -``` - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The preceding command is applicable to Ubuntu 18.04. For other Ubuntu versions, modify the preceding installation command based on the installation package name. Python 3.7 or later is required. Python 3.8 is used as an example. - -## Obtaining Standard-System Source Code - -### Prerequisites - -1. Register your account with Gitee. -2. Register an SSH public key for access to Gitee. -3. Install the [git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure basic user information. - - ``` - git config --global user.name "yourname" - git config --global user.email "your-email-address" - git config --global credential.helper store - ``` - -4. Run the following commands to install the **repo** tool: - - ``` - curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo # If you do not have the access permission to this directory, download the tool to any other accessible directory and configure the directory to the environment variable. - chmod a+x /usr/local/bin/repo - pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests - ``` - - -### Procedure - -Two methods are provided for you to obtain the OpenHarmony master code. You are advised to create a new folder and run the related commands in this folder to download the source code. This folder will then be the root directory of the source code. - -Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to Gitee.\) - -``` -repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify -repo sync -c -repo forall -c 'git lfs pull' -``` - -Method 2: Use the **repo** tool to download the source code over HTTPS. - -``` -repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify -repo sync -c -repo forall -c 'git lfs pull' -``` - -## Running prebuilts - -Go to the root directory of the source code and run the following script to install the compiler and binary tool: - -``` -bash build/prebuilts_download.sh -``` - -By default, the downloaded prebuilts binary file is stored in **OpenHarmony\_2.0\_canary\_prebuilts** \(which is in the same directory as **OpenHarmony**\). - -## Building Source Code - -Perform the following operations in the Linux environment: - -1. Go to the root directory of the source code and run the following command to build the distribution. - - ``` - ./build.sh --product-name {product_name} - ``` - - **product\_name** indicates the product supported by the current distribution, for example, **Hi3516DV300**. - -2. Check the build result. After the build is complete, the following information is displayed in the log: - - ``` - build system image successful. - =====build Hi3516DV300 successful. - ``` - - Files generated during the build are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details about module-specific build operations, see [Building Guidelines](../subsystems/subsys-build-standard-large.md). - -3. Burn the image. For details, see [Burning Images](quickstart-standard-burn.md). - diff --git a/en/device-dev/quick-start/quickstart-standard-reference.md b/en/device-dev/quick-start/quickstart-standard-reference.md index a1bb41dcfd09fd8b5c0419a11cbd8ca6b494c06a..2c20ea41430d7201815a82058950a99f53847d28 100644 --- a/en/device-dev/quick-start/quickstart-standard-reference.md +++ b/en/device-dev/quick-start/quickstart-standard-reference.md @@ -5,7 +5,7 @@ 1. Go to the root directory of the source code and run the build command. - + ``` ./build.sh --product-name name --ccache ``` @@ -14,7 +14,7 @@ > _name_ indicates the product name, for example, **Hi3516D V300** and **rk3568**. 2. Check the build result. After the build is complete, the following information is displayed in the log: - + ``` post_process =====build name successful. @@ -31,13 +31,13 @@ ### Setting Up the Python Proxy 1. Create a proxy configuration file. - + ``` mkdir ~/.pipvim ~/.pip/pip.conf ``` 2. Add the following proxy information to the file, save the file, and exit: - + ``` [global] index-url = http:// Proxy URL @@ -46,23 +46,23 @@ ``` -### Setting Up the npm Proxy +### Setting Up the npm Proxy 1. Create a proxy configuration file. - + ``` vim ~/.npmrc ``` 2. Add the following proxy information to the file, save the file, and exit: - + ``` Registry=http:// Proxy URL strict-ssl=false ``` 3. Add the following content to the **.bashrc** file, save the file, and exit: - + ``` export NPM_REGISTRY=http:// Proxy URL source .bashrc diff --git a/en/device-dev/quick-start/quickstart-standard-sourcecode-acquire.md b/en/device-dev/quick-start/quickstart-standard-sourcecode-acquire.md deleted file mode 100644 index 53b2301eb0f43b72bd7d94404135633e7a6a5e66..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-standard-sourcecode-acquire.md +++ /dev/null @@ -1,49 +0,0 @@ -# Obtaining Source Code - -### Prerequisites - -1. Register your account with Gitee. -2. Register an SSH public key for access to Gitee. -3. Install the [git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure basic user information. - - ``` - git config --global user.name "yourname" - git config --global user.email "your-email-address" - git config --global credential.helper store - ``` - -4. Run the following commands to install the **repo** tool: - - ``` - curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo # If you do not have the access permission to this directory, download the tool to any other accessible directory and configure the directory to the environment variable. - chmod a+x /usr/local/bin/repo - pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests - ``` - - -### How to Obtain - ->![](../public_sys-resources/icon-note.gif) **NOTE**
->Download the master code if you want to get quick access to the latest features for your development. Download the release code, which is more stable, if you want to develop commercial functionalities. - -- **Obtaining OpenHarmony master code** - - Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to Gitee.\) - - ``` - repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - - Method 2: Use the **repo** tool to download the source code over HTTPS. - - ``` - repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - -- **Obtaining OpenHarmony release code** - - For details about how to obtain the source code of an OpenHarmony release, see the [Release-Notes](../get-code/../../release-notes/Readme.md). diff --git a/en/device-dev/quick-start/quickstart-standard-windows-environment.md b/en/device-dev/quick-start/quickstart-standard-windows-environment.md deleted file mode 100644 index a7b213cda58152c74063f9a2f94c029142dd3db6..0000000000000000000000000000000000000000 --- a/en/device-dev/quick-start/quickstart-standard-windows-environment.md +++ /dev/null @@ -1,63 +0,0 @@ -# Setting Up a Windows Development Environment - -System requirements: - -- OS: 64-bit Windows 10 -- User name: cannot contain Chinese characters - -## Installing DevEco Device Tool - -DevEco Device Tool is installed in Visual Studio Code as a plug-in and depends on Python, Node.js, and HPM for running. - -DevEco Device Tool supports integrated installation. The DevEco Device Tool setup wizard checks whether the adaptation versions of Visual Studio Code, Python, Node.js and HPM tools have been installed. If any of the tools is not installed, you'll be prompted to select the tool to be automatically installed. - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->Before installing DevEco Device Tool, make sure the user name of the host does not contain Chinese characters. Otherwise, the **DevEco Home** page will be stuck loading and the DevEco Device Tool cannot work. - -1. Log in to the [HarmonyOS Device website](https://device.harmonyos.com/cn/ide#download_beta) with your HUAWEI ID and download DevEco Device Tool V3.0 Beta1 or a later version. If you do not have a HUAWEI ID, [register](https://developer.huawei.com/consumer/en/doc/start/registration-and-verification-0000001053628148) one first. -2. Decompress the DevEco Device Tool package, double-click the installer, and then click **Next**. -3. Set the installation path of DevEco Device Tool and click **Next**. -4. When prompted, select the tools to be automatically installed and click **Next**. - - ![](figures/snap28.png) - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >When the setup wizard detects that a compatible Python version has been installed, it prompts you to select the installed Python version or download the recommended Python version. - -5. In the dialog box shown below, click **Next** to download and install the tools. - - ![](figures/snap8.png) - -6. In the displayed Python setup wizard, select **Add Python 3.8 to PATH** and click **Install Now**. After the installation is complete, click **Close**. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you have selected the compatible Python version installed on your device, the Python setup wizard will not be displayed. In this case, you skip this step. - >If DevEco Device Tool 2.1 Release is installed, the Python version must be 3.8.x. If DevEco Device Tool V3.0 Beta1 or a later version is installed, the Python version must be 3.8.x or 3.9.x. - - ![](figures/snap34.png) - -7. In the Visual Studio Code setup wizard, install Visual Studio Code as prompted. During the installation, select **Add to PATH \(requires shell restart\)**. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you are using the correct version of Visual Studio Code, the Visual Studio Code setup wizard will not be displayed. In this case, you skip this step. - - ![](figures/snap33.png) - -8. In the Node.js setup wizard, retain the default settings and click **Next** until **Finish** is displayed. During the installation, Node.js will automatically set the system Path environment variable to the installation directory of **node.exe**. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you are using the correct version of Node.js, the Node.js setup wizard will not be displayed. In this case, you skip this step. - -9. Wait for the DevEco Device Tool setup wizard to automatically install the HPM and DevEco Device Tool. After the installation is complete, click **Finish** to close the setup wizard. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you are using the correct version of HPM, the setup wizard does not download or install HPM. - -10. Start Visual Studio Code. The C/C++ and CodeLLDB plug-ins on which DevEco Device Tool depends will be automatically installed. After the installation is complete, click ![](figures/button.png) on the left of Visual Studio Code to check whether C/C++, CodeLLDB, and DevEco Device Tool are included in the **INSTALLED** list. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If the C/C++ and CodeLLDB plug-ins fail to be installed, DevEco Device Tool cannot run properly. To solve the issue, see [Installing the C/C++ and CodeLLDB Plug-ins Offline](https://device.harmonyos.com/en/docs/ide/user-guides/offline_plugin_install-0000001074376846). - - ![](figures/deveco-device-tool-install-sucessful.png) - - diff --git a/en/device-dev/subsystems/subsys-security-sigverify.md b/en/device-dev/subsystems/subsys-security-sigverify.md index 66ec4fba0f6f38fcd95b26eebe52e19040a61cf5..86ab86db160dd0a3a8740477b7a98041f672fd5b 100644 --- a/en/device-dev/subsystems/subsys-security-sigverify.md +++ b/en/device-dev/subsystems/subsys-security-sigverify.md @@ -83,5 +83,5 @@ The following table lists the innerkits APIs provided by the signature verificat ### OpenHarmony Self-signed Application -To develop an OpenHarmony self-signed application, follow instructions provided in the guide of [_Configuring the OpenHarmony App Signature_](https://gitee.com/openharmony/docs/blob/master/en/application-dev/quick-start/configuring-openharmony-app-signature.md) : +For details about how to develop an OpenHarmony self-signed application, see [Having Your App Automatically Signed](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465). diff --git a/zh-cn/application-dev/ability/fa-pageability.md b/zh-cn/application-dev/ability/fa-pageability.md index cf12ea2ccc0cdca0b329d85477238a4cce4fc765..7ac8555694f378fc28933783e5e3005db87b8587 100644 --- a/zh-cn/application-dev/ability/fa-pageability.md +++ b/zh-cn/application-dev/ability/fa-pageability.md @@ -34,16 +34,15 @@ PageAbility生命周期流转如下图所示: PageAbility提供命周期回调,开发者可以在`app.js/app.ets`中重写生命周期相关回调函数 。目前`app.js`环境中仅支持onCreate和onDestroy回调,`app.ets`环境支持全量生命周期回调。 ### 启动模式 -ability支持单实例、多实例和指定实例3种启动模式。 +ability支持单实例和多实例两种启动模式。 在config.json中通过launchType配置项,可以配置具体的启动模式,其中: | 启动模式 | 描述 |说明 | | ----------- | ------- |---------------- | | standard | 多实例 | 每次startAbility都会启动一个新的实例 | | singleton | 单实例 | 系统中只存在唯一一个实例,startAbility时,如果已存在,则复用系统中的唯一一个实例 | -| specified | 指定实例 | 运行时由ability内部业务决定是否创建多实例 | -缺省情况下是standard模式。 +缺省情况下是singleton模式。 ## 开发指导 ### featureAbility接口说明 diff --git a/zh-cn/application-dev/application-dev-website.md b/zh-cn/application-dev/application-dev-website.md index 09e13ac43c52e5eff927b176af8037ffceece574..4717b423c14696a71c8575cd92f0b828349f7b5d 100644 --- a/zh-cn/application-dev/application-dev-website.md +++ b/zh-cn/application-dev/application-dev-website.md @@ -578,6 +578,8 @@ - 资源调度 - [@ohos.backgroundTaskManager (后台任务管理)](reference/apis/js-apis-backgroundTaskManager.md) + - [@ohos.workScheduler (延迟任务调度)](reference/apis/js-apis-workScheduler.md) + - [@ohos.WorkSchedulerExtensionAbility (延迟任务调度回调)](reference/apis/js-apis-WorkSchedulerExtensionAbility.md) - 定制管理 - [@ohos.configPolicy (配置策略)](reference/apis/js-apis-config-policy.md) diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index f834608513ca8f3499aadb8f6d5d2315e7bcad09..dcf89e5f8147bcbf4c87f4592f4b8198f8fe49c7 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -64,6 +64,8 @@ - 资源调度 - [@ohos.backgroundTaskManager (后台任务管理)](js-apis-backgroundTaskManager.md) + - [@ohos.workScheduler (延迟任务调度)](js-apis-workScheduler.md) + - [@ohos.WorkSchedulerExtensionAbility (延迟任务调度回调)](js-apis-WorkSchedulerExtensionAbility.md) - 定制管理 - [@ohos.configPolicy (配置策略)](js-apis-config-policy.md) @@ -90,6 +92,7 @@ - [@ohos.fileManager (公共文件访问与管理)](js-apis-filemanager.md) - [@ohos.statfs (statfs)](js-apis-statfs.md) - [@ohos.storageStatistics (应用空间统计)](js-apis-storage-statistics.md) + - [@ohos.volumeManager (卷管理)](js-apis-volumemanager.md) - 电话服务 - [@ohos.contact (联系人)](js-apis-contact.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md new file mode 100644 index 0000000000000000000000000000000000000000..45be5b1eb16a18f3b4321cccc6aeaa5380f41a99 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @@ -0,0 +1,60 @@ +# 延迟任务调度回调 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 9开始支持。API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。 + + +## 导入模块 + +``` +import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility' +``` + +## WorkSchedulerExtensionAbility.onWorkStart + +onWorkStart(work: workScheduler.WorkInfo): void + +延迟任务调度开始回调。 + +**系统能力:** SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | --------------------- | ---- | -------------- | +| work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | 是 | 指示要添加到执行队列的工作。 | + +**示例:** + + ``` + export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { + onWorkStart(workInfo) { + console.log('MyWorkSchedulerExtensionAbility onWorkStart' + JSON.stringify(workInfo)); + } + } + ``` + +## WorkSchedulerExtensionAbility.onWorkStop + +onWorkStop(work: workScheduler.WorkInfo): void + +延迟任务调度结束回调。 + +**系统能力:** SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | --------------------- | ---- | -------------- | +| work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | 是 | 指示要添加到执行队列的工作。 | + + +**示例:** + + ``` + export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { + onWorkStop(workInfo) { + console.log('MyWorkSchedulerExtensionAbility onWorkStop' + JSON.stringify(workInfo)); + } + } + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index a9eb2c060abcfdaa010f9f486c8bb5999b1a52e6..594eb3853f0533c1b36c1bfaace0458f2eb35a57 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -625,7 +625,7 @@ read(fd: number, buffer: ArrayBuffer, options?: { | ------- | ----------- | ---- | ---------------------------------------- | | fd | number | 是 | 待读取文件的文件描述符。 | | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。
- 约束:offset+length<=buffer.size。 | - 返回值: | 类型 | 说明 | @@ -662,7 +662,7 @@ read(fd: number, buffer: ArrayBuffer, options: { | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | fd | number | 是 | 待读取文件的文件描述符。 | | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。
- 约束:offset+length<=buffer.size。 | | callback | AsyncCallback<[ReadOut](#readout)> | 是 | 异步读取数据之后的回调。 | - 示例: @@ -695,7 +695,7 @@ readSync(fd: number, buffer: ArrayBuffer, options?: { | ------- | ----------- | ---- | ---------------------------------------- | | fd | number | 是 | 待读取文件的文件描述符。 | | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。
- 约束:offset+length<=buffer.size。 | - 返回值: | 类型 | 说明 | @@ -867,7 +867,7 @@ write(fd: number, buffer: ArrayBuffer | string, options?: { | ------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | 是 | 待写入文件的文件描述符。 | | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
- 约束:offset+length<=buffer.size。 | - 返回值: | 类型 | 说明 | @@ -903,7 +903,7 @@ write(fd: number, buffer: ArrayBuffer | string, options: { | -------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | 是 | 待写入文件的文件描述符。 | | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
- 约束:offset+length<=buffer.size。 | | callback | AsyncCallback<number> | 是 | 异步将数据写入完成后执行的回调函数。 | - 示例: @@ -935,7 +935,7 @@ writeSync(fd: number, buffer: ArrayBuffer | string, options?: { | ------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | 是 | 待写入文件的文件描述符。 | | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
- 约束:offset+length<=buffer.size。 | - 返回值: | 类型 | 说明 | @@ -1472,10 +1472,10 @@ read(buffer: ArrayBuffer, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ----------- | ---- | ---------------------------------------- | - | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------- | ---- | ------------------------------------------------------------ | + | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- 约束:offset+length<=buffer.size。 | - 返回值: | 类型 | 说明 | @@ -1509,7 +1509,7 @@ read(buffer: ArrayBuffer, options: { | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- 约束:offset+length<=buffer.size。 | | callback | AsyncCallback<[ReadOut](#readout)> | 是 | 异步从文件读取数据之后的回调。 | - 示例 @@ -2721,7 +2721,7 @@ write(buffer: ArrayBuffer | string, options?: { | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
- 约束:offset+length<=buffer.size。 | - 返回值: | 类型 | 说明 | @@ -2753,11 +2753,11 @@ write(buffer: ArrayBuffer | string, options: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------- | ---- | ---------------------------------------- | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | - | callback | AsyncCallback<number> | 是 | 异步写入完成后执行的回调函数。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | + | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
- 约束:offset+length<=buffer.size。 | + | callback | AsyncCallback<number> | 是 | 异步写入完成后执行的回调函数。 | - 示例: ```js @@ -2788,7 +2788,7 @@ writeSync(buffer: ArrayBuffer | string, options?: { | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
- 约束:offset+length<=buffer.size。 | - 返回值: | 类型 | 说明 | @@ -2818,7 +2818,7 @@ read(buffer: ArrayBuffer, options?: { | 参数名 | 类型 | 必填 | 说明 | | ------- | ----------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。
- 约束:offset+length<=buffer.size。 | - 返回值: | 类型 | 说明 | @@ -2853,7 +2853,7 @@ read(buffer: ArrayBuffer, options: { | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。
- 约束:offset+length<=buffer.size。 | | callback | AsyncCallback<[ReadOut](#readout)> | 是 | 异步从流文件读取数据之后的回调。 | - 示例: @@ -2884,7 +2884,7 @@ readSync(buffer: ArrayBuffer, options?: { | 参数名 | 类型 | 必填 | 说明 | | ------- | ----------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。
- 约束:offset+length<=buffer.size。 | - 返回值: | 类型 | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md index fe6843e020b1c0993bbb485432ae494370720a47..a9db2331bde2b2d8dec787e315cb315e0b8f9e9c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @@ -3,7 +3,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > > - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> - 本模块接口为系统接口,三方应用不支持调用。 +> - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。 ## 导入模块 @@ -67,6 +67,7 @@ getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):v }); ``` + ## storagestatistics.getFreeSizeOfVolume @@ -124,3 +125,71 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):vo console.info("getFreeSizeOfVolume successfully:"+ number); }); ``` + +## storagestatistics.getBundleStats9+ + +getBundleStats(packageName: string): Promise<BundleStats> + +异步获取应用存储数据,以promise方式返回。 + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | ------ | ---- | -------- | + | packageName | string | 是 | 应用包名 | + +- 返回值 + + | 类型 | 说明 | + | ------------------------------------------ | -------------------------- | + | Promise<[Bundlestats](#bundlestats)> | 返回指定卷上的应用存储状态 | + +- 示例 + + ```js + let packageName = ""; + storagestatistics.getBundleStats(packageName).then(function(BundleStats){ + console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); + }).catch(function(err){ + console.info("getBundleStats failed with error:"+ err); + }); + ``` + +## storagestatistics.getBundleStats9+ + +getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>): void + +异步获取应用存储数据,以callback方式返回。 + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | + | packageName | string | 是 | 应用包名 | + | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 | + +- 示例 + + ```js + let packageName = ""; + storagestatistics.getBundleStats(packageName, function(error, BundleStats){ + // do something + console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); + }); + ``` + +## BundleStats9+ + +**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.SpatialStatistics。 + +### 属性 + +| 名称 | 类型 | 说明 | +| --------- | ------ | -------------- | +| appSize9+ | number | app数据大小 | +| cacheSize9+ | number | 缓存数据大小 | +| dataSize9+ | number | 应用总数据大小 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md new file mode 100644 index 0000000000000000000000000000000000000000..60a9052e01f5a602113afcf74c68babad790496d --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @@ -0,0 +1,179 @@ +# 卷管理 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 本模块首批接口从API version 9开始支持。 +> - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。 + +## 导入模块 + +```js +import volumemanager from "@ohos.volumeManager"; +``` + +## volumemanager.getAllVolumes + +getAllVolumes(): Promise<Array<Volume>> + +异步获取当前所有可获得的卷信息,以promise方式返回。 + +**系统能力**:SystemCapability.FileManagement.StorageService.Volume + +- 返回值 + + | 类型 | 说明 | + | ---------------------------------- | -------------------------- | + | Promise<[Volume](#volume)[]> | 返回当前所有可获得的卷信息 | + +- 示例 + + ```js + volumemanager.getAllVolumes().then(function(volumes){ + // do something + }); + ``` + +## volumemanager.getAllVolumes + +getAllVolumes(callback: AsyncCallback<Array<Volume>>): void + +异步获取当前所有可获得的卷信息,以callback方式返回。 + +**系统能力**:SystemCapability.FileManagement.StorageService.Volume + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------------------- | ---- | ------------------------------------ | + | callback | callback:AsyncCallback<[Volume](#volume)[]> | 是 | 获取当前所有可获得的卷信息之后的回调 | + +- 示例 + + ```js + let uuid = ""; + volumemanager.getAllVolumes(uuid, function(error, volumes){ + // do something + }); + ``` + + +## volumemanager.mount + +mount(volumeId: string): Promise<boolean> + +异步挂载指定卷,以promise方式返回。 + +**系统能力**:SystemCapability.FileManagement.StorageService.Volume + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | ---- | + | volumeId | string | 是 | 卷id | + +- 返回值 + + | 类型 | 说明 | + | ---------------------- | ---------- | + | Promise<boolean> | 挂载指定卷 | + +- 示例 + + ```js + let volumeId = ""; + volumemanager.mount(volumeId).then(function(flag){ + // do something + }); + ``` + +## volumemanager.mount + +mount(volumeId: string, callback:AsyncCallback<boolean>):void + +异步获取指定卷的可用空间大小,以callback方式返回。 + +**系统能力**:SystemCapability.FileManagement.StorageService.Volume + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | 是 | 卷id | + | callback | callback:AsyncCallback<boolean> | 是 | 挂载指定卷之后的回调 | + +- 示例 + + ```js + let volumeId = ""; + volumemanager.mount(volumeId, function(error, flag){ + // do something + }); + ``` + +## volumemanager.unmount + +unmount(volumeId: string): Promise<boolean> + +异步卸载指定卷,以promise方式返回。 + +**系统能力**:SystemCapability.FileManagement.StorageService.Volume + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | ---- | + | volumeId | string | 是 | 卷id | + +- 返回值 + + | 类型 | 说明 | + | ---------------------- | ---------- | + | Promise<boolean> | 卸载指定卷 | + +- 示例 + + ```js + let volumeId = ""; + volumemanager.unmount(volumeId).then(function(flag){ + // do something + }); + ``` + +## volumemanager.unmount + +unmount(volumeId: string, callback:AsyncCallback<boolean>):void + +异步卸载指定卷,以callback方式返回。 + +**系统能力**:SystemCapability.FileManagement.StorageService.Volume + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | 是 | 卷id | + | callback | callback:AsyncCallback<boolean> | 是 | 卸载指定卷之后的回调 | + +- 示例 + + ```js + let volumeId = ""; + volumemanager.unmount(volumeId, function(error, flag){ + // do something + }); + ``` + +## Volume + +**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.Volume。 + +### 属性 + +| 名称 | 类型 | 说明 | +| ----------- | ------- | -------------------- | +| id | number | 卷id | +| uuid | string | 卷uuid | +| description | string | 卷相关描述 | +| removable | boolean | 是否为可移动存储设备 | +| state | int | 当前卷状态 | +| path | string | 卷的挂载地址 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md new file mode 100644 index 0000000000000000000000000000000000000000..8f904a17731e6a83f3fe85c6afeedf26c22909d6 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @@ -0,0 +1,341 @@ +# 延迟任务调度 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 9开始支持。API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。 + + +## 导入模块 + +``` +import workScheduler from '@ohos.workScheduler' +``` + +## workScheduler.startWork +startWork(work: WorkInfo): boolean + +通知WorkSchedulerService将工作添加到执行队列。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | --------------------- | ---- | -------------- | +| work | [WorkInfo](#workinfo) | 是 | 指示要添加到执行队列的工作。 | + +**返回值**: + +| 类型 | 说明 | +| ------- | -------------------------------- | +| boolean | 如果工作成功添加到执行队列,则返回true,否则返回false。 | + +**示例**: + +``` + let workInfo = { + workId: 1, + batteryLevel:50, + batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, + isRepeat: false, + isPersisted: true, + bundleName: "com.example.myapplication", + abilityName: "MyExtension" + } + var res = workScheduler.startWork(workInfo); + console.info("workschedulerLog res:" + res); +``` + +## workScheduler.stopWork +stopWork(work: WorkInfo, needCancel?: boolean): boolean + +通知WorkSchedulerService停止指定工作。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------- | ---- | ---------- | +| work | [WorkInfo](#workinfo) | 是 | 指示要停止的工作。 | +| needCancel | boolean | 是 | 是否需要取消的工作。 | + +**返回值**: + +| 类型 | 说明 | +| ------- | ----------------------- | +| boolean | 如果成功,则返回true,否则返回false。 | + +**示例**: + +``` + let workInfo = { + workId: 1, + batteryLevel:50, + batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, + isRepeat: false, + isPersisted: true, + bundleName: "com.example.myapplication", + abilityName: "MyExtension" + } + var res = workScheduler.stopWork(workInfo, false); + console.info("workschedulerLog res:" + res); +``` + +## workScheduler.getWorkStatus +getWorkStatus(workId: number, callback : AsyncCallback\): void + +获取工作的最新状态,使用Callback形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | ---------------------------------------- | +| workId | number | 是 | work的id。 | +| callback | AsyncCallback\<[WorkInfo](#workinfo)> | 是 | 指定的callback回调方法。如果指定的工作Id有效,则返回从WorkSchedulerService获取的有效工作状态;否则返回null。 | + +**示例**: + +``` + workScheduler.getWorkStatus(50, (err, res) => { + if (err) { + console.info('workschedulerLog getWorkStatus failed, because:' + err.data); + } else { + for (let item in res) { + console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); + } + } + }); +``` + +## workScheduler.getWorkStatus +getWorkStatus(workId: number): Promise\ + +获取工作的最新状态,使用Promise形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| workId | number | 是 | work的id。 | + +**返回值**: + +| 类型 | 说明 | +| ------------------------------- | ---------------------------------------- | +| Promise\<[WorkInfo](#workinfo)> | 指定的Promise回调方法。如果指定的工作ID有效,则返回从WorkSchedulerService获取的有效工作状态;否则返回null。 | + +**示例**: + +``` + workScheduler.getWorkStatus(50).then((res) => { + for (let item in res) { + console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); + } + }).catch((err) => { + console.info('workschedulerLog getWorkStatus failed, because:' + err.data); + }) +``` + +## workScheduler.obtainAllWorks +obtainAllWorks(callback : AsyncCallback\): Array\ + +获取与当前应用程序关联的所有工作,使用Callback形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------------------- | +| callback | AsyncCallback\ | 是 | 指定的callback回调方法。返回与应用程序关联的所有工作。 | + +**返回值**: + +| 类型 | 说明 | +| ----------------------------- | --------------- | +| Array\<[WorkInfo](#workinfo)> | 返回与应用程序关联的所有工作。 | + +**示例**: + +``` + workScheduler.obtainAllWorks((err, res) =>{ + if (err) { + console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); + } else { + console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); + } + }); +``` + +## workScheduler.obtainAllWorks +obtainAllWorks(): Promise> + +获取与当前应用程序关联的所有工作,使用Promise形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**返回值**: + +| 类型 | 说明 | +| -------------------------------------- | ------------------------------ | +| Promise> | 指定的Promise回调方法。返回与应用程序关联的所有工作。 | + +**示例**: + +``` + workScheduler.obtainAllWorks().then((res) => { + console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); + }).catch((err) => { + console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); + }) +``` + +## workScheduler.stopAndClearWorks +stopAndClearWorks(): boolean + +停止和取消与当前应用程序关联的所有工作。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**示例**: + +``` + let res = workScheduler.stopAndClearWorks(); + console.info("workschedulerLog res:" + res); +``` + +## workScheduler.isLastWorkTimeOut +isLastWorkTimeOut(workId: number, callback : AsyncCallback\): boolean + +检查指定工作的最后一次执行是否为超时操作,使用Callback形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------------------------------- | +| workId | number | 是 | work的id。 | +| callback | AsyncCallback\ | 是 | 指定的callback回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | + +**返回值**: + +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 指定的callback回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | + +**示例**: + +``` + workScheduler.isLastWorkTimeOut(500, (err, res) =>{ + if (err) { + console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); + } else { + console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); + } + }); +``` + +## workScheduler.isLastWorkTimeOut +isLastWorkTimeOut(workId: number): Promise\ + +检查指定工作的最后一次执行是否为超时操作,使用Promise形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| workId | number | 是 | work的id。 | + +**返回值**: + +| 类型 | 说明 | +| ----------------- | ---------------------------------------- | +| Promise\ | 指定的Promise回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | + +**示例**: + +``` + workScheduler.isLastWorkTimeOut(500) + .then(res => { + console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); + }) + .catch(err => { + console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); + }); +``` + +## WorkInfo +提供工作的具体信息。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler + +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | --------------------------------- | ---- | -------------------------------- | +| workId | number | 是 | 当前工作的ID | +| bundleName | string | 是 | 延迟任务包名 | +| abilityName | string | 是 | 延迟任务回调通知的组件名(必填) | +| networkType | [NetworkType](#networktype) | 否 | 网络类型 | +| isCharging | boolean | 否 | 是否充电 | +| chargerType | [ChargingType](#chargingtype) | 否 | 充电类型 | +| batteryLevel | number | 否 | 电量 | +| batteryStatus | [BatteryStatus](#batterystatus) | 否 | 电池状态 | +| storageRequest | [StorageRequest](#storagerequest) | 否 | 存储状态 | +| isRepeat | boolean | 否 | 是否循环任务 | +| repeatCycleTime | number | 否 | 循环间隔 | +| repeatCount | number | 否 | 循环次数 | +| isPersisted | boolean | 否 | 是否持久化保存工作 | + +## NetworkType +触发工作的网络类型。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler + +| 名称 | 默认值 | 说明 | +| ---------------------- | ---- | ----------------------- | +| NETWORK_TYPE_ANY | 0 | 表示这个触发条件是任何类型的网络连接。 | +| NETWORK_TYPE_MOBILE | 1 | 表示这个触发条件是Mobile网络连接。 | +| NETWORK_TYPE_WIFI | 2 | 表示这个触发条件是Wifi类型的网络连接。 | +| NETWORK_TYPE_BLUETOOTH | 3 | 表示这个触发条件是Bluetooth网络连接。 | +| NETWORK_TYPE_WIFI_P2P | 4 | 表示这个触发条件是Wifi P2P网络连接。 | +| NETWORK_TYPE_ETHERNET | 5 | 表示这个触发条件是有线网络连接。 | + +## ChargingType +触发工作的充电类型。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler + +| 名称 | 默认值 | 说明 | +| ------------------------- | ---- | -------------------- | +| CHARGING_PLUGGED_ANY | 0 | 表示这个触发条件是任何类型的充电器连接。 | +| CHARGING_PLUGGED_AC | 1 | 表示这个触发条件是直流充电器连接。 | +| CHARGING_PLUGGED_USB | 2 | 表示这个触发条件是USB充连接。 | +| CHARGING_PLUGGED_WIRELESS | 3 | 表示这个触发条件是无线充电器连接。 | + +## BatteryStatus +触发工作的电池状态。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler + +| 名称 | 默认值 | 说明 | +| -------------------------- | ---- | -------------------------- | +| BATTERY_STATUS_LOW | 0 | 表示这个触发条件是低电告警。 | +| BATTERY_STATUS_OKAY | 1 | 表示这个触发条件是从低电恢复到正常电量。 | +| BATTERY_STATUS_LOW_OR_OKAY | 2 | 表示这个触发条件是从低电恢复到正常电量或者低电告警。 | + +## StorageRequest +触发工作的存储状态。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler + + |名称 |默认值 |说明| + | -------- | -------- | -------- | + |STORAGE_LEVEL_LOW |0 |表示这个触发条件是存储空间不足。 + |STORAGE_LEVEL_OKAY |1 |表示这个触发条件是从存储空间不足恢复到正常。 + |STORAGE_LEVEL_LOW_OR_OKAY |2 |表示这个触发条件是从存储空间不足恢复到正常或者存储空间不足。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index f860a751b5d7a6c6c0e7bdcb7350b0a6dc590e56..f513523443f42d8038c2fc34ed5d3d4d40e1129a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -88,7 +88,7 @@ caretPosition(value: number): void ``` @Entry @Component -struct TextAreaExample2 { +struct TextAreaExample1 { @State text: string = '' build() { Column() { @@ -123,7 +123,7 @@ struct TextAreaExample2 { ``` @Entry @Component -struct TextAreaTest { +struct TextAreaExample2 { controller: TextAreaController = new TextAreaController() build() { Column() { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index 2a45556e43462bb6fdf754427eb01529fbcbc52f..279471bbf8ae99a48673addb5fd64e17c2f1a760 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -100,7 +100,7 @@ caretPosition(value: number): void ``` @Entry @Component -struct TextAreaExample2 { +struct TextInputExample1 { @State text: string = '' build() { @@ -134,7 +134,7 @@ struct TextAreaExample2 { ``` @Entry @Component -struct TextInputTest { +struct TextInputExample2 { @State text: string = '' controller: TextInputController = new TextInputController() build() { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md index 22dad5d017cb7fde6d3fcb67b43ff354ef946d15..6486c97a25964c9f1e6f10f72f95a77be28c6d5d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md @@ -26,13 +26,13 @@ TabContent() 不支持触摸热区设置。 -| 名称 | 参数类型 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| tabBar | string \| {
icon?: string,
text?: string
}
\| [CustomBuilder](../../ui/ts-types.md#custombuilder类型8+)8+ | - | 设置TabBar上显示内容。
CustomBuilder: 构造器,内部可以传入组件(API8版本以上适用)。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果icon采用svg格式图源,则要求svg图源删除其自有宽高属性值。如采用带有自有宽高属性的svg图源,icon大小则是svg本身内置的宽高属性值大小。 | +| 名称 | 参数类型 | 默认值 | 描述 | +| ------ | ---------------------------------------- | ---- | ---------------------------------------- | +| tabBar | string \| {
icon?: string,
text?: string
}
\| [CustomBuilder](../../ui/ts-types.md)8+ | - | 设置TabBar上显示内容。
CustomBuilder: 构造器,内部可以传入组件(API8版本以上适用)。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果icon采用svg格式图源,则要求svg图源删除其自有宽高属性值。如采用带有自有宽高属性的svg图源,icon大小则是svg本身内置的宽高属性值大小。 | > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - TabContent组件不支持设置通用宽度属性,其宽度默认撑满Tabs父组件。 -> +> > - TabContent组件不支持设置通用高度属性,其高度由Tabs父组件高度与TabBar组件高度决定。 diff --git a/zh-cn/application-dev/ui/ui-js-components-grid.md b/zh-cn/application-dev/ui/ui-js-components-grid.md index df6ac362e27ccc48685834c47b544d60b45779a5..ec3fd8941309b8b4208f9acd495072d3dd5b61d1 100644 --- a/zh-cn/application-dev/ui/ui-js-components-grid.md +++ b/zh-cn/application-dev/ui/ui-js-components-grid.md @@ -1,4 +1,4 @@ -# Grid +# 栅格布局 栅格布局容器根节点,使用grid-row与grid-col进行栅格布局。具体请参考[Grid-container](../reference/arkui-js/js-components-grid-container.md)。 diff --git a/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md b/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md index 1b7edd1205710adc65fd787f04aceacdf96ec4ad..57345d1720c689f987851f8dd69df2a8814eb9bd 100644 --- a/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md +++ b/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md @@ -433,7 +433,7 @@ ``` @Component struct ContentTable { - @Builder IngredientItem(title:string, colorValue: string, name: string, value: string) { + @Builder IngredientItem(title:string, name: string, value: string) { Flex() { Text(title) .fontSize(17.4) @@ -531,6 +531,6 @@ 针对创建简单视图,有以下示例工程可供参考: -- [eTSBuildCommonView](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/eTSBuildCommonView) +- [eTSBuildCommonView](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/BuildCommonView) 本示例为构建了简单页面展示食物番茄的图片和营养信息,主要为了展示简单页面的Stack布局和Flex布局。 diff --git a/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md b/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md index 8223e2a771379d0441519ee0ad3515ff6b0ae67b..e32f4b0b2c140bd70006b4e0fdb2879812fadcfc 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md @@ -12,25 +12,25 @@ ## 栅格系统 -栅格系统有Columns、Margins、Gutters三个概念。 +栅格系统有Column、Margin、Gutter三个概念。 ![zh-cn_image_0000001217236574](figures/zh-cn_image_0000001217236574.png) -1. Gutters: +1. Gutter: 用来控制元素与元素之间距离关系。可以根据设备的不同尺寸,定义不同的gutter值,作为栅格布局的统一规范。为了保证较好的视觉效果,通常gutter的取值不会大于margin的取值。 -2. Margins: +2. Margin: 离栅格容器边缘的距离。可以根据设备的不同尺寸,定义不同的margin值,作为栅格布局的统一规范。 -3. Columns: +3. Column: 栅格布局的主要定位工具。根据设备的不同尺寸,把栅格容器分割成不同的列数,在保证margin和gutter符合规范的情况下,根据总Column的个数计算每个Column列的宽度。 ### 系统栅格断点 -系统根据不同水平宽度设备对应Columns的数量关系,形成了一套断点规则定义。 +系统根据不同水平宽度设备对应Column的数量关系,形成了一套断点规则定义。 -系统以设备的水平宽度的屏幕密度像素值作为断点依据,根据当前设备水平宽度所在的断点范围,定义了设备的宽度类型。系统的栅格断点范围、设备宽度类型及其描述,以及对应的默认总列数(columns),边距(gutter),间隔(gutter)定义如下: +系统以设备的水平宽度的屏幕密度像素值作为断点依据,根据当前设备水平宽度所在的断点范围,定义了设备的宽度类型。系统的栅格断点范围、设备宽度类型及其描述,以及对应的默认总列数(column),边距(margin),间隔(gutter)定义如下: | 设备水平宽度断点范围 | 设备宽度类型 | 描述 | columns | gutter | margin | @@ -48,7 +48,7 @@ 通过接口`GridContainer(options?: { columns?: number | 'auto', sizeType?: SizeType, gutter?: Length, margin?: Length})`创建栅格容器,栅格容器内的所有子组件可以使用栅格布局。 -- 可以通过参数定义栅格布局的总列数(columns),间隔(gutter),两侧边距(margin)。例如栅格容器总共分为6列,列于列间隔为10vp, 两侧边距为20vp: +- 可以通过参数定义栅格布局的总列数(columns),间隔(gutter),两侧边距(margin)。例如栅格容器总共分为6列,列与列间隔为10vp, 两侧边距为20vp: ``` GridContainer({ columns: 6, gutter: 10, margin: 20 }) {} @@ -60,7 +60,7 @@ GridContainer() {} ``` - 上述例子中,默认在在小宽度类型设备(SizeType.SM)上,栅格容器被分为4列,列于列的间隔为24vp, 两侧边距是24vp。在中等宽度类型设备(SizeType.MD)上,栅格容器被分为8列,列于列的间隔为24vp,两侧边距是32vp。 + 上述例子中,默认在小宽度类型设备(SizeType.SM)上,栅格容器被分为4列,列与列的间隔为24vp, 两侧边距是24vp。在中等宽度类型设备(SizeType.MD)上,栅格容器被分为8列,列与列的间隔为24vp,两侧边距是32vp。 - 也可以通过参数sizeType指定此栅格容器内的组件使用此设备宽度类型的栅格设置,如: diff --git a/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md b/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md index 2bbcf5679d0b4aaa1c9e93c1c39641191da1df4f..380a6b8a0713c0d77c96ee464f05c153cb8700ff 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md @@ -15,11 +15,11 @@ 首先导入媒体查询模块,例如: ``` - import mediaquery from '@ohos.mediaquery' +import mediaquery from '@ohos.mediaquery' ``` 然后通过matchMediaSync接口设置媒体查询条件,并保存返回的条件监听句柄,例如: ``` - listener = mediaquery.matchMediaSync('(orientation: landscape)') +listener = mediaquery.matchMediaSync('(orientation: landscape)') ``` 最后通过上面保存的条件监听句柄listener去注册回调函数,在回调函数里更改页面布局或者实现业务逻辑,当匹配到媒体查询条件时会触发此回调函数,例如: ``` @@ -39,13 +39,13 @@ listener.on('change', onPortrait) ``` 例如: -screen and (round-screen: true) // 当设备屏幕是圆形时条件成立 +`screen and (round-screen: true)` :当设备屏幕是圆形时条件成立 -(max-height: 800) // 当高度小于800时条件成立 +`(max-height: 800)` :当高度小于800时条件成立 -(height <= 800) // 当高度小于800时条件成立 +`(height <= 800) ` :当高度小于800时条件成立 -screen and (device-type: tv) or (resolution < 2) // 包含多个媒体特征的多条件复杂语句查询 +`screen and (device-type: tv) or (resolution < 2)` :包含多个媒体特征的多条件复杂语句查询 ### 媒体类型(media-type) diff --git a/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md b/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md index 826fdd6f5c0db8f423d9ec0b2f85d6a53ff5c43e..7aaf302a3043f9699a41bd37517bc2b8c5fec6d0 100644 --- a/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md +++ b/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md @@ -267,6 +267,6 @@ 针对页面布局与连接,有以下示例工程可供参考: -- [eTSDefiningPageLayoutAndConnection](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/eTSDefiningPageLayoutAndConnection) +- [eTSDefiningPageLayoutAndConnection](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/DefiningPageLayoutAndConnection) 本示例构建了食物分类列表页面和食物详情页,向开发者展示了List布局、Grid布局以及页面路由的基本用法。 diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index 09e13ac43c52e5eff927b176af8037ffceece574..4717b423c14696a71c8575cd92f0b828349f7b5d 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -578,6 +578,8 @@ - 资源调度 - [@ohos.backgroundTaskManager (后台任务管理)](reference/apis/js-apis-backgroundTaskManager.md) + - [@ohos.workScheduler (延迟任务调度)](reference/apis/js-apis-workScheduler.md) + - [@ohos.WorkSchedulerExtensionAbility (延迟任务调度回调)](reference/apis/js-apis-WorkSchedulerExtensionAbility.md) - 定制管理 - [@ohos.configPolicy (配置策略)](reference/apis/js-apis-config-policy.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md index 3f1b6b56cb815e006e5f4ce5ccf7b9f3a108ebc4..bb73222e4580bbb3ca1698da91a517ac03016c85 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md @@ -7,12 +7,12 @@ OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存 考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: -- IDE方式:完全采用IDE(Deveco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 +- IDE方式:完全采用IDE(DevEco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 - 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 -本文采用Deveco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[轻量和小型系统快速入门(安装包方式)](../quick-start/quickstart-lite-package-directory.md)。 +本文采用DevEco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[轻量和小型系统快速入门(安装包方式)](../quick-start/quickstart-lite-package-directory.md)。 ## 开发环境 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md index a63a062889da8bdf6e09308e52abb0a511060977..f6f1961c270e114ca0d7c4fe8025a0d357ddc3e5 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md @@ -7,12 +7,12 @@ OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文, 考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: -- IDE方式:完全采用IDE(Deveco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 +- IDE方式:完全采用IDE(DevEco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 - 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 -本文采用Deveco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[标准系统快速入门(安装包方式)](../quick-start/quickstart-standard-package-directory.md)。 +本文采用DevEco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[标准系统快速入门(安装包方式)](../quick-start/quickstart-standard-package-directory.md)。 ## 开发环境 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-faq-burning.md b/zh-cn/device-dev/quick-start/quickstart-lite-faq-burning.md index 43c9baef63931bec9d01c3440515a371858843bf..8eac50fee385ac88f3bbb5158b1b76af12f8fb1b 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-faq-burning.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-faq-burning.md @@ -125,15 +125,13 @@ 1. 获取引导文件U-boot。 > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** - > 单板的U-boot文件请在开源包中获取: > - > Hi3516DV300:device\hisilicon\hispark_taurus\sdk_liteos\uboot\out\boot\u-boot-hi3516dv300.bin - > - > Hi3518EV300:device\hisilicon\hispark_aries\sdk_liteos\uboot\out\boot\u-boot-hi3518ev300.bin + > 单板的U-boot文件请在开源包中获取:device\hisilicon\hispark_taurus\sdk_liteos\uboot\out\boot\u-boot-hi3516dv300.bin + 2. 根据USB烧写步骤烧写U-boot文件。 - 按照[Hi3516系列USB烧写步骤](https://device.harmonyos.com/cn/docs/documentation/guide/ide-hi3516-upload-0000001052148681)/[Hi3518系列USB烧写步骤](https://device.harmonyos.com/cn/docs/documentation/guide/ide-hi3518-upload-0000001057313128#section93591711580)中描述的烧写方法,选择对应单板的U-boot文件进行烧写。 + 按照[Hi3516系列USB烧写步骤](https://device.harmonyos.com/cn/docs/documentation/guide/ide-hi3516-upload-0000001052148681)中描述的烧写方法,选择对应单板的U-boot文件进行烧写。 3. 烧写完成后,登录串口如下图所示。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md index b0cef24b4d2dba209ff14b954380a9e5061f91fc..1a83620da460d93d0c74ba9cb8083bcdcca8788a 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md @@ -21,7 +21,7 @@ build └── subsystem_config.json productdefine/common └── products - └── Hi3568DV300.json + └── Hi3516DV300.json ```