diff --git a/CODEOWNERS b/CODEOWNERS index 7c6530eb16de9051510d7344025cf8b61c566c78..6a8730751d65c0cd83e109d7a4edffce37b988ec 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -151,9 +151,9 @@ zh-cn/application-dev/work-scheduler/ @HelloCrease zh-cn/application-dev/internationalization/ @HelloCrease zh-cn/application-dev/device/usb-overview.md @ge-yafang zh-cn/application-dev/device/usb-guidelines.md @ge-yafang -zh-cn/application-dev/device/device-location-overview.md @sun-yue14 -zh-cn/application-dev/device/device-location-info.md @sun-yue14 -zh-cn/application-dev/device/device-location-geocoding.md @sun-yue14 +zh-cn/application-dev/device/device-location-overview.md @zengyawen +zh-cn/application-dev/device/device-location-info.md @zengyawen +zh-cn/application-dev/device/device-location-geocoding.md @zengyawen zh-cn/application-dev/device/sensor-overview.md @HelloCrease zh-cn/application-dev/device/sensor-guidelines.md @HelloCrease zh-cn/application-dev/device/vibrator-overview.md @HelloCrease @@ -277,14 +277,14 @@ zh-cn/application-dev/reference/apis/js-apis-http.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-request.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-socket.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-webSocket.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @bmeangel -zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @bmeangel -zh-cn/application-dev/reference/apis/js-apis-nfcTech.md @bmeangel -zh-cn/application-dev/reference/apis/js-apis-tagSession.md @bmeangel -zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @bmeangel +zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-nfcTech.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-tagSession.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-rpc.md @qinxiaowang -zh-cn/application-dev/reference/apis/js-apis-wifi.md @bmeangel -zh-cn/application-dev/reference/apis/js-apis-wifiext.md @bmeangel +zh-cn/application-dev/reference/apis/js-apis-wifi.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-wifiext.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-accessibility.md @qinxiaowang zh-cn/application-dev/reference/apis/js-apis-faultLogger.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-hiappevent.md @zengyawen @@ -293,18 +293,18 @@ zh-cn/application-dev/reference/apis/js-apis-hidebug.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-hilog.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-hitracechain.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-hitracemeter.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @bmeangel -zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @bmeangel +zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @ge-yafang -zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @bmeangel -zh-cn/application-dev/reference/apis/js-apis-system-time.md @bmeangel -zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @bmeangel +zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-system-time.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-timer.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-battery-info.md @qinxiaowang zh-cn/application-dev/reference/apis/js-apis-brightness.md @qinxiaowang zh-cn/application-dev/reference/apis/js-apis-device-info.md @qinxiaowang zh-cn/application-dev/reference/apis/js-apis-device-manager.md -zh-cn/application-dev/reference/apis/js-apis-geolocation.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-geolocation.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @HelloCrease diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md index 2205df9ceffb51c3c6cb7816f6d11784ba532b20..8cec5ca111cd814d599d159ab7b333259f669ea8 100644 --- a/en/application-dev/database/database-mdds-guidelines.md +++ b/en/application-dev/database/database-mdds-guidelines.md @@ -50,18 +50,41 @@ The following uses a single KV store as an example to describe the development p This permission must also be granted by the user when the application is started for the first time. The sample code is as follows: ```js + // FA model import featureAbility from '@ohos.ability.featureAbility'; - + function grantPermission() { - console.info('grantPermission'); - let context = featureAbility.getContext(); - context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { - console.info(`result.requestCode=${result.requestCode}`) - - }) - console.info('end grantPermission'); + console.info('grantPermission'); + let context = featureAbility.getContext(); + context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666).then((data) => { + console.info('success: ${data}'); + }).catch((error) => { + console.info('failed: ${error}'); + }) } - + + grantPermission(); + + // Stage model + import Ability from '@ohos.application.Ability'; + + let context = null; + + function grantPermission() { + class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + let context = this.context; + } + } + + let permissions = ['ohos.permission.DISTRIBUTED_DATASYNC']; + context.requestPermissionsFromUser(permissions).then((data) => { + console.log('success: ${data}'); + }).catch((error) => { + console.log('failed: ${error}'); + }); + } + grantPermission(); ``` @@ -73,25 +96,39 @@ The following uses a single KV store as an example to describe the development p The sample code is as follows: ```js + // Obtain the context of the FA model. + import featureAbility from '@ohos.ability.featureAbility'; + let context = featureAbility.getContext(); + + // Obtain the context of the stage model. + import AbilityStage from '@ohos.application.Ability'; + let context = null; + class MainAbility extends AbilityStage{ + onWindowStageCreate(windowStage){ + context = this.context; + } + } + let kvManager; try { const kvManagerConfig = { bundleName: 'com.example.datamanagertest', userInfo: { + context:context, userId: '0', userType: distributedData.UserType.SAME_USER_ID } } distributedData.createKVManager(kvManagerConfig, function (err, manager) { if (err) { - console.log("createKVManager err: " + JSON.stringify(err)); + console.log('Failed to create KVManager: ${error}'); return; } - console.log("createKVManager success"); + console.log('Created KVManager successfully'); kvManager = manager; }); } catch (e) { - console.log("An unexpected error occurred. Error: " + e); + console.log('An unexpected error occurred. Error: ${e}'); } ``` @@ -115,14 +152,14 @@ The following uses a single KV store as an example to describe the development p }; kvManager.getKVStore('storeId', options, function (err, store) { if (err) { - console.log("getKVStore err: " + JSON.stringify(err)); + console.log('Failed to get KVStore: ${err}'); return; } - console.log("getKVStore success"); + console.log('Got KVStore successfully'); kvStore = store; }); } catch (e) { - console.log("An unexpected error occurred. Error: " + e); + console.log('An unexpected error occurred. Error: ${e}'); } ``` @@ -136,7 +173,7 @@ The following uses a single KV store as an example to describe the development p ```js kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { - console.log("dataChange callback call data: " + JSON.stringify(data)); + console.log("dataChange callback call data: ${data}"); }); ``` @@ -153,13 +190,13 @@ The following uses a single KV store as an example to describe the development p try { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { - console.log("put err: " + JSON.stringify(err)); + console.log('Failed to put data: ${error}'); return; } - console.log("put success"); + console.log('Put data successfully'); }); } catch (e) { - console.log("An unexpected error occurred. Error: " + e); + console.log('An unexpected error occurred. Error: ${e}'); } ``` @@ -176,16 +213,16 @@ The following uses a single KV store as an example to describe the development p try { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { - console.log("put err: " + JSON.stringify(err)); + console.log('Failed to put data: ${error}'); return; } - console.log("put success"); + console.log('Put data successfully'); kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { - console.log("get success data: " + data); + console.log('Got data successfully: ${data}'); }); }); } catch (e) { - console.log("An unexpected error occurred. Error: " + e); + console.log('An unexpected error occurred. Error: ${e}'); } ``` @@ -204,7 +241,7 @@ The following uses a single KV store as an example to describe the development p let devManager; // Create deviceManager. - deviceManager.createDeviceManager("bundleName", (err, value) => { + deviceManager.createDeviceManager('bundleName', (err, value) => { if (!err) { devManager = value; // deviceIds is obtained by deviceManager by calling getTrustedDeviceListSync(). @@ -219,7 +256,7 @@ The following uses a single KV store as an example to describe the development p // 1000 indicates that the maximum delay is 1000 ms. kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000); } catch (e) { - console.log("An unexpected error occurred. Error: " + e); + console.log('An unexpected error occurred. Error: ${e}'); } } }); diff --git a/en/application-dev/database/database-mdds-overview.md b/en/application-dev/database/database-mdds-overview.md index 26efa7491805e871017db3593f5fa50d947717f5..cfe264a4f7eb06cd51cb834bc3e38ee27e649a14 100644 --- a/en/application-dev/database/database-mdds-overview.md +++ b/en/application-dev/database/database-mdds-overview.md @@ -1,105 +1,103 @@ # Distributed Data Service Overview -The distributed data service (DDS) implements distributed database collaboration across devices for applications. +The distributed data service (DDS) implements distributed database collaboration across devices for applications. Applications save data to distributed databases by calling the DDS APIs. The DDS isolates data of different applications based on a triplet of account, application, and database to ensure secure data access. The DDS synchronizes application data between trusted devices to provide users with consistent data access experience on different devices. You do not need to care about the implementation of the database locking mechanism. + ## Basic Concepts -- **KV data model** +### KV Data Model - The key-value \(KV\) data model allows data to be organized, indexed, and stored in key-value pairs. +The key-value (KV) data model allows data to be organized, indexed, and stored in KV pairs. - The KV data model is suitable for storing service data that is not related. It provides better read and write performance than the SQL database. The KV data model is widely used in distributed scenarios because it handles database version compatibility issues and data synchronization conflicts easily. The distributed database is based on the KV data model and provides KV-based access interfaces. +The KV data model is suitable for storing service data that is not related. It provides better read and write performance than the SQL database. The KV data model is widely used in distributed scenarios because it handles database version compatibility issues and data synchronization conflicts easily. The distributed database is based on the KV data model and provides KV-based access interfaces. -- **Distributed database transactions** +### Distributed Database Transaction - Distributed database transactions include local transactions \(same as the transactions of traditional databases\) and synchronization transactions. Synchronization transactions allow data to be synchronized between devices by local transaction. Synchronization of a local transaction modification either succeeds or fails on all the devices. +Distributed database transactions include local transactions (same as the transactions of traditional databases) and synchronization transactions. Synchronization transactions allow data to be synchronized between devices by local transaction. Synchronization of a local transaction modification either succeeds or fails on all the devices. -- **Distributed database consistency** +### Distributed Database Consistency - In a distributed scenario, cross-device collaboration demands consistent data between the devices in the same network. The data consistency can be classified into the following types: +In a distributed scenario, cross-device collaboration demands consistent data between the devices in the same network. The data consistency can be classified into the following types: - - **Strong consistency**: When data is inserted, deleted, or modified on a device, other devices in the same network will obtain the latest data immediately. - - **Weak consistency**: When data is added, deleted, or modified on a device, other devices in the same network may or may not obtain the latest data. The data on these devices may be inconsistent after a certain period of time. - - **Eventual consistency**: When data is added, deleted, or modified on a device, other devices in the same network may not obtain the latest data immediately. However, data on these devices will become consistent after a certain period of time. +- **Strong consistency**: When data is inserted, deleted, or modified on a device, other devices in the same network will obtain the latest data immediately. +- **Weak consistency**: When data is added, deleted, or modified on a device, other devices in the same network may or may not obtain the latest data. The data on these devices may be inconsistent after a certain period of time. +- **Eventual consistency**: When data is added, deleted, or modified on a device, other devices in the same network may not obtain the latest data immediately. However, data on these devices will become consistent after a certain period of time. - Strong consistency has high requirements on distributed data management and may be used in distributed server deployment. The DDS supports only the eventual consistency because mobile devices are not always online and the network has no center. +Strong consistency has high requirements on distributed data management and may be used in distributed server deployment. The DDS supports only the eventual consistency because mobile devices are not always online and the network has no center. -- **Distributed database synchronization** +### Distributed Database Synchronization - After discovering and authenticating a device, the underlying communication component notifies the upper-layer application \(including the DDS\) that the device goes online. The DDS then establishes an encrypted transmission channel to synchronize data between the two devices. +After discovering and authenticating a device, the underlying communication component notifies the upper-layer application (including the DDS) that the device goes online. The DDS then establishes an encrypted transmission channel to synchronize data between the two devices. - The DDS provides the following synchronization modes: +The DDS provides the following synchronization modes: - - **Manual synchronization**: Applications call **sync** to trigger a synchronization. The list of devices to be synchronized and the synchronization mode must be specified. The synchronization mode can be **PULL\_ONLY** \(pulling remote data to the local end\), **PUSH\_ONLY** \(pushing local data to the remote end\), or **PUSH\_PULL** \(pushing local data to the remote end and pulling remote data to the local end\). The internal interface supports condition-based synchronization. The data that meets the conditions can be synchronized to the remote end. - - **Automatic synchronization**: includes full synchronization and condition-based subscription synchronization. In full synchronization, the distributed database automatically pushes local data to the remote end and pulls remote data to the local end when a device goes online or application data is updated. Applications do not need to call **sync**. The internal interface supports condition-based subscription synchronization. The data that meets the subscription conditions on the remote end is automatically synchronized to the local end. +- **Manual synchronization**: Applications call **sync()** to trigger a synchronization. The list of devices to be synchronized and the synchronization mode must be specified. The synchronization mode can be **PULL_ONLY** (pulling remote data to the local end), **PUSH_ONLY** (pushing local data to the remote end), or **PUSH_PULL** (pushing local data to the remote end and pulling remote data to the local end). The internal interface supports condition-based synchronization. The data that meets the conditions can be synchronized to the remote end. +- **Automatic synchronization**: includes full synchronization and condition-based subscription synchronization. In full synchronization, the distributed database automatically pushes local data to the remote end and pulls remote data to the local end when a device goes online or application data is updated. Applications do not need to call **sync()**. The internal interface supports condition-based subscription synchronization. The data that meets the subscription conditions on the remote end is automatically synchronized to the local end. -- **Single KV store** +### Single KV Store - Data is saved locally in the unit of a single KV entry. Only one entry is saved for each key. Data can be modified only locally and synchronized to remote devices in sequence based on the update time. +Data is saved locally in the unit of a single KV entry. Only one entry is saved for each key. Data can be modified only locally and synchronized to remote devices in sequence based on the update time. -- **Device KV store** +### Device KV Store - The device KV store is based on the single KV store. The local device ID is added to the key when KV data is stored in the device KV store. Data can be isolated, managed, and queried by device. However, the data synchronized from remote devices cannot be modified locally. +The device KV store is based on the single KV store. The local device ID is added to the key when KV data is stored in the device KV store. Data can be isolated, managed, and queried by device. However, the data synchronized from remote devices cannot be modified locally. -- **Conflict resolution** +### Conflict Resolution - A data conflict occurs when multiple devices modify the same data and commit the modification to the database. The last write wins \(LWW\) is the default conflict resolution policy used for data conflicts. Based on the commit timestamps, the data with a later timestamp is used. Currently, customized conflict resolution policies are not supported. +A data conflict occurs when multiple devices modify the same data and commit the modification to the database. The last write wins (LWW) is the default conflict resolution policy used for data conflicts. Based on the commit timestamps, the data with a later timestamp is used. Currently, customized conflict resolution policies are not supported. -- **Schema-based database management and data query based on predicates** +### Schema-based Database Management and Predicate-based Data Query - A schema is specified when you create or open a single KV store. Based on the schema, the database detects the value format of key-value pairs and checks the value structure. Based on the fields in the values, the database implements index creation and predicate-based query. +A schema is specified when you create or open a single KV store. Based on the schema, the database detects the value format of KV pairs and checks the value structure. Based on the fields in the values, the database implements index creation and predicate-based query. -- **Distributed database backup** +### Distributed Database Backup - The DDS provides the database backup capability. You can set **backup** to **true** to enable daily backup. If a distributed database is damaged, the DDS deletes the database and restores the most recent data from the backup database. If no backup database is available, the DDS creates one. The DDS can also back up encrypted databases. +The DDS provides the database backup capability. You can set **backup** to **true** to enable daily backup. If a distributed database is damaged, the DDS deletes the database and restores the most recent data from the backup database. If no backup database is available, the DDS creates one. The DDS can also back up encrypted databases. ## Working Principles -The DDS supports distributed management of application database data in the OpenHarmony system. Data can be synchronized between multiple devices with the same account, delivering a consistent user experience across devices. The DDS consists of the following: +The DDS supports distributed management of application database data in the OpenHarmony system. Data can be synchronized between multiple devices with the same account, delivering a consistent user experience across devices. -- **APIs** +The DDS consists of the following: - The DDS provides APIs to create databases, access data, and subscribe to data. The APIs support the KV data model and common data types. They are highly compatible and easy to use, and can be released. +- **APIs**
The DDS provides APIs to create databases, access data, and subscribe to data. The APIs support the KV data model and common data types. They are highly compatible and easy to use, and can be released. -- **Service component** +- **Service component**
The service component implements management of metadata, permissions, encryption, backup and restore, and multiple users, and completes initialization of the storage component, synchronization component, and communication adaptation layer of the distributed database. - The service component implements management of metadata, permissions, encryption, backup and restore, and multiple users, and completes initialization of the storage component, synchronization component, and communication adaptation layer of the distributed database. +- **Storage component**
The storage component implements data access, data reduction, transactions, snapshots, database encryption, data combination, and conflict resolution. -- **Storage component** +- **Synchronization component**
The synchronization component interacts with the storage component and the communication adaptation layer to maintain data consistency between online devices. It synchronizes data generated on the local device to other devices and merges data from other devices into the local device. - The storage component implements data access, data reduction, transactions, snapshots, database encryption, data combination, and conflict resolution. +- **Communication adaptation layer**
The communication adaptation layer calls APIs of the underlying public communication layer to create and connect to communication channels, receive device online and offline messages, update metadata of the connected and disconnected devices, send device online and offline messages to the synchronization component. The synchronization component updates the list of connected devices, and calls the APIs of the communication adaption layer to encapsulate data and send the data to the connected devices. -- **Synchronization component** +Applications call the DDS APIs to create, access, and subscribe to distributed databases. The APIs store data to the storage component based on the capabilities provided by the service component. The storage component interacts with the synchronization component to synchronize data. The synchronization component uses the communication adaptation layer to synchronize data to remote devices, which update the data in the storage component and provide the data for applications through service APIs. - The synchronization component interacts with the storage component and the communication adaptation layer to maintain data consistency between online devices. It synchronizes data generated on the local device to other devices and merges data from other devices into the local device. -- **Communication adaptation layer** +**Figure 1** How DDS works - The communication adaptation layer calls APIs of the underlying public communication layer to create and connect to communication channels, receive device online and offline messages, update metadata of the connected and disconnected devices, send device online and offline messages to the synchronization component. The synchronization component updates the list of connected devices, and calls the APIs of the communication adaption layer to encapsulate data and send the data to the connected devices. +![](figures/en-us_image_0000001183386164.png) -Applications call the DDS APIs to create, access, and subscribe to distributed databases. The APIs store data to the storage component based on the capabilities provided by the service component. The storage component interacts with the synchronization component to synchronize data. The synchronization component uses the communication adaptation layer to synchronize data to remote devices, which update the data in the storage component and provide the data for applications through service APIs. -**Figure 1** How DDS works +## Constraints +- The DDS supports the KV data model only. It does not support foreign keys or triggers of the relational database. -![](figures/en-us_image_0000001183386164.png) +- The KV data model specifications supported by the DDS are as follows: -## Constraints + - For each record in a device KV store, the key must be less than or equal to 896 bytes and the value be less than 4 MB. + - For each record in a single KV store, the key must be less than or equal to 1 KB and the value be less than 4 MB. + - An application can open a maximum of 16 KV stores simultaneously. + +- The data that needs to be synchronized between devices should be stored in distributed databases rather than local databases. -- The DDS supports the KV data model only. It does not support foreign keys or triggers of the relational database. -- The KV data model specifications supported by the DDS are as follows: - - For each record in a device KV store, the key must be less than or equal to 896 bytes and the value be less than 4 MB. - - For each record in a single KV store, the key must be less than or equal to 1 KB and the value be less than 4 MB. - - An application can open a maximum of 16 KV stores simultaneously. +- The DDS does not support customized conflict resolution policies. -- The data that needs to be synchronized between devices should be stored in distributed databases rather than local databases. -- The DDS does not support customized conflict resolution policies. -- The maximum number of access requests to the KvStore API is 1000 per second and 10000 per minute. The maximum number of access requests to the KvManager API is 50 per second and 500 per minute. -- Blocking operations, such as modifying UI components, are not allowed in the distributed database event callback. +- The maximum number of access requests to the KvStore API is 1000 per second and 10000 per minute. The maximum number of access requests to the KvManager API is 50 per second and 500 per minute. +- Blocking operations, such as modifying UI components, are not allowed in the distributed database event callback. diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index a4acbd9a7b47dca4332c7f6a881939b1928abd78..bd38925cbe8a17e5cb6319ffc9729ef263945e9c 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -196,17 +196,41 @@ Table 15 Transaction APIs (3) Create an RDB store. - The sample code is as follows: + FA model: ```js - import data_rdb from '@ohos.data.rdb' + import data_rdb from '@ohos.data.rdb' + // Obtain the context. + import featureAbility from '@ohos.ability.featureAbility' + let context = featureAbility.getContext() + + const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; - const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; - const STORE_CONFIG = { name: "rdbstore.db" } - data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { + const STORE_CONFIG = { name: "RdbTest.db" } + data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) { rdbStore.executeSql(CREATE_TABLE_TEST) console.info('create table done.') - }) + }) + ``` + Stage model: + ```ts + import data_rdb from '@ohos.data.rdb' + // Obtain the context. + import Ability from '@ohos.application.Ability' + let context = null + class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + context = this.context + } + } + + const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; + + const STORE_CONFIG = { name: "rdbstore.db" } + data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) { + rdbStore.executeSql(CREATE_TABLE_TEST) + console.info('create table done.') + }) ``` 2. Insert data. diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md index 44f96b01b333ed9ad5e1258b0173734c0c7869d7..c98d603c0092e8f2fd9e1f9a2ce0d33ecd9cc1a7 100644 --- a/en/application-dev/reference/apis/js-apis-appAccount.md +++ b/en/application-dev/reference/apis/js-apis-appAccount.md @@ -2104,6 +2104,7 @@ Called to return the result of an authentication request. **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ------ | -------------------- | ---- | ------ | | code | number | Yes | Authentication result code.| @@ -2134,6 +2135,7 @@ Called to redirect a request. **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ------- | ---- | ---- | ---------- | | request | Want | Yes | Request to be redirected.| @@ -2191,6 +2193,7 @@ Implicitly adds an app account based on the specified authentication type and op **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | authType | string | Yes | Authentication type. | @@ -2207,6 +2210,7 @@ Authenticates an app account to obtain the OAuth token. This API uses an asynchr **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | name | string | Yes | Name of the target app account. | @@ -2224,6 +2228,7 @@ Verifies the credential of an app account. This API uses an asynchronous callbac **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | name | string | Yes | Name of the target app account. | @@ -2239,6 +2244,7 @@ Sets authenticator properties. This API uses an asynchronous callback to return **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | options | [SetPropertiesOptions](#setpropertiesoptions9) | Yes | Authenticator properties to set. | @@ -2253,6 +2259,7 @@ Checks the account labels. This API uses an asynchronous callback to return the **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | name | string | Yes | Name of the target app account. | @@ -2268,6 +2275,7 @@ Checks whether an app account can be deleted. This API uses an asynchronous call **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | name | string | Yes | Name of the target app account. | diff --git a/en/application-dev/reference/apis/js-apis-data-storage.md b/en/application-dev/reference/apis/js-apis-data-storage.md index ff9f8d69e48847bd60741f174af4dbe92a19e2ee..f01e1a3ab8db3d7fb42d8362a35e29455066b15e 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -5,9 +5,11 @@ Lightweight storage provides applications with data processing capability and al > **NOTE** > -> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > -> - The APIs of this module are no longer maintained since API Version 9. You are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md). +> - The APIs of this module are no longer maintained since API version 9. You are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md). +> +> - The APIs of this module can be used only in the FA model. ## Modules to Import @@ -36,15 +38,15 @@ Reads the specified file and loads its data to the **Storage** instance for data **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Return value** -| Type | Description | -| ------------------- | ------------------------------------------------------ | -| [Storage](#storage) | **Storage** instance used for data storage operations. | +| Type | Description | +| ------------------- | ------------------------------------------------- | +| [Storage](#storage) | **Storage** instance used for data storage operations.| **Example** @@ -54,13 +56,13 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -let storage = data_storage.getStorageSync(path + '/mystore'); -storage.putSync('startup', 'auto'); -storage.flushSync(); + let storage = data_storage.getStorageSync(path + '/mystore'); + storage.putSync('startup', 'auto'); + storage.flushSync(); +}); ``` @@ -74,10 +76,10 @@ Reads the specified file and loads its data to the **Storage** instance for data **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | --------------------------------------------- | -| path | string | Yes | Path of the target file. | -| callback | AsyncCallback<[Storage](#storage)> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| +| callback | AsyncCallback<[Storage](#storage)> | Yes | Callback used to return the execution result. | **Example** @@ -87,18 +89,18 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -data_storage.getStorage(path + '/mystore', function (err, storage) { + data_storage.getStorage(path + '/mystore', function (err, storage) { if (err) { - console.info("Failed to get the storage. path: " + path + '/mystore'); - return; + console.info("Failed to get the storage. path: " + path + '/mystore'); + return; } storage.putSync('startup', 'auto'); storage.flushSync(); -}) + }) +}); ``` @@ -112,15 +114,15 @@ Reads the specified file and loads its data to the **Storage** instance for data **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Return value** -| Type | Description | -| ---------------------------------- | ---------------------------------- | -| Promise<[Storage](#storage)> | Promise used to return the result. | +| Type | Description | +| ---------------------------------- | ------------------------------- | +| Promise<[Storage](#storage)> | Promise used to return the result.| **Example** @@ -130,17 +132,17 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -let getPromise = data_storage.getStorage(path + '/mystore'); -getPromise.then((storage) => { + let getPromise = data_storage.getStorage(path + '/mystore'); + getPromise.then((storage) => { storage.putSync('startup', 'auto'); storage.flushSync(); -}).catch((err) => { + }).catch((err) => { console.info("Failed to get the storage. path: " + path + '/mystore'); -}) + }) +}); ``` @@ -154,9 +156,9 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Example** @@ -168,12 +170,11 @@ var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); -}); -data_storage.deleteStorageSync(path + '/mystore'); + data_storage.deleteStorageSync(path + '/mystore'); +}); ``` - ## data_storage.deleteStorage deleteStorage(path: string, callback: AsyncCallback<void>): void @@ -184,9 +185,9 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------- | -| path | string | Yes | Path of the target file. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -197,17 +198,17 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -data_storage.deleteStorage(path + '/mystore', function (err) { + data_storage.deleteStorage(path + '/mystore', function (err) { if (err) { - console.info("Failed to delete the storage with err: " + err); - return; + console.info("Failed to delete the storage with err: " + err); + return; } console.info("Succeeded in deleting the storage."); -}) + }) +}); ``` @@ -221,13 +222,14 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Return value** -| Type | Description | -| ------------------- | ------------------------------ | + +| Type | Description | +| ------------------- | ------------------------------- | | Promise<void> | Promise that returns no value. | **Example** @@ -238,16 +240,16 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -let promisedelSt = data_storage.deleteStorage(path + '/mystore'); -promisedelSt.then(() => { + let promisedelSt = data_storage.deleteStorage(path + '/mystore'); + promisedelSt.then(() => { console.info("Succeeded in deleting the storage."); -}).catch((err) => { + }).catch((err) => { console.info("Failed to delete the storage with err: " + err); -}) + }) +}); ``` @@ -260,10 +262,9 @@ Removes the singleton **Storage** instance of a file from the cache. The removed **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** - -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Example** @@ -275,9 +276,9 @@ var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); + + data_storage.removeStorageFromCacheSync(path + '/mystore'); }); - -data_storage.removeStorageFromCacheSync(path + '/mystore'); ``` @@ -291,9 +292,9 @@ Removes the singleton **Storage** instance of a file from the cache. The removed **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------- | -| path | string | Yes | Path of the target file. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -304,17 +305,17 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -data_storage.removeStorageFromCache(path + '/mystore', function (err) { + data_storage.removeStorageFromCache(path + '/mystore', function (err) { if (err) { - console.info("Failed to remove storage from cache with err: " + err); - return; + console.info("Failed to remove storage from cache with err: " + err); + return; } console.info("Succeeded in removing storage from cache."); -}) + }) +}); ``` @@ -328,14 +329,14 @@ Removes the singleton **Storage** instance of a file from the cache. The removed **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Return value** -| Type | Description | -| ------------------- | ------------------------------ | +| Type | Description | +| ------------------- | ------------------------------- | | Promise<void> | Promise that returns no value. | **Example** @@ -346,24 +347,22 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore') -promiserevSt.then(() => { + let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore') + promiserevSt.then(() => { console.info("Succeeded in removing storage from cache."); -}).catch((err) => { + }).catch((err) => { console.info("Failed to remove storage from cache with err: " + err); -}) + }) +}); ``` - ## Storage Provides APIs for obtaining and modifying storage data. - ### getSync getSync(key: string, defValue: ValueType): ValueType @@ -374,16 +373,16 @@ Obtains the value corresponding to a key. If the value is null or not in the def **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ----------------------- | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| defValue | [ValueType](#valuetype) | Yes | Default value to be returned if the value of the specified key does not exist. It can be a number, string, or Boolean value. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ------------------------------------------------------------ | +| key | string | Yes | Key of the data. It cannot be empty. | +| defValue | [ValueType](#valuetype) | Yes | Default value to be returned if the value of the specified key does not exist. It can be a number, string, or Boolean value.| **Return value** -| Type | Description | -| --------- | ------------------------------------------------------------ | -| ValueType | Value corresponding to the specified key. If the value is null or not in the default value format, the default value is returned. | +| Type | Description | +| --------- | -------------------------------------------------------- | +| ValueType | Value corresponding to the specified key. If the value is null or not in the default value format, the default value is returned.| **Example** @@ -403,11 +402,11 @@ Obtains the value corresponding to a key. If the value is null or not in the def **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------ | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| defValue | [ValueType](#valuetype) | Yes | Default value to be returned. It can be a number, string, or Boolean value. | -| callback | AsyncCallback<ValueType> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------ | ---- | ----------------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty. | +| defValue | [ValueType](#valuetype) | Yes | Default value to be returned. It can be a number, string, or Boolean value.| +| callback | AsyncCallback<ValueType> | Yes | Callback used to return the execution result. | **Example** @@ -432,18 +431,19 @@ Obtains the value corresponding to a key. If the value is null or not in the def **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ----------------------- | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| defValue | [ValueType](#valuetype) | Yes | Default value to be returned. It can be a number, string, or Boolean value. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ----------------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty. | +| defValue | [ValueType](#valuetype) | Yes | Default value to be returned. It can be a number, string, or Boolean value.| **Return value** -| Type | Description | -| ------------------------ | ---------------------------------- | -| Promise<ValueType> | Promise used to return the result. | +| Type | Description | +| ------------------------ | ------------------------------- | +| Promise<ValueType> | Promise used to return the result.| **Example** + ```js let promiseget = storage.get('startup', 'default'); promiseget.then((value) => { @@ -464,15 +464,15 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ----------------------- | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value. | +| Name| Type | Mandatory| Description | +| ------ | ----------------------- | ---- | ----------------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty. | +| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value.| **Example** ```js -storage.putSync('startup', 'auto') +storage.putSync('startup', 'auto'); ``` @@ -486,10 +486,10 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ----------------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty. | +| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value.| | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -515,18 +515,19 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ----------------------- | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value. | +| Name| Type | Mandatory| Description | +| ------ | ----------------------- | ---- | ----------------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty. | +| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value.| **Return value** -| Type | Description | -| ------------------- | ------------------------------ | +| Type | Description | +| ------------------- | --------------------------- | | Promise<void> | Promise that returns no value. | **Example** + ```js let promiseput = storage.put('startup', 'auto'); promiseput.then(() => { @@ -547,15 +548,15 @@ Checks whether the storage object contains data with a given key. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty.| **Return value** -| Type | Description | -| ------- | ------------------------------------------------------------ | -| boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise. | +| Type | Description | +| ------- | ------------------------------------- | +| boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise.| **Example** @@ -577,16 +578,16 @@ Checks whether the storage object contains data with a given key. This API uses **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------- | --------- | --------------------------------------------- | -| key | string | Yes | Key of the data. It cannot be empty. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty.| +| callback | AsyncCallback<boolean> | Yes | Callback used to return the execution result. | **Return value** -| Type | Description | -| ------- | ------------------------------------------------------------ | -| boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise. | +| Type | Description | +| ------- | ------------------------------- | +| boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise.| **Example** @@ -613,15 +614,15 @@ Checks whether the storage object contains data with a given key. This API uses **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty.| **Return value** -| Type | Description | -| ---------------------- | ---------------------------------- | -| Promise<boolean> | Promise used to return the result. | +| Type | Description | +| ---------------------- | --------------------------- | +| Promise<boolean> | Promise used to return the result.| **Example** @@ -647,14 +648,14 @@ Deletes data with the specified key from this storage object. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | --------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty.| **Example** ```js -storage.deleteSync('startup') + storage.deleteSync('startup'); ``` @@ -668,9 +669,9 @@ Deletes data with the specified key from this storage object. This API uses an a **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty.| | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -696,14 +697,14 @@ Deletes data with the specified key from this storage object. This API uses a pr **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ---------------- | -| key | string | Yes | Key of the data. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | --------------------- | +| key | string | Yes | Key of the data.| **Return value** -| Type | Description | -| ------------------- | ------------------------------ | +| Type | Description | +| ------------------- | --------------------------- | | Promise<void> | Promise that returns no value. | **Example** @@ -729,7 +730,7 @@ Saves the modification of this object to the **Storage** instance and synchroniz **Example** ```js -storage.flushSync() +storage.flushSync(); ``` @@ -743,8 +744,8 @@ Saves the modification of this object to the **Storage** instance and synchroniz **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------- | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -770,8 +771,8 @@ Saves the modification of this object to the **Storage** instance and synchroniz **Return value** -| Type | Description | -| ------------------- | ------------------------------ | +| Type | Description | +| ------------------- | --------------------------- | | Promise<void> | Promise that returns no value. | **Example** @@ -797,7 +798,7 @@ Clears this **Storage** object. **Example** ```js -storage.clearSync() +storage.clearSync(); ``` @@ -811,8 +812,8 @@ Clears this **Storage** object. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------- | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -837,9 +838,8 @@ Clears this **Storage** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Return value** - -| Type | Description | -| ------------------- | ------------------------------ | +| Type | Description | +| ------------------- | --------------------------- | | Promise<void> | Promise that returns no value. | **Example** @@ -864,10 +864,10 @@ Subscribes to data changes. The **StorageObserver** needs to be implemented. Whe **Parameters** -| Name | Type | Description | -| -------- | --------------------------------------------------- | ------------------------------------------------------------ | -| type | string | Event type. The value **change** indicates data change events. | -| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. | +| Name | Type | Description | +| -------- | --------------------------------------------------- | ---------------------------------------- | +| type | string | Event type. The value **change** indicates data change events.| +| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. | **Example** @@ -891,10 +891,10 @@ Unsubscribes from data changes. **Parameters** -| Name | Type | Description | -| -------- | --------------------------------------------------- | ------------------------------------------------------------ | -| type | string | Event type. The value **change** indicates data change events. | -| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. | +| Name | Type | Description | +| -------- | --------------------------------------------------- | ---------------------------------------- | +| type | string | Event type. The value **change** indicates data change events.| +| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. | **Example** @@ -910,9 +910,9 @@ storage.off('change', observer); **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------- | -| key | string | No | Data changed. | +| Name| Type| Mandatory| Description | +| ---- | -------- | ---- | ---------------- | +| key | string | No | Data changed.| ## ValueType @@ -920,8 +920,8 @@ Enumerates the value types. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -| Type | Description | -| ------- | ----------------------------- | -| number | The value is a number. | -| string | The value is a string. | -| boolean | The value is of Boolean type. | \ No newline at end of file +| Type | Description | +| ------- | -------------------- | +| number | The value is a number. | +| string | The value is a string. | +| boolean | The value is of Boolean type.| diff --git a/en/application-dev/reference/apis/js-apis-distributed-account.md b/en/application-dev/reference/apis/js-apis-distributed-account.md index efb9ce6224f75f0f56638fd209f888e45a65290c..4dc76cd2d39f631d74d5c51b61259bd88a1ea924 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-account.md +++ b/en/application-dev/reference/apis/js-apis-distributed-account.md @@ -21,12 +21,13 @@ Obtains a **DistributedAccountAbility** instance. **System capability**: SystemCapability.Account.OsAccount -- Return value +**Return value** + | Type| Description| | -------- | -------- | | [DistributedAccountAbility](#distributedaccountability) | **DistributedAccountAbility** instance obtained. This instance provides methods for querying and updating the login state of a distributed account.| -- Example +**Example** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); ``` @@ -45,12 +46,13 @@ Obtains distributed account information. This API uses an asynchronous callback **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC -- Parameters +**Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the distributed account information obtained.| -- Example +**Example** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo((err, data) => { @@ -70,12 +72,13 @@ Obtains distributed account information. This API uses a promise to return the r **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC -- Return value +**Return value** + | Type| Description| | -------- | -------- | | Promise<[DistributedInfo](#distributedinfo)> | Promise used to return the distributed account information obtained.| -- Example +**Example** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo().then((data) => { @@ -96,13 +99,14 @@ Updates distributed account information. This API uses an asynchronous callback **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS -- Parameters +**Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | accountInfo | [DistributedInfo](#distributedinfo) | Yes| Distributed account information.| | callback | AsyncCallback<void> | Yes| Callback invoked when the distributed account information is updated.| -- Example +**Example** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; @@ -121,17 +125,19 @@ Updates distributed account information. This API uses a promise to return the r **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS -- Parameters +**Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | accountInfo | [DistributedInfo](#distributedinfo) | Yes| Distributed account information.| -- Return value +**Return value** + | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example +**Example** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; diff --git a/en/application-dev/reference/apis/js-apis-distributed-data.md b/en/application-dev/reference/apis/js-apis-distributed-data.md index 7ad7cfe126f1186189c62cd525098aad770cdabd..b1ceeabca8640799415596532a757f67d62e92c8 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-data.md +++ b/en/application-dev/reference/apis/js-apis-distributed-data.md @@ -45,55 +45,50 @@ Stage model: import AbilityStage from '@ohos.application.Ability' let kvManager; export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("MyAbilityStage onCreate") - let context = this.context - const kvManagerConfig = { - context: context, - bundleName: 'com.example.datamanagertest', - userInfo: { - userId: '0', - userType: distributedData.UserType.SAME_USER_ID - } + onCreate() { + console.log("MyAbilityStage onCreate") + let context = this.context + const kvManagerConfig = { + context: context, + bundleName: 'com.example.datamanagertest', + userInfo: { + userId: '0', + userType: distributedData.UserType.SAME_USER_ID + } + } + distributedData.createKVManager(kvManagerConfig, function (err, manager) { + if (err) { + console.log("Failed to create KVManager: " + JSON.stringify(err)); + return; + } + console.log("Created KVManager successfully"); + kvManager = manager; + }); } - distributedData.createKVManager(kvManagerConfig, function (err, manager) { - if (err) { - console.log("Failed to create KVManager: " + JSON.stringify(err)); - return; - } - console.log("Created KVManager successfully"); - kvManager = manager; - }); - } } ``` FA model: ```js -import AbilityStage from '@ohos.application.Ability' +import featureAbility from '@ohos.ability.featureAbility' let kvManager; -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("MyAbilityStage onCreate") - let context = this.context - const kvManagerConfig = { - context: context.getApplicationContext(), - bundleName: 'com.example.datamanagertest', - userInfo: { +let context = featureAbility.getContext() +const kvManagerConfig = { + context: context, + bundleName: 'com.example.datamanagertest', + userInfo: { userId: '0', userType: distributedData.UserType.SAME_USER_ID - } } - distributedData.createKVManager(kvManagerConfig, function (err, manager) { - if (err) { +} +distributedData.createKVManager(kvManagerConfig, function (err, manager) { + if (err) { console.log("Failed to create KVManager: " + JSON.stringify(err)); return; - } - console.log("Created KVManager successfully"); - kvManager = manager; - }); - } -} + } + console.log("Created KVManager successfully"); + kvManager = manager; +}); ``` ## distributedData.createKVManager @@ -123,55 +118,46 @@ Stage model: import AbilityStage from '@ohos.application.Ability' let kvManager; export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("MyAbilityStage onCreate") - let context = this.context - const kvManagerConfig = { - context: context, - bundleName: 'com.example.datamanagertest', - userInfo: { - userId: '0', - userType: distributedData.UserType.SAME_USER_ID - } + onCreate() { + console.log("MyAbilityStage onCreate") + let context = this.context + const kvManagerConfig = { + context: context, + bundleName: 'com.example.datamanagertest', + userInfo: { + userId: '0', + userType: distributedData.UserType.SAME_USER_ID + } + } + distributedData.createKVManager(kvManagerConfig).then((manager) => { + console.log("Created KVManager successfully"); + kvManager = manager; + }).catch((err) => { + console.log("Failed to create KVManager: " + JSON.stringify(err)); + }); } - distributedData.createKVManager(kvManagerConfig, function (err, manager) { - if (err) { - console.log("Failed to create KVManager: " + JSON.stringify(err)); - return; - } - console.log("Created KVManager successfully"); - kvManager = manager; - }); - } } ``` FA model: ```js -import AbilityStage from '@ohos.application.Ability' +import featureAbility from '@ohos.ability.featureAbility' let kvManager; -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("MyAbilityStage onCreate") - let context = this.context - const kvManagerConfig = { - context: context.getApplicationContext(), - bundleName: 'com.example.datamanagertest', - userInfo: { +let context = featureAbility.getContext() +const kvManagerConfig = { + context: context, + bundleName: 'com.example.datamanagertest', + userInfo: { userId: '0', userType: distributedData.UserType.SAME_USER_ID - } } - distributedData.createKVManager(kvManagerConfig, function (err, manager) { - if (err) { - console.log("Failed to create KVManager: " + JSON.stringify(err)); - return; - } - console.log("Created KVManager successfully"); - kvManager = manager; - }); - } } +distributedData.createKVManager(kvManagerConfig).then((manager) => { + console.log("Created KVManager successfully"); + kvManager = manager; +}).catch((err) => { + console.log("Failed to create KVManager: " + JSON.stringify(err)); +}); ``` ## KVManagerConfig @@ -320,7 +306,7 @@ Closes a KV store. This API uses an asynchronous callback to return the result. | appId | string | Yes | Bundle name of the app that invokes the KV store. | | storeId | string | Yes | Unique identifier of the KV store to close. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| | kvStore | [KVStore](#kvstore) | Yes | KV store to close. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.| **Example** @@ -328,21 +314,21 @@ Closes a KV store. This API uses an asynchronous callback to return the result. let kvStore; let kvManager; const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - schema : '', - securityLevel : distributedData.SecurityLevel.S2, - } - try { + createIfMissing: true, + encrypt: false, + backup: false, + autoSync: true, + kvStoreType: distributedData.KVStoreType.SINGLE_VERSION, + schema: '', + securityLevel: distributedData.SecurityLevel.S2, +} +try { kvManager.getKVStore('storeId', options, async function (err, store) { - console.log('getKVStore success'); - kvStore = store; - kvManager.closeKVStore('appId', 'storeId', kvStore, function (err, data) { - console.log('closeKVStore success'); - }); + console.log('getKVStore success'); + kvStore = store; + kvManager.closeKVStore('appId', 'storeId', kvStore, function (err, data) { + console.log('closeKVStore success'); + }); }); } catch (e) { console.log('closeKVStore e ' + e); @@ -378,29 +364,29 @@ Closes a KV store. This API uses a promise to return the result. let kvManager; let kvStore; const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - schema : '', - securityLevel : distributedData.SecurityLevel.S2, + createIfMissing: true, + encrypt: false, + backup: false, + autoSync: true, + kvStoreType: distributedData.KVStoreType.SINGLE_VERSION, + schema: '', + securityLevel: distributedData.SecurityLevel.S2, } - try { +try { kvManager.getKVStore('storeId', options).then(async (store) => { - console.log('getKVStore success'); - kvStore = store; - kvManager.closeKVStore('appId', 'storeId', kvStore).then(() => { - console.log('closeKVStore success'); - }).catch((err) => { - console.log('closeKVStore err ' + JSON.stringify(err)); - }); + console.log('getKVStore success'); + kvStore = store; + kvManager.closeKVStore('appId', 'storeId', kvStore).then(() => { + console.log('closeKVStore success'); + }).catch((err) => { + console.log('closeKVStore err ' + JSON.stringify(err)); + }); }).catch((err) => { console.log('CloseKVStore getKVStore err ' + JSON.stringify(err)); }); - } catch (e) { +} catch (e) { console.log('closeKVStore e ' + e); -} +} ``` @@ -418,7 +404,7 @@ Deletes a KV store. This API uses an asynchronous callback to return the result. | ----- | ------ | ---- | ----------------------- | | appId | string | Yes | Bundle name of the app that invokes the KV store. | | storeId | string | Yes | Unique identifier of the KV store to delete. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.| **Example** @@ -514,7 +500,7 @@ Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore) | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | appId | string | Yes | Bundle name of the app that invokes the KV store. | -| callback | AsyncCallback<string[]> | Yes |Callback used to return the KV store IDs obtained. | +| callback | AsyncCallback<string[]> | Yes |Callback invoked to return the KV store IDs obtained. | **Example** @@ -574,7 +560,7 @@ try { on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): void -Subscribes to service status changes. +Subscribes to service status changes. This API returns the result synchronously. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -590,7 +576,6 @@ Subscribes to service status changes. ```js let kvManager; try { - console.log('KVManagerOn'); const deathCallback = function () { console.log('death callback call'); @@ -606,7 +591,7 @@ try { off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): void -Unsubscribes from service status changes. +Unsubscribes from service status changes. This API returns the result synchronously. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -615,7 +600,7 @@ Unsubscribes from service status changes. | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | event | string | Yes | Event to unsubscribe from. The value is **distributedDataServiceDie**, which indicates a service status change event.| -| deathCallback | Callback<void> | No | Callback used to return a service status change event.| +| deathCallback | Callback<void> | No | Callback for the service status change event.| **Example** @@ -666,16 +651,14 @@ Enumerates the KV store types. Enumerates the KV store security levels. -**System capability**: SystemCapability.DistributedDataManager.KVStore.Core - | Name | Value| Description | | --- | ---- | ----------------------- | -| NO_LEVEL | 0 | No security level is set for the KV store. | -| S0 | 1 | The KV store security level is public.| -| S1 | 2 | The KV store security level is low. If data leakage occurs, minor impact will be caused on the database. For example, a KV store that contains system data such as wallpapers.| -| S2 | 3 | The KV store security level is medium. If data leakage occurs, moderate impact will be caused on the database. For example, a KV store that contains information created by users or call records, such as audio or video clips.| -| S3 | 5 | The KV store security level is high. If data leakage occurs, major impact will be caused on the database. For example, a KV store that contains information such as user fitness, health, and location data.| -| S4 | 6 | The KV store security level is critical. If data leakage occurs, severe impact will be caused on the database. For example, a KV store that contains information such as authentication credentials and financial data.| +| NO_LEVEL | 0 | No security level is set for the KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | +| S0 | 1 | The KV store security level is public.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| S1 | 2 | The KV store security level is low. If data leakage occurs, minor impact will be caused on the database. For example, a KV store that contains system data such as wallpapers.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| S2 | 3 | The KV store security level is medium. If data leakage occurs, moderate impact will be caused on the database. For example, a KV store that contains information created by users or call records, such as audio or video clips.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| S3 | 5 | The KV store security level is high. If data leakage occurs, major impact will be caused on the database. For example, a KV store that contains information such as user fitness, health, and location data.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| S4 | 6 | The KV store security level is critical. If data leakage occurs, severe impact will be caused on the database. For example, a KV store that contains information such as authentication credentials and financial data.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | ## Constants @@ -1025,7 +1008,7 @@ try { }).catch((err) => { console.log('getResultSet failed: ' + err); }); - const moved5 = resultSet.move(); + const moved5 = resultSet.move(1); console.log("move succeed:" + moved5); } catch (e) { console.log("move failed: " + e); @@ -1065,7 +1048,7 @@ try { }).catch((err) => { console.log('getResultSet failed: ' + err); }); - const moved6 = resultSet.moveToPosition(); + const moved6 = resultSet.moveToPosition(1); console.log("moveToPosition succeed: " + moved6); } catch (e) { console.log("moveToPosition failed: " + e); @@ -2156,7 +2139,7 @@ Adds a KV pair of the specified type to this KV store. This API uses an asynchro | ----- | ------ | ---- | ----------------------- | | key | string | Yes |Key of the KV pair to add. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | | value | Uint8Array \| string \| number \| boolean | Yes |Value of the KV pair to add. The value type can be Uint8Array, number, string, or boolean. A value of the Uint8Array or string type cannot exceed [MAX_VALUE_LENGTH](#constants). | -| callback | AsyncCallback<void> | Yes |Callback used to return the result. | +| callback | AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -2229,7 +2212,7 @@ Deletes a KV pair from this KV store. This API uses an asynchronous callback to | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | key | string | Yes |Key of the KV pair to delete. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | -| callback | AsyncCallback<void> | Yes |Callback used to return the result. | +| callback | AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -2314,7 +2297,7 @@ Deletes KV pairs that meet the specified conditions. This API uses an asynchrono | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes |Conditions for deleting data. If this parameter is **null**, define the processing logic.| -| callback | AsyncCallback<void> | Yes |Callback used to return the result. | +| callback | AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -2395,8 +2378,8 @@ Backs up an RDB store. This API uses an asynchronous callback to return the resu | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| file | string | Yes | Name of the database. The value cannot be empty or exceed [MAX_KEY_LENGTH](#constants).| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is the error object. | +| file | string | Yes | Name of the RDB store. The value cannot be empty or exceed [MAX_KEY_LENGTH](#constants).| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is the error object.| **Example** @@ -2429,7 +2412,7 @@ Backs up an RDB store. This API uses a promise to return the result. | Name| Type| Mandatory| Description | | ------ | -------- | ---- | ------------------------------------------------------------ | -| file | string | Yes | Name of the database. This parameter cannot be empty and its length cannot exceed [MAX_KEY_LENGTH](#constants).| +| file | string | Yes | Name of the RDB store. The value cannot be empty or exceed [MAX_KEY_LENGTH](#constants).| **Return value** @@ -2467,7 +2450,7 @@ Restores an RDB store from a database file. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | | file | string | Yes | Name of the database file. The value cannot be empty or exceed [MAX_KEY_LENGTH](#constants).| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| **Example** @@ -2600,7 +2583,7 @@ try { on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotification>): void -Subscribes to data changes of the specified type. +Subscribes to data changes of the specified type. This API returns the result synchronously. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2610,7 +2593,7 @@ Subscribes to data changes of the specified type. | ----- | ------ | ---- | ----------------------- | | event |string | Yes |Event to subscribe to. The value is **dataChange**, which indicates a data change event. | | type |[SubscribeType](#subscribetype) | Yes |Type of data change. | -| listener |Callback<[ChangeNotification](#changenotification)> | Yes |Callback used to return a data change event.| +| listener |Callback<[ChangeNotification](#changenotification)> | Yes |Callback invoked to return a data change event.| **Example** @@ -2626,7 +2609,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void -Subscribes to synchronization complete events. +Subscribes to synchronization complete events. This API returns the result synchronously. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2635,7 +2618,7 @@ Subscribes to synchronization complete events. | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | event |string | Yes |Event to subscribe to. The value is **syncComplete**, which indicates a synchronization complete event. | -| syncCallback |Callback<Array<[string, number]>> | Yes |Callback used to return a synchronization complete event. | +| syncCallback |Callback<Array<[string, number]>> | Yes |Callback invoked to return a synchronization complete event.| **Example** @@ -2650,7 +2633,7 @@ kvStore.on('syncComplete', function (data) { off(event:'dataChange', listener?: Callback<ChangeNotification>): void -Unsubscribes from data changes. +Unsubscribes from data changes. This API returns the result synchronously. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2659,7 +2642,7 @@ Unsubscribes from data changes. | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates a data change event. | -| listener |Callback<[ChangeNotification](#changenotification)> |No |Callback used to return a data change event.| +| listener |Callback<[ChangeNotification](#changenotification)> |No |Callback for the data change event.| **Example** @@ -2686,7 +2669,7 @@ class KvstoreModel { off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void -Unsubscribes from data changes. This API returns the result synchronously. +Unsubscribes from the synchronization complete events. This API returns the result synchronously. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2695,7 +2678,7 @@ Unsubscribes from data changes. This API returns the result synchronously. | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event. | -| syncCallback |Callback<Array<[string, number]>> | No |Callback used to return a synchronization complete event. | +| syncCallback |Callback<Array<[string, number]>> | No |Callback for the synchronization complete event. | **Example** @@ -2732,7 +2715,7 @@ Inserts KV pairs in batches to this KV store. This API uses an asynchronous call | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | entries |[Entry](#entry)[] | Yes |KV pairs to insert in batches. | -| callback |Asyncallback<void> |Yes |Callback used to return the result.| +| callback |Asyncallback<void> |Yes |Callback invoked to return the result.| **Example** @@ -2835,7 +2818,7 @@ Writes data to this KV store. This API uses an asynchronous callback to return | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | value |Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | Yes |Data to write. | -| callback |Asyncallback<void> |Yes |Callback used to return the result.| +| callback |Asyncallback<void> |Yes |Callback invoked to return the result.| **Example** @@ -2921,7 +2904,7 @@ Deletes KV pairs in batches from this KV store. This API uses an asynchronous ca | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | keys |string[] | Yes |KV pairs to delete in batches. | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -3023,7 +3006,7 @@ Starts the transaction in this KV store. This API uses an asynchronous callback | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -3110,7 +3093,7 @@ Commits the transaction in this KV store. This API uses an asynchronous callback | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -3172,7 +3155,7 @@ Rolls back the transaction in this KV store. This API uses an asynchronous callb | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -3235,7 +3218,7 @@ Sets data synchronization, which can be enabled or disabled. This API uses an as | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | enabled |boolean | Yes |Whether to enable data synchronization. The value **true** means to enable data synchronization, and **false** means the opposite. | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -3305,7 +3288,7 @@ Sets the data synchronization range. This API uses an asynchronous callback to r | ----- | ------ | ---- | ----------------------- | | localLabels |string[] | Yes |Synchronization labels set for the local device. | | remoteSupportLabels |string[] | Yes |Synchronization labels set for remote devices. | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -3632,7 +3615,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | Yes |Key prefix to match. | -| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback used to return the KV pairs obtained. | +| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback invoked to return the KV pairs obtained. | **Example** @@ -4033,7 +4016,7 @@ Closes the **KvStoreResultSet** object obtained by [SingleKvStore.getResultSet]( | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -4205,7 +4188,7 @@ Deletes data of a device. This API uses an asynchronous callback to return the r | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | deviceId |string | Yes |ID of the target device. | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -4287,7 +4270,7 @@ try { on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void -Subscribes to synchronization complete events. +Subscribes to synchronization complete events. This API returns the result synchronously. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -4323,7 +4306,7 @@ try { off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void -Unsubscribes from synchronization complete events. +Unsubscribes from synchronization complete events. This API returns the result synchronously. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -4332,7 +4315,7 @@ Unsubscribes from synchronization complete events. | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event. | -| syncCallback |Callback<Array<[string, number]>> | No |Callback used to return a synchronization complete event. | +| syncCallback |Callback<Array<[string, number]>> | No |Callback for the synchronization complete event. | **Example** @@ -4394,7 +4377,7 @@ Unsubscribes from data changes. This API returns the result synchronously. | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates a data change event. | -| listener |Callback<[ChangeNotification](#changenotification)> |No |Callback used to return a data change event.| +| listener |Callback<[ChangeNotification](#changenotification)> |No |Callback for the data change event.| **Example** @@ -4421,7 +4404,7 @@ class KvstoreModel { sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void -Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview] (../../database/database-mdds-overview.md). +Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md). **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC @@ -4445,7 +4428,7 @@ kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000); ### sync9+ sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void -Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview] (../../database/database-mdds-overview.md). +Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md). **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC @@ -4497,7 +4480,7 @@ Sets the default delay allowed for KV store synchronization. This API uses an as | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | defaultAllowedDelayMs |number | Yes |Default delay allowed for database synchronization, in ms. | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -4634,7 +4617,7 @@ Obtains a string value that matches the specified device ID and key. This API us | ----- | ------ | ---- | ----------------------- | | deviceId |string | Yes |ID of the target device. | | key |string | Yes |Key to match. | -| callback |AsyncCallback<boolean\|string\|number\|Uint8Array> | Yes |Callback used to return the value obtained. | +| callback |AsyncCallback<boolean\|string\|number\|Uint8Array> | Yes |Callback invoked to return the value obtained. | **Example** @@ -4713,7 +4696,7 @@ Obtains all KV pairs that match the specified device ID and key prefix. This API | ----- | ------ | ---- | ----------------------- | | deviceId |string | Yes |ID of the target device. | | keyPrefix |string | Yes |Key prefix to match. | -| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback used to return the KV pairs obtained. | +| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback invoked to return the KV pairs obtained. | **Example** @@ -4819,7 +4802,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | Yes |**Query** object to match. | -| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback used to return the KV pairs obtained. | +| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback invoked to return the KV pairs obtained. | **Example** @@ -5355,7 +5338,7 @@ Closes the **KvStoreResultSet** object obtained by [DeviceKVStore.getResultSet]( | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#getresultset8) | Yes |**KvStoreResultSet** object to close. | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -5634,7 +5617,7 @@ Deletes data of the specified device from this KV store. This API uses an asynch | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | deviceId |string | Yes |ID of the target device. | -| callback |AsyncCallback<void> | Yes |Callback used to return the result. | +| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | **Example** @@ -5716,7 +5699,7 @@ try { sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void -Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview] (../../database/database-mdds-overview.md). +Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md). **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC @@ -5755,7 +5738,7 @@ try { sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void -Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview] (../../database/database-mdds-overview.md). +Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md). **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC @@ -5797,7 +5780,7 @@ try { on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void -Subscribes to synchronization complete events. +Subscribes to synchronization complete events. This API returns the result synchronously. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -5842,7 +5825,7 @@ Unsubscribes from synchronization complete events. This API returns the result s | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.| -| syncCallback |Callback-  **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| @@ -83,6 +84,7 @@ Obtains information about the second-level album or files in asynchronous mode. **System capability**: SystemCapability.FileManagement.UserFileService **Parameters** + | Name| Type| Mandatory| Description| | --- | --- | --- | -- | | path | string | Yes| URI of the directory to query.| @@ -169,6 +171,7 @@ Creates a file in the specified path in asynchronous mode. This API uses a promi **System capability**: SystemCapability.FileManagement.UserFileService **Parameters** + | Name| Type| Mandatory| Description| | --- | --- | --- | -- | | filename | string | Yes| Name of the file to create.| diff --git a/en/application-dev/reference/apis/js-apis-osAccount.md b/en/application-dev/reference/apis/js-apis-osAccount.md index a4692039779fa40b82edb8de1dab204423ac957d..8320fceaa5601703f01f8fc8f4937bcd34d3b4d5 100644 --- a/en/application-dev/reference/apis/js-apis-osAccount.md +++ b/en/application-dev/reference/apis/js-apis-osAccount.md @@ -21,13 +21,14 @@ Obtains an **AccountManager** instance. **System capability**: SystemCapability.Account.OsAccount **Return value** + | Type | Description | | --------------------------------- | ------------------------ | | [AccountManager](#accountmanager) | Obtains an **AccountManager** instance.| **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); ``` ## OsAccountType @@ -67,10 +68,10 @@ This is a system API and cannot be called by third-party applications. **Example**: Activate OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.activateOsAccount(localId, (err)=>{ - console.log("activateOsAccount err:" + JSON.stringify(err)); + console.log('activateOsAccount err:' + JSON.stringify(err)); }); ``` @@ -100,12 +101,12 @@ This is a system API and cannot be called by third-party applications. **Example**: Activate OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.activateOsAccount(localId).then(() => { - console.log("activateOsAccount success"); + console.log('activateOsAccount success'); }).catch((err) => { - console.log("activateOsAccount err:" + JSON.stringify(err)); + console.log('activateOsAccount err:' + JSON.stringify(err)); }); ``` @@ -126,9 +127,9 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable((err, isEnabled) => { - console.log("isMultiOsAccountEnable err: " + JSON.stringify(err)); + console.log('isMultiOsAccountEnable err: ' + JSON.stringify(err)); console.log('isMultiOsAccountEnable isEnabled: ' + isEnabled); }); ``` @@ -150,11 +151,11 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable().then((isEnabled) => { console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled); }).catch((err) => { - console.log("isMultiOsAccountEnable err: " + JSON.stringify(err)); + console.log('isMultiOsAccountEnable err: ' + JSON.stringify(err)); }); ``` @@ -178,11 +179,11 @@ Checks whether an OS account is activated. This API uses an asynchronous callbac **Example**: Check whether OS account 100 is activated. ```js - const accountManager = account_osAccount.getAccountManager(); - var osLocalId = 100; + let accountManager = account_osAccount.getAccountManager(); + let osLocalId = 100; accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{ - console.log("isOsAccountActived err:" + JSON.stringify(err)); - console.log("isOsAccountActived isActive:" + isActive); + console.log('isOsAccountActived err:' + JSON.stringify(err)); + console.log('isOsAccountActived isActive:' + isActive); }); ``` @@ -211,12 +212,12 @@ Checks whether an OS account is activated. This API uses a promise to return the **Example**: Check whether OS account 100 is activated. ```js - const accountManager = account_osAccount.getAccountManager(); - var osLocalId = 100; + let accountManager = account_osAccount.getAccountManager(); + let osLocalId = 100; accountManager.isOsAccountActived(osLocalId).then((isActive) => { console.log('isOsAccountActived, isActive: ' + isActive); }).catch((err) => { - console.log("isOsAccountActived err: " + JSON.stringify(err)); + console.log('isOsAccountActived err: ' + JSON.stringify(err)); }); ``` @@ -241,11 +242,11 @@ Checks whether the specified constraint is enabled for an OS account. This API u **Example**: Check whether OS account 100 is forbidden to use Wi-Fi. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{ - console.log("isOsAccountConstraintEnable err:" + JSON.stringify(err)); - console.log("isOsAccountConstraintEnable isConstraintEnabled:" + isConstraintEnabled); + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + accountManager.isOsAccountConstraintEnable(localId, 'constraint.wifi', (err, isConstraintEnabled)=>{ + console.log('isOsAccountConstraintEnable err:' + JSON.stringify(err)); + console.log('isOsAccountConstraintEnable isConstraintEnabled:' + isConstraintEnabled); }); ``` @@ -275,12 +276,12 @@ Checks whether the specified constraint is enabled for an OS account. This API u **Example**: Check whether OS account 100 is forbidden to use Wi-Fi. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => { + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + accountManager.isOsAccountConstraintEnable(localId, 'constraint.wifi').then((isConstraintEnabled) => { console.log('isOsAccountConstraintEnable, isConstraintEnabled: ' + isConstraintEnabled); }).catch((err) => { - console.log("isOsAccountConstraintEnable err: " + JSON.stringify(err)); + console.log('isOsAccountConstraintEnable err: ' + JSON.stringify(err)); }); ``` @@ -301,9 +302,9 @@ Checks whether this OS account is a test account. This API uses an asynchronous **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount((err, isTest) => { - console.log("isTestOsAccount err: " + JSON.stringify(err)); + console.log('isTestOsAccount err: ' + JSON.stringify(err)); console.log('isTestOsAccount isTest: ' + isTest); }); ``` @@ -325,11 +326,11 @@ Checks whether this OS account is a test account. This API uses a promise to ret **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount().then((isTest) => { console.log('isTestOsAccount, isTest: ' + isTest); }).catch((err) => { - console.log("isTestOsAccount err: " + JSON.stringify(err)); + console.log('isTestOsAccount err: ' + JSON.stringify(err)); }); ``` @@ -350,9 +351,9 @@ Checks whether this OS account has been verified. This API uses an asynchronous **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { - console.log("isOsAccountVerified err: " + JSON.stringify(err)); + console.log('isOsAccountVerified err: ' + JSON.stringify(err)); console.log('isOsAccountVerified isVerified: ' + isVerified); }); ``` @@ -377,9 +378,9 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { - console.log("isOsAccountVerified err: " + JSON.stringify(err)); + console.log('isOsAccountVerified err: ' + JSON.stringify(err)); console.log('isOsAccountVerified isVerified: ' + isVerified); }); ``` @@ -409,11 +410,11 @@ Checks whether an OS account has been verified. This API uses a promise to retur **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified().then((isVerified) => { console.log('isOsAccountVerified, isVerified: ' + isVerified); }).catch((err) => { - console.log("isOsAccountVerified err: " + JSON.stringify(err)); + console.log('isOsAccountVerified err: ' + JSON.stringify(err)); }); ``` @@ -439,10 +440,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => { + let accountManager = account_osAccount.getAccountManager(); + accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => { accountManager.removeOsAccount(osAccountInfo.localId, (err)=>{ - console.log("removeOsAccount err:" + JSON.stringify(err)); + console.log('removeOsAccount err:' + JSON.stringify(err)); }); }); ``` @@ -474,12 +475,12 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ + let accountManager = account_osAccount.getAccountManager(); + accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ accountManager.removeOsAccount(osAccountInfo.localId).then(() => { console.log('removeOsAccount Success'); }).catch(() => { - console.log("removeOsAccount err: " + JSON.stringify(err)); + console.log('removeOsAccount err: ' + JSON.stringify(err)); }); }); ``` @@ -508,10 +509,10 @@ This is a system API and cannot be called by third-party applications. **Example**: Disable Wi-Fi for OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{ - console.log("setOsAccountConstraints err:" + JSON.stringify(err)); + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + accountManager.setOsAccountConstraints(localId, ['constraint.wifi'], true, (err)=>{ + console.log('setOsAccountConstraints err:' + JSON.stringify(err)); }); ``` @@ -541,15 +542,15 @@ This is a system API and cannot be called by third-party applications. | :------------------ | :---------------------------------- | | Promise<void> | Promise used to return the result.| -**Example**: Remote the constraint on the use of Wi-Fi for OS account 100. +**Example**: Remove the constraint on the use of Wi-Fi for OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => { + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => { console.log('setOsAccountConstraints Success'); }).catch((err) => { - console.log("setOsAccountConstraints err: " + JSON.stringify(err)); + console.log('setOsAccountConstraints err: ' + JSON.stringify(err)); }); ``` @@ -576,11 +577,11 @@ This is a system API and cannot be called by third-party applications. **Example**: Set the name of OS account 100 to **demoName**. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - var newName = "demoName"; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + let newName = 'demoName'; accountManager.setOsAccountName(localId, newName, (err)=>{ - console.debug("setOsAccountName err:" + JSON.stringify(err)); + console.debug('setOsAccountName err:' + JSON.stringify(err)); }); ``` @@ -612,13 +613,13 @@ This is a system API and cannot be called by third-party applications. **Example**: Set the name of OS account 100 to **demoName**. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - var nameLimit = "demoName"; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + let nameLimit = 'demoName'; accountManager.setOsAccountName(localId, nameLimit).then(() => { console.log('setOsAccountName Success'); }).catch((err) => { - console.log("setOsAccountName err: " + JSON.stringify(err)); + console.log('setOsAccountName err: ' + JSON.stringify(err)); }); ``` @@ -641,10 +642,10 @@ Obtains the number of OS accounts created. This API uses an asynchronous callbac **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{ - console.log("obtains the number of all os accounts created err:" + JSON.stringify(err)); - console.log("obtains the number of all os accounts created accountCnt:" + accountCnt); + console.log('obtains the number of all os accounts created err:' + JSON.stringify(err)); + console.log('obtains the number of all os accounts created accountCnt:' + accountCnt); }); ``` @@ -667,11 +668,11 @@ Obtains the number of OS accounts created. This API uses a promise to return the **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount().then((accountCnt) => { console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt); }).catch((err) => { - console.log("getCreatedOsAccountsCount err: " + JSON.stringify(err)); + console.log('getCreatedOsAccountsCount err: ' + JSON.stringify(err)); }); ``` @@ -692,9 +693,9 @@ Obtains the ID of the OS account to which the current process belongs. This API **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess((err, accountID) => { - console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromProcess err: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromProcess accountID: ' + accountID); }); ``` @@ -716,11 +717,11 @@ Obtains the ID of the OS account to which the current process belongs. This API **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess().then((accountID) => { console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID); }).catch((err) => { - console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromProcess err: ' + JSON.stringify(err)); }); ``` @@ -742,10 +743,10 @@ Obtains the OS account ID based on the process UID. This API uses an asynchronou **Example**: Obtain the ID of the OS account whose process UID is **12345678**. ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => { - console.log("getOsAccountLocalIdFromUid err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromUid err: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromUid: ' + accountID); }); ``` @@ -773,12 +774,12 @@ Obtains the OS account ID based on the process UID. This API uses a promise to r **Example**: Obtain the ID of the OS account whose process UID is **12345678**. ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => { console.log('getOsAccountLocalIdFromUid: ' + accountID); }).catch((err) => { - console.log("getOsAccountLocalIdFromUid err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromUid err: ' + JSON.stringify(err)); }); ``` @@ -802,10 +803,10 @@ Obtains the OS account ID based on domain account information. This API uses an **Example** ```js - var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; - const accountManager = account_osAccount.getAccountManager(); + let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; + let accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => { - console.log("getOsAccountLocalIdFromDomain: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromDomain: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromDomain: ' + accountID); }); ``` @@ -835,12 +836,12 @@ Obtains the OS account ID based on domain account information. This API uses a p **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; + let accountManager = account_osAccount.getAccountManager(); + let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => { console.log('getOsAccountLocalIdFromDomain: ' + accountID); }).catch((err) => { - console.log("getOsAccountLocalIdFromDomain err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromDomain err: ' + JSON.stringify(err)); }); ``` @@ -863,10 +864,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{ - console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err)); - console.log("queryMaxOsAccountNumber maxCnt:" + maxCnt); + console.log('queryMaxOsAccountNumber err:' + JSON.stringify(err)); + console.log('queryMaxOsAccountNumber maxCnt:' + maxCnt); }); ``` @@ -889,11 +890,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber().then((maxCnt) => { console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt); }).catch((err) => { - console.log("queryMaxOsAccountNumber err: " + JSON.stringify(err)); + console.log('queryMaxOsAccountNumber err: ' + JSON.stringify(err)); }); ``` @@ -917,11 +918,11 @@ Obtains all constraints enabled for an OS account. This API uses an asynchronous **Example**: Obtain all constraints of OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{ - console.log("getOsAccountAllConstraints err:" + JSON.stringify(err)); - console.log("getOsAccountAllConstraints:" + JSON.stringify(constraints)); + console.log('getOsAccountAllConstraints err:' + JSON.stringify(err)); + console.log('getOsAccountAllConstraints:' + JSON.stringify(constraints)); }); ``` @@ -950,12 +951,12 @@ Obtains all constraints enabled for an OS account. This API uses a promise to re **Example**: Obtain all constraints of OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getOsAccountAllConstraints(localId).then((constraints) => { - console.log("getOsAccountAllConstraints, constraints: " + constraints); + console.log('getOsAccountAllConstraints, constraints: ' + constraints); }).catch((err) => { - console.log("getOsAccountAllConstraints err: " + JSON.stringify(err)); + console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err)); }); ``` @@ -980,10 +981,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ - console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err)); - console.log("queryAllCreatedOsAccounts accountArr:" + JSON.stringify(accountArr)); + console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err)); + console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr)); }); ``` @@ -1008,11 +1009,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts().then((accountArr) => { console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); }).catch((err) => { - console.log("queryAllCreatedOsAccounts err: " + JSON.stringify(err)); + console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err)); }); ``` @@ -1033,12 +1034,12 @@ Obtains information about all activated OS accounts. This API uses an asynchrono **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryActivatedOsAccountIds((err, idArray)=>{ - console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err)); - console.log("queryActivatedOsAccountIds idArray length:" + idArray.length); - for(var i=0;i { console.log('queryActivatedOsAccountIds, idArray: ' + idArray); }).catch((err) => { - console.log("queryActivatedOsAccountIds err: " + JSON.stringify(err)); + console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err)); }); ``` @@ -1091,10 +1092,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount("testName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ - console.log("createOsAccount err:" + JSON.stringify(err)); - console.log("createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + let accountManager = account_osAccount.getAccountManager(); + accountManager.createOsAccount('testName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ + console.log('createOsAccount err:' + JSON.stringify(err)); + console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo)); }); ``` @@ -1126,11 +1127,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL).then((accountInfo) => { - console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo)); + let accountManager = account_osAccount.getAccountManager(); + accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL).then((accountInfo) => { + console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); }).catch((err) => { - console.log("createOsAccount err: " + JSON.stringify(err)); + console.log('createOsAccount err: ' + JSON.stringify(err)); }); ``` @@ -1157,11 +1158,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; + let accountManager = account_osAccount.getAccountManager(); + let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ - console.log("createOsAccountForDomain err:" + JSON.stringify(err)); - console.log("createOsAccountForDomain osAccountInfo:" + JSON.stringify(osAccountInfo)); + console.log('createOsAccountForDomain err:' + JSON.stringify(err)); + console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo)); }); ``` @@ -1193,12 +1194,12 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; + let accountManager = account_osAccount.getAccountManager(); + let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { - console.log("createOsAccountForDomain, account info: " + JSON.stringify(accountInfo)); + console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo)); }).catch((err) => { - console.log("createOsAccountForDomain err: " + JSON.stringify(err)); + console.log('createOsAccountForDomain err: ' + JSON.stringify(err)); }); ``` @@ -1221,10 +1222,10 @@ Obtains information about the OS account to which the current process belongs. T **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{ - console.log("queryCurrentOsAccount err:" + JSON.stringify(err)); - console.log("queryCurrentOsAccount curAccountInfo:" + JSON.stringify(curAccountInfo)); + console.log('queryCurrentOsAccount err:' + JSON.stringify(err)); + console.log('queryCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo)); }); ``` @@ -1247,11 +1248,11 @@ Obtains information about the OS account to which the current process belongs. T **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount().then((accountInfo) => { - console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo)); + console.log('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); }).catch((err) => { - console.log("queryCurrentOsAccount err: " + JSON.stringify(err)); + console.log('queryCurrentOsAccount err: ' + JSON.stringify(err)); }); ``` @@ -1277,11 +1278,11 @@ This is a system API and cannot be called by third-party applications. **Example**: Query information about OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ - console.log("queryOsAccountById err:" + JSON.stringify(err)); - console.log("queryOsAccountById accountInfo:" + JSON.stringify(accountInfo)); + console.log('queryOsAccountById err:' + JSON.stringify(err)); + console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo)); }); ``` @@ -1312,12 +1313,12 @@ This is a system API and cannot be called by third-party applications. **Example**: Query information about OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.queryOsAccountById(localId).then((accountInfo) => { - console.log("queryOsAccountById, accountInfo: " + JSON.stringify(accountInfo)); + console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo)); }).catch((err) => { - console.log("queryOsAccountById err: " + JSON.stringify(err)); + console.log('queryOsAccountById err: ' + JSON.stringify(err)); }); ``` @@ -1338,9 +1339,9 @@ Obtains the type of the OS account to which the current process belongs. This AP **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess((err, accountType) => { - console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err)); + console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); console.log('getOsAccountTypeFromProcess accountType: ' + accountType); }); ``` @@ -1362,11 +1363,11 @@ Obtains the type of the OS account to which the current process belongs. This AP **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess().then((accountType) => { console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); }).catch((err) => { - console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err)); + console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); }); ``` @@ -1389,9 +1390,9 @@ Obtains the ID of this distributed virtual device. This API uses an asynchronous **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId((err, virtualID) => { - console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err)); + console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err)); console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID); }); ``` @@ -1415,11 +1416,11 @@ Obtains the ID of this distributed virtual device. This API uses a promise to re **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId().then((virtualID) => { console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID); }).catch((err) => { - console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err)); + console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err)); }); ``` @@ -1445,11 +1446,11 @@ This is a system API and cannot be called by third-party applications. **Example**: Obtain the profile photo of OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ - console.log("getOsAccountProfilePhoto err:" + JSON.stringify(err)); - console.log("get photo:" + photo + " by localId: " + localId); + console.log('getOsAccountProfilePhoto err:' + JSON.stringify(err)); + console.log('get photo:' + photo + ' by localId: ' + localId); }); ``` @@ -1480,12 +1481,12 @@ This is a system API and cannot be called by third-party applications. **Example**: Obtain the profile photo of OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getOsAccountProfilePhoto(localId).then((photo) => { - console.log("getOsAccountProfilePhoto: " + photo); + console.log('getOsAccountProfilePhoto: ' + photo); }).catch((err) => { - console.log("getOsAccountProfilePhoto err: " + JSON.stringify(err)); + console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err)); }); ``` @@ -1512,14 +1513,14 @@ This is a system API and cannot be called by third-party applications. **Example**: Set a profile photo for OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ - "Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+ - "q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+ - "+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==" + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + let photo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+ + 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ + 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+ + '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==' accountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{ - console.log("setOsAccountProfilePhoto err:" + JSON.stringify(err)); + console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err)); }); ``` @@ -1551,16 +1552,16 @@ This is a system API and cannot be called by third-party applications. **Example**: Set a profile photo for OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ - "Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+ - "q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+ - "+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==" + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + let photo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+ + 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ + 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+ + '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==' accountManager.setOsAccountProfilePhoto(localId, photo).then(() => { - console.log("setOsAccountProfilePhoto success"); + console.log('setOsAccountProfilePhoto success'); }).catch((err) => { - console.log("setOsAccountProfilePhoto err: " + JSON.stringify(err)); + console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err)); }); ``` @@ -1579,14 +1580,14 @@ Obtains the OS account ID based on the SN. This API uses an asynchronous callbac | serialNumber | number | Yes | Account SN. | | callback | AsyncCallback<number> | Yes | Callback used to return the OS account ID obtained.| -**Example**: Obtain the ID of the OS account whose SN is **12345**. +**Example**: Obtain the ID of the OS account whose SN is 12345. ```js - const accountManager = account_osAccount.getAccountManager(); - var serialNumber = 12345; + let accountManager = account_osAccount.getAccountManager(); + let serialNumber = 12345; accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ - console.log("ger localId err:" + JSON.stringify(err)); - console.log("get localId:" + localId + " by serialNumber: " + serialNumber); + console.log('ger localId err:' + JSON.stringify(err)); + console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber); }); ``` @@ -1610,15 +1611,15 @@ Obtains the OS account ID based on the SN. This API uses a promise to return the | :-------------------- | :----------------------------------------------------------- | | Promise<number> | Promise used to return the OS account ID obtained.| -**Example**: Obtain the ID of the OS account whose SN is **12345**. +**Example**: Obtain the ID of the OS account whose SN is 12345. ```js - const accountManager = account_osAccount.getAccountManager(); - var serialNumber = 12345; + let accountManager = account_osAccount.getAccountManager(); + let serialNumber = 12345; accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => { - console.log("getOsAccountLocalIdBySerialNumber localId: " + localId); + console.log('getOsAccountLocalIdBySerialNumber localId: ' + localId); }).catch((err) => { - console.log("getOsAccountLocalIdBySerialNumber err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err)); }); ``` @@ -1637,14 +1638,14 @@ Obtains the SN of an OS account based on the account ID. This API uses an asynch | localId | number | Yes | ID of the target OS account. | | callback | AsyncCallback<number> | Yes | Callback used to return the account SN obtained.| -**Example**: Obtain the SN of OS account 100. +**Example**: Obtain the SN of the OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ - console.log("ger serialNumber err:" + JSON.stringify(err)); - console.log("get serialNumber:" + serialNumber + " by localId: " + localId); + console.log('ger serialNumber err:' + JSON.stringify(err)); + console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId); }); ``` @@ -1668,15 +1669,15 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise | :-------------------- | :----------------------------------------------------------- | | Promise<number> | Promise used to return the account SN obtained.| -**Example**: Obtain the SN of OS account 100. +**Example**: Obtain the SN of the OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => { - console.log("getSerialNumberByOsAccountLocalId serialNumber: " + serialNumber); + console.log('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber); }).catch((err) => { - console.log("getSerialNumberByOsAccountLocalId err: " + JSON.stringify(err)); + console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err)); }); ``` @@ -1703,11 +1704,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); function onCallback(receiveLocalId){ - console.log("receive localId:" + receiveLocalId); + console.log('receive localId:' + receiveLocalId); } - accountManager.on("activating", "osAccountOnOffNameA", onCallback); + accountManager.on('activating', 'osAccountOnOffNameA', onCallback); ``` ### off @@ -1733,11 +1734,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); function offCallback(){ - console.log("off enter") + console.log('off enter') } - accountManager.off("activating", "osAccountOnOffNameA", offCallback); + accountManager.off('activating', 'osAccountOnOffNameA', offCallback); ``` ### getBundleIdFromUid9+ @@ -1760,11 +1761,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - var testUid = 1000000; + let accountManager = account_osAccount.getAccountManager(); + let testUid = 1000000; accountManager.getBundleIdFromUid(testUid, (err, bundleId) => { - console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err)); - console.info("getBundleIdFromUid bundleId:" + JSON.stringify(bundleId)); + console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err)); + console.info('getBundleIdFromUid bundleId:' + JSON.stringify(bundleId)); }); ``` ### getBundleIdFromUid9+ @@ -1792,12 +1793,12 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - var testUid = 1000000; + let accountManager = account_osAccount.getAccountManager(); + let testUid = 1000000; accountManager.getBundleIdFromUid(testUid).then((result) => { - console.info("getBundleIdFromUid bundleId:" + JSON.stringify(result)); + console.info('getBundleIdFromUid bundleId:' + JSON.stringify(result)); }).catch((err)=>{ - console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err)); + console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err)); }); ``` @@ -1822,10 +1823,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isMainOsAccount((err,result)=>{ - console.info("isMainOsAccount errInfo:" + JSON.stringify(err)); - console.info("isMainOsAccount result:" + JSON.stringify(result)); + console.info('isMainOsAccount errInfo:' + JSON.stringify(err)); + console.info('isMainOsAccount result:' + JSON.stringify(result)); }); ``` ### isMainOsAccount9+ @@ -1849,11 +1850,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isMainOsAccount().then((result) => { - console.info("isMainOsAccount result:" + JSON.stringify(result)); + console.info('isMainOsAccount result:' + JSON.stringify(result)); }).catch((err)=>{ - console.info("isMainOsAccount errInfo:" + JSON.stringify(err)); + console.info('isMainOsAccount errInfo:' + JSON.stringify(err)); }); ``` ### queryOsAccountConstraintSourceTypes9+ @@ -1879,10 +1880,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi",(err,sourceTypeInfos)=>{ - console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err)); - console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(sourceTypeInfos)); + let accountManager = account_osAccount.getAccountManager(); + accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi',(err,sourceTypeInfos)=>{ + console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err)); + console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(sourceTypeInfos)); }); ``` @@ -1914,11 +1915,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi").then((result) => { - console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(result)); + let accountManager = account_osAccount.getAccountManager(); + accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi').then((result) => { + console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(result)); }).catch((err)=>{ - console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err)); + console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err)); }); ``` @@ -1938,7 +1939,7 @@ This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.Account.OsAccount -**Example** +**Example** ```js let userAuth = new account_osAccount.UserAuth(); ``` @@ -1960,11 +1961,11 @@ This is a system API and cannot be called by third-party applications. | :----- | :----------- | | number | Version information obtained.| -**Example** +**Example** ```js let userAuth = new account_osAccount.UserAuth(); let version = userAuth.getVersion(); - console.log("getVersion version = " + version); + console.log('getVersion version = ' + version); ``` ### getAvailableStatus8+ @@ -1992,13 +1993,13 @@ This is a system API and cannot be called by third-party applications. | :----- | :---------------------------------------- | | number | [Result code](#resultcode8).| -**Example** +**Example** ```js let userAuth = new account_osAccount.UserAuth(); let authType = account_osAccount.AuthType.PIN; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; let status = userAuth.getAvailableStatus(authType, authTrustLevel); - console.log("getAvailableStatus status = " + status); + console.log('getAvailableStatus status = ' + status); ``` ### getProperty8+ @@ -2033,8 +2034,8 @@ This is a system API and cannot be called by third-party applications. keys: keys }; userAuth.getProperty(request, (err, result) => { - console.log("getProperty err = " + JSON.stringify(err)); - console.log("getProperty result = " + JSON.stringify(result)); + console.log('getProperty err = ' + JSON.stringify(err)); + console.log('getProperty result = ' + JSON.stringify(result)); }); ``` @@ -2075,9 +2076,9 @@ This is a system API and cannot be called by third-party applications. keys: keys }; userAuth.getProperty(request).then((result) => { - console.log("getProperty result = " + JSON.stringify(result)); + console.log('getProperty result = ' + JSON.stringify(result)); }).catch((err) => { - console.log("getProperty error = " + JSON.stringify(err)); + console.log('getProperty error = ' + JSON.stringify(err)); }); ``` @@ -2109,8 +2110,8 @@ This is a system API and cannot be called by third-party applications. setInfo: new Uint8Array([0]) }; userAuth.setProperty(request, (err, result) => { - console.log("setProperty error = " + JSON.stringify(err)); - console.log("setProperty result = " + JSON.stringify(result)); + console.log('setProperty error = ' + JSON.stringify(err)); + console.log('setProperty result = ' + JSON.stringify(result)); }); ``` @@ -2147,9 +2148,9 @@ This is a system API and cannot be called by third-party applications. setInfo: new Uint8Array([0]) }; userAuth.setProperty(request).then((result) => { - console.log("setProperty result = " + JSON.stringify(result)); + console.log('setProperty result = ' + JSON.stringify(result)); }).catch((err) => { - console.log("setProperty error = " + JSON.stringify(err)); + console.log('setProperty error = ' + JSON.stringify(err)); }); ``` @@ -2189,8 +2190,8 @@ This is a system API and cannot be called by third-party applications. let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; userAuth.auth(challenge, authType, authTrustLevel, { onResult: function(result,extraInfo){ - console.log("auth result = " + result); - console.log("auth extraInfo = " + JSON.stringify(extraInfo)); + console.log('auth result = ' + result); + console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); } }); ``` @@ -2233,8 +2234,8 @@ This is a system API and cannot be called by third-party applications. let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; userAuth.authUser(userID, challenge, authType, authTrustLevel, { onResult: function(result,extraInfo){ - console.log("authUser result = " + result); - console.log("authUser extraInfo = " + JSON.stringify(extraInfo)); + console.log('authUser result = ' + result); + console.log('authUser extraInfo = ' + JSON.stringify(extraInfo)); } }); ``` @@ -2270,12 +2271,12 @@ This is a system API and cannot be called by third-party applications. let challenge = new Uint8Array([0]); let contextID = userAuth.auth(challenge, account_osAccount.AuthType.PIN, account_osAccount.AuthTrustLevel.ATL1, { onResult: (result, extraInfo) => { - console.log("auth result = " + result); - console.log("auth extraInfo = " + JSON.stringify(extraInfo)); + console.log('auth result = ' + result); + console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); } }); let result = userAuth.cancelAuth(contextID); - console.log("cancelAuth result = " + result); + console.log('cancelAuth result = ' + result); ``` ## PINAuth8+ @@ -2294,7 +2295,7 @@ This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.Account.OsAccount -**Example** +**Example** ```js let pinAuth = new account_osAccount.PINAuth(); ``` @@ -2332,7 +2333,7 @@ This is a system API and cannot be called by third-party applications. callback.onSetData(pinSubType, password); } }); - console.log("registerInputer result = " + result); + console.log('registerInputer result = ' + result); ``` ### unregisterInputer @@ -2369,7 +2370,7 @@ This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.Account.OsAccount -**Example** +**Example** ```js let userIDM = new account_osAccount.UserIdentityManager(); ``` @@ -2396,8 +2397,8 @@ This is a system API and cannot be called by third-party applications. ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.openSession((err, challenge) => { - console.log("openSession error = " + JSON.stringify(err)); - console.log("openSession challenge = " + JSON.stringify(challenge)); + console.log('openSession error = ' + JSON.stringify(err)); + console.log('openSession challenge = ' + JSON.stringify(challenge)); }); ``` @@ -2423,9 +2424,9 @@ This is a system API and cannot be called by third-party applications. ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.openSession().then((challenge) => { - console.info("openSession challenge = " + JSON.stringify(challenge)); + console.info('openSession challenge = ' + JSON.stringify(challenge)); }).catch((err) => { - console.info("openSession error = " + JSON.stringify(err)); + console.info('openSession error = ' + JSON.stringify(err)); }); ``` @@ -2466,8 +2467,8 @@ This is a system API and cannot be called by third-party applications. userIDM.openSession((err, challenge) => { userIDM.addCredential(credentialInfo, { onResult: (result, extraInfo) => { - console.log("updateCredential result = " + result); - console.log("updateCredential extraInfo = " + extraInfo); + console.log('updateCredential result = ' + result); + console.log('updateCredential extraInfo = ' + extraInfo); } }); }); @@ -2517,8 +2518,8 @@ This is a system API and cannot be called by third-party applications. credentialInfo.token = extraInfo.token; userIDM.updateCredential(credentialInfo, { onResult: (result, extraInfo) => { - console.log("updateCredential result = " + result); - console.log("updateCredential extraInfo = " + extraInfo); + console.log('updateCredential result = ' + result); + console.log('updateCredential extraInfo = ' + extraInfo); } }); } @@ -2566,14 +2567,14 @@ This is a system API and cannot be called by third-party applications. | Type | Description | | :----- | :-------------------------------------------------------- | -| number | [Result code](#resultcode8) indicating whether the operation is successful.| +| number | [Result code](#resultcode8).| **Example** ```js let userIDM = new account_osAccount.UserIdentityManager(); let challenge = new Uint8Array([0]); let result = userIDM.cancel(challenge); - console.log("cancel result: " + result); + console.log('cancel result: ' + result); ``` ### delUser8+ @@ -2601,8 +2602,8 @@ This is a system API and cannot be called by third-party applications. let token = new Uint8Array([0]); userIDM.delUser(token, { onResult: (result, extraInfo) => { - console.log("delUser result = " + result); - console.log("delUser extraInfo = " + JSON.stringify(extraInfo)); + console.log('delUser result = ' + result); + console.log('delUser extraInfo = ' + JSON.stringify(extraInfo)); } }); ``` @@ -2634,8 +2635,8 @@ This is a system API and cannot be called by third-party applications. let token = new Uint8Array([0]); userIDM.delCred(credentialId, token, { onResult: (result, extraInfo) => { - console.log("delCred result = " + result); - console.log("delCred extraInfo = " + JSON.stringify(extraInfo)); + console.log('delCred result = ' + result); + console.log('delCred extraInfo = ' + JSON.stringify(extraInfo)); } }); ``` @@ -2656,15 +2657,15 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | -------- | -------------------------------------------------- | ---- | -------------------------------------------------- | -| callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | Yes | Callback invoked to return information about all enrolled credentials of the specified type.| +| callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | Yes | Callback invoked to return information about all the user's enrolled credentials of the specified type.| **Example** ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.getAuthInfo((err, result) => { - console.log("getAuthInfo err = " + JSON.stringify(err)); - console.log("getAuthInfo result = " + JSON.stringify(result)); + console.log('getAuthInfo err = ' + JSON.stringify(err)); + console.log('getAuthInfo result = ' + JSON.stringify(result)); }); ``` @@ -2691,8 +2692,8 @@ This is a system API and cannot be called by third-party applications. ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.getAuthInfo(account_osAccount.AuthType.PIN, (err, result) => { - console.log("getAuthInfo err = " + JSON.stringify(err)); - console.log("getAuthInfo result = " + JSON.stringify(result)); + console.log('getAuthInfo err = ' + JSON.stringify(err)); + console.log('getAuthInfo result = ' + JSON.stringify(result)); }); ``` @@ -2724,9 +2725,9 @@ This is a system API and cannot be called by third-party applications. ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.getAuthInfo(account_osAccount.AuthType.PIN).then((result) => { - console.log("getAuthInfo result = " + JSON.stringify(result)) + console.log('getAuthInfo result = ' + JSON.stringify(result)) }).catch((err) => { - console.log("getAuthInfo error = " + JSON.stringify(err)); + console.log('getAuthInfo error = ' + JSON.stringify(err)); }); ``` @@ -2805,7 +2806,7 @@ This is a system API and cannot be called by third-party applications. }; let pinAuth = new account_osAccount.PINAuth(); let result = pinAuth.registerInputer(inputer); - console.log("registerInputer result: " + result); + console.log('registerInputer result: ' + result); ``` ## IUserAuthCallback8+ @@ -2835,8 +2836,8 @@ This is a system API and cannot be called by third-party applications. ```js let authCallback = { onResult: (result, extraInfo) => { - console.log("auth result = " + result); - console.log("auth extraInfo = " + JSON.stringify(extraInfo)); + console.log('auth result = ' + result); + console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); } }; ``` @@ -2863,12 +2864,12 @@ This is a system API and cannot be called by third-party applications. ```js let authCallback = { onResult: (result, extraInfo) => { - console.log("auth result = " + result) - console.log("auth extraInfo = " + JSON.stringify(extraInfo)); + console.log('auth result = ' + result) + console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); }, onAcquireInfo: (module, acquire, extraInfo) => { - console.log("auth module = " + module); - console.log("auth acquire = " + acquire); + console.log('auth module = ' + module); + console.log('auth acquire = ' + acquire); console.info('auth extraInfo = ' + JSON.stringify(extraInfo)); } }; @@ -2899,9 +2900,9 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - var idmCallback = { + let idmCallback = { onResult: (result, extraInfo) => { - console.log("callback result = " + result) + console.log('callback result = ' + result) console.info('callback extraInfo = ' + JSON.stringify(extraInfo)); } }; @@ -2929,12 +2930,12 @@ This is a system API and cannot be called by third-party applications. ```js let idmCallback = { onResult: (result, extraInfo) => { - console.log("callback result = " + result) - console.log("callback onResult = " + JSON.stringify(extraInfo)); + console.log('callback result = ' + result) + console.log('callback onResult = ' + JSON.stringify(extraInfo)); }, onAcquireInfo: (module, acquire, extraInfo) => { - console.log("callback module = " + module); - console.log("callback acquire = " + acquire); + console.log('callback module = ' + module); + console.log('callback acquire = ' + acquire); console.log('callback onacquireinfo = ' + JSON.stringify(extraInfo)); } }; @@ -3217,8 +3218,8 @@ Domain account information. | Constraint | Description | | ------------------------------------- | ------------------------------ | -| constraint.wifi | A user is not allowed to use Wi-Fi. | -| constraint.wifi.set | A user is not allowed to change Wi-Fi settings. | +| constraint.wifi | A user is not allowed to use Wi-Fi. | +| constraint.wifi.set | A user is not allowed to set Wi-Fi. | | constraint.locale.set | A user is not allowed to change the device language. | | constraint.app.accounts | A user is not allowed to add or delete app accounts. | | constraint.apps.install | A user is not allowed to install apps. | diff --git a/en/application-dev/reference/apis/js-apis-rpc.md b/en/application-dev/reference/apis/js-apis-rpc.md index 60cd08a08e0baf3853bf11f2628230a402805900..d1b4506837068ac88f3821befed6a673726fd327 100644 --- a/en/application-dev/reference/apis/js-apis-rpc.md +++ b/en/application-dev/reference/apis/js-apis-rpc.md @@ -16,7 +16,7 @@ import rpc from '@ohos.rpc'; ## MessageParcel -Provides methods for reading and writing basic data types and arrays, inter-process communication (IPC) objects, interface tokens, and sequenceable objects. +Provides APIs for reading and writing data in specific format. During RPC, the sender can use the **write()** method provided **MessageParcel** to write data to a **MessageParcel** object in specific format. The receiver can use the **read()** method provided by **MessageParcel** to read data in specific format from a **MessageParcel** object. The data formats include basic data types and arrays, IPC objects, interface tokens, and custom sequenceable objects. ### create @@ -28,7 +28,8 @@ Creates a **MessageParcel** object. This method is a static method. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | MessageParcel | **MessageParcel** object created.| @@ -65,12 +66,14 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | object | [IRemoteObject](#iremoteobject) | Yes| Remote object to serialize and write to the **MessageParcel** object.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -111,7 +114,8 @@ Reads the remote object from this **MessageParcel** object. You can use this met **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | [IRemoteObject](#iremoteobject) | Remote object obtained.| @@ -148,17 +152,19 @@ Reads the remote object from this **MessageParcel** object. You can use this met writeInterfaceToken(token: string): boolean -Writes an interface token to this **MessageParcel** object. +Writes an interface token to this **MessageParcel** object. The remote object can use this interface token to verify the communication. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | token | string | Yes| Interface token to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -175,12 +181,13 @@ Writes an interface token to this **MessageParcel** object. readInterfaceToken(): string -Reads the interface token from this **MessageParcel** object. The interface tokens are read in the order in which they are written into the **MessageParcel** object. +Reads the interface token from this **MessageParcel** object. The interface token is read in the sequence in which it is written to the **MessageParcel** object. The local object can use it to verify the communication. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Interface token obtained.| @@ -206,7 +213,8 @@ Obtains the data size of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Size of the **MessageParcel** object obtained, in bytes.| @@ -228,7 +236,8 @@ Obtains the capacity of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | **MessageParcel** capacity obtained, in bytes.| @@ -250,12 +259,14 @@ Sets the size of data contained in this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | size | number | Yes| Data size to set, in bytes.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -277,12 +288,14 @@ Sets the storage capacity of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | size | number | Yes| Storage capacity to set, in bytes.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -304,7 +317,8 @@ Obtains the writable capacity of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | **MessageParcel** writable capacity obtained, in bytes.| @@ -330,7 +344,8 @@ Obtains the readable capacity of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | **MessageParcel** object readable capacity, in bytes.| @@ -356,7 +371,8 @@ Obtains the read position of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Current read position of the **MessageParcel** object.| @@ -378,7 +394,8 @@ Obtains the write position of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Current write position of the **MessageParcel** object.| @@ -401,12 +418,14 @@ Moves the read pointer to the specified position. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | pos | number | Yes| Position from which data is to read.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the read position changes; returns **false** otherwise.| @@ -433,12 +452,14 @@ Moves the write pointer to the specified position. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | pos | number | Yes| Position from which data is to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the write position changes; returns **false** otherwise.| @@ -463,12 +484,14 @@ Writes a Byte value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Byte value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -490,7 +513,8 @@ Reads the Byte value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Byte value read.| @@ -514,12 +538,14 @@ Writes a Short int value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Short int value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -541,7 +567,8 @@ Reads the Short int value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Short int value read.| @@ -565,12 +592,14 @@ Writes an Int value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Int value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -592,7 +621,8 @@ Reads the Int value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Int value read.| @@ -616,12 +646,14 @@ Writes a Long int value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Long int value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -643,7 +675,8 @@ Reads the Long int value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Long int value read.| @@ -667,12 +700,14 @@ Writes a Float value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Float value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -694,7 +729,8 @@ Reads the Float value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Float value read.| @@ -718,12 +754,14 @@ Writes a Double value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Double value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -745,7 +783,8 @@ Reads the Double value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Double value read.| @@ -769,12 +808,14 @@ Writes a Boolean value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | boolean | Yes| Boolean value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -796,7 +837,8 @@ Reads the Boolean value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Boolean value read.| @@ -820,12 +862,14 @@ Writes a Char value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Char value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -847,7 +891,8 @@ Reads the Char value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Char value read.| @@ -871,12 +916,14 @@ Writes a string to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | string | Yes| String to write. The length of the string must be less than 40960 bytes.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -898,7 +945,8 @@ Reads a string from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | String read.| @@ -922,12 +970,14 @@ Writes a sequenceable object to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | [Sequenceable](#sequenceable) | Yes| Sequenceable object to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -968,12 +1018,14 @@ Reads member variables from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | [Sequenceable](#sequenceable) | Yes| Object that reads member variables from the **MessageParcel** object.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1017,12 +1069,14 @@ Writes a byte array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | byteArray | number[] | Yes| Byte array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1045,7 +1099,8 @@ Reads a byte array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| Byte array to read.| @@ -1070,7 +1125,8 @@ Reads the byte array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Byte array read.| @@ -1095,12 +1151,14 @@ Writes a short array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | shortArray | number[] | Yes| Short array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1122,7 +1180,8 @@ Reads a short array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| Short array to read.| @@ -1146,7 +1205,8 @@ Reads the short array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Short array read.| @@ -1170,12 +1230,14 @@ Writes an integer array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | intArray | number[] | Yes| Integer array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1197,7 +1259,8 @@ Reads an integer array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| Integer array to read.| @@ -1221,7 +1284,8 @@ Reads the integer array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Integer array read.| @@ -1245,12 +1309,14 @@ Writes a long array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | longArray | number[] | Yes| Long array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1272,7 +1338,8 @@ Reads a long array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| Long array to read.| @@ -1296,7 +1363,8 @@ Reads the long array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Long array read.| @@ -1320,12 +1388,14 @@ Writes a FloatArray to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | floatArray | number[] | Yes| FloatArray to write. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1347,7 +1417,8 @@ Reads a FloatArray from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| FloatArray to read. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| @@ -1372,7 +1443,8 @@ Reads the FloatArray from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | FloatArray read.| @@ -1396,12 +1468,14 @@ Writes a DoubleArray to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | doubleArray | number[] | Yes| DoubleArray to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1423,7 +1497,8 @@ Reads a DoubleArray from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| DoubleArray to read.| @@ -1447,7 +1522,8 @@ Reads the DoubleArray from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | DoubleArray read.| @@ -1471,12 +1547,14 @@ Writes a Boolean array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | booleanArray | boolean[] | Yes| Boolean array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1498,7 +1576,8 @@ Reads a Boolean array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | boolean[] | Yes| Boolean array to read.| @@ -1522,7 +1601,8 @@ Reads the Boolean array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean[] | Boolean array read.| @@ -1545,12 +1625,14 @@ Writes a character array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | charArray | number[] | Yes| Character array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1572,7 +1654,8 @@ Reads a character array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| Character array to read.| @@ -1596,7 +1679,8 @@ Reads the character array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Character array read.| @@ -1620,12 +1704,14 @@ Writes a string array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | stringArray | string[] | Yes| String array to write. The length of a single element in the array must be less than 40960 bytes.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1647,7 +1733,8 @@ Reads a string array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | string[] | Yes| String array to read.| @@ -1671,7 +1758,8 @@ Reads the string array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string[] | String array read.| @@ -1793,12 +1881,14 @@ Writes a sequenceable array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | sequenceableArray | Sequenceable[] | Yes| Sequenceable array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1842,7 +1932,8 @@ Reads a sequenceable array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | sequenceableArray | Sequenceable[] | Yes| Sequenceable array to read.| @@ -1888,12 +1979,14 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | objectArray | IRemoteObject[] | Yes| Array of **IRemoteObject** objects to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** if the operation fails or if the **IRemoteObject** array is null.| @@ -1939,7 +2032,8 @@ Reads an **IRemoteObject** array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | objects | IRemoteObject[] | Yes| **IRemoteObject** array to read.| @@ -1986,7 +2080,8 @@ Reads the **IRemoteObject** array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | IRemoteObject[] | **IRemoteObject** object array obtained.| @@ -2034,7 +2129,8 @@ Closes a file descriptor. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | fd | number | Yes| File descriptor to close.| @@ -2057,12 +2153,14 @@ Duplicates a file descriptor. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | fd | number | Yes| File descriptor to duplicate.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | New file descriptor.| @@ -2085,7 +2183,8 @@ Checks whether this **MessageParcel** object contains a file descriptor. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the **MessageParcel** object contains a file descriptor; returns **false** otherwise.| @@ -2113,12 +2212,14 @@ Writes a file descriptor to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | fd | number | Yes| File descriptor to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2143,7 +2244,8 @@ Reads the file descriptor from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | File descriptor read.| @@ -2169,12 +2271,14 @@ Writes an anonymous shared object to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | ashmem | Ashmem | Yes| Anonymous shared object to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2197,7 +2301,8 @@ Reads the anonymous shared object from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Ashmem | Anonymous share object obtained.| @@ -2222,7 +2327,8 @@ Obtains the maximum amount of raw data that can be held by this **MessageParcel* **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | 128 MB, which is the maximum amount of raw data that can be held by this **MessageParcel** object.| @@ -2244,13 +2350,15 @@ Writes raw data to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | rawData | number[] | Yes| Raw data to write.| | size | number | Yes| Size of the raw data, in bytes.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2273,12 +2381,14 @@ Reads raw data from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | size | number | Yes| Size of the raw data to read.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Raw data obtained, in bytes.| @@ -2307,12 +2417,14 @@ Marshals the sequenceable object into a **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataOut | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object to which the sequenceable object is to be marshaled.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2356,12 +2468,14 @@ Unmarshals this sequenceable object from a **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object in which the sequenceable object is to be unmarshaled.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2405,12 +2519,13 @@ Provides the holder of a remote proxy object. asObject(): IRemoteObject -Obtains a proxy or remote object. This method must be implemented by its derived classes. +Obtains a proxy or remote object. This API must be implemented by its derived classes. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | [IRemoteObject](#iremoteobject) | Returns the [RemoteObject](#ashmem8) if it is the caller; returns the [IRemoteObject](#iremoteobject), the holder of this **RemoteProxy** object, if the caller is a [RemoteProxy](#remoteproxy) object.| @@ -2491,29 +2606,32 @@ Obtains the interface. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | descriptor | string | Yes| Interface descriptor.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | IRemoteBroker | **IRemoteBroker** object bound to the specified interface descriptor.| ### sendRequest(deprecated) +sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean + > **NOTE**
> This API is deprecated since API version 8. You are advised to use [sendRequestAsync9+](#sendrequestasync9). -sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean - Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2521,24 +2639,26 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| ### sendRequest8+(deprecated) -> **NOTE**
-> This API is deprecated since API Version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9). - sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> +> **NOTE**
+> This API is deprecated since API version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9). + Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2546,7 +2666,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -2559,7 +2680,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2567,7 +2689,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -2580,7 +2703,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2598,13 +2722,15 @@ Adds a callback for receiving death notifications of the remote object. This met **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to add.| | flags | number | Yes| Flag of the death notification.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| @@ -2618,13 +2744,15 @@ Removes the callback used to receive death notifications of the remote object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to remove.| | flags | number | Yes| Flag of the death notification.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the callback is removed successfully; returns **false** otherwise.| @@ -2638,7 +2766,8 @@ Obtains the interface descriptor of this object. The interface descriptor is a s **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Interface descriptor obtained.| @@ -2652,7 +2781,8 @@ Checks whether this object is dead. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the object is dead; returns **false** otherwise.| @@ -2676,17 +2806,18 @@ Provides methods to implement **IRemoteObject**. ### sendRequest(deprecated) -> **NOTE**
-> This API is deprecated since API Version 8. You are advised to use [sendRequestAsync9+](#sendrequestasync9-1). - sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean +> **NOTE**
+> This API is deprecated since API version 8. You are advised to use [sendRequestAsync9+](#sendrequestasync9-1). + Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2694,7 +2825,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2741,17 +2873,18 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ### sendRequest8+(deprecated) -> **NOTE**
-> This API is deprecated since API Version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9-1). - sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> +> **NOTE**
+> This API is deprecated since API version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9-1). + Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2759,7 +2892,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -2818,7 +2952,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2826,7 +2961,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -2885,7 +3021,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2946,12 +3083,14 @@ Obtains the **LocalInterface** object of an interface descriptor. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | interface | string | Yes| Interface descriptor.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | IRemoteBroker | Returns **Null** by default, which indicates a proxy interface.| @@ -2991,13 +3130,15 @@ Adds a callback for receiving the death notifications of the remote object, incl **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to add.| | flags | number | Yes| Flag of the death notification. This parameter is reserved. It is set to **0**.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| @@ -3042,13 +3183,15 @@ Removes the callback used to receive death notifications of the remote object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to remove.| | flags | number | Yes| Flag of the death notification. This parameter is reserved. It is set to **0**.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the callback is removed successfully; returns **false** otherwise.| @@ -3094,7 +3237,8 @@ Obtains the interface descriptor of this proxy object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Interface descriptor obtained.| @@ -3134,7 +3278,8 @@ Checks whether the **RemoteObject** is dead. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the **RemoteObject** is dead; returns **false** otherwise.| @@ -3188,7 +3333,8 @@ A constructor used to create a **MessageOption** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | syncFlags | number | No| Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.| | waitTime | number | No| Maximum wait time for an RPC call. The default value is **TF_WAIT_TIME**.| @@ -3203,7 +3349,8 @@ Obtains the call flag, which can be synchronous or asynchronous. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Call mode obtained.| @@ -3217,7 +3364,8 @@ Sets the call flag, which can be synchronous or asynchronous. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | flags | number | Yes| Call flag to set.| @@ -3231,7 +3379,8 @@ Obtains the maximum wait time for this RPC call. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Maximum wait time obtained.| @@ -3245,7 +3394,8 @@ Sets the maximum wait time for this RPC call. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | waitTime | number | Yes| Maximum wait time to set.| @@ -3264,7 +3414,8 @@ Obtains the system capability manager. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | [IRemoteObject](#iremoteobject) | System capability manager obtained.| @@ -3285,7 +3436,8 @@ Obtains the PID of the caller. This method is invoked by the **RemoteObject** ob **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | PID of the caller.| @@ -3311,7 +3463,8 @@ Obtains the UID of the caller. This method is invoked by the **RemoteObject** ob **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | UID of the caller.| @@ -3363,7 +3516,8 @@ Obtains the ID of the device hosting the caller's process. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Device ID obtained.| @@ -3389,7 +3543,8 @@ Obtains the local device ID. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Local device ID obtained.| @@ -3415,7 +3570,8 @@ Checks whether the remote process is a process of the local device. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the local and remote processes are on the same device; returns **false** otherwise.| @@ -3441,13 +3597,15 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | object | [IRemoteObject](#iremoteobject) | Yes| **RemoteProxy** specified. | **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Returns **0** if the operation is successful; returns an error code if the input object is null or a **RemoteObject**, or if the operation fails.| @@ -3488,7 +3646,8 @@ Changes the UID and PID of the remote user to the UID and PID of the local user. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | String containing the UID and PID of the remote user.| @@ -3514,12 +3673,14 @@ Restores the UID and PID of the remote user. It is usually called when the UID a **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | identity | string | Yes| String containing the remote user UID and PID, which are returned by **resetCallingIdentity**.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -3556,24 +3717,26 @@ A constructor used to create a **RemoteObject** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | descriptor | string | Yes| Interface descriptor.| ### sendRequest(deprecated) -> **NOTE**
-> This API is deprecated since API Version 8. You are advised to use [sendRequestAsync9+](#sendrequestasync9-2). - sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean +> **NOTE**
+> This API is deprecated since API version 8. You are advised to use [sendRequestAsync9+](#sendrequestasync9-2). + Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -3581,7 +3744,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -3630,17 +3794,18 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ### sendRequest8+(deprecated) -> **NOTE**
-> This API is deprecated since API Version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9-2). - sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> +> **NOTE**
+> This API is deprecated since API version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9-2). + Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -3648,7 +3813,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -3709,7 +3875,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -3717,7 +3884,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -3777,7 +3945,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -3831,16 +4000,21 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ``` -### onRemoteRequest +### onRemoteRequest8+(deprecated) + onRemoteRequest(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean +> **NOTE**
+> This API is deprecated since API version 9. You are advised to use [onRemoteRequestEx9+](#onremoterequestex9). + Provides a response to **sendRequestAsync()**. The server processes the request and returns a response in this function. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Service request code sent by the remote end.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that holds the parameters called by the client.| @@ -3848,14 +4022,15 @@ Provides a response to **sendRequestAsync()**. The server processes the request | option | [MessageOption](#messageoption) | Yes| Whether the operation is synchronous or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** - ``` + ```ets class MyDeathRecipient { onRemoteDied() { console.log("server died"); @@ -3886,8 +4061,190 @@ Provides a response to **sendRequestAsync()**. The server processes the request } } ``` +### onRemoteRequestEx9+ + +onRemoteRequestEx(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean | Promise + +> **NOTE**
+>- You are advised to overload **onRemoteRequestEx** preferentially, which implements synchronous and asynchronous message processing. +>- If both **onRemoteRequest** and **onRemoteRequestEx** are overloaded, only **onRemoteRequestEx** takes effect. + +Provides a response to **sendRequestAsync()**. The server processes the request synchronously or asynchronously and returns the result in this API. + +**System capability**: SystemCapability.Communication.IPC.Core + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | code | number | Yes| Service request code sent by the remote end.| + | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that holds the parameters called by the client.| + | reply | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object carrying the result.| + | option | [MessageOption](#messageoption) | Yes| Whether the operation is synchronous or asynchronous.| + +**Return value** + + | Type| Description| + | -------- | -------- | + | boolean | Returns a Boolean value if the request is processed synchronously in **onRemoteRequestEx**. If the operation is successful, **true** is returned. Otherwise, **false** is returned.| + | Promise | Returns a promise object if the request is processed asynchronously in **onRemoteRequestEx**.| + + +**Example**: Overload **onRemoteRequestEx** to process a request synchronously. + + ```ets + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + onRemoteRequestEx(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: sync onRemoteRequestEx is called"); + return true; + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + } + } + ``` + **Example**: Overload **onRemoteRequestEx** to process a request asynchronously. + ```ets + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + async onRemoteRequestEx(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: async onRemoteRequestEx is called"); + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + await new Promise((resolve) => { + setTimeout(resolve, 100); + }) + return true; + } + } + ``` +**Example**: Overload **onRemoteRequestEx** and **onRemoteRequest** to process requests synchronously. + ```ets + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + onRemoteRequest(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: sync onRemoteRequestEx is called"); + return true; + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + } + // Only onRemoteRequestEx is executed when onRemoteRequestEx and onRemoteRequest are called. + onRemoteRequestEx(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: async onRemoteRequestEx is called"); + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + + return true; + } + } + ``` + **Example**: Overload **onRemoteRequestEx** and **onRemoteRequest** to process requests asynchronously. + + ```ets + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + onRemoteRequest(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: sync onRemoteRequestEx is called"); + return true; + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + } + // Only onRemoteRequestEx is executed when onRemoteRequestEx and onRemoteRequest are called. + async onRemoteRequestEx(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: async onRemoteRequestEx is called"); + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + await new Promise((resolve) => { + setTimeout(resolve, 100); + }) + return true; + } + } + ``` ### getCallingUid getCallingUid(): number @@ -3897,7 +4254,8 @@ Obtains the UID of the remote process. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | UID of the remote process obtained.| @@ -3938,7 +4296,8 @@ Obtains the PID of the remote process. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | PID of the remote process obtained.| @@ -3979,12 +4338,14 @@ Checks whether the remote object corresponding to the specified interface descri **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | descriptor | string | Yes| Interface descriptor.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | IRemoteBroker | Returns the remote object if a match is found; returns **Null** otherwise.| @@ -4025,7 +4386,8 @@ Obtains the interface descriptor. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Interface descriptor obtained.| @@ -4067,7 +4429,8 @@ Binds an interface descriptor to an **IRemoteBroker** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | localInterface | IRemoteBroker | Yes| **IRemoteBroker** object.| | descriptor | string | Yes| Interface descriptor.| @@ -4128,13 +4491,15 @@ Creates an **Ashmem** object with the specified name and size. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | name | string | Yes| Name of the **Ashmem** object to create.| | size | number | Yes| Size (in bytes) of the **Ashmem** object to create.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Ashmem | Returns the **Ashmem** object if it is created successfully; returns null otherwise.| @@ -4157,12 +4522,14 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | ashmem | Ashmem | Yes| Existing **Ashmem** object.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Ashmem | **Ashmem** object created.| @@ -4218,7 +4585,8 @@ Obtains the memory size of this **Ashmem** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | **Ashmem** size obtained.| @@ -4240,12 +4608,14 @@ Creates the shared file mapping on the virtual address space of this process. Th **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | mapType | number | Yes| Protection level of the memory region to which the shared file is mapped.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -4267,7 +4637,8 @@ Maps the shared file to the readable and writable virtual address space of the p **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -4289,7 +4660,8 @@ Maps the shared file to the read-only virtual address space of the process. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -4311,12 +4683,14 @@ Sets the protection level of the memory region to which the shared file is mappe **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | protectionType | number | Yes| Protection type to set.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -4338,14 +4712,16 @@ Writes data to the shared file associated with this **Ashmem** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | buf | number[] | Yes| Data to write.| | size | number | Yes| Size of the data to write.| | offset | number | Yes| Start position of the data to write in the memory region associated with this **Ashmem** object.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** is the data is written successfully; returns **false** otherwise.| @@ -4370,13 +4746,15 @@ Reads data from the shared file associated with this **Ashmem** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | size | number | Yes| Size of the data to read.| | offset | number | Yes| Start position of the data to read in the memory region associated with this **Ashmem** object.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Data read.| diff --git a/en/application-dev/reference/apis/js-apis-statfs.md b/en/application-dev/reference/apis/js-apis-statfs.md index fc9109b25611afe452ea32255267b036e71a45b0..b9cf5106d4369769056d0ad19ed0b4a37a75f553 100644 --- a/en/application-dev/reference/apis/js-apis-statfs.md +++ b/en/application-dev/reference/apis/js-apis-statfs.md @@ -18,26 +18,26 @@ Obtains the number of free bytes of the specified file system in asynchronous mo **System capability**: SystemCapability.FileManagement.File.FileIO -- **Parameters** +**Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------- | | path | string | Yes | File path of the file system.| -- Return value +**Return value** | Type | Description | | --------------------- | -------------- | | Promise<number> | Promise used to return the number of free bytes obtained.| -- Example +**Example** ```js let path = "/dev"; - statfs.getFreeBytes(path).then(function (number){ - console.info("getFreeBytes promise successfully:"+ number); - }).catch(function(err){ - console.info("getFreeBytes failed with error:"+ err); + statfs.getFreeBytes(path).then(function (number) { + console.info("getFreeBytes promise successfully:" + number); + }).catch(function (err) { + console.info("getFreeBytes failed with error:" + err); }); ``` @@ -49,21 +49,21 @@ Obtains the number of free bytes of the specified file system in asynchronous mo **System capability**: SystemCapability.FileManagement.File.FileIO -- **Parameters** +**Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ---------------------------- | | path | string | Yes | File path of the file system.| | callback | AsyncCallback<number> | Yes | Callback invoked to return the number of free bytes obtained.| -- Example +**Example** ```js - import featureAbility from '@ohos.ability.featureAbility'; + import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getFilesDir().then(function (path) { - statfs.getFreeBytes(path, function(err, number){ - console.info("Got free bytes successfully:"+ number); + statfs.getFreeBytes(path, function (err, number) { + console.info("getFreeBytes callback successfully:" + number); }); }); ``` @@ -76,26 +76,26 @@ Obtains the total number of bytes of the specified file system in asynchronous m **System capability**: SystemCapability.FileManagement.File.FileIO -- **Parameters** +**Parameters** | Name| Type | Mandatory| Description | | ---- | ------ | ---- | ---------------------------- | | path | string | Yes | File path of the file system.| -- Return value +**Return value** | Type | Description | | --------------------- | ------------ | | Promise<number> | Promise used to return the total number of bytes obtained.| -- Example +**Example** ```js let path = "/dev"; - statfs.getTotalBytes(path).then(function (number){ - console.info("getTotalBytes promise successfully:"+ number); - }).catch(function(err){ - console.info("getTotalBytes failed with error:"+ err); + statfs.getTotalBytes(path).then(function (number) { + console.info("getTotalBytes promise successfully:" + number); + }).catch(function (err) { + console.info("getTotalBytes failed with error:" + err); }); ``` @@ -107,21 +107,21 @@ Obtains the total number of bytes of the specified file system in asynchronous m **System capability**: SystemCapability.FileManagement.File.FileIO -- **Parameters** +**Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ---------------------------- | | path | string | Yes | File path of the file system.| | callback | AsyncCallback<number> | Yes | Callback invoked to return the total number of bytes obtained. | -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getFilesDir().then(function (path) { - statfs.getTotalBytes(path, function(err, number){ - console.info("Got total bytes successfully:"+ number); + statfs.getTotalBytes(path, function(err, number) { + console.info("getTotalBytes callback successfully:" + number); }); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-system-cipher.md b/en/application-dev/reference/apis/js-apis-system-cipher.md index cd4100d455e6f47f6d2600562a4d0522c885284a..82be7501dfcef800ba7bd6db6fc9e3759ac05bfa 100644 --- a/en/application-dev/reference/apis/js-apis-system-cipher.md +++ b/en/application-dev/reference/apis/js-apis-system-cipher.md @@ -25,7 +25,7 @@ Encrypts or decrypts data using RSA. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| action | string | Yes| Action to perform. The options are as follows:
- encrypt
- decrypt| +| action | string | Yes| Action to perform. The options are as follows:
- encrypt
- decrypt | | text | string | Yes| Text to be encrypted or decrypted.
The text to be encrypted must be common text that meets the following requirement:
Maximum text length = Key length/8 - 66
For example, if the key is of 1024 bytes, the text to be encrypted cannot exceed 62 bytes (1024/8 -66 = 62).
The text to be decrypted must be binary text encoded in Base64. The default format is used for Base64 encoding.| | key | string | Yes| RSA key. The key is used as a public key in encryption and a private key in decryption.| | transformation | string | No| RSA padding. The default value is **RSA/None/OAEPWithSHA256AndMGF1Padding**.| @@ -109,7 +109,7 @@ Encrypts or decrypts data using AES. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| action | string | Yes| Action to perform. The options are as follows:
- encrypt
- decrypt| +| action | string | Yes| Action to perform. The options are as follows:
- encrypt
- decrypt | | text | string | Yes| Text to be encrypted or decrypted.
The text to be encrypted must be common text. The text to be decrypted must be binary text encoded in Base64. The default format is used for Base64 encoding.| | key | string | Yes| Key used for encryption or decryption. It is a string encoded in Base64.| | transformation | string | No| Encryption mode and padding of the AES algorithm. The default value is **AES/CBC/PKCS5Padding**.| @@ -165,7 +165,6 @@ export default { console.log(`operation complete!`); } }); - }); } } diff --git a/en/application-dev/reference/apis/js-apis-vibrator.md b/en/application-dev/reference/apis/js-apis-vibrator.md index b27059e688201d7621fe90006df89e1720eb5823..8d0c0ad48f1dc919c5032dc1d37ad39026071583 100644 --- a/en/application-dev/reference/apis/js-apis-vibrator.md +++ b/en/application-dev/reference/apis/js-apis-vibrator.md @@ -2,8 +2,6 @@ The **Vibrator** module provides APIs for triggering or stopping vibration. -Misc devices, including vibrators and LED lights, are used to send signals externally. You can call the APIs of this module to control the vibration of vibrators and turning-on/off of LED lights. - > **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. @@ -19,25 +17,26 @@ import vibrator from '@ohos.vibrator'; vibrate(duration: number): Promise<void> -Triggers vibration with a specific duration. This API uses a promise to return the execution result. +Triggers vibration with the specified duration. This API uses a promise to return the result. -**Required permissions**: ohos.permission.VIBRATE (a system permission) +**Required permissions**: ohos.permission.VIBRATE **System capability**: SystemCapability.Sensors.MiscDevice - **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------ | ---- | ------------ | -| duration | number | Yes | Vibration duration.| + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ---------------------- | +| duration | number | Yes | Vibration duration, in ms.| **Return value** -| Type | Description | -| ------------------- | ----------- | -| Promise<void> | Promise used to indicate whether the vibration is triggered successfully.| +| Type | Description | +| ------------------- | -------------------------------------- | +| Promise<void> | Promise that returns no value.| **Example** + ```js vibrator.vibrate(1000).then(()=>{ console.log("Promise returned to indicate a successful vibration."); @@ -46,28 +45,67 @@ Triggers vibration with a specific duration. This API uses a promise to return t }); ``` +## vibrator.vibrate9+ + +vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise<void> + +Triggers vibration with the specified effect and attribute. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.VIBRATE + +**System capability**: SystemCapability.Sensors.MiscDevice + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | -------------------------------------- | ---- | :------------- | +| effect | [VibrateEffect](#vibrateeffect9) | Yes | Vibration effect.| +| attribute | [VibrateAttribute](#vibrateattribute9) | Yes | Vibration attribute.| + +**Return value** + +| Type | Description | +| ------------------- | -------------------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** + +```js +vibrator.vibrate({ + type: 'time', + duration: 1000 +}, { + id: 0, + usage: 'alarm' +}).then(()=>{ + console.log("Promise returned to indicate a successful vibration"); +}).catch((error)=>{ + console.log("error.code" + error.code + "error.message" + error.message); +}) +``` ## vibrator.vibrate vibrate(duration: number, callback?: AsyncCallback<void>): void -Triggers vibration with a specific duration. This API uses an asynchronous callback to return the execution result. +Triggers vibration with the specified duration. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.VIBRATE (a system permission) +**Required permissions**: ohos.permission.VIBRATE **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ----------------------- | -| duration | number | Yes | Vibration duration. | -| callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is triggered successfully.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------------------------------------------------------- | +| duration | number | Yes | Vibration duration, in ms. | +| callback | AsyncCallback<void> | No | Callback used to the result. If the vibration starts, **err** is **undefined**. Otherwise, **err** is an error object.| **Example** + ```js vibrator.vibrate(1000,function(error){ if(error){ - console.log("error.code"+error.code+"error.message"+error.message); + console.log("error.code" + error.code + "error.message" + error.message); }else{ console.log("Callback returned to indicate a successful vibration."); } @@ -79,28 +117,28 @@ Triggers vibration with a specific duration. This API uses an asynchronous callb vibrate(effectId: EffectId): Promise<void> -Triggers vibration with a specific effect. This API uses a promise to return the execution result. +Triggers vibration with the specified effect. This API uses a promise to return the result. -**Required permissions**: ohos.permission.VIBRATE (a system permission) +**Required permissions**: ohos.permission.VIBRATE **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------- | ---- | ------------- | -| effectId | [EffectId](#effectid) | Yes | Vibration effect. | +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| effectId | [EffectId](#effectid) | Yes | Preset vibration effect ID.| **Return value** -| Type | Description | -| ------------------- | ----------- | -| Promise<void> | Promise used to indicate whether the vibration is triggered successfully.| +| Type | Description | +| ------------------- | -------------------------------------- | +| Promise<void> | Promise that returns no value.| **Example** ```js vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{ console.log("Promise returned to indicate a successful vibration."); }, (error)=>{ - console.log("error.code"+error.code+"error.message"+error.message); + console.log("error.code" + error.code + "error.message" + error.message); }); ``` @@ -109,56 +147,94 @@ Triggers vibration with a specific effect. This API uses a promise to return the vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void -Triggers vibration with a specific effect. This API uses an asynchronous callback to return the execution result. +Triggers vibration with the specified effect. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.VIBRATE (a system permission) +**Required permissions**: ohos.permission.VIBRATE **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ----------------------- | -| effectId | [EffectId](#effectid) | Yes | Vibration effect. | -| callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is triggered successfully.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------------------------------------------------------- | +| effectId | [EffectId](#effectid) | Yes | Preset vibration effect ID. | +| callback | AsyncCallback<void> | No | Callback used to the result. If the vibration starts, **err** is **undefined**. Otherwise, **err** is an error object.| **Example** + ```js vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){ if(error){ - console.log("error.code"+error.code+"error.message"+error.message); + console.log("error.code" + error.code + "error.message" + error.message); }else{ console.log("Callback returned to indicate a successful vibration."); } }) ``` +## vibrator.vibrate9+ + +vibrate(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback<void>): void + +Triggers vibration with the specified effect and attribute. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.VIBRATE + +**System capability**: SystemCapability.Sensors.MiscDevice + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | -------------------------------------- | ---- | :--------------------------------------------------------- | +| effect | [VibrateEffect](#vibrateeffect9) | Yes | Vibration effect. | +| attribute | [VibrateAttribute](#vibrateattribute9) | Yes | Vibration attribute. | +| callback | AsyncCallback<void> | Yes | Callback used to the result. If the vibration starts, **err** is **undefined**. Otherwise, **err** is an error object.| + +**Example** + +```js +vibrator.vibrate({ + type:'time', + duration:1000, +},{ + id:0, + usage: 'alarm' +}, (error)=>{ + if(error){ + console.log("vibrate fail, error.code:" + error.code + ",error.message:" + error.message); + }else{ + console.log("Callback returned to indicate a successful vibration."); + } +}); +``` ## vibrator.stop stop(stopMode: VibratorStopMode): Promise<void> -Stops the vibration based on the specified **stopMode**. This API uses a promise to return the execution result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called. +Stops the vibration with the specified **stopMode**. This API uses a promise to return the result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called. -**Required permissions**: ohos.permission.VIBRATE (a system permission) +**Required permissions**: ohos.permission.VIBRATE **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------------- | ---- | --------------- | -| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------- | ---- | ------------------------ | +| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Mode to stop the vibration.| **Return value** -| Type | Description | -| ------------------- | ----------- | -| Promise<void> | Promise used to indicate whether the vibration is stopped successfully.| + +| Type | Description | +| ------------------- | -------------------------------------- | +| Promise<void> | Promise that returns no value.| **Example** + ```js vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ console.log("Promise returned to indicate a successful vibration."); }, (error)=>{ - console.log("error.code"+error.code+"error.message"+error.message); + console.log("error.code" + error.code + "error.message" + error.message); }); ``` @@ -167,23 +243,24 @@ Stops the vibration based on the specified **stopMode**. This API uses a promise stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void; -Stops the vibration based on the specified **stopMode**. This API uses an asynchronous callback to return the execution result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called. +Stops the vibration with the specified **stopMode**. This API uses an asynchronous callback to return the result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called. -**Required permissions**: ohos.permission.VIBRATE (a system permission) +**Required permissions**: ohos.permission.VIBRATE **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------------- | ---- | ----------------------- | -| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. | -| callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is stopped successfully.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------- | ---- | ------------------------------------------------------------ | +| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Mode to stop the vibration. | +| callback | AsyncCallback<void> | No | Callback used to the result. If the vibration stops, **err** is **undefined**. Otherwise, **err** is an error object.| **Example** + ```js vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ if(error){ - console.log("error.code"+error.code+"error.message"+error.message); + console.log("error.code" + error.code + "error.message" + error.message); }else{ console.log("Callback returned to indicate a successful stop."); } @@ -193,22 +270,85 @@ Stops the vibration based on the specified **stopMode**. This API uses an asynch ## EffectId -Describes the vibration effect. +Describes the vibration effect ID. **System capability**: SystemCapability.Sensors.MiscDevice -| Name | Default Value | Description | -| ------------------ | -------------------- | --------------- | -| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer.| +| Name | Default Value | Description | +| ------------------ | -------------------- | ------------------ | +| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Preset vibration effect ID.| ## VibratorStopMode -Describes the vibration mode to stop. +Enumerates the modes available to stop the vibration. **System capability**: SystemCapability.Sensors.MiscDevice -| Name | Default Value | Description | -| ------------------------- | -------- | ---------------------------------------- | +| Name | Default Value | Description | +| ------------------------- | -------- | ------------------------------------------------------------ | | VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type.| | VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type.| + +## VibrateEffect9+ + +Describes the vibration effect. + +**System capability**: SystemCapability.Sensors.MiscDevice + +| Type | Description | +| -------------------------------- | ------------------------------ | +| [VibrateTime](#vibratetime9) | Triggers vibration with the specified duration. This API uses a promise to return the result.| +| [VibratePreset](#vibratepreset9) | Vibration with a preset effect.| + +## VibrateTime9+ + +Describes the vibration with the specified duration. + +**System capability**: SystemCapability.Sensors.MiscDevice + +| Name | Default Value| Description | +| -------- | ------ | ------------------------------ | +| type | "time" | Vibration with the specified duration.| +| duration | - | Vibration duration, in ms. | + +## VibratePreset9+ + +Describes the vibration with a preset effect. + +**System capability**: SystemCapability.Sensors.MiscDevice + +| Name | Default Value | Description | +| -------- | -------- | ------------------------------ | +| type | "preset" | Vibration with the specified effect.| +| effectId | - | Preset vibration effect ID. | +| count | - | Number of vibrations to repeat. | + +## VibrateAttribute9+ + +Describes the vibration attribute. + +**System capability**: SystemCapability.Sensors.MiscDevice + +| Name | Default Value| Description | +| ----- | ------ | -------------- | +| id | 0 | Vibrator ID. | +| usage | - | Vibration scenario.| + +## Usage9+ + +Enumerates the vibration scenarios. + +**System capability**: SystemCapability.Sensors.MiscDevice + +| Name | Type | Description | +| ---------------- | ------ | ------------------------------ | +| unknown | string | Unknown scenario, with the lowest priority.| +| alarm | string | Vibration for alarms. | +| ring | string | Vibration for incoming calls. | +| notification | string | Vibration for notifications. | +| communication | string | Vibration for communication. | +| touch | string | Touch vibration scenario. | +| media | string | Multimedia vibration scenario. | +| physicalFeedback | string | Physical feedback vibration scenario. | +| simulateReality | string | Simulated reality vibration scenario. | diff --git a/en/contribute/introducing-third-party-open-source-software.md b/en/contribute/introducing-third-party-open-source-software.md index 3976cb07251ee26e93102eb09b1b7642fa6a5125..a0b35543246aff22d2d6ad693f1553add5932457 100644 --- a/en/contribute/introducing-third-party-open-source-software.md +++ b/en/contribute/introducing-third-party-open-source-software.md @@ -30,13 +30,13 @@ For easier maintenance and evolution, comply with the following principles when 2. Provide a sound reason for software introduction. If the software to be introduced already exists in the OpenHarmony project, reuse it to avoid maintenance complexity caused by coexistence of multiple versions. 3. Introduce the software in the form of source code, rather than binary files. If a piece of software needs to be introduced in the form of binary files, the PMC should review the request and make a decision. 4. Make sure the software can be correctly built on the OpenHarmony project. If the software has dependency software that has not been introduced, or the running or build of the software depends on a component that cannot be introduced, the SIG-Architecture should review the request and make a decision. -5. Place the software in an independent code repository and name it in the format of **third_party_*****softwareName***, where *softwareName* must be an official name. +5. Place the software in an independent code repository and name it in the format of **third_party**_**softwareName**, where *softwareName* must be an official name. 6. Retain the directory structure, license, and copyright information of the official code repository of the software. Do not modify the original license and copyright information. 7. Do not introduce any software version that has not been officially released, for example, the Beta version. 8. Do not introduce any software version that has high-risk vulnerabilities and does not provide solutions. 9. If you need to modify the software, place the new code in the software repository and ensure that the new code meets the license requirements of the software. Retain the original license for the modified files, and use the same license for the new files (recommended). 10. Provide the **README.OpenSource** file in the root directory of the software repository. Include the following information in the file: software name, license, license file location, version, upstream community address of the corresponding version, software maintenance owner, function description, and introduction reason. -11. Make sure the software you introduce is under the custody of a domain SIG. In principle, the SIG-Architecture will deny the introduction of a piece of software without the confirmation of the SIG-Compliance and the corresponding domain SIG. When introducing multiple pieces of software at a time, you can ask the PMC to hold a temporary review meeting between SIGs for faster introduction. If you want to introduce a piece of software but fail to meet the preceding requirements, send an email to law@openatom.org. +11. Make sure the software you introduce is under the custody of a domain SIG. In principle, the SIG-Architecture will deny the introduction of a piece of software without the confirmation of the SIG-Compliance and the corresponding domain SIG. When introducing multiple pieces of software at a time, you can ask the PMC to hold a temporary review meeting between SIGs for faster introduction. If you want to introduce a piece of software but fail to meet the preceding requirements, send an email to oh-legal@openatom.io. 12. When software introduction depends on other dependency software, it is not allowed to nest the dependency software in the subdirectory of the software introduction, and all dependency softwares must be placed in separate repository, and name it in the format of **third_party_*****softwareName***, because nested placement of dependency software may lead to multiple versions of the same software, old versions of security vulnerabilities cannot be fixed in a timely, and will risk the opensource compliance issues. - Dependency software are named in the compiled BUILD.gn with part name by prefixing the newly software introduction name, e.g. part_name = "software_introduction_name_dependency software_name". - The inter-component dependencies between software introduction and dependency software are resolved via external_deps. @@ -51,7 +51,7 @@ For easier maintenance and evolution, comply with the following principles when | Source| Check whether the software is downloaded from its official website or source specified on the official website.| | Community activeness| 1. Do not introduce software from a community or organization that notifies users of software maintenance termination by releasing a bullet, modifying the software repository status, or moving the software repository in a specified directory.
2. Do not introduce software from an individual, a small community, or an organization that has not released a version (either official or test version) within two years, does not have a clear version roadmap, or does not respond to any valid bug or pull request in the community.
3. Do not introduce software from a community that is not longer maintained or does not respond to any operating status related issue or email for more than half a year.| | Security vulnerability| 1. Search for disclosed security vulnerabilities in the industry, and check whether solutions are provided if there are high-risk vulnerabilities in the software.| -| Software name| 1. Name the repository in the format of **third_party_*****softwareName***, where *softwareName* must be the same as the official name.
2. Do not use the sub-module name of the software as the software name.
3. If the software has development libraries in multiple languages, add prefixes such as **python-** to the official software name for standardized management.| +| Software name| 1. Name the repository in the format of **third_party**_**softwareName**, where **softwareName** must be the same as the official name.
2. Do not use the sub-module name of the software as the software name.
3. If the software has development libraries in multiple languages, add prefixes such as **python-** to the official software name for standardized management.| | Official website information| 1. Describe the official website of the software in the request. If there is no official website, provide the project URL on a mainstream code hosting platform. Dot not use the hosting library addresses such as Maven, mvnrepository, and SpringSource.
2. Provide the official download address of the software version source package for traceability. If a binary package is required, provide the official download address of the binary package.| | License| 1. Check whether the software to be introduced has a license.
2. Check whether the imported license is consistent with the license of the corresponding version on the official website of the software.
3. Exercise caution when introducing open-source software with high-risk licenses. Before introducing the software, fully evaluate the risk and attach the analysis conclusion in the request.| @@ -63,7 +63,7 @@ Follow the process described in the [SIG Management Regulations](https://gitee.c | Check Item| Description| Self-Check Result Example| | :----- | :----- | :----- | -| Software name| Provide the official name of the software and the repository name to which the software is introduced. The repository name is in the format of **third_party_*****softwareName***.| third_party_*softwareName*| +| Software name| Provide the official name of the software and the repository name to which the software is introduced. The repository name is in the format of **third_party**_**softwareName**.| third_party_**softwareName**| | Official website| Provide the official website link of the software.| https://softwaresite | | Software version| Provide the version number of the software to be introduced. The version number must be an official version number released by the community. Do not modify the version number or introduce a version that is not officially released.| 1.0.0 | | Software version release date| Provide the official release date of the software version.| 2021.01.01 | @@ -192,7 +192,7 @@ Refer to the [SIG Management Regulations](https://gitee.com/openharmony/communit * Ruby License * Eclipse Public License 2.0: EPL 2.0 -If you want to introduce the software that complies with the unrecommended licenses listed in **4** or other licenses that are not mentioned, send an email to law@openatom.org. +If you want to introduce the software that complies with the unrecommended licenses listed in **4** or other licenses that are not mentioned, send an email to oh-legal@openatom.io. ## Software Exit and Exit Principles diff --git a/en/device-dev/driver/figures/ADM_startup_flowchart.png b/en/device-dev/driver/figures/ADM_startup_flowchart.png index cf921d8db2ed82bd5e46628fd34bb0066262213f..7882f97a27b9c06094562a8cb9deb5028f00468b 100644 Binary files a/en/device-dev/driver/figures/ADM_startup_flowchart.png and b/en/device-dev/driver/figures/ADM_startup_flowchart.png differ diff --git a/en/device-dev/driver/figures/Audio_architecture.png b/en/device-dev/driver/figures/Audio_architecture.png index a419414b829274b2163f9a7581dc201ae33c28c9..8c88b9094ef4511b2522993b612ae9d44e5d4fe4 100644 Binary files a/en/device-dev/driver/figures/Audio_architecture.png and b/en/device-dev/driver/figures/Audio_architecture.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001322167645.png b/en/device-dev/quick-start/figures/en-us_image_0000001322167645.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001322167645.png rename to en/device-dev/quick-start/figures/en-us_image_0000001322167645.png diff --git a/en/device-dev/subsystems/subsys-build-FAQ.md b/en/device-dev/subsystems/subsys-build-FAQ.md index 6c5b37abf2df7fd3607351c60246243cbce48ca7..0d1d79a09673b880c555185942d6ab4e0ca440d8 100644 --- a/en/device-dev/subsystems/subsys-build-FAQ.md +++ b/en/device-dev/subsystems/subsys-build-FAQ.md @@ -56,17 +56,21 @@ - **Possible Causes** - You do not have the permission to access files in the RISC-V compiler directory. + You do not have the permission to access files in the RISC-V compiler directory. - **Solution** 1. Run the following command to locate **gcc_riscv32**: + + ```shell + which riscv32-unknown-elf-gcc + ``` - ```shell - which riscv32-unknown-elf-gcc - ``` - + + 2. Run the **chmod** command to change the directory permission to **755**. + + ### "No module named 'Crypto'" Displayed During the Build Process @@ -76,7 +80,7 @@ - **Possible Causes** - Crypto is not installed in Python 3. + Crypto is not installed in Python3. - **Solution** @@ -109,4 +113,21 @@ sudo ln -s /bin/bash /bin/sh ``` - + +### "some services are not authenticated. Listed as follows" Displayed During the Build Process + +- **Symptom** + + The build fails, and "some services are not authenticated. Listed as follows" is displayed. + +- **Possible Causes** + + For the processes listed in the error information, the UID is set to **root** or **system** in the process configuration files. However, these processes are not high-privilege processes defined by the product. + +- **Solution** + + Modify the process configuration file to reduce the privilege level. Do not set **UID** to **root** or **system** unless necessary. + + If a process must have the **root** or **system** privilege due to service requirements, modify the **high_privilege_process_list.json** file with the approval of security experts. The **high_privilege_process_list.json** file is located in **vendor/**{*company_name*}/{*product_name*}**/security_config**. For example, the file for rk3586 is **//vendor/hihope/rk3568/security_config/high_privilege_process_list.json**. + + diff --git a/en/readme/figures/en_architecture-of-netmanager-subsystem.png b/en/readme/figures/en_architecture-of-netmanager-subsystem.png index 426e1360e245a115219fe6666c67fc0b26fed0c1..2ec10b551bfe57e1ae1277b20160c60f34aaf8df 100644 Binary files a/en/readme/figures/en_architecture-of-netmanager-subsystem.png and b/en/readme/figures/en_architecture-of-netmanager-subsystem.png differ diff --git a/en/readme/network-management.md b/en/readme/network-management.md new file mode 100644 index 0000000000000000000000000000000000000000..3851fa87f79902e69d3fe82a09c69f04bfa19bd0 --- /dev/null +++ b/en/readme/network-management.md @@ -0,0 +1,148 @@ +# Network Management + + +## Introduction + +As a mandatory component for device networking, the network management subsystem implements unified connection management, traffic management, policy management, network sharing of different types of networks, and provides network protocol stack capabilities. An application can call APIs to obtain connection information of a data network, query and subscribe to connection status, network traffic data, and network policy, share the network, and transfer data using a network protocol stack. + +The figure below shows the architecture of the network management subsystem. The network management subsystem consists of the following components: + +- Basic network management: provides basic network connection management and related JS and native APIs, including connection priority management, connection information query, connection status observation, DNS resolution, traffic management, networking policy management, and physical network management. +- Extended network management: provides extended network management capabilities and related JS and native APIs, including Ethernet connection and hotspot sharing. +- Network protocol stacks: provides basic network protocol stacks (such as HTTP, HTTPS, WebSocket, and TCP/UDP/TLS socket) and related JS APIs. + +**Figure 1** Architecture of the network management subsystem + +![](figures/en_architecture-of-netmanager-subsystem.png) + +## Directory Structure + +``` +foundation/communication/ +├── netmanager_base # Basic network management +├── netmanager_ext # Extended network management +└── netstack # Network protocol stacks +``` + +## Usage + +### Observing Network Status Changes + +1. Import the connection namespace from **@ohos.net.connection.d.ts**. + +2. Call **createNetConnection()** to create a **NetConnection** object. You can specify the network type, capability, and timeout interval. If you do not specify parameters, the default values will be used. + +3. Call **conn.on()** to subscribe to the target event. You must pass in **type** and **callback**. + +4. Call **conn.register()** to subscribe to network status changes of the specified network. + +6. Call **conn.unregister()** to unsubscribe from the network status changes if required. + + ``` + // Import the connection namespace. + import connection from '@ohos.net.connection' + + let netCap = { + // Set the network type to cellular network. + bearerTypes: [connection.NetBearType.BEARER_CELLULAR], + // Set the network capability to Internet. + networkCap: [connection.NetCap.NET_CAPABILITY_INTERNET], + }; + let netSpec = { + netCapabilities: netCap, + }; + // Set the timeout interval to 10s. + let timeout = 10 * 1000; + // Create a NetConnection object. + let conn = connection.createNetConnection(netSpec, timeout); + // Subscribe to the netAvailable event. When the network is available, the callback will be invoked to report the event. + conn.on('netAvailable', (data=> { + console.log("net is available, netId is " + data.netId); + })); + // Register an observer for network status changes. + conn.register((err, data) => {}); + // Unregister the observer for network status changes. + conn.unregister((err, data) => {}); + ``` + +### Sharing a Network + +1. Import the network sharing namespace from **@ohos.net.sharing**. +2. Set the network sharing type. +3. Start network sharing. +4. Stop network sharing. +``` +// Import the network sharing namespace. +import sharing from '@ohos.net.sharing'; +// Set the network sharing type. +this.sharingType = 0; // The value 0 indicates Wi-Fi, 1 indicates USB, and 2 indicates Bluetooth. +// Start network sharing. +sharing.startSharing(this.sharingType,(err)=>{ + this.callBack(err); +}) +// Stop network sharing. +sharing.stopSharing(this.sharingType,(err)=>{ + this.callBack(err); +}) +``` + +### Initiating a Network Request + +1. Import the HTTP namespace from **@ohos.net.http.d.ts**. +2. Call **createHttp()** to create an **HttpRequest** object. +3. Call **httpRequest.on()** to subscribe to an HTTP response header. This method returns a response earlier than the request. You can subscribe to HTTP response header events based on service requirements. +4. Call **httpRequest.request()** to initiate a network request. You need to pass in the URL and optional parameters of the HTTP request. +5. Parse the returned result based on service requirements. +6. Call **httpRequest.destroy()** to release resources after the request is processed. + +``` +// Import the HTTP namespace. +import http from '@ohos.net.http'; + +// Each httpRequest corresponds to an HttpRequestTask object and cannot be reused. +let httpRequest = http.createHttp(); +// Subscribe to the HTTP response header, which is returned earlier than the response to httpRequest. +httpRequest.on('headersReceive', (data) => { + console.info('header: ' + data.header); +}); +httpRequest.request( + // Set the URL for the httpRequest. You must specify the URL address, and set httpRequestOptions as required. You can specify the parameters for GET in extraData. + "EXAMPLE_URL", + { + method: 'POST', // Optional. The default value is GET. + // You can add header fields based on service requirements. + header: { + 'Content-Type': 'application/json' + }, + // This field is used to transfer data when the POST request is used. + extraData: { + "data": "data to send", + }, + connectTimeout: 60000, // This parameter is optional. The default value is 60000, that is, 60s. + readTimeout: 60000, // This parameter is optional. The default value is 60000, that is, 60s. + },(err, data) => { + if (!err) { + // data.result carries the HTTP response. Parse the response based on service requirements. + console.info('Result:' + data.result); + console.info('code:' + data.responseCode); + // data.header carries the HTTP response header. Parse the content based on service requirements. + console.info('header:' + data.header); + console.info('header:' + data.cookies); + } else { + console.info('error:' + err); + } + // Call destroy() to release resources after HttpRequest is complete. + httpRequest.destroy(); + } +); +``` + +## Repositories Involved + +**Network Management Subsystem** + +[communication_netmanager_base](https://gitee.com/openharmony/communication_netmanager_base) + +[communication_netmanager_ext](https://gitee.com/openharmony/communication_netmanager_ext) + +[communication_netstack](https://gitee.com/openharmony/communication_netstack) \ No newline at end of file diff --git a/en/release-notes/release-definitions/Release-version-definitions.md b/en/release-notes/release-definitions/Release-version-definitions.md new file mode 100644 index 0000000000000000000000000000000000000000..07c9f9b80d4f4716a330bbc74c41518170e5a8a0 --- /dev/null +++ b/en/release-notes/release-definitions/Release-version-definitions.md @@ -0,0 +1,66 @@ +# OpenHarmony Version Definitions + +## Branches + +To ensure smooth version evolution and continuous stability and reliability of historical versions, the OpenHarmony community periodically pulls branches such as Long Term Support (LTS), Release, and Beta from Master and manages them based on the OpenHarmony lifecycle definition. + +![1.png](figures/1.png) + + +### Master + +Master is the main branch in the OpenHarmony community, to which code updates of all software packages' Master branches in the community are proactively merged for real-time build. + +### LTS + +LTS is a branch pulled from Master in the OpenHarmony community in the third quarter of each year. This branch is compiled, built, and tested in a centralized manner, and finally reviewed and released by the community. + +### Release + +Release is a branch pulled from Master in the OpenHarmony community in the first quarter of each year. This branch is compiled, built, and tested in a centralized manner, and finally reviewed and released by the community. A Release branch has the same release requirements but a shorter maintenance period when compared with an LTS branch. + +### Beta + +Beta is a branch pulled from Master in the OpenHarmony community irregularly. This branch has centralized compilation, building, and basic function verification finished, and can be used for development and debugging. + +### Tag + +A tag version is a stable and reliable version created by applying patches to an LTS or a Release branch, with the purpose of fixing individual bugs, security vulnerabilities, and other necessary adaptation modifications. + +## Maintenance Policies + +### Lifecycle Policies + +OpenHarmony provides lifecycle management services for LTS and Release branches as follows: + +#### Release -> Stop proactive maintenance + +The Release SIG periodically makes and maintains tag version plans to resolve individual bugs, security vulnerabilities, and other major issues to ensure continuously stable and available branches. + +#### Stop proactive maintenance -> Stop maintenance + +The Release SIG no longer proactively plans and releases tag versions. It only fixes security vulnerabilities and major defects in corresponding branches. + +### LTS and Release Maintenance Policies + +For an LTS branch, the OpenHarmony community provides 2-year proactive maintenance and 1.5-year passive maintenance since its release. + +For a Release branch, the OpenHarmony community provides 1-year proactive maintenance and 1-year passive maintenance since its release. + +### Branch Merge Policies + +The Release SIG is responsible for lifecycle management of an LTS or a Release branch. During the maintenance period, the SIG accepts only code updates that resolve security vulnerabilities, ACTS issues, and other major issues. All code updates can be merged into the branch only after the related pull request has been approved by the [owner](https://gitee.com/openharmony/community/blob/master/zh/BRANCHOWNER). + +### Maintenance Schedule + +The following table lists the maintenance schedule of the LTS and Release branches that have been released in the OpenHarmony community. + +| No. | Branch Name | Branch Type| Release Date | End of Proactive Maintenance| End of Maintenance | +| :--- | ------------- | :------- | :-------- | :----------- | :-------- | +| 1 | 1.0.1-Release | Release | 2021-03-30| 2022-03-30 | 2023-03-30| +| 2 | 3.0-LTS | LTS | 2021-09-30| 2023-09-30 | 2025-03-30| +| 3 | 3.1-Release | Release | 2022-03-30| 2023-03-30 | 2024-03-30| + +### Version Plan + +The OpenHarmony Release SIG periodically releases, updates, and maintains branch version plans. For details, visit [OpenHarmony-SIG-RoadMap](https://gitee.com/openharmony-sig/oh-inner-release-management/blob/master/OpenHarmony-SIG-RoadMap.md). diff --git a/en/release-notes/release-definitions/figures/1.png b/en/release-notes/release-definitions/figures/1.png new file mode 100644 index 0000000000000000000000000000000000000000..5731d241932f7e65f83d9b56e029f3d3db6931d6 Binary files /dev/null and b/en/release-notes/release-definitions/figures/1.png differ diff --git a/zh-cn/application-dev/faqs/faqs-device-management.md b/zh-cn/application-dev/faqs/faqs-device-management.md index b5bac9f878fb9e5bbe7732479e97c478df7dfc5d..7a1ca35602e3be567b3afeceb91054f86cf9f0cb 100644 --- a/zh-cn/application-dev/faqs/faqs-device-management.md +++ b/zh-cn/application-dev/faqs/faqs-device-management.md @@ -20,5 +20,5 @@ display.getDefaultDisplay((err, data) => { } console.info('Test Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); console.info('Test densityDPI:' + JSON.stringify(data.densityDPI)); -});https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-device-info.md) +}); ``` diff --git a/zh-cn/application-dev/faqs/faqs-ui-js.md b/zh-cn/application-dev/faqs/faqs-ui-js.md index 390b9e3753099a245a1395f9fc8e82ff7f271675..90ec607864c46ecfbeba21b7ac327ffe8c3e3ae1 100644 --- a/zh-cn/application-dev/faqs/faqs-ui-js.md +++ b/zh-cn/application-dev/faqs/faqs-ui-js.md @@ -13,25 +13,33 @@ convertxml中convert方法提供了转换xml文本为JavaScript对象的能力 ``` import convertxml from '@ohos.convertxml'; -// 代码片段 -xml = +// xml格式的字符串 +let xml = '' + '' + ' Happy' + ' Work' + ' Play' + ''; -let conv = new convertxml.ConvertXML(); +let conv = new convertxml.ConvertXML(); // 转换选项, 参考文档使用 -let options = {trim : false, declarationKey:"_declaration", - instructionKey : "_instruction", attributesKey : "_attributes", - textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", - commentKey : "_comment", parentKey : "_parent", typeKey : "_type", - nameKey : "_name", elementsKey : "_elements"} -let result:any = conv.convert(xml, options) // 将xml文本转为JS对象 +let options = { + trim: false, + declarationKey: "_declaration", + instructionKey: "_instruction", + attributesKey: "_attributes", + textKey: "_text", + cdataKey: "_cdata", + doctypeKey: "_doctype", + commentKey: "_comment", + parentKey: "_parent", + typeKey: "_type", + nameKey: "_name", + elementsKey: "_elements" +} +let result: any = conv.convert(xml, options) // 将xml文本转为JS对象 console.log('Test: ' + JSON.stringify(result)) -console.log('Test: ' + result._declaration._attributes.version) // xml代码片段version字段信息 -console.log('Test: ' + result._elements[0]._elements[0]._elements[0]._text) // xml代码片段title字段内容 +console.log('Test: ' + result._declaration._attributes.version) // xml字符串中version字段信息console.log('Test: ' + result._elements[0]._elements[0]._elements[0]._text) // xml字符串中title字段内容 ``` 参考文档:[xml转换JavaScript](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-convertxml.md) diff --git a/zh-cn/application-dev/media/image.md b/zh-cn/application-dev/media/image.md index f04166c6daf2f463665605bee6d095feb7824293..3536c857eed935735b273d047314dad492106421 100644 --- a/zh-cn/application-dev/media/image.md +++ b/zh-cn/application-dev/media/image.md @@ -21,45 +21,43 @@ let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { // 创建pixelmap对象 const color = new ArrayBuffer(96); let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } } - image.createPixelMap(color, opts, pixelmap => { - expect(pixelmap !== null).assertTrue(); - console.info('TC_001-1 success'); - done(); - }) +image.createPixelMap(color, opts, pixelmap => { + console.log('Succeeded in creating pixelmap.'); +}) + // 用于读像素 pixelmap.readPixels(area,(data) => { - if(data !== null) { - var bufferArr = new Uint8Array(area.pixels); + if(data !== null) { + var bufferArr = new Uint8Array(area.pixels); var res = true; for (var i = 0; i < bufferArr.length; i++) { - console.info('TC_021-1 buffer ' + bufferArr[i]); - if(res) { - if(bufferArr[i] == 0) { - res = false; - console.info('TC_021-1 Success'); - expect(true).assertTrue(); - done(); - break; - } - } + console.info(' buffer ' + bufferArr[i]); + if(res) { + if(bufferArr[i] == 0) { + res = false; + console.log('readPixels end.'); + break; } + } + } + } +}) // 用于存像素 const readBuffer = new ArrayBuffer(96); pixelmap.readPixelsToBuffer(readBuffer,() => { -var bufferArr = new Uint8Array(readBuffer); -var res = true; -for (var i = 0; i < bufferArr.length; i++) { - if(res) { - if (bufferArr[i] !== 0) { - res = false; - console.info('TC_020-1 Success'); - expect(true).assertTrue(); - done(); - break; + var bufferArr = new Uint8Array(readBuffer); + var res = true; + for (var i = 0; i < bufferArr.length; i++) { + if(res) { + if (bufferArr[i] !== 0) { + res = false; + console.log('readPixelsToBuffer end.'); + break; + } } } -} +}) // 用于写像素 pixelmap.writePixels(area,() => { @@ -71,56 +69,51 @@ pixelmap.writePixels(area,() => { if(res) { if (readArr[i] !== 0) { res = false; - console.info('TC_022-1 Success'); - expect(true).assertTrue(); - done(); + console.log('readPixels end.please check buffer'); break; } } } + }) +}) // 用于写像素到缓冲区 pixelmap.writeBufferToPixels(writeColor).then(() => { const readBuffer = new ArrayBuffer(96); pixelmap.readPixelsToBuffer(readBuffer).then (() => { - var bufferArr = new Uint8Array(readBuffer); - var res = true; - for (var i = 0; i < bufferArr.length; i++) { - if(res) { - if (bufferArr[i] !== i) { - res = false; - console.info('TC_023 Success'); - expect(true).assertTrue() - done(); + var bufferArr = new Uint8Array(readBuffer); + var res = true; + for (var i = 0; i < bufferArr.length; i++) { + if(res) { + if (bufferArr[i] !== i) { + res = false; + console.log('readPixels end.please check buffer'); break; } } } + }) +}) // 用于获取图片信息 pixelmap.getImageInfo( imageInfo => { if (imageInfo !== null) { - console.info('TC_024-1 imageInfo is ready'); - expect(imageInfo.size.height == 4).assertTrue(); - expect(imageInfo.size.width == 6).assertTrue(); - expect(imageInfo.pixelFormat == 4).assertTrue(); - done(); + console.log('Succeeded in getting imageInfo'); } }) // 用于释放pixelmap pixelmap.release(()=>{ - expect(true).assertTrue(); - console.log('TC_027-1 suc'); - done(); + console.log('Succeeded in releasing pixelmap'); }) -let path = '/data/local/tmp/test.jpg'; // 用于创建imagesource(uri) -const imageSourceApi = image.createImageSource(path); // '/data/local/tmp/test.jpg' +let path = '/data/local/tmp/test.jpg'; +const imageSourceApi = image.createImageSource(path); // 用于创建imagesource(fd) -const imageSourceApi = image.createImageSource(29); +let fd = 29; +const imageSourceApi = image.createImageSource(fd); // 用于创建imagesource(data) const data = new ArrayBuffer(96); @@ -128,15 +121,15 @@ const imageSourceApi = image.createImageSource(data); // 用于释放imagesource imageSourceApi.release(() => { - console.info('TC_044-1 Success'); - }) + console.log('Succeeded in releasing imagesource'); +}) // 用于编码 const imagePackerApi = image.createImagePacker(); +const imageSourceApi = image.createImageSource(0); +let packOpts = { format:"image/jpeg", quality:98 }; imagePackerApi.packing(imageSourceApi, packOpts, data => { - console.info('TC_062-1 finished'); - expect(data !== null).assertTrue(); - done(); + console.log('Succeeded in packing'); }) // 用于释放imagepacker @@ -164,75 +157,54 @@ let decodingOptions = { // 用于回调方式创建pixelmap imageSourceApi.createPixelMap(decodingOptions, pixelmap => { - console.info('TC_050 createPixelMap '); - expect(pixelmap !== null ).assertTrue(); - done(); - }) -} + console.log('Succeeded in creating pixelmap.'); +}) // 用于promise创建pixelmap imageSourceApi.createPixelMap().then(pixelmap => { - console.info('TC_050-11 createPixelMap '); - expect(pixelmap !== null ).assertTrue(); - done(); + console.log('Succeeded in creating pixelmap.'); }) // 函数调用发生异常时,捕捉错误信息 catch(error => { - console.log('TC_050-11 error: ' + error); - expect().assertFail(); - done(); + console.log('Failed in creating pixelmap.' + error); }) // 用于获取像素每行字节数 pixelmap.getBytesNumberPerRow( num => { - console.info('TC_025-1 num is ' + num); - expect(num == expectNum).assertTrue(); - done(); + console.log('Succeeded in getting BytesNumber PerRow.'); }) // 用于获取像素总字节数 pixelmap.getPixelBytesNumber(num => { - console.info('TC_026-1 num is ' + num); - expect(num == expectNum).assertTrue(); - done(); + console.log('Succeeded in getting PixelBytesNumber.'); }) // 用于获取pixelmap信息 pixelmap.getImageInfo( imageInfo => {}) - -// 用于打印获取失败信息 -console.info('TC_024-1 imageInfo is empty'); -expect(false).assertTrue() // 用于释放pixelmap pixelmap.release(()=>{ - expect(true).assertTrue(); - console.log('TC_027-1 suc'); - done(); + console.log('Succeeded in releasing pixelmap'); }) // 用于捕捉释放失败信息 catch(error => { - console.log('TC_027-1 error: ' + error); - expect().assertFail(); - done(); + console.log('Failed in releasing pixelmap.' + error); }) ``` ### 编码场景 ```js -let path = '/data/local/tmp/test.png' // 设置创建imagesource的路径 +let path = '/data/local/tmp/test.png'; // 设置创建imagesource的路径 // 用于设置imagesource const imageSourceApi = image.createImageSource(path); // '/data/local/tmp/test.png' // 如果创建imagesource失败,打印错误信息 if (imageSourceApi == null) { - console.info('TC_062 create image source failed'); - expect(false).assertTrue(); - done(); + console.log('Failed in creating imageSource.'); } // 如果创建imagesource成功,则创建imagepacker @@ -240,9 +212,7 @@ const imagePackerApi = image.createImagePacker(); // 如果创建失败,打印错误信息 if (imagePackerApi == null) { - console.info('TC_062 create image packer failed'); - expect(false).assertTrue(); - done(); + console.log('Failed in creating imagePacker.'); } // 如果创建imagepacker成功,则设置编码参数 @@ -252,19 +222,15 @@ let packOpts = { format:["image/jpeg"], // 支持编码的格式为jpg // 用于编码 imagePackerApi.packing(imageSourceApi, packOpts) .then( data => { - console.info('TC_062 finished'); - expect(data !== null).assertTrue(); - done(); + console.log('Succeeded in packing'); }) - + // 编码完成,释放imagepacker imagePackerApi.release(); // 用于获取imagesource信息 imageSourceApi.getImageInfo(imageInfo => { - console.info('TC_045 imageInfo'); - expect(imageInfo !== null).assertTrue(); - done(); + console.log('Succeeded in getting imageInfo'); }) // 用于更新增量数据 diff --git a/zh-cn/application-dev/quick-start/start-overview.md b/zh-cn/application-dev/quick-start/start-overview.md index ef61b48ccffded3f156af895d3929f633d923e49..0834b0f2e2ea1b612027a5db9ebd43a854ead7c3 100644 --- a/zh-cn/application-dev/quick-start/start-overview.md +++ b/zh-cn/application-dev/quick-start/start-overview.md @@ -16,11 +16,11 @@ OpenHarmony提供了一套UI开发框架,即方舟开发框架(ArkUI框架)。方舟开发框架可为开发者提供应用UI开发所必需的能力,比如多种组件、布局计算、动画能力、UI交互、绘制等。 -方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于TS扩展的声明式开发范式(简称“声明式开发范式”)和基于JS扩展的类Web开发范式(简称“类Web开发范式”)。以下是两种开发范式的简单对比。 +方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于eTS的声明式开发范式(简称“声明式开发范式”)和兼容JS的类Web开发范式(简称“类Web开发范式”)。以下是两种开发范式的简单对比。 | **开发范式名称** | **语言生态** | **UI更新方式** | **适用场景** | **适用人群** | | -------- | -------- | -------- | -------- | -------- | -| 声明式开发范式 | 扩展的TS语言(eTS) | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 | +| 声明式开发范式 | eTS语言 | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 | | 类Web开发范式 | JS语言 | 数据驱动更新 | 界面较为简单的程序应用和卡片 | Web前端开发人员 | 更多UI框架的开发内容及指导,详见[UI开发](../ui/arkui-overview.md)。 diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0001.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0001.gif new file mode 100644 index 0000000000000000000000000000000000000000..fc737da287358cd81c65567e17da1bd4d701edff Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0001.gif differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0002.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0002.gif new file mode 100644 index 0000000000000000000000000000000000000000..9e3ff82c3de3a8867949b0d65aa4ffe55360e7cb Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0002.gif differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0004.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0004.gif new file mode 100644 index 0000000000000000000000000000000000000000..3b8462cf93c07e4b92c250bcb46409cc81e5129f Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0004.gif differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0005.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0005.gif new file mode 100644 index 0000000000000000000000000000000000000000..2bb6aa6c2a2086f16ae6149e9d3e4b2340d6fe37 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0005.gif differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0006.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0006.gif new file mode 100644 index 0000000000000000000000000000000000000000..2a6cf73b491304e3f53cb0a333588cad2e42f30b Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0006.gif differ diff --git a/zh-cn/application-dev/reference/apis/js-apis-call.md b/zh-cn/application-dev/reference/apis/js-apis-call.md index f09dd20b04ab5b7b94a12f2fb9171db222141276..5fb798aceeb9d3e5b08efcec6484ec8df3018743 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-call.md +++ b/zh-cn/application-dev/reference/apis/js-apis-call.md @@ -796,7 +796,7 @@ call.reject(rejectMessageOptions, (err, data) => { ## call.reject7+ -reject(callId: number, callback: AsyncCallback): +reject(callId: number, callback: AsyncCallback\): void 拒绝来电。使用callback异步回调。 @@ -811,20 +811,11 @@ reject(callId: number, callback: AsyncCallback): | callId | number | 是 | 呼叫Id。可以通过订阅callDetailsChange事件获得。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | -**返回值:** - -| 类型 | 说明 | -| ------------------- | --------------------------- | -| Promise<void> | 以Promise形式异步返回结果。 | - **示例:** ```js -let promise = call.reject(1); -promise.then(data => { - console.log(`reject success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`reject fail, promise: err->${JSON.stringify(err)}`); +call.reject(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1624,8 +1615,8 @@ on\(type: 'callDetailsChange', callback: Callback\): void **示例:** ```js -call.on('callDetailsChange', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.on('callDetailsChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1649,8 +1640,8 @@ on\(type: 'callEventChange', callback: Callback\): void **示例:** ```js -call.on('callEventChange', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.on('callEventChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1674,8 +1665,8 @@ on\(type: 'callDisconnectedCause', callback: Callback): vo **示例:** ```js -call.on('callDisconnectedCause', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.on('callDisconnectedCause', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1699,8 +1690,8 @@ on\(type: 'mmiCodeResult', callback: Callback\): void **示例:** ```js -call.on('mmiCodeResult', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.on('mmiCodeResult', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1724,8 +1715,8 @@ off\(type: 'callDetailsChange', callback?: Callback\): vo **示例:** ```js -call.off('callDetailsChange', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.off('callDetailsChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1749,8 +1740,8 @@ off\(type: 'callEventChange', callback?: Callback\): void **示例:** ```js -call.off('callEventChange', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.off('callEventChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1774,8 +1765,8 @@ off\(type: 'callDisconnectedCause', callback?: Callback\): **示例:** ```js -call.off('callDisconnectedCause', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.off('callDisconnectedCause', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1799,8 +1790,8 @@ off\(type: 'mmiCodeResult', callback?: Callback\): void **示例:** ```js -call.off('mmiCodeResult', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.off('mmiCodeResult', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -2389,7 +2380,7 @@ setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: Asyn let audioDeviceOptions={ bluetoothAddress: "IEEE 802-2014" } -call.setAudioDevice(1, audioDeviceOptions, (err, value) => { +call.setAudioDevice(1, audioDeviceOptions, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md b/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md new file mode 100644 index 0000000000000000000000000000000000000000..38b19761bb45edb344fac038c4dd78e11a075d82 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md @@ -0,0 +1,733 @@ +# 公共文件访问与管理 + +fileAccess模块是基于extension机制实现的一个对公共文件访问和操作的框架。该模块一方面对接各类文件管理服务,如媒体库、外置存储管理服务等,另一方面为系统应用提供一套统一的文件访问管理接口。其中,媒体库服务提供本地设备、分布式设备等公共文件访问服务;外置存储管理服务可以提供共享盘、U盘、SD卡等设备的公共文件访问服务。 + +>![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +>- 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +>- 本模块接口为系统接口,三方应用不支持调用,当前只支持filepicker、文件管理器调用。 + +## 导入模块 + +```js +import fileAccess from '@ohos.data.fileAccess'; +``` + +## fileAccess.getFileAccessAbilityInfo + +getFileAccessAbilityInfo( ) : Promise<Array<Want>> + +以异步方法获取系统内extension配置为fileAcesss类型的所有Want信息。使用Promise异步回调。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + +无 + +**返回值:** + + | 类型 | 说明 | + | --- | -- | + | Promise<Array<Want>> | 表示当前系统配置fileAccess的所有文件管理类服务 | + +**示例:** + + ```js + async getFileAccessAbilityInfo() { + let wantInfos = []; + try { + wantInfos = await fileAccess.getFileAccessAbilityInfo(); + console.log("getFileAccessAbilityInfo data " + JSON.stringify(wantInfos)); + } catch (error) { + console.error("getFileAccessAbilityInfo failed, error " + error); + } + } + ``` + +## fileAccess.createFileAccessHelper + +createFileAccessHelper(context: Context, wants: Array<Want>) : FileAccessHelper + +以同步方法创建连接指定wants的helper对象。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | --- | -- | + | context | Context | 是 | 代表ability的上下文的能力 | + | wants | Array<Want> | 是 | Want是一种基本通信组件,主要用于服务拉起 | + +**返回值:** + + | 类型 | 说明 | + | --- | -- | + | FileAccessHelper | 提供文件访问和操作能力的helper对象 | + +**示例:** + + ```js + createFileAccessHelper() { + let fileAccesssHelper = null; + // wantInfo 从getFileAccessAbilityInfo()获取 + // 创建只连接媒体库服务的helper对象 + let wantInfo = { + "bundleName": "com.ohos.medialibrary.medialibrarydata", + "abilityName": "FileExtensionAbility", + } + try { + fileAccesssHelper = fileAccess.createFileAccessHelper(this.context, wantInfos); + if (!fileAccesssHelper) + console.error("createFileAccessHelper interface returns an undefined object"); + } catch (error) { + console.error("createFileAccessHelper failed, error " + error); + } + } + ``` + +## fileAccess.createFileAccessHelper + +createFileAccessHelper(context: Context) : FileAccessHelper + +以同步方法创建连接当前系统内所有文件管理服务的helper对象。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | --- | -- | + | context | Context | 是 | ability的上下文的能力 | + +**返回值:** + + | 类型 | 说明 | + | --- | -- | + | FileAccessHelper | 提供文件访问和操作的能力的helper对象 | + +**示例:** + + ```js + createFileAccessHelper() { + let fileAccesssHelperAllServer = null; + // 创建连接系统内所有配置fileAccess的文件管理类服务的helper对象 + try { + fileAccesssHelperAllServer = fileAccess.createFileAccessHelper(this.context); + if (!fileAccesssHelperAllServer) + console.error("createFileAccessHelper interface returns an undefined object"); + } catch (error) { + console.error("createFileAccessHelper failed, error " + error); + } + } + ``` + +## FileAccessHelper.getRoots + +getRoots( ) : Promise<RootIterator> + +以异步方法获取helper对象连接的文件管理服务类的设备根节点信息。使用Promise异步回调。 +该方法返回迭代器对象RootIterator,然后通过[next](#rootiteratornext)方法返回[RootInfo](#rootinfo)。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + +无 + +**返回值:** + + | 类型 | 说明 | + | --- | -- | + | Promise<RootIterator> | 根设备目录信息组成迭代器对象 | + +**示例:** + + ```js + async getRoots() { + let rootIterator = null; + let rootinfos = []; + let isDone = false; + try { + rootIterator = await fileAccesssHelper.getRoots(); + if (!rootIterator) { + console.error("getRoots interface returns an undefined object"); + return; + } + while (!isDone) { + let result = rootIterator.next(); + console.log("next result = " + JSON.stringify(result)); + isDone = result.done; + if (!isDone) + rootinfos.push(result.value); + } + } catch (error) { + console.error("getRoots failed, error " + error); + } + } + ``` + +## RootInfo.listfile + +listFile(filter?: Filter) : FileIterator + +以同步方法从某设备根节点开始,基于过滤器,获取第一级符合条件的文件(夹)信息的迭代器对象FileIterator,然后通过[next](#fileiteratornext)方法返回[FileInfo](#fileinfo)。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | -- | -- | + | filter | Filter | 否 | 过滤器对象 | + + +**返回值:** + + | 类型 | 说明 | + | --- | -- | + | FileIterator | 文件(夹)信息的迭代器对象FileIterator | + +**示例:** + + ```js + // rootinfos 从getRoots()获取 + // let filter = {suffix : [".txt", ".jpg", ".xlsx"]}; + let rootInfo = rootinfos[0]; + let fileInfos = []; + let isDone = false; + try { + let fileIterator = rootInfo.listFile(); + // 含过滤器实现的listFile + // let fileIterator = rootInfo.listFile(filter); + if (fileIterator) { + console.error("listFile interface returns an undefined object"); + return; + } + while (!isDone) { + let result = fileIterator.next(); + console.log("next result = " + JSON.stringify(result)); + isDone = result.done; + if (!isDone) + fileInfos.push(result.value); + } + } catch (error) { + console.log("listFile failed, error " + error); + } + ``` + +## RootInfo.scanFile + +scanFile(filter?: Filter) : FileIterator + +以同步方法从某设备根节点开始,基于过滤器,递归获取符合条件的文件信息的迭代器对象FileIterator,然后通过[next](#fileiteratornext)方法返回[FileInfo](#fileinfo)。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | -- | -- | + | filter | Filter | 否 | 过滤器对象 | + +**返回值:** + + | 类型 | 说明 | + | --- | -- | + | FileIterator | 文件信息的迭代器对象FileIterator | + +**示例:** + + ```js + // rootinfos 从 getRoots()获取 + // let filter = {suffix : [".txt", ".jpg", ".xlsx"]}; + let rootInfo = rootinfos[0]; + let fileInfos = []; + let isDone = false; + try { + let fileIterator = rootInfo.scanFile(); + // 含过滤器实现的scanFile + // let fileIterator = rootInfo.scanFile(filter); + if (fileIterator) { + console.error("scanFile interface returns undefined object"); + return; + } + while (!isDone) { + let result = fileIterator.next(); + console.log("next result = " + JSON.stringify(result)); + isDone = result.done; + if (!isDone) + fileInfos.push(result.value); + } + } catch (error) { + console.error("scanFile failed, error " + error); + } + ``` + +## FileInfo.listfile + +listFile(filter?: Filter) : FileIterator + +以同步方法从某个目录,基于过滤器,获取下一级符合条件的文件(夹)信息的迭代器对象FileIterator,然后通过[next](#fileiteratornext)方法返回[FileInfo](#fileinfo)。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | -- | -- | + | filter | Filter | 否 | 过滤器对象 | + +**返回值:** + + | 类型 | 说明 | + | --- | -- | + | FileIterator | 文件(夹)信息的迭代器对象FileIterator | + +**示例:** + + ```js + // fileInfoDir 表示某个目录信息 + // let filter = { suffix : [".txt", ".jpg", ".xlsx"] }; + let fileInfoDir = fileInfos[0]; + let subfileInfos = []; + let isDone = false; + try { + let fileIterator = fileInfoDir.listFile(); + // 含过滤器实现的listFile + // let fileIterator = rootInfo.listFile(filter); + if (fileIterator) { + console.error("listFile interface returns an undefined object"); + return; + } + while (!isDone) { + let result = fileIterator.next(); + console.log("next result = " + JSON.stringify(result)); + isDone = result.done; + if (!isDone) + subfileInfos.push(result.value); + } + } catch (error) { + console.error("listFile failed, error " + error); + } + ``` + +## FileInfo.scanfile + +scanFile(filter?: Filter) : FileIterator; + +以同步方法从某个目录,基于过滤器,递归获取符合条件的文件信息的迭代器对象FileIterator,然后通过[next](#fileiteratornext)方法返回[FileInfo](#fileinfo)。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | -- | -- | + | filter | Filter | 否 | 过滤器对象 | + + +**返回值:** + + | 类型 | 说明 | + | --- | -- | + | FileIterator | 文件信息的迭代器对象FileIterator | + +**示例:** + + ```js + // fileInfoDir 表示某个目录信息 + // let filter = {suffix : [".txt", ".jpg", ".xlsx"]}; + let fileInfoDir = fileInfos[0]; + let subfileInfos = []; + let isDone = false; + try { + let fileIterator = fileInfoDir.scanFile(); + // 含过滤器实现的scanFile + // let fileIterator = rootInfo.scanFile(filter); + if (fileIterator) { + console.error("scanFile interface returns an undefined object"); + return; + } + while (!isDone) { + let result = fileIterator.next(); + console.error("next result = " + JSON.stringify(result)); + isDone = result.done; + if (!isDone) + subfileInfos.push(result.value); + } + } catch (error) { + console.error("scanFile-filter failed, error " + error); + } + ``` + +## FileAccessHelper.createFile + +createFile(uri: string, displayName: string) : Promise<string> + +以异步方法创建文件到指定目录,返回新文件uri。使用Promise异步回调。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | --- | -- | + | uri | string | 是 | 表示需要创建文件的父目录的Uri | + | displayName | string | 是 | 待创建文件的名称,本地文件需要添加后缀,共享盘不要求| + +**返回值:** + +| 类型 | 说明 | +| --- | -- | +| Promise<string> | 新创建的文件的uri | + +**示例:** + + ```js + // 以共享盘uri为例 + let sourceUri = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon"; + let displayName = "file1" + let fileUri = null; + try { + fileUri = await fileAccessHelper.createFile(sourceUri, displayName) + if (!fileUri) { + console.error("createFile return undefined object"); + return; + } + console.log("createFile sucess, fileUri: " + JSON.stringify(fileUri)); + } catch (error) { + console.error("createFile failed, error " + error); + }; + ``` + +## FileAccessHelper.mkDir + +mkDir(parentUri: string, displayName: string) : Promise<string> + +以异步方法创建文件夹到指定目录,返回文件夹uri。使用Promise异步回调。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | --- | -- | + | parentUri | string | 是 | 表示需要创建文件夹的父目录的Uri | + | displayName | string | 是 | 待创建文件夹的名称| + +**返回值:** + +| 类型 | 说明 | +| --- | -- | +| Promise<string> | 新创建的文件夹的uri | + +**示例:** + + ```js + // 以共享盘uri为例 + let sourceUri = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon"; + let dirName = "dirTest" + let dirUri = null; + try { + dirUri = await fileAccessHelper.mkDir(sourceUri, displayName) + if (!dirUri) { + console.error("mkDir return undefined object"); + return; + } + console.log("mkDir sucess, fileUri: " + JSON.stringify(fileUri)); + } catch (error) { + console.error("mkDir failed, error " + error); + }; + ``` + +## FileAccessHelper.openFile + +openFile(uri: string, flags: [OPENFLAGS](#openflags)) : Promise<number> + +以异步方法打开文件,返回文件句柄。使用Promise异步回调。 + +**系统能力**:SystemCapability.FileManagement.UserFileService。 + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | --- | -- | + | uri | string | 是 | 待打开文件的uri | + | flags | OPENFLAGS | 文件打开的标志 | + +**返回值:** + +| 类型 | 说明 | +| --- | -- | +| Promise<number> | 文件句柄 | + +**示例:** + + ```js + // 以共享盘uri为例 + let targetUri = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/file1"; + try { + let fd = await fileAccessHelper.openFile(targetUri, OPENFLAGS.READ); + } cache (error) { + console.error("openFile failed, error " + error); + }; + ``` + +## FileAccessHelper.delete + +delete(uri: string) : Promise<number> + +以异步方法删除文件(夹),返回错误码。使用Promise异步回调。 + +**系统能力**:SystemCapability.FileManagement.UserFileService。 + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | --- | -- | + | uri | string | 是 | 待删除文件(夹)的uri | + +**返回值:** + +| 类型 | 说明 | +| --- | -- | +| Promise<number> | 删除操作的错误码 | + +**示例:** + + ```js + // 以共享盘uri为例 + let targetUri = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/file1"; + try { + let code = await fileAccessHelper.delete(targetUri); + if (code != 0) + console.error("delete failed, code " + code); + } cache (error) { + console.error("delete failed, error " + error); + }; + ``` + +## FileAccessHelper.move + +move(sourceFile: string, destFile: string) : Promise<string> + +以异步方法移动文件(夹),返回移动后文件(夹)的uri。使用Promise异步回调。 + +**系统能力**:SystemCapability.FileManagement.UserFileService。 + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | --- | -- | + | sourceFile | string | 是 | 待移动的源文件(夹)的uri | + | destFile | string | 是 | 目标文件夹的uri | + +**返回值:** + +| 类型 | 说明 | +| ----- | ------ | +| Promise<string> | 新路径下的文件(夹)的uri | + +**示例:** + + ```js + // 以共享盘uri为例 + let sourceFile = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/file1"; + let destFile = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/dirTest"; + try { + let fileUri = await fileAccessHelper.move(sourceFile, destFile); + console.log("move sucess, fileUri: " + JSON.stringify(fileUri)); + } cache (error) { + console.error("move failed, error " + error); + }; + ``` + +## FileAccessHelper.rename + +rename(uri: string, displayName: string) : Promise<string> + +以异步方法重命名文件(夹),返回重命名后的文件(夹)的Uri。使用Promise异步回调。 + +**系统能力**:SystemCapability.FileManagement.UserFileService。 + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | --- | -- | + | uri | string | 是 | 源文件(夹)的uri | + | displayName | string | 是 | 文件(夹)名,支持带后缀 | + +**返回值:** + +| 类型 | 说明 | +| --- | -- | +| Promise<string> | 重命名后的文件(夹)的uri | + +**示例:** + + ```js + // 以共享盘uri为例 + let sourceDir = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/dirTest"; + try { + let DestDir = await fileAccessHelper.rename(sourceDir, "testDir"); + console.log("rename sucess, DestDir: " + JSON.stringify(DestDir)); + } cache (error) { + console.error("rename failed, error " + error); + }; + ``` + +## FileAccessHelper.access + +access(sourceFileUri: string) : Promise<boolean> + +以异步方法判断文件(夹)是否存在。使用Promise异步回调。 + +**系统能力**:SystemCapability.FileManagement.UserFileService。 + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --- | --- | --- | -- | + | sourceFileUri | string | 是 | 文件(夹)的uri | + +**返回值:** + +| 类型 | 说明 | +| --- | -- | +| Promise<boolean> | 文件(夹)是否存在 | + +**示例:** + + ```js + // 以共享盘uri为例 + let sourceDir = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/dirTest"; + try { + let existJudgment = await fileAccessHelper.access(sourceDir); + if (existJudgment) + console.log("sourceDir exists"); + else + console.log("sourceDir does not exist"); + } cache (error) { + console.error("rename failed, error " + error); + }; + ``` + +## RootIterator.next + +next( ) : { value: RootInfo, done: boolean } + +RootIterator表示设备根目录的迭代器对象,可以通过next同步方法获取下一级设备根目录。 + +**系统能力**:SystemCapability.FileManagement.UserFileService。 + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + +无 + +**返回值:** + +| 类型 | 说明 | +| --- | -- | +| {value: RootInfo, done: boolean} | 通过next遍历文件夹,直到done返回true结束;value字段返回rootInfo。| + +## FileIterator.next + +next( ) : { value: FileInfo, done: boolean } + +FileIterator表示文件夹的迭代器对象,可以通过next同步方法获取下一级文件(夹)信息。 + +**系统能力**:SystemCapability.FileManagement.UserFileService。 + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + +无 + +**返回值:** + +| 类型 | 说明 | +| --- | -- | +| {value: FileInfo, done: boolean} | 通过next遍历文件夹,直到done返回true结束;value字段返回fileInfo。| + +## RootInfo + +表示设备的根属性信息和接口能力。 + +**系统能力**:SystemCapability.FileManagement.UserFileService。 + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +### 属性 + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | -------- | ------ | -------- | +| deviceType | number | 是 | 否 |设备类型 | +| uri | string | 是 | 否 | 设备根目录Uri | +| displayName | string | 是 | 否 | 设备名称 | +| deviceFlags | number | 是 | 否 | 设备支持的能力 | + +## FileInfo + +表示文件(夹)属性信息和接口能力。 + +**系统能力**:SystemCapability.FileManagement.UserFileService。 + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +### 属性 + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | -------- | ------ | -------- | +| uri | string | 是 | 否 | 文件(夹)的uri | +| fileName | string | 是 | 否 | 文件(夹)的名称 | +| mode | number | 是 | 否 | 文件(夹)的权限信息 | +| size | number | 是 | 否 | 文件(夹)的大小 | +| mtime | number | 是 | 否 | 文件(夹)的修改时间 | +| mimeType | string | 是 | 否 | 文件(夹)的媒体资源类型 | + +## OPENFLAGS + +目前支持的文件打开的标志位。 + +**系统能力:** SystemCapability.FileManagement.UserFileService + +| 名称 | 值 | 说明 | +| ----- | ------ | ------ | +| READ | 0o0 | 读模式。 | +| WRITE | 0o1 | 写模式。 | +| WRITE_READ | 0o2 | 读写模式。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md b/zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..b0058cb086c97a3749b8497a91ce290d2f305ea3 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md @@ -0,0 +1,58 @@ +# 公共文件访问与管理 + +该模块提供公共文件访问和管理模块中RootInfo与FileInfo中部分属性值的定义。 + +>![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +>- 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +>- 本模块接口为系统接口。 + +## 导入模块 + +```js +import fileExtensionInfo from '@ohos.fileExtensionInfo'; +``` + +## fileExtensionInfo.DeviceType + +组成RootInfo中的deviceType字段,表明此设备的类型。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +| 名称 | 值 | 说明 | +| ----- | ------ | ------ | +| DEVICE_LOCAL_DISK | 1 | 本地c,d...盘。 | +| DEVICE_SHARED_DISK | 2 | 多用户共享盘。 | +| DEVICE_SHARED_TERMINAL | 3 | 分布式网络终端设备。 | +| DEVICE_NETWORK_NEIGHBORHOODS | 4 | 网络邻居设备。 | +| DEVICE_EXTERNAL_MTP | 5 | MTP设备。 | +| DEVICE_EXTERNAL_USB | 6 | USB设备。 | +| DEVICE_EXTERNAL_CLOUD | 7 | 云盘设备。 | + +## fileExtensionInfo.DeviceFlag + +组成RootInfo中的deviceFlags字段,通过与运算判断是否具备某种能力。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +### 属性 + + | 名称 | 类型 | 值 | 可读 | 可写 | 说明 | + | ------ | ------ | ---- | ---- | ---- | -------- | + | SUPPORTS_READ | number | 0b1 | 是 | 否 | 支持读 | + | SUPPORTS_WRITE | number | 0b10 | 是 | 否 | 支持写 | + +## fileExtensionInfo.DocumentFlag + +组成FileInfo中的mode字段,通过与运算判断是否具备某种能力。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +### 属性 + + | 名称 | 类型 | 值 | 可读 | 可写 | 说明 | + | ------ | ------ | ---- | ---- | ---- | -------- | + | REPRESENTS_FILE | number | 0b1 | 是 | 否 | 代表文件 | + | REPRESENTS_DIR | number | 0b10 | 是 | 否 | 代表目录 | + | SUPPORTS_READ | number | 0b100 | 是 | 否 | 支持读 | + | SUPPORTS_WRITE | number | 0b1000 | 是 | 否 | 支持写 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-huks.md b/zh-cn/application-dev/reference/apis/js-apis-huks.md index 7421c7fb92e6ac8a4c26b808c18516c975886579..6e5a68a050a6095fbe08600ad2065957bf715343 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-huks.md +++ b/zh-cn/application-dev/reference/apis/js-apis-huks.md @@ -12,7 +12,7 @@ HUKS所管理的密钥可以由应用导入或者由应用调用HUKS接口生成 ```js import huks from '@ohos.security.huks' ``` -## HuksErrorCode +## HuksErrorCode(deprecated) 表示错误码的枚举。 @@ -95,6 +95,113 @@ import huks from '@ohos.security.huks' | HUKS_ERROR_INTERNAL_ERROR | -999 |表示内部错误。| | HUKS_ERROR_UNKNOWN_ERROR | -1000 |表示未知错误。| +## HuksExceptionErrCode9+ + +表示错误码的枚举以及对应的错误信息, 错误码表示错误类型,错误信息展示错误详情。 + +**系统能力**:SystemCapability.Security.Huks + +| 类型 | 名称 | 说明 | 错误码 | +| ------------------------- | ---------------------------------------------- | --------------------------- | -------- | +| 权限 | HUKS_ERR_CODE_PERMISSION_FAIL | 权限错误导致失败。 | 201 | +| 参数 | HUKS_ERR_CODE_ILLEGAL_ARGUMENT | 参数错误导致失败。 | 401 | +| 不支持的API | HUKS_ERR_CODE_NOT_SUPPORTED_API | 不支持的API。 | 801 | +| 不支持的功能/特性 | HUKS_ERR_CODE_FEATURE_NOT_SUPPORTED | 不支持的功能/特性。 | 12000001 | +| 缺少密钥算法参数 | HUKS_ERR_CODE_MISSING_CRYPTO_ALG_ARGUMENT | 缺少密钥算法参数。 | 12000002 | +| 无效密钥算法参数 | HUKS_ERR_CODE_INVALID_CRYPTO_ALG_ARGUMENT | 无效密钥算法参数。 | 12000003 | +| 文件 | HUKS_ERR_CODE_FILE_OPERATION_FAIL | 文件操作失败。 | 12000004 | +| 通信 | HUKS_ERR_CODE_COMMUNICATION_FAIL | 通信失败。 | 12000005 | +| 算法库操作失败 | HUKS_ERR_CODE_CRYPTO_FAIL | 算法库操作失败。 | 12000006 | +| 密钥访问失败-密钥访问失效 | HUKS_ERR_CODE_KEY_AUTH_PERMANENTLY_INVALIDATED | 密钥访问失败-密钥访问失效。 | 12000007 | +| 密钥访问失败-密钥认证失败 | HUKS_ERR_CODE_KEY_AUTH_VERIFY_FAILED | 密钥访问失败-密钥认证失败。 | 12000008 | +| 密钥访问失败-密钥访问超时 | HUKS_ERR_CODE_KEY_AUTH_TIME_OUT | 密钥访问失败-密钥访问超时。 | 12000009 | +| 密钥操作会话数已达上限 | HUKS_ERR_CODE_SESSION_LIMIT | 密钥操作会话数已达上限。 | 12000010 | +| 目标对象不存在 | HUKS_ERR_CODE_ITEM_NOT_EXIST | 目标对象不存在。 | 12000011 | +| 外部错误 | HUKS_ERR_CODE_EXTERNAL_ERROR | 外部错误。 | 12000012 | +| 缺失所需凭据 | HUKS_ERR_CODE_CREDENTIAL_NOT_EXIST | 缺失所需凭据。 | 12000013 | +| 内存不足 | HUKS_ERR_CODE_INSUFFICIENT_MEMORY | 内存不足。 | 12000014 | +| 调用其他系统服务失败 | HUKS_ERR_CODE_CALL_SERVICE_FAILED | 调用其他系统服务失败。 | 12000015 | + +错误信息: + +| 类型 | 错误码 | ERROR MESSAGE | 错误信息 | +| ------------------------- | -------- | ------------------------------------------------------------ | ----------------------------------------- | +| 权限 | 201 | Check permission failed. User should request permission first. | 表示没有许可。 | +| 参数 | 401 | Argument is invalid. User should make sure using the correct value. | 表示无效的参数。 | +| 参数 | 401 | Input data is not sufficient. | 表示数据不足。 | +| 参数 | 401 | The buffer is too small. | 表示缓冲区太小。 | +| 参数 | 401 | Parameter is null. User should make sure using the correct value. | 表示空指针。 | +| 参数 | 401 | Public key is invalid. | 表示无效的公钥。 | +| 参数 | 401 | Key info is invalid. | 表示无效的密钥信息。 | +| 参数 | 401 | Queried param does not exist. | 表示参数不存在。 | +| 参数 | 401 | Root key material already exists. | 表示存在新的根密钥材料。 | +| 参数 | 401 | The format of wrapped key data is invalid. | 表示导入加密密钥时,密钥格式错误。 | +| 参数 | 401 | Check get auth type failed. User should add auth type in paramset. | 表示获取身份验证类型失败。 | +| 参数 | 401 | Check get challenge type failed. User should add challenge type in paramset. | 表示获取挑战值类型失败。 | +| 参数 | 401 | Check get access type failed. User should add access type in paramset. | 表示获取访问类型失败。 | +| 参数 | 401 | Check get auth token failed. User should add auth token in paramset. | 表示获取身份验证令牌失败。 | +| 参数 | 401 | Time out param is invalid. User should make sure using the correct value. | 表示超时参数无效 | +| 参数 | 401 | Auth type param is invalid. User should make sure using the correct value. | 表示身份验证类型参数无效。 | +| 参数 | 401 | Challenge type param is invalid. User should make sure using the correct value. | 表示挑战值类型参数无效。 | +| 参数 | 401 | Access type param is invalid. User should make sure using the correct value. | 表示访问类型参数无效。 | +| 参数 | 401 | Auth token param is invalid. User should make sure using the correct value. | 表示身份验证令牌参数无效。 | +| 参数 | 401 | Secure sign type param is invalid. User should make sure using the correct value. | 表示安全符号类型参数无效。 | +| 不支持的API | 801 | This api is not supported in current device. | 不支持的API。 | +| 不支持的功能/特性 | 12000001 | Feature is not support. Please make sure using the correct combination of params. | 功能特性不支持,请输入正确的参数组合。 | +| 不支持的功能/特性 | 12000001 | This user auth type is not supported in current device. | 表示不支持当前用户认证类型的访问控制。 | +| 缺少密钥算法参数 | 12000002 | Check get algorithm failed. User should add algorithm in paramset. | 表示检查获取 ALG 失败。 | +| 缺少密钥算法参数 | 12000002 | Check get key size failed. User should add key size in paramset. | 表示检查获取密钥大小失败。 | +| 缺少密钥算法参数 | 12000002 | Check get padding failed. User should add padding in paramset. | 表示检查获取填充失败。 | +| 缺少密钥算法参数 | 12000002 | Check get purpose failed. User should add purpose in paramset. | 表示检查获取目的失败。 | +| 缺少密钥算法参数 | 12000002 | Check get digest failed. User should add digest in paramset. | 表示检查获取摘要失败。 | +| 缺少密钥算法参数 | 12000002 | Check get mode failed. User should add mode in paramset. | 表示检查获取模式失败。 | +| 缺少密钥算法参数 | 12000002 | Check get nonce failed. User should add nonce in paramset. | 表示检查获取随机数失败。 | +| 缺少密钥算法参数 | 12000002 | Check get aad failed. User should add AAD in paramset. | 表示检查获取 AAD 失败。 | +| 缺少密钥算法参数 | 12000002 | Check get iv failed. User should add iv in paramset. | 表示检查 GET IV 失败。 | +| 缺少密钥算法参数 | 12000002 | Check get aead failed. User should add aead in paramset. | 表示检查获取 AE 标记失败。 | +| 缺少密钥算法参数 | 12000002 | Check get salt failed. User should add salt in paramset. | 表示检查获取SALT失败。 | +| 缺少密钥算法参数 | 12000002 | Check get iteration failed. User should add iteration in paramset. | 表示检查获取迭代失败。 | +| 无效密钥算法参数 | 12000003 | Algorithm param is invalid. User should make sure using the correct value. | 表示无效的算法。 | +| 无效密钥算法参数 | 12000003 | Key size param is invalid. User should make sure using the correct value. | 表示无效的密钥大小。 | +| 无效密钥算法参数 | 12000003 | Padding param is invalid. User should make sure using the correct value. | 表示无效的填充。 | +| 无效密钥算法参数 | 12000003 | Purpose param is invalid. User should make sure using the correct value. | 表示无效的目的。 | +| 无效密钥算法参数 | 12000003 | Mode param is invalid. User should make sure using the correct value. | 表示无效模式。 | +| 无效密钥算法参数 | 12000003 | Digest param is invalid. User should make sure using the correct value. | 表示无效的摘要。 | +| 无效密钥算法参数 | 12000003 | Signture size param is invalid. User should make sure using the correct value. | 表示签名大小无效。 | +| 无效密钥算法参数 | 12000003 | IV param is invalid. User should make sure using the correct value. | 表示无效的 IV。 | +| 无效密钥算法参数 | 12000003 | AAD param is invalid. User should make sure using the correct value. | 表示无效的 AAD。 | +| 无效密钥算法参数 | 12000003 | Nonce param is invalid. User should make sure using the correct value. | 表示无效的随机数。 | +| 无效密钥算法参数 | 12000003 | AE param is invalid. User should make sure using the correct value. | 表示无效的 AE 标签。 | +| 无效密钥算法参数 | 12000003 | Salt param is invalid. User should make sure using the correct value. | 表示无效SALT。 | +| 无效密钥算法参数 | 12000003 | Iteration param is invalid. User should make sure using the correct value. | 表示无效的迭代。 | +| 无效密钥算法参数 | 12000003 | Purpose param is invalid. User should make sure using the correct value. | 表示导入加密密钥时,密钥用途错误。 | +| 文件 | 12000004 | Storage space is insufficient. | 表示存储故障。 | +| 文件 | 12000004 | The value of file size is unexpected. | 表示文件大小失败。 | +| 文件 | 12000004 | Read file failed. | 表示读取文件失败。 | +| 文件 | 12000004 | Write file failed. | 表示写文件失败。 | +| 文件 | 12000004 | Remove file failed. | 表示删除文件失败。 | +| 文件 | 12000004 | Open file failed. | 表示打开文件失败。 | +| 文件 | 12000004 | Close file failed. | 表示关闭文件失败。 | +| 文件 | 12000004 | Make directory failed. | 表示创建目录失败。 | +| 文件 | 12000004 | Read key from file failed, for key fi哦呜le is invalid. | 表示无效的密钥文件。 | +| 通信 | 12000005 | Get message from IPC failed. | 表示IPC 信息失败。 | +| 通信 | 12000005 | IPC communication time out. | 表示通讯超时。 | +| 通信 | 12000005 | IPC init failed. | 表示IPC 初始化失败。 | +| 通信 | 12000005 | IPC async call failed. | IPC异步调用失败。 | +| 算法库操作失败 | 12000006 | Errors occured in crypto engine. | 表示CRYPTO ENGINE错误。 | +| 密钥访问失败-密钥访问失效 | 12000007 | This credential is already invalidated permanently. | 密钥访问失败-密钥访问失效 | +| 密钥访问失败-密钥认证失败 | 12000008 | Verify authtoken failed. | 密钥访问失败-密钥认证失败 | +| 密钥访问失败-密钥访问超时 | 12000009 | This authtoken is already timeout. | 密钥访问失败-密钥访问超时 | +| 密钥操作会话数已达上限 | 12000010 | The number of sessions has reached limit. | 密钥操作会话数已达上限。 | +| 目标对象不存在 | 12000011 | Queried entity does not exist. | 表示不存在。 | +| 外部错误 | 12000012 | General error. | 一般错误。 | +| 外部错误 | 12000012 | System error. | 系统错误。 | +| 外部错误 | 12000012 | System external error. | 表示系统外部错误。 | +| 缺失所需凭据 | 12000013 | Queried credential does not exist. | 查询的凭据不存在。 | +| 内存不足 | 12000014 | Memory is insufficient. | 表示内存不足。 | +| 内存不足 | 12000014 | Malloc failed. | 表示MALLOC 失败。 | +| 调用其他系统服务失败 | 12000015 | Calling useriam to get sec info failed. | 访问useriam获取当前用户安全属性信息失败。 | +| 调用其他系统服务失败 | 12000015 | Calling useriam to get auth info failed. | 访问useriam获取当前用户认证信息失败。 | ## HuksKeyPurpose @@ -448,12 +555,14 @@ import huks from '@ohos.security.huks' | HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20002 | 预留。 | | HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20003 | 预留。 | -## huks.generateKey +## huks.generateKey(deprecated) generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void 生成密钥,使用Callback回调异步返回结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.generateKeyItem9+](#huksgeneratekeyitem9)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -498,12 +607,14 @@ var options = { huks.generateKey(keyAlias, options, function (err, data){}); ``` -## huks.generateKey +## huks.generateKey(deprecated) generateKey(keyAlias: string, options: HuksOptions) : Promise\ 生成密钥,使用Promise方式异步返回结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.generateKeyItem9+](#huksgeneratekeyitem9-1)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -549,12 +660,125 @@ var options = { var result = huks.generateKey(keyAlias, options); ``` -## huks.deleteKey +## huks.generateKeyItem9+ + +generateKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void + +生成密钥,使用Callback回调异步返回结果。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------------------------------------- | +| keyAlias | string | 是 | 别名。 | +| options | [HuksOptions](#huksoptions) | 是 | 用于存放生成key所需TAG。 | +| callback | AsyncCallback\ | 是 | 不返回err值时表示接口使用成功,其他时为错误。 | + +**示例:** + +```js +/* 以生成ECC256密钥为例 */ +var keyAlias = 'keyAlias'; +var properties = new Array(); +properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_ECC +}; +properties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256 +}; +properties[2] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY +}; +properties[3] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 +}; +var options = { + properties: properties +}; +try { + huks.generateKeyItem(keyAlias, options, function (error, data) { + if (error) { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: generateKeyItem key success`); + } + }); +} catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` + +## huks.generateKeyItem9+ + +generateKeyItem(keyAlias: string, options: HuksOptions) : Promise\ + +生成密钥,使用Promise方式异步返回结果。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------ | +| keyAlias | string | 是 | 密钥别名。 | +| options | [HuksOptions](#huksoptions) | 是 | 用于存放生成key所需TAG。 | + +**示例:** + +```js +/* 以生成ECC256密钥为例 */ +var keyAlias = 'keyAlias'; +var properties = new Array(); +properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_ECC +}; +properties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256 +}; +properties[2] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY +}; +properties[3] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 +}; +var options = { + properties: properties +}; +try { + huks.generateKeyItem(keyAlias, options) + .then((data) => { + console.info(`promise: generateKeyItem success`); + }) + .catch(error => { + console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); +} catch (error) { + console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` + +## huks.deleteKey(deprecated) deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void 删除密钥,使用Callback回调异步返回结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.deleteKeyItem9+](#huksdeletekeyitem9)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -576,12 +800,14 @@ var emptyOptions = { huks.deleteKey(keyAlias, emptyOptions, function (err, data) {}); ``` -## huks.deleteKey +## huks.deleteKey(deprecated) deleteKey(keyAlias: string, options: HuksOptions) : Promise\ 删除密钥,使用Promise方式异步返回结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.deleteKeyItem9+](#huksdeletekeyitem9-1)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -608,6 +834,79 @@ var emptyOptions = { var result = huks.deleteKey(keyAlias, emptyOptions); ``` +## huks.deleteKeyItem9+ + +deleteKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void + +删除密钥,使用Callback回调异步返回结果。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------------------------------------- | +| keyAlias | string | 是 | 密钥别名,应为生成key时传入的别名。 | +| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | +| callback | AsyncCallback\ | 是 | 不返回err值时表示接口使用成功,其他时为错误。 | + +**示例:** + +```js +/* 此处options选择emptyOptions传空 */ +var keyAlias = 'keyAlias'; +var emptyOptions = { + properties: [] +}; +try { + huks.deleteKeyItem(keyAlias, emptyOptions, function (error, data) { + if (error) { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: deleteKeyItem key success`); + } + }); +} catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` + +## huks.deleteKeyItem9+ + +deleteKeyItem(keyAlias: string, options: HuksOptions) : Promise\ + +删除密钥,使用Promise方式异步返回结果。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ----------------------------------- | +| keyAlias | string | 是 | 密钥别名,应为生成key时传入的别名。 | +| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | + +**示例:** + +```js +/* 此处options选择emptyOptions传空 */ +var keyAlias = 'keyAlias'; +var emptyOptions = { + properties: [] +}; +try { + huks.deleteKeyItem(keyAlias, emptyOptions) + .then ((data) => { + console.info(`promise: deleteKeyItem key success`); + }) + .catch(error => { + console.error(`promise: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); +} catch (error) { + console.error(`promise: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` + ## huks.getSdkVersion getSdkVersion(options: HuksOptions) : string @@ -638,12 +937,14 @@ var emptyOptions = { var result = huks.getSdkVersion(emptyOptions); ``` -## huks.importKey +## huks.importKey(deprecated) importKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void 导入明文密钥,使用Callback方式回调异步返回结果 。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.importKeyItem9+](#huksimportkeyitem9)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -696,12 +997,14 @@ var options = { huks.importKey(keyAlias, options, function (err, data){}); ``` -## huks.importKey +## huks.importKey(deprecated) importKey(keyAlias: string, options: HuksOptions) : Promise\ 导入明文密钥,使用Promise方式异步返回结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.importKeyItem9+](#huksimportkeyitem9-1)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -761,242 +1064,395 @@ var huksoptions = { var result = huks.importKey(keyAlias, huksoptions); ``` -## huks.attestkey9+ +## huks.importKeyItem9+ -attestKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void +importKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void -获取密钥证书,使用Callback方式回调异步返回结果 。 +导入明文密钥,使用Callback方式回调异步返回结果 。 **系统能力**:SystemCapability.Security.Huks **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ----------------------------------------- | ---- | -------------------------------------------------- | -| keyAlias | string | 是 | 密钥别名,存放待获取证书密钥的别名。 | -| options | [HuksOptions](#huksoptions) | 是 | 用于获取证书时指定所需参数与数据。 | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | 返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------------------------------------- | +| keyAlias | string | 是 | 密钥别名。 | +| options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的密钥。 | +| callback | AsyncCallback\ | 是 | 不返回err值时表示接口使用成功,其他时为错误。 | **示例:** ```js -let securityLevel = stringToUint8Array('sec_level'); -let challenge = stringToUint8Array('challenge_data'); -let versionInfo = stringToUint8Array('version_info'); -let keyAliasString = "key attest"; - -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; -} - -function printLog(...data) { - console.error(data.toString()); -} - -async function generateKey(alias) { - let properties = new Array(); - properties[0] = { +/* 以导入AES256密钥为例 */ +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_RSA - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_PERSISTENT - }; - properties[2] = { + value: huks.HuksKeyAlg.HUKS_ALG_AES +}; +properties[1] = { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }; - properties[3] = { + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 +}; +properties[2] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }; - properties[5] = { + 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_PSS - }; - properties[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, - value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT - }; - properties[7] = { + value:huks.HuksKeyPadding.HUKS_PADDING_PKCS7 +}; +properties[4] = { tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, value: huks.HuksCipherMode.HUKS_MODE_ECB - }; - let options = { - properties: properties - }; - - await huks.generateKey(alias, options).then(async (data) => { - console.error(`generateKey data ${JSON.stringify(data)}`); - }).catch((err) => { - console.error(`generateKey err: " + ${JSON.stringify(err)}`); - });; -} - -async function attestKey() { - let aliasString = keyAliasString; - let aliasUint8 = stringToUint8Array(aliasString); - let properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, - value: securityLevel - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, - value: challenge - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, - value: versionInfo - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, - value: aliasUint8 - }; - let options = { - properties: properties - }; - await generateKey(aliasString); - huks.attestKey(aliasString, options, function (err, data) { - printLog(`key attest result : ${JSON.stringify(data)}`); - }); +}; +var options = { + properties: properties, + inData: plainTextSize32 +}; +try { + huks.importKeyItem(keyAlias, options, function (error, data) { + if (error) { + console.error(`callback: importKeyItem failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: importKeyItem success`); + } + }); +} catch (error) { + console.error(`callback: importKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); } ``` -## huks.attestkey9+ +## huks.importKeyItem9+ -attestKey(keyAlias: string, options: HuksOptions) : Promise\ +importKeyItem(keyAlias: string, options: HuksOptions) : Promise\ -获取密钥证书,使用Promise方式异步返回结果 。 +导入明文密钥,使用Promise方式异步返回结果。 **系统能力**:SystemCapability.Security.Huks **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ----------------------------------------- | ---- | -------------------------------------------------- | -| keyAlias | string | 是 | 密钥别名,存放待获取证书密钥的别名。 | -| options | [HuksOptions](#huksoptions) | 是 | 用于获取证书时指定所需参数与数据。 | - -**返回值:** - -| 类型 | 说明 | -| ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | 返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ----------------------------------- | +| keyAlias | string | 是 | 密钥别名。 | +| options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的密钥。 | **示例:** ```js -let securityLevel = stringToUint8Array('sec_level'); -let challenge = stringToUint8Array('challenge_data'); -let versionInfo = stringToUint8Array('version_info'); -let keyAliasString = "key attest"; - -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; -} +/* 以导入AES128为例 */ +var plainTextSize32 = makeRandomArr(32); -function printLog(...data) { - console.error(data.toString()); -} +function makeRandomArr(size) { + var arr = new Uint8Array(size); + for (var i = 0; i < size; i++) { + arr[i] = Math.floor(Math.random() * 10); + } + return arr; +}; -async function generateKey(alias) { - let properties = new Array(); - properties[0] = { +/*第一步:生成密钥*/ +var keyAlias = 'keyAlias'; +var properties = new Array(); +properties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_PERSISTENT - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 - }; - properties[3] = { + value: huks.HuksKeyAlg.HUKS_ALG_AES +}; +properties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 +}; +properties[2] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }; - properties[5] = { + 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_PSS - }; - properties[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, - value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT - }; - properties[7] = { + value:huks.HuksKeyPadding.HUKS_PADDING_PKCS7 +}; +properties[4] = { tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, value: huks.HuksCipherMode.HUKS_MODE_ECB - }; - let options = { - properties: properties - }; +}; +var huksoptions = { + properties: properties, + inData: plainTextSize32 +}; +try { + huks.importKeyItem(keyAlias, huksoptions) + .then ((data) => { + console.info(`promise: importKeyItem success`); + }) + .catch(error => { + console.error(`promise: importKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); +} catch (error) { + console.error(`promise: importKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` - await huks.generateKey(alias, options).then(async (data) => { - console.error(`generateKey data ${JSON.stringify(data)}`); - }).catch((err) => { - console.error(`generateKey err: " + ${JSON.stringify(err)}`); - });; +## huks.attestKeyItem9+ + +attestKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void + +获取密钥证书,使用Callback方式回调异步返回结果 。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | --------------------------------------------- | +| keyAlias | string | 是 | 密钥别名,存放待获取证书密钥的别名。 | +| options | [HuksOptions](#huksoptions) | 是 | 用于获取证书时指定所需参数与数据。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | 是 | 不返回err值时表示接口使用成功,其他时为错误。 | + +**示例:** + +```js +let securityLevel = stringToUint8Array('sec_level'); +let challenge = stringToUint8Array('challenge_data'); +let versionInfo = stringToUint8Array('version_info'); +let keyAliasString = "key attest"; + +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(alias) { + let properties = new Array(); + properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }; + properties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_PERSISTENT + }; + properties[2] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }; + properties[3] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }; + properties[4] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }; + properties[5] = { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PSS + }; + properties[6] = { + tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, + value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT + }; + properties[7] = { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB + }; + let options = { + properties: properties + }; + + try { + huks.generateKeyItem(alias, options, function (error, data) { + if (error) { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: generateKeyItem success`); + } + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } } async function attestKey() { - let aliasString = keyAliasString; - let aliasUint8 = stringToUint8Array(aliasString); - let properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, - value: securityLevel - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, - value: challenge - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, - value: versionInfo - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, - value: aliasUint8 - }; - let options = { - properties: properties - }; - await generateKey(aliasString); - huks.attestKey(aliasString, options) - .then((data) => { - console.log(`test attestKey data: ${JSON.stringify(data)}`); - }) - .catch((err) => { - console.log('test attestKey information: ' + JSON.stringify(err)); - }); + let aliasString = keyAliasString; + let aliasUint8 = stringToUint8Array(aliasString); + let properties = new Array(); + properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, + value: securityLevel + }; + properties[1] = { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, + value: challenge + }; + properties[2] = { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, + value: versionInfo + }; + properties[3] = { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, + value: aliasUint8 + }; + let options = { + properties: properties + }; + await generateKey(aliasString); + try { + huks.attestKeyItem(aliasString, options, function (error, data) { + if (error) { + console.error(`callback: attestKeyItem failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: attestKeyItem success`); + } + }); + } catch (error) { + console.error(`callback: attestKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } } ``` -## huks.importWrappedKey9+ +## huks.attestKeyItem9+ -importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void +attestKeyItem(keyAlias: string, options: HuksOptions) : Promise\ + +获取密钥证书,使用Promise方式异步返回结果 。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------ | +| keyAlias | string | 是 | 密钥别名,存放待获取证书密钥的别名。 | +| options | [HuksOptions](#huksoptions) | 是 | 用于获取证书时指定所需参数与数据。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------------- | --------------------------------------------- | +| Promise<[HuksReturnResult](#huksreturnresult)> | 不返回err值时表示接口使用成功,其他时为错误。 | + +**示例:** + +```js +let securityLevel = stringToUint8Array('sec_level'); +let challenge = stringToUint8Array('challenge_data'); +let versionInfo = stringToUint8Array('version_info'); +let keyAliasString = "key attest"; + +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(alias) { + let properties = new Array(); + properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_RSA + }; + properties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_PERSISTENT + }; + properties[2] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }; + properties[3] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY + }; + properties[4] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }; + properties[5] = { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PSS + }; + properties[6] = { + tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, + value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT + }; + properties[7] = { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB + }; + let options = { + properties: properties + }; + + try { + await huks.generateKeyItem(alias, options) + .then((data) => { + console.info(`promise: generateKeyItem success`); + }) + .catch(error => { + console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function attestKey() { + let aliasString = keyAliasString; + let aliasUint8 = stringToUint8Array(aliasString); + let properties = new Array(); + properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, + value: securityLevel + }; + properties[1] = { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, + value: challenge + }; + properties[2] = { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, + value: versionInfo + }; + properties[3] = { + tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, + value: aliasUint8 + }; + let options = { + properties: properties + }; + await generateKey(aliasString); + try { + await huks.attestKeyItem(aliasString, options) + .then ((data) => { + console.info(`promise: attestKeyItem success`); + }) + .catch(error => { + console.error(`promise: attestKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: attestKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} +``` + +## huks.importWrappedKeyItem9+ + +importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void 导入加密密钥,使用Callback方式回调异步返回结果 。 @@ -1004,98 +1460,118 @@ importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOption **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ----------------------------------------- | ---- | -------------------------------------------------- | -| keyAlias | string | 是 | 密钥别名,存放待导入密钥的别名。 | -| wrappingKeyAlias | string | 是 | 密钥别名,对应密钥用于解密加密的密钥数据。 | -| options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的加密的密钥数据。 | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | 返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | --------------------------- | ---- | --------------------------------------------- | +| keyAlias | string | 是 | 密钥别名,存放待导入密钥的别名。 | +| wrappingKeyAlias | string | 是 | 密钥别名,对应密钥用于解密加密的密钥数据。 | +| options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的加密的密钥数据。 | +| callback | AsyncCallback\ | 是 | 不返回err值时表示接口使用成功,其他时为错误。 | **示例:** ```js +import huks from '@ohos.security.huks'; + var exportWrappingKey; var alias1 = "importAlias"; var alias2 = "wrappingKeyAlias"; async function TestGenFunc(alias, options) { - await genKey(alias, options) - .then((data) => { - console.log(`test genKey data: ${JSON.stringify(data)}`); - }) - .catch((err) => { - console.log('test genKey err information: ' + JSON.stringify(err)); - }); + try { + await genKey(alias, options) + .then((data) => { + console.info(`callback: generateKeyItem success`); + }) + .catch(error => { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } } function genKey(alias, options) { - return new Promise((resolve, reject) => { - huks.generateKey(alias, options, function (err, data) { - console.log(`test genKey data: ${JSON.stringify(data)}`); - if (err.code !== 0) { - console.log('test genKey err information: ' + JSON.stringify(err)); - reject(err); - } else { - resolve(data); - } + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(alias, options, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); - }); } async function TestExportFunc(alias, options) { - await exportKey(alias, options) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`); - }) - .catch((err) => { - console.log('test exportKey err information: ' + JSON.stringify(err)); - }); + try { + await exportKey(alias, options) + .then ((data) => { + console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); + exportWrappingKey = data.outData; + }) + .catch(error => { + console.error(`callback: exportKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: exportKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } } -function exportKey(alias, options) { - return new Promise((resolve, reject) => { - huks.exportKey(alias, options, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`); - if (err.code !== 0) { - console.log('test exportKey err information: ' + JSON.stringify(err)); - reject(err); - } else { - exportWrappingKey = data.outData; - resolve(data); - } +function exportKey(alias, options) : Promise { + return new Promise((resolve, reject) => { + try { + huks.exportKeyItem(alias, options, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); - }); } async function TestImportWrappedFunc(alias, wrappingAlias, options) { - await importWrappedKey(alias, wrappingAlias, options) - .then((data) => { - console.log(`TestImportWrappedFunc data: ${JSON.stringify(data)}`); - }) - .catch((err) => { - console.log('test importWrappedKey err information: ' + JSON.stringify(err)); - }); + try { + await importWrappedKey(alias, wrappingAlias, options) + .then ((data) => { + console.info(`callback: importWrappedKeyItem success`); + }) + .catch(error => { + console.error(`callback: importWrappedKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: importWrappedKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } } function importWrappedKey(alias, wrappingAlias, options) { - return new Promise((resolve, reject) => { - huks.importWrappedKey(alias, wrappingAlias, options, function (err, data) { - console.log(`importWrappedKey data: ${JSON.stringify(data)}`); - if (err.code !== 0) { - console.log('importWrappedKey err information: ' + JSON.stringify(err)); - reject(err); - } else { - resolve(data); - } + return new Promise((resolve, reject) => { + try { + huks.importWrappedKeyItem(alias, wrappingAlias, options, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); - }); } async function TestImportWrappedKeyFunc( - alias, - wrappingAlias, - genOptions, - importOptions + alias, + wrappingAlias, + genOptions, + importOptions ) { await TestGenFunc(wrappingAlias, genOptions); await TestExportFunc(wrappingAlias, genOptions); @@ -1119,72 +1595,80 @@ async function TestImportWrappedKeyFunc( } function makeGenerateOptions() { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256 - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }; - var options = { - properties: properties - }; - return options; + var properties = new Array(); + properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_ECC + }; + properties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256 + }; + properties[2] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP + }; + properties[3] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }; + properties[4] = { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR, + }; + var options = { + properties: properties + }; + return options; }; function makeImportOptions() { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE, - value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING - }; - var options = { - properties: properties - }; - return options; + var properties = new Array(); + properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }; + properties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 + }; + properties[2] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + }; + properties[3] = { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC + }; + properties[4] = { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE + }; + properties[5] = { + tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE, + value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING + }; + var options = { + properties: properties + }; + return options; }; function huksImportWrappedKey() { - var genOptions = makeGenerateOptions(); - var importOptions = makeImportOptions(); - TestImportWrappedKeyFunc( - alias1, - alias2, - genOptions, - importOptions - ); + var genOptions = makeGenerateOptions(); + var importOptions = makeImportOptions(); + TestImportWrappedKeyFunc( + alias1, + alias2, + genOptions, + importOptions + ); } ``` -## huks.importWrappedKey9+ +## huks.importWrappedKeyItem9+ -importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions) : Promise\ +importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions) : Promise\ 导入加密密钥,使用Promise方式异步返回结果。 @@ -1198,32 +1682,33 @@ importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOption | wrappingKeyAlias | string | 是 | 密钥别名,对应密钥用于解密加密的密钥数据。 | | options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的加密的密钥数据。 | -**返回值:** - -| 类型 | 说明 | -| ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | 返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。 | - **示例:** ```js /* 处理流程与callback类似,主要差异点为如下函数: */ async function TestImportWrappedFunc(alias, wrappingAlias, options) { - var result = await huks.importWrappedKey(alias, wrappingAlias, options); - if (result.errorCode === 0) { - console.log('test importWrappedKey success'); - } else { - console.log('test importWrappedKey fail'); - } + try { + await huks.importWrappedKeyItem(alias, wrappingAlias, options) + .then ((data) => { + console.info(`promise: importWrappedKeyItem success`); + }) + .catch(error => { + console.error(`promise: importWrappedKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: importWrappedKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } } ``` -## huks.exportKey +## huks.exportKey(deprecated) exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void 导出密钥,使用Callback方式回调异步返回的结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.exportKeyItem9+](#huksexportkeyitem9)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -1245,12 +1730,14 @@ var emptyOptions = { huks.exportKey(keyAlias, emptyOptions, function (err, data){}); ``` -## huks.exportKey +## huks.exportKey(deprecated) exportKey(keyAlias: string, options: HuksOptions) : Promise\ 导出密钥,使用Promise方式回调异步返回的结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.exportKeyItem9+](#huksexportkeyitem9-1))替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -1277,12 +1764,93 @@ var emptyOptions = { var result = huks.exportKey(keyAlias, emptyOptions); ``` -## huks.getKeyProperties +## huks.exportKeyItem9+ + +exportKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void + +导出密钥,使用Callback方式回调异步返回的结果。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | +| keyAlias | string | 是 | 密钥别名,应与所用密钥生成时使用的别名相同。 | +| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | 是 | 返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。outData:返回从密钥中导出的公钥。 | + +**示例:** + +```js +/* 此处options选择emptyOptions来传空 */ +var keyAlias = 'keyAlias'; +var emptyOptions = { + properties: [] +}; +try { + huks.exportKeyItem(keyAlias, emptyOptions, function (error, data) { + if (error) { + console.error(`callback: exportKeyItem failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); + } + }); +} catch (error) { + console.error(`callback: exportKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` + +## huks.exportKeyItem9+ + +exportKeyItem(keyAlias: string, options: HuksOptions) : Promise\ + +导出密钥,使用Promise方式回调异步返回的结果。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------------------------------------- | +| keyAlias | string | 是 | 密钥别名,应与所用密钥生成时使用的别名相同。 | +| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------------- | ------------------------------------------------------------ | +| Promise<[HuksReturnResult](#huksreturnresult)> | 不返回err值时表示接口使用成功,其他时为错误。outData:返回从密钥中导出的公钥。 | + +**示例:** + +```js +/* 此处options选择emptyOptions来传空 */ +var keyAlias = 'keyAlias'; +var emptyOptions = { + properties: [] +}; +try { + huks.exportKeyItem(keyAlias, emptyOptions) + .then ((data) => { + console.info(`promise: exportKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: exportKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); +} catch (error) { + console.error(`promise: exportKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` + +## huks.getKeyProperties(deprecated) getKeyProperties(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void 获取密钥属性,使用Callback回调异步返回结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.getKeyItemProperties9+](#huksgetkeyitemproperties9)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -1304,12 +1872,14 @@ var emptyOptions = { huks.getKeyProperties(keyAlias, emptyOptions, function (err, data){}); ``` -## huks.getKeyProperties +## huks.getKeyProperties(deprecated) getKeyProperties(keyAlias: string, options: HuksOptions) : Promise\ 获取密钥属性,使用Promise回调异步返回结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.getKeyItemProperties9+](#huksgetkeyitemproperties9-1)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -1336,7 +1906,86 @@ var emptyOptions = { var result = huks.getKeyProperties(keyAlias, emptyOptions); ``` -## huks.isKeyExist +## huks.getKeyItemProperties9+ + +getKeyItemProperties(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void + +获取密钥属性,使用Callback回调异步返回结果。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | +| keyAlias | string | 是 | 密钥别名,应与所用密钥生成时使用的别名相同。 | +| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | 是 | errorCode:返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。 | + +**示例:** + +```js +/* 此处options选择emptyOptions来传空 */ +var keyAlias = 'keyAlias'; +var emptyOptions = { + properties: [] +}; +try { + huks.getKeyItemProperties(keyAlias, emptyOptions, function (error, data) { + if (error) { + console.error(`callback: getKeyItemProperties failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: getKeyItemProperties success, data = ${JSON.stringify(data)}`); + } + }); +} catch (error) { + console.error(`callback: getKeyItemProperties input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` + +## huks.getKeyItemProperties9+ + +getKeyItemProperties(keyAlias: string, options: HuksOptions) : Promise\ + +获取密钥属性,使用Promise回调异步返回结果。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------------------------------------- | +| keyAlias | string | 是 | 密钥别名,应与所用密钥生成时使用的别名相同。 | +| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------------- | ------------------------------------------------------------ | +| Promise\<[HuksReturnResult](#huksreturnresult)> | 不返回err值时表示接口使用成功,其他时为错误。properties:返回值为生成密钥时所需参数。 | + +**示例:** + +```js +/* 此处options选择emptyOptions来传空 */ +var keyAlias = 'keyAlias'; +var emptyOptions = { + properties: [] +}; +try { + huks.getKeyItemProperties(keyAlias, emptyOptions) + .then ((data) => { + console.info(`promise: getKeyItemProperties success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: getKeyItemProperties failed, code: ${error.code}, msg: ${error.message}`); + }); +} catch (error) { + console.error(`promise: getKeyItemProperties input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` + +## huks.isKeyExist(deprecated) isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void @@ -1363,7 +2012,7 @@ var emptyOptions = { huks.isKeyExist(keyAlias, emptyOptions, function (err, data){}); ``` -## huks.isKeyExist +## huks.isKeyExist(deprecated) isKeyExist(keyAlias: string, options: HuksOptions) : Promise\ @@ -1395,15 +2044,94 @@ var emptyOptions = { var result = huks.isKeyExist(keyAlias, emptyOptions); ``` +## huks.isKeyItemExist9+ + +isKeyItemExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void + +判断密钥是否存在,使用Callback回调异步返回结果 。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------------------------------- | +| keyAlias | string | 是 | 所需查找的密钥的别名。 | +| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | +| callback | AsyncCallback\ | 是 | FALSE代表密钥不存在,TRUE代表密钥存在。 | + +**示例:** + +```js +/* 此处options选择emptyOptions来传空 */ +var keyAlias = 'keyAlias'; +var emptyOptions = { + properties: [] +}; +try { + huks.isKeyItemExist(keyAlias, emptyOptions, function (error, data) { + if (error) { + console.info(`callback: isKeyItemExist success, data = ${JSON.stringify(data)}`); + } else { + console.error(`callback: isKeyItemExist failed, code: ${error.code}, msg: ${error.message}`); + } + }); +} catch (error) { + console.error(`promise: isKeyItemExist input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` + +## huks.isKeyItemExist9+ +isKeyItemExist(keyAlias: string, options: HuksOptions) : Promise\ -## huks.init +判断密钥是否存在,使用Promise回调异步返回结果 。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------ | +| keyAlias | string | 是 | 所需查找的密钥的别名。 | +| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------- | --------------------------------------- | +| Promise\ | FALSE代表密钥不存在,TRUE代表密钥存在。 | + +**示例:** + +```js +/* 此处options选择emptyOptions来传空 */ +var keyAlias = 'keyAlias'; +var emptyOptions = { + properties: [] +}; +try { + huks.isKeyItemExist(keyAlias, emptyOptions) + .then ((data) => { + console.info(`promise: isKeyItemExist success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: isKeyItemExist failed, code: ${error.code}, msg: ${error.message}`); + }); +} catch (error) { + console.error(`promise: isKeyItemExist input arg invalid, code: ${error.code}, msg: ${error.message}`); +} +``` + +## huks.init(deprecated) init(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void init操作密钥接口,使用Callback回调异步返回结果 。 -**系统能力**:SystemCapability.Security.Huks +> **说明:** 从API Version 9开始废弃,建议使用[huks.initSession9+](#huksinitsession9-1)替代。 + +系统能力**:SystemCapability.Security.Huks **参数:** @@ -1414,13 +2142,15 @@ init操作密钥接口,使用Callback回调异步返回结果 。 | callback | AsyncCallback\<[HuksHandle](#hukshandle)> | 是 | 将Init操作操作返回的handle添加到密钥管理系统的回调。 | -## huks.init +## huks.init(deprecated) init(keyAlias: string, options: HuksOptions) : Promise\ init操作密钥接口,使用Promise方式异步返回结果。 -**系统能力**:SystemCapability.Security.Huks +> **说明:** 从API Version 9开始废弃,建议使用[huks.initSession9+](#huksinitsession9-1)替代。 + +系统能力**:SystemCapability.Security.Huks **参数:** @@ -1430,14 +2160,62 @@ init操作密钥接口,使用Promise方式异步返回结果。 | options | [HuksOptions](#huksoptions) | 是 | Init参数集合。 | | promise | Promise\<[HuksHandle](#hukshandle)> | 是 | 将Init操作返回的handle添加到密钥管理系统的回调。 | +## huks.initSession9+ + +initSession(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void + +initSession操作密钥接口,使用Callback回调异步返回结果 。 + +系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ---------------------------------------------------- | +| keyAlias | string | 是 | Init操作密钥的别名。 | +| options | [HuksOptions](#huksoptions) | 是 | Init操作的参数集合。 | +| callback | AsyncCallback\<[HuksSessionHandle](#hukssessionhandle)> | 是 | 将Init操作操作返回的handle添加到密钥管理系统的回调。 | + + +## huks.initSession9+ + +initSession(keyAlias: string, options: HuksOptions) : Promise\ + +initSession操作密钥接口,使用Promise方式异步返回结果。 + +系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------- | ---- | ------------------------------------------------ | +| keyAlias | string | 是 | Init操作密钥的别名。 | +| options | [HuksOptions](#huksoptions) | 是 | Init参数集合。 | +| promise | Promise\<[HuksSessionHandle](#hukssessionhandle)> | 是 | 将Init操作返回的handle添加到密钥管理系统的回调。 | + +## huks.update(deprecated) + +update(handle: number, options: HuksOptions, callback: AsyncCallback\) : void + +update操作密钥接口,使用Callback回调异步返回结果 。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Update操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Update的参数集合。 | +| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | 将Update操作的结果添加到密钥管理系统的回调。 | ## huks.update(deprecated) -update(handle: number, token?: Uint8Array, options: HuksOptions, callback: AsyncCallback\) : void +update(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\) : void update操作密钥接口,使用Callback回调异步返回结果 。 -> **说明:** 从API Version 9开始废弃,建议使用[huks.update9+](#huksupdate9-1)替代。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.updateSession9+](#huksupdatesession9)替代。 **系统能力**: SystemCapability.Security.Huks @@ -1452,11 +2230,11 @@ update操作密钥接口,使用Callback回调异步返回结果 。 ## huks.update(deprecated) -update(handle: number, token?: Uint8Array, options: HuksOptions) : Promise\ +update(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\ update操作密钥接口,使用Promise方式异步返回结果。 -> **说明:** 从API Version 9开始废弃,建议使用[huks.update9+](#huksupdate9)替代。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.updateSession9+](#huksupdatesession9-1)替代。 **系统能力**: SystemCapability.Security.Huks @@ -1469,63 +2247,65 @@ update操作密钥接口,使用Promise方式异步返回结果。 | options | [HuksOptions](#huksoptions) | 是 | Update操作的参数集合。 | | promise | Promise\<[HuksResult](#huksresult)> | 是 | 将Update操作的结果添加到密钥管理系统的回调。 | -## huks.update9+ +## huks.updateSession9+ -update(handle: number, options: HuksOptions, callback: AsyncCallback\) : void +updateSession(handle: number, options: HuksOptions, callback: AsyncCallback\) : void -update操作密钥接口,使用Callback回调异步返回结果 。 +updateSession操作密钥接口,使用Callback回调异步返回结果 。 **系统能力**:SystemCapability.Security.Huks **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------- | ---- | -------------------------------------------- | -| handle | number | 是 | Update操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Update的参数集合。 | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | 将Update操作的结果添加到密钥管理系统的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Update操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Update的参数集合。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | 是 | 将Update操作的结果添加到密钥管理系统的回调。 | -## huks.update9+ +## huks.updateSession9+ -update(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\) : void +updateSession(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\) : void -update操作密钥接口,使用Callback回调异步返回结果 。 +updateSession操作密钥接口,使用Callback回调异步返回结果 。 **系统能力**:SystemCapability.Security.Huks **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------- | ---- | -------------------------------------------- | -| handle | number | 是 | Update操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Update操作的参数集合。 | -| token | Uint8Array | 是 | Update操作的token。 | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | 将Update操作的结果添加到密钥管理系统的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Update操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Update操作的参数集合。 | +| token | Uint8Array | 是 | Update操作的token。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | 是 | 将Update操作的结果添加到密钥管理系统的回调。 | -## huks.update9+ +## huks.updateSession9+ -update(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\ +updateSession(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\ -update操作密钥接口,使用Promise方式异步返回结果。 +uupdateSession操作密钥接口,使用Promise方式异步返回结果。 **系统能力**:SystemCapability.Security.Huks **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ----------------------------------- | ---- | -------------------------------------------- | -| handle | number | 是 | Update操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Update操作的参数集合。 | -| token | Uint8Array | 否 | Update操作的token。 | -| promise | Promise\<[HuksResult](#huksresult)> | 是 | 将Update操作的结果添加到密钥管理系统的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Update操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Update操作的参数集合。 | +| token | Uint8Array | 否 | Update操作的token。 | +| promise | Promise<[HuksReturnResult](#huksreturnresult)> | 是 | 将Update操作的结果添加到密钥管理系统的回调。 | -## huks.finish +## huks.finish(deprecated) finish(handle: number, options: HuksOptions, callback: AsyncCallback\) : void finish操作密钥接口,使用Callback回调异步返回结果 。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.finishSession9+](#huksfinishsession9)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -1537,12 +2317,14 @@ finish操作密钥接口,使用Callback回调异步返回结果 。 | callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | 将Finish操作的结果添加到密钥管理系统的回调。 | -## huks.finish +## huks.finish(deprecated) finish(handle: number, options: HuksOptions) : Promise\ finish操作密钥接口,使用Promise方式异步返回结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.updateSession9+](#huksfinishsession9-1)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -1553,47 +2335,66 @@ finish操作密钥接口,使用Promise方式异步返回结果。 | options | [HuksOptions](#huksoptions) | 是 | Finish操作的参数集合。 | | promise | Promise\<[HuksResult](#huksresult)> | 是 | promise实例,用于获取异步返回结果。 | -## huks.finish9+ +## huks.finishSession9+ -finish(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\) : void +finishSession(handle: number, options: HuksOptions, callback: AsyncCallback\) : void -finish操作密钥接口,使用Callback回调异步返回结果 。 +finishSession操作密钥接口,使用Callback回调异步返回结果 。 **系统能力**:SystemCapability.Security.Huks **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------- | ---- | -------------------------------------------- | -| handle | number | 是 | Finish操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Finish的参数集合。 | -| token | Uint8Array | 是 | Finish操作的token。 | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | 将Finish操作的结果添加到密钥管理系统的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Finish操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Finish的参数集合。 | +| token | Uint8Array | 是 | Finish操作的token。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | 是 | 将Finish操作的结果添加到密钥管理系统的回调。 | +## huks.finishSession9+ -## huks.finish9+ +finishSession(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\) : void -finish(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\ +finishSession操作密钥接口,使用Callback回调异步返回结果 。 -finish操作密钥接口,使用Promise方式异步返回结果。 +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Finish操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Finish的参数集合。 | +| token | Uint8Array | 是 | Finish操作的token。 | +| callback | AsyncCallback\<[HuksReturnResult](#huksreturnresult)> | 是 | 将Finish操作的结果添加到密钥管理系统的回调。 | + + +## huks.finishSession9+ + +finishSession(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\ + +finishSession操作密钥接口,使用Promise方式异步返回结果。 **系统能力**:SystemCapability.Security.Huks **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ----------------------------------- | ---- | ----------------------------------- | -| handle | number | 是 | Finish操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Finish操作的参数集合。 | -| token | Uint8Array | 否 | Finish操作的token。 | -| promise | Promise\<[HuksResult](#huksresult)> | 是 | promise实例,用于获取异步返回结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------------------------- | ---- | ----------------------------------- | +| handle | number | 是 | Finish操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Finish操作的参数集合。 | +| token | Uint8Array | 否 | Finish操作的token。 | +| promise | Promise\<[HuksReturnResult](#huksreturnresult)> | 是 | promise实例,用于获取异步返回结果。 | -## huks.abort +## huks.abort(deprecated) abort(handle: number, options: HuksOptions, callback: AsyncCallback\) : void abort操作密钥接口,使用Callback回调异步返回结果 。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.abortSession9+](#huksabortsession9)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -1612,19 +2413,6 @@ abort操作密钥接口,使用Callback回调异步返回结果 。 * * 以下以RSA1024密钥的callback操作使用为例 */ -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 keyalias = "HuksDemoRSA"; var properties = new Array(); var options = { @@ -1708,112 +2496,16 @@ async function huksAbort() { }); 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('Init') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .width('50%') - .height('10%') - .backgroundColor('#0D9FFB') - .onClick(() => { - huksInit() - }) - Button() { - Text('Update') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .width('50%') - .height('10%') - .backgroundColor('#0D9FFB') - .onClick(() => { - huksUpdate() - }) - Button() { - Text('Finish') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .width('50%') - .height('10%') - .backgroundColor('#0D9FFB') - .onClick(() => { - huksFinish() - }) - Button() { - Text('Abort') - .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 +## huks.abort(deprecated) abort(handle: number, options: HuksOptions) : Promise\; abort操作密钥接口,使用Promise方式异步返回结果。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.abortSession9+](#huksabortsession9-1)替代。 + **系统能力**:SystemCapability.Security.Huks **参数:** @@ -1832,20 +2524,6 @@ abort操作密钥接口,使用Promise方式异步返回结果。 * * 以下以RSA1024密钥的promise操作使用为例 */ -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 keyalias = "HuksDemoRSA"; var properties = new Array(); var options = { @@ -1935,102 +2613,295 @@ function huksAbort() { }); }); } -@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('Init') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .width('50%') - .height('10%') - .backgroundColor('#0D9FFB') - .onClick(() => { - huksInit() - }) - Button() { - Text('Update') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .width('50%') - .height('10%') - .backgroundColor('#0D9FFB') - .onClick(() => { - huksUpdate() - }) - Button() { - Text('Finish') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .width('50%') - .height('10%') - .backgroundColor('#0D9FFB') - .onClick(() => { - huksFinish() - }) - Button() { - Text('Abort') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .width('50%') - .height('10%') - .backgroundColor('#0D9FFB') - .onClick(() => { - huksAbort() - }) +``` + +## huks.abortSession9+ + +abortSession(handle: number, options: HuksOptions, callback: AsyncCallback\) : void + +abort操作密钥接口,使用Callback回调异步返回结果 。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------- | +| handle | number | 是 | Abort操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Abort操作的参数集合。 | +| callback | AsyncCallback\ | 是 | 将Abort操作的结果添加到密钥管理系统的回调。 | + +**示例:** + +```js +/* huks.initSession, huks.updateSession, huks.finishSession为三段式接口,需要一起使用,当 + * huks.initSession和huks.updateSession + * 以及huks.finishSession操作中的任一阶段发生错误时, + * 都需要调用huks.abortSession来终止密钥的使用。 + * + * 以下以RSA1024密钥的callback功能使用为例 + */ +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; +} + +var keyAlias = "HuksDemoRSA"; +var properties = new Array(); +var options = { + properties: properties, + inData: new Uint8Array(0) +}; +var handle; +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_PKCS1_V1_5 + }; + properties[4] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }; + properties[5] = { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB, + } + + try { + await huks.generateKeyItem(keyAlias, options, function (error, data) { + if (error) { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: generateKeyItem success`); + } + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function huksInit() { + console.log('enter huksInit'); + try { + huks.initSession(keyAlias, options, function (error, data) { + if (error) { + console.error(`callback: initSession failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: initSession success, data = ${JSON.stringify(data)}`); + handle = data.handle; + } + }); + } catch (error) { + console.error(`callback: initSession input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function huksUpdate() { + console.log('enter huksUpdate'); + options.inData = stringToUint8Array("huksHmacTest"); + try { + huks.updateSession(handle, options, function (error, data) { + if (error) { + console.error(`callback: updateSession failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: updateSession success, data = ${JSON.stringify(data)}`); + } + }); + } catch (error) { + console.error(`callback: updateSession input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function huksFinish() { + console.log('enter huksFinish'); + options.inData = new Uint8Array(0); + try { + huks.finishSession(handle, options, function (error, data) { + if (error) { + console.error(`callback: finishSession failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: finishSession success, data = ${JSON.stringify(data)}`); + } + }); + } catch (error) { + console.error(`callback: finishSession input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function huksAbort() { + console.log('enter huksAbort'); + try { + huks.abortSession(handle, options, function (error, data) { + if (error) { + console.error(`callback: abortSession failed, code: ${error.code}, msg: ${error.message}`); + } else { + console.info(`callback: abortSession success`); + } + }); + } catch (error) { + console.error(`callback: abortSession input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} +``` + +## huks.abortSession9+ + +abortSession(handle: number, options: HuksOptions) : Promise\; + +abort操作密钥接口,使用Promise方式异步返回结果。 + +**系统能力**:SystemCapability.Security.Huks + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------- | ---- | ------------------------------------------- | +| handle | number | 是 | Abort操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Abort操作的参数集合。 | +| promise | Promise\ | 是 | 将Abort操作的结果添加到密钥管理系统的回调。 | + +**示例:** + +```js +/* huks.initSession, huks.updateSession, huks.finishSession为三段式接口,需要一起使用,当 + * huks.initSession和huks.updateSession + * 以及huks.finishSession操作中的任一阶段发生错误时, + * 都需要调用huks.abortSession来终止密钥的使用。 + * + * 以下以RSA1024密钥的callback功能使用为例 + */ +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; +} + +var keyAlias = "HuksDemoRSA"; +var properties = new Array(); +var options = { + properties: properties, + inData: new Uint8Array(0) +}; +var handle; +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_PKCS1_V1_5 + }; + properties[4] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }; + properties[5] = { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_ECB, + } + + try { + await huks.generateKeyItem(keyAlias, options) + .then((data) => { + console.info(`promise: generateKeyItem success`); + }) + .catch(error => { + console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function huksInit() { + console.log('enter huksInit'); + try { + await huks.initSession(keyAlias, options) + .then ((data) => { + console.info(`promise: initSession success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch(error => { + console.error(`promise: initSession key failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: initSession input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function huksUpdate() { + console.log('enter huksUpdate'); + options.inData = stringToUint8Array("huksHmacTest"); + try { + await huks.updateSession(handle, options) + .then ((data) => { + console.info(`promise: updateSession success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: updateSession failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: updateSession input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function huksFinish() { + console.log('enter huksFinish'); + options.inData = new Uint8Array(0); + try { + await huks.finishSession(handle, options) + .then ((data) => { + console.info(`promise: finishSession success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: finishSession failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: finishSession input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function huksAbort() { + console.log('enter huksAbort'); + try { + await huks.abortSession(keyAlias, options) + .then ((data) => { + console.info(`promise: abortSession success`); + }) + .catch(error => { + console.error(`promise: abortSession failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: abortSession input arg invalid, code: ${error.code}, msg: ${error.message}`); } - .width('100%') - .height('100%') - } } ``` @@ -2056,7 +2927,7 @@ struct Index { | properties | Array\<[HuksParam](#huksparam)> | 否 | 属性,用于存HuksParam的数组。 | | inData | Uint8Array | 否 | 输入数据。 | -## HuksHandle +## HuksHandle(deprecated) huks Handle结构体。 @@ -2068,8 +2939,18 @@ huks Handle结构体。 | handle | number | 是 | 表示handle值。 | | token | Uint8Array | 否 | 表示[init](#huksinit)操作之后获取到的challenge信息。 | +## HuksSessionHandle9+ -## HuksResult +huks Handle结构体。 + +**系统能力**:SystemCapability.Security.Huks + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ---------- | ---- | ---------------------------------------------------- | +| handle | number | 是 | 表示handle值。 | +| challenge | Uint8Array | 否 | 表示[init](#huksinit)操作之后获取到的challenge信息。 | + +## HuksResult(deprecated) 调用接口返回的result。 @@ -2084,3 +2965,16 @@ huks Handle结构体。 | properties | Array\<[HuksParam](#huksparam)> | 否 | 表示属性信息。 | | certChains | Array\ | 否 | 表示证书链数据。 | +## HuksReturnResult9+ + +调用接口返回的result。 + +**系统能力**:SystemCapability.Security.Huks + + + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------------- | ---- | ---------------- | +| outData | Uint8Array | 否 | 表示输出数据。 | +| properties | Array\<[HuksParam](#huksparam)> | 否 | 表示属性信息。 | +| certChains | Array\ | 否 | 表示证书链数据。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md index 902b060a0fe746ce5b2fa529e62a088d25d2190d..e7536e336b6cd7f61d2822276ad5d91703427f41 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -73,6 +73,9 @@ function listener(data) { console.log("type: " + data.type + ", deviceId: " + data.deviceId); } +// 监听输入设备的热插拔事件 +inputDevice.on("change", listener); + // 单独取消listener的监听。 inputDevice.off("change", listener); diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index 1cb18e61f1f300d444a42d7a8c56c21a92ce6633..dab4a75c0a4ee4f5079cfd0fcce5497b76be0abc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -228,7 +228,7 @@ Codec MIME类型枚举。 | VIDEO_MPEG2 | 'video/mpeg2' | 表示视频/mpeg2类型。 | | VIDEO_MPEG4 | 'video/mp4v-es' | 表示视频/mpeg4类型。 | | VIDEO_VP8 | 'video/x-vnd.on2.vp8' | 表示视频/vp8类型。 | -| AUDIO_AAC | "audio/mp4a-latm" | 表示音频/mp4a-latm类型。 | +| AUDIO_AAC | 'audio/mp4a-latm' | 表示音频/mp4a-latm类型。 | | AUDIO_VORBIS | 'audio/vorbis' | 表示音频/vorbis类型。 | | AUDIO_FLAC | 'audio/flac' | 表示音频/flac类型。 | @@ -240,16 +240,16 @@ Codec MIME类型枚举。 | 名称 | 值 | 说明 | | ------------------------ | --------------- | ------------------------------------------------------------ | -| MD_KEY_TRACK_INDEX | "track_index" | 表示轨道序号,其对应键值类型为number。 | -| MD_KEY_TRACK_TYPE | "track_type" | 表示轨道类型,其对应键值类型为number,参考[MediaType](#mediatype8)。 | -| MD_KEY_CODEC_MIME | "codec_mime" | 表示codec_mime类型,其对应键值类型为string。 | -| MD_KEY_DURATION | "duration" | 表示媒体时长,其对应键值类型为number,单位为毫秒(ms)。 | -| MD_KEY_BITRATE | "bitrate" | 表示比特率,其对应键值类型为number,单位为比特率(bps)。 | -| MD_KEY_WIDTH | "width" | 表示视频宽度,其对应键值类型为number,单位为像素(px)。 | -| MD_KEY_HEIGHT | "height" | 表示视频高度,其对应键值类型为number,单位为像素(px)。 | -| MD_KEY_FRAME_RATE | "frame_rate" | 表示视频帧率,其对应键值类型为number,单位为100帧每秒(100fps)。 | -| MD_KEY_AUD_CHANNEL_COUNT | "channel_count" | 表示声道数,其对应键值类型为number。 | -| MD_KEY_AUD_SAMPLE_RATE | "sample_rate" | 表示采样率,其对应键值类型为number,单位为赫兹(Hz)。 | +| MD_KEY_TRACK_INDEX | 'track_index' | 表示轨道序号,其对应键值类型为number。 | +| MD_KEY_TRACK_TYPE | 'track_type' | 表示轨道类型,其对应键值类型为number,参考[MediaType](#mediatype8)。 | +| MD_KEY_CODEC_MIME | 'codec_mime' | 表示codec_mime类型,其对应键值类型为string。 | +| MD_KEY_DURATION | 'duration' | 表示媒体时长,其对应键值类型为number,单位为毫秒(ms)。 | +| MD_KEY_BITRATE | 'bitrate' | 表示比特率,其对应键值类型为number,单位为比特率(bps)。 | +| MD_KEY_WIDTH | 'width' | 表示视频宽度,其对应键值类型为number,单位为像素(px)。 | +| MD_KEY_HEIGHT | 'height' | 表示视频高度,其对应键值类型为number,单位为像素(px)。 | +| MD_KEY_FRAME_RATE | 'frame_rate' | 表示视频帧率,其对应键值类型为number,单位为100帧每秒(100fps)。 | +| MD_KEY_AUD_CHANNEL_COUNT | 'channel_count' | 表示声道数,其对应键值类型为number。 | +| MD_KEY_AUD_SAMPLE_RATE | 'sample_rate' | 表示采样率,其对应键值类型为number,单位为赫兹(Hz)。 | ## BufferingInfoType8+ @@ -441,10 +441,10 @@ function printfDescription(obj) { } } -audioPlayer.getTrackDescription((error, arrlist) => { - if (arrlist != null) { - for (let i = 0; i < arrlist.length; i++) { - printfDescription(arrlist[i]); +audioPlayer.getTrackDescription((error, arrList) => { + if (arrList != null) { + for (let i = 0; i < arrList.length; i++) { + printfDescription(arrList[i]); } } else { console.log(`audio getTrackDescription fail, error:${error}`); @@ -477,9 +477,9 @@ function printfDescription(obj) { } } let arrayDescription = null -audioPlayer.getTrackDescription().then((arrlist) => { - if (arrlist != null) { - arrayDescription = arrlist; +audioPlayer.getTrackDescription().then((arrList) => { + if (arrList != null) { + arrayDescription = arrList; } else { console.log('audio getTrackDescription fail'); } @@ -1234,10 +1234,10 @@ function printfDescription(obj) { } } -videoPlayer.getTrackDescription((error, arrlist) => { - if ((arrlist) != null) { - for (let i = 0; i < arrlist.length; i++) { - printfDescription(arrlist[i]); +videoPlayer.getTrackDescription((error, arrList) => { + if ((arrList) != null) { + for (let i = 0; i < arrList.length; i++) { + printfDescription(arrList[i]); } } else { console.log(`video getTrackDescription fail, error:${error}`); @@ -1271,9 +1271,9 @@ function printfDescription(obj) { } let arrayDescription; -videoPlayer.getTrackDescription().then((arrlist) => { - if (arrlist != null) { - arrayDescription = arrlist; +videoPlayer.getTrackDescription().then((arrList) => { + if (arrList != null) { + arrayDescription = arrList; } else { console.log('video getTrackDescription fail'); } @@ -1617,10 +1617,10 @@ function printfItemDescription(obj, key) { console.info('audio value is ' + property); //对应key值得value。其类型可为任意类型,具体key对应value的类型可参考[MediaDescriptionKey] } let audioPlayer = media.createAudioPlayer(); -audioPlayer.getTrackDescription((error, arrlist) => { - if (arrlist != null) { - for (let i = 0; i < arrlist.length; i++) { - printfItemDescription(arrlist[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值 +audioPlayer.getTrackDescription((error, arrList) => { + if (arrList != null) { + for (let i = 0; i < arrList.length; i++) { + printfItemDescription(arrList[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值 } } else { console.log(`audio getTrackDescription fail, error:${error}`); @@ -2532,8 +2532,8 @@ videoRecorder.on('error', (error) => { // 设 | 名称 | 值 | 说明 | | ----------- | ----- | --------------------- | -| CFT_MPEG_4 | "mp4" | 视频的容器格式,MP4。 | -| CFT_MPEG_4A | "m4a" | 音频的容器格式,M4A。 | +| CFT_MPEG_4 | 'mp4' | 视频的容器格式,MP4。 | +| CFT_MPEG_4A | 'm4a' | 音频的容器格式,M4A。 | ## Location diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md index 96de434b161a278ee506d8665cd184064e4ce807..029821e239fe7b40cb4e498017d6d95630152dd8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md +++ b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md @@ -162,7 +162,7 @@ connection.getAllNets(function (error, nets) { getAllNets(): Promise<Array<NetHandle>> -获取所有处于连接状态的网络列表,使用promise方式作为异步方法。 +获取所有处于连接状态的网络列表,使用Promise方式作为异步方法。 **需要权限**:ohos.permission.GET_NETWORK_INFO @@ -336,7 +336,7 @@ connection.getDefaultNet().then(function (netHandle) { reportNetConnected(netHandle: NetHandle): Promise<void> 向网络管理报告网络处于可用状态,调用此接口说明应用程序认为网络的可用性(ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED)与网络管理不一致。 -使用promise方式作为异步方法。 +使用Promise方式作为异步方法。 **需要权限**:ohos.permission.GET_NETWORK_INFO 和 ohos.permission.INTERNET @@ -351,7 +351,7 @@ reportNetConnected(netHandle: NetHandle): Promise<void> **返回值:** | 类型 | 说明 | | -------- | -------- | -| Promise<void> | 以Promise形式返回执行结果。 | +| Promise<void> | 无返回值的Promise对象。 | **示例:** @@ -398,7 +398,7 @@ connection.getDefaultNet().then(function (netHandle) { reportNetDisconnected(netHandle: NetHandle): Promise<void> 向网络管理报告网络处于不可用状态,调用此接口说明应用程序认为网络的可用性(ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED)与网络管理不一致。 -使用promise方式作为异步方法。 +使用Promise方式作为异步方法。 **需要权限**:ohos.permission.GET_NETWORK_INFO 和 ohos.permission.INTERNET @@ -413,7 +413,7 @@ reportNetDisconnected(netHandle: NetHandle): Promise<void> **返回值:** | 类型 | 说明 | | -------- | -------- | -| Promise<void> | 以Promise形式返回执行结果。 | +| Promise<void> | 无返回值的Promise对象。 | **示例:** @@ -522,7 +522,7 @@ enableAirplaneMode(): Promise\ | 类型 | 说明 | | ------------------------------------------- | ----------------------------- | -| Promise\ | 以Promise形式返回结果。 | +| Promise\ | 无返回值的Promise对象。 | **示例:** @@ -571,7 +571,7 @@ disableAirplaneMode(): Promise\ | 类型 | 说明 | | ------------------------------------------- | ----------------------------- | -| Promise\ | 以Promise形式返回结果。 | +| Promise\ | 无返回值的Promise对象。 | **示例:** @@ -890,7 +890,7 @@ bindSocket(socketParam: TCPSocket \| UDPSocket): Promise\; | 类型 | 说明 | | -------------- | ---------------------- | -| Promise\ | 以Promise形式返回结果。 | +| Promise\ | 无返回值的Promise对象。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md index 0d2e8531dcff5c16a4df4a649bb02b1cca741e24..3cccd741b976c1b9122a871a11601e411fa18c55 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @@ -312,7 +312,7 @@ NDEF Record的TNF(Type Name Field)类型值,参考NDEF标签技术规范《NFC | TNF_UNKNOWN | 0x05 | Unknown。| | TNF_UNCHANGED | 0x06 | Unchanged (see section 2.3.3)。| -## RtdType9+ +## NDEF Record RTD类型定义 NDEF Record的RTD(Record Type Definition)类型值,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。 **需要权限**:ohos.permission.NFC_TAG @@ -320,8 +320,8 @@ NDEF Record的RTD(Record Type Definition)类型值,参考NDEF标签技术规 **系统能力**:SystemCapability.Communication.NFC.Core | **参数名** | **常量值** | **说明** | | -------- | -------- | -------- | -| RTD_TEXT | 常量 'T' | 文本类型的NDEF Record。| -| RTD_URI | 常量 'U' | URI类型的NDEF Record。| +| RTD_TEXT9+ | [0x54] | 文本类型的NDEF Record。| +| RTD_URI9+ | [0x55] | URI类型的NDEF Record。| ## NfcForumType9+ NFC Forum标准里面Tag类型的定义。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfctech.md b/zh-cn/application-dev/reference/apis/js-apis-nfctech.md index 3f1870ceb884df8e7776a997d1a2ab4476832f96..f8e60ee302277a4aebcddf738e130d7a944f6da0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfctech.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfctech.md @@ -728,9 +728,9 @@ ndef.writeNdef(ndefMessage, (err, data)=> { ### NdefTag.canSetReadOnly9+ -canSetReadOnly(): Promise\ +canSetReadOnly(): boolean -检查ndef标签是否可以设置为只读,使用promise方式作为异步方法。 +检查NDEF标签是否可以设置为只读。 **需要权限**:ohos.permission.NFC_TAG @@ -740,7 +740,7 @@ canSetReadOnly(): Promise\ | **类型** | **说明** | | ------------------ | --------------------------| -| Promise<boolean> | true: NDEF标签可设置为只读, false: NDEF标签不可设置为只读。 | +| boolean| true: NDEF标签可设置为只读, false: NDEF标签不可设置为只读。 | **示例:** @@ -748,43 +748,8 @@ canSetReadOnly(): Promise\ import tag from '@ohos.nfc.tag'; // see 'tag.TagInfo' at 'js-apis-nfcTag', has obtained the 'ndef' correctly. -ndef.canSetReadOnly() - .then((data) => { - console.log("ndef canSetReadOnly data: " + data); - }).catch((err)=> { - console.log("ndef canSetReadOnly err: " + err); - }); -``` - -### NdefTag.canSetReadOnly9+ - -canSetReadOnly(callback: AsyncCallback<boolean>): void; - -检查ndef标签是否可以设置为只读,使用callback方式作为异步方法。 - -**需要权限**:ohos.permission.NFC_TAG - -**系统能力**:SystemCapability.Communication.NFC - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback\ | 是 | 回调函数,NDEF标签可设置为只读,返回true。 | - -**示例:** - -```js -import tag from '@ohos.nfc.tag'; - -// see 'tag.TagInfo' at 'js-apis-nfcTag', has obtained the 'ndef' correctly. -ndef.canSetReadOnly((err, data)=> { - if (err) { - console.log("ndef canSetReadOnly err: " + err); - } else { - console.log("ndef canSetReadOnly data: " + data); - } -}); +var canSetReadOnly = ndef.canSetReadOnly(); +console.log("ndef canSetReadOnly: " + canSetReadOnly); ``` ### NdefTag.setReadOnly9+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-prompt.md b/zh-cn/application-dev/reference/apis/js-apis-prompt.md index aeb56ea6f380e2daf696e872cb01514d167ead8c..0553da25895103c1ada4a4ce65bd56e3cebaf53e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-prompt.md +++ b/zh-cn/application-dev/reference/apis/js-apis-prompt.md @@ -35,6 +35,8 @@ prompt.showToast({ }); ``` +![zh-cn_image_0001](figures/zh-cn_image_0001.gif) + ## ShowToastOptions 文本提示框的选项。 @@ -92,6 +94,8 @@ prompt.showDialog({ }) ``` +![zh-cn_image_0002](figures/zh-cn_image_0002.gif) + ## prompt.showDialog showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSuccessResponse>):void @@ -132,6 +136,8 @@ prompt.showDialog({ }); ``` +![zh-cn_image_0004](figures/zh-cn_image_0004.gif) + ## ShowDialogOptions 对话框的选项。 @@ -170,7 +176,6 @@ showActionMenu(options: ActionMenuOptions, callback: AsyncCallback<ActionMenu | options | [ActionMenuOptions](#actionmenuoptions) | 是 | 操作菜单选项。 | | callback | AsyncCallback<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | 是 | 菜单响应结果回调。 | - **示例:** ```js @@ -195,6 +200,8 @@ prompt.showActionMenu({ }) ``` +![zh-cn_image_0005](figures/zh-cn_image_0005.gif) + ## prompt.showActionMenu showActionMenu(options: ActionMenuOptions): Promise<ActionMenuSuccessResponse> @@ -238,6 +245,8 @@ prompt.showActionMenu({ console.info('showActionMenu error: ' + err); }) ``` +![zh-cn_image_0006](figures/zh-cn_image_0006.gif) + ## ActionMenuOptions 操作菜单的选项。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md b/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md index 6091e9ccefaff6fc81d8b9f28256fc6c56e46866..17f1f4702f2feedf93d98c3690484a9d527137b9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @@ -20,6 +20,11 @@ isScreenLocked(callback: AsyncCallback<boolean>): void 判断屏幕是否锁屏,使用callback作为异步方法。 +> **说明:** +> 从API version 9开始废弃。建议使用[screenlock.isLocked9+](#screenlockislocked9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.ScreenLock **参数:** @@ -47,6 +52,11 @@ isScreenLocked(): Promise<boolean> 判断屏幕是否锁屏,使用Promise作为异步方法。 +> **说明:** +> 从API version 9开始废弃。建议使用[screenlock.isLocked9+](#screenlockislocked9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.ScreenLock **返回值**: @@ -66,17 +76,40 @@ isScreenLocked(): Promise<boolean> ``` +## screenlock.isLocked9+ + +isLocked(): boolean; + +判断屏幕是否锁屏,使用同步方法。 + +**系统能力**: SystemCapability.MiscServices.ScreenLock + +**返回值**: + + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回true表示当前屏幕已锁定,返回false表示当前屏幕未锁定。 | + +**示例**: + + ```js + var isLocked = screenlock.isLocked(); + ``` + + ## screenlock.isSecureMode isSecureMode(callback: AsyncCallback<boolean>): void - 判断设备是否处于安全模式下,使用callback作为异步方法。 +> **说明:** +> 从API version 9开始废弃。建议使用[screenlock.isSecure9+](#screenlockissecure9)代替。 +> +> 从 API version 7开始支持。 **系统能力**: SystemCapability.MiscServices.ScreenLock - **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -102,6 +135,11 @@ isSecureMode(): Promise<boolean> 判断设备是否处于安全模式下,使用Promise作为异步方法。 +> **说明:** +> 从API version 9开始废弃。建议使用[screenlock.isSecure9+](#screenlockissecure9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.ScreenLock **返回值**: @@ -121,17 +159,40 @@ isSecureMode(): Promise<boolean> ``` +## screenlock.isSecure9+ + +isSecure(): boolean; + +判断设备是否处于安全模式下,使用同步方法。 + +**系统能力**: SystemCapability.MiscServices.ScreenLock + +**返回值**: + + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回true表示屏幕处于安全模式下,返回false表示屏幕当前不在安全模式下。 | + +**示例**: + + ```js + var isSecure = screenlock.isSecure(); + ``` + + ## screenlock.unlockScreen unlockScreen(callback: AsyncCallback<void>): void - 解锁屏幕,使用callback作为异步方法。 +> **说明:** +> 从API version 9开始废弃。建议使用[screenlock.unlock9+](#screenlockunlock9)代替。 +> +> 从 API version 7开始支持。 **系统能力**: SystemCapability.MiscServices.ScreenLock - **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -157,6 +218,11 @@ unlockScreen(): Promise<void> 解锁屏幕,使用Promise作为异步方法。 +> **说明:** +> 从API version 9开始废弃。建议使用[screenlock.unlock9+](#screenlockunlock9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.ScreenLock **返回值**: @@ -176,14 +242,64 @@ unlockScreen(): Promise<void> ``` -## screenlock.lockScreen9+ +## screenlock.unlock9+ + +unlock(callback: AsyncCallback<boolean>): void + +解锁屏幕,使用callback作为异步方法。 + +**系统能力**: SystemCapability.MiscServices.ScreenLock + +**参数**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | 是 | 回调函数。返回true表示屏幕解锁成功,返回false表示屏幕解锁失败。 | + +**示例**: + + ```js + screenlock.unlock((err,data) => { + if (err) { + console.error('unlock error -> ${JSON.stringify(err)}'); + return; + } + console.info('unlock success data -> ${JSON.stringify(data)}'); + }); + ``` + + +## screenlock.unlock9+ -lockScreen(callback: AsyncCallback<boolean>): void +unlock(): Promise<boolean> +解锁屏幕,使用Promise作为异步方法。 -锁定屏幕,使用callback作为异步方法。 +**系统能力**: SystemCapability.MiscServices.ScreenLock + +**返回值**: + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 以Promise形式返回结果。 | + +**示例**: + + ```js + screenlock.unlock().then((data) => { + console.log('unlock success'); + }).catch((err) => { + console.error('unlock fail, : err->${JSON.stringify(err)}'); + }); + ``` +## screenlock.lock9+ + +lock(callback: AsyncCallback<boolean>): void + +锁定屏幕,使用callback作为异步方法。 + **系统能力**: SystemCapability.MiscServices.ScreenLock **系统接口**:此接口为系统接口,三方应用不支持调用。 @@ -192,23 +308,23 @@ lockScreen(callback: AsyncCallback<boolean>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 回调函数,失败时返回错误信息。 | + | callback | AsyncCallback<void> | 是 | 回调函数。返回true表示屏幕锁定成功,返回false表示屏幕锁定失败。 | **示例**: ```js - screenlock.lockScreen((err) => { + screenlock.lock((err) => { if (err) { - console.error('lockScreen callback error -> ${JSON.stringify(err)}'); + console.error('lock callback error -> ${JSON.stringify(err)}'); return; } - console.info('lockScreen callback success'); + console.info('lock callback success'); }); ``` -## screenlock.lockScreen9+ +## screenlock.lock9+ -lockScreen(): Promise<boolean> +lock(): Promise<boolean> 锁定屏幕,使用Promise作为异步方法。 @@ -225,10 +341,10 @@ lockScreen(): Promise<boolean> **示例**: ```js - screenlock.lockScreen().then(() => { - console.log('lockScreen success'); + screenlock.lock().then(() => { + console.log('lock success'); }).catch((err) => { - console.error('lockScreen fail, promise: err->${JSON.stringify(err)}'); + console.error('lock fail, promise: err->${JSON.stringify(err)}'); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-sim.md b/zh-cn/application-dev/reference/apis/js-apis-sim.md index a3cf167b66502bf8482823d9e7818b0197d2f71b..9a73d5f485e38f088f98530e62ae0a1afb55159d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sim.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sim.md @@ -710,7 +710,7 @@ setShowName\(slotId: number, name: string, callback: AsyncCallback\): voi **示例:** ```js -let name = "中国移动"; +let name = "ShowName"; sim.setShowName(0, name, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -744,7 +744,7 @@ setShowName\(slotId: number, name: string\): Promise\ **示例:** ```js -let name = "中国移动"; +let name = "ShowName"; let promise = sim.setShowName(0, name); promise.then(data => { console.log(`setShowName success, promise: data->${JSON.stringify(data)}`); 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 11c4b540ab18a6092fbfa12a795c70589426c23c..b0a44d376ac347c3e25825aee28ae22815f26968 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 @@ -52,7 +52,7 @@ getTotalSizeOfVolume(volumeUuid: string): Promise<number> ## storageStatistics.getTotalSizeOfVolume -getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void +getTotalSizeOfVolume(volumeUuid: string, callback: AsyncCallback<number>): void 异步获取指定卷的总空间大小,以callback方式返回。 @@ -69,7 +69,7 @@ getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):v | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------ | ---- | -------------------------- | | volumeUuid | string | 是 | 卷id | - | callback | callback:AsyncCallback<number> | 是 | 获取指定卷总空间之后的回调 | + | callback | callback: AsyncCallback<number> | 是 | 获取指定卷总空间之后的回调 | **示例:** @@ -121,7 +121,7 @@ getFreeSizeOfVolume(volumeUuid: string): Promise<number> ## storageStatistics.getFreeSizeOfVolume -getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void +getFreeSizeOfVolume(volumeUuid: string, callback: AsyncCallback<number>): void 异步获取指定卷的可用空间大小,以callback方式返回。 @@ -138,7 +138,7 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):vo | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------ | ---- | ---------------------------- | | volumeUuid | string | 是 | 卷id | - | callback | callback:AsyncCallback<number> | 是 | 获取指定卷可用空间之后的回调 | + | callback | callback: AsyncCallback<number> | 是 | 获取指定卷可用空间之后的回调 | **示例:** @@ -206,7 +206,7 @@ getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>) | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | packageName | string | 是 | 应用包名 | - | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储数据之后的回调 | + | callback | callback: AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储数据之后的回调 | **示例:** @@ -251,7 +251,7 @@ getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | - | callback | callback:AsyncCallback<[BundleStats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 | + | callback | callback: AsyncCallback<[BundleStats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 | **示例:** @@ -323,7 +323,7 @@ getTotalSize(callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------ | ---- | ------------------------ | - | callback | callback:AsyncCallback<number> | 是 | 获取内卡的总空间大小之后的回调 | + | callback | callback: AsyncCallback<number> | 是 | 获取内卡的总空间大小之后的回调 | **示例:** @@ -381,7 +381,7 @@ getFreeSize(callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------ | ---- | ------------------------- | - | callback | callback:AsyncCallback<number> | 是 | 获取内卡的可用空间大小之后的回调 | + | callback | callback: AsyncCallback<number> | 是 | 获取内卡的可用空间大小之后的回调 | **示例:** @@ -424,7 +424,7 @@ getSystemSize(): Promise<number> ## storageStatistics.getSystemSize9+ -getSystemSize(callback:AsyncCallback<number>):void +getSystemSize(callback: AsyncCallback<number>): void 异步获取系统空间大小,以callback方式返回。 @@ -440,7 +440,7 @@ getSystemSize(callback:AsyncCallback<number>):void | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------ | ---- | -------------------------- | - | callback | callback:AsyncCallback<number> | 是 | 获取系统空间大小之后的回调 | + | callback | callback: AsyncCallback<number> | 是 | 获取系统空间大小之后的回调 | **示例:** @@ -475,7 +475,7 @@ getUserStorageStats(userId? : number): Promise<StorageStats> | 类型 | 说明 | | --------------------- | ---------------- | - | Promise<[StorageStats](#StorageStats)> | 返回各类别数据大小 | + | Promise<[StorageStats](#storagestats)> | 返回各类别数据大小 | **示例:** @@ -490,7 +490,7 @@ getUserStorageStats(userId? : number): Promise<StorageStats> ## storageStatistics.getUserStorageStats9+ -getUserStorageStats(userId: number, callback:AsyncCallback<StorageStats>):void +getUserStorageStats(userId: number, callback: AsyncCallback<StorageStats>): void 异步获取用户各类别数据大小,以callback方式返回。 @@ -507,7 +507,7 @@ getUserStorageStats(userId: number, callback:AsyncCallback<StorageStats>): | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------ | ---- | -------------------------- | | userId | number | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。 | - | callback | callback:AsyncCallback<[StorageStats](#StorageStats)> | 是 | 返回各类别数据大小之后的回调 | + | callback | callback: AsyncCallback<[StorageStats](#storagestats)> | 是 | 返回各类别数据大小之后的回调 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-url.md b/zh-cn/application-dev/reference/apis/js-apis-url.md index 881b10ac1deaa241f621101a4ca7af2ac56c648b..44b873ad803829f77a47b79878496e9eaab5e92f 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-url.md +++ b/zh-cn/application-dev/reference/apis/js-apis-url.md @@ -25,7 +25,7 @@ URLSearchParams的构造函数。 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| init | string[][] \| Record<string, string> \| string \| URLSearchParams | 否 | 入参对象。
- string[][]:字符串二维数组
- Record<string, string>:对象列表
- string:字符串
- URLSearchParams:对象 | +| init | string[][] \| Record<string, string> \| string \| URLSearchParams | 否 | 入参对象。
- string[][]:字符串二维数组
- Record<string, string>:对象列表
- string:字符串
- URLSearchParams:对象 | **示例:** @@ -127,7 +127,7 @@ entries(): IterableIterator<[string, string]> | 类型 | 说明 | | -------- | -------- | -| IterableIterator<[string, string]> | 返回一个ES6的迭代器。 | +| IterableIterator<[string, string]> | 返回一个ES6的迭代器。 | **示例:** @@ -191,7 +191,7 @@ get(name: string): string | null | 类型 | 说明 | | -------- | -------- | | string | 返回第一个值。 | -| null | 如果没找到,返回 null。 | +| null | 如果没找到,返回 null。 | **示例:** @@ -332,7 +332,7 @@ for (var value of searchParams.values()) { | 类型 | 说明 | | -------- | -------- | -| IterableIterator<[string, string]> | 返回一个ES6的迭代器。 | +| IterableIterator<[string, string]> | 返回一个ES6的迭代器。 | **示例:** @@ -403,7 +403,7 @@ URL的构造函数。 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | url | string | 是 | 入参对象。 | -| base | string \| URL | 否 | 入参字符串或者对象。
- string:字符串
- URL:字符串或对象 | +| base | string \| URL | 否 | 入参字符串或者对象。
- string:字符串
- URL:字符串或对象 | **示例:** @@ -441,7 +441,7 @@ toString(): string ```js const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); -url.toString() +url.toString(); ``` @@ -462,5 +462,5 @@ toJSON(): string **示例:** ```js const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); -url.toJSON() +url.toJSON(); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md b/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md index e7b62b26edd06910929557ff5a97f3b78a869b23..a22163a78c646bedab2ff1ec36df7797f7562b42 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @@ -37,36 +37,38 @@ constructor() ```js import userIAM_faceAuth from '@ohos.userIAM.faceAuth'; - let faceAuthManager = new userIAM_faceAuth.FaceAuthManager() + let faceAuthManager = new userIAM_faceAuth.FaceAuthManager(); ``` ### setSurfaceId -setSurfaceId(surfaceId: string): ResultCode; +setSurfaceId(surfaceId: string): void; -设置录入流程中人脸预览界面 [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID, 返回值表示操作是否成功。 +设置录入流程中人脸预览界面 [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID。 **系统能力:** SystemCapability.UserIAM.UserAuth.FaceAuth +**需要权限:** ohos.permission.MANAGE_USER_IDM + **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------------- | ---------------------------------- | ---- | -------------------------- | | surfaceId | string | 是 | [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID。 | -**返回值:** - -| 类型 | 说明 | -| ---------- | ------------------------------------------------------------ | -| [ResultCode](#resultcode) | 表示操作是否成功 | - **示例:** ```js - import userIAM_faceAuth from '@ohos.userIAM.faceAuth'; - - let faceAuthManager = new userIAM_faceAuth.FaceAuthManager() - faceAuthManager.setSurfaceId("0"); + import faceAuth from '@ohos.userIAM.faceAuth'; + + let surfaceId = "123456"; + let manager = new faceAuth.FaceAuthManager(); + try { + manager.setSurfaceId(surfaceId); + console.info("set surface id success"); + } catch (e) { + console.error("set surface id failed, error = " + e); + } ``` ## ResultCode @@ -77,5 +79,4 @@ setSurfaceId(surfaceId: string): ResultCode; | 名称 | 默认值 | 描述 | | ----------------------- | ------ | -------------------- | -| SUCCESS | 0 | 执行成功。 | -| FAIL | 1 | 执行失败。 | +| FAIL | 12700001 | 执行失败。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md index 97940a9d991bf61c0e01dc85d6e284092117d8e4..3f5904c8eca91a72e441ce4497ef5c3899776074 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -14,6 +14,71 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth'; ## 完整示例 +```js +// API version 9 +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +export default { + getVersion() { + try { + let version = userIAM_userAuth.getVersion(); + console.info("auth version = " + version); + } catch (error) { + console.info("get version failed, error = " + error); + } + }, + + start() { + console.info("start auth"); + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + try { + let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + auth.on("result", { + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); + } + }); + auth.start(); + console.log("authV9 start success"); + } catch (error) { + console.log("authV9 error = " + error); + // do error + } + }, + + getAvailableStatus() { + console.info("start check auth support"); + try { + userIAM_userAuth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1); + console.info("current auth trust level is supported"); + } catch (error) { + console.info("current auth trust level is not supported, error = " + error); + } + }, + + cancel() { + console.info("start cancel auth"); + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + try { + let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + auth.start(); + auth.cancel(); + console.info("cancel auth success"); + } catch (error) { + console.info("cancel auth failed, error = " + error); + } + } +} +``` + ```js // API version 8 import userIAM_userAuth from '@ohos.userIAM.userAuth'; @@ -22,13 +87,13 @@ let auth = new userIAM_userAuth.UserAuth(); export default { getVersion() { console.info("start get version"); - let version = this.auth.getVersion(); + let version = auth.getVersion(); console.info("auth version = " + version); }, startAuth() { console.info("start auth"); - this.auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { + auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { onResult: (result, extraInfo) => { try { console.info("auth onResult result = " + result); @@ -108,15 +173,374 @@ export default { } ``` +## EventInfo9+ + +类型别名,用于表示认证事件信息的类型,取值可以为下表中的类型。 + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +| 类型 | 说明 | +| --------- | ----------------------- | +| [AuthResultInfo](#authresultinfo9) | 认证结果信息 | +| [TipInfo](#tipinfo9) | 认证过程中的提示信息 | + +## AuthEvent9+ + +认证事件回调的对象。 + +### callback9+ + +callback: (result : EventInfo) => void + +表示在认证结束后返回结果信息或者在认证操作中返回提示信息。 + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | -------------------------- | ---- | -------------------------------------------------------- | +| result | [EventInfo](#eventinfo9) | 是 | 返回的认证结果信息或提示信息。 | + +**示例:** + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + try { + let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + auth.on("result", { + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); + } + }); + auth.start(); + console.log("authV9 start success"); + } catch (error) { + console.log("authV9 error = " + error); + // do error + } + ``` + +## AuthResultInfo9+ + +表示认证结果信息的对象。 + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +| 名称 | 参数类型 | 必填 | 说明 | +| ------------ | ---------- | ---- | -------------------- | +| result | number | 是 | 认证结果。 | +| token | Uint8Array | 否 | 用户身份认证通过的凭证。 | +| remainAttempts | number | 否 | 剩余的认证操作次数。 | +| lockoutDuration | number | 否 | 认证操作的冻结时间。 | + +## TipInfo9+ + +表示认证过程中提示信息的对象。 + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +| 名称 | 参数类型 | 必填 | 说明 | +| ------------ | ---------- | ---- | -------------------- | +| module | number | 否 | 认证结果。 | +| tip | number | 否 | 认证过程提示信息。 | + +## AuthEventKey9+ + +类型别名,表示认证事件的关键字,取值为表格内字符串。 + +| 取值 | 说明 | +| ---------- | ----------------------- | +| "result" | 取值为result时,事件回调返回认证的结果信息。 | +| "tip" | 取值为tip时,事件回调返回认证操作中的提示信息。 | + +## AuthInstance9+ + +执行用户认证的对象。 + +### on9+ + +on(name : AuthEventKey, callback : AuthEvent) : void + +表示开启对认证事件的监听。 + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | -------------------------- | ---- | ------------------------- | +| name | AuthEventKey | 是 | 认证事件的关键字 | +| callback | AuthEvent | 是 | 认证事件的回调函数 | + +**示例:** + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + try { + let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + auth.on("result", { + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); + } + }); + auth.start(); + console.log("authV9 start success"); + } catch (error) { + console.log("authV9 error = " + error); + // do error + } + ``` + +### off9+ + +off(name : AuthEventKey) : void + +表示关闭对认证事件的监听。 + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | -------------------------- | ---- | ------------------------- | +| name | AuthEventKey | 是 | 认证事件的关键字 | + +**示例:** + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + try { + let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + auth.on("result", { + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); + } + }); + console.log("turn on authentication event listening success"); + } catch (error) { + console.log("turn off authentication event listening failed " + error); + // do error + } + + try { + let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + auth.off("result"); + console.info("turn off authentication event listening success"); + } catch (error) { + console.info("turn off authentication event listening failed, error = " + error); + } + ``` + +### start9+ + +start() : void + +表示开始认证。 + +**需要权限**:ohos.permission.ACCESS_BIOMETRIC + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +**示例:** + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + try { + let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + auth.start(); + console.info("authV9 start auth success"); + } catch (error) { + console.info("authV9 start auth failed, error = " + error); + } + ``` + +### cancel9+ + +cancel(): void + +表示取消认证。 + +**需要权限**:ohos.permission.ACCESS_BIOMETRIC + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +**示例:** + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + try { + let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + auth.start(); + auth.cancel(); + console.info("cancel auth success"); + } catch (error) { + console.info("cancel auth failed, error = " + error); + } + ``` + +## userIAM_userAuth.getAuthInstance9+ + +getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel : AuthTrustLevel): AuthInstance + +获取AuthInstance对象,用于执行用户身份认证。 + +> **说明:** +> 每个AuthInstance只能用于发起一次认证,若需要再次发起认证需重新获取AuthInstance。 + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------------- | ---- | ------------------------ | +| challenge | Uint8Array | 是 | 挑战值,最大长度为32字节,可以填null。 | +| authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前支持FACE。 | +| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------- | ------------ | +| [AuthInstance](#authinstance9) | 认证器对象。 | + +**示例:** + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + try { + let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.info("get auth instance success"); + } catch (error) { + console.info("get auth instance success failed, error = " + error); + } + ``` + +## userIAM_userAuth.getVersion9+ + +getVersion(): number + +获取认证器的版本信息。 + +**需要权限**:ohos.permission.ACCESS_BIOMETRIC + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +**返回值:** + +| 类型 | 说明 | +| ------ | ---------------------- | +| number | 获取的认证器版本信息。 | + +**示例:** + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + try { + let version = userIAM_userAuth.getVersion(); + console.info("auth version = " + version); + } catch (error) { + console.info("get version failed, error = " + error); + } + ``` + +## userIAM_userAuth.getAvailableStatus9+ + +getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void + +表示检查指定的认证等级的认证能力是否可用。 + +**需要权限**:ohos.permission.ACCESS_BIOMETRIC + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------- | ---- | -------------------------- | +| authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前只支持FACE。 | +| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证结果的信任等级。 | + +**示例:** + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + try { + userIAM_userAuth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1); + console.info("current auth trust level is supported"); + } catch (error) { + console.info("current auth trust level is not supported, error = " + error); + } + ``` + + ## ResultCodeV99+ + +表示执行结果的枚举。 + +**系统能力**:SystemCapability.UserIAM.UserAuth.Core + +| 名称 | 默认值 | 描述 | +| ----------------------- | ------ | -------------------- | +| SUCCESS | 12500000 | 执行成功。 | +| FAIL | 12500001 | 执行失败。 | +| GENERAL_ERROR | 12500002 | 操作通用错误。 | +| CANCELED | 12500003 | 操作取消。 | +| TIMEOUT | 12500004 | 操作超时。 | +| TYPE_NOT_SUPPORT | 12500005 | 不支持的认证类型。 | +| TRUST_LEVEL_NOT_SUPPORT | 12500006 | 不支持的认证等级。 | +| BUSY | 12500007 | 忙碌状态。 | +| INVALID_PARAMETERS | 12500008 | 无效参数。 | +| LOCKED | 12500009 | 认证器已锁定。 | +| NOT_ENROLLED | 12500010 | 用户未录入认证信息。 | ## UserAuth8+ 认证器的对象。 -### constructor8+ +### constructor(deprecated) constructor() +> **说明:** +> 从 API version 9 开始废弃,请使用[getAuthInstance](#useriam_userauthgetauthinstance9)替代。 +
从 API version 8 开始支持。 + 表示获取的认证器对象。 **系统能力**:SystemCapability.UserIAM.UserAuth.Core @@ -135,10 +559,14 @@ constructor() let auth = new userIAM_userAuth.UserAuth(); ``` -### getVersion8+ +### getVersion(deprecated) getVersion() : number +> **说明:** +> 从 API version 9 开始废弃,请使用[getVersion](#useriam_userauthgetversion9)替代。 +
从 API version 8 开始支持。 + 表示获取的认证器版本信息。 **需要权限**:ohos.permission.ACCESS_BIOMETRIC @@ -161,10 +589,14 @@ getVersion() : number console.info("auth version = " + version); ``` -### getAvailableStatus8+ +### getAvailableStatus(deprecated) getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number +> **说明:** +> 从 API version 9 开始废弃,请使用开始废弃,请使用[getAvailableStatus](#useriam_userauthgetavailablestatus9)替代。 +
从 API version 8 开始支持。 + 表示检查指定的认证等级的认证能力是否可用。 **需要权限**:ohos.permission.ACCESS_BIOMETRIC @@ -182,7 +614,7 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : n | 类型 | 说明 | | ------ | ------------------------------------------------------------ | -| number | 获取指定的认证等级的认证能力是否可用的检查结果,返回值参见[ResultCode](#resultcode8)。 | +| number | 获取指定的认证等级的认证能力是否可用的检查结果,返回值参见[ResultCode](#resultcodedeprecated)。 | **示例:** @@ -200,10 +632,14 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : n } ``` -### auth8+ +### auth(deprecated) auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array +> **说明:** +> 从 API version 9 开始废弃,建议使用[start](#start9)代替。 +
从 API version 8 开始支持。 + 表示执行用户认证,使用callback方式作为异步方法。 **需要权限**:ohos.permission.ACCESS_BIOMETRIC @@ -217,13 +653,13 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev | challenge | Uint8Array | 是 | 挑战值,可以填null。 | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前支持FACE。 | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 信任等级。 | -| callback | [IUserAuthCallback](#iuserauthcallback8) | 是 | 回调函数。 | +| callback | [IUserAuthCallback](#iuserauthcallbackdeprecated) | 是 | 回调函数。 | **返回值:** | 类型 | 说明 | | ---------- | ------------------------------------------------------------ | -| Uint8Array | ContextId,作为取消认证[cancelAuth](#cancelauth8)接口的入参。 | +| Uint8Array | ContextId,作为取消认证[cancelAuth](#cancelauthdeprecated)接口的入参。 | **示例:** @@ -248,10 +684,14 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev }); ``` -### cancelAuth8+ +### cancelAuth(deprecated) cancelAuth(contextID : Uint8Array) : number +> **说明:** +> 从 API version 9 开始废弃,建议使用[cancel](#cancel9)代替。 +
从 API version 8 开始支持。 + 表示通过contextID取消本次认证操作。 **需要权限**:ohos.permission.ACCESS_BIOMETRIC @@ -262,7 +702,7 @@ cancelAuth(contextID : Uint8Array) : number | 参数名 | 类型 | 必填 | 说明 | | --------- | ---------- | ---- | ------------------------------------------ | -| contextID | Uint8Array | 是 | 上下文ID信息,通过[auth](#auth8)接口获得。 | +| contextID | Uint8Array | 是 | 上下文ID信息,通过[auth](#authdeprecated)接口获得。 | **返回值:** @@ -286,14 +726,22 @@ cancelAuth(contextID : Uint8Array) : number } ``` -## IUserAuthCallback8+ +## IUserAuthCallback(deprecated) + +> **说明:** +> 从 API version 9 开始废弃,建议使用[AuthEvent](#authevent9)代替。 +
从 API version 8 开始支持。 认证过程中回调结果的对象。 -### onResult8+ +### onResult(deprecated) onResult: (result : number, extraInfo : AuthResult) => void +> **说明:** +> 从 API version 9 开始废弃,建议使用[callback](#callback9)代替。 +
从 API version 8 开始支持。 + 表示在认证操作中,获取认证结果。 **系统能力**:SystemCapability.UserIAM.UserAuth.Core @@ -302,8 +750,8 @@ onResult: (result : number, extraInfo : AuthResult) => void | 参数名 | 类型 | 必填 | 说明 | | --------- | -------------------------- | ---- | ------------------------------------------------------------ | -| result | number | 是 | 认证结果,参见[ResultCode](#resultcode8)。 | -| extraInfo | [AuthResult](#authresult8) | 是 | 扩展信息,不同情况下的具体信息,
如果身份验证通过,则在extrainfo中返回用户认证令牌,
如果身份验证失败,则在extrainfo中返回剩余的用户认证次数,
如果身份验证执行器被锁定,则在extrainfo中返回冻结时间。 | +| result | number | 是 | 认证结果,参见[ResultCode](#resultcodedeprecated)。 | +| extraInfo | [AuthResult](#authresultdeprecated) | 是 | 扩展信息,不同情况下的具体信息,
如果身份验证通过,则在extrainfo中返回用户认证令牌,
如果身份验证失败,则在extrainfo中返回剩余的用户认证次数,
如果身份验证执行器被锁定,则在extrainfo中返回冻结时间。 | **示例:** @@ -339,10 +787,14 @@ onResult: (result : number, extraInfo : AuthResult) => void }); ``` -### onAcquireInfo8+ +### onAcquireInfo(deprecated) onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void +> **说明:** +> 从 API version 9 开始废弃,建议使用[callback](#callback9)代替。 +
从 API version 8 开始支持。 + 表示在认证过程中,获取提示码信息,非必须实现。 **系统能力**:SystemCapability.UserIAM.UserAuth.Core @@ -388,7 +840,11 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void }); ``` -## AuthResult8+ +## AuthResult(deprecated) + +> **说明:** +> 从 API version 9 开始废弃,建议使用[AuthResultInfo](#authresultinfo9)代替。 +
从 API version 8 开始支持。 表示认证结果的对象。 @@ -400,7 +856,10 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void | remainTimes | number | 否 | 剩余的认证操作次数。 | | freezingTime | number | 否 | 认证操作的冻结时间。 | -## ResultCode8+ +## ResultCode(deprecated) + +> **说明:** +> 从 API version 9 开始废弃,建议使用[ResultCodeV9](#resultcodev99)代替。 表示执行结果的枚举。 @@ -487,7 +946,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void getAuthenticator(): Authenticator > **说明:** -> 从 API Version 8 开始废弃,建议使用[constructor](#constructor8)替代。 +> 从 API version 8 开始废弃,建议使用[constructor](#constructordeprecated)替代。 获取Authenticator对象,用于执行用户身份认证。 @@ -507,7 +966,7 @@ getAuthenticator(): Authenticator ## Authenticator(deprecated) > **说明:** -> 从 API Version 8 开始废弃,建议使用[UserAuth](#userauth8)替代。 +> 从 API version 8 开始废弃,建议使用[UserAuth](#userauth8)替代。 认证器对象。 @@ -517,7 +976,7 @@ getAuthenticator(): Authenticator execute(type: AuthType, level: SecureLevel, callback: AsyncCallback<number>): void > **说明:** -> 从 API Version 8 开始废弃,建议使用[auth](#auth8)替代。 +> 从 API version 8 开始废弃,建议使用[auth](#authdeprecated)替代。 执行用户认证,使用callback方式作为异步方法。 @@ -557,7 +1016,7 @@ execute(type: AuthType, level: SecureLevel, callback: AsyncCallback<number> execute(type:AuthType, level:SecureLevel): Promise<number> > **说明:** -> 从 API Version 8 开始废弃,建议使用[auth](#auth8)替代。 +> 从 API version 8 开始废弃,建议使用[auth](#authdeprecated)替代。 执行用户认证,使用promise方式作为异步方法。 @@ -592,7 +1051,7 @@ execute(type:AuthType, level:SecureLevel): Promise<number> ## AuthenticationResult(deprecated) > **说明:** -> 从 API Version 8 开始废弃,建议使用[ResultCode](#resultcode8)替代。 +> 从 API version 8 开始废弃,建议使用[ResultCode](#resultcodedeprecated)替代。 表示认证结果的枚举。 @@ -610,4 +1069,4 @@ execute(type:AuthType, level:SecureLevel): Promise<number> | INVALID_PARAMETERS | 6 | 认证参数无效。 | | LOCKED | 7 | 认证失败次数过多,已锁定。 | | NOT_ENROLLED | 8 | 未录入认证凭据。 | -| GENERAL_ERROR | 100 | 其他错误。 | \ No newline at end of file +| GENERAL_ERROR | 100 | 其他错误。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md index 1e80088a9051d63bc368eaf24e6acdb6c25d7a0a..b7b6212bd8c6df1c5fa3313c94e084037a1f5f04 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @@ -52,7 +52,7 @@ getAllVolumes(callback: AsyncCallback<Array<Volume>>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------- | ---- | ------------------------------------ | - | callback | callback:AsyncCallback<[Volume](#volume)[]> | 是 | 获取当前所有可获得的卷信息之后的回调 | + | callback | callback: AsyncCallback<[Volume](#volume)[]> | 是 | 获取当前所有可获得的卷信息之后的回调 | **示例:** @@ -110,7 +110,7 @@ mount(volumeId: string, callback:AsyncCallback<boolean>):void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | -------------------- | | volumeId | string | 是 | 卷id | - | callback | callback:AsyncCallback<boolean> | 是 | 挂载指定卷之后的回调 | + | callback | callback: AsyncCallback<boolean> | 是 | 挂载指定卷之后的回调 | **示例:** @@ -154,7 +154,7 @@ unmount(volumeId: string): Promise<boolean> ## volumemanager.unmount -unmount(volumeId: string, callback:AsyncCallback<boolean>):void +unmount(volumeId: string, callback: AsyncCallback<boolean>): void 异步卸载指定卷,以callback方式返回。 @@ -167,7 +167,7 @@ unmount(volumeId: string, callback:AsyncCallback<boolean>):void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | -------------------- | | volumeId | string | 是 | 卷id | - | callback | callback:AsyncCallback<boolean> | 是 | 卸载指定卷之后的回调 | + | callback | callback: AsyncCallback<boolean> | 是 | 卸载指定卷之后的回调 | **示例:** @@ -226,7 +226,7 @@ getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------ | ---- | -------------------- | | uuid | string | 是 | 卷uuid | - | callback | callback:AsyncCallback<[Volume](#volume)> | 是 | 获取卷信息之后的回调 | + | callback | callback: AsyncCallback<[Volume](#volume)> | 是 | 获取卷信息之后的回调 | **示例:** @@ -347,7 +347,7 @@ setVolumeDescription(uuid: string, description: string, callback: AsyncCallback& | ---------- | --------------------------------------- | ---- | ---------------- | | uuid | string | 是 | 卷uuid | | description | string | 是 | 卷描述 | - | callback | callback:AsyncCallback<void> | 是 | 设置卷描述之后的回调 | + | callback | callback: AsyncCallback<void> | 是 | 设置卷描述之后的回调 | **示例:** @@ -410,7 +410,7 @@ format(volumeId: string, fsType: string, callback: AsyncCallback<void>): v | -------- | ------------------------- | ---- | ----------------------------- | | volumeId | string | 是 | 卷id | | fsType | string | 是 | 文件系统类型 | - | callback | callback:AsyncCallback<void> | 是 | 对指定卷格式化后的回调 | + | callback | callback: AsyncCallback<void> | 是 | 对指定卷格式化后的回调 | **示例:** @@ -473,7 +473,7 @@ partition(diskId: string, type: number, callback: AsyncCallback<void>): vo | -------- | --------------------------------------- | ---- | ---------------- | | diskId | string | 是 | 卷所属的磁盘id | | type | number | 是 | 分区类型 | - | callback | callback:AsyncCallback<void> | 是 | 对磁盘进行分区 | + | callback | callback: AsyncCallback<void> | 是 | 对磁盘进行分区 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md index 7b83e70733439c339358b263087a92fd39fed77b..0804b9e3805cfa9ca1730320d144b9ecfe7c75c1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @@ -32,6 +32,11 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<Rgba 获取指定类型壁纸的主要颜色信息。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getColorsSync9+](#wallpapergetcolorssync9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.Wallpaper **参数:** @@ -60,6 +65,11 @@ getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>> 获取指定类型壁纸的主要颜色信息。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getColorsSync9+](#wallpapergetcolorssync9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.Wallpaper **参数:** @@ -85,12 +95,44 @@ getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>> ``` +## wallpaper.getColorsSync9+ + +getColorsSync(wallpaperType: WallpaperType): Arrayy<RgbaColory>; + +获取指定类型壁纸的主要颜色信息。 + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + +**返回值**: + + | 类型 | 说明 | + | -------- | -------- | + | Array<[RgbaColor](#rgbacolor)> | 返回壁纸的主要颜色信息。 | + +**示例**: + + ```js + var colors = wallpaper.getColorsSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM); + ``` + + ## wallpaper.getId getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void 获取指定类型壁纸的ID。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getIdSync9+](#wallpapergetidsync9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.Wallpaper **参数:** @@ -119,8 +161,12 @@ getId(wallpaperType: WallpaperType): Promise<number> 获取指定类型壁纸的ID。 -**系统能力**: SystemCapability.MiscServices.Wallpaper +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getIdSync9+](#wallpapergetidsync9)代替。 +> +> 从 API version 7开始支持。 +**系统能力**: SystemCapability.MiscServices.Wallpaper **参数:** @@ -145,12 +191,44 @@ getId(wallpaperType: WallpaperType): Promise<number> ``` +## wallpaper.getIdSync9+ + +getIdSync(wallpaperType: WallpaperType): number; + +获取指定类型壁纸的ID。 + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + +**返回值**: + + | 类型 | 说明 | + | -------- | -------- | + | number | 返回壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | + +**示例**: + + ```js + var id = wallpaper.getIdSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM); + ``` + + ## wallpaper.getMinHeight getMinHeight(callback: AsyncCallback<number>): void 获取壁纸的最小高度值。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getMinHeightSync9+](#wallpapergetminheightsync9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.Wallpaper **参数:** @@ -178,8 +256,12 @@ getMinHeight(): Promise<number> 获取壁纸的最小高度值。 -**系统能力**: SystemCapability.MiscServices.Wallpaper +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getMinHeightSync9+](#wallpapergetminheightsync9)代替。 +> +> 从 API version 7开始支持。 +**系统能力**: SystemCapability.MiscServices.Wallpaper **返回值:** @@ -198,14 +280,39 @@ getMinHeight(): Promise<number> ``` +## wallpaper.getMinHeightSync9+ + +getMinHeightSync(): number + +获取壁纸的最小高度值。 + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | number | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | + +**示例:** + + ```js + var minHeight = wallpaper.getMinHeightSync(); + ``` + + ## wallpaper.getMinWidth getMinWidth(callback: AsyncCallback<number>): void 获取壁纸的最小宽度值。 -**系统能力**: SystemCapability.MiscServices.Wallpaper +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getMinWidthSync9+](#wallpapergetminwidthsync9)代替。 +> +> 从 API version 7开始支持。 +**系统能力**: SystemCapability.MiscServices.Wallpaper **参数:** @@ -232,6 +339,11 @@ getMinWidth(): Promise<number> 获取壁纸的最小宽度值。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getMinWidthSync9+](#wallpapergetminwidthsync9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.Wallpaper **返回值:** @@ -251,12 +363,38 @@ getMinWidth(): Promise<number> ``` +## wallpaper.getMinWidthSync9+ + +getMinWidthSync(): number + +获取壁纸的最小宽度值。 + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | number | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | + +**示例:** + + ```js + var minWidth = wallpaper.getMinWidthSync(); + ``` + + ## wallpaper.isChangePermitted isChangePermitted(callback: AsyncCallback<boolean>): void 是否允许应用改变当前用户的壁纸。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.isChangeAllowed9+](#wallpaperischangeallowed9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.Wallpaper **参数:** @@ -284,6 +422,11 @@ isChangePermitted(): Promise<boolean> 是否允许应用改变当前用户的壁纸。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.isChangeAllowed9+](#wallpaperischangeallowed9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.Wallpaper **返回值:** @@ -303,12 +446,38 @@ isChangePermitted(): Promise<boolean> ``` +## wallpaper.isChangeAllowed9+ + +isChangeAllowed(): boolean + +是否允许应用改变当前用户的壁纸。 + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | + +**示例:** + + ```js + var isChangeAllowed = wallpaper.isChangeAllowed(); + ``` + + ## wallpaper.isOperationAllowed isOperationAllowed(callback: AsyncCallback<boolean>): void 是否允许用户设置壁纸。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.isUserChangeAllowed9+](#wallpaperisuserchangeallowed9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.Wallpaper **参数:** @@ -336,6 +505,11 @@ isOperationAllowed(): Promise<boolean> 是否允许用户设置壁纸。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.isUserChangeAllowed9+](#wallpaperisuserchangeallowed9)代替。 +> +> 从 API version 7开始支持。 + **系统能力**: SystemCapability.MiscServices.Wallpaper **返回值:** @@ -355,12 +529,38 @@ isOperationAllowed(): Promise<boolean> ``` +## wallpaper.isUserChangeAllowed9+ + +isUserChangeAllowed(): boolean + +是否允许用户设置壁纸。 + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | + +**示例:** + + ```js + var isUserChangeAllowed = wallpaper.isUserChangeAllowed(); + ``` + + ## wallpaper.reset reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void 移除指定类型的壁纸,恢复为默认显示的壁纸。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.restore9+](#wallpaperrestore9)代替。 +> +> 从 API version 7开始支持。 + **需要权限**:ohos.permission.SET_WALLPAPER **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -391,6 +591,11 @@ reset(wallpaperType: WallpaperType): Promise<void> 移除指定类型的壁纸,恢复为默认显示的壁纸。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.restore9+](#wallpaperrestore9)代替。 +> +> 从 API version 7开始支持。 + **需要权限**:ohos.permission.SET_WALLPAPER **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -418,12 +623,80 @@ reset(wallpaperType: WallpaperType): Promise<void> ``` +## wallpaper.restore9+ + +restore(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void + +移除指定类型的壁纸,恢复为默认显示的壁纸。 + +**需要权限**:ohos.permission.SET_WALLPAPER + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | + +**示例:** + + ```js + wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to restore because: ` + JSON.stringify(error)); + return; + } + console.log(`success to restore.`); + }); + ``` + + +## wallpaper.restore9+ + +restore(wallpaperType: WallpaperType): Promise<void> + +移除指定类型的壁纸,恢复为默认显示的壁纸。 + +**需要权限**:ohos.permission.SET_WALLPAPER + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | + +**示例:** + + ```js + wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to restore.`); + }).catch((error) => { + console.error(`failed to restore because: ` + JSON.stringify(error)); + }); + ``` + + ## wallpaper.setWallpaper setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void 将指定资源设置为指定类型的壁纸。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.setImage9+](#wallpapersetimage9)代替。 +> +> 从 API version 7开始支持。 + **需要权限**:ohos.permission.SET_WALLPAPER **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -478,6 +751,11 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro 将指定资源设置为指定类型的壁纸。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.setImage9+](#wallpapersetimage9)代替。 +> +> 从 API version 7开始支持。 + **需要权限**:ohos.permission.SET_WALLPAPER **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -526,12 +804,127 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro }); ``` + +## wallpaper.setImage9+ + +setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void + +将指定资源设置为指定类型的壁纸。 + +**需要权限**:ohos.permission.SET_WALLPAPER + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | source | string \|[PixelMap](js-apis-image.md#pixelmap7) | | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是返回设置的结果,调用失败则返回error信息。 | + +**示例:** + + ```js + // source类型为string + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to setImage because: ` + JSON.stringify(error)); + return; + } + console.log(`success to setImage.`); + }); + + // source类型为image.PixelMap + import image from '@ohos.multimedia.image'; + let imageSource = image.createImageSource("file://" + wallpaperPath); + let opts = { + "desiredSize": { + "height": 3648, + "width": 2736 + } + }; + imageSource.createPixelMap(opts).then((pixelMap) => { + wallpaper.setImage(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to setImage because: ` + JSON.stringify(error)); + return; + } + console.log(`success to setImage.`); + }); + }).catch((error) => { + console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.setImage9+ + +setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void> + +将指定资源设置为指定类型的壁纸。 + +**需要权限**:ohos.permission.SET_WALLPAPER + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | source | string \|[PixelMap](js-apis-image.md#pixelmap7) | 是 | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 | + +**示例:** + + ```js + // source类型为string + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to setImage.`); + }).catch((error) => { + console.error(`failed to setImage because: ` + JSON.stringify(error)); + }); + + // source类型为image.PixelMap + import image from '@ohos.multimedia.image'; + let imageSource = image.createImageSource("file://" + wallpaperPath); + let opts = { + "desiredSize": { + "height": 3648, + "width": 2736 + } + }; + imageSource.createPixelMap(opts).then((pixelMap) => { + wallpaper.setImage(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to setImage.`); + }).catch((error) => { + console.error(`failed to setImage because: ` + JSON.stringify(error)); + }); + }).catch((error) => { + console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); + }); + ``` + + ## wallpaper.getFile8+ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void 获取指定类型的壁纸文件。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getFileSync9+](#wallpapergetfilesync9)代替。 +> +> 从 API version 8开始支持。 + **需要权限**:ohos.permission.GET_WALLPAPER **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -561,6 +954,11 @@ getFile(wallpaperType: WallpaperType): Promise<number> 获取指定类型的壁纸文件。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getFileSync9+](#wallpapergetfilesync9)代替。 +> +> 从 API version 8开始支持。 + **需要权限**:ohos.permission.GET_WALLPAPER **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -588,12 +986,46 @@ getFile(wallpaperType: WallpaperType): Promise<number> ``` +## wallpaper.getFileSync9+ + +getFileSync(wallpaperType: WallpaperType): number; + +获取指定类型的壁纸文件。 + +**需要权限**:ohos.permission.GET_WALLPAPER + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | number | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | + +**示例:** + + ```js + var file = wallpaper.getFileSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM); + ``` + + ## wallpaper.getPixelMap getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void; 获取壁纸图片的像素图。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getImage9+](#wallpapergetimage9)代替。 +> +> 从 API version 7开始支持。 + **需要权限**:ohos.permission.GET_WALLPAPER **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -623,6 +1055,11 @@ getPixelMap(wallpaperType: WallpaperType): Promise<image.PixelMap> 获取壁纸图片的像素图。 +> **说明:** +> 从API version 9开始废弃。建议使用[wallpaper.getImage9+](#wallpapergetimage9)代替。 +> +> 从 API version 7开始支持。 + **需要权限**:ohos.permission.GET_WALLPAPER **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -654,7 +1091,73 @@ getPixelMap(wallpaperType: WallpaperType): Promise<image.PixelMap> ``` -## wallpaper.on('colorChange') +## wallpaper.getImage9+ + +getImage(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void; + +获取壁纸图片的像素图。 + +**需要权限**:ohos.permission.GET_WALLPAPER + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**系统接口**:此接口为系统接口,三方应用不支持调用。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回壁纸图片的像素图大小,调用失败则返回error信息。 | + +**示例:** + + ```js + wallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM, function (err, data) { + console.info('wallpaperXTS ===> testgetImageCallbackSystem err : ' + JSON.stringify(err)); + console.info('wallpaperXTS ===> testgetImageCallbackSystem data : ' + JSON.stringify(data)); + }); + ``` + + +## wallpaper.getImage9+ + +getImage(wallpaperType: WallpaperType): Promise<image.PixelMap> + +获取壁纸图片的像素图。 + +**需要权限**:ohos.permission.GET_WALLPAPER + +**系统能力**: SystemCapability.MiscServices.Wallpaper + +**系统接口**:此接口为系统接口,三方应用不支持调用。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 调用成功则返回壁纸图片的像素图大小,调用失败则返回error信息。 | + +**示例:** + + ```js + wallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.info('wallpaperXTS ===> testgetImagePromiseSystem data : ' + data); + console.info('wallpaperXTS ===> testgetImagePromiseSystem data : ' + JSON.stringify(data)); + }).catch((err) => { + console.info('wallpaperXTS ===> testgetImagePromiseSystem err : ' + err); + console.info('wallpaperXTS ===> testgetImagePromiseSystem err : ' + JSON.stringify(err)); + }); + ``` + + +## wallpaper.on('colorChange')9+ on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void @@ -679,7 +1182,7 @@ on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType ``` -## wallpaper.off('colorChange') +## wallpaper.off('colorChange')9+ off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-piece.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-piece.md index 9e443a8bcf848efe396b10fcdb535aa88efe45be..11e62d888d0296e315826919c7d0ecb1920c970e 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-piece.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-piece.md @@ -1,10 +1,10 @@ # piece + 一种块状的入口,可包含图片和文本,常用于展示收件人。例如,邮件收件人或信息收件人。 + > **说明:** > 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -一种块状的入口,可包含图片和文本。常用于展示收件人,例如:邮件收件人或信息收件人。 - ## 子组件 @@ -15,11 +15,11 @@ 除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | ------- | ----- | ---- | ---------------------------------------- | -| content | string | - | 是 | 操作块文本内容。 | -| closable | boolean | false | 否 | 设置当前操作块是否显示删除图标,当显示删除图标时,点击删除图标会触发close事件。 | -| icon | string | - | 否 | 操作块删除图标的url,支持本地路径。 | +| 名称 | 类型 | 必填 | 描述 | +| -------- | ------- | ---- | ------------------------------------------------------------ | +| content | string | 是 | 操作块文本内容。 | +| closable | boolean | 否 | 设置当前操作块是否显示删除图标,当显示删除图标时,点击删除图标会触发close事件。
默认值:false | +| icon | string | 否 | 操作块删除图标的url,支持本地路径。 | ## 样式 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-span.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-span.md index 571a6dd406cb32dbe063708a03813b6eae3edee9..36bd2cae87bb31384245bd8f0bb9ace33d35f7a2 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-span.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-span.md @@ -12,7 +12,7 @@ ## 子组件 -支持子组件<span>。 +无 ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-toggle.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-toggle.md index 73eaf9b433414210b8c935c8f4452199fb578c30..45704a321874f48f2ff3ef4b5b7b9fe64c2e4ff2 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-toggle.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-toggle.md @@ -81,34 +81,51 @@ ```js // xxx.js export default { - data: { - toggle_list: [ - { "id":"1001", "name":"Living room", "checked":true }, - { "id":"1002", "name":"Bedroom", "checked":false }, - { "id":"1003", "name":"Second bedroom", "checked":false }, - { "id":"1004", "name":"Kitchen", "checked":false }, - { "id":"1005", "name":"Study", "checked":false }, - { "id":"1006", "name":"Garden", "checked":false }, - { "id":"1007", "name":"Bathroom", "checked":false }, - { "id":"1008", "name":"Balcony", "checked":false }, - ], - toggles: ["Living room","Bedroom","Kitchen","Study"], - idx: "" - }, - allclick(arg) { - this.idx = arg - }, - allchange(e) { - if (e.checked === true) { - for (var i = 0; i < this.toggle_list.length; i++) { - if (this.toggle_list[i].id === this.idx) { - this.toggle_list[i].checked = true - } else { - this.toggle_list[i].checked = false + data: { + toggle_list: [ + { + "id": "1001", "name": "Living room", "checked": true + }, + { + "id": "1002", "name": "Bedroom", "checked": false + }, + { + "id": "1003", "name": "Second bedroom", "checked": false + }, + { + "id": "1004", "name": "Kitchen", "checked": false + }, + { + "id": "1005", "name": "Study", "checked": false + }, + { + "id": "1006", "name": "Garden", "checked": false + }, + { + "id": "1007", "name": "Bathroom", "checked": false + }, + { + "id": "1008", "name": "Balcony", "checked": false + }, + ], + toggles: ["Living room", "Bedroom", "Kitchen", "Study"], + idx: "" + }, + allclick(arg) { + this.idx = arg; + }, + allchange(e) { + if (e.checked != true) { + return; + } + for (var i = 0; i < this.toggle_list.length; i++) { + if (this.toggle_list[i].id === this.idx) { + this.toggle_list[i].checked = true; + } else { + this.toggle_list[i].checked = false; + } } - } } - } } ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md index 14d552170a6fb1f46431b0bff81b55d68a67cddd..66ef1e82c5de238a67fde97adea3dc5ad6297ba2 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md @@ -3,7 +3,7 @@ > **说明:** > 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -工具栏子组件。作为工具栏组件的子组件,用于展示工具栏上的一个操作选项。 +工具栏[toolbar](js-components-basic-toolbar.md)子组件。 用于展示工具栏上的一个操作选项。 ## 子组件 @@ -59,13 +59,13 @@ ```html - - - - - - - + + + + + + + ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-dialog.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-dialog.md index 699830dde1cb148307e3217fc51adbcf7e27e103..0841767ae2a054395cef5e0567b88ff60124b6e5 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-dialog.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-dialog.md @@ -132,27 +132,27 @@ // xxx.js import prompt from '@system.prompt'; export default { - showDialog(e) { + showDialog() { this.$element('simpledialog').show() }, - cancelDialog(e) { + cancelDialog() { prompt.showToast({ message: 'Dialog cancelled' }) }, - cancelSchedule(e) { + cancelSchedule() { this.$element('simpledialog').close() prompt.showToast({ message: 'Successfully cancelled' }) }, - setSchedule(e) { + setSchedule() { this.$element('simpledialog').close() prompt.showToast({ message: 'Successfully confirmed' }) }, - doubleclick(e){ + doubleclick(){ prompt.showToast({ message: 'doubleclick' }) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-swiper.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-swiper.md index 031a2d0c9a8a8a10c38d31db839304c52f899d92..c0db6e8c9ce3668558a09d4c6ffbc888d1b5d769 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-swiper.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-swiper.md @@ -12,7 +12,7 @@ ## 子组件 -支持除<list>之外的子组件。 +可以包含子组件。 ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/focus.png b/zh-cn/application-dev/reference/arkui-ts/figures/focus.png index 217dcfbca0de33adef4ffa0d90fd167192845c3c..dcd16fbecdce07e04721915ff9d9777590d39e7a 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/focus.png and b/zh-cn/application-dev/reference/arkui-ts/figures/focus.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/keyEvent.png b/zh-cn/application-dev/reference/arkui-ts/figures/keyEvent.png new file mode 100644 index 0000000000000000000000000000000000000000..defa53e2581a56c7fb0933d85c0ce1578ebbfd48 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/keyEvent.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/mouse.png b/zh-cn/application-dev/reference/arkui-ts/figures/mouse.png new file mode 100644 index 0000000000000000000000000000000000000000..28baf4e713b69b4bea0e9ed3498a4a2ce12fc2b3 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/mouse.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/mouse1.png b/zh-cn/application-dev/reference/arkui-ts/figures/mouse1.png new file mode 100644 index 0000000000000000000000000000000000000000..dc3ea1fb958f1de66f6310e22b6163ebfbfb7494 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/mouse1.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/progress.png b/zh-cn/application-dev/reference/arkui-ts/figures/progress.png new file mode 100644 index 0000000000000000000000000000000000000000..d50f4b47628b425b09f93bc9a44853ad79e12631 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/progress.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/qrcode.png b/zh-cn/application-dev/reference/arkui-ts/figures/qrcode.png new file mode 100644 index 0000000000000000000000000000000000000000..762c952314fc6e52bbbc0ae55565422c40d05ff0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/qrcode.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/richText.png b/zh-cn/application-dev/reference/arkui-ts/figures/richText.png new file mode 100644 index 0000000000000000000000000000000000000000..1520a854a9baed9fcc4e50e989bbfb4e83acf487 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/richText.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/span.png b/zh-cn/application-dev/reference/arkui-ts/figures/span.png new file mode 100644 index 0000000000000000000000000000000000000000..881f4945dac79e31cb9f11216a682110de4efec7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/span.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/text_clock.gif b/zh-cn/application-dev/reference/arkui-ts/figures/text_clock.gif new file mode 100644 index 0000000000000000000000000000000000000000..29a32d79a14fbcf8a27f6e27fc3fa226a2b83446 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/text_clock.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/text_clock.png b/zh-cn/application-dev/reference/arkui-ts/figures/text_clock.png deleted file mode 100644 index 7d8b74289c00f8d8cc8e53482a96bf3281c841e3..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/text_clock.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194192458.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194192458.png deleted file mode 100644 index 5da42e3e14d601745274cb62d914c6600620bb25..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194192458.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001198839004.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001198839004.gif deleted file mode 100644 index b0667769e77a2a2d1b131736bdce96489b7e064e..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001198839004.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001209874754.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001209874754.gif index f0962619f5df0fec543cd693195045c9203378d9..e83d5b33f9b10e586aa2288f6271c51fd79fab47 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001209874754.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001209874754.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001210353788.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001210353788.gif index b8a7961adce1b592b8fdbce98966c70cf1da68e8..38ffa5ca3c66dc3852f3a6045789473e8bdb0c41 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001210353788.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001210353788.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662669.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662669.png deleted file mode 100644 index 6b2c6040690cebf054da6dbc70c87d14c82be9d6..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662669.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864151.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864151.gif index c18ae783333765788db1b8bf6107ee0c117ec9e6..4edf113bcfe487f1b10ddd123dfdbb3ab612af92 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864151.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864151.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982709.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982709.gif deleted file mode 100644 index 3a2f5de773fed90a3c0c058d0b27bc0edd1f1904..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982709.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238952377.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238952377.png index 5da42e3e14d601745274cb62d914c6600620bb25..eb03ebe25132eb551b633d052cdfc984eda432ee 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238952377.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238952377.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252667389.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252667389.gif index a5092180309ecb061248cc205e4bd667eb290085..198227c0282462bfb34f5363a7996a6817e1bb83 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252667389.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252667389.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md b/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md index 329c83c73eb406fe0966045f16d2152ecffdfbb4..2990e52994591116ad439fa1badab3263d490c31 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md @@ -221,9 +221,9 @@ | 名称 | 描述 | | ------ | -------------------- | -| Butt | 分割线两端为平行线,不额外扩展。 | -| Round | 在分割线两端延伸半个圆,直径等于线宽。 | -| Square | 在分割线两端延伸一个矩形,宽度等于线宽的一半,高度等于线宽。 | +| Butt | 线条两端为平行线,不额外扩展。 | +| Round | 在线条两端延伸半个圆,直径等于线宽。 | +| Square | 在线条两端延伸一个矩形,宽度等于线宽的一半,高度等于线宽。 | ## Axis diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md index 0b92ea63cfb6046805b13c61dc574e7c4f599b36..072bc49476ee62742a065c60dd766618e40dbb4f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -27,7 +27,7 @@ Image(src: string | PixelMap | Resource) | 参数名 | 参数类型 | 必填 | 参数描述 | | ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource类型) | 是 | 图片的数据源,支持本地图片和网络图片。
当使用相对路径引用图片资源时,例如`Image("common/test.jpg")`,不支持跨包/跨模块调用该Image组件,建议使用`$r`方式来管理需全局使用的图片资源。
\- 支持的图片格式包括png、jpg、bmp、svg和gif。
\- 支持`Base64`字符串。格式`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, 其中`[base64 data]`为`Base64`字符串数据。
\- 支持`dataability://`路径前缀的字符串,用于访问通过data ability提供的图片路径。 | +| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource类型) | 是 | 图片的数据源,支持本地图片和网络图片。
当使用相对路径引用图片资源时,例如`Image("common/test.jpg")`,不支持跨包/跨模块调用该Image组件,建议使用`$r`方式来管理需全局使用的图片资源。
\- 支持的图片格式包括png、jpg、bmp、svg和gif。
\- 支持`Base64`字符串。格式`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, 其中`[base64 data]`为`Base64`字符串数据。
\- 支持`dataability://`路径前缀的字符串,用于访问通过data ability提供的图片路径。
\- 支持file:///data/storage路径前缀的字符串,用于读取本应用安装目录下files文件夹下的图片资源。需要保证目录包路径下的文件有可读权限。 | ## 属性 @@ -348,3 +348,53 @@ struct ImageExample3 { ``` ![zh-cn_image_0000001205972610](figures/zh-cn_image_0000001205972610.gif) + +### 渲染沙箱路径图片 + +``` +import fileio from '@ohos.fileio'; +import image from '@ohos.multimedia.image'; + +const EMPTY_PATH = 'file://'; + +@Entry +@Component +struct LoadImageExample { + @State fileContent: string = ''; + @State path: string = EMPTY_PATH; + @State accountInfoHeadPic: any = ''; + + build() { + Column() { + Button('读取沙箱图片') + .margin({ bottom: 10 }) + .onClick(() => { + try { + this.path = EMPTY_PATH; + let context = getContext(this); + let path = context.getApplicationContext().filesDir + '/icon.png'; + console.log(`读取沙箱图片=========>${path}`); + let fd = fileio.openSync(path, 0o100, 0o666); + console.log(`create file========>${fd}`); + let srcPath = context.bundleCodeDir + '/entry/resource/base/media/icon.png'; + fileio.copyFileSync(srcPath, path); + console.log(`error:=============>${e.message}`); + } + }) + Button('读取资源图片') + .margin({ bottom: 10 }) + .onClick(() => { + this.path = EMPTY_PATH; + this.path += getContext(this.bundleCodeDir + '/entry/resource/base/media/icon.png'); + }) + Text(`图片路径:${this.path}`) + .fontSize(20) + .margin({ bottom: 10 }) + Image(this.path) + .width(100) + .height(100) + } + .width('100%').height('100%') + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md index a63597995da88faff74e34b651112403052943df..9c21ba142bb83e9a3a8c4443ea8d074dd0041d79 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md @@ -26,12 +26,12 @@ Navigation() | -------------- | ---------------------------------------- | ---------------------------------------- | | title | string \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 页面标题。 | | subTitle | string | 页面副标题。 | -| menus | Array8+ | 页面右上角菜单。 | -| titleMode | NavigationTitleMode | 页面标题栏显示模式。
默认值:NavigationTitleMode.Free | -| toolBar | object \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 设置工具栏内容。
items: 工具栏所有项。 | -| hideToolBar | boolean | 设置隐藏/显示工具栏:
默认值:false
true: 隐藏工具栏。
false: 显示工具栏。 | -| hideTitleBar | boolean | 隐藏标题栏。
默认值:false | -| hideBackButton | boolean | 隐藏返回键。
默认值:false | +| menus | Array<[NavigationMenuItem](#navigationmenuitem类型说明)> \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 页面右上角菜单。 | +| titleMode | [NavigationTitleMode](#navigationtitlemode枚举说明) | 页面标题栏显示模式。
默认值:NavigationTitleMode.Free | +| toolBar | [object](#object类型说明) \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 设置工具栏内容。
items: 工具栏所有项。 | +| hideToolBar | boolean | 隐藏工具栏:
默认值:false
true: 隐藏工具栏。
false: 显示工具栏。 | +| hideTitleBar | boolean | 隐藏标题栏。
默认值:false
true: 隐藏标题栏。
false: 显示标题栏。 | +| hideBackButton | boolean | 隐藏返回键。
默认值:false
true: 隐藏返回键。
false: 显示返回键。 | ## NavigationMenuItem类型说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md index ec2692af803ac6bc4ced019989151a3d409177d1..cfc96d3bab0785f3be04d14b64efe2e12cbf4203 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md @@ -12,7 +12,7 @@ 无 -## 接口说明 +## 接口 Progress(options: {value: number, total?: number, type?: ProgressType}) @@ -24,8 +24,8 @@ Progress(options: {value: number, total?: number, type?: ProgressType}) | -------- | -------- | -------- | -------- | | value | number | 是 | 指定当前进度值。 | | total | number | 否 | 指定进度总长。
默认值:100 | -| type8+ | ProgressType | 否 | 指定进度条样式。
默认值:ProgressType.Linear | -| styledeprecated | ProgressStyle | 否 | 指定进度条类型。
该参数从API Version8开始废弃,建议使用type替代。
默认值:ProgressStyle.Linear | +| type8+ | [ProgressType](#progresstype枚举说明) | 否 | 指定进度条类型。
默认值:ProgressType.Linear | +| styledeprecated | [ProgressStyle](#progressstyle枚举说明) | 否 | 指定进度条样式。
该参数从API Version8开始废弃,建议使用type替代。
默认值:ProgressStyle.Linear | ## ProgressType枚举说明 @@ -69,6 +69,7 @@ struct ProgressExample { Progress({ value: 10, type: ProgressType.Linear }).width(200) Progress({ value: 20, total: 150, type: ProgressType.Linear }).color(Color.Grey).value(50).width(200) + Text('Eclipse Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') Row({ space: 40 }) { Progress({ value: 10, type: ProgressType.Eclipse }).width(100) @@ -83,6 +84,16 @@ struct ProgressExample { .style({ strokeWidth: 15, scaleCount: 15, scaleWidth: 5 }) } + // scaleCount和scaleWidth效果对比 + Row({ space: 40 }) { + Progress({ value: 20, total: 150, type: ProgressType.ScaleRing }) + .color(Color.Grey).value(50).width(100) + .style({ strokeWidth: 20, scaleCount: 20, scaleWidth: 5 }) + Progress({ value: 20, total: 150, type: ProgressType.ScaleRing }) + .color(Color.Grey).value(50).width(100) + .style({ strokeWidth: 20, scaleCount: 30, scaleWidth: 3 }) + } + Text('Ring Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') Row({ space: 40 }) { Progress({ value: 10, type: ProgressType.Ring }).width(100) @@ -105,4 +116,4 @@ struct ProgressExample { } ``` -![zh-cn_image_0000001198839004](figures/zh-cn_image_0000001198839004.gif) +![progress](figures/progress.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md index 259600117c3d8b53a05ca3c302d72aa60f21d4b6..d029ffdc31014f2046db268c33cc81917b2d783a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md @@ -44,17 +44,21 @@ QRCode(value: string) @Component struct QRCodeExample { private value: string = 'hello world' - build() { Column({ space: 5 }) { - Text('normal').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text('normal').fontSize(9).width('90%').fontColor(0xCCCCCC).fontSize(30) QRCode(this.value).width(200).height(200) - Text('color').fontSize(9).width('90%').fontColor(0xCCCCCC) + // 设置二维码颜色 + Text('color').fontSize(9).width('90%').fontColor(0xCCCCCC).fontSize(30) QRCode(this.value).color(0xF7CE00).width(200).height(200) + + // 设置二维码背景色 + Text('backgroundColor').fontSize(9).width('90%').fontColor(0xCCCCCC).fontSize(30) + QRCode(this.value).width(200).height(200).backgroundColor(Color.Orange) }.width('100%').margin({ top: 5 }) } } ``` -![zh-cn_image_0000001219662669](figures/zh-cn_image_0000001219662669.png) +![qrcode](figures/qrcode.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md index 1ac29d0fe113890b4565a0fa235c2e4307c521fc..2bc0322f27d016b6d0ae55eec0dcde7cf8f11e07 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md @@ -79,4 +79,6 @@ struct RichTextExample { } } } -``` \ No newline at end of file +``` + + ![richText](figures/richText.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md index 3aa51016e0caf1597f5cd214dbdff9a909a3d169..59ea8bf4922847804e96d2dad708696fb5885d85 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md @@ -21,7 +21,7 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | | scroller | [Scroller](ts-container-scroll.md#scroller) | 是 | 可滚动组件的控制器。用于与可滚动组件进行绑定。 | -| direction | ScrollBarDirection | 否 | 滚动条的方向,控制可滚动组件对应方向的滚动。
默认值:ScrollBarDirection.Vertical | +| direction | [ScrollBarDirection](#scrollbardirection枚举说明) | 否 | 滚动条的方向,控制可滚动组件对应方向的滚动。
默认值:ScrollBarDirection.Vertical | | state | [BarState](ts-appendix-enums.md#barstate) | 否 | 滚动条状态。
默认值:BarState.Auto | > **说明:** diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md index 7066a306eaf8f8339d0195d603cf15e42842b624..055451e0feea7c6140d477b19e42ed09a352c661 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md @@ -12,9 +12,9 @@ ## 接口 -Select(options: Array\) +Select(options: Array\<[SelectOption](#selectoption对象说明)\>) -**SelectOption对象说明:** +## SelectOption对象说明 | 参数名 | 参数类型 | 必填 | 参数描述 | | ------ | ----------------------------------- | ---- | -------------- | @@ -26,7 +26,7 @@ Select(options: Array\) | 名称 | 参数类型 | 描述 | | ----------------------- | ------------------------------------- | --------------------------------------------- | | selected | number | 设置下拉菜单初始选项的索引,第一项的索引为0。 | -| value | string | 设置下拉按钮本身的文本显示。 | +| value | string | 设置下拉按钮本身的文本内容。 | | font | [Font](ts-types.md#font) | 设置下拉按钮本身的文本样式。 | | fontColor | [ResourceColor](ts-types.md#resourcecolor) | 设置下拉按钮本身的文本颜色。 | | selectedOptionBgColor | [ResourceColor](ts-types.md#resourcecolor) | 设置下拉菜单选中项的背景色。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md index d61c7802db72149e6a10d510992ceab2823ce4d3..0aa1c8acede3ba6135fd598ac4dc86f4ed43ba4f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md @@ -56,7 +56,7 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty | 名称 | 功能描述 | | -------- | -------- | -| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Slider滑动时触发事件回调。
value:当前进度值。
mode:拖动状态。 | +| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Slider滑动时触发事件回调。
value:当前进度值。若返回值有小数,可使用Math.toFixed()将数据处理为想要的精度。
mode:拖动状态。 | ## SliderChangeMode枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md index 2cfe30907a56df7f1d8a994c4b85638df3b401c9..5e615e7033fbe11e87ff2746df9547684a56f2d9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md @@ -30,7 +30,7 @@ Span(value: string | Resource) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),
color?: [ResourceColor](ts-types.md#resourcecolor)
} | 设置文本装饰线样式及其颜色。
默认值:{
type: TextDecorationType.None
color:Color.Black
} | -| letterSpacing | number \| string | 设置文本字符间距。 | +| letterSpacing | number \| string | 设置文本字符间距。取值小于0,字符聚集重叠,取值大于0且随着数值变大,字符间距越来越大,稀疏分布。 | | textCase | [TextCase](ts-appendix-enums.md#textcase) | 设置文本大小写。
默认值:TextCase.Normal | @@ -58,29 +58,59 @@ struct SpanExample { .decoration({ type: TextDecorationType.None, color: Color.Red }) } + // 文本横线添加 Text('Text Decoration').fontSize(9).fontColor(0xCCCCCC) Text() { Span('I am Underline-span').decoration({ type: TextDecorationType.Underline, color: Color.Red }).fontSize(12) } + Text() { - Span('I am LineThrough-span').decoration({ type: TextDecorationType.LineThrough, color: Color.Red }).fontSize(12) + Span('I am LineThrough-span') + .decoration({ type: TextDecorationType.LineThrough, color: Color.Red }) + .fontSize(12) } + Text() { Span('I am Overline-span').decoration({ type: TextDecorationType.Overline, color: Color.Red }).fontSize(12) } + // 文本字符间距 + Text('LetterSpacing').fontSize(9).fontColor(0xCCCCCC) + Text() { + Span('span letter spacing') + .letterSpacing(0) + .fontSize(12) + } + + Text() { + Span('span letter spacing') + .letterSpacing(-2) + .fontSize(12) + } + + Text() { + Span('span letter spacing') + .letterSpacing(3) + .fontSize(12) + } + + + // 文本大小写展示设置 Text('Text Case').fontSize(9).fontColor(0xCCCCCC) Text() { - Span('I am Lower-span').textCase(TextCase.LowerCase).fontSize(12) - .decoration({ type: TextDecorationType.None, color: Color.Red }) + Span('I am Lower-span').fontSize(12) + .textCase(TextCase.LowerCase) + .decoration({ type: TextDecorationType.None }) } + Text() { - Span('I am Upper-span').textCase(TextCase.UpperCase).fontSize(12) - .decoration({ type: TextDecorationType.None, color: Color.Red }) + Span('I am Upper-span').fontSize(12) + .textCase(TextCase.UpperCase) + .decoration({ type: TextDecorationType.None }) } }.width('100%').height(250).padding({ left: 35, right: 35, top: 35 }) } } ``` -![zh-cn_image_0000001219982709](figures/zh-cn_image_0000001219982709.gif) +![span](figures/span.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md index 32e8ab5facd0d88692571b27af2399c05acf5a7a..3362e271b8c4e1f03dfef68bbb857bfa6df00d76 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -32,7 +32,7 @@ Text(content?: string | Resource) | textOverflow | {overflow: [TextOverflow](ts-appendix-enums.md#textoverflow)} | 设置文本超长时的显示方式。
默认值:{overflow: TextOverflow.Clip}
**说明:**
文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格:\u200B。
需配合`maxLines`使用,单独设置不生效。 | | maxLines | number | 设置文本的最大行数。
默认值:Infinity
**说明:**
默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过 `textOverflow`来指定截断方式。 | | lineHeight | string \| number \| [Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。 | -| decoration | {
type: TextDecorationType,
color?: [ResourceColor](ts-types.md#resourcecolor)
} | 设置文本装饰线样式及其颜色。
默认值:{
type: TextDecorationType.None,
color:Color.Black
} | +| decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),
color?: [ResourceColor](ts-types.md#resourcecolor)
} | 设置文本装饰线样式及其颜色。
默认值:{
type: TextDecorationType.None,
color:Color.Black
} | | baselineOffset | number \| string | 设置文本基线的偏移量。 | | letterSpacing | number \| string | 设置文本字符间距。 | | minFontSize | number \| string \| [Resource](ts-types.md#resource) | 设置文本最小显示字号。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md index 0820f1f4ad8e758cd1432aab55f9f2b549c0c514..675e57599dbb993dffb2e2f29bc9fd3b65b0636c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md @@ -21,30 +21,15 @@ TextClock(options?: { timeZoneOffset?: number, controller?: TextClockController | timeZoneOffset | number | 否 | 设置时区偏移量。
取值范围为[-14, 12],表示东十二区到西十二区,其中负值表示东时区,正值表示西时区,比如东八区为-8。
对横跨国际日界线的国家或地区,用-13(UTC+13)和-14(UTC+14)来保证整个国家或者区域处在相同的时间,当设置的值不在取值范围内时,将使用当前系统的时区偏移量。
默认值:当前系统的时区偏移量 | | controller | [TextClockController](#textclockcontroller) | 否 | 绑定一个控制器,用来控制文本时钟的状态。| -## 属性 - -除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: - -| 名称 | 参数类型 | 描述 | -| ------ | --------------- | ------------------------------------------------------------ | -| format | string | 设置显示时间格式。
日期间隔符固定为"/",时间间隔符为":"。
如yyyyMMdd,yyyy-MM-dd显示为yyyy/MM/dd,
hhmmss显示为hh:mm:ss。
时间格式只用写一位即可,如"hhmmss"等同于"hms"。
支持的时间格式化字符串:
- YYYY/yyyy:完整年份。
- YY/yy:年份后两位。
- M:月份(若想使用01月则使用MM)。
- d:日期(若想使用01日则使用dd)。
- D:年中日(一年中的第几天)。
- H:24小时制。
- h:12小时制。
- m:分钟。
- s:秒。
- SSS:毫秒。
默认值: 'hms'| - -## 事件 - -除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: - -| 名称 | 功能描述 | -| -------------------------------------------- | ------------------------------------------------------------ | -| onDateChange(event: (value: number) => void) | 提供时间变化回调,该事件最小回调间隔为秒。
- value: Unix Time Stamp,即自1970年1月1日(UTC)起经过的毫秒数。 | ## TextClockController -TextClock容器组件的控制器,可以将此对象绑定到TextClock组件,再通过它控制文本时钟的启动与停止。一个TextClock组件仅支持绑定一个控制器。 +TextClock容器组件的控制器,可以将该控制器绑定到TextClock组件,通过它控制文本时钟的启动与停止。一个TextClock组件仅支持绑定一个控制器。 ### 导入对象 ```ts -controller: TextClockController = new TextClockController() +controller: TextClockController = new TextClockController(); ``` ### start @@ -60,15 +45,32 @@ stop() 停止文本时钟。 +## 属性 + +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + +| 名称 | 参数类型 | 描述 | +| ------ | --------------- | ------------------------------------------------------------ | +| format | string | 设置显示时间格式。
日期间隔符固定为"/",时间间隔符为":"。
如yyyyMMdd,yyyy-MM-dd显示为yyyy/MM/dd,
hhmmss显示为hh:mm:ss。
时间格式只用写一位即可,如"hhmmss"等同于"hms"。
支持的时间格式化字符串:
- YYYY/yyyy:完整年份。
- YY/yy:年份后两位。
- M:月份(若想使用01月则使用MM)。
- d:日期(若想使用01日则使用dd)。
- D:年中日(一年中的第几天)。
- H:24小时制。
- h:12小时制。
- m:分钟。
- s:秒。
- SSS:毫秒。
默认值: 'hms'| + +## 事件 + +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + +| 名称 | 功能描述 | +| -------------------------------------------- | ------------------------------------------------------------ | +| onDateChange(event: (value: number) => void) | 提供时间变化回调,该事件最小回调间隔为秒。
value: Unix Time Stamp,即自1970年1月1日(UTC)起经过的毫秒数。 | + + ## 示例 ```ts @Entry @Component struct Second { - @State accumulateTime: number = 0 - controller: TextClockController = new TextClockController() - + @State accumulateTime: number = 0; + // 导入对象 + controller: TextClockController = new TextClockController(); build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text('Current milliseconds is ' + this.accumulateTime) @@ -77,18 +79,20 @@ struct Second { TextClock({ timeZoneOffset: -8, controller: this.controller }) .format('hms') .onDateChange((value: number) => { - this.accumulateTime = value + this.accumulateTime = value; }) .margin(20) .fontSize(30) Button("start TextClock") .margin({ bottom: 10 }) .onClick(() => { - this.controller.start() + // 启动文本时钟 + this.controller.start(); }) Button("stop TextClock") .onClick(() => { - this.controller.stop() + // 停止文本时钟 + this.controller.stop(); }) } .width('100%') @@ -96,5 +100,5 @@ struct Second { } } ``` -![](figures/text_clock.png) +![text_clock](figures/text_clock.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md index 0f20ae9ed4d76f5c16e5842f027d3dfe316a6360..feea880eb6a5486c8bbf2263ecfdc93bcb520ed6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md @@ -22,9 +22,9 @@ TextPicker(options?: {range: string[]|Resource, selected?: number, value?: strin | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| range | string[] \| [Resource](ts-types.md#resource类型) | 是 | 选择器的数据选择范围。 | -| selected | number | 否 | 选中项在数组中的index值。
默认值:0 | -| value | string | 否 | 选中项的值,优先级低于selected。
默认值:第一个元素值 | +| range | string[] \| [Resource](ts-types.md#resource类型) | 是 | 选择器的数据选择列表。 | +| selected | number | 否 | 设置默认选中项在数组中的index值。
默认值:0 | +| value | string | 否 | 设置默认选中项的值,优先级低于selected。
默认值:第一个元素值 | ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index b8dcfdf87277a8cfc29324f9ef160055e531be4a..a7d649f25f4546fcc44d145429b7a0f25f2ac07e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -771,7 +771,7 @@ clearRect(x: number, y: number, w: number, h: number): void Canvas(this.context) .width('100%') .height('100%') - .backgroundColor('#ffff00') + .backgroundColor('#ffffff') .onReady(() =>{ this.context.fillStyle = 'rgb(0,0,255)' this.context.fillRect(0,0,500,500) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md index 6e444434ff1950e67bdf3ca2ab95498d672e3c8f..30f776153f65ebc24fae112be97eaffe0b276109 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md @@ -21,11 +21,11 @@ ListItemGroup(options?: {header?: CustomBuilder, footer?: CustomBuilder, space?: **参数:** - | 参数名 | 参数类型 | 必填 | 参数描述 | - | -------- | -------- | -------- | -------- | - | header | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 设置ListItemGroup头部组件。 | - | footer | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 设置ListItemGroup尾部组件。 | - | space | number \| string | 否 | 列表项间距。只作用于ListItem与ListItem之间,不作用于header与ListItem、footer与ListItem之间。 | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| header | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 设置ListItemGroup头部组件。 | +| footer | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 设置ListItemGroup尾部组件。 | +| space | number \| string | 否 | 列表项间距。只作用于ListItem与ListItem之间,不作用于header与ListItem、footer与ListItem之间。 | ## 属性 @@ -96,7 +96,7 @@ struct ListItemGroupExample { }, item => item) } .borderRadius(20) - .divider({ strokeWidth: 1, color: Color.Blue) // 每行之间的分界线 + .divider({ strokeWidth: 1, color: Color.Blue }) // 每行之间的分界线 }) } .width('90%') diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md index 8376694073445f0b52b7f283be3a7b44cc2cb1e2..54c51fe6288d6b11bc989f0a1d5e0af02c3ec25f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md @@ -20,7 +20,7 @@ Row(value?:{space?: number | string }) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| space | string \| number | 否 | 横向布局元素间距。
默认值:0 | +| space | string \| number | 否 | 横向布局元素间距。
默认值:0,单位vp | ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md b/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md index 353f6ba375b7e5e05504a7ae0e41460151e4ef0b..dcc4bf1065fbf418faf35acfe9b4392ee82ee600 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md @@ -38,7 +38,7 @@ ## 响应手势事件 -组件通过手势事件绑定不同GestureType的手势对象,各手势对象在响应手势操作的事件回调中提供手势相关信息。下面通过TapGesture手势对象的onAction事件响应点击事件,获取事件相关信息。其余手势对象的事件定义见各个手势对象章节。 +组件通过手势事件绑定不同GestureType的手势对象,各手势对象在响应手势操作的事件回调中提供手势相关信息。下面通过TapGesture手势对象的onAction事件响应点击事件,获取事件相关信息。其余手势对象的事件定义见各个手势对象章节。 若需绑定多种手势请使用 [组合手势](ts-combined-gestures.md)。 - TapGesture事件说明 | 名称 | 功能描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-interpolation-calculation.md b/zh-cn/application-dev/reference/arkui-ts/ts-interpolation-calculation.md index 4c348a725dca9f80c7ba28cd8e27214c7b44f881..f12674493dd658953d876d3f2094ce36e5a5c905 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-interpolation-calculation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-interpolation-calculation.md @@ -24,7 +24,7 @@ initCurve(curve?: Curve):ICurve | 参数名 | 类型 | 必填 | 默认值 | 说明 | | ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | -| curve | [Curve](#curve枚举说明) | 否 | Curve.Linear | 曲线类型。 | +| curve | [Curve](ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | **返回值:** @@ -175,7 +175,7 @@ init(curve?: Curve): string | 参数名 | 类型 | 必填 | 默认值 | 说明 | | ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | -| curve |[Curve](#curve枚举说明) | 否 | Curve.Linear | 曲线类型。 | +| curve |[Curve](ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | ## Curves.steps(deprecated) @@ -226,26 +226,6 @@ spring(velocity: number, mass: number, stiffness: number, damping: number): stri | stiffness | number | 是 | 刚度。是物体抵抗施加的力而形变的程度。在弹性系统中,刚度越大,抵抗变形的能力越强,恢复到平衡位置的速度就越快。 | | damping | number | 是 | 阻尼。是一个纯数,无真实的物理意义,用于描述系统在受到扰动后震荡及衰减的情形。阻尼越大,弹性运动的震荡次数越少、震荡幅度越小。 | - -## Curve枚举说明 - -| 名称 | 描述 | -| ------------------- | ---------------------------------------- | -| Linear | 表示动画从头到尾的速度都是相同的。 | -| Ease | 表示动画以低速开始,然后加快,在结束前变慢,CubicBezier(0.25, 0.1, 0.25, 1.0)。 | -| EaseIn | 表示动画以低速开始,CubicBezier(0.42, 0.0, 1.0, 1.0)。 | -| EaseOut | 表示动画以低速结束,CubicBezier(0.0, 0.0, 0.58, 1.0)。 | -| EaseInOut | 表示动画以低速开始和结束,CubicBezier(0.42, 0.0, 0.58, 1.0)。 | -| FastOutSlowIn | 标准曲线,cubic-bezier(0.4, 0.0, 0.2, 1.0)。 | -| LinearOutSlowIn | 减速曲线,cubic-bezier(0.0, 0.0, 0.2, 1.0)。 | -| FastOutLinearIn | 加速曲线,cubic-bezier(0.4, 0.0, 1.0, 1.0)。 | -| ExtremeDeceleration | 急缓曲线,cubic-bezier(0.0, 0.0, 0.0, 1.0)。 | -| Sharp | 锐利曲线,cubic-bezier(0.33, 0.0, 0.67, 1.0)。 | -| Rhythm | 节奏曲线,cubic-bezier(0.7, 0.0, 0.2, 1.0)。 | -| Smooth | 平滑曲线,cubic-bezier(0.4, 0.0, 0.4, 1.0)。 | -| Friction | 阻尼曲线,CubicBezier(0.2, 0.0, 0.2, 1.0)。 | - - ## 整体示例 ```ts diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md b/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md index 366ba2766ef1cbe2688625dc50de078d422a3d44..43d8e5b727ca19041f0c4f9cfdfdfcae59e3f8a6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md @@ -85,13 +85,13 @@ identity(): Matrix4Transit Matrix的初始化函数,可以返回一个单位矩阵对象。 -**返回值** +**返回值:** | 类型 | 说明 | | -------------- | -------------- | | Matrix4Transit | 单位矩阵对象。 | -**示例** +**示例:** ```ts // matrix1 和 matrix2 效果一致 @@ -128,13 +128,13 @@ copy(): Matrix4Transit Matrix的拷贝函数,可以拷贝一份当前的矩阵对象。 -**返回值** +**返回值:** | 类型 | 说明 | | -------------- | -------------------- | | Matrix4Transit | 当前矩阵的拷贝对象。 | -**示例** +**示例:** ```ts // xxx.ets @@ -180,13 +180,13 @@ Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个 | ------ | ------- | ---- | ------------------ | | matrix | Matrix4 | 是 | 待叠加的矩阵对象。 | -**返回值** +**返回值:** | 类型 | 说明 | | -------------- | ------------------ | | Matrix4Transit | 矩阵叠加后的对象。 | -**示例** +**示例:** ```ts // xxx.ets @@ -225,13 +225,13 @@ invert(): Matrix4Transit Matrix的逆函数,可以返回一个当前矩阵对象的逆矩阵,即效果正好相反。 -**返回值** +**返回值:** | 类型 | 说明 | | -------------- | ---------------------- | | Matrix4Transit | 当前矩阵的逆矩阵对象。 | -**示例** +**示例:** ```ts import matrix4 from '@ohos.matrix4' @@ -266,7 +266,7 @@ translate({x?: number, y?: number, z?: number}): Matrix4Transit Matrix的平移函数,可以为当前矩阵增加x轴/Y轴/Z轴平移效果。 -**参数** +**参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------- | @@ -274,13 +274,13 @@ Matrix的平移函数,可以为当前矩阵增加x轴/Y轴/Z轴平移效果。 | y | number | 否 | y轴的平移距离,单位px。
默认值:0 | | z | number | 否 | z轴的平移距离,单位px。
默认值:0 | -**返回值** +**返回值:** | 类型 | 说明 | | -------------- | ---------------------------- | | Matrix4Transit | 增加好平移效果后的矩阵对象。 | -**示例** +**示例:** ```ts // xxx.ets @@ -320,13 +320,13 @@ Matrix的缩放函数,可以为当前矩阵增加x轴/Y轴/Z轴缩放效果。 | centerX | number | 否 | 变换中心点x轴坐标。
默认值:0 | | centerY | number | 否 | 变换中心点y轴坐标。
默认值:0 | -**返回值** +**返回值:** | 类型 | 说明 | | -------------- | ---------------------------- | | Matrix4Transit | 增加好缩放效果后的矩阵对象。 | -**示例** +**示例:** ```ts // xxx.ets @@ -367,13 +367,13 @@ Matrix的旋转函数,可以为当前矩阵增加x轴/Y轴/Z轴旋转效果。 | centerX | number | 否 | 变换中心点x轴坐标。
默认值:0 | | centerY | number | 否 | 变换中心点y轴坐标。
默认值:0 | -**返回值** +**返回值:** | 类型 | 说明 | | -------------- | ---------------------------- | | Matrix4Transit | 增加好旋转效果后的矩阵对象。 | -**示例** +**示例:** ```ts // xxx.ets @@ -409,13 +409,13 @@ Matrix的坐标点转换函数,可以将当前的变换效果作用到一个 | ------ | ----- | ---- | ------------------ | | point | Point | 是 | 需要转换的坐标点。 | -**返回值** +**返回值:** | 类型 | 说明 | | ----- | ---------------- | | Point | 返回矩阵变换后的Point对象。 | -**示例** +**示例:** ```ts // xxx.ets diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-action-sheet.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-action-sheet.md index e03a97dc9f4496d46dfcdf4cd28b72ca19292c5d..fe3c7bc635115130ff8f3ee27a58682e2b1a0ffc 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-action-sheet.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-action-sheet.md @@ -47,7 +47,6 @@ show(value: { title: string | Resource, message: string  @Entry @Component struct ActionSheetExample { - build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Button('Click to Show ActionSheet') @@ -58,26 +57,26 @@ struct ActionSheetExample { confirm: { value: 'Confirm button', action: () => { - console.log('Get Alert Dialog handled') + console.log('Get Alert Dialog handled'); } }, sheets: [ { title: 'apples', action: () => { - console.error('apples') + console.log('apples'); } }, { title: 'bananas', action: () => { - console.error('bananas') + console.log('bananas'); } }, { title: 'pears', action: () => { - console.error('pears') + console.log('pears'); } } ] diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md index 339f808f170e7f9ec3177acfd89776bef19b4f1f..ffb54ddf303b00aa927bdc538a69dfd4022c9c66 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md @@ -23,7 +23,7 @@ | cancel | () => void | 否 | 点击遮障层关闭dialog时的回调。 | | alignment | [DialogAlignment](#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。
默认值:DialogAlignment.Default | | offset | [Offset](ts-types.md#offset) | 否 | 弹窗相对alignment所在位置的偏移量。 | -| gridCount | number | 否 | 弹窗容器宽度所占用栅格数。 | +| gridCount | number | 否 | 弹窗容器宽度所占用栅格数。
**说明:**
当gridCount小于等于0时,弹窗宽度是固定的;大于0时,按照设置的数值显示宽度,最大值为4,若值为小数,则向下取整。 | ## AlertDialogParamWithButtons对象说明 | 参数名 | 参数类型 | 必填 | 参数描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index aa7d7323d82434ad094ea57c5adc8af414a6e38b..cc257b0dcb26a633ee9116a19c972ac9608a5d34 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -26,6 +26,22 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, aut | customStyle | boolean | 否 | 弹窗容器样式是否自定义。
默认值:false | | gridCount8+ | number | 否 | 弹窗宽度占栅格宽度的个数。 | +## DialogAlignment枚举说明 + +| 名称 | 描述 | +| ------------------------ | ------------------------------------------------------ | +| Top | 垂直顶部对齐。 | +| Center | 垂直居中对齐。 | +| Bottom | 垂直底部对齐。 | +| Default | 默认对齐。
**说明:**
与枚举值Center效果相同。 | +| TopStart8+ | 左上对齐。 | +| TopEnd8+ | 右上对齐。 | +| CenterStart8+ | 左中对齐。 | +| CenterEnd8+ | 右中对齐。 | +| BottomStart8+ | 左下对齐。 | +| BottomEnd8+ | 右下对齐。 | + + ## CustomDialogController ### 导入对象 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md index fe160b0760ee2ce71c67a0c8ad3f7df3344a83d4..494aabc0122e49cb4a09f9b8e67b0143db07013e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md @@ -12,13 +12,13 @@ show(options?: TimePickerDialogOptions) 定义时间滑动选择器弹窗并弹出。 - options参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | selected | Date | 否 | 当前系统时间 | 设置选中项的时间。 | - | useMilitaryTime | boolean | 否 | false | 展示时间是否为24小时制。 | - | onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | - | 点击弹窗中确定按钮时触发。 | - | onCancel | () => void | 否 | - | 点击弹窗中取消按钮时触发。 | - | onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | - | 滑动选择器,当前选择项改变时触发。 | + | 参数名 | 参数类型 | 必填 | 参数描述 | + | -------- | -------- | -------- | -------- | + | selected | Date | 否 | 设置选中项的时间。
默认值:当前系统时间 | + | useMilitaryTime | boolean | 否 | 展示时间是否为24小时制。
默认值:false | + | onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 点击弹窗中确定按钮时触发。 | + | onCancel | () => void | 否 | 点击弹窗中取消按钮时触发。 | + | onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 滑动选择器,当前选择项改变时触发。 | ## 示例 @@ -28,22 +28,24 @@ show(options?: TimePickerDialogOptions) @Entry @Component struct TimePickerDialogExample01 { - @State isUseMilitaryTime: boolean = true + @State isUseMilitaryTime: boolean = true; + private selectTime: Date = new Date('7/22/2022 12:45:00'); build() { Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Button("TimePickerDialog").onClick(() => { TimePickerDialog.show({ + selected:this.selectTime, useMilitaryTime: this.isUseMilitaryTime, onAccept: (value: TimePickerResult) => { - console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)) + console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)); }, onCancel: () => { - console.info("TimePickerDialog:onCancel()") + console.info("TimePickerDialog:onCancel()"); }, onChange: (value: TimePickerResult) => { - console.info("TimePickerDialog:onChange()" + JSON.stringify(value)) + console.info("TimePickerDialog:onChange()" + JSON.stringify(value)); } }) }) @@ -60,7 +62,7 @@ struct TimePickerDialogExample01 { @Entry @Component struct TimePickerDialogExample02 { - @State isUseMilitaryTime: boolean = false + @State isUseMilitaryTime: boolean = false; build() { Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, @@ -72,10 +74,10 @@ struct TimePickerDialogExample02 { console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)) }, onCancel: () => { - console.info("TimePickerDialog:onCancel()") + console.info("TimePickerDialog:onCancel()"); }, onChange: (value: TimePickerResult) => { - console.info("TimePickerDialog:onChange()" + JSON.stringify(value)) + console.info("TimePickerDialog:onChange()" + JSON.stringify(value)); } }) }) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index c89967bd0d471b0aefaa929337db50c57e4781a6..9a0caa9f125ab28009166ecebd0cf9d7dccc8eea 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -4,7 +4,7 @@ > 从 API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -使用OffscreenCanvasRenderingContext2D在Canvas上进行离屏绘制,绘制对象可以是矩形、文本、图片等。离屏绘制是指将需要绘制的内容先绘制在缓存区,然后将其转换成图片,一次性绘制绘制到canvas上,加快了绘制速度。 +使用OffscreenCanvasRenderingContext2D在Canvas上进行离屏绘制,绘制对象可以是矩形、文本、图片等。离屏绘制是指将需要绘制的内容先绘制在缓存区,然后将其转换成图片,一次性绘制到canvas上,加快了绘制速度。 ## 接口 @@ -13,11 +13,11 @@ OffscreenCanvasRenderingContext2D(width: number, height: number, setting: Render **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------- | ---------------------------------------- | ---- | ---- | ------------------------------ | -| width | number | 是 | - | 离屏画布的宽度 | -| height | number | 是 | - | 离屏画布的高度 | -| setting | [RenderingContextSettings](ts-canvasrenderingcontext2d.md#renderingcontextsettings) | 是 | - | 见RenderingContextSettings接口描述。 | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------- | ------------------------------------------------------------ | ---- | ------------------------------------ | +| width | number | 是 | 离屏画布的宽度 | +| height | number | 是 | 离屏画布的高度 | +| setting | [RenderingContextSettings](ts-canvasrenderingcontext2d.md#renderingcontextsettings) | 是 | 见RenderingContextSettings接口描述。 | ## 属性 @@ -846,7 +846,7 @@ fillText(text: string, x: number, y: number, maxWidth?: number): void | 参数 | 类型 | 必填 | 默认值 | 说明 | | -------- | ------ | ---- | ---- | --------------- | -| text | string | 是 | “” | 需要绘制的文本内容。 | +| text | string | 是 | "" | 需要绘制的文本内容。 | | x | number | 是 | 0 | 需要绘制的文本的左下角x坐标。 | | y | number | 是 | 0 | 需要绘制的文本的左下角y坐标。 | | maxWidth | number | 否 | - | 指定文本允许的最大宽度。 | @@ -893,7 +893,7 @@ strokeText(text: string, x: number, y: number): void | 参数 | 类型 | 必填 | 默认值 | 描述 | | -------- | ------ | ---- | ---- | --------------- | -| text | string | 是 | “” | 需要绘制的文本内容。 | +| text | string | 是 | "" | 需要绘制的文本内容。 | | x | number | 是 | 0 | 需要绘制的文本的左下角x坐标。 | | y | number | 是 | 0 | 需要绘制的文本的左下角y坐标。 | | maxWidth | number | 否 | - | 需要绘制的文本的最大宽度 。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md b/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md index b1ee6ef8be10e1eb92fd8230e1ca9f47e59248d0..c94d72831575816d8b7589dbdf297698ccce541b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md @@ -9,8 +9,8 @@ | 名称 | 参数 | 参数描述 | | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| PageTransitionEnter | {
type: RouteType,
duration: number,
curve: Curve \| Curves,
delay: number
} | 设置当前页面的自定义入场动效。
- type:不配置时表明pop为push时效果的逆播。
- duration:动画的时长,单位为毫秒。
- curve:动画曲线,有效值参见[Curve](ts-animatorproperty.md) 。
 默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | -| PageTransitionExit | {
type: RouteType,
duration: number,
curve: Curve \| Curves,
delay: number
} | 设置当前页面的自定义退场动效。
- type:不配置时表明pop为push时效果的逆播
- duration:动画的时长,单位为毫秒。
- curve:动画曲线,有效值参见[Curve](ts-animatorproperty.md) 。
 默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | +| PageTransitionEnter | {
type: RouteType,
duration: number,
curve: [Curve](ts-appendix-enums.md#curve) \| string,
delay: number
} | 设置当前页面的自定义入场动效。
- type:不配置时表明pop为push时效果的逆播。
- duration:动画的时长,单位为毫秒。
- curve:动画曲线。string类型的取值支持"ease"、"ease-in"、"ease-out"、"ease-in-out"、"extreme-deceleration"、"fast-out-linear-in"、"fast-out-slow-in"、"friction"、"linear"、"linear-out-slow-in"、"rhythm"、"sharp"、"smooth"。
 默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | +| PageTransitionExit | {
type: RouteType,
duration: number,
curve: [Curve](ts-appendix-enums.md#curve) \| string,
delay: number
} | 设置当前页面的自定义退场动效。
- type:不配置时表明pop为push时效果的逆播
- duration:动画的时长,单位为毫秒。
- curve:动画曲线,string类型取值与PageTransitionEnter相同。
 默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | ## RouteType枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md index 62c664240b27b57982e3db85cfed4939589fb885..866b744c03c9ed21d9f270eb8462f1b8be433f67 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md @@ -12,7 +12,7 @@ | 名称 | 参数 | 参数描述 | | ---------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| sharedTransition | id: string,
{
duration?: number,
curve?: Curve \| string,
delay?: number,
motionPath?:
{
path: string,
form?: number,
to?: number,
rotatable?: boolean
},
zIndex?: number,
type?: [SharedTransitionEffectType](ts-appendix-enums.md#sharedtransitioneffecttype)
} | 两个页面中id值相同且不为空字符串的组件即为共享元素,在页面转场时可显示共享元素转场动效。
-  id:设置组件的id。
-  duration:单位为毫秒,默认动画时长为1000毫秒。
- curve:默认曲线为Linear,有效值参见[Curve](ts-animatorproperty.md) 说明。
- delay:单位为毫秒,默认不延时播放。
- motionPath:运动路径信息。
- path:设置路径。
- from:设置起始值。
- to:设置终止值。
- rotatable:是否旋转。
- zIndex:设置Z轴。
- type:动画类型。 | +| sharedTransition | id: string,
{
 duration?: number,
 curve?: Curve \| string,
 delay?: number,
 motionPath?:
{
 path: string,
 form?: number,
 to?: number,
 rotatable?: boolean
},
zIndex?: number,
type?: [SharedTransitionEffectType](ts-appendix-enums.md#sharedtransitioneffecttype)
} | 两个页面中id值相同且不为空字符串的组件即为共享元素,在页面转场时可显示共享元素转场动效。
- id:设置组件的id。
- duration:单位为毫秒,默认动画时长为1000毫秒。
- curve:默认曲线为Linear,有效值参见[Curve](ts-animatorproperty.md) 说明。
- delay:单位为毫秒,默认不延时播放。
- motionPath:运动路径信息。
- path:设置路径。
- from:设置起始值。
- to:设置终止值。
- rotatable:是否旋转。
- zIndex:设置Z轴。
- type:动画类型。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index bd48e25b3b06f38aeb2713817d23ef9e4a93686a..9f9c8f42383cd699a337eb7f1f17e1a003707ebf 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -35,7 +35,7 @@ | maskColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 提示气泡遮障层的颜色。 | | popupColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 提示气泡的颜色。 | | enableArrow | boolean | 否 | 是否显示箭头。
从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。
默认值:true | -| autoCancel | boolean | 否 | 页面有操作时,是否自动关闭气泡
默认值:true | +| autoCancel | boolean | 否 | 页面有操作时,是否自动关闭气泡。
默认值:true | | onStateChange | (event: { isVisible: boolean }) => void | 否 | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md index ec4e7e0f29fea2bc64b5c7e122587f78f4be99dc..d1442f932d74fb733e403d8b626a7fc1b648e220 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -1,6 +1,6 @@ # 点击事件 -点击事件指组件被点击时触发的事件。 +组件被点击时触发的事件。 > **说明:** > @@ -11,17 +11,18 @@ | 名称 | 支持冒泡 | 功能描述 | | ---------------------------------------- | ---- | --------------------------------- | -| onClick(event: (event?: ClickEvent) => void) | 否 | 点击动作触发该方法调用,event参数见ClickEvent介绍。 | +| onClick(event: (event?: ClickEvent) => void) | 否 | 点击动作触发该回调,event返回值见ClickEvent对象说明。 | ## ClickEvent对象说明 -| 属性名称 | 类型 | 描述 | +| 名称 | 类型 | 描述 | | ------------------- | ------------------------------------ | -------------------------------------------------------- | -| screenX | number | 点击点相对于应用窗口左上角的X坐标。 | -| screenY | number | 点击点相对于应用窗口左上角的Y坐标。 | -| x | number | 点击点相对于被点击元素左上角的X坐标。 | -| y | number | 点击点相对于被点击元素左上角的Y坐标。 | -| target8+ | [EventTarget](#eventtarget8对象说明) | 被点击元素对象。 | -| timestamp | number | 事件时间戳。触发事件时距离系统启动的时间间隔,单位纳秒。 | +| screenX | number | 点击位置相对于应用窗口左上角的X坐标。 | +| screenY | number | 点击位置相对于应用窗口左上角的Y坐标。 | +| x | number | 点击位置相对于被点击元素左上角的X坐标。 | +| y | number | 点击位置相对于被点击元素左上角的Y坐标。 | +| timestamp8+ | number | 事件时间戳。触发事件时距离系统启动的时间间隔,单位纳秒。 | +| target8+ | [EventTarget](#eventtarget8对象说明) | 触发事件的元素对象显示区域。 | +| source8+ | [SourceType](ts-gesture-settings.md#sourcetype枚举说明) | 事件输入设备。 | ## EventTarget8+对象说明 @@ -38,19 +39,29 @@ @Entry @Component struct ClickExample { - @State text: string = '' + @State text: string = ''; build() { Column() { - Button('Click').backgroundColor(0x2788D9).width(100).height(40) - .onClick((event: ClickEvent) => { - console.info(this.text = 'Click Point:' + '\n screenX:' + event.screenX + '\n screenY:' + event.screenY - + '\n x:' + event.x + '\n y:' + event.y + '\ntarget:' + '\n component globalPos:(' - + event.target.area.globalPosition.x + ',' + event.target.area.globalPosition.y + ')\n width:' - + event.target.area.width + '\n height:' + event.target.area.height) - }) - Text(this.text).padding(15) - }.height(350).width('100%').padding(10) + Row({ space: 20 }) { + Button('Click').width(100).height(40) + .onClick((event: ClickEvent) => { + this.text = 'Click Point:' + '\n screenX:' + event.screenX + '\n screenY:' + event.screenY + + '\n x:' + event.x + '\n y:' + event.y + '\ntarget:' + '\n component globalPos:(' + + event.target.area.globalPosition.x + ',' + event.target.area.globalPosition.y + ')\n width:' + + event.target.area.width + '\n height:' + event.target.area.height + '\ntimestamp' + event.timestamp; + }) + Button('Click').width(200).height(50) + .onClick((event: ClickEvent) => { + this.text = 'Click Point:' + '\n screenX:' + event.screenX + '\n screenY:' + event.screenY + + '\n x:' + event.x + '\n y:' + event.y + '\ntarget:' + '\n component globalPos:(' + + event.target.area.globalPosition.x + ',' + event.target.area.globalPosition.y + ')\n width:' + + event.target.area.width + '\n height:' + event.target.area.height + '\ntimestamp' + event.timestamp; + }) + }.margin(20) + + Text(this.text).margin(15) + }.width('100%') } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md index af4d9e3ed3a62ce06e4a4082cd6e2c8168cd8697..137610753611d3a732559979a46d274c3d8a2d9a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md @@ -1,6 +1,6 @@ # 拖拽事件 -拖拽事件指被长按后拖拽时触发的事件。 +拖拽事件指组件被长按后拖拽时触发的事件。 > **说明:** > @@ -10,35 +10,35 @@ | 名称 | 支持冒泡 | 功能描述 | | ---------------------------------------- | ---- | ---------------------------------------- | -| onDragStart(event: (event?: DragEvent, extraParams?: string) =>  [CustomBuilder](ts-types.md#custombuilder8) \| DragItemInfo) | 否 | 第一次拖拽此事件绑定的组件时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见extraParam类型描述。
返回值:当前跟手效果所拖拽的对象,用于显示拖拽时的提示组件。
长按150毫秒(ms)可触发拖拽事件。优先级:长按手势配置时间小于等于150毫秒(ms)时,长按手势优先触发,否则拖拽事件优先触发。 | -| onDragEnter(event: (event?: DragEvent, extraParams?: string) => void) | 否 | 拖拽进入组件范围内时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见extraParam类型描述。
当监听了onDrop事件时,此事件才有效。 | -| onDragMove(event: (event?: DragEvent, extraParams?: string) => void) | 否 | 拖拽在组件范围内移动时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见extraParam类型描述。
当监听了onDrop事件时,此事件才有效。 | -| onDragLeave(event: (event?: DragEvent, extraParams?: string) => void) | 否 | 拖拽离开组件范围内时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见extraParam类型描述。
当监听了onDrop事件时,此事件才有效。 | -| onDrop(event: (event?: DragEvent, extraParams?: string) => void) | 否 | 绑定此事件的组件可作为拖拽释放目标,当在本组件范围内停止拖拽行为时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见extraParam类型描述。 | +| onDragStart(event: (event?: [DragEvent](#dragevent说明), extraParams?: string) =>  [CustomBuilder](ts-types.md#custombuilder8) \| [DragItemInfo](#dragiteminfo说明) | 否 | 第一次拖拽此事件绑定的组件时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见[extraParams](#extraparams说明)说明。
返回值:当前跟手效果所拖拽的对象,用于显示拖拽时的提示组件。
长按150ms可触发拖拽事件。优先级:长按手势配置时间小于等于150ms时,长按手势优先触发,否则拖拽事件优先触发。 | +| onDragEnter(event: (event?: [DragEvent](#dragevent说明), extraParams?: string) => void) | 否 | 拖拽进入组件范围内时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见[extraParams](#extraparams说明)说明。
当监听了onDrop事件时,此事件才有效。 | +| onDragMove(event: (event?: [DragEvent](#dragevent说明), extraParams?: string) => void) | 否 | 拖拽在组件范围内移动时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见[extraParams](#extraparams说明)说明。
当监听了onDrop事件时,此事件才有效。 | +| onDragLeave(event: (event?: [DragEvent](#dragevent说明), extraParams?: string) => void) | 否 | 拖拽离开组件范围内时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见[extraParams](#extraparams说明)说明。
当监听了onDrop事件时,此事件才有效。 | +| onDrop(event: (event?: [DragEvent](#dragevent说明), extraParams?: string) => void) | 否 | 绑定此事件的组件可作为拖拽释放目标,当在本组件范围内停止拖拽行为时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见[extraParams](#extraparams说明)说明。 | ## DragItemInfo说明 -| 属性名称 | 属性类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 描述 | | --------- | ---------------------------------------- | ---- | --------------------------------- | | pixelMap | [PixelMap](../apis/js-apis-image.md#pixelmap7) | 否 | 设置拖拽过程中显示的图片。 | -| builder | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 使用自定义生成器进行绘图,如果设置了pixelMap,则忽略此值。 | +| builder | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 拖拽过程中显示自定义组件,如果设置了pixelMap,则忽略此值。 | | extraInfo | string | 否 | 拖拽项的描述。 | -## extraParam说明 +## extraParams说明 用于返回组件在拖拽中需要用到的额外信息。 - extraParam是Json对象转换的string字符串,可以通过Json.parse转换的Json对象获取如下属性。 + extraParams是Json对象转换的string字符串,可以通过Json.parse转换的Json对象获取如下属性。 -| 属性名称 | 属性类型 | 描述 | +| 名称 | 类型 | 描述 | | ------------- | ------ | ---------------------------------------- | -| selectedIndex | number | 当拖拽事件设在父容器的子元素时,selectedIndex表示当前被拖拽子元素是父容器第selectedIndex个子元素,selectedIndex从0开始。
仅在ListItem组件中生效。 | +| selectedIndex | number | 当拖拽事件设在父容器的子元素时,selectedIndex表示当前被拖拽子元素是父容器第selectedIndex个子元素,selectedIndex从0开始。
仅在ListItem组件的拖拽事件中生效。 | | insertIndex | number | 当前拖拽元素在List组件中放下时,insertIndex表示被拖拽元素插入该组件的第insertIndex个位置,insertIndex从0开始。
仅在List组件的拖拽事件中生效。 | -## DragEvent对象说明 +## DragEvent说明 -| 名称 | 返回值类型 | 功能描述 | +| 名称 | 类型 | 描述 | | ------ | ------ | ---------------- | | getX() | number | 当前拖拽点x轴坐标,单位为vp。 | | getY() | number | 当前拖拽点y轴坐标,单位为vp。 | @@ -50,101 +50,117 @@ @Entry @Component struct DragExample { - @State numbers: string[] = ['one', 'two', 'three', 'four', 'five', 'six'] - @State text: string = '' - @State bool: boolean = false - @State bool1: boolean = false - @State appleVisible: Visibility = Visibility.Visible - @State orangeVisible: Visibility = Visibility.Visible - @State bananaVisible: Visibility = Visibility.Visible - @State select: number = 0 - + @State numbers: string[] = ['one', 'two', 'three', 'four', 'five', 'six']; + @State text: string = ''; + @State bool: boolean = false; + @State appleVisible: Visibility = Visibility.Visible; + @State orangeVisible: Visibility = Visibility.Visible; + @State bananaVisible: Visibility = Visibility.Visible; + + // 自定义拖拽过程中显示的内容 @Builder pixelMapBuilder() { Column() { Text(this.text) - .width('50%').height(60).fontSize(16).borderRadius(10) - .textAlign(TextAlign.Center).backgroundColor(Color.Yellow) + .width('50%') + .height(60) + .fontSize(16) + .borderRadius(10) + .textAlign(TextAlign.Center) + .backgroundColor(Color.Yellow) } } build() { Column() { Text('There are three Text elements here') - .fontSize(12).fontColor(0xCCCCCC).width('90%') - .textAlign(TextAlign.Start).margin(5) - Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { - Text('apple').width('25%').height(35).fontSize(16) - .textAlign(TextAlign.Center).backgroundColor(0xAFEEEE) + .fontSize(12) + .fontColor(0xCCCCCC) + .width('90%') + .textAlign(TextAlign.Start) + .margin(5) + Row({ space: 15 }) { + Text('apple') + .width('25%') + .height(35) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(0xAFEEEE) .visibility(this.appleVisible) .onDragStart(() => { - this.bool = true - this.text = 'apple' - this.appleVisible = Visibility.Hidden - return this.pixelMapBuilder + this.bool = true; + this.text = 'apple'; + this.appleVisible = Visibility.None; + return this.pixelMapBuilder; }) - Text('orange').width('25%').height(35).fontSize(16) - .textAlign(TextAlign.Center).backgroundColor(0xAFEEEE) + Text('orange') + .width('25%') + .height(35) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(0xAFEEEE) .visibility(this.orangeVisible) .onDragStart(() => { - this.bool = true - this.text = 'orange' - this.orangeVisible = Visibility.Hidden - return this.pixelMapBuilder + this.bool = true; + this.text = 'orange'; + this.orangeVisible = Visibility.None; + return this.pixelMapBuilder; }) - Text('banana').width('25%').height(35).fontSize(16) - .textAlign(TextAlign.Center).backgroundColor(0xAFEEEE) + Text('banana') + .width('25%') + .height(35) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(0xAFEEEE) .visibility(this.bananaVisible) .onDragStart((event: DragEvent, extraParams: string) => { - console.log('Text onDragStarts, ' + extraParams) - this.bool = true - this.text = 'banana' - this.bananaVisible = Visibility.Hidden - return this.pixelMapBuilder + console.log('Text onDragStart, ' + extraParams + 'X:' + event.getX() + 'Y:' + event.getY()); + this.bool = true; + this.text = 'banana'; + this.bananaVisible = Visibility.None; + return this.pixelMapBuilder; }) - }.border({ width: 1 }).width('90%').padding({ top: 10, bottom: 10 }).margin(10) - - Text('This is a List element').fontSize(12) - .fontColor(0xCCCCCC).width('90%') - .textAlign(TextAlign.Start).margin(15) - List({ space: 20, initialIndex: 0 }) { + }.padding({ top: 10, bottom: 10 }).margin(10) + + Text('This is a List element') + .fontSize(12) + .fontColor(0xCCCCCC) + .width('90%') + .textAlign(TextAlign.Start) + .margin(15) + List({ space: 20 }) { ForEach(this.numbers, (item) => { ListItem() { - Text('' + item) - .width('100%').height(80).fontSize(16).borderRadius(10) - .textAlign(TextAlign.Center).backgroundColor(0xAFEEEE) + Text(item) + .width('100%') + .height(80) + .fontSize(16) + .borderRadius(10) + .textAlign(TextAlign.Center) + .backgroundColor(0xAFEEEE) } - .onDragStart((event: DragEvent, extraParams: string) => { - console.log('ListItem onDragStarts, ' + extraParams) - var jsonString = JSON.parse(extraParams) - this.bool1 = true - this.text = this.numbers[jsonString.selectedIndex] - this.select = jsonString.selectedIndex - return this.pixelMapBuilder - }) }, item => item) } .editMode(true) - .height('50%').width('90%').border({ width: 1 }) + .height('50%') + .width('90%') + .border({ width: 1 }) + .padding(15) .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) .onDragEnter((event: DragEvent, extraParams: string) => { - console.log('List onDragEnter, ' + extraParams) + console.log('List onDragEnter, ' + extraParams + 'X:' + event.getX() + 'Y:' + event.getY()); }) .onDragMove((event: DragEvent, extraParams: string) => { - console.log('List onDragMove, ' + extraParams) + console.log('List onDragMove, ' + extraParams + 'X:' + event.getX() + 'Y:' + event.getY()); }) .onDragLeave((event: DragEvent, extraParams: string) => { - console.log('List onDragLeave, ' + extraParams) + console.log('List onDragLeave, ' + extraParams + 'X:' + event.getX() + 'Y:' + event.getY()); }) .onDrop((event: DragEvent, extraParams: string) => { - var jsonString = JSON.parse(extraParams) + var jsonString = JSON.parse(extraParams); if (this.bool) { - this.numbers.splice(jsonString.insertIndex, 0, this.text) - this.bool = false - } else if (this.bool1) { - this.numbers.splice(jsonString.selectedIndex, 1) - this.numbers.splice(jsonString.insertIndex, 0, this.text) - this.bool = false - this.bool1 = false + // 通过splice方法插入元素 + this.numbers.splice(jsonString.insertIndex, 0, this.text); + this.bool = false; } }) }.width('100%').height('100%').padding({ top: 20 }).margin({ top: 20 }) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md index e0e208469e40d997700b3c6b2b0346bee666019b..a1f8377688ccbc92894bf6cd20698688a551db1b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md @@ -1,6 +1,6 @@ # 按键事件 -按键事件指组件与键盘、遥控器等按键设备交互时触发的事件,适用于所有可交互组件(默认可获焦),例如Button。对于Text,Image等不可获焦组件,可以设置focusable属性为true后使用按键事件。 +按键事件指组件与键盘、遥控器等按键设备交互时触发的事件,适用于所有可获焦组件,例如Button。对于Text,Image等默认不可获焦的组件,可以设置focusable属性为true后使用按键事件。 > **说明:** > @@ -12,7 +12,7 @@ | 名称 | 支持冒泡 | 功能描述 | | ---------------------------------------- | ---- | ---------------------------------------- | -| onKeyEvent(event: (event?: KeyEvent) => void) | 是 | 绑定该方法的组件获焦后,按键动作触发该方法调用,event参数见[KeyEvent](#keyevent对象说明)介绍。 | +| onKeyEvent(event: (event?: KeyEvent) => void) | 是 | 绑定该方法的组件获焦后,按键动作触发该回调,event返回值见[KeyEvent](#keyevent对象说明)介绍。 | ## KeyEvent对象说明 @@ -24,7 +24,7 @@ | keyText | string | 按键的键值。 | | keySource | [KeySource](ts-appendix-enums.md#keysource) | 触发当前按键的输入设备类型。 | | deviceId | number | 触发当前按键的输入设备ID。 | -| metaKey | number | 按键发生时元键的状态,1表示按压态,0表示未按压态。 | +| metaKey | number | 按键发生时元键(即Windows键盘的WIN键、Mac键盘的Command键)的状态,1表示按压态,0表示未按压态。 | | timestamp | number | 按键发生时的时间戳。 | | stopPropagation | () => void | 阻塞事件冒泡传递。 | @@ -36,20 +36,20 @@ @Entry @Component struct KeyEventExample { - @State text: string = '' - @State eventType: string = '' + @State text: string = ''; + @State eventType: string = ''; build() { Column() { - Button('KeyEvent').backgroundColor(0x2788D9) + Button('KeyEvent') .onKeyEvent((event: KeyEvent) => { if (event.type === KeyType.Down) { - this.eventType = 'Down' + this.eventType = 'Down'; } if (event.type === KeyType.Up) { - this.eventType = 'Up' + this.eventType = 'Up'; } - console.info(this.text = 'KeyType:' + this.eventType + '\nkeyCode:' + event.keyCode + '\nkeyText:' + event.keyText) + this.text = 'KeyType:' + this.eventType + '\nkeyCode:' + event.keyCode + '\nkeyText:' + event.keyText; }) Text(this.text).padding(15) }.height(300).width('100%').padding(35) @@ -57,4 +57,4 @@ struct KeyEventExample { } ``` -![zh-cn_image_0000001174264364](figures/zh-cn_image_0000001174264364.gif) + ![keyEvent](figures/keyEvent.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md index c7eed9da294e19d917e8669ff57176c385995cff..d3ff6dc98d86fb800a524ade36c90514e9540a07 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md @@ -19,30 +19,36 @@ ```ts // xxx.ets -import prompt from '@system.prompt' +import prompt from '@ohos.prompt'; @Entry @Component struct AppearExample { - @State isShow: boolean = true - private myText: string = 'Text for onAppear' - private changeAppear: string = 'Hide Text' + @State isShow: boolean = true; + @State changeAppear: string = 'Hide Text'; + private myText: string = 'Text for onAppear'; build() { Column() { Button(this.changeAppear) .onClick(() => { - this.isShow = !this.isShow - }).margin(3).backgroundColor(0x2788D9) + this.isShow = !this.isShow; + }).margin(15) if (this.isShow) { - Text(this.myText) + Text(this.myText).fontSize(26).fontWeight(FontWeight.Bold) .onAppear(() => { - this.changeAppear = 'Show Text' - prompt.showToast({ message: 'The text is shown', duration: 2000 }) + this.changeAppear = 'Hide Text'; + prompt.showToast({ + message: 'The text is shown', + duration: 2000 + }) }) .onDisAppear(() => { - this.changeAppear = 'Hide Text' - prompt.showToast({ message: 'The text is hidden', duration: 2000 }) + this.changeAppear = 'Show Text'; + prompt.showToast({ + message: 'The text is hidden', + duration: 2000 + }) }) } }.padding(30).width('100%') diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md index f671f750b9073e8dd8ea70ee5645f9d0b3abfe53..f24bb33026d8b5a126b960bfb387be2a506b8423 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md @@ -1,6 +1,6 @@ # 触摸事件 -当手指放在组件上、滑动或从组件上移开时触发。 +当手指在组件上按下、滑动、抬起时触发。 > **说明:** > @@ -11,7 +11,7 @@ | 名称 | 是否冒泡 | 功能描述 | | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | -| onTouch(event: (event?: TouchEvent) => void) | 是 | 触摸动作触发该方法调用,event参数见[TouchEvent](#touchevent对象说明)介绍。 | +| onTouch(event: (event?: TouchEvent) => void) | 是 | 手指触摸动作触发该回调,event返回值见[TouchEvent](#touchevent对象说明)介绍。 | ## TouchEvent对象说明 @@ -23,8 +23,8 @@ | changedTouches | Array<[TouchObject](#touchobject对象说明)> | 当前发生变化的手指信息。 | | stopPropagation | () => void | 阻塞事件冒泡。 | | timestamp8+ | number | 事件时间戳。触发事件时距离系统启动的时间间隔,单位纳秒。 | -| target8+ | [EventTarget](ts-universal-events-click.md) | 触发手势事件的元素对象显示区域。 | -| source8+ | [SourceType](ts-gesture-settings.md) | 事件输入设备。 | +| target8+ | [EventTarget](ts-universal-events-click.md#eventtarget8对象说明) | 触发事件的元素对象显示区域。 | +| source8+ | [SourceType](ts-gesture-settings.md#sourcetype枚举说明) | 事件输入设备。 | ## TouchObject对象说明 @@ -45,29 +45,45 @@ @Entry @Component struct TouchExample { - @State text: string = '' - @State eventType: string = '' + @State text: string = ''; + @State eventType: string = ''; build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Button('Touch').backgroundColor(0x2788D9).height(40).width(80) + Column() { + Button('Touch').height(40).width(100) .onTouch((event: TouchEvent) => { if (event.type === TouchType.Down) { - this.eventType = 'Down' + this.eventType = 'Down'; } if (event.type === TouchType.Up) { - this.eventType = 'Up' + this.eventType = 'Up'; } if (event.type === TouchType.Move) { - this.eventType = 'Move' + this.eventType = 'Move'; } - console.info(this.text = 'TouchType:' + this.eventType + '\nDistance between touch point and touch element:\nx: ' - + event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\ncomponent globalPos:(' + this.text = 'TouchType:' + this.eventType + '\nDistance between touch point and touch element:\nx: ' + + event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\nComponent globalPos:(' + event.target.area.globalPosition.x + ',' + event.target.area.globalPosition.y + ')\nwidth:' - + event.target.area.width + '\nheight:' + event.target.area.height) + + event.target.area.width + '\nheight:' + event.target.area.height; + }) + Button('Touch').height(50).width(200).margin(20) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down'; + } + if (event.type === TouchType.Up) { + this.eventType = 'Up'; + } + if (event.type === TouchType.Move) { + this.eventType = 'Move'; + } + this.text = 'TouchType:' + this.eventType + '\nDistance between touch point and touch element:\nx: ' + + event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\nComponent globalPos:(' + + event.target.area.globalPosition.x + ',' + event.target.area.globalPosition.y + ')\nwidth:' + + event.target.area.width + '\nheight:' + event.target.area.height; }) Text(this.text) - }.height(200).width(350).padding({ left: 35, right: 35, top: 35 }) + }.width('100%').padding(30) } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-focus-event.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-focus-event.md index 4a3fc90ef557a6446963dc0aceb68584c130b248..3f9aa271b4b137b384542758d11a5815086e1c34 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-focus-event.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-focus-event.md @@ -1,10 +1,11 @@ # 焦点事件 -焦点事件指页面焦点在组件间移动时触发的事件,组件可使用焦点事件来更改内容。 +焦点事件指页面焦点在可获焦组件间移动时触发的事件,组件可使用焦点事件来处理相关逻辑。 > **说明:** > > - 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> > - 目前仅支持通过外接键盘的tab键、方向键触发。 @@ -12,13 +13,9 @@ | **名称** | **支持冒泡** | **功能描述** | | ---------------------------------------- | -------- | --------------- | -| onFocus(event: () => void) | 否 | 当前组件获取焦点时触发的回调。 | +| onFocus(event: () => void) | 否 | 当前组件获取焦点时触发的回调。 | | onBlur(event:() => void) | 否 | 当前组件失去焦点时触发的回调。 | -> **说明:** -> -> 支持焦点事件的组件:Button、Text、Image、List、Grid。 - ## 示例 @@ -27,44 +24,52 @@ @Entry @Component struct FocusEventExample { - @State textOne: string = '' - @State textTwo: string = '' - @State textThree: string = '' - @State oneButtonColor: string = '#FF0000' - @State twoButtonColor: string = '#87CEFA' - @State threeButtonColor: string = '#90EE90' + @State oneButtonColor: string = '#FFC0CB'; + @State twoButtonColor: string = '#87CEFA'; + @State threeButtonColor: string = '#90EE90'; build() { - Column({ space:20 }){ - Button(this.textOne) + Column({ space: 20 }) { + // 通过外接键盘的上下键可以让焦点在三个按钮间移动,按钮获焦时颜色变化,失焦时变回原背景色 + Button('First Button') .backgroundColor(this.oneButtonColor) - .width(260).height(70).fontColor(Color.Black) + .width(260) + .height(70) + .fontColor(Color.Black) .focusable(true) .onFocus(() => { - this.textOne = 'First Button onFocus' - this.oneButtonColor = '#AFEEEE' + this.oneButtonColor = '#FF0000'; }) .onBlur(() => { - this.textOne = 'First Button onBlur' - this.oneButtonColor = '#FFC0CB' + this.oneButtonColor = '#FFC0CB'; }) - Button(this.textTwo) + Button('Second Button') .backgroundColor(this.twoButtonColor) - .width(260).height(70).fontColor(Color.Black) + .width(260) + .height(70) + .fontColor(Color.Black) .focusable(true) - Button(this.textThree) + .onFocus(() => { + this.twoButtonColor = '#FF0000'; + }) + .onBlur(() => { + this.twoButtonColor = '#87CEFA'; + }) + Button('Third Button') .backgroundColor(this.threeButtonColor) - .width(260).height(70).fontColor(Color.Black) + .width(260) + .height(70) + .fontColor(Color.Black) .focusable(true) .onFocus(() => { - this.textThree = 'Third Button onFocus' - this.threeButtonColor = '#AFEEEE' + this.threeButtonColor = '#FF0000'; }) .onBlur(() => { - this.textThree = 'Third Button onBlur' - this.threeButtonColor = '#FFC0CB' + this.threeButtonColor = '#90EE90'; }) - }.width('100%').margin({ top:20 }) + }.width('100%').margin({ top: 20 }) } } ``` + + ![focus](figures/focus.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md index 8f0eb3cfa01685a36211438aa8bfafc67b8e62d0..d2311944b0908b312b12f43eba837fde2a2780b0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md @@ -1,6 +1,10 @@ + + + + # 鼠标事件 -在单个动作触发多个事件时,事件的顺序是固定的,鼠标事件默认透传。 +在鼠标的单个动作触发多个事件时,事件的顺序是固定的,鼠标事件默认透传。 > **说明:** > @@ -12,23 +16,23 @@ | 名称 | 支持冒泡 | 描述 | | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | | onHover(event: (isHover?: boolean) => void) | 否 | 鼠标进入或退出组件时触发该回调。
isHover:表示鼠标是否悬浮在组件上,鼠标进入时为true, 退出时为false。 | -| onMouse(event: (event?: MouseEvent) => void) | 是 | 当前组件被鼠标按键点击时或者鼠标在组件上移动时,触发该回调,event参数包含触发事件时的时间戳、鼠标按键、动作、点击触点在整个屏幕上的坐标和点击触点相对于当前组件的坐标。 | +| onMouse(event: (event?: MouseEvent) => void) | 是 | 当前组件被鼠标按键点击时或者鼠标在组件上悬浮移动时,触发该回调,event返回值包含触发事件时的时间戳、鼠标按键、动作、鼠标位置在整个屏幕上的坐标和相对于当前组件的坐标。 | ## MouseEvent对象说明 | 名称 | 属性类型 | 描述 | | --------- | ------------------------------- | -------------------- | -| screenX | number | 点击触点相对于应用窗口左上角的x轴坐标。 | -| screenY | number | 点击触点相对于应用窗口左上角的y轴坐标。 | -| x | number | 点击触点相对于当前组件左上角的x轴坐标。 | -| y | number | 点击触点相对于当前组件左上角的y轴坐标。 | +| screenX | number | 鼠标位置相对于应用窗口左上角的x轴坐标。 | +| screenY | number | 鼠标位置相对于应用窗口左上角的y轴坐标。 | +| x | number | 鼠标位置相对于当前组件左上角的x轴坐标。 | +| y | number | 鼠标位置相对于当前组件左上角的y轴坐标。 | | button | [MouseButton](ts-appendix-enums.md#mousebutton) | 鼠标按键。 | -| action | [MouseAction](ts-appendix-enums.md#mouseaction) | 事件动作。 | +| action | [MouseAction](ts-appendix-enums.md#mouseaction) | 鼠标动作。 | | stopPropagation | () => void | 阻塞事件冒泡。 | -| timestamp8+ | number | 事件时间戳。触发事件时距离系统启动的时间间隔,单位纳秒。 | -| target8+ | [EventTarget](ts-universal-events-click.md) | 触发手势事件的元素对象显示区域。 | -| source8+ | [SourceType](ts-gesture-settings.md) | 事件输入设备。 | +| timestamp8+ | number | 事件时间戳。触发事件时距离系统启动的时间间隔,单位纳秒。 | +| target8+ | [EventTarget](ts-universal-events-click.md#eventtarget8对象说明) | 触发事件的元素对象显示区域。 | +| source8+ | [SourceType](ts-gesture-settings.md#sourcetype枚举说明) | 事件输入设备。 | ## 示例 @@ -37,31 +41,80 @@ @Entry @Component struct MouseEventExample { - @State hoverText: string = 'no hover' - @State mouseText: string = 'MouseText' - @State color: Color = Color.Blue + @State hoverText: string = 'no hover'; + @State mouseText: string = ''; + @State action: string = ''; + @State mouseBtn: string = ''; + @State color: Color = Color.Blue; build() { - Column({ space:20 }) { + Column({ space: 20 }) { Button(this.hoverText) + .width(180).height(80) + .backgroundColor(this.color) .onHover((isHover: boolean) => { + // 通过onHover事件动态修改按钮在是否有鼠标悬浮时的文本内容与背景颜色 if (isHover) { - this.hoverText = 'on hover' - this.color = Color.Pink + this.hoverText = 'hover'; + this.color = Color.Pink; } else { - this.hoverText = 'no hover' - this.color = Color.Blue + this.hoverText = 'no hover'; + this.color = Color.Blue; } }) - .backgroundColor(this.color) Button('onMouse') + .width(180).height(80) .onMouse((event: MouseEvent) => { - console.log(this.mouseText = 'onMouse:\nButton = ' + event.button + - '\nAction = ' + event.action + '\nlocalXY=(' + event.x + ',' + event.y + ')' + - '\nscreenXY=(' + event.screenX + ',' + event.screenY + ')') + switch (event.button) { + case MouseButton.None: + this.mouseBtn = 'None'; + break; + case MouseButton.Left: + this.mouseBtn = 'Left'; + break; + case MouseButton.Right: + this.mouseBtn = 'Right'; + break; + case MouseButton.Back: + this.mouseBtn = 'Back'; + break; + case MouseButton.Forward: + this.mouseBtn = 'Forward'; + break; + case MouseButton.Middle: + this.mouseBtn = 'Middle'; + break; + } + switch (event.action) { + case MouseAction.Hover: + this.action = 'Hover'; + break; + case MouseAction.Press: + this.action = 'Press'; + break; + case MouseAction.Move: + this.action = 'Move'; + break; + case MouseAction.Release: + this.action = 'Release'; + break; + } + this.mouseText = 'onMouse:\nButton = ' + this.mouseBtn + + '\nAction = ' + this.action + '\nXY=(' + event.x + ',' + event.y + ')' + + '\nscreenXY=(' + event.screenX + ',' + event.screenY + ')'; }) Text(this.mouseText) - }.padding({ top: 20 }).width('100%') + }.padding({ top: 30 }).width('100%') } } ``` + +示意图: + +鼠标悬浮时改变文本内容与背景颜色: + + ![mouse](figures/mouse.png) + +鼠标点击时: + +![mouse1](figures/mouse1.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-syntax-css.md b/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-syntax-css.md index 9838ed3a9b2b4ed23312e49a9b608bf59ebbd02d..809c934f24978bb4ef2350a1be405676b9174d34 100644 --- a/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-syntax-css.md +++ b/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-syntax-css.md @@ -7,8 +7,8 @@ CSS是描述HML页面结构的样式语言。所有组件均存在系统默认 ## 尺寸单位 1. 逻辑像素px(文档中以<length>表示): - 1. 默认卡片具有的逻辑宽度为150px(配置见[配置文件](js-service-widget-config-file.md#window)中的window小节),实际显示时会将页面布局缩放至屏幕实际宽度,如100px在宽度为300的卡片上,实际渲染为200物理像素(从150px向300物理像素,所有尺寸放大2倍)。 - 2. 额外配置autoDesignWidth为true时(配置见[配置文件](js-service-widget-config-file.md#window)中的window小节),逻辑像素px将按照屏幕密度进行缩放,如100px在屏幕密度为3的设备上,实际渲染为300物理像素。应用需要适配多种设备时,建议采用此方法。 + 1. 默认卡片具有的逻辑宽度为150px,实际显示时会将页面布局缩放至屏幕实际宽度,如100px在宽度为300的卡片上,实际渲染为200物理像素(从150px向300物理像素,所有尺寸放大2倍)。 + 2. 额外配置autoDesignWidth为true时,逻辑像素px将按照屏幕密度进行缩放,如100px在屏幕密度为3的设备上,实际渲染为300物理像素。应用需要适配多种设备时,建议采用此方法。 2. 百分比(文档中以<percentage>表示):表示该组件占父组件尺寸的百分比,如组件的width设置为50%,代表其宽度为父组件的50%。 diff --git a/zh-cn/application-dev/security/huks-guidelines.md b/zh-cn/application-dev/security/huks-guidelines.md index 3e8c29679158e3dbb7b5b0299be645bfe7fee706..ad21dacc614d44fe52b4829ebe8cdef4d5e7ff6d 100644 --- a/zh-cn/application-dev/security/huks-guidelines.md +++ b/zh-cn/application-dev/security/huks-guidelines.md @@ -1,134 +1,18 @@ # HUKS开发指导 -## 场景介绍 - - HUKS(OpenHarmony Universal KeyStore,OpenHarmony通用密钥库系统)向应用提供密钥库能力,包括密钥管理及密钥的密码学操作等功能。HUKS所管理的密钥可以由应用导入或者由应用调用HUKS接口生成。 - -## 基于JS的开发指导 - -1. 引入HUKS模块 - - ```js - import huks from '@ohos.security.huks' - ``` - -2. 使用generateKey接口生成密钥。 - - keyAlias为生成的密钥别名,options为生成密钥时使用到的参数,需根据具体需要到的算法设定options中的参数。 - - generateKey接口会返回密钥的生成是否成功。 - - ```js - var alias = 'testAlias'; - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224 - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE - }; - var options = { - properties: properties - } - var resultA = huks.generateKey(alias, options); - ``` - -3. 使用Init接口进行init操作。 - - Alias为初始化密钥的别名,options为初始化密钥用的参数集合,需根据具体需要到的算法设定options中的参数。 - - init接口会返回init操作是否成功。 - - ```js - var alias = 'test001' - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DH - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_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)}`); - } - }) - ``` - -4. 使用Update接口进行update操作。 - - handle为更新密钥的session id,options为更新密钥用的参数集合,需根据具体需要到的算法设定options中的参数。 - - update接口会返回update操作是否成功。 - - ```js - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DH - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_4096 - }; - var options = { - properties: properties - }; - var result = huks.update(handle, options) - ``` - -5. 使用Finish接口进行finish操作。 - - handle为 结束密钥的session id,options为结束密钥用的参数集合,需根据具体需要到的算法设定options中的参数。 - - finish接口会返回finish操作是否成功。 - - ```js - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DH - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_4096 - }; - var options = { - properties: properties - }; - var result = huks.finish(handle, options) - ``` - -## 基于TS的开发指导 +HUKS(OpenHarmony Universal KeyStore,OpenHarmony通用密钥库系统)向应用提供密钥库能力,包括密钥管理及密钥的密码学操作等功能。HUKS所管理的密钥可以由应用导入或者由应用调用HUKS接口生成。 + +> **说明** +> +> 本开发指导基于API version 9,仅适用于eTS语言开发 + +### **前提条件** + +在使用HUKS的接口开发前,需要引入HUKS模块 + +```ts +import huks from '@ohos.security.huks' +``` ### 密钥导入导出 @@ -168,98 +52,252 @@ RSA512, RSA768, RSA1024, RSA2048, RSA3072, RSA4096, ECC224, ECC256, ECC384, ECC5 **示例:** ```ts -/* 以生成RSA512密钥为例 */ +/* 以导出RSA512密钥及导入ECC256密钥为例 */ +import huks from '@ohos.security.huks'; + +function StringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicExportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback export`); + try { + await exportKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); + if (data.outData !== null) { + exportKey = data.outData; + } + }) + .catch(error => { + console.error(`callback: exportKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: exportKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function exportKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.exportKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicImportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter promise importKeyItem`); + try { + await importKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: importKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: importKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: importKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function importKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.importKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback deleteKeyItem`); + try { + await deleteKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + var srcKeyAlias = 'hukRsaKeyAlias'; var srcKeyAliasSecond = 'huksRsaKeyAliasSecond'; var exportKey; +var inputEccPair = new Uint8Array([ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0xa5, 0xb8, 0xa3, 0x78, 0x1d, 0x6d, 0x76, 0xe0, 0xb3, 0xf5, 0x6f, 0x43, + 0x9d, 0xcf, 0x60, 0xf6, 0x0b, 0x3f, 0x64, 0x45, 0xa8, 0x3f, 0x1a, 0x96, 0xf1, 0xa1, 0xa4, 0x5d, + 0x3e, 0x2c, 0x3f, 0x13, 0xd7, 0x81, 0xf7, 0x2a, 0xb5, 0x8d, 0x19, 0x3d, 0x9b, 0x96, 0xc7, 0x6a, + 0x10, 0xf0, 0xaa, 0xbc, 0x91, 0x6f, 0x4d, 0xa7, 0x09, 0xb3, 0x57, 0x88, 0x19, 0x6f, 0x00, 0x4b, + 0xad, 0xee, 0x34, 0x35, 0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, 0x2a, + 0x7c, 0x86, 0xba, 0xca, 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f, + 0x9e, 0x3c, 0xe5, 0xf9]); async function testImportExport() { /* 集成生成密钥参数集 */ - var properties = new Array(); - properties[0] = { + var exportProperties = new Array(); + exportProperties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_RSA, } - properties[1] = { + exportProperties[1] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, } - properties[2] = { + exportProperties[2] = { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, } - properties[3] = { + exportProperties[3] = { tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, value: huks.HuksCipherMode.HUKS_MODE_ECB, } - properties[4] = { + exportProperties[4] = { tag: huks.HuksTag.HUKS_TAG_PADDING, value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, } - properties[5] = { + exportProperties[5] = { tag: huks.HuksTag.HUKS_TAG_DIGEST, value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, } var huksOptions = { - properties: properties, + properties: exportProperties, inData: new Uint8Array(new Array()) } /* 生成密钥 */ - await huks.generateKey(srcKeyAlias, huksOptions).then((data) => { - console.info(`test generateKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test generateKey err information: ' + JSON.stringify(err)); - }); + await publicGenKeyFunc(srcKeyAlias, huksOptions); /* 导出密钥 */ - await huks.exportKey(srcKeyAlias, huksOptions).then((data) => { - console.info(`test ExportKey data: ${JSON.stringify(data)}`); - exportKey = data.outData; - }).catch((err) => { - console.info('test ImportKey err information: ' + JSON.stringify(err)); - }); + await publicExportKeyFunc(srcKeyAlias, huksOptions); /* 集成导入密钥参数集 */ - var propertiesEncrypt = new Array(); - propertiesEncrypt[0] = { + var importProperties = new Array(); + importProperties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA, - } - propertiesEncrypt[1] = { + value: huks.HuksKeyAlg.HUKS_ALG_ECC + }; + importProperties[1] = { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - } - propertiesEncrypt[2] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - } - propertiesEncrypt[3] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB, - } - propertiesEncrypt[4] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - } - propertiesEncrypt[5] = { + value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256 + }; + importProperties[2] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - } - var encryptOptions = { - properties: propertiesEncrypt, - inData: new Uint8Array(new Array()) - } + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP + }; + importProperties[3] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 + }; + importProperties[4] = { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR, + }; + var importOptions = { + properties: importProperties, + inData: inputEccPair + }; /* 导入密钥 */ - encryptOptions.inData = exportKey; - await huks.importKey(srcKeyAliasSecond, encryptOptions).then((data) => { - console.info(`test ImportKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test ImportKey err information: ' + JSON.stringify(err)); - }); + await publicImportKeyFunc(srcKeyAliasSecond, importOptions); + + await publicDeleteKeyFunc(srcKeyAlias, huksOptions); + await publicDeleteKeyFunc(srcKeyAliasSecond, importOptions); +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('testImportExport') + .fontSize(30) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(()=>{ + testImportExport(); + }) + } + .width('100%') + .height('100%') + } } ``` @@ -299,87 +337,211 @@ AES128, AES192, AES256, RSA512, RSA768, RSA1024, RSA2048, RSA3072, RSA4096, Hmac **示例:** ```ts -var inputEccPair = new Uint8Array([ - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xa5, 0xb8, - 0xa3, 0x78, 0x1d, 0x6d, 0x76, 0xe0, 0xb3, 0xf5, 0x6f, 0x43, 0x9d, - 0xcf, 0x60, 0xf6, 0x0b, 0x3f, 0x64, 0x45, 0xa8, 0x3f, 0x1a, 0x96, - 0xf1, 0xa1, 0xa4, 0x5d, 0x3e, 0x2c, 0x3f, 0x13, 0xd7, 0x81, 0xf7, - 0x2a, 0xb5, 0x8d, 0x19, 0x3d, 0x9b, 0x96, 0xc7, 0x6a, 0x10, 0xf0, - 0xaa, 0xbc, 0x91, 0x6f, 0x4d, 0xa7, 0x09, 0xb3, 0x57, 0x88, 0x19, - 0x6f, 0x00, 0x4b, 0xad, 0xee, 0x34, 0x35, 0xfb, 0x8b, 0x9f, 0x12, - 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, 0x2a, 0x7c, 0x86, 0xba, - 0xca, 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, 0x77, 0xbc, 0x71, 0xe3, - 0x0f, 0x0f, 0x9e, 0x3c, 0xe5, 0xf9]); - -var exportWrappingKey; -var importAlias = "importAlias"; -var wrapAlias = "wrappingKeyAlias"; +import huks from '@ohos.security.huks'; + +async function publicExportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback export`); + try { + await exportKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); + if (data.outData !== null) { + exportKey = data.outData; + } + }) + .catch(error => { + console.error(`callback: exportKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: exportKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} -async function TestGenFunc(alias, options) { - await genKey(alias, options).then((data) => { - console.log(`test genKey data: ${JSON.stringify(data)}`); - }) - .catch((err) => { - console.log('test genKey err information: ' + JSON.stringify(err)); +function exportKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.exportKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); } -function genKey(alias, options) { +async function publicImportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter promise importKeyItem`); + try { + await importKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: importKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: importKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: importKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function importKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { return new Promise((resolve, reject) => { - huks.importKey(alias, options, function (err, data) { - console.log(`test genKey data: ${JSON.stringify(data)}`); - if (err.code !== 0) { - console.log('test genKey err information: ' + JSON.stringify(err)); - reject(err); - } else { - resolve(data); - } - }); + try { + huks.importKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); } -async function TestExportFunc(alias, options) { - await exportKey(alias, options).then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`); - }) - .catch((err) => { - console.log('test exportKey err information: ' + JSON.stringify(err)); - }); +async function publicImportWrappedKey(keyAlias:string, wrappingKeyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback importWrappedKeyItem`); + try { + await importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions) + .then ((data) => { + console.info(`callback: importWrappedKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: importWrappedKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: importWrappedKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } } -function exportKey(alias, options) { +function importWrappedKeyItem(keyAlias:string, wrappingKeyAlias:string, huksOptions:huks.HuksOptions) { return new Promise((resolve, reject) => { - huks.exportKey(alias, options, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`); - if (err.code !== 0) { - console.log('test exportKey err information: ' + JSON.stringify(err)); - reject(err); - } else { - exportWrappingKey = data.outData; - resolve(data); - } - }); + try { + huks.importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); } -async function TestImportWrappedFunc(alias, wrappingAlias, options) { - var result = await huks.importWrappedKey(alias, wrappingAlias, options); - if (result.errorCode === 0) { - console.error('test importWrappedKey success'); - } else { - console.error('test importWrappedKey fail'); +async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback deleteKeyItem`); + try { + await deleteKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); } } -async function TestImportWrappedKeyFunc( - importAlias, - wrappingAlias, - genOptions, - importOptions -) { - await TestGenFunc(wrappingAlias, genOptions); - await TestExportFunc(wrappingAlias, genOptions); +function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +var importAlias = "importAlias"; +var wrapAlias = "wrappingKeyAlias"; +var exportKey; + +var inputEccPair = new Uint8Array([ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0xa5, 0xb8, 0xa3, 0x78, 0x1d, 0x6d, 0x76, 0xe0, 0xb3, 0xf5, 0x6f, 0x43, + 0x9d, 0xcf, 0x60, 0xf6, 0x0b, 0x3f, 0x64, 0x45, 0xa8, 0x3f, 0x1a, 0x96, 0xf1, 0xa1, 0xa4, 0x5d, + 0x3e, 0x2c, 0x3f, 0x13, 0xd7, 0x81, 0xf7, 0x2a, 0xb5, 0x8d, 0x19, 0x3d, 0x9b, 0x96, 0xc7, 0x6a, + 0x10, 0xf0, 0xaa, 0xbc, 0x91, 0x6f, 0x4d, 0xa7, 0x09, 0xb3, 0x57, 0x88, 0x19, 0x6f, 0x00, 0x4b, + 0xad, 0xee, 0x34, 0x35, 0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, 0x2a, + 0x7c, 0x86, 0xba, 0xca, 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f, + 0x9e, 0x3c, 0xe5, 0xf9]); + +var properties = new Array(); +properties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_ECC +}; +properties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256 +}; +properties[2] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP +}; +properties[3] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 +}; +properties[4] = { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR, +}; +var huksOptions = { + properties: properties, + inData: inputEccPair +}; + +var importProperties = new Array(); +importProperties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES +}; +importProperties[1] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 +}; +importProperties[2] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT +}; +importProperties[3] = { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC +}; +importProperties[4] = { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_NONE +}; +importProperties[5] = { + tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE, + value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING +}; +var importOptions = { + properties: importProperties, + inData: new Uint8Array(new Array()) +}; + +async function importWrappedKeyItemTest() { + + console.info(`enter ImportWrapKey test`); + await publicImportKeyFunc(wrapAlias, huksOptions); + + await publicExportKeyFunc(wrapAlias, huksOptions); /* 以下操作不需要调用HUKS接口,此处不给出具体实现。 * 假设待导入的密钥为keyA @@ -395,110 +557,55 @@ async function TestImportWrappedKeyFunc( * keyA长度占用的内存长度(4字节) + keyA的长度 + keyA_enc的长度(4字节) + keyA_enc的数据 */ var inputKey = new Uint8Array([ - 0x5b, 0x00, 0x00, 0x00, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, - 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, - 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xc0, 0xfe, - 0x1c, 0x67, 0xde, 0x86, 0x0e, 0xfb, 0xaf, 0xb5, 0x85, 0x52, 0xb4, - 0x0e, 0x1f, 0x6c, 0x6c, 0xaa, 0xc5, 0xd9, 0xd2, 0x4d, 0xb0, 0x8a, - 0x72, 0x24, 0xa1, 0x99, 0xaf, 0xfc, 0x3e, 0x55, 0x5a, 0xac, 0x99, - 0x3d, 0xe8, 0x34, 0x72, 0xb9, 0x47, 0x9c, 0xa6, 0xd8, 0xfb, 0x00, - 0xa0, 0x1f, 0x9f, 0x7a, 0x41, 0xe5, 0x44, 0x3e, 0xb2, 0x76, 0x08, - 0xa2, 0xbd, 0xe9, 0x41, 0xd5, 0x2b, 0x9e, 0x10, 0x00, 0x00, 0x00, - 0xbf, 0xf9, 0x69, 0x41, 0xf5, 0x49, 0x85, 0x31, 0x35, 0x14, 0x69, - 0x12, 0x57, 0x9c, 0xc8, 0xb7, 0x10, 0x00, 0x00, 0x00, 0x2d, 0xb7, - 0xf1, 0x5a, 0x0f, 0xb8, 0x20, 0xc5, 0x90, 0xe5, 0xca, 0x45, 0x84, - 0x5c, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x43, 0x25, 0x1b, 0x2f, - 0x5b, 0x86, 0xd8, 0x87, 0x04, 0x4d, 0x38, 0xc2, 0x65, 0xcc, 0x9e, - 0xb7, 0x20, 0x00, 0x00, 0x00, 0xf4, 0xe8, 0x93, 0x28, 0x0c, 0xfa, - 0x4e, 0x11, 0x6b, 0xe8, 0xbd, 0xa8, 0xe9, 0x3f, 0xa7, 0x8f, 0x2f, - 0xe3, 0xb3, 0xbf, 0xaf, 0xce, 0xe5, 0x06, 0x2d, 0xe6, 0x45, 0x5d, - 0x19, 0x26, 0x09, 0xe7, 0x10, 0x00, 0x00, 0x00, 0xf4, 0x1e, 0x7b, - 0x01, 0x7a, 0x84, 0x36, 0xa4, 0xa8, 0x1c, 0x0d, 0x3d, 0xde, 0x57, - 0x66, 0x73, 0x10, 0x00, 0x00, 0x00, 0xe3, 0xff, 0x29, 0x97, 0xad, - 0xb3, 0x4a, 0x2c, 0x50, 0x08, 0xb5, 0x68, 0xe1, 0x90, 0x5a, 0xdc, - 0x10, 0x00, 0x00, 0x00, 0x26, 0xae, 0xdc, 0x4e, 0xa5, 0x6e, 0xb1, - 0x38, 0x14, 0x24, 0x47, 0x1c, 0x41, 0x89, 0x63, 0x11, 0x04, 0x00, - 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x0b, - 0xcb, 0xa9, 0xa8, 0x5f, 0x5a, 0x9d, 0xbf, 0xa1, 0xfc, 0x72, 0x74, - 0x87, 0x79, 0xf2, 0xf4, 0x22, 0x0c, 0x8a, 0x4d, 0xd8, 0x7e, 0x10, - 0xc8, 0x44, 0x17, 0x95, 0xab, 0x3b, 0xd2, 0x8f, 0x0a]); + 0x5b, 0x00, 0x00, 0x00, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, + 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xc0, + 0xfe, 0x1c, 0x67, 0xde, 0x86, 0x0e, 0xfb, 0xaf, 0xb5, 0x85, 0x52, 0xb4, 0x0e, 0x1f, 0x6c, 0x6c, + 0xaa, 0xc5, 0xd9, 0xd2, 0x4d, 0xb0, 0x8a, 0x72, 0x24, 0xa1, 0x99, 0xaf, 0xfc, 0x3e, 0x55, 0x5a, + 0xac, 0x99, 0x3d, 0xe8, 0x34, 0x72, 0xb9, 0x47, 0x9c, 0xa6, 0xd8, 0xfb, 0x00, 0xa0, 0x1f, 0x9f, + 0x7a, 0x41, 0xe5, 0x44, 0x3e, 0xb2, 0x76, 0x08, 0xa2, 0xbd, 0xe9, 0x41, 0xd5, 0x2b, 0x9e, 0x10, + 0x00, 0x00, 0x00, 0xbf, 0xf9, 0x69, 0x41, 0xf5, 0x49, 0x85, 0x31, 0x35, 0x14, 0x69, 0x12, 0x57, + 0x9c, 0xc8, 0xb7, 0x10, 0x00, 0x00, 0x00, 0x2d, 0xb7, 0xf1, 0x5a, 0x0f, 0xb8, 0x20, 0xc5, 0x90, + 0xe5, 0xca, 0x45, 0x84, 0x5c, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x43, 0x25, 0x1b, 0x2f, 0x5b, + 0x86, 0xd8, 0x87, 0x04, 0x4d, 0x38, 0xc2, 0x65, 0xcc, 0x9e, 0xb7, 0x20, 0x00, 0x00, 0x00, 0xf4, + 0xe8, 0x93, 0x28, 0x0c, 0xfa, 0x4e, 0x11, 0x6b, 0xe8, 0xbd, 0xa8, 0xe9, 0x3f, 0xa7, 0x8f, 0x2f, + 0xe3, 0xb3, 0xbf, 0xaf, 0xce, 0xe5, 0x06, 0x2d, 0xe6, 0x45, 0x5d, 0x19, 0x26, 0x09, 0xe7, 0x10, + 0x00, 0x00, 0x00, 0xf4, 0x1e, 0x7b, 0x01, 0x7a, 0x84, 0x36, 0xa4, 0xa8, 0x1c, 0x0d, 0x3d, 0xde, + 0x57, 0x66, 0x73, 0x10, 0x00, 0x00, 0x00, 0xe3, 0xff, 0x29, 0x97, 0xad, 0xb3, 0x4a, 0x2c, 0x50, + 0x08, 0xb5, 0x68, 0xe1, 0x90, 0x5a, 0xdc, 0x10, 0x00, 0x00, 0x00, 0x26, 0xae, 0xdc, 0x4e, 0xa5, + 0x6e, 0xb1, 0x38, 0x14, 0x24, 0x47, 0x1c, 0x41, 0x89, 0x63, 0x11, 0x04, 0x00, 0x00, 0x00, 0x20, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x0b, 0xcb, 0xa9, 0xa8, 0x5f, 0x5a, 0x9d, 0xbf, 0xa1, + 0xfc, 0x72, 0x74, 0x87, 0x79, 0xf2, 0xf4, 0x22, 0x0c, 0x8a, 0x4d, 0xd8, 0x7e, 0x10, 0xc8, 0x44, + 0x17, 0x95, 0xab, 0x3b, 0xd2, 0x8f, 0x0a + ]); importOptions.inData = inputKey; - await TestImportWrappedFunc(importAlias, wrappingAlias, importOptions); -} + await publicImportWrappedKey(importAlias, wrapAlias, importOptions); -function makePubKeyOptions() { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256 - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, - value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR, - }; - var options = { - properties: properties, - inData: inputEccPair - }; - return options; + await publicDeleteKeyFunc(wrapAlias, huksOptions); + await publicDeleteKeyFunc(importAlias, importOptions); } -function makeImportOptions() { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }; - properties[5] = { - tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE, - value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING - }; - var options = { - properties: properties - }; - return options; -} - -function huksImportWrappedKey() { - var genOptions = makePubKeyOptions(); - var importOptions = makeImportOptions(); - TestImportWrappedKeyFunc( - importAlias, - wrapAlias, - genOptions, - importOptions - ); +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('importWrappedKeyItemTest') + .fontSize(30) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(()=>{ + importWrappedKeyItemTest(); + }) + } + .width('100%') + .height('100%') + } } ``` @@ -553,14 +660,17 @@ function huksImportWrappedKey() { * * 以下以SM4 128密钥的Promise操作使用为例 */ -function sm4CipherStringToUint8Array(str) { +import huks from '@ohos.security.huks'; + +function StringToUint8Array(str) { var arr = []; for (var i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); } return new Uint8Array(arr); } -function sm4CipherUint8ArrayToString(fileData) { + +function Uint8ArrayToString(fileData) { var dataString = ''; for (var i = 0; i < fileData.length; i++) { dataString += String.fromCharCode(fileData[i]); @@ -568,14 +678,157 @@ function sm4CipherUint8ArrayToString(fileData) { return dataString; } -var handle; +async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicInitFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter promise doInit`); + try { + await huks.initSession(keyAlias, huksOptions) + .then ((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch(error => { + console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function publicUpdateFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doUpdate`); + try { + await updateSession(handle, huksOptions) + .then ((data) => { + console.info(`callback: doUpdate success, data = ${JSON.stringify(data)}`); + updateResult = Array.from(data.outData); + }) + .catch(error => { + console.error(`callback: doUpdate failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doUpdate input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function updateSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.updateSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicFinishFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doFinish`); + try { + await finishSession(handle, huksOptions) + .then ((data) => { + finishOutData = Uint8ArrayToString(new Uint8Array(updateResult)); + console.info(`callback: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: doFinish failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doFinish input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function finishSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback deleteKeyItem`); + try { + await deleteKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + var IV = '0000000000000000'; var cipherInData = 'Hks_SM4_Cipher_Test_101010101010101010110_string'; var srcKeyAlias = 'huksCipherSm4SrcKeyAlias'; var encryptUpdateResult = new Array(); -var decryptUpdateResult = new Array(); +var handle; +var updateResult = new Array(); +var finishOutData; -async function testCipher() { +async function testSm4Cipher() { /* 集成生成密钥参数集 & 加密参数集 */ var properties = new Array(); properties[0] = { @@ -628,7 +881,7 @@ async function testCipher() { } propertiesEncrypt[5] = { tag: huks.HuksTag.HUKS_TAG_IV, - value: sm4CipherStringToUint8Array(IV), + value: StringToUint8Array(IV), } var encryptOptions = { properties: propertiesEncrypt, @@ -636,38 +889,22 @@ async function testCipher() { } /* 生成密钥 */ - await huks.generateKey(srcKeyAlias, huksOptions).then((data) => { - console.info(`test generateKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test generateKey err information: ' + JSON.stringify(err)); - }); + await publicGenKeyFunc(srcKeyAlias, huksOptions); /* 进行密钥加密操作 */ - await huks.init(srcKeyAlias, encryptOptions).then((data) => { - console.info(`test init data: ${JSON.stringify(data)}`); - handle = data.handle; - }).catch((err) => { - console.info('test init err information: ' + JSON.stringify(err)); - }); - encryptOptions.inData = sm4CipherStringToUint8Array(cipherInData); - await huks.update(handle, encryptOptions).then(async (data) => { - console.info(`test update data ${JSON.stringify(data)}`); - encryptUpdateResult = Array.from(data.outData); - }).catch((err) => { - console.info('test update err information: ' + err); - }); + await publicInitFunc(srcKeyAlias, encryptOptions); + + encryptOptions.inData = StringToUint8Array(cipherInData); + await publicUpdateFunc(handle, encryptOptions); + encryptUpdateResult = updateResult; + encryptOptions.inData = new Uint8Array(new Array()); - await huks.finish(handle, encryptOptions).then((data) => { - console.info(`test finish data: ${JSON.stringify(data)}`); - var finishData = sm4CipherUint8ArrayToString(new Uint8Array(encryptUpdateResult)); - if (finishData === cipherInData) { - console.info('test finish encrypt err '); - } else { - console.info('test finish encrypt success'); - } - }).catch((err) => { - console.info('test finish err information: ' + JSON.stringify(err)); - }); + await publicFinishFunc(handle, encryptOptions); + if (finishOutData === cipherInData) { + console.info('test finish encrypt err '); + } else { + console.info('test finish encrypt success'); + } /* 修改加密参数集为解密参数集 */ propertiesEncrypt.splice(1, 1, { @@ -680,37 +917,43 @@ async function testCipher() { } /* 进行解密操作 */ - await huks.init(srcKeyAlias, decryptOptions).then((data) => { - console.info(`test init data: ${JSON.stringify(data)}`); - handle = data.handle; - }).catch((err) => { - console.info('test init err information: ' + JSON.stringify(err)); - }); + await publicInitFunc(srcKeyAlias, decryptOptions); + decryptOptions.inData = new Uint8Array(encryptUpdateResult); - await huks.update(handle, decryptOptions).then(async (data) => { - console.info(`test update data ${JSON.stringify(data)}`); - decryptUpdateResult = Array.from(data.outData); - }).catch((err) => { - console.info('test update err information: ' + err); - }); + await publicUpdateFunc(handle, decryptOptions); + decryptOptions.inData = new Uint8Array(new Array()); - await huks.finish(handle, decryptOptions).then((data) => { - console.info(`test finish data: ${JSON.stringify(data)}`); - var finishData = sm4CipherUint8ArrayToString(new Uint8Array(decryptUpdateResult)); - if (finishData === cipherInData) { - console.info('test finish decrypt success '); - } else { - console.info('test finish decrypt err'); - } - }).catch((err) => { - console.info('test finish err information: ' + JSON.stringify(err)); - }); + await publicFinishFunc(handle, decryptOptions); + if (finishOutData === cipherInData) { + console.info('test finish decrypt success '); + } else { + console.info('test finish decrypt err'); + } - await huks.deleteKey(srcKeyAlias, huksOptions).then((data) => { - console.info(`test deleteKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test deleteKey err information: ' + JSON.stringify(err)); - }); + await publicDeleteKeyFunc(srcKeyAlias, huksOptions); +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('testSm4Cipher') + .fontSize(30) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(()=>{ + testSm4Cipher(); + }) + } + .width('100%') + .height('100%') + } } ``` @@ -721,14 +964,17 @@ async function testCipher() { * * 以下以AES128 GCM密钥的Promise操作使用为例 */ -function aesCipherStringToUint8Array(str) { +import huks from '@ohos.security.huks'; + +function StringToUint8Array(str) { var arr = []; for (var i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); } return new Uint8Array(arr); } -function aesCipherUint8ArrayToString(fileData) { + +function Uint8ArrayToString(fileData) { var dataString = ''; for (var i = 0; i < fileData.length; i++) { dataString += String.fromCharCode(fileData[i]); @@ -736,15 +982,160 @@ function aesCipherUint8ArrayToString(fileData) { return dataString; } -async function aesCipher() { - var handle; - var AAD = '0000000000000000'; - var NONCE = '000000000000'; - var AEAD = '0000000000000000'; - var cipherInData = 'Hks_AES_Cipher_Test_00000000000000000000000000000000000000000000000000000_string'; - var srcKeyAlias = 'huksCipherAesSrcKeyAlias'; - var encryptUpdateResult = new Array(); - var decryptUpdateResult = new Array(); +async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicInitFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter promise doInit`); + try { + await huks.initSession(keyAlias, huksOptions) + .then ((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch(error => { + console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function publicUpdateFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doUpdate`); + try { + await updateSession(handle, huksOptions) + .then ((data) => { + console.info(`callback: doUpdate success, data = ${JSON.stringify(data)}`); + updateResult = Array.from(data.outData); + }) + .catch(error => { + console.error(`callback: doUpdate failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doUpdate input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function updateSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.updateSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicFinishFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doFinish`); + try { + await finishSession(handle, huksOptions) + .then ((data) => { + updateResult = updateResult.concat(Array.from(data.outData)); + console.info(`callback: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: doFinish failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doFinish input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function finishSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback deleteKeyItem`); + try { + await deleteKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +var AAD = '0000000000000000'; +var NONCE = '000000000000'; +var AEAD = '0000000000000000'; +var cipherInData = 'Hks_AES_Cipher_Test_00000000000000000000000000000000000000000000000000000_string'; +var srcKeyAlias = 'huksCipherSm4SrcKeyAlias'; +var updateResult = new Array(); +var encryptUpdateResult = new Array(); +var decryptUpdateResult = new Array(); +var handle; +var finishOutData; + +async function testAesCipher() { /* 集成生成密钥参数集 & 加密参数集 */ var properties = new Array(); properties[0] = { @@ -769,7 +1160,7 @@ async function aesCipher() { tag: huks.HuksTag.HUKS_TAG_PADDING, value: huks.HuksKeyPadding.HUKS_PADDING_NONE, } - var HuksOptions = { + var huksOptions = { properties: properties, inData: new Uint8Array(new Array()) } @@ -801,15 +1192,15 @@ async function aesCipher() { } propertiesEncrypt[6] = { tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA, - value: aesCipherStringToUint8Array(AAD), + value: StringToUint8Array(AAD), } propertiesEncrypt[7] = { tag: huks.HuksTag.HUKS_TAG_NONCE, - value: aesCipherStringToUint8Array(NONCE), + value: StringToUint8Array(NONCE), } propertiesEncrypt[8] = { tag: huks.HuksTag.HUKS_TAG_AE_TAG, - value: aesCipherStringToUint8Array(AEAD), + value: StringToUint8Array(AEAD), } var encryptOptions = { properties: propertiesEncrypt, @@ -817,39 +1208,24 @@ async function aesCipher() { } /* 生成密钥 */ - await huks.generateKey(srcKeyAlias, HuksOptions).then((data) => { - console.info(`test generateKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test generateKey err information: ' + JSON.stringify(err)); - }); + await publicGenKeyFunc(srcKeyAlias, huksOptions); /* 进行密钥加密操作 */ - await huks.init(srcKeyAlias, encryptOptions).then((data) => { - console.info(`test init data: ${JSON.stringify(data)}`); - handle = data.handle; - }).catch((err) => { - console.info('test init err information: ' + JSON.stringify(err)); - }); - encryptOptions.inData = aesCipherStringToUint8Array(cipherInData.slice(0,64)); - await huks.update(handle, encryptOptions).then(async (data) => { - console.info(`test update data ${JSON.stringify(data)}`); - encryptUpdateResult = Array.from(data.outData); - }).catch((err) => { - console.info('test update err information: ' + err); - }); - encryptOptions.inData = aesCipherStringToUint8Array(cipherInData.slice(64,80)); - await huks.finish(handle, encryptOptions).then((data) => { - console.info(`test finish data: ${JSON.stringify(data)}`); - encryptUpdateResult = encryptUpdateResult.concat(Array.from(data.outData)); - var finishData = aesCipherUint8ArrayToString(new Uint8Array(encryptUpdateResult)); - if (finishData === cipherInData) { - console.info('test finish encrypt err '); - } else { - console.info('test finish encrypt success'); - } - }).catch((err) => { - console.info('test finish err information: ' + JSON.stringify(err)); - }); + await publicInitFunc(srcKeyAlias, encryptOptions); + + encryptOptions.inData = StringToUint8Array(cipherInData.slice(0,64)); + await publicUpdateFunc(handle, encryptOptions); + encryptUpdateResult = updateResult; + + encryptOptions.inData = StringToUint8Array(cipherInData.slice(64,80)); + await publicFinishFunc(handle, encryptOptions); + encryptUpdateResult = updateResult; + finishOutData = Uint8ArrayToString(new Uint8Array(encryptUpdateResult)); + if (finishOutData === cipherInData) { + console.info('test finish encrypt err '); + } else { + console.info('test finish encrypt success'); + } /* 修改加密参数集为解密参数集 */ propertiesEncrypt.splice(1, 1, { @@ -866,38 +1242,46 @@ async function aesCipher() { } /* 进行解密操作 */ - await huks.init(srcKeyAlias, decryptOptions).then((data) => { - console.info(`test init data: ${JSON.stringify(data)}`); - handle = data.handle; - }).catch((err) => { - console.info('test init err information: ' + JSON.stringify(err)); - }); + await publicInitFunc(srcKeyAlias, decryptOptions); + decryptOptions.inData = new Uint8Array(encryptUpdateResult.slice(0,64)); - await huks.update(handle, decryptOptions).then(async (data) => { - console.info(`test update data ${JSON.stringify(data)}`); - decryptUpdateResult = Array.from(data.outData); - }).catch((err) => { - console.info('test update err information: ' + err); - }); + await publicUpdateFunc(handle, decryptOptions); + decryptUpdateResult = updateResult; + decryptOptions.inData = new Uint8Array(encryptUpdateResult.slice(64,encryptUpdateResult.length)); - await huks.finish(handle, decryptOptions).then((data) => { - console.info(`test finish data: ${JSON.stringify(data)}`); - decryptUpdateResult = decryptUpdateResult.concat(Array.from(data.outData)); - var finishData = aesCipherUint8ArrayToString(new Uint8Array(decryptUpdateResult)); - if (finishData === cipherInData) { - console.info('test finish decrypt success '); - } else { - console.info('test finish decrypt err'); - } - }).catch((err) => { - console.info('test finish err information: ' + JSON.stringify(err)); - }); + await publicFinishFunc(handle, decryptOptions); + decryptUpdateResult = updateResult; + finishOutData = Uint8ArrayToString(new Uint8Array(decryptUpdateResult)); + if (finishOutData === cipherInData) { + console.info('test finish decrypt success '); + } else { + console.info('test finish decrypt err'); + } - await huks.deleteKey(srcKeyAlias, HuksOptions).then((data) => { - console.info(`test deleteKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test deleteKey err information: ' + JSON.stringify(err)); - }); + await publicDeleteKeyFunc(srcKeyAlias, huksOptions); +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('testAesCipher') + .fontSize(30) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(()=>{ + testAesCipher(); + }) + } + .width('100%') + .height('100%') + } } ``` @@ -938,13 +1322,13 @@ Update过程只将inData发送到Core中记录在ctx中,不进行Hash计算, 在使用示例前,需要先了解几个预先定义的变量: -| 参数名 | 类型 | 必填 | 说明 | -| -------------------- | ----------- | ---- | ------------------------ | -| srcRsaKeyAliasSign | string | 是 | 生成密钥别名。 | -| srcRsaKeyAliasVerify | string | 是 | 导入密钥别名。 | -| rsaSignOptions | HuksOptions | 是 | 用于存放生成key所需TAG。 | -| rsaSignOptionsSecond | HuksOptions | 是 | 用于存放签名key所需TAG。 | -| rsaVerifyOptions | HuksOptions | 是 | 用于存放验签key所需TAG。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | ----------- | ---- | ------------------------ | +| generateKeyAlias | string | 是 | 生成密钥别名。 | +| importKeyAlias | string | 是 | 导入密钥别名。 | +| genrateKeyOptions | HuksOptions | 是 | 用于存放生成key所需TAG。 | +| signOptions | HuksOptions | 是 | 用于存放签名key所需TAG。 | +| verifyOptions | HuksOptions | 是 | 用于存放验签key所需TAG。 | 关于接口的具体信息,可在[API参考文档](../reference/apis/js-apis-huks.md)中查看。 @@ -953,9 +1337,11 @@ Update过程只将inData发送到Core中记录在ctx中,不进行Hash计算, ```ts /* Sign/Verify操作支持RSA、ECC、SM2、ED25519、DSA类型的密钥。 * - * 以下以RSA512密钥的Promise操作使用为例 + * 以下以SM2密钥的Callback操作使用为例 */ -function rsaSignVerifyStringToUint8Array(str) { +import huks from '@ohos.security.huks'; + +function StringToUint8Array(str) { var arr = []; for (var i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); @@ -963,168 +1349,367 @@ function rsaSignVerifyStringToUint8Array(str) { return new Uint8Array(arr); } -var rsaSignHandle; -var rsaSignVerifyInData = 'signVerifyInData'; -var srcRsaKeyAliasSign = 'huksSignVerifySrcKeyAliasSign'; -var srcRsaKeyAliasVerify = 'huksSignVerifySrcKeyAliasVerify'; -var finishRsaSignData; -var rsaExportSignKey; - -async function testSignVerify() { - /* 集成生成密钥参数集 & 签名参数集 & 验签参数集 */ - var rsaSignProperties = new Array(); - rsaSignProperties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA, - } - rsaSignProperties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - } - rsaSignProperties[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - } - rsaSignProperties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_MD5, - } - rsaSignProperties[4] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - } - var rsaSignOptions = { - properties: rsaSignProperties, - inData: new Uint8Array(new Array()) +async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); } +} - var rsaPropertiesSign = new Array(); - rsaPropertiesSign[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA, - } - rsaPropertiesSign[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN - } - rsaPropertiesSign[2] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_MD5, - } - rsaPropertiesSign[3] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - } - rsaPropertiesSign[4] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - } - var rsaSignOptionsSecond = { - properties: rsaPropertiesSign, - inData: new Uint8Array(new Array()) - } +function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} - var rsaPropertiesVerify = new Array(); - rsaPropertiesVerify[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA, - } - rsaPropertiesVerify[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - } - rsaPropertiesVerify[2] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_MD5, - } - rsaPropertiesVerify[3] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - } - rsaPropertiesVerify[4] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - } - var rsaVerifyOptions = { - properties: rsaPropertiesVerify, - inData: new Uint8Array(new Array()) +async function publicInitFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback doInit`); + try { + await initSession(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback1: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch((error) => { + console.error(`callback1: doInit failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); } +} - /* 生成密钥 */ - await huks.generateKey(srcRsaKeyAliasSign, rsaSignOptions).then((data) => { - console.info(`test generateKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test generateKey err information: ' + JSON.stringify(err)); +function initSession(keyAlias:string, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.initSession(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); +} - /* 对密钥进行签名操作 */ - await huks.init(srcRsaKeyAliasSign, rsaSignOptionsSecond).then((data) => { - console.info(`test init data: ${JSON.stringify(data)}`); - rsaSignHandle = data.handle; - }).catch((err) => { - console.info('test init err information: ' + JSON.stringify(err)); - }); - rsaSignOptionsSecond.inData = rsaSignVerifyStringToUint8Array(rsaSignVerifyInData) - await huks.update(rsaSignHandle, rsaSignOptionsSecond).then(async (data) => { - console.info(`test update data ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test update err information: ' + err); - }); - rsaSignOptionsSecond.inData = new Uint8Array(new Array()); - await huks.finish(rsaSignHandle, rsaSignOptionsSecond).then((data) => { - console.info(`test finish data: ${JSON.stringify(data)}`); - finishRsaSignData = data.outData; - }).catch((err) => { - console.info('test finish err information: ' + JSON.stringify(err)); - }); +async function publicUpdateFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doUpdate`); + try { + await updateSession(handle, huksOptions) + .then ((data) => { + console.info(`callback: doUpdate success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: doUpdate failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doUpdate input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} - /* 通过导出导入模拟获取一段密钥数据 */ - await huks.exportKey(srcRsaKeyAliasSign, rsaSignOptions).then((data) => { - console.info(`test exportKey data: ${JSON.stringify(data)}`); - rsaExportSignKey = data.outData; - }).catch((err) => { - console.info('test exportKey err information: ' + JSON.stringify(err)); - }); - rsaVerifyOptions.inData = rsaExportSignKey; - await huks.importKey(srcRsaKeyAliasVerify, rsaVerifyOptions).then((data) => { - console.info(`test ImportKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test exportKey err information: ' + JSON.stringify(err)); +function updateSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.updateSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); +} - /* 对密钥进行验签 */ - await huks.init(srcRsaKeyAliasVerify, rsaVerifyOptions).then((data) => { - console.info(`test init data: ${JSON.stringify(data)}`); - rsaSignHandle = data.handle; - }).catch((err) => { - console.info('test init err information: ' + JSON.stringify(err)); - }); - rsaVerifyOptions.inData = rsaSignVerifyStringToUint8Array(rsaSignVerifyInData); - await huks.update(rsaSignHandle, rsaVerifyOptions).then(async (data) => { - console.info(`test update data ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test update err information: ' + err); +async function publicFinishFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doFinish`); + try { + await finishSession(handle, huksOptions) + .then ((data) => { + finishOutData = data.outData;; + console.info(`callback: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: doFinish failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doFinish input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function finishSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); - rsaVerifyOptions.inData = finishRsaSignData; - await huks.finish(rsaSignHandle, rsaVerifyOptions).then((data) => { - console.info(`test finish data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test finish err information: ' + JSON.stringify(err)); +} + +async function publicExportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback export`); + try { + await exportKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); + exportKey = data.outData; + }) + .catch(error => { + console.error(`callback: exportKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: exportKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function exportKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.exportKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); +} + +async function publicImportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter promise importKeyItem`); + try { + await importKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: importKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: importKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: importKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} - await huks.deleteKey(srcRsaKeyAliasVerify, rsaVerifyOptions).then((data) => { - console.info(`test deleteKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test deleteKey err information: ' + JSON.stringify(err)); +function importKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.importKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); +} + +async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback deleteKeyItem`); + try { + await deleteKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} - await huks.deleteKey(srcRsaKeyAliasSign, rsaSignOptions).then((data) => { - console.info(`test deleteKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test deleteKey err information: ' + JSON.stringify(err)); +function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } }); } + +var signVerifyInData = 'signVerifyInDataForTest'; +var generateKeyAlias = 'generateKeyAliasForTest'; +var importKeyAlias = 'importKeyAliasForTest'; +var handle; +var exportKey; +var finishOutData; + +/* 集成生成密钥参数集 */ +var generateKeyProperties = new Array(); +generateKeyProperties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM2, +} +generateKeyProperties[1] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, +} +generateKeyProperties[2] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256, +} +generateKeyProperties[3] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SM3, +} +var genrateKeyOptions = { + properties: generateKeyProperties, + inData: new Uint8Array(new Array()) +} + +/* 集成签名参数集 */ +var signProperties = new Array(); +signProperties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM2, +} +signProperties[1] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN +} +signProperties[2] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SM3, +} +signProperties[3] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256, +} +var signOptions = { + properties: signProperties, + inData: new Uint8Array(new Array()) +} + +/* 集成验签参数集 */ +var verifyProperties = new Array(); +verifyProperties[0] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_SM2, +} +verifyProperties[1] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY +} +verifyProperties[2] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_SM3, +} +verifyProperties[3] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256, +} +var verifyOptions = { + properties: verifyProperties, + inData: new Uint8Array(new Array()) +} + +async function testSm2SignVerify() { + /* 生成密钥 */ + await publicGenKeyFunc(generateKeyAlias, genrateKeyOptions); + + /* 签名 */ + var signHandle; + var signFinishOutData; + await publicInitFunc(generateKeyAlias, signOptions); + + signHandle = handle; + signOptions.inData = StringToUint8Array(signVerifyInData) + await publicUpdateFunc(signHandle, signOptions); + + signOptions.inData = new Uint8Array(new Array()); + await publicFinishFunc(signHandle, signOptions); + signFinishOutData = finishOutData; + + /* 导出密钥 */ + await publicExportKeyFunc(generateKeyAlias, genrateKeyOptions); + + /* 导入密钥 */ + verifyOptions.inData = exportKey; + await publicImportKeyFunc(importKeyAlias, verifyOptions); + + /* 验证签名 */ + var verifyHandle; + await publicInitFunc(importKeyAlias, verifyOptions); + + verifyHandle = handle; + + verifyOptions.inData = StringToUint8Array(signVerifyInData) + await publicUpdateFunc(verifyHandle, verifyOptions); + + verifyOptions.inData = signFinishOutData; + await publicFinishFunc(verifyHandle, verifyOptions); + + await publicDeleteKeyFunc(generateKeyAlias, genrateKeyOptions); + await publicDeleteKeyFunc(importKeyAlias, genrateKeyOptions); +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('testSm2SignVerify') + .fontSize(30) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(()=>{ + testSm2SignVerify(); + }) + } + .width('100%') + .height('100%') + } +} ``` ### 密钥协商 @@ -1185,7 +1770,9 @@ HksFinish对paramSet中参数的要求: * * 以下以X25519 256 TEMP密钥的Promise操作使用为例 */ -function AgreeStringToUint8Array(str) { +import huks from '@ohos.security.huks'; + +function StringToUint8Array(str) { var arr = []; for (var i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); @@ -1193,9 +1780,199 @@ function AgreeStringToUint8Array(str) { return new Uint8Array(arr); } +async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicInitFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback doInit`); + try { + await initSession(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback1: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch((error) => { + console.error(`callback1: doInit failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function initSession(keyAlias:string, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.initSession(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicUpdateFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doUpdate`); + try { + await updateSession(handle, huksOptions) + .then ((data) => { + console.info(`callback: doUpdate success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: doUpdate failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doUpdate input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function updateSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.updateSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicFinishFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doFinish`); + try { + await finishSession(handle, huksOptions) + .then ((data) => { + console.info(`callback: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: doFinish failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doFinish input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function finishSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicExportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback export`); + try { + await exportKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); + exportKey = data.outData; + }) + .catch(error => { + console.error(`callback: exportKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: exportKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function exportKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.exportKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback deleteKeyItem`); + try { + await deleteKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + var srcKeyAliasFirst = "AgreeX25519KeyFirstAlias"; var srcKeyAliasSecond = "AgreeX25519KeySecondAlias"; var agreeX25519InData = 'AgreeX25519TestIndata'; +var handle; +var exportKey; var exportKeyFrist; var exportKeySecond; @@ -1232,28 +2009,13 @@ async function testAgree() { } /* 1.生成两个密钥并导出 */ - await huks.generateKey(srcKeyAliasFirst, HuksOptions).then((data) => { - console.info('test generateKey data = ' + JSON.stringify(data)); - }).catch((err) => { - console.info(`test generateKey err: " + ${JSON.stringify(err)}`); - }); - await huks.generateKey(srcKeyAliasSecond, HuksOptions).then((data) => { - console.info('test generateKey data = ' + JSON.stringify(data)); - }).catch((err) => { - console.info(`test generateKey err: " + ${JSON.stringify(err)}`); - }); - await huks.exportKey(srcKeyAliasFirst, HuksOptions).then((data) => { - console.info('test exportKey data = ' + JSON.stringify(data)); - exportKeyFrist = data.outData; - }).catch((err) => { - console.info(`test exportKey err: " + ${JSON.stringify(err)}`); - }); - await huks.exportKey(srcKeyAliasSecond, HuksOptions).then((data) => { - console.info('test exportKey data = ' + JSON.stringify(data)); - exportKeySecond = data.outData; - }).catch((err) => { - console.info(`test exportKey err: " + ${JSON.stringify(err)}`); - }); + await publicGenKeyFunc(srcKeyAliasFirst, HuksOptions); + await publicGenKeyFunc(srcKeyAliasSecond, HuksOptions); + + await publicExportKeyFunc(srcKeyAliasFirst, HuksOptions); + exportKeyFrist = exportKey; + await publicExportKeyFunc(srcKeyAliasFirst, HuksOptions); + exportKeySecond = exportKey; /* 集成第一个协商参数集 */ var finishProperties = new Array(); @@ -1285,7 +2047,7 @@ async function testAgree() { } finishProperties[6] = { tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, - value: AgreeStringToUint8Array(srcKeyAliasFirst+ 'final'), + value: StringToUint8Array(srcKeyAliasFirst+ 'final'), } finishProperties[7] = { tag: huks.HuksTag.HUKS_TAG_PADDING, @@ -1297,67 +2059,57 @@ async function testAgree() { } var finishOptionsFrist = { properties: finishProperties, - inData: AgreeStringToUint8Array(agreeX25519InData) + inData: StringToUint8Array(agreeX25519InData) } - + /* 对第一个密钥进行协商 */ - await huks.init(srcKeyAliasFirst, HuksOptions).then((data) => { - console.info(`test init data: ${JSON.stringify(data)}`); - handle = data.handle; - }).catch((err) => { - console.info(`test init err: " + ${JSON.stringify(err)}`); - }); + await publicInitFunc(srcKeyAliasFirst, HuksOptions); HuksOptions.inData = exportKeySecond; - await huks.update(handle, HuksOptions).then((data) => { - console.info(`test update data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info(`test update err: " + ${JSON.stringify(err)}`); - }); - await huks.finish(handle, finishOptionsFrist).then((data) => { - console.info(`test finish data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test finish err information: ' + JSON.stringify(err)); - }); + await publicUpdateFunc(handle, HuksOptions); + await publicFinishFunc(handle, finishOptionsFrist); /* 集成第二个协商参数集 */ var finishOptionsSecond = { properties: finishProperties, - inData: AgreeStringToUint8Array(agreeX25519InData) + inData: StringToUint8Array(agreeX25519InData) } finishOptionsSecond.properties.splice(6, 1, { tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, - value: AgreeStringToUint8Array(srcKeyAliasSecond + 'final'), + value: StringToUint8Array(srcKeyAliasSecond + 'final'), }) - + /* 对第二个密钥进行协商 */ - await huks.init(srcKeyAliasSecond, HuksOptions).then((data) => { - console.info(`test init data: ${JSON.stringify(data)}`); - handle = data.handle; - }).catch((err) => { - console.info(`test init err: " + ${JSON.stringify(err)}`); - }); + await publicInitFunc(srcKeyAliasSecond, HuksOptions); HuksOptions.inData = exportKeyFrist; - await huks.update(handle, HuksOptions).then((data) => { - console.info(`test update data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info(`test update err: " + ${JSON.stringify(err)}`); - }); - await huks.finish(handle, finishOptionsSecond).then((data) => { - console.info(`test finish data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test finish err information: ' + JSON.stringify(err)); - }); + await publicUpdateFunc(handle, HuksOptions); + await publicFinishFunc(handle, finishOptionsSecond); - await huks.deleteKey(srcKeyAliasFirst, huksOptions).then((data) => { - console.info(`test deleteKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test deleteKey err information: ' + JSON.stringify(err)); - }); - await huks.deleteKey(srcKeyAliasSecond, huksOptions).then((data) => { - console.info(`test deleteKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test deleteKey err information: ' + JSON.stringify(err)); - }); + + await publicDeleteKeyFunc(srcKeyAliasFirst, HuksOptions); + await publicDeleteKeyFunc(srcKeyAliasSecond, HuksOptions); +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('testAgree') + .fontSize(30) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(()=>{ + testAgree(); + }) + } + .width('100%') + .height('100%') + } } ``` @@ -1416,7 +2168,9 @@ HksFinish对paramSet中参数的要求: * * 以下以HKDF256密钥的Promise操作使用为例 */ -function hkdfStringToUint8Array(str) { +import huks from '@ohos.security.huks'; + +function StringToUint8Array(str) { var arr = []; for (var i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); @@ -1424,6 +2178,146 @@ function hkdfStringToUint8Array(str) { return new Uint8Array(arr); } +async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicInitFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter promise doInit`); + try { + await huks.initSession(keyAlias, huksOptions) + .then ((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch(error => { + console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +async function publicUpdateFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doUpdate`); + try { + await updateSession(handle, huksOptions) + .then ((data) => { + console.info(`callback: doUpdate success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: doUpdate failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doUpdate input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function updateSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.updateSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicFinishFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doFinish`); + try { + await finishSession(handle, huksOptions) + .then ((data) => { + console.info(`callback: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: doFinish failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doFinish input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function finishSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback deleteKeyItem`); + try { + await deleteKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + var deriveHkdfInData = "deriveHkdfTestIndata"; var srcKeyAlias = "deriveHkdfKeyAlias"; var handle; @@ -1454,11 +2348,7 @@ async function testDerive() { } /* 生成密钥 */ - await huks.generateKey(srcKeyAlias, huksOptions).then((data) => { - console.info('test generateKey data = ' + JSON.stringify(data)); - }).catch((err) => { - console.info(`test init err: " + ${JSON.stringify(err)}`); - }); + await publicGenKeyFunc(srcKeyAlias, huksOptions); /* 调整init时的参数集 */ huksOptions.properties.splice(0, 1, { @@ -1499,7 +2389,7 @@ async function testDerive() { } finishProperties[6] = { tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, - value: hkdfStringToUint8Array(srcKeyAlias), + value: StringToUint8Array(srcKeyAlias), } finishProperties[7] = { tag: huks.HuksTag.HUKS_TAG_PADDING, @@ -1515,23 +2405,11 @@ async function testDerive() { } /* 进行派生操作 */ - await huks.init(srcKeyAlias, huksOptions).then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`); - handle = data.handle; - }).catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`); - }); - huksOptions.inData = hkdfStringToUint8Array(deriveHkdfInData); - await huks.update(handle, huksOptions).then((data) => { - console.log(`test update data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.log(`test update err: " + ${JSON.stringify(err)}`); - }); - await huks.finish(handle, finishOptions).then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)); - }); + await publicInitFunc(srcKeyAlias, huksOptions); + + huksOptions.inData = StringToUint8Array(deriveHkdfInData); + await publicUpdateFunc(handle, huksOptions); + await publicFinishFunc(handle, finishOptions); huksOptions.properties.splice(0, 1, { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, @@ -1542,11 +2420,30 @@ async function testDerive() { value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, }); - await huks.deleteKey(srcKeyAlias, huksOptions).then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.log('test deleteKey err information: ' + JSON.stringify(err)); - }); + await publicDeleteKeyFunc(srcKeyAlias, huksOptions); +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('testDerive') + .fontSize(30) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(()=>{ + testDerive(); + }) + } + .width('100%') + .height('100%') + } } ``` @@ -1588,7 +2485,9 @@ HksInit对paramSet中参数的要求,其他三段式接口对paramSet无要求 * * 以下以SM3 256密钥的Promise操作使用为例 */ -function macStringToUint8Array(str) { +import huks from '@ohos.security.huks'; + +function StringToUint8Array(str) { var arr = []; for (var i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); @@ -1596,6 +2495,162 @@ function macStringToUint8Array(str) { return new Uint8Array(arr); } +async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicInitFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback doInit`); + try { + await initSession(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback1: doInit success, data = ${JSON.stringify(data)}`); + handle = data.handle; + }) + .catch((error) => { + console.error(`callback1: doInit failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function initSession(keyAlias:string, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.initSession(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicUpdateFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doUpdate`); + try { + await updateSession(handle, huksOptions) + .then ((data) => { + console.info(`callback: doUpdate success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: doUpdate failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doUpdate input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function updateSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.updateSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicFinishFunc(handle:number, huksOptions:huks.HuksOptions) { + console.info(`enter callback doFinish`); + try { + await finishSession(handle, huksOptions) + .then ((data) => { + console.info(`callback: doFinish success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: doFinish failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: doFinish input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function finishSession(handle:number, huksOptions:huks.HuksOptions) : Promise { + return new Promise((resolve, reject) => { + try { + huks.finishSession(handle, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback deleteKeyItem`); + try { + await deleteKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + var srcKeyAlias = "sm3KeyAlias"; var hmacInData = 'sm3TestIndata'; var handle; @@ -1625,43 +2680,44 @@ async function testMac() { } /* 生成密钥 */ - await huks.generateKey(srcKeyAlias, huksOptions).then((data) => { - console.info('test generateKey data = ' + JSON.stringify(data)); - }).catch((err) => { - console.info(`test init err: " + ${JSON.stringify(err)}`); - }); + await publicGenKeyFunc(srcKeyAlias, huksOptions); /* 修改init时的参数集并进行mac操作 */ huksOptions.properties.splice(3, 3); - await huks.init(srcKeyAlias, huksOptions).then((data) => { - console.info(`test init data: ${JSON.stringify(data)}`); - handle = data.handle; - }).catch((err) => { - console.info(`test init err: " + ${JSON.stringify(err)}`); - }); - huksOptions.inData = macStringToUint8Array(hmacInData); - await huks.update(handle, huksOptions).then((data) => { - console.info(`test init data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info(`test init err: " + ${JSON.stringify(err)}`); - }); + await publicInitFunc(srcKeyAlias, huksOptions); + huksOptions.inData = StringToUint8Array(hmacInData); + await publicUpdateFunc(handle, huksOptions); huksOptions.inData = new Uint8Array(new Array()); - await huks.finish(handle, huksOptions).then((data) => { - console.info(`test update data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test update err information: ' + JSON.stringify(err)); - }); - + await publicFinishFunc(handle, huksOptions); + huksOptions.properties.splice(1, 0, { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, }); + await publicDeleteKeyFunc(srcKeyAlias, huksOptions); +} - await huks.deleteKey(srcKeyAlias, huksOptions).then((data) => { - console.info(`test deleteKey data: ${JSON.stringify(data)}`); - }).catch((err) => { - console.info('test deleteKey err information: ' + JSON.stringify(err)); - }); +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('testMac') + .fontSize(30) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(()=>{ + testMac(); + }) + } + .width('100%') + .height('100%') + } } ``` @@ -1699,30 +2755,123 @@ RSA512, RSA768, RSA1024, RSA2048, RSA3072, RSA4096, ECC224, ECC256, ECC384, ECC5 ```ts /* 证书AttestID操作示例如下*/ -function stringToUint8Array(str) { +import huks from '@ohos.security.huks'; + +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; + return new Uint8Array(arr); +} + +async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicAttestKey(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback attestKeyItem`); + try { + await attestKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: attestKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: attestKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: attestKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function attestKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) : Promise{ + return new Promise((resolve, reject) => { + try { + huks.attestKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback deleteKeyItem`); + try { + await deleteKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } } -function printLog(...data) { - console.error(data.toString()); +function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); } -let securityLevel = stringToUint8Array('sec_level'); -let challenge = stringToUint8Array('challenge_data'); -let versionInfo = stringToUint8Array('version_info'); -let udid = stringToUint8Array('udid'); -let serial = stringToUint8Array('serial'); -let deviceId = stringToUint8Array('device_id'); -let idAliasString = "id attest"; +var securityLevel = StringToUint8Array('sec_level'); +var challenge = StringToUint8Array('challenge_data'); +var versionInfo = StringToUint8Array('version_info'); +var udid = StringToUint8Array('udid'); +var serial = StringToUint8Array('serial'); +var deviceId = StringToUint8Array('device_id'); +var idAliasString = "id attest"; + +async function testAttestId() { + var aliasString = idAliasString; + var aliasUint8 = StringToUint8Array(aliasString); -/* 集成生成密钥参数集 & 生成密钥 */ -function generateKey(alias) { - let properties = new Array(); + /* 集成生成密钥参数集 & 生成密钥 */ + var properties = new Array(); properties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_RSA @@ -1755,54 +2904,71 @@ function generateKey(alias) { tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, value: huks.HuksCipherMode.HUKS_MODE_ECB }; - let options = { + var options = { properties: properties }; - huks.generateKey(alias, options); -} - -async function attestId() { - let aliasString = idAliasString; - let aliasUint8 = stringToUint8Array(aliasString); + await publicGenKeyFunc(aliasString, options); /* 集成证书参数集 */ - let properties = new Array(); - properties[0] = { + var attestProperties = new Array(); + attestProperties[0] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, value: securityLevel }; - properties[1] = { + attestProperties[1] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, value: challenge }; - properties[2] = { + attestProperties[2] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, value: versionInfo }; - properties[3] = { + attestProperties[3] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, value: aliasUint8 }; - properties[4] = { + attestProperties[4] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_UDID, value: udid }; - properties[5] = { + attestProperties[5] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SERIAL, value: serial }; - properties[6] = { + attestProperties[6] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_DEVICE, value: deviceId }; - let options = { - properties: properties + var huksOptions = { + properties: attestProperties }; - generateKey(aliasString); - huks.attestKey(aliasString, options, function (err, data) { - printLog(`key attest result : ${JSON.stringify(data)}`); - }); + await publicAttestKey(aliasString, huksOptions); + + await publicDeleteKeyFunc(aliasString, options); +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('testAttestId') + .fontSize(30) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(()=>{ + testAttestId(); + }) + } + .width('100%') + .height('100%') + } } ``` @@ -1838,27 +3004,119 @@ RSA512, RSA768, RSA1024, RSA2048, RSA3072, RSA4096, ECC224, ECC256, ECC384, ECC5 ```ts /* 证书AttestKey操作示例如下*/ -function stringToUint8Array(str) { +import huks from '@ohos.security.huks'; + +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; + return new Uint8Array(arr); +} + +async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback generateKeyItem`); + try { + await generateKeyItem(keyAlias, huksOptions) + .then((data) => { + console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicAttestKey(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback attestKeyItem`); + try { + await attestKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: attestKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: attestKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: attestKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + +function attestKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) : Promise{ + return new Promise((resolve, reject) => { + try { + huks.attestKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); +} + +async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback deleteKeyItem`); + try { + await deleteKeyItem(keyAlias, huksOptions) + .then ((data) => { + console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); + }); + } catch (error) { + console.error(`callback: deleteKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } } -function printLog(...data) { - console.error(data.toString()); +function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions) { + return new Promise((resolve, reject) => { + try { + huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throw(error); + } + }); } -let securityLevel = stringToUint8Array('sec_level'); -let challenge = stringToUint8Array('challenge_data'); -let versionInfo = stringToUint8Array('version_info'); -let keyAliasString = "key attest"; +var securityLevel = StringToUint8Array('sec_level'); +var challenge = StringToUint8Array('challenge_data'); +var versionInfo = StringToUint8Array('version_info'); +var keyAliasString = "key attest"; -/* 集成生成密钥参数集 & 生成密钥 */ -function generateKey(alias) { - let properties = new Array(); +async function testAttestKey() { + var aliasString = keyAliasString; + var aliasUint8 = StringToUint8Array(aliasString); + + var properties = new Array(); properties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_RSA @@ -1891,41 +3149,59 @@ function generateKey(alias) { tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, value: huks.HuksCipherMode.HUKS_MODE_ECB }; - let options = { + var options = { properties: properties }; - huks.generateKey(alias, options); -} - -async function attestKey() { - let aliasString = keyAliasString; - let aliasUint8 = stringToUint8Array(aliasString); + await publicGenKeyFunc(aliasString, options); /* 集成证书参数集 */ - let properties = new Array(); - properties[0] = { + var attestProperties = new Array(); + attestProperties[0] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, value: securityLevel }; - properties[1] = { + attestProperties[1] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, value: challenge }; - properties[2] = { + attestProperties[2] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, value: versionInfo }; - properties[3] = { + attestProperties[3] = { tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, value: aliasUint8 }; - let options = { - properties: properties + var huksOptions = { + properties: attestProperties }; - generateKey(aliasString); - huks.attestKey(aliasString, options, function (err, data) { - printLog(`key attest result : ${JSON.stringify(data)}`); - }); + + await publicAttestKey(aliasString, huksOptions); + + await publicDeleteKeyFunc(aliasString, options); +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('testAttestKey') + .fontSize(30) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(()=>{ + testAttestKey(); + }) + } + .width('100%') + .height('100%') + } } ``` diff --git a/zh-cn/application-dev/ui/arkui-overview.md b/zh-cn/application-dev/ui/arkui-overview.md index b3244601362b918dda4d9666016607459dab4003..3d809b82f2c6fbc107a710376dc63b3fd2800b60 100644 --- a/zh-cn/application-dev/ui/arkui-overview.md +++ b/zh-cn/application-dev/ui/arkui-overview.md @@ -14,7 +14,7 @@ ## 主要特征 -- UI组件:方舟开发框架不仅提供了多种基础组件,如文本显示、图片显示、按键交互等,也提供了支持视频播放能力的媒体组件。并且针对不同类型设备进行了组件设计,提供了组件在不同平台上的样式适配能力,此种组件称为“多态组件”。 +- UI组件:方舟开发框架不仅提供了多种基础组件, 例如文本、图片、按钮等 ,也提供了支持视频播放能力的媒体组件。并且针对不同类型设备进行了组件设计,提供了组件在不同平台上的样式适配能力,此种组件称为“多态组件”。 - 布局:UI界面设计离不开布局的参与。方舟开发框架提供了多种布局方式,不仅保留了经典的弹性布局能力,也提供了列表、宫格、栅格布局和适应多分辨率场景开发的原子布局能力。 diff --git a/zh-cn/application-dev/ui/figures/custom-dialog-demo.gif b/zh-cn/application-dev/ui/figures/custom-dialog-demo.gif new file mode 100644 index 0000000000000000000000000000000000000000..8d0979823e13f959b2a4828f479af7bbc03f69f3 Binary files /dev/null and b/zh-cn/application-dev/ui/figures/custom-dialog-demo.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642023.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642023.gif new file mode 100644 index 0000000000000000000000000000000000000000..c584f3fddad26c473453a573a12f6aa869d2cdbc Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642023.gif differ diff --git a/zh-cn/application-dev/ui/js-framework-syntax-js.md b/zh-cn/application-dev/ui/js-framework-syntax-js.md index 8233a1903b741f09f847ec542912db31c55bf8da..6a1484b0d9d49c295ff7c99390d547d4bc589c81 100644 --- a/zh-cn/application-dev/ui/js-framework-syntax-js.md +++ b/zh-cn/application-dev/ui/js-framework-syntax-js.md @@ -164,8 +164,8 @@ JS文件用来定义HML页面的业务逻辑,支持ECMA规范的JavaScript语 images: [ { src: '/common/frame1.png' }, { src: '/common/frame2.png' }, - { src: '/common/frame3.png' }, - ], + { src: '/common/frame3.png' } + ] }, handleClick() { const animator = this.$refs.animator; // 获取ref属性为animator的DOM元素 @@ -196,8 +196,8 @@ JS文件用来定义HML页面的业务逻辑,支持ECMA规范的JavaScript语 images: [ { src: '/common/frame1.png' }, { src: '/common/frame2.png' }, - { src: '/common/frame3.png' }, - ], + { src: '/common/frame3.png' } + ] }, handleClick() { const animator = this.$element('animator'); // 获取id属性为animator的DOM元素 diff --git a/zh-cn/application-dev/ui/ts-component-based-customdialog.md b/zh-cn/application-dev/ui/ts-component-based-customdialog.md index 13082cfa353e705fcd464a21cfba17b7d0b61f21..f8b04e394c8a802479d0717b060142d8519ddb88 100644 --- a/zh-cn/application-dev/ui/ts-component-based-customdialog.md +++ b/zh-cn/application-dev/ui/ts-component-based-customdialog.md @@ -47,3 +47,5 @@ struct CustomDialogUser { } } ``` + +![custom-dialog-demo](figures/custom-dialog-demo.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md b/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md index 2ec686adbe79f83c44d548b31d928c51d7f841f9..86db59447ccb15bad9579553a1eef2e03e143d23 100644 --- a/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md +++ b/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md @@ -56,10 +56,10 @@ struct ParentComp { Column() { Text(this.isCountDown ? 'Count Down' : 'Stopwatch') if (this.isCountDown) { - Image('countdown.png') + Image($r("app.media.countdown")).width(200).height(200) TimerComponent({counter: 10, changePerSec: -1, showInColor: Color.Red}) } else { - Image('stopwatch.png') + Image($r("app.media.stopwatch")).width(200).height(200) TimerComponent({counter: 0, changePerSec: +1, showInColor: Color.Black }) } Button(this.isCountDown ? 'Switch to Stopwatch' : 'Switch to Count Down') @@ -93,3 +93,5 @@ struct TimerComponent { } } ``` + +![](figures/zh-cn_image_0000001118642023.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-pixel-units.md b/zh-cn/application-dev/ui/ts-pixel-units.md index 519a4322eea0ae221078144e959e0036420bc948..0385cfbf9d1a11bf7adb4ab41a09ccac536634b3 100644 --- a/zh-cn/application-dev/ui/ts-pixel-units.md +++ b/zh-cn/application-dev/ui/ts-pixel-units.md @@ -8,7 +8,7 @@ | px | 屏幕物理像素单位。 | | vp | 屏幕密度相关像素,根据屏幕像素密度转换为屏幕物理像素,当数值不带单位时,默认单位vp。 | | fp | 字体像素,与vp类似适用屏幕密度变化,随系统字体大小设置变化。 | -| lpx | 视窗逻辑像素单位,lpx单位为实际屏幕宽度与逻辑宽度(通过[designWidth](../ui/ts-framework-js-tag.md)配置)的比值,designWidth默认值为720。当designWidth为720时,在实际宽度为1440物理像素的屏幕上,1lpx为2px大小。 | +| lpx | 视窗逻辑像素单位,lpx单位为实际屏幕宽度与逻辑宽度(通过[designWidth](../quick-start/package-structure.md)配置)的比值,designWidth默认值为720。当designWidth为720时,在实际宽度为1440物理像素的屏幕上,1lpx为2px大小。 | ## 像素单位转换 diff --git a/zh-cn/application-dev/ui/ui-js-components-path2d.md b/zh-cn/application-dev/ui/ui-js-components-path2d.md index da7e1bc8c413d116b1e31a3459ea5abf2ce014ad..636c694e48377be4ca33691f314ef53c0806e498 100644 --- a/zh-cn/application-dev/ui/ui-js-components-path2d.md +++ b/zh-cn/application-dev/ui/ui-js-components-path2d.md @@ -17,58 +17,62 @@ ```css /* xxx.css */ -.container{ - flex-direction: column; - background-color: #F1F3F5; - align-items: center; - justify-content: center; - width: 100%; +.container { + flex-direction: column; + background-color: #F1F3F5; + align-items: center; + justify-content: center; + width: 100%; } -canvas{ - width: 600px; - height: 600px; - background-color: #fdfdfd; - border: 5px solid red; + +canvas { + width: 600px; + height: 600px; + background-color: #fdfdfd; + border: 5px solid red; } ``` ```js // xxx.js import prompt from '@system.prompt'; + export default { - onShow(){ - let ctx = this.$refs.canvas.getContext('2d',{antialias: true}); - let path = ctx.createPath2D(); - // 房顶 - path.moveTo(10, 300); - path.lineTo(210,100); - path.lineTo(410, 300); - // 屋子 - path.moveTo(10, 300); - path.lineTo(410, 300); - path.lineTo(410, 600); - path.lineTo(10, 600); - path.closePath(); - // 窗子 - path.moveTo(50, 450); - path.bezierCurveTo(70, 350, 130, 350, 150, 450); - path.closePath(); - // 门 - path.moveTo(250, 450); - path.rect(250, 450, 350, 600); - path.closePath(); - // 烟囱 - path.moveTo(365, 250); - path.ellipse(310, 215, 30, 130,0, Math.PI * 0.04, Math.PI * 1.1, 1); - // 树 - path.moveTo(485, 450); - path.quadraticCurveTo(510, 500, 485, 600); - path.moveTo(550, 450); - path.quadraticCurveTo(525, 500, 550, 600); - path.moveTo(600, 535); - path.arc(520, 450, 85, 0, 6); - ctx.stroke(path); - }, + onShow() { + let ctx = this.$refs.canvas.getContext('2d', { + antialias: true + }); + let path = ctx.createPath2D(); + // 房顶 + path.moveTo(10, 300); + path.lineTo(210, 100); + path.lineTo(410, 300); + // 屋子 + path.moveTo(10, 300); + path.lineTo(410, 300); + path.lineTo(410, 600); + path.lineTo(10, 600); + path.closePath(); + // 窗子 + path.moveTo(50, 450); + path.bezierCurveTo(70, 350, 130, 350, 150, 450); + path.closePath(); + // 门 + path.moveTo(250, 450); + path.rect(250, 450, 350, 600); + path.closePath(); + // 烟囱 + path.moveTo(365, 250); + path.ellipse(310, 215, 30, 130, 0, Math.PI * 0.04, Math.PI * 1.1, 1); + // 树 + path.moveTo(485, 450); + path.quadraticCurveTo(510, 500, 485, 600); + path.moveTo(550, 450); + path.quadraticCurveTo(525, 500, 550, 600); + path.moveTo(600, 535); + path.arc(520, 450, 85, 0, 6); + ctx.stroke(path); + } } ``` @@ -84,46 +88,49 @@ export default { ```html
- -
- {{ isAdd }} - {{textName}} -
+ +
+ {{ isAdd }} + {{ textName }} +
``` ```css /* xxx.css */ -.container{ - flex-direction: column; - background-color: #F1F3F5; - align-items: center; - justify-content: center; - width: 100%; +.container { + flex-direction: column; + background-color: #F1F3F5; + align-items: center; + justify-content: center; + width: 100%; } -canvas{ - width: 600px; - height: 600px; - background-color: #fdfdfd; - border: 5px solid red; + +canvas { + width: 600px; + height: 600px; + background-color: #fdfdfd; + border: 5px solid red; } -.content{ - width: 80%; - margin-top: 50px; - margin-bottom: 50px; - display: flex; - flex-wrap: wrap; - justify-content: space-around; + +.content { + width: 80%; + margin-top: 50px; + margin-bottom: 50px; + display: flex; + flex-wrap: wrap; + justify-content: space-around; } -text{ - width: 150px; - height: 80px; - color: white; - border-radius: 20px; - text-align: center; - background-color: #6060e7; - margin-bottom: 30px; + +text { + width: 150px; + height: 80px; + color: white; + border-radius: 20px; + text-align: center; + background-color: #6060e7; + margin-bottom: 30px; } ``` @@ -131,58 +138,66 @@ text{ ```js // xxx.js import prompt from '@system.prompt'; + export default { - data:{ - ctx: null, - path1: null, - path2: null, - path3: null, - isAdd: "addPath2", - isChange: true, - textName: 'change' - }, - onShow(){ - this.ctx = this.$refs.canvas.getContext('2d',{antialias:true}); - this.path1 = this.ctx.createPath2D(); - this.path1.moveTo(200, 200); - this.path1.lineTo(400, 200); - this.path1.lineTo(400, 400); - this.path1.lineTo(200, 400); - this.path1.closePath(); - this.path2 = this.ctx.createPath2D(); - this.path2.arc(300, 300, 75, 0, 6.28) - this.ctx.stroke(this.path1); - }, - addPath(){ - if(this.isAdd == "addPath2"){ - this.ctx.clearRect(0,0,600,600) - this.ctx.beginPath(); - this.path2.addPath(this.path1) - this.ctx.stroke(this.path2); - this.isAdd = "clearPath2" - }else{ - this.ctx.clearRect(0,0,600,600) - this.ctx.stroke(this.path1); - this.isAdd = "addPath2" - } - }, - setTransform(){ - if(this.isChange){ - this.ctx.clearRect(0,0,600,600) - this.path3 = this.ctx.createPath2D(); - this.path3.arc(150, 150, 100, 0, 6.28) - this.path3.setTransform(2, 0.1, 0.1, 2, 0,0); - this.ctx.stroke(this.path3); - this.isChange = !this.isChange; - this.textName = "back" - }else{ - this.ctx.clearRect(0,0,600,600) - this.path3.setTransform(0.5, -0.1, -0.1, 0.5, 0,0); - this.ctx.stroke(this.path3); - this.isChange = !this.isChange; - this.textName = "change" + data: { + ctx: null, + path1: null, + path2: null, + path3: null, + isAdd: "addPath2", + isChange: true, + textName: 'change' + }, + onShow() { + this.ctx = this.$refs.canvas.getContext('2d', { + antialias: true + }); + this.path1 = this.ctx.createPath2D(); + // 正方形 + this.path1.moveTo(200, 200); + this.path1.lineTo(400, 200); + this.path1.lineTo(400, 400); + this.path1.lineTo(200, 400); + this.path1.closePath(); + this.path2 = this.ctx.createPath2D(); + // 圆形 + this.path2.arc(300, 300, 75, 0, 6.28); + this.ctx.stroke(this.path1); + }, + addPath() { + if (this.isAdd == "addPath2") { + // 删除指定指定区域的绘制内容 + this.ctx.clearRect(0, 0, 600, 600); + this.ctx.beginPath(); + // 将另一个的路径添加到当前路径对象中 + this.path2.addPath(this.path1); + this.ctx.stroke(this.path2); + this.isAdd = "clearPath2"; + } else { + this.ctx.clearRect(0, 0, 600, 600); + this.ctx.stroke(this.path1); + this.isAdd = "addPath2"; + } + }, + setTransform() { + if (this.isChange) { + this.ctx.clearRect(0, 0, 600, 600); + this.path3 = this.ctx.createPath2D(); + this.path3.arc(150, 150, 100, 0, 6.28); + // 重置现有的变换矩阵并创建新的变换矩阵 + this.path3.setTransform(2, 0.1, 0.1, 2, 0, 0); + this.ctx.stroke(this.path3); + this.isChange = !this.isChange; + this.textName = "back" + } else { + this.ctx.clearRect(0, 0, 600, 600); + this.path3.setTransform(0.5, -0.1, -0.1, 0.5, 0, 0); + this.ctx.stroke(this.path3); + this.isChange = !this.isChange; + this.textName = "change"; + } } - }, } ``` diff --git a/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md b/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md index 51ee15b3e6c18b9b51340a51c0b54f133ce6700d..1f8e88029e8a192fbed74060f3c72d1e21d2357b 100644 --- a/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md +++ b/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md @@ -320,7 +320,7 @@ } ``` - 自定义组件提供了两个生命周期的回调接口aboutToAppear和aboutToDisappear。aboutToAppear的执行时机在创建自定义组件后,执行自定义组件build方法之前。aboutToDisappear在自定义组件的去初始化的时机执行。 + 自定义组件提供了两个生命周期的回调接口aboutToAppear和aboutToDisappear。aboutToAppear的执行时机在创建自定义组件后,执行自定义组件build方法之前。aboutToDisappear在自定义组件销毁之前的时机执行。 ![zh-cn_image_0000001215113569](figures/zh-cn_image_0000001215113569.png) 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 f9ef0596f48ebcb930dda2f94e594fa1e33788dd..a58772dcd84f01f7d4e52c8bd7a7a2e9430e4727 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 @@ -1,6 +1,6 @@ # 创建简单视图 -在这一小节中,我们将开始食物详情页的开发,学习如何通过容器组件Stack、Flex和基本组件Image、Text,构建用户自定义组件,完成图文并茂的食物介绍。 +在这一小节中,我们将开始食物详情页的开发,学习如何通过容器组件Stack、Flex和基础组件Image、Text,构建用户自定义组件,完成图文并茂的食物介绍。 ## 构建Stack布局 @@ -24,7 +24,8 @@ ![zh-cn_image_0000001214128687](figures/zh-cn_image_0000001214128687.png) 2. 食物图片展示。 - 创建Image组件,指定Image组件的url,Image组件和Text组件都是必选构造参数组件。为了让Text组件在Image组件上方显示,所以要先声明Image组件。图片资源放在resources下的rawfile文件夹内,引用rawfile下资源时使用`$rawfile('filename')`的形式,filename为rawfile目录下的文件相对路径。当前`$rawfile`仅支持Image控件引用图片资源。 + 创建Image组件,指定Image组件的url,Image组件是必选构造参数组件。为了让Text组件在Image组件上方显示,所以要先声明Image组件。图片资源放在resources下的rawfile文件夹内,引用rawfile下资源时使用`$rawfile('filename')`的形式,filename为rawfile目录下的文件相对路径。当前`$rawfile`仅支持Image控件引用图片资源。 + ``` @Entry @Component @@ -40,15 +41,16 @@ } ``` - ![zh-cn_image_0000001168410342](figures/zh-cn_image_0000001168410342.png) + +![zh-cn_image_0000001168410342](figures/zh-cn_image_0000001168410342.png) 3. 通过资源访问图片。 除指定图片路径外,也可以使用引用媒体资源符$r引用资源,需要遵循resources文件夹的资源限定词的规则。右键resources文件夹,点击New>Resource Directory,选择Resource Type为Media(图片资源)。 将Tomato.png放入media文件夹内。就可以通过`$r('app.type.name')`的形式引用应用资源,即`$r('app.media.Tomato')`。 - ``` - @Entry +``` +@Entry @Component struct MyComponent { build() { @@ -62,7 +64,8 @@ } } } - ``` +``` + 4. 设置Image宽高,并且将image的objectFit属性设置为ImageFit.Contain,即保持图片长宽比的情况下,使得图片完整地显示在边界内。 如果Image填满了整个屏幕,原因如下: @@ -70,8 +73,8 @@ 2. Image的objectFit默认属性是ImageFit.Cover,即在保持长宽比的情况下放大或缩小,使其填满整个显示边界。 - ``` - @Entry +``` +@Entry @Component struct MyComponent { build() { @@ -85,13 +88,15 @@ } } } - ``` +``` + ![zh-cn_image_0000001214210217](figures/zh-cn_image_0000001214210217.png) 5. 设置食物图片和名称布局。设置Stack的对齐方式为底部起始端对齐,Stack默认为居中对齐。设置Stack构造参数alignContent为Alignment.BottomStart。其中Alignment和FontWeight一样,都是框架提供的内置枚举类型。 - ``` - @Entry + +``` +@Entry @Component struct MyComponent { build() { @@ -105,16 +110,21 @@ } } } - ``` +``` + ![zh-cn_image_0000001168728872](figures/zh-cn_image_0000001168728872.png) -6. 通过设置Stack的背景颜色来改变食物图片的背景颜色,设置颜色有两种方式: +6. 通过设置Stack的背景颜色来改变食物图片的背景颜色,设置颜色有四种方式: 1. 通过框架提供的Color内置枚举值来设置,比如backgroundColor(Color.Red),即设置背景颜色为红色。 2. string类型参数,支持的颜色格式有:rgb、rgba和HEX颜色码。比如backgroundColor('\#0000FF'),即设置背景颜色为蓝色,backgroundColor('rgb(255, 255, 255)'),即设置背景颜色为白色。 + 3. number类型参数,支持十六进制颜色值。比如backgroundColor(0xFF0000),即设置背景颜色为红色。 + + 4. Resource类型参数请参考[资源访问](ts-resource-access.md) 。 + - ``` - @Entry +``` +@Entry @Component struct MyComponent { build() { @@ -128,8 +138,9 @@ } .backgroundColor('#FFedf2f5') } - } - ``` +} +``` + ![zh-cn_image_0000001168888822](figures/zh-cn_image_0000001168888822.png) @@ -137,8 +148,8 @@ 1. 参数为Length时,即统一指定四个边的外边距,比如margin(20),即上、右、下、左四个边的外边距都是20。 2. 参数为{top?: Length, right?: Length, bottom?: Length, left?:Length},即分别指定四个边的边距,比如margin({ left: 26, bottom: 17.4 }),即左边距为26,下边距为17.4。 - ``` - @Entry +``` +@Entry @Component struct MyComponent { build() { @@ -154,15 +165,16 @@ .backgroundColor('#FFedf2f5') } } - ``` +``` + ![zh-cn_image_0000001213968747](figures/zh-cn_image_0000001213968747.png) 8. 调整组件间的结构,语义化组件名称。创建页面入口组件为FoodDetail,在FoodDetail中创建Column,设置水平方向上居中对齐 alignItems(HorizontalAlign.Center)。MyComponent组件名改为FoodImageDisplay,为FoodDetail的子组件。 Column是子组件竖直排列的容器组件,本质为线性布局,所以只能设置交叉轴方向的对齐。 - ``` - @Component +``` +@Component struct FoodImageDisplay { build() { Stack({ alignContent: Alignment.BottomStart }) { @@ -188,7 +200,8 @@ .alignItems(HorizontalAlign.Center) } } - ``` +``` + ## 构建Flex布局 @@ -196,8 +209,9 @@ 开发者可以使用Flex弹性布局来构建食物的食物成分表,弹性布局在本场景的优势在于可以免去多余的宽高计算,通过比例来设置不同单元格的大小,更加灵活。 1. 创建ContentTable组件,使其成为页面入口组件FoodDetail的子组件。 - ``` - @Component + +``` +@Component struct FoodImageDisplay { build() { Stack({ alignContent: Alignment.BottomStart }) { @@ -229,7 +243,8 @@ .alignItems(HorizontalAlign.Center) } } - ``` +``` + 2. 创建Flex组件展示Tomato两类成分。 一类是热量Calories,包含卡路里(Calories);一类是营养成分Nutrition,包含蛋白质(Protein)、脂肪(Fat)、碳水化合物(Carbohydrates)和维生素C(VitaminC)。 @@ -238,8 +253,8 @@ 已省略FoodImageDisplay代码,只针对ContentTable进行扩展。 - ``` - @Component +``` +@Component struct ContentTable { build() { Flex() { @@ -267,13 +282,15 @@ .alignItems(HorizontalAlign.Center) } } - ``` +``` + ![zh-cn_image_0000001169759552](figures/zh-cn_image_0000001169759552.png) 3. 调整布局,设置各部分占比。分类名占比(layoutWeight)为1,成分名和成分含量一共占比(layoutWeight)2。成分名和成分含量位于同一个Flex中,成分名占据所有剩余空间flexGrow(1)。 - ``` - @Component + +``` +@Component struct FoodImageDisplay { build() { Stack({ alignContent: Alignment.BottomStart }) { @@ -322,15 +339,16 @@ .alignItems(HorizontalAlign.Center) } } - ``` +``` + ![zh-cn_image_0000001215079443](figures/zh-cn_image_0000001215079443.png) 4. 仿照热量分类创建营养成分分类。营养成分部分(Nutrition)包含:蛋白质(Protein)、脂肪(Fat)、碳水化合物(Carbohydrates)和维生素C(VitaminC)四个成分,后三个成分在表格中省略分类名,用空格代替。 设置外层Flex为竖直排列FlexDirection.Column, 在主轴方向(竖直方向)上等距排列FlexAlign.SpaceBetween,在交叉轴方向(水平轴方向)上首部对齐排列ItemAlign.Start。 - ``` - @Component +``` +@Component struct ContentTable { build() { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { @@ -421,7 +439,8 @@ .alignItems(HorizontalAlign.Center) } } - ``` +``` + 5. 使用自定义构造函数\@Builder简化代码。可以发现,每个成分表中的成分单元其实都是一样的UI结构。 ![zh-cn_image_0000001169599582](figures/zh-cn_image_0000001169599582.png) @@ -430,8 +449,8 @@ 在ContentTable内声明\@Builder修饰的IngredientItem方法,用于声明分类名、成分名称和成分含量UI描述。 - ``` - @Component +``` + @Component struct ContentTable { @Builder IngredientItem(title:string, name: string, value: string) { Flex() { @@ -450,12 +469,13 @@ } } } - ``` +``` - 在ContentTable的build方法内调用IngredientItem接口,需要用this去调用该Component作用域内的方法,以此来区分全局的方法调用。 - ``` - @Component + 在ContentTable的build方法内调用IngredientItem接口,需要用this去调用该Component作用域内的方法,以此来区分全局的方法调用。 + +``` +@Component struct ContentTable { ...... build() { @@ -470,12 +490,13 @@ .padding({ top: 30, right: 30, left: 30 }) } } - ``` +``` - ContentTable组件整体代码如下。 - ``` - @Component + ContentTable组件整体代码如下。 + +``` +@Component struct ContentTable { @Builder IngredientItem(title:string, name: string, value: string) { Flex() { @@ -494,17 +515,18 @@ } } - build() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { - this.IngredientItem('Calories', 'Calories', '17kcal') - this.IngredientItem('Nutrition', 'Protein', '0.9g') - this.IngredientItem('', 'Fat', '0.2g') - this.IngredientItem('', 'Carbohydrates', '3.9g') - this.IngredientItem('', 'VitaminC', '17.8mg') - } - .height(280) - .padding({ top: 30, right: 30, left: 30 }) - } + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { + this.IngredientItem('Calories', 'Calories', '17kcal') + this.IngredientItem('Nutrition', 'Protein', '0.9g') + this.IngredientItem('', 'Fat', '0.2g') + this.IngredientItem('', 'Carbohydrates', '3.9g') + this.IngredientItem('', 'VitaminC', '17.8mg') + } + .height(280) + .padding({ top: 30, right: 30, left: 30 }) + } + } @Entry @@ -518,7 +540,8 @@ .alignItems(HorizontalAlign.Center) } } - ``` +``` + ![zh-cn_image_0000001215199399](figures/zh-cn_image_0000001215199399.png) 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 add3021585976afbccfa75de3caf2761ef1bf50c..f6159c9d12c3b8a25232ef70b2a2339c6bba41a5 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md @@ -130,7 +130,7 @@ listener.on('change', onPortrait) } aboutToAppear() { - portraitFunc = this.onPortrait.bind(this) //bind current js instance + portraitFunc = this.onPortrait.bind(this) //绑定当前应用实例 this.listener.on('change', portraitFunc) } diff --git "a/zh-cn/contribute/\347\254\254\344\270\211\346\226\271\345\274\200\346\272\220\350\275\257\344\273\266\345\274\225\345\205\245\346\214\207\345\257\274.md" "b/zh-cn/contribute/\347\254\254\344\270\211\346\226\271\345\274\200\346\272\220\350\275\257\344\273\266\345\274\225\345\205\245\346\214\207\345\257\274.md" index c21688d51c617ad6581798e79cbe748572a8e053..32cc3b647502e1862a928f76b02847f8b0a2b620 100755 --- "a/zh-cn/contribute/\347\254\254\344\270\211\346\226\271\345\274\200\346\272\220\350\275\257\344\273\266\345\274\225\345\205\245\346\214\207\345\257\274.md" +++ "b/zh-cn/contribute/\347\254\254\344\270\211\346\226\271\345\274\200\346\272\220\350\275\257\344\273\266\345\274\225\345\205\245\346\214\207\345\257\274.md" @@ -30,13 +30,13 @@ OpenHarmony遵从 [Open Source Definition](https://opensource.org/docs/osd) , 2. 必须有明确的引入理由,若需要引入的软件在OpenHarmony项目中已存在,请重用该版本,避免多版本共存增加维护的复杂性。 3. 软件应该以源码方式引入,原则上二进制不应该被引入,应从源码构建。如果需要引入二进制,经由PMC评审后决定。 4. 软件应该在OpenHarmony上可以被正确构建,若该软件有尚未被引入的依赖软件,或者软件的运行或者构建依赖一个不能引入OpenHarmony的组件,需由SIG-Architecture评审后决定。 -5. 引入软件到OpenHarmony项目中必须将其放置到单独的代码仓,命名统一为third_party_软件名称,其中软件名称和其官网保持一致。 +5. 引入软件到OpenHarmony项目中必须将其放置到单独的代码仓,命名统一为**third_party**_**软件名称**,其中软件名称和其官网保持一致。 6. 应当完整保留引入软件的官方代码仓目录结构、许可证及Copyright信息,不要修改第三方开源软件的原始许可证与Copyright信息。 7. 不建议引入未发布正式版本(如只发布Beta版本)的开源软件。 8. 不能引入有高危漏洞且无解决方案的版本。 9. 若需针对引入的开源软件进行修改,请将修改的代码放在该开源软件仓中,并确保满足该开源软件的许可证要求,修改的文件应当保持其原始许可证条款,新增的文件也建议采用相同的许可证条款。 10. 新引入的开源软件必须在其根目录提供README.OpenSource文件,在该文件中准确描述其软件名、许可证、许可文件位置、版本、对应版本的上游社区地址、软件的维护Owner、功能描述以及引入的原因。 -11. 引入新软件到OpenHarmony时必须有对应的SIG负责管理,原则上如果没有SIG-Compliance以及相应SIG的确认,SIG-Architecture不批准相应软件的引入。当要批量引入多个软件时,可以求助SIG-Architecture主持发起SIG间的临时评审会议,提升协调效率。如因特殊原因不能满足上述要求但又需要引入,请请联系邮箱:law@openatom.org。 +11. 引入新软件到OpenHarmony时必须有对应的SIG负责管理,原则上如果没有SIG-Compliance以及相应SIG的确认,SIG-Architecture不批准相应软件的引入。当要批量引入多个软件时,可以求助SIG-Architecture主持发起SIG间的临时评审会议,提升协调效率。如因特殊原因不能满足上述要求但又需要引入,请请联系邮箱:oh-legal@openatom.io。 12. 引入新的开源软件存在依赖其他开源软件时,不允许将被动依赖软件嵌套在引入的新的开源软件子目录中,必须剥离所有依赖软件项,并将其分别放置到单独的代码仓,命名统一为third_party_依赖软件名称,原因是嵌套放置依赖软件可能导致多同一款软件多版本、旧版本安全漏洞无法及时修复、开源义务履行合规的风险问题。 - 依赖软件在编译构建部件命名,将新引入的主软件名作为依赖软件部件前缀命名,例如 part_name = "新引入主软件名_依赖软件名" - 新引入软件和依赖软件分别独立构建,通过external_deps来解决部件间依赖。 @@ -51,7 +51,7 @@ OpenHarmony遵从 [Open Source Definition](https://opensource.org/docs/osd) , | 来源可靠 | 1、应该从开源软件官网获取或官网指定的代码托管地址获取。 | | 社区活跃 | 1、软件来自知名社区或组织,社区或组织通过发布公告、修改软件仓库状态、将仓库放到特定目录下等方式告知停止维护的,不建议引入。
2、软件来自个人、小型社区或组织,两年内未发布版本(含正式版本与测试版本),无明确版本计划,社区提交了有效的Bug或PR,但是半年以上未响应的,不建议引入。
3、社区运营状态不明确,通过Issue 或者邮件等方式询问社区是否继续维护,半年以上未响应或者答复停止维护的,不建议引入。| | 安全漏洞 | 1、检索业界已知公开的安全漏洞,如有高危漏洞需要有应对方案。| -| 规范化软件名称 | 1、 仓库命名统一为third_party_软件名称,其中软件名称和其官网保持一致。
2、 不允许以软件的子模块作为软件名。
3、 当软件存在多个语言的开发库时,可在其官方命名前追加python-等前缀予以规范化管理。 | +| 规范化软件名称 | 1、 仓库命名统一为**third_party**_**软件名称**,其中软件名称和其官网保持一致。
2、 不允许以软件的子模块作为软件名。
3、 当软件存在多个语言的开发库时,可在其官方命名前追加python-等前缀予以规范化管理。 | | 官网信息 | 1、在申请引入请求中准确描述该软件官方网址,如无正式官网则提供主流代码托管商上面对应的项目网址,不能使用maven、mvnrepository、springsource等托管库地址。
2、必须同时提供要引入版本的官方源代码包下载地址,以达到可溯源,如需要二进制包,请提供官方的二进制包下载地址。 | | License检查 | 1、待引入软件是否有license。
2、入库的License是否和官网对应版本的License保持一致。
3、高风险license的开源软件谨慎引入,在引入前请充分评估并在申请时附上分析结论。 | @@ -63,7 +63,7 @@ OpenHarmony遵从 [Open Source Definition](https://opensource.org/docs/osd) , | 检查项 | 填写指导 | 自检结果示例 | | :----- | :----- | :----- | -| 软件名 | 描述该软件官方名称以及引入后的仓名,仓名统一为third_party_加上官方软件名称 | third_party_softwarename | +| 软件名 | 描述该软件官方名称以及引入后的仓名,仓名统一为**third_party**_**加上官方软件名称** | third_party_**softwarename** | | 软件官网地址 | 描述该软件官方网站链接地址 | https://softwaresite | | 软件版本号 | 描述该软件要引入的版本号,版本号为其社区正式发布的版本号,不要随意修改;未正式发布的版本不建议引入 | 1.0.0 | | 软件版本发布日期 | 描述该软件要引入的版本的社区发布日期 | 2021.01.01 | @@ -192,7 +192,7 @@ third_party_abcde/doc/ LICENSEFILE LICENSE Apache-2.0 * Ruby License * Eclipse Public License 2.0: EPL 2.0 -如要引入其它类型License或上述(4)所列License,请联系邮箱:law@openatom.org。 +如要引入其它类型License或上述(4)所列License,请联系邮箱:oh-legal@openatom.io。 ## 软件退出与退出原则 diff --git a/zh-cn/device-dev/Readme-CN.md b/zh-cn/device-dev/Readme-CN.md index 5d292301578abdb62b5a3f809fa918507523b23e..eab525eca520337d2a0ee458a9fb919ecb54b5dd 100644 --- a/zh-cn/device-dev/Readme-CN.md +++ b/zh-cn/device-dev/Readme-CN.md @@ -6,8 +6,7 @@ - [术语](../glossary.md) - [版本说明](../release-notes/Readme.md) - 快速开始 - - [轻量和小型系统快速入门](quick-start/quickstart-ide-lite-overview.md) - - [标准系统快速入门](quick-start/quickstart-ide-standard-overview.md) + - [快速入门](quick-start/Readme-CN.md) - 兼容性与安全 - [隐私与安全规范](security/Readme-CN.md) - 移植 diff --git a/zh-cn/device-dev/device-dev-guide.md b/zh-cn/device-dev/device-dev-guide.md index 76d8e9a25a17aa33ff238e74066bc99abf67c889..8bcd5350656f5567c701c910c08dd4baa70cc783 100644 --- a/zh-cn/device-dev/device-dev-guide.md +++ b/zh-cn/device-dev/device-dev-guide.md @@ -36,9 +36,9 @@ OpenHarmony也提供了一系列可选的系统组件,方便设备开发者按 | --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | 了解OpenHarmony | 整体认知OpenHarmony | - [OpenHarmony概述](https://gitee.com/openharmony)
- [术语](../glossary.md) | | 获取开发资源 | 准备开发前相关资源 | - [获取源码](get-code/sourcecode-acquire.md)
- [获取工具](get-code/gettools-acquire.md) | -| 快速入门 | 快速熟悉OpenHarmony环境搭建、编译、烧录、调测、运行 | - [轻量和小型系统快速入门](quick-start/quickstart-ide-lite-overview.md) | +| 快速入门 | 快速熟悉OpenHarmony环境搭建、编译、烧录、调测、运行 | - [快速入门](quick-start/Readme-CN.md) | | 基础能力使用 | 使用OpenHarmony提供的基础能力 | - [轻量系统内核开发指南](kernel/kernel-mini-overview.md)
- [小型系统内核开发指南](kernel/kernel-small-overview.md)
- [驱动开发指南](driver/driver-hdf-overview.md)
- [子系统开发指南](subsystems/subsys-build-all.md)
- [安全指南](security/security-guidelines-overall.md)
- [隐私保护](security/security-privacy-protection.md) | -| 进阶开发 | 结合系统能力开发智能设备 | - [WLAN连接类产品](guide/device-wlan-led-control.md)
- [无屏摄像头类产品](guide/device-iotcamera-control-overview.md)
- [带屏摄像头类产品](guide/device-camera-control-overview.md) | +| 进阶开发 | 结合系统能力开发智能设备 | - [WLAN连接类产品](guide/device-wlan-led-control.md)
- [带屏摄像头类产品](guide/device-camera-control-overview.md) | | 移植适配 | - 针对特定芯片做移植适配
- 对三方库进行移植适配
- 三方厂商移植案例
| - [轻量系统芯片移植指导](porting/porting-minichip-overview.md)
- [小型系统芯片移植指导](porting/porting-smallchip-prepare-needs.md)
- [轻量和小型系统三方库移植指导](porting/porting-thirdparty-overview.md)
- [带屏解决方案之恒玄芯片移植案例](porting/porting-bes2600w-on-minisystem-display-demo.md)
- [Combo解决方案之ASR芯片移植案例](porting/porting-asr582x-combo-demo.md)
- [物联网解决方案之芯海cst85芯片移植案例](porting/porting-cst85f01-combo-demo.md)
- [轻量系统STM32F407芯片移植案例](porting/porting-stm32f407-on-minisystem-eth.md)
- [Combo解决方案之W800芯片移植案例](porting/porting-w800-combo-demo.md)
- [小型设备STM32MP1芯片移植案例](porting/porting-stm32mp15xx-on-smallsystem.md) | | 贡献组件 | 为OpenHarmony贡献功能组件 | - [HPM Part 介绍](hpm-part/hpm-part-about.md)
- [HPM Part 开发指导](hpm-part/hpm-part-development.md)
- [HPM Part 参考](hpm-part/hpm-part-reference.md) | | 参考 | 为开发者提供常见的问题解答和HDI接口参考 | - [常见问题](faqs/faqs-overview.md)
- [HDI接口参考](reference/hdi-apis/Readme-CN.md) | @@ -48,7 +48,7 @@ OpenHarmony也提供了一系列可选的系统组件,方便设备开发者按 | -------- | -------- | -------- | | 了解OpenHarmony | 整体认知OpenHarmony | - [OpenHarmony概述](https://gitee.com/openharmony)
- [术语](../glossary.md) | | 获取开发资源 | 准备开发前相关资源 | - [获取源码](get-code/sourcecode-acquire.md)
- [获取工具](get-code/gettools-acquire.md) | -| 快速入门 | 快速熟悉OpenHarmony环境搭建、编译、烧录、调测、运行 | - [标准系统快速入门](quick-start/quickstart-ide-standard-overview.md) | +| 快速入门 | 快速熟悉OpenHarmony环境搭建、编译、烧录、调测、运行 | - [快速入门](quick-start/Readme-CN.md)| | 基础能力使用 | 使用OpenHarmony提供的基础能力 | - [内核开发指南](kernel/kernel-standard-overview.md)
- [驱动开发指南](driver/driver-hdf-overview.md)
- [子系统开发指南](subsystems/subsys-build-all.md)
- [安全指南](security/security-guidelines-overall.md)
- [隐私保护](security/security-privacy-protection.md) | | 进阶开发 | 结合系统能力开发智能设备 | - [时钟应用开发指导](guide/device-clock-guide.md)
- [平台驱动开发示例](guide/device-driver-demo.md)
- [外设驱动开发示例](guide/device-outerdriver-demo.md) | | 移植适配 | - 针对特定芯片做移植适配
- 快速移植OpenHarmony Linux内核的方法| - [标准系统芯片移植指导](porting/standard-system-porting-guide.md)
- [一种快速移植OpenHarmony Linux内核的方法](porting/porting-linux-kernel.md)
- [标准系统方案之瑞芯微RK3568移植案例](porting/porting-dayu200-on_standard-demo.md)| diff --git a/zh-cn/device-dev/faqs/faqs-burning.md b/zh-cn/device-dev/faqs/faqs-burning.md index 28fffd486a78cc5477823858b285208085d3512d..1e1d16aed57749fbee981943b49586d6492c7935 100644 --- a/zh-cn/device-dev/faqs/faqs-burning.md +++ b/zh-cn/device-dev/faqs/faqs-burning.md @@ -26,7 +26,7 @@ ![zh-cn_image_0000001243481989](figures/zh-cn_image_0000001243481989.png) 2. 点击标号中的垃圾桶图标,关闭串口。 - + **图3** 关闭串口终端 ![zh-cn_image_0000001243082093](figures/zh-cn_image_0000001243082093.png) @@ -88,7 +88,7 @@ > Hi3518EV300:device\hisilicon\hispark_aries\sdk_liteos\uboot\out\boot\u-boot-hi3518ev300.bin 2. 根据USB烧写步骤烧写U-boot文件。 - 按照[Hi3516系列USB烧写步骤](../quick-start/quickstart-ide-lite-steps-hi3516-burn.md)中描述的烧写方法,选择对应单板的U-boot文件进行烧写。 + 按照[Hi3516系列USB烧写步骤](../quick-start/quickstart-ide-3516-burn.md)中描述的烧写方法,选择对应单板的U-boot文件进行烧写。 3. 烧写完成后,登录串口如下图所示。 @@ -104,7 +104,7 @@ 点击烧写并选择串口后,无法获取文件。 **图6** 网络不通,单板无法获取文件图 - + ![zh-cn_image_0000001198322428](figures/zh-cn_image_0000001198322428.png) - **可能原因** @@ -124,19 +124,19 @@ ![zh-cn_image_0000001198162584](figures/zh-cn_image_0000001198162584.png) 3. 点击“允许应用通过防火墙”。 - + **图8** 防火墙和网络保护界面图 ![zh-cn_image_0000001198323146](figures/zh-cn_image_0000001198323146.png) 4. 查找Visual Studio Code应用。 - + **图9** 查找Visual Studio Code应用图 ![zh-cn_image_0000001198003232](figures/zh-cn_image_0000001198003232.png) 5. 勾选Visual Studio Code的专用和公用网络的访问权限。 - + **图10** 允许Visual Studio Code应用访问网络 - + ![zh-cn_image_0000001243084579](figures/zh-cn_image_0000001243084579.png) diff --git a/zh-cn/device-dev/get-code/sourcecode-acquire.md b/zh-cn/device-dev/get-code/sourcecode-acquire.md index a75e45501508c29cfedac97c14f1f84e1935c3e5..7fb9f4c4c51323d740ad6cf5d3da5bed2d20fbec 100644 --- a/zh-cn/device-dev/get-code/sourcecode-acquire.md +++ b/zh-cn/device-dev/get-code/sourcecode-acquire.md @@ -197,12 +197,12 @@ OpenHarmony是由开放原子开源基金会(OpenAtom Foundation)孵化及 | Hi3516解决方案-Linux(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | | RELEASE-NOTES | 3.0 | [站点](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/zh-cn/release-notes/OpenHarmony-v3.0-LTS.md) | - | | **最新发布版本源码** | **版本信息** | **下载站点** | **SHA256校验码** | -| 全量代码Beta版本(标准、轻量和小型系统) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/code-v3.2-Beta2.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/code-v3.2-Beta2.tar.gz.sha256) | -| RK3568标准系统解决方案(二进制) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/dayu200_standard_arm64.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/dayu200_standard_arm64.tar.gz.sha256) | -| Hi3861解决方案(二进制) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_pegasus.tar.gz.sha256) | -| Hi3516解决方案-LiteOS(二进制) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_LiteOS.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_LiteOS.tar.gz.sha256) | -| Hi3516解决方案-Linux(二进制) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_Linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_Linux.tar.gz.sha256) | -| RELEASE-NOTES | 3.2 Beta2 | [站点](../../release-notes/OpenHarmony-v3.2-beta2.md) | - | +| 全量代码Beta版本(标准、轻量和小型系统) | 3.2 Beta3 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/code-v3.2-Beta3.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/code-v3.2-Beta3.tar.gz.sha256) | +| RK3568标准系统解决方案(二进制) | 3.2 Beta3 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/dayu200_standard_arm32.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/dayu200_standard_arm32.tar.gz.sha256) | +| Hi3861解决方案(二进制) | 3.2 Beta3 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_pegasus.tar.gz.sha256) | +| Hi3516解决方案-LiteOS(二进制) | 3.2 Beta3 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_taurus_LiteOS.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_taurus_LiteOS.tar.gz.sha256) | +| Hi3516解决方案-Linux(二进制) | 3.2 Beta3 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_taurus_Linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_taurus_Linux.tar.gz.sha256) | +| RELEASE-NOTES | 3.2 Beta3 | [站点](../../release-notes/OpenHarmony-v3.2-beta3.md) | - | | **编译工具链** | **版本信息** | **下载站点** | **SHA256校验码** | | 编译工具链获取清单 | - | [站点](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/) | - | diff --git a/zh-cn/device-dev/guide/Readme-CN.md b/zh-cn/device-dev/guide/Readme-CN.md index f3d4ce4dda929fefc50ed0c16f5c57d6b696ec8a..6ccfe900d89d600cd818d10e122f1ec80d2bdec4 100755 --- a/zh-cn/device-dev/guide/Readme-CN.md +++ b/zh-cn/device-dev/guide/Readme-CN.md @@ -4,13 +4,6 @@ - WLAN连接类产品 - [LED外设控制](device-wlan-led-control.md) - [集成三方SDK](device-wlan-sdk.md) - - 无屏摄像头类产品 - - 摄像头控制 - - [概述](device-iotcamera-control-overview.md) - - 示例开发 - - [拍照开发指导](device-iotcamera-control-demo-photodevguide.md) - - [录像开发指导](device-iotcamera-control-demo-videodevguide.md) - - [应用实例](device-iotcamera-control-example.md) - 带屏摄像头类产品 - 屏幕和摄像头控制 - [概述](device-camera-control-overview.md) diff --git a/zh-cn/device-dev/guide/device-camera-control-example.md b/zh-cn/device-dev/guide/device-camera-control-example.md index 0ddac333669841dfa42ae4b95859fad94287e926..bca04953d80f8c642b5d2ed062075a15fe61282e 100644 --- a/zh-cn/device-dev/guide/device-camera-control-example.md +++ b/zh-cn/device-dev/guide/device-camera-control-example.md @@ -3,7 +3,7 @@ 本示例将运行源码中的camera示例代码,通过本示例可以实现使用开发板进行拍照、录像及预览等功能。 - 本示例源码路径为“applications/sample/camera/media/camera\_sample.cpp”。 -- 在运行本示例前需先完成编译烧录、运行镜像等步骤,相关操作请参考[Hi3516快速入门](../quick-start/quickstart-lite-overview.md)。 +- 在运行本示例前需先完成编译烧录、运行镜像等步骤,相关操作请参考[小型系统快速入门](../quick-start/Readme-CN.md)。 >![](../public_sys-resources/icon-note.gif) **说明:** >开发板启动后默认会加载launcher应用,应用的图形界面默认显示在媒体图层上方,会影响camera\_sample的演示结果,因此需要在编译或是打包时去掉launcher应用。 diff --git a/zh-cn/device-dev/guide/device-camera-visual-run.md b/zh-cn/device-dev/guide/device-camera-visual-run.md index 798c16bb43fec9d2f03c6a68577d193ea79591dd..7eb2de2d3794931d7cf31c037f8f4b4c3ed47ecc 100644 --- a/zh-cn/device-dev/guide/device-camera-visual-run.md +++ b/zh-cn/device-dev/guide/device-camera-visual-run.md @@ -1,6 +1,6 @@ # 真机运行 -应用编译打包后即可安装到开发板。安装应用前需要先完成[DevEco Device Tool的安装配置](https://device.harmonyos.com/cn/docs/ide/user-guides/service_introduction-0000001050166905),然后将OpenHarmony烧录到开发板并运行。编译烧录、运行镜像的基本操作请参考快速入门手册:[Hi3516快速入门](../quick-start/quickstart-lite-overview.md)。完成镜像运行,系统正常启动后,执行如下步骤安装或卸载三方应用。 +应用编译打包后即可安装到开发板。安装应用前需要先完成[DevEco Device Tool的安装配置](https://device.harmonyos.com/cn/docs/ide/user-guides/service_introduction-0000001050166905),然后将OpenHarmony烧录到开发板并运行。编译烧录、运行镜像的基本操作请参考快速入门手册:[小型系统快速入门](../quick-start/Readme-CN.md)。完成镜像运行,系统正常启动后,执行如下步骤安装或卸载三方应用。 1. 将IDE编译的未签名应用安装包和安装工具(镜像文件生成目录中的dev\_tools)放在sdcard中,将sdcard插入开发板卡槽。 2. 应用安装默认要校验签名,需要执行以下命令,关闭签名校验。 diff --git a/zh-cn/device-dev/guide/device-clock-guide.md b/zh-cn/device-dev/guide/device-clock-guide.md index aafad2d960b5e804d57054c0124082445e72a5da..15baa4e9c933fc9cea0d9bc9a3adba333708a37d 100644 --- a/zh-cn/device-dev/guide/device-clock-guide.md +++ b/zh-cn/device-dev/guide/device-clock-guide.md @@ -1,14 +1,5 @@ # 时钟应用开发指导 -- [概述](#section11522349121115) -- [开发准备](#section6592121861218) -- [开发步骤](#section19901741111312) -- [签名打包](#section10601181101516) -- [真机运行](#section092721731511) -- [常见问题](#section1122413460153) - - [hdc\_std连接不到设备](#section1922725151614) - - [hdc\_std运行不了](#section15657547131615) - ## 概述 @@ -259,7 +250,7 @@ ## 真机运行 -应用签名打包后即可安装到开发板。安装应用前需要先完成[DevEco Device Tool的安装配置](https://device.harmonyos.com/cn/docs/ide/user-guides/service_introduction-0000001050166905),然后将OpenHarmony系统烧录到开发板并运行。编译烧录、运行镜像的基本操作请参考快速入门手册:[标准系统Hi3516快速入门](../quick-start/quickstart-standard-overview.md)。完成镜像运行,系统正常启动后,执行如下步骤安装或卸载应用。 +应用签名打包后即可安装到开发板。安装应用前需要先完成[DevEco Device Tool的安装配置](https://device.harmonyos.com/cn/docs/ide/user-guides/service_introduction-0000001050166905),然后将OpenHarmony系统烧录到开发板并运行。编译烧录、运行镜像的基本操作请参考快速入门手册:[标准系统Hi3516快速入门](../quick-start/quickstart-appendix-hi3516-ide.md)。完成镜像运行,系统正常启动后,执行如下步骤安装或卸载应用。 1. 从开发者工具代码仓路径中获取hdc客户端。 diff --git a/zh-cn/device-dev/guide/device-driver-demo.md b/zh-cn/device-dev/guide/device-driver-demo.md index 69bc256f70eb551ba14d9943943818c0f38b2995..9276b5f934e691b423fd2193455795e15b0dbd12 100644 --- a/zh-cn/device-dev/guide/device-driver-demo.md +++ b/zh-cn/device-dev/guide/device-driver-demo.md @@ -1,15 +1,5 @@ # 平台驱动开发示例 -- [概述](#section194201316174215) -- [环境准备](#section6926133918422) -- [开发](#section65801539470) - - [文件说明](#section0708184454414) - - [实例化驱动入口](#section85325864412) - - [设置相关参数](#section8155172019453) - - [添加控制器](#section1335374114452) - -- [编译及烧录](#section164824754712) - ## 概述 本文档将以I2C驱动为例,介绍如何基于HDF驱动框架完成平台驱动开发。 @@ -26,7 +16,7 @@ HDF驱动框架为常用外围设备提供了标准的驱动框架,驱动开 ## 环境准备 -环境准备具体操作请参考[标准系统基础环境搭建](../quick-start/quickstart-standard-overview.md)。 +环境准备具体操作请参考[Hi3516标准系统入门](../quick-start/quickstart-appendix-hi3516-ide.md)完成环境搭建。 >![](../public_sys-resources/icon-notice.gif) **须知:** >本示例针对OpenHarmony轻量系统、小型系统、标准系统都适用,本文以标准系统为例。其他系统的开发者可参考对应系统的指导文档进行环境搭建。 @@ -440,8 +430,8 @@ HDF_INIT(g_sampleI2cDriverEntry); 2. 编译及烧录。 - - 安装包方式具体操作请参考标准系统快速入门[编译](../quick-start/quickstart-ide-standard-running-hi3516-build.md)和[烧录](../quick-start/quickstart-ide-standard-running-hi3516-burning.md)。 + - 安装包方式具体操作请参考标准系统快速入门[编译](../quick-start/quickstart-appendix-hi3516-pkg.md#编译)和[烧录](../quick-start/quickstart-appendix-hi3516-pkg.md#烧录)。 - - IDE方式具体操作请参考标准系统快速入门[编译](../quick-start/quickstart-standard-running-hi3516-build.md)和[烧录](../quick-start/quickstart-standard-running-hi3516-burning.md)。 + - IDE方式具体操作请参考标准系统快速入门[编译](../quick-start/quickstart-appendix-hi3516-ide.md#编译)和[烧录](../quick-start/quickstart-appendix-hi3516-ide.md#烧录)。 diff --git a/zh-cn/device-dev/guide/device-iotcamera-control-demo-photodevguide.md b/zh-cn/device-dev/guide/device-iotcamera-control-demo-photodevguide.md deleted file mode 100644 index f317784dbd25862f4752c69d6526335f03069fc9..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/guide/device-iotcamera-control-demo-photodevguide.md +++ /dev/null @@ -1,396 +0,0 @@ -# 拍照开发指导 - -- [使用场景](#zh-cn_topic_0000001052170554_section1963312376119) -- [接口说明](#zh-cn_topic_0000001052170554_section56549532016) -- [约束与限制](#zh-cn_topic_0000001052170554_section1165911177314) -- [开发步骤](#zh-cn_topic_0000001052170554_section138543918214) - -## 使用场景 - -使用Camera产生图片帧(拍照)。 - -## 接口说明 - -**表 1** API列表 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

类名

-

接口名

-

描述

-

CameraKit

-

int32_t GetCameraIds(std::list<string> cameraList)

-

获取cameraId列表

-

CameraKit

-

CameraAbility& GetCameraAbility(string cameraId)

-

获取指定camera的能力

-

CameraKit

-

void RegisterCameraDeviceCallback(CameraDeviceCallback* callback, EventHandler* handler)

-

注册camera设备状态回调

-

CameraKit

-

void UnregisterCameraDeviceCallback(CameraDeviceCallback* callback)

-

去注册camera设备状态回调

-

CameraKit

-

void CreateCamera(string cameraId, CameraStateCallback* callback, EventHandler* handler)

-

创建camera实例

-

Camera

-

string GetCameraId()

-

获取cameraID

-

Camera

-

CameraConfig& GetCameraConfig()

-

获取camera配置信息

-

Camera

-

FrameConfig& GetFrameConfig(int32_t type)

-

获取捕获帧类型

-

Camera

-

void Configure(CameraConfig& config)

-

配置camera

-

Camera

-

void Release()

-

释放camera

-

Camera

-

int TriggerLoopingCapture(FrameConfig& frameConfig)

-

开始循环帧捕获

-

Camera

-

void StopLoopingCapture()

-

停止循环帧捕获

-

Camera

-

int32_t TriggerSingleCapture(FrameConfig& frameConfig)

-

抓图

-

CameraConfig

-

void SetFrameStateCallback(FrameStateCallback* callback, EventHandler* handler);

-

设置帧状态回调

-

CameraConfig

-

static CameraConfig* CreateCameraConfig()

-

创建camera配置信息实例

-

CameraAbility

-

std::list<Size> GetSupportedSizes(int format)

-

根据类型获取支持输出图像尺寸大小

-

CameraAbility

-

std::list<T> GetParameterRange(uint32_t key)

-

获取支持的参数范围

-

CameraDevice

-

CameraDeviceCallback()

-

camera设备回调类构造函数

-

CameraDevice

-

void OnCameraStatus​(std::string cameraId, int32_t status)

-

camera设备状态变化时的回调

-

CameraStateCallback

-

CameraStateCallback​()

-

camera状态回调类构造函数

-

CameraStateCallback

-

void OnConfigured​(Camera& camera)

-

camera配置成功回调

-

CameraStateCallback

-

void OnConfigureFailed​(Camera& camera,int32_t errorCode)

-

camera配置失败回调

-

CameraStateCallback

-

void OnCreated​(Camera& camera)

-

camera创建成功回调

-

CameraStateCallback

-

void OnCreateFailed​(std::string cameraId,int32_t errorCode)

-

camera创建失败回调

-

CameraStateCallback

-

void OnReleased​(Camera& camera)

-

camera释放回调

-

FrameStateCallback

-

FrameStateCallback​()

-

帧状态回调类构造函数

-

FrameStateCallback

-

void OnFrameFinished(Camera& camera, FrameConfig& frameConfig, FrameResult& frameResult)

-

拍照帧完成回调

-

FrameStateCallback

-

void OnFrameError​(Camera& camera, FrameConfig& frameConfig, int32_t errorCode, FrameResult& frameResult)

-

拍照帧异常回调

-

FrameConfig

-

int32_t GetFrameConfigType()

-

获取帧配置类型

-

FrameConfig

-

std::list<OHOS::Surface> GetSurfaces()

-

获取帧配置的surface

-

FrameConfig

-

void AddSurface(OHOS::AGP::UISurface& surface);

-

添加surface

-

FrameConfig

-

void RemoveSurface(OHOS::AGP::UISurface& surface);

-

删除surface

-
- -## 约束与限制 - -无。 - -## 开发步骤 - -1. 实现设备状态回调的派生类,用户在设备状态发生变更(如新插入相机设备/相机掉线)时,自定义操作。 - - ``` - class SampleCameraDeviceCallback : public CameraDeviceCallback { - void OnCameraStatus(std::string cameraId, int32_t status) override - { - //do something when camera is available/unavailable - } - }; - ``` - -2. 实现帧事件回调的派生类,这里在拿到帧数据以后将其转存为文件。 - - ``` - static void SampleSaveCapture(const char *p, uint32_t size) - { - cout << "Start saving picture" << endl; - struct timeval tv; - gettimeofday(&tv, NULL); - struct tm *ltm = localtime(&tv.tv_sec); - if (ltm != nullptr) { - ostringstream ss("Capture_"); - ss << "Capture" << ltm->tm_hour << "-" << ltm->tm_min << "-" << ltm->tm_sec << ".jpg"; - - ofstream pic("/sdcard/" + ss.str(), ofstream::out | ofstream::trunc); - cout << "write " << size << " bytes" << endl; - pic.write(p, size); - cout << "Saving picture end" << endl; - } - } - - class TestFrameStateCallback : public FrameStateCallback { - void OnFrameFinished(Camera &camera, FrameConfig &fc, FrameResult &result) override - { - cout << "Receive frame complete inform." << endl; - if (fc.GetFrameConfigType() == FRAME_CONFIG_CAPTURE) { - cout << "Capture frame received." << endl; - list surfaceList = fc.GetSurfaces(); - for (Surface *surface : surfaceList) { - SurfaceBuffer *buffer = surface->AcquireBuffer(); - if (buffer != nullptr) { - char *virtAddr = static_cast(buffer->GetVirAddr()); - if (virtAddr != nullptr) { - SampleSaveCapture(virtAddr, buffer->GetSize()); - } - surface->ReleaseBuffer(buffer); - } - delete surface; - } - delete &fc; - } - } - }; - ``` - -3. 实现相机状态回调的派生类,自定义相机状态发生变化(配置成功/失败,创建成功/失败\)时的操作。 - - ``` - class SampleCameraStateMng : public CameraStateCallback { - public: - SampleCameraStateMng() = delete; - SampleCameraStateMng(EventHandler &eventHdlr) : eventHdlr_(eventHdlr) {} - ~SampleCameraStateMng() - { - if (recordFd_ != -1) { - close(recordFd_); - } - } - void OnCreated(Camera &c) override - { - cout << "Sample recv OnCreate camera." << endl; - auto config = CameraConfig::CreateCameraConfig(); - config->SetFrameStateCallback(&fsCb_, &eventHdlr_); - c.Configure(*config); - cam_ = &c; - } - void OnCreateFailed(const std::string cameraId, int32_t errorCode) override {} - void OnReleased(Camera &c) override {} - }; - ``` - -4. 创建CameraKit,用于创建和获取camera信息。 - - ``` - CameraKit *camKit = CameraKit::GetInstance(); - list camList = camKit->GetCameraIds(); - string camId; - for (auto &cam : camList) { - cout << "camera name:" << cam << endl; - const CameraAbility *ability = camKit->GetCameraAbility(cam); - /* find camera which fits user's ability */ - list sizeList = ability->GetSupportedSizes(0); - if (find(sizeList.begin(), sizeList.end(), CAM_PIC_1080P) != sizeList.end()) { - camId = cam; - break; - } - } - ``` - -5. 创建Camera实例。 - - ``` - EventHandler eventHdlr; // Create a thread to handle callback events - SampleCameraStateMng CamStateMng(eventHdlr); - - camKit->CreateCamera(camId, CamStateMng, eventHdlr); - ``` - -6. 根据[步骤1](#zh-cn_topic_0000001052170554_li378084192111)、[步骤2](#zh-cn_topic_0000001052170554_li8716104682913)、[步骤3](#zh-cn_topic_0000001052170554_li6671035102514)中的回调设计,同步等待 OnCreated 回调拿到 cam\_ 之后,进行相关操作。 - - ``` - void OnCreated(Camera &c) override - { - cout << "Sample recv OnCreate camera." << endl; - auto config = CameraConfig::CreateCameraConfig(); - config->SetFrameStateCallback(&fsCb_, &eventHdlr_); - c.Configure(*config); - cam_ = &c; - } - - void Capture() - { - if (cam_ == nullptr) { - cout << "Camera is not ready." << endl; - return; - } - FrameConfig *fc = new FrameConfig(FRAME_CONFIG_CAPTURE); - Surface *surface = Surface::CreateSurface(); - if (surface == nullptr) { - delete fc; - return; - } - surface->SetWidthAndHeight(1920, 1080); /* 1920:width,1080:height */ - fc->AddSurface(*surface); - cam_->TriggerSingleCapture(*fc); - } - ``` - - diff --git a/zh-cn/device-dev/guide/device-iotcamera-control-demo-videodevguide.md b/zh-cn/device-dev/guide/device-iotcamera-control-demo-videodevguide.md deleted file mode 100755 index c949175ec624ee835cb506636bb6f0598b2b3a6f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/guide/device-iotcamera-control-demo-videodevguide.md +++ /dev/null @@ -1,43 +0,0 @@ -# 录像开发指导 - -- [使用场景](#zh-cn_topic_0000001051451869_section186634310418) -- [接口说明](#zh-cn_topic_0000001051451869_section125479541744) -- [约束与限制](#zh-cn_topic_0000001051451869_section1165911177314) -- [开发步骤](#zh-cn_topic_0000001051451869_section1196016315516) - -## 使用场景 - -使用camera采集视频码流。 - -## 接口说明 - -参考“拍照开发指导”的“接口说明”。 - -## 约束与限制 - -无。 - -## 开发步骤 - -1. 参考“拍照开发指导”中步骤1、步骤2、步骤3、步骤4。 -2. 获取录像FrameConfig。 - - ``` - /* 从recorder获取surface */ - Surface *surface = recorder_->GetSurface(0); - surface->SetWidthAndHeight(1920, 1080); - surface->SetQueueSize(3); - surface->SetSize(1024 * 1024); - /* 将surface配置到帧配置中 */ - FrameConfig *fc = new FrameConfig(FRAME_CONFIG_RECORD); - fc->AddSurface(*surface); - ``` - -3. 开启和停止录像。 - - ``` - stateCallback->camera_->TriggerLoopingCapture(*fc); // 开始录像 - stateCallback->camera_->StopLoopingCapture(); // 结束录像 - ``` - - diff --git a/zh-cn/device-dev/guide/device-iotcamera-control-example.md b/zh-cn/device-dev/guide/device-iotcamera-control-example.md deleted file mode 100644 index 2a8f94bc82951c7d998d2d9519e9aba6f4f05818..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/guide/device-iotcamera-control-example.md +++ /dev/null @@ -1,45 +0,0 @@ -# 应用实例 - -- 开发板介绍、编译烧录、运行镜像等操作请参考[Hi3518快速入门](../quick-start/quickstart-lite-overview.md),编译结果包含示例,结果文件为out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample,可将文件通过读卡器复制至TF卡中,或者修改camera\_sample的编译脚本将结果文件复制至rootfs.img中。 - - 修改applications/sample/camera/media/BUILD.gn中的output\_dir。 - - - 修改前:output\_dir = "$root\_out\_dir/dev\_tools" - - 修改后:output\_dir = "$root\_out\_dir/" - - 重新执行源码仓编译并烧写入单板后,可在单板bin目录下找到camera\_sample文件。 - -- 相机示例代码为applications/sample/camera/media/camera\_sample.cpp。 - - >![](../public_sys-resources/icon-notice.gif) **须知:** - >实例运行拍照和录像功能需要插入TF卡\(最大容量支持128GB\),系统启动后时自动将TF卡挂载至/sdcard目录,如果在启动后插入则需要手动挂载。查看拍照和录像内容可将TF卡中内容复制到电脑中进行查看,预览功能无需TF卡。 - - -1. 通过cd命令进入可执行程序的末端路径,启动camera\_sample,执行命令如下图。 - - **图 1** 启动示例 - ![](figures/启动示例.png "启动示例") - - 运行后的控制命令如串口打印所示,按s键停止当前操作(包括录像和预览),按q键退出示例程序。 - -2. 按1进行拍照,拍照的文件格式为jpg,存储在/sdcard,文件名Capture\* - - **图 2** 输入拍照指令后串口打印日志 - ![](figures/输入拍照指令后串口打印日志.png "输入拍照指令后串口打印日志") - - 若想查看保存文件,可在退出程序后进入文件系统查看,退出后重新进入请回到步骤1。 - - **图 3** 查看文件图 - ![](figures/查看文件图.png "查看文件图") - -3. 按2进行录像,录像的文件格式为mp4,存储在/sdcard,文件名Record\*,按s键停止 - - **图 4** 输入录像指令后串口打印日志 - ![](figures/输入录像指令后串口打印日志.png "输入录像指令后串口打印日志") - -4. 按q键退出 - - **图 5** 输出退出指令后串口打印日志 - ![](figures/输出退出指令后串口打印日志.png "输出退出指令后串口打印日志") - - diff --git a/zh-cn/device-dev/guide/device-iotcamera-control-overview.md b/zh-cn/device-dev/guide/device-iotcamera-control-overview.md deleted file mode 100644 index 03fef3f55e4efd17bb96166a158e592c0f1316f5..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/guide/device-iotcamera-control-overview.md +++ /dev/null @@ -1,10 +0,0 @@ -# 概述 - -本文档将介绍如何基于IoT Camera开发板,利用开发套件中自带的摄像头,完成拍照、录像功能。 - -开发者可通过执行示例应用,对开发板的外设控制有了更深入了解后,可使用开发板完成摄像头等设备。 - -若开发者想先查看示例效果,请进入[应用实例](device-iotcamera-control-example.md)。如需自定义应用行为,可参考下节“示例开发”对示例代码进行修改。 - -相机开发基本概念可参考:[相机开发概述](../subsystems/subsys-multimedia-camera-overview.md)。 - diff --git a/zh-cn/device-dev/guide/device-outerdriver-demo.md b/zh-cn/device-dev/guide/device-outerdriver-demo.md index 29798f2ecd1c9d4bab66c032615d91a153aae8a0..38fe3a47a2a23eb8380f711e7ef4d9324060916a 100644 --- a/zh-cn/device-dev/guide/device-outerdriver-demo.md +++ b/zh-cn/device-dev/guide/device-outerdriver-demo.md @@ -25,7 +25,7 @@ Input驱动模型核心部分由设备管理层、公共驱动层、器件驱动 ## 环境搭建 -环境准备具体操作请参考[标准系统基础环境搭建](../quick-start/quickstart-standard-overview.md)。 +环境准备具体操作请参考[快速入门环境搭建章节](../quick-start/Readme-CN.md)。 >![](../public_sys-resources/icon-notice.gif) **须知:** >本示例针对OpenHarmony轻量系统、小型系统、标准系统都适用,本文以标准系统为例。其他系统的开发者可参考对应系统的指导文档进行环境搭建。 @@ -316,7 +316,7 @@ Input模型由三层驱动组成,开发者适配一款全新触摸屏驱动只 其中touch\_gt911.o为本示例中追加的内容。 -2. 具体编译及烧录操作请参考[标准系统快速入门编译及烧录章节](../quick-start/quickstart-standard-overview.md)。 +2. 具体编译及烧录操作请参考[标准系统快速入门的编译及烧录章节](../quick-start/Readme-CN.md)。 ## 调试验证 diff --git a/zh-cn/device-dev/guide/device-wlan-led-control.md b/zh-cn/device-dev/guide/device-wlan-led-control.md index 834a4332098799654d76f8ae76071c5a00edbf99..f5c5aa15d37ca16a1c2a3c9ea959cbd0fa15e83f 100644 --- a/zh-cn/device-dev/guide/device-wlan-led-control.md +++ b/zh-cn/device-dev/guide/device-wlan-led-control.md @@ -10,7 +10,7 @@ OpenHarmony WLAN模组基于Hi3861平台提供了丰富的外设操作能力, ## 开发 -1. 请先完成[《Hi3861快速入门》](../quick-start/quickstart-lite-overview.md)。 +1. 请先完成[轻量系统快速入门](../quick-start/Readme-CN.md)。 LED控制参考示例存放于applications/sample/wifi-iot/app/iothardware/led\_example.c文件中。 @@ -100,7 +100,7 @@ OpenHarmony WLAN模组基于Hi3861平台提供了丰富的外设操作能力, ## 验证 -编译过程请参考《[Hi3861快速入门-源码编译](../quick-start/quickstart-lite-steps-hi3861-building.md)》,烧录过程请参考《[Hi3861快速入门-镜像烧录](../quick-start/quickstart-lite-steps-hi3861-burn.md)》。 +编译过程请参考[轻量系统快速入门的编译章节](../quick-start/quickstart-ide-3861-build.md),烧录过程请参考[轻量系统快速入门的烧录章节](../quick-start/quickstart-ide-3861-burn.md)。 完成以上两步后,按下RST键复位模组,可发现LED在周期性闪烁,与预期相符,验证完毕。 diff --git a/zh-cn/device-dev/kernel/kernel-mini-overview.md b/zh-cn/device-dev/kernel/kernel-mini-overview.md index dd3ac86578e263c3e311cf25c34eeb9d97aa545f..4f8c132c2dcd4b8c99f7a7355208f5345b3bdf9b 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-overview.md +++ b/zh-cn/device-dev/kernel/kernel-mini-overview.md @@ -98,7 +98,7 @@ LiteOS-M内核的编译构建系统是一个基于gn和ninja的组件化构建 ### 搭建系统基础环境 -在搭建各个开发板环境前,需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境,详细介绍请参考官方站点[开发环境准备](../quick-start/quickstart-lite-env-setup.md)。开发者需要根据环境搭建文档完成环境搭建。 +在搭建各个开发板环境前,需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境,详细介绍请参考官方站点[快速入门环境搭建部分](../quick-start/Readme-CN.md)。开发者需要根据环境搭建文档完成环境搭建。 ### 获取OpenHarmony源码 diff --git a/zh-cn/device-dev/kernel/kernel-standard-newip.md b/zh-cn/device-dev/kernel/kernel-standard-newip.md index 6ef84d06c58931cebe4e6d1dfd253abdf86a506c..734d8b000e9c3288f5d4ffce3cfb521409960ad2 100644 --- a/zh-cn/device-dev/kernel/kernel-standard-newip.md +++ b/zh-cn/device-dev/kernel/kernel-standard-newip.md @@ -109,7 +109,7 @@ VENDOR_HOOKS=y // 使能内核插桩基础框架 备注: 1. 只在Linux 5.10内核上支持NewIP内核协议栈。 -2. 鸿蒙linux内核要求所有原生内核代码侵入式修改,都要修改成插桩方式。 +2. OpenHarmony linux内核要求所有原生内核代码侵入式修改,都要修改成插桩方式。 ```c /* 将NewIP ehash函数注册到内核 */ diff --git a/zh-cn/device-dev/porting/porting-minichip-overview.md b/zh-cn/device-dev/porting/porting-minichip-overview.md index c57c302091456ba3252dc6d4f9b607ecd501f376..381dbac536272720a7c3334336c304db2fd74bb3 100644 --- a/zh-cn/device-dev/porting/porting-minichip-overview.md +++ b/zh-cn/device-dev/porting/porting-minichip-overview.md @@ -43,5 +43,4 @@ | hb | OpenHarmony的命令行工具,用来执行编译命令。 | | HOBT | HiLink SDK OHOS Basic Test缩写,是HiLink SDK 接入 OpenHarmony的基础功能测试,检验HiLink SDK依赖的相关接口功能是否完善。 | | Kit Framework | Kit Framework是Kit的基础框架,包含了OpenHarmony的安全部件,不可裁剪。 | -| HiLink SDK | HarmonyOS Connect套件的一个关键组成部分,用于实现设备的联网,以及设备与HarmonyOS Connect云和智慧生活App的互联互通。 | | kv | 键值对(key-value),描述数据存储的格式。 | diff --git a/zh-cn/device-dev/porting/porting-smallchip-kernel-linux.md b/zh-cn/device-dev/porting/porting-smallchip-kernel-linux.md index 3e0a2da086cf2159e079694de88099de185c73d3..2b19663ca9314d684662e40ed273229aa72da186 100644 --- a/zh-cn/device-dev/porting/porting-smallchip-kernel-linux.md +++ b/zh-cn/device-dev/porting/porting-smallchip-kernel-linux.md @@ -45,7 +45,7 @@ Linux内核移植主要涉及基于linux内核基线合入三方芯片补丁后 4. 烧录启动。 由于不同芯片的开发板的烧录方式不一样,此处不表述具体的烧录方式。需要注意烧录的各镜像的大小及启动参数的配置,参考hi3516dv300采用uboot启动参数: - + ``` setenv bootargs 'mem=128M console=ttyAMA0,115200 root=/dev/mmcblk0p3 ro rootfstype=ext4 rootwait blkdevparts=mmcblk0:1M(boot),9M(kernel),50M(rootfs),50M(userfs)' ``` @@ -53,7 +53,7 @@ Linux内核移植主要涉及基于linux内核基线合入三方芯片补丁后 ## 验证 -调试init进程、启动shell和运行简单的用户态程序,验证内核移植是否成功。OpenHarmony[小型系统](../quick-start/quickstart-lite-overview.md)的OS镜像结构以及linux用户态的启动流程如下图1所示: +调试init进程、启动shell和运行简单的用户态程序,验证内核移植是否成功。OpenHarmony小型系统的OS镜像结构以及linux用户态的启动流程如下图1所示: **图1** 基于linux内核的OS镜像结构和用户态程序启动流程 ![zh-cn_image_0000001154372318](figures/zh-cn_image_0000001154372318.png) diff --git a/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md b/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md index 9a1463516ad1720c7e7d53a2e755ea40a6d8058a..5806ea15a5a72d3b363573fdebcbe0a57388b65b 100644 --- a/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md +++ b/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md @@ -2,7 +2,7 @@ ## 编译环境搭建 -首先请搭建OpenHarmony基础环境,步骤请参考轻量和小型系统入门[安装Hi3861开发板环境](../quick-start/quickstart-lite-steps-hi3861-setting.md)。用户态和LiteOS-A的内核态编译均使用llvm编译器编译,安装方法在搭建基础环境中已提供。若选择移植linux内核,请执行如下命令安装gcc-arm-linux-gnueabi交叉编译工具链,用于编译linux内核态镜像: +首先请搭建OpenHarmony基础环境,相关操作请参考[快速入门环境搭建章节](../quick-start/Readme-CN.md)。用户态和LiteOS-A的内核态编译均使用llvm编译器编译,安装方法在搭建基础环境中已提供。若选择移植linux内核,请执行如下命令安装gcc-arm-linux-gnueabi交叉编译工具链,用于编译linux内核态镜像: ``` diff --git a/zh-cn/device-dev/porting/porting-smallchip-prepare-needs.md b/zh-cn/device-dev/porting/porting-smallchip-prepare-needs.md index b8bcb956d8ccc29e138fde8784604b89caa9159b..e18f2c2236395eca02de67659a501f4cfce5305e 100644 --- a/zh-cn/device-dev/porting/porting-smallchip-prepare-needs.md +++ b/zh-cn/device-dev/porting/porting-smallchip-prepare-needs.md @@ -1,15 +1,15 @@ # 移植须知 -本文详细介绍如何将OpenHarmony[小型系统](../quick-start/quickstart-lite-overview.md)的linux和LiteOS-A内核移植到新的开发板上,要求读者具有一定的嵌入式系统开发经验。建议先查看[入门指导](../../OpenHarmony-Overview_zh.md),以了解OpenHarmony软件架构、目录结构、内核子系统和驱动子系统相关知识。当前小型系统已适配的开发板如下表所示: +本文详细介绍如何将OpenHarmony小型系统的linux和LiteOS-A内核移植到新的开发板上,要求读者具有一定的嵌入式系统开发经验。建议先查看[入门指导](../../OpenHarmony-Overview_zh.md),以了解OpenHarmony软件架构、目录结构、内核子系统和驱动子系统相关知识。当前小型系统已适配的开发板如下表所示: **表1** OpenHarmony小型系统已适配的开发板 -| 开发板 | 内核 | arch | ROM | RAM | 文件系统 | Flash 类型 | +| 开发板 | 内核 | arch | ROM | RAM | 文件系统 | Flash 类型 | | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -| hispark_taurus | LiteOS-A和linux-4.19 | ARM cortex-a7 | 8G | 1GB | VFAT、EXT4 | eMMC4.5 | -| hispark_aries | LiteOS-A | ARM cortex-a7 | 16M | 512M | JFFS2 | SPI NOR | +| hispark_taurus | LiteOS-A和linux-4.19 | ARM cortex-a7 | 8G | 1GB | VFAT、EXT4 | eMMC4.5 | +| hispark_aries | LiteOS-A | ARM cortex-a7 | 16M | 512M | JFFS2 | SPI NOR | 表1中的开发板可作为待移植开发板的参考,当前LiteOS-A和linux-4.19支持的arch、ROM占用、支持的文件系统和支持的Flash类型如下表所示: @@ -17,7 +17,7 @@ **表2** OpenHarmony小型系统内核移植信息表 -| 内核 | 支持的arch | ROM | 文件系统 | Flash类型 | +| 内核 | 支持的arch | ROM | 文件系统 | Flash类型 | | -------- | -------- | -------- | -------- | -------- | -| LiteOS-A | ARMv7 | > 2M | VFAT、JFFS2、YAFFS2 | SPI NOR、NAND、EMMC | -| linux-4.19 | ARM, ARM64、 MIPS、 X86等 | > 5M | VFAT、JFFS2、YAFFS、EXT/2/3/4、NFS等等 | NOR、NAND、EMMC等 | +| LiteOS-A | ARMv7 | > 2M | VFAT、JFFS2、YAFFS2 | SPI NOR、NAND、EMMC | +| linux-4.19 | ARM, ARM64、 MIPS、 X86等 | > 5M | VFAT、JFFS2、YAFFS、EXT/2/3/4、NFS等等 | NOR、NAND、EMMC等 | diff --git a/zh-cn/device-dev/porting/porting-thirdparty-cmake.md b/zh-cn/device-dev/porting/porting-thirdparty-cmake.md index 94b137955ecd3608b9d1e3ab31ee257d2a0d4d64..72b327ff5ed244779d6fea182041418c01ec2a84 100644 --- a/zh-cn/device-dev/porting/porting-thirdparty-cmake.md +++ b/zh-cn/device-dev/porting/porting-thirdparty-cmake.md @@ -10,23 +10,23 @@ **表1** 源码目录结构 -| 名称 | 描述 | +| 名称 | 描述 | | -------- | -------- | -| double-conversion/cmake/ | CMake组织编译使用到的模板 | -| double-conversion/double-conversion/ | 源文件目录 | -| double-conversion/msvc/ | - | -| double-conversion/test/ | 测试用例源文件 | -| double-conversion/.gitignore | - | -| double-conversion/AUTHORS | - | -| double-conversion/BUILD | - | -| double-conversion/CMakeLists.txt | CMake方式顶层编译组织文件 | -| double-conversion/COPYING | - | -| double-conversion/Changelog | - | -| double-conversion/LICENSE | - | -| double-conversion/Makefile | - | -| double-conversion/README.md | - | -| double-conversion/SConstruct | - | -| double-conversion/WORKSPACE | - | +| double-conversion/cmake/ | CMake组织编译使用到的模板 | +| double-conversion/double-conversion/ | 源文件目录 | +| double-conversion/msvc/ | - | +| double-conversion/test/ | 测试用例源文件 | +| double-conversion/.gitignore | - | +| double-conversion/AUTHORS | - | +| double-conversion/BUILD | - | +| double-conversion/CMakeLists.txt | CMake方式顶层编译组织文件 | +| double-conversion/COPYING | - | +| double-conversion/Changelog | - | +| double-conversion/LICENSE | - | +| double-conversion/Makefile | - | +| double-conversion/README.md | - | +| double-conversion/SConstruct | - | +| double-conversion/WORKSPACE | - | ## 移植思路 @@ -76,7 +76,7 @@ CMake方式可通过指定工具链进行交叉编译,修改并编译该库, 2. 执行编译 linux命令行中进入double-conversion的源文件目录(即标1所示目录),执行下列命令: - + ``` mkdir build && cd build cmake .. -DBUILD_TESTING=ON -DOHOS_SYSROOT_PATH="..." @@ -90,24 +90,24 @@ CMake方式可通过指定工具链进行交叉编译,修改并编译该库, **表2** 编译生成文件目录结构 - | 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | - | double-conversion/build/libdouble-conversion.a | 生成的静态库文件 | - | double-conversion/build/test/ | 目录下存放生成的测试用例和相关CMake缓存文件 | - | double-conversion/build/CMakeCache.txt | CMake构建过程中的缓存文件 | - | double-conversion/build/CMakeFiles/ | - | - | double-conversion/build/cmake_install.cmake | - | - | double-conversion/build/CTestTestfile.cmake | - | - | double-conversion/build/DartConfiguration.tcl | - | - | double-conversion/build/generated/ | - | - | double-conversion/build/Makefile | - | - | double-conversion/build/Testing/ | - | + | double-conversion/build/libdouble-conversion.a | 生成的静态库文件 | + | double-conversion/build/test/ | 目录下存放生成的测试用例和相关CMake缓存文件 | + | double-conversion/build/CMakeCache.txt | CMake构建过程中的缓存文件 | + | double-conversion/build/CMakeFiles/ | - | + | double-conversion/build/cmake_install.cmake | - | + | double-conversion/build/CTestTestfile.cmake | - | + | double-conversion/build/DartConfiguration.tcl | - | + | double-conversion/build/generated/ | - | + | double-conversion/build/Makefile | - | + | double-conversion/build/Testing/ | - | ## 测试 1. 搭建OpenHarmony环境 - 以Hi3516DV300为例,编译出OpenHarmony镜像,烧写到开发板,参考[开发Hi3516第一个示例程序](../quick-start/quickstart-lite-steps-hi3516-running.md)。 + 以Hi3516DV300为例,编译出OpenHarmony镜像,烧写到开发板,相关操作可参考[快速入门小型系统部分](../quick-start/Readme-CN.md)。 进入系统如下所示: @@ -129,7 +129,7 @@ CMake方式可通过指定工具链进行交叉编译,修改并编译该库, ``` 上述命令执行结果部分展示: - + ``` test-bignum/Assign< @@ -178,12 +178,12 @@ CMake方式可通过指定工具链进行交叉编译,修改并编译该库, **表3** 添加到工程后的目录结构 - | 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | - | OpenHarmony/third_party/double-conversion/BUILD.gn | 将三方库加入工程的gn适配文件 | - | OpenHarmony/third_party/double-conversion/build_thirdparty.py | GN调用shell命令脚本文件,由上面GN文件将相关命令传入,实现GN转CMake | - | OpenHarmony/third_party/double-conversion/config.gni | 三方库编译配置文件,可修改该文件来配置用例是否参与构建等 | - | OpenHarmony/third_party/double-conversion/double-conversion/ | 要移植的三方库目录 | + | OpenHarmony/third_party/double-conversion/BUILD.gn | 将三方库加入工程的gn适配文件 | + | OpenHarmony/third_party/double-conversion/build_thirdparty.py | GN调用shell命令脚本文件,由上面GN文件将相关命令传入,实现GN转CMake | + | OpenHarmony/third_party/double-conversion/config.gni | 三方库编译配置文件,可修改该文件来配置用例是否参与构建等 | + | OpenHarmony/third_party/double-conversion/double-conversion/ | 要移植的三方库目录 | 2. 添加gn到CMake适配文件 - **新增的BUILD.gn文件实现如下,其他采用CMake方式可独立编译的三方库移植到OpenHarmony平台时只需修改路径即可**。 @@ -289,7 +289,7 @@ CMake方式可通过指定工具链进行交叉编译,修改并编译该库, 执行下列命令 - + ``` hb build -T //third_party/double-conversion:double-conversion ``` diff --git a/zh-cn/device-dev/quick-start/Readme-CN.md b/zh-cn/device-dev/quick-start/Readme-CN.md index bdb003fcbd532f07ec1fc149ffc7314e7232af65..bb9ddaaf38bf9545eb0d2ea904bc148118c41d78 100644 --- a/zh-cn/device-dev/quick-start/Readme-CN.md +++ b/zh-cn/device-dev/quick-start/Readme-CN.md @@ -1,99 +1,59 @@ # 快速入门 -- 轻量和小型系统快速入门(IDE方式,推荐) - - [轻量与小型系统入门概述](quickstart-ide-lite-overview.md) - - 准备轻量与小型系统环境 - - [搭建Windows+Ubuntu混合开发环境](quickstart-ide-lite-env-setup-win-ubuntu.md) - - [获取源码](quickstart-ide-lite-sourcecode-acquire.md) - - [导入源码工程](quickstart-ide-lite-create-project.md) - - 运行“Hello World” - - Hi3861开发板 - - [编写“Hello World”程序](quickstart-ide-lite-steps-hi3861-helloworld.md) - - [编译](quickstart-ide-lite-steps-hi3861-building.md) - - [烧录](quickstart-ide-lite-steps-hi3861-burn.md) - - [联网](quickstart-ide-lite-steps-hi3861-netconfig.md) - - [调试验证](quickstart-ide-lite-steps-hi3861-debug.md) - - [运行](quickstart-ide-lite-steps-hi3861-running.md) - - Hi3516开发板 - - [编写“Hello World”程序](quickstart-ide-lite-steps-hi3516-helloworld.md) - - [编译](quickstart-ide-lite-steps-hi3516-building.md) - - [烧录](quickstart-ide-lite-steps-hi3516-burn.md) - - [运行](quickstart-ide-lite-steps-hi3516-running.md) - - 附录 - - [Hi3861开发板介绍](quickstart-ide-lite-introduction-hi3861.md) - - [Hi3516开发板介绍](quickstart-ide-lite-introduction-hi3516.md) - - [编译形态整体说明](quickstart-build.md) -- 轻量和小型系统快速入门(安装包方式) - - [轻量与小型系统入门概述](quickstart-lite-overview.md) - - [搭建轻量与小型系统环境](quickstart-lite-env-setup.md) - - 运行“Hello World” - - Hi3861开发板 - - [安装Hi3861开发板环境](quickstart-lite-steps-hi3861-setting.md) - - [编写“Hello World”程序](quickstart-lite-steps-hi3861-helloworld.md) - - [编译](quickstart-lite-steps-hi3861-building.md) - - [烧录](quickstart-lite-steps-hi3861-burn.md) - - [联网](quickstart-lite-steps-hi3861-netconfig.md) - - [调试验证](quickstart-lite-steps-hi3861-debug.md) - - [运行](quickstart-lite-steps-hi3861-running.md) - - Hi3516开发板 - - [安装Hi3516开发板环境](quickstart-lite-steps-hi3516-setting.md) - - [编写“Hello World”程序](quickstart-lite-steps-hi3516-helloworld.md) - - [编译](quickstart-lite-steps-hi3516-building.md) - - [烧录](quickstart-lite-steps-hi3516-burn.md) - - [运行](quickstart-lite-steps-hi3516-running.md) - - 常见问题 - - [hb安装异常](quickstart-lite-faq-hb.md) - - [编译异常](quickstart-lite-faq-compose.md) - - [烧录异常](quickstart-lite-faq-burning.md) - - 附录 - - 开发板介绍 - - [Hi3861开发板介绍](quickstart-lite-introduction-hi3861.md) - - [Hi3516开发板介绍](quickstart-lite-introduction-hi3516.md) - - [参考信息](quickstart-lite-reference.md) - - [使用HiTool烧录代码](quickstart-lite-hitool.md) - - [编译形态整体说明](quickstart-build.md) -- 标准系统快速入门(IDE方式,推荐) - - [标准系统入门概述](quickstart-ide-standard-overview.md) - - 准备标准系统环境 - - [搭建Windows+Ubuntu混合开发环境](quickstart-ide-standard-env-setup-win-ubuntu.md) - - [获取源码](quickstart-ide-standard-sourcecode-acquire.md) - - [导入源码工程](quickstart-ide-standard-create-project.md) - - 运行“Hello World” - - Hi3516开发板 - - [编写“Hello World”程序](quickstart-ide-standard-running-hi3516-create.md) - - [编译](quickstart-ide-standard-running-hi3516-build.md) - - [烧录](quickstart-ide-standard-running-hi3516-burning.md) - - [运行](quickstart-ide-standard-running-hi3516-running.md) - - RK3568开发板 - - [编写“Hello World”程序](quickstart-ide-standard-running-rk3568-create.md) - - [编译](quickstart-ide-standard-running-rk3568-build.md) - - [烧录](quickstart-ide-standard-running-rk3568-burning.md) - - [运行](quickstart-ide-standard-running-rk3568-running.md) - - 附录 - - [Hi3516开发板介绍](quickstart-ide-standard-board-introduction-hi3516.md) - - [RK3568开发板介绍](quickstart-ide-standard-board-introduction-rk3568.md) - - [编译形态整体说明](quickstart-build.md) -- 标准系统快速入门(安装包方式) - - [标准系统入门概述](quickstart-standard-overview.md) - - [搭建标准系统环境](quickstart-standard-env-setup.md) - - 运行“Hello World” - - Hi3516开发板 - - [编写“Hello World”程序](quickstart-std-3516-create.md) - - [编译](quickstart-standard-running-hi3516-build.md) - - [烧录](quickstart-standard-running-hi3516-burning.md) - - [运行](quickstart-standard-running-hi3516-running.md) - - RK3568开发板 - - [编写“Hello World”程序](quickstart-standard-running-rk3568-create.md) - - [编译](quickstart-standard-running-rk3568-build.md) - - [烧录](quickstart-standard-running-rk3568-burning.md) - - [运行](quickstart-standard-running-rk3568-running.md) - - 常见问题 - - [hb安装异常](quickstart-standard-faq-hb.md) - - [编译异常](quickstart-standard-faq-compose.md) - - [烧录异常](quickstart-standard-faq-burning.md) - - 附录 - - 开发板介绍 - - [Hi3516开发板介绍](quickstart-standard-board-introduction-hi3516.md) - - [RK3568开发板介绍](quickstart-standard-board-introduction-rk3568.md) - - [参考信息](quickstart-standard-reference.md) - - [使用HiTool烧录代码](quickstart-standard-hitool.md) - - [编译形态整体说明](quickstart-build.md) \ No newline at end of file + +- [快速入门概述](quickstart-overview.md) +- 基于IDE入门 + - 搭建开发环境 + - [搭建Windows环境](quickstart-ide-env--win.md) + - [搭建Ubuntu环境](quickstart-ide-env-ubuntu.md) + - [配置远程访问环境](quickstart-ide-env-remote.md) + - [创建工程并获取源码](quickstart-ide-import-project.md) + - 轻量系统(基于Hi3861开发板) + - [编写“Hello World”程序](quickstart-ide-3861-helloworld.md) + - [编译](quickstart-ide-3861-build.md) + - [烧录](quickstart-ide-3861-burn.md) + - [运行](quickstart-ide-3861-running.md) + - 小型系统(基于Hi3516开发板) + - [编写“Hello World”程序](quickstart-ide-3516-helloworld.md) + - [编译](quickstart-ide-3516-build.md) + - [烧录](quickstart-ide-3516-burn.md) + - [运行](quickstart-ide-3516-running.md) + - 标准系统(基于RK3568开发板) + - [编写“Hello World”程序](quickstart-ide-3568-helloworld.md) + - [编译](quickstart-ide-3568-build.md) + - [烧录](quickstart-ide-3568-burn.md) + - [运行](quickstart-ide-3568-running.md) +- 基于命令行入门 + - 搭建开发环境 + - [准备开发环境](quickstart-pkg-prepare.md) + - [安装库和工具集](quickstart-pkg-install_package.md) + - [获取源码](quickstart-pkg-sourcecode.md) + - [安装编译工具](quickstart-pkg-install_tool.md) + - 轻量系统(基于Hi3861开发板) + - [安装Hi3861开发板特有环境](quickstart-pkg-3861-tool.md) + - [编写“Hello World”程序](quickstart-pkg-3861-helloworld.md) + - [编译](quickstart-pkg-3861-build.md) + - [烧录](quickstart-pkg-3861-burn.md) + - [运行](quickstart-pkg-3861-running.md) + - 小型系统(基于Hi3516开发板) + - [编写“Hello World”程序](quickstart-pkg-3516-helloworld.md) + - [编译](quickstart-pkg-3516-build.md) + - [烧录](quickstart-pkg-3516-burn.md) + - [运行](quickstart-pkg-3516-running.md) + - 标准系统(基于RK3568开发板) + - [编写“Hello World”程序](quickstart-pkg-3568-helloworld.md) + - [编译](quickstart-pkg-3568-build.md) + - [烧录](quickstart-pkg-3568-burn.md) + - [运行](quickstart-pkg-3568-running.md) + - 常用信息 + - [配置代理](quickstart-pkg-common-proxy.md) + - [使用build.sh脚本编译源码](quickstart-pkg-common-build.md) + - [hb安装异常处理](quickstart-pkg-common-hberr.md) + - [编译异常处理](quickstart-pkg-common-builderr.md) + - [烧录异常处理](quickstart-pkg-common-burnerr.md) +- 附录 + - [Hi3516开发板介绍](quickstart-appendix-hi3516.md) + - [Hi3861开发板介绍](quickstart-appendix-hi3861.md) + - [RK3568开发板介绍](quickstart-appendix-rk3568.md) + - [编译形态整体说明](quickstart-appendix-compiledform.md) + - [Hi3516标准系统入门(IDE方式)](quickstart-appendix-hi3516-ide.md) + - [Hi3516标准系统入门(命令行方式)](quickstart-appendix-hi3516-pkg.md) diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001312778829.png b/zh-cn/device-dev/quick-start/figures/3516-small-partitions.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001312778829.png rename to zh-cn/device-dev/quick-start/figures/3516-small-partitions.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223190441.png b/zh-cn/device-dev/quick-start/figures/3516-small-usb.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223190441.png rename to zh-cn/device-dev/quick-start/figures/3516-small-usb.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239661509.png b/zh-cn/device-dev/quick-start/figures/3865-uploader.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239661509.png rename to zh-cn/device-dev/quick-start/figures/3865-uploader.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198566365.png b/zh-cn/device-dev/quick-start/figures/Phoenix-upload.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198566365.png rename to zh-cn/device-dev/quick-start/figures/Phoenix-upload.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001209906547.png b/zh-cn/device-dev/quick-start/figures/bootloader.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001209906547.png rename to zh-cn/device-dev/quick-start/figures/bootloader.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594753.png b/zh-cn/device-dev/quick-start/figures/faq-download-ecdsa.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594753.png rename to zh-cn/device-dev/quick-start/figures/faq-download-ecdsa.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794696.png b/zh-cn/device-dev/quick-start/figures/faq-download-pycrypto.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794696.png rename to zh-cn/device-dev/quick-start/figures/faq-download-pycrypto.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474573.png b/zh-cn/device-dev/quick-start/figures/faq-download-six.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474573.png rename to zh-cn/device-dev/quick-start/figures/faq-download-six.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114636.png b/zh-cn/device-dev/quick-start/figures/faq-python-add-soft-link.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114636.png rename to zh-cn/device-dev/quick-start/figures/faq-python-add-soft-link.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922322.png b/zh-cn/device-dev/quick-start/figures/faq-python-error.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922322.png rename to zh-cn/device-dev/quick-start/figures/faq-python-error.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602414.png b/zh-cn/device-dev/quick-start/figures/faq-python3-not-found.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602414.png rename to zh-cn/device-dev/quick-start/figures/faq-python3-not-found.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602398.png b/zh-cn/device-dev/quick-start/figures/helloworld.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602398.png rename to zh-cn/device-dev/quick-start/figures/helloworld.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234753.png b/zh-cn/device-dev/quick-start/figures/hi3516-faq-burn-uboot-success.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234753.png rename to zh-cn/device-dev/quick-start/figures/hi3516-faq-burn-uboot-success.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234765.png b/zh-cn/device-dev/quick-start/figures/hi3516-faq-firewall-find-vscode.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234765.png rename to zh-cn/device-dev/quick-start/figures/hi3516-faq-firewall-find-vscode.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202457.png b/zh-cn/device-dev/quick-start/figures/hi3516-faq-firewall-setting-allow.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202457.png rename to zh-cn/device-dev/quick-start/figures/hi3516-faq-firewall-setting-allow.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634732.png b/zh-cn/device-dev/quick-start/figures/hi3516-faq-firewall-setting.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634732.png rename to zh-cn/device-dev/quick-start/figures/hi3516-faq-firewall-setting.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442273.png b/zh-cn/device-dev/quick-start/figures/hi3516-faq-firewall-vscode-allow-network.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442273.png rename to zh-cn/device-dev/quick-start/figures/hi3516-faq-firewall-vscode-allow-network.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922306.png b/zh-cn/device-dev/quick-start/figures/hi3516-faq-network-fail.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922306.png rename to zh-cn/device-dev/quick-start/figures/hi3516-faq-network-fail.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634728.png b/zh-cn/device-dev/quick-start/figures/hi3516-faq-serial-access-denied.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634728.png rename to zh-cn/device-dev/quick-start/figures/hi3516-faq-serial-access-denied.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954644.png b/zh-cn/device-dev/quick-start/figures/hi3516-faq-serial-check.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954644.png rename to zh-cn/device-dev/quick-start/figures/hi3516-faq-serial-check.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202469.png b/zh-cn/device-dev/quick-start/figures/hi3516-faq-serial-close-terminal.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202469.png rename to zh-cn/device-dev/quick-start/figures/hi3516-faq-serial-close-terminal.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562449.png b/zh-cn/device-dev/quick-start/figures/hi3516-faq-serial-reburn.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562449.png rename to zh-cn/device-dev/quick-start/figures/hi3516-faq-serial-reburn.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634692.png b/zh-cn/device-dev/quick-start/figures/hi3861-front.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634692.png rename to zh-cn/device-dev/quick-start/figures/hi3861-front.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794688.png b/zh-cn/device-dev/quick-start/figures/hi3861-function.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794688.png rename to zh-cn/device-dev/quick-start/figures/hi3861-function.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794660.png b/zh-cn/device-dev/quick-start/figures/hi3861-rear.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794660.png rename to zh-cn/device-dev/quick-start/figures/hi3861-rear.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234749.png b/zh-cn/device-dev/quick-start/figures/hi3861-scons-install-success.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234749.png rename to zh-cn/device-dev/quick-start/figures/hi3861-scons-install-success.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634668.png b/zh-cn/device-dev/quick-start/figures/hi3861-test.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634668.png rename to zh-cn/device-dev/quick-start/figures/hi3861-test.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198466090.png b/zh-cn/device-dev/quick-start/figures/hi3861-upload-restart.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198466090.png rename to zh-cn/device-dev/quick-start/figures/hi3861-upload-restart.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001164506870.png b/zh-cn/device-dev/quick-start/figures/monitor.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001164506870.png rename to zh-cn/device-dev/quick-start/figures/monitor.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202289.gif b/zh-cn/device-dev/quick-start/figures/press-any-key-to-enter-the-system.gif similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202289.gif rename to zh-cn/device-dev/quick-start/figures/press-any-key-to-enter-the-system.gif diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001268278138.png b/zh-cn/device-dev/quick-start/figures/quick-start-hi3516-standard-build.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001268278138.png rename to zh-cn/device-dev/quick-start/figures/quick-start-hi3516-standard-build.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762210.png b/zh-cn/device-dev/quick-start/figures/quickstart-appendix-hi3516-ide-run-set.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762210.png rename to zh-cn/device-dev/quick-start/figures/quickstart-appendix-hi3516-ide-run-set.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602238.png b/zh-cn/device-dev/quick-start/figures/quickstart-appendix-hi3516-ide-run-start.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602238.png rename to zh-cn/device-dev/quick-start/figures/quickstart-appendix-hi3516-ide-run-start.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762374.png b/zh-cn/device-dev/quick-start/figures/quickstart-appendix-hi3516-ide-run.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762374.png rename to zh-cn/device-dev/quick-start/figures/quickstart-appendix-hi3516-ide-run.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001249937194.png b/zh-cn/device-dev/quick-start/figures/quickstart-hi3516-standard-hitool-select.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001249937194.png rename to zh-cn/device-dev/quick-start/figures/quickstart-hi3516-standard-hitool-select.png diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-ide-3861-running-mirror.png b/zh-cn/device-dev/quick-start/figures/quickstart-ide-3861-running-mirror.png new file mode 100644 index 0000000000000000000000000000000000000000..56ec34df8900dbe9f62a7fb5fb0825f9535f91a0 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-ide-3861-running-mirror.png differ diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-ide-3861-running-restart.png b/zh-cn/device-dev/quick-start/figures/quickstart-ide-3861-running-restart.png new file mode 100644 index 0000000000000000000000000000000000000000..97275b916212138aa8d4a40e3b5b879671d8347c Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-ide-3861-running-restart.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954648.png b/zh-cn/device-dev/quick-start/figures/quickstart-ide-3861-running-success.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954648.png rename to zh-cn/device-dev/quick-start/figures/quickstart-ide-3861-running-success.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001317198053.png b/zh-cn/device-dev/quick-start/figures/quickstart-lite-3516-build.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001317198053.png rename to zh-cn/device-dev/quick-start/figures/quickstart-lite-3516-build.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001317078157.png b/zh-cn/device-dev/quick-start/figures/quickstart-lite-3861-build.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001317078157.png rename to zh-cn/device-dev/quick-start/figures/quickstart-lite-3861-build.png diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-overview-process.png b/zh-cn/device-dev/quick-start/figures/quickstart-overview-process.png new file mode 100644 index 0000000000000000000000000000000000000000..457cd2745ff907d960a06d2eee6ab9c8cdf1a3d3 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-overview-process.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234769.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3516-running.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234769.png rename to zh-cn/device-dev/quick-start/figures/quickstart-pkg-3516-running.png diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3568-running-restart.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3568-running-restart.png new file mode 100644 index 0000000000000000000000000000000000000000..fb835e7325ec19cc9b9f99feca68a43fe6b9896f Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3568-running-restart.png differ diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-burning.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-burning.png new file mode 100644 index 0000000000000000000000000000000000000000..d6156b480558ca02e0d1c60037f53671bda53bd1 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-burning.png differ diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-connect.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-connect.png new file mode 100644 index 0000000000000000000000000000000000000000..1ceffb203eb4d8fa629b26c937744333f97a9eb7 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-connect.png differ diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-end.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-end.png new file mode 100644 index 0000000000000000000000000000000000000000..cf6c9da952d239c7cd81cc48266d7503f02eaab2 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-end.png differ diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-hiburn.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-hiburn.png new file mode 100644 index 0000000000000000000000000000000000000000..85156f56ba63d3ecdc645e251a37a4f3903d23dc Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-hiburn.png differ diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-selectfile.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-selectfile.png new file mode 100644 index 0000000000000000000000000000000000000000..67ff2fb770e914ed26c4eece7f830759918dd423 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-burn-selectfile.png differ diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-running-restart.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-running-restart.png new file mode 100644 index 0000000000000000000000000000000000000000..4bc097c5256c1c6068739524f05294954865f6b9 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-running-restart.png differ diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-running-success.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-running-success.png new file mode 100644 index 0000000000000000000000000000000000000000..eb82a1333c47122b8ee4a194f2e93984222df37f Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-3861-running-success.png differ diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-pkg-prepare-networkdriver.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-prepare-networkdriver.png new file mode 100644 index 0000000000000000000000000000000000000000..c2569d536003ab7abbf9289183bfcc71d87b8ee4 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-prepare-networkdriver.png differ diff --git a/zh-cn/device-dev/quick-start/figures/quickstart-pkg-prepare-setsamba.png b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-prepare-setsamba.png new file mode 100644 index 0000000000000000000000000000000000000000..a1c3a49091f525d23e4233f3f087f23e002cb4f2 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/quickstart-pkg-prepare-setsamba.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001268598074.png b/zh-cn/device-dev/quick-start/figures/quickstart-standard-rk3568-build.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001268598074.png rename to zh-cn/device-dev/quick-start/figures/quickstart-standard-rk3568-build.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198626874.png b/zh-cn/device-dev/quick-start/figures/reboot-success.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198626874.png rename to zh-cn/device-dev/quick-start/figures/reboot-success.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001210385161.png b/zh-cn/device-dev/quick-start/figures/reset_success.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001210385161.png rename to zh-cn/device-dev/quick-start/figures/reset_success.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442129.png b/zh-cn/device-dev/quick-start/figures/rk3568-front.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442129.png rename to zh-cn/device-dev/quick-start/figures/rk3568-front.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602394.png b/zh-cn/device-dev/quick-start/figures/rk3568-rear.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602394.png rename to zh-cn/device-dev/quick-start/figures/rk3568-rear.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602250.png b/zh-cn/device-dev/quick-start/figures/rk3568-run-configuration.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602250.png rename to zh-cn/device-dev/quick-start/figures/rk3568-run-configuration.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322437.png b/zh-cn/device-dev/quick-start/figures/setenv-bootargs.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322437.png rename to zh-cn/device-dev/quick-start/figures/setenv-bootargs.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001243641075.png b/zh-cn/device-dev/quick-start/figures/ubuntu-dash-to-bash.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001243641075.png rename to zh-cn/device-dev/quick-start/figures/ubuntu-dash-to-bash.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193920448.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193920448.png deleted file mode 100644 index 378084aa4b6a467f549a6c97bde39c7720d6b427..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193920448.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193983334.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193983334.png deleted file mode 100644 index 216476f79ed241c3b77d7d2d688cb6fcdc1d8423..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193983334.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198943768.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198943768.png deleted file mode 100644 index 5702f209752edc74d687e5e8ce7e210428f4551e..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198943768.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852753.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852753.png deleted file mode 100644 index 58d4e1027aefb6650920d9d31fbb622bebc4f726..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852753.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852754.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852754.png deleted file mode 100644 index a316d0a2c4117a16143c79426523dbc75c8dd1a8..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852754.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221012766.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221012766.png deleted file mode 100644 index 8d6c2de3aeeda000f6b0258f53de71e147ce5b27..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221012766.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602406.jpg b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602406.jpg deleted file mode 100644 index 31c5a26705cd1da6cf9cb6f3bb356994e4ecc22e..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602406.jpg and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634676.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634676.png deleted file mode 100644 index 5e307225f0246c7d1afe8b949a8135b5a0e94a51..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634676.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634700.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634700.png deleted file mode 100644 index 8c6ec0adb87f693519f0e3b00b3aa7053f3e23ae..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634700.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762222.jpg b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762222.jpg deleted file mode 100644 index 31c5a26705cd1da6cf9cb6f3bb356994e4ecc22e..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762222.jpg and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762378.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762378.png deleted file mode 100644 index 5006140f00ec1195d04297cdeb26ad935fb9f0e5..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762378.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794644.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794644.png deleted file mode 100644 index e674bafb0adaa4c0ff8efaf297ee52bab3165212..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794644.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794704.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794704.png deleted file mode 100644 index 9d3bdbfe1eac9dc532496a7785e8caf99c41780b..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794704.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922154.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922154.png deleted file mode 100644 index f1aa2e319290cf3700a49391c3f078092a80821e..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922154.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922310.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922310.png deleted file mode 100644 index 504da23ba456a9c377525e22c4630361286b5dd7..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922310.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954632.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954632.png deleted file mode 100644 index 4829c4ecd911b02b1066790a85360aabb5492ec3..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954632.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082162.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082162.png deleted file mode 100644 index 6d350e5d4db03fecc5c1b8055b01cdf73667ed36..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082162.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082182.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082182.png deleted file mode 100644 index e53a724993830b5d0e6e1e9871d99dfc99c55f11..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082182.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082314.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082314.png deleted file mode 100644 index a56a33574b9766509dc8add6ba3a1ecc578fe92c..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082314.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082322.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082322.png deleted file mode 100644 index 88cba0537b5431aa266364abbe19162130f4e3ca..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082322.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082334.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082334.png deleted file mode 100644 index 527fe8b9836daf35c8300e0e84bdb2ca390f85a5..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082334.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114584.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114584.png deleted file mode 100644 index 67e50038e79cf0f7c2a6bd79b48c63b7557179a4..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114584.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114612.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114612.png deleted file mode 100644 index ebf4f8eba03720edddfb9ef8eb38bd5f71126f2a..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114612.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114628.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114628.png deleted file mode 100644 index a56a33574b9766509dc8add6ba3a1ecc578fe92c..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114628.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114640.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114640.png deleted file mode 100644 index ff9105c313d5755f140920bbfc2399e3ccb5e2f5..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114640.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114644.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114644.png deleted file mode 100644 index 8c6ec0adb87f693519f0e3b00b3aa7053f3e23ae..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114644.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001237801283.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001237801283.png deleted file mode 100644 index e9127be45474fa5d254a8444bc96d34ec8798108..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001237801283.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239275843.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239275843.png deleted file mode 100644 index b9b0c15345138b5d784e027330b650e16b97ee4e..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239275843.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001259180828.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001259180828.png deleted file mode 100644 index e6bc8d9c83c45f71ad7ea181903503a9c8d4eb3b..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001259180828.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261395999.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261395999.png deleted file mode 100644 index 349188d5e1a6e11772c88615dc00deffc8dd39b7..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261395999.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265652869.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265652869.png deleted file mode 100644 index fb6232380ebbc988a3b23dfec149daedd3f0c971..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265652869.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265772913.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265772913.png deleted file mode 100644 index e5596ca2eac9b5d2cd1c96ffa50b1e390c68c904..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265772913.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202461.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202461.png deleted file mode 100644 index 0eee1bbff2e54816d6be05f7f3972a83f615884d..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202461.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202465.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202465.png deleted file mode 100644 index f1aa2e319290cf3700a49391c3f078092a80821e..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202465.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202473.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202473.png deleted file mode 100644 index cfa0ceb21f5a11d459b93721f512309c9d6da2ac..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202473.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234705.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234705.png deleted file mode 100644 index bc935a8970e39629d2c93f6b92f96c5fa7d1a49b..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234705.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234717.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234717.png deleted file mode 100644 index e53a724993830b5d0e6e1e9871d99dfc99c55f11..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234717.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234729.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234729.png deleted file mode 100644 index 7de3c25e7ef2abc8d85d8bc945249f571f6bf0c3..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234729.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234757.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234757.png deleted file mode 100644 index 548e03da4b76123cb67d41cbd1de4a0f33f5ef4b..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234757.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234761.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234761.png deleted file mode 100644 index 0c1f60638087d0fe56127f2f842244355afad85f..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234761.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234773.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234773.png deleted file mode 100644 index e53a724993830b5d0e6e1e9871d99dfc99c55f11..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234773.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271237242.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271237242.png deleted file mode 100644 index 9a300afbcd842f7c61877123236675efc422f039..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271237242.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322277.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322277.png deleted file mode 100644 index f1aa2e319290cf3700a49391c3f078092a80821e..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322277.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322293.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322293.png deleted file mode 100644 index 8baa9c7c75625c18979d30ab52b2a0f64e0e8349..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322293.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354733.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354733.png deleted file mode 100644 index a8037d1ebc95a3c9383d87678981b3ae5ccc8144..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354733.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354745.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354745.png deleted file mode 100644 index b6bc36af5339ea5a4f67640e69836965b3776e17..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354745.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354749.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354749.png deleted file mode 100644 index 775ce6fe99d4894b39f2bdd613097dcaf11a37b2..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354749.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442261.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442261.png deleted file mode 100644 index c728580c57510fa2fe67a7e337492adae328d7ea..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442261.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442265.gif b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442265.gif deleted file mode 100644 index 52b3511bd7ec50a86e9b348aecfb1704dae36188..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442265.gif and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271448821.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271448821.png deleted file mode 100644 index 0a150015345ea48708c486f21b76796f6e3ee36d..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271448821.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474569.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474569.png deleted file mode 100644 index 5086d2b4518cfea4040f3cc243abb2e6087af350..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474569.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474585.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474585.png deleted file mode 100644 index afc9028fbb61db82e6f1384032bb32f56ed2ec35..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474585.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271477045.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271477045.png deleted file mode 100644 index 8581b9663ab1f1597166d9e5b668c4d70c273e01..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271477045.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562257.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562257.png deleted file mode 100644 index 5e307225f0246c7d1afe8b949a8135b5a0e94a51..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562257.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562269.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562269.png deleted file mode 100644 index 802cce4e760102043f177cb2fa71e8bd16539ba1..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562269.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562437.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562437.png deleted file mode 100644 index 47231369bbeb827e70a8720b7a3d03ac58fad0c3..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562437.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562445.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562445.png deleted file mode 100644 index c735ae362e184083329cdf710289a169ad5625d4..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562445.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562453.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562453.png deleted file mode 100644 index 9284df45bb1415d84f0325df85b4eb5c223281e8..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562453.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594709.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594709.png deleted file mode 100644 index 7a063003ded7d94e8b2a030a3df855f6915c933c..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594709.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594733.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594733.png deleted file mode 100644 index 9d3bdbfe1eac9dc532496a7785e8caf99c41780b..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594733.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594765.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594765.png deleted file mode 100644 index 208a4fbace342514f59f0000c4d50f5dc9321f0f..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594765.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001278358765.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001272258726.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001278358765.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001272258726.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198566364.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001274745038.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198566364.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001274745038.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852755.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001274748606.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852755.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001274748606.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239650137.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275267040.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239650137.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275267040.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261515989.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275432904.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261515989.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275432904.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265492885.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275483042.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265492885.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275483042.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307019009.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275586896.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307019009.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275586896.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265785209.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275752808.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265785209.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275752808.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001160649344.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275802150.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001160649344.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275802150.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001114129426.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275835836.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001114129426.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001275835836.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276122010.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276122010.png new file mode 100644 index 0000000000000000000000000000000000000000..e31eef74e95c2ecbb8e62d4ad897a2188e66d186 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276122010.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001267532292.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276281922.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001267532292.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276281922.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001160649343.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276317464.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001160649343.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276317464.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279425450.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279425450.png deleted file mode 100644 index fa3d1c40e18002a60a3c179b5e4e1396056a5b41..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279425450.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279426717.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279426717.png deleted file mode 100644 index 0a150015345ea48708c486f21b76796f6e3ee36d..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279426717.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279586409.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279586409.png deleted file mode 100644 index e1cfe8323c13c750a03c4d5c86f2c383e554485d..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279586409.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279587085.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279587085.png deleted file mode 100644 index 084af8cfb40d4c59aa428890df7a1aee622a79d4..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001279587085.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194821710.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001280147358.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194821710.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001280147358.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216761476.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281002722.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216761476.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281002722.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265505181.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281221352.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265505181.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281221352.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221344980.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281378224.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221344980.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281378224.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285647778.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285647778.png new file mode 100644 index 0000000000000000000000000000000000000000..8b183c06a0f476e6e58c99af2b4266f78f03db3b Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285647778.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285658392.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285658392.png new file mode 100644 index 0000000000000000000000000000000000000000..1c3fd17aa457fa946feb8896f260e63b1bf7c546 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285658392.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285806330.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285806330.png new file mode 100644 index 0000000000000000000000000000000000000000..5e8e45b85dbbda22db008150b798f0c984394642 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285806330.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285965546.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285965546.png new file mode 100644 index 0000000000000000000000000000000000000000..f07b21dbc89b6722f6374a8bde9bdc893798f120 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285965546.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285965778.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285965778.png new file mode 100644 index 0000000000000000000000000000000000000000..6aa63a6876293a994ffe1cc90f6973a949e9e43a Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001285965778.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221356692.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531806.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221356692.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531806.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227277128.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531862.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227277128.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531862.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292849062.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292849062.png new file mode 100644 index 0000000000000000000000000000000000000000..d430a7534a65f96de3f90fc37e279ba116fdf43c Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292849062.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227757036.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001296270098.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227757036.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001296270098.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922318.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001305463846.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922318.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001305463846.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221172711.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307160958.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221172711.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307160958.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222361042.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307162054.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222361042.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307162054.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307320918.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307320918.png new file mode 100644 index 0000000000000000000000000000000000000000..a26e00b26ee901ab8d2c592b7b51ca173589427e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307320918.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307480750.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307480750.png new file mode 100644 index 0000000000000000000000000000000000000000..faa03a87ca4210e264ff09b85ec3dfc626d9d0df Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307480750.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307480754.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307480754.png new file mode 100644 index 0000000000000000000000000000000000000000..6eaa0217fb9bdb2d6dde4e13640a5fc3f3f2924a Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307480754.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001325269477.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001325269477.png new file mode 100644 index 0000000000000000000000000000000000000000..d1992b49a9805cd0823c98c2d6f1500a10c5f249 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001325269477.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001114129427.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326201857.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001114129427.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326201857.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001266887264.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326234609.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001266887264.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326234609.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001270076961.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326386753.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001270076961.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326386753.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261315939.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326512673.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261315939.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326512673.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194984912.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001327549705.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194984912.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001327549705.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001327669509.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001327669509.png new file mode 100644 index 0000000000000000000000000000000000000000..1fef79a0d9ab7d7862be1e108ae947cec5eb16d2 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001327669509.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001330777737.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001330777737.png new file mode 100644 index 0000000000000000000000000000000000000000..1fef79a0d9ab7d7862be1e108ae947cec5eb16d2 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001330777737.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221025048.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333256741.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221025048.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333256741.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216440138.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333322693.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216440138.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333322693.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265945173.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333581089.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265945173.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333581089.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001225760456.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338012765.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001225760456.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338012765.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338102621.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338102621.png new file mode 100644 index 0000000000000000000000000000000000000000..c7d4b3f3adb48546bba7d2a6886d159368370501 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338102621.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338187673.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338187673.png new file mode 100644 index 0000000000000000000000000000000000000000..ff80afa57efa440724111403e2c941bc1ed1e62a Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338187673.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198722374.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338201457.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198722374.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338201457.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338536201.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338536201.png new file mode 100644 index 0000000000000000000000000000000000000000..5cdc2d808a177b729e12d76d3ff63b01f892240b Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338536201.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177478136.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338622229.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177478136.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338622229.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194504874.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338663697.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194504874.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338663697.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001340557741.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001340557741.png new file mode 100644 index 0000000000000000000000000000000000000000..62a1301f0ec1679b5211cd7582702a1bbde2a105 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001340557741.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001243704061.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001345770181.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001243704061.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001345770181.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265676877.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001349388493.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265676877.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001349388493.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360080305.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360080305.png new file mode 100644 index 0000000000000000000000000000000000000000..c98fb2a07b27a0b36913a3a5c913f96cfc6a39d5 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360080305.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354693.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360320977.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354693.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360320977.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360439881.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360439881.png new file mode 100644 index 0000000000000000000000000000000000000000..ab85672164a7efca486295641c5ec15e40eda432 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360439881.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221012768.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001366345198.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221012768.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001366345198.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265665157.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001405938781.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265665157.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001405938781.png diff --git a/zh-cn/device-dev/quick-start/quickstart-appendix-compiledform.md b/zh-cn/device-dev/quick-start/quickstart-appendix-compiledform.md new file mode 100644 index 0000000000000000000000000000000000000000..6a9d6c7acef2d768dc41c0533f00b3da6b83f4e8 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-appendix-compiledform.md @@ -0,0 +1,45 @@ +# 编译形态整体说明 + + +在编译过程中,需要根据实际需求选择不同的编译形态。单击下表中的链接可获取具体产品配置,从而了解其中差异。 + + + **表1** 编译构建支持的产品列表 + +| **编译形态** | **开发板** | **主芯片** | **内核** | **系统类型** | +| -------- | -------- | -------- | -------- | -------- | +| [neptune100](https://gitee.com/openharmony/vendor_hihope/blob/master/neptune_iotlink_demo/config.json) | neptune100 | winnermicro | liteos_m | mini | +| [rk3568](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/config.json) | rk3568 | rockchip | linux | standard | +| [rk3568_mini_system](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568_mini_system/config.json) | rk3568 | rockchip | linux | standard | +| [bearpi_hm_micro](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_micro/config.json) | bearpi_hm_micro | stm32mp1xx | liteos_a | small | +| [bearpi_hm_nano](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_nano/config.json) | bearpi_hm_nano | hi3861v100 | liteos_m | mini | +| [wifiiot_hispark_pegasus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus/config.json) | hispark_pegasus | hi3861v100 | liteos_m | mini | +| [ipcamera_hispark_aries](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_aries/config.json) | hispark_aries | hi3518ev300 | liteos_a | small | +| [ipcamera_hispark_taurus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus/config.json) | hispark_taurus | hi3516dv300 | liteos_a | small | +| [ipcamera_hispark_taurus_linux](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_linux/config.json) | hispark_taurus | hi3516dv300 | linux | small | +| [hispark_taurus_standard](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_standard/config.json) | hispark_taurus | hi3516dv300 | linux | standard | +| [watchos](https://gitee.com/openharmony/vendor_hisilicon/blob/master/watchos/config.json) | hispark_taurus | hi3516dv300 | linux | standard | +| [hispark_phoenix](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_phoenix/config.json) | hispark_phoenix | hi3751v350 | linux | standard | +| [hispark_taurus_mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_mini_system/config.json) | hispark_taurus | hi3516dv300 | liteos_a | mini | +| [hispark_pegasus_mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus_mini_system/config.json) | hispark_pegasus | hi3861v100 | liteos_m | mini | +| [gr5515_sk_iotlink_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_iotlink_demo/config.json) | gr5515_sk | gr551x | liteos_m | mini | +| [gr5515_sk_xts_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_xts_demo/config.json) | gr5515_sk | gr551x | liteos_m | mini | +| [wifi_demo](https://gitee.com/openharmony/vendor_asrmicro/blob/master/wifi_demo/config.json) | dev_wifi_a | asr582x | liteos_m | mini | +| [xts_demo](https://gitee.com/openharmony/vendor_asrmicro/blob/master/xts_demo/config.json) | dev_wifi_a | asr582x | liteos_m | mini | +| [display_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/display_demo/config.json) | v200zr | bes2600 | liteos_m | mini | +| [xts_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/xts_demo/config.json) | v200zr | bes2600 | liteos_m | mini | +| [iotlink_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/iotlink_demo/config.json) | v200zr | bes2600 | liteos_m | mini | +| [mini_distributed_music_player](https://gitee.com/openharmony/vendor_bestechnic/blob/master/mini_distributed_music_player/config.json) | v200zr | bes2600 | liteos_m | mini | +| [niobe407](https://gitee.com/openharmony/vendor_talkweb/blob/master/niobe407/config.json) | niobe407 | stm32f4xx | liteos_m | mini | +| [qemu_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_mini_system_demo/config.json) | arm_mps2_an386 | qemu | liteos_m | mini | +| [qemu_csky_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_csky_mini_system_demo/config.json) | SmartL_E802 | qemu | liteos_m | mini | +| [qemu_cm55_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_cm55_mini_system_demo/config.json) | arm_mps3_an547 | qemu | liteos_m | mini | +| [qemu_xtensa_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_xtensa_mini_system_demo/config.json) | esp32 | qemu | liteos_m | mini | +| [qemu_riscv_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_riscv32_mini_system_demo/config.json) | ricsv32_virt | qemu | liteos_m | mini | +| [qemu_ca7_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_ca7_mini_system_demo/config.json) | arm_virt | qemu | liteos_a | small | +| [qemu_small_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_small_system_demo/config.json) | arm_virt | qemu | liteos_a | small | +| [qemu_arm_linux_min](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_min/config.json) | qemu-arm-linux | qemu | linux | standard | +| [qemu_arm_linux_headless](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_headless/config.json) | qemu-arm-linux | qemu | linux | standard | +| [iotlink_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/iotlink_demo/config.json) | cst85_wblink | chipsea | liteos_m | mini | +| [dsoftbus_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/dsoftbus_demo/config.json) | cst85_wblink | chipsea | liteos_m | mini | +| [xts_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/xts_demo/config.json) | cst85_wblink | chipsea | liteos_m | mini | diff --git a/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-ide.md b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-ide.md new file mode 100644 index 0000000000000000000000000000000000000000..de97f5472490b9078fc78b4868b679e567d4f9ab --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-ide.md @@ -0,0 +1,334 @@ +# Hi3516标准系统入门(IDE方式) + + +除小型系统外,Hi3516DV300开发板还支持标准系统。此章节简要介绍如何使用IDE在Hi3516DV300开发板上进行标准系统的开发。 + + +下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 + + +在进行开发之前,请完成如下准备工作: + + +- [搭建开发环境](quickstart-ide-env--win.md) + +- [创建工程并获取源码](quickstart-ide-import-project.md) + + +## 编写“Hello World”程序 + + +### 示例目录 + + +``` +applications/sample/hello + │── BUILD.gn + │── include + │ └── helloworld.h + │── src + │ └── helloworld.c + ├── bundle.json + build + └── subsystem_config.json + productdefine/common + └── products + └── Hi3516DV300.json +``` + + +### 开发步骤 + +请在源码目录中通过以下步骤创建“Hello World”应用程序: + +1. 创建目录,编写业务代码。 + 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 + + + ``` + #include + #include "helloworld.h" + int main(int argc, char **argv) + { + HelloPrint(); + return 0; + } + void HelloPrint() + { + printf("\n\n"); + printf("\n\t\tHello World!\n"); + printf("\n\n"); + } + ``` + + 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。 + + + ``` + #ifndef HELLOWORLD_H + #define HELLOWORLD_H + #ifdef __cplusplus + #if __cplusplus + extern "C" { + #endif + #endif + void HelloPrint(); + #ifdef __cplusplus + #if __cplusplus + } + #endif + #endif + #endif // HELLOWORLD_H + ``` + +2. 新建编译组织文件。 + 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示: + + ``` + import("//build/ohos.gni") # 导入编译模板 + ohos_executable("helloworld") { # 可执行模块 + sources = [ # 模块源码 + "src/helloworld.c" + ] + include_dirs = [ # 模块依赖头文件目录 + "include" + ] + cflags = [] + cflags_c = [] + cflags_cc = [] + ldflags = [] + configs = [] + deps =[] # 部件内部依赖 + part_name = "hello" # 所属部件名称,必选 + install_enable = true # 是否默认安装(缺省默认不安装),可选 + } + ``` + 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。 + + ``` + { + "name": "@ohos/hello", + "description": "Hello world example.", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "applications/sample/hello" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "hello", + "subsystem": "sample", + "syscap": [], + "features": [], + "adapted_system_type": [ "mini", "small", "standard" ], + "rom": "10KB", + "ram": "10KB", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [ + "//applications/sample/hello:helloworld" + ], + "inner_kits": [], + "test": [] + } + } + } + ``` + + bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。 + +3. 修改子系统配置文件。 + 在build/subsystem_config.json中添加新建的子系统的配置。 + + + ``` + "sample": { + "path": "applications/sample/hello", + "name": "sample" + }, + ``` + +4. 修改产品配置文件。 + 在productdefine/common/products/Hi3516DV300.json中添加对应的hello部件,直接添加到原有部件后即可。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 本章节操作是以OpenHarmony-v3.1-Release版本为例进行操作的,该版本中,Hi3516的配置文件为productdefine/common/products/Hi3516DV300.json;若源码版本大于OpenHarmony-v3.1-Release时,Hi3516的配置文件为vendor/hisilicon/Hi3516DV300/config.json。 + + + ``` + "usb:usb_manager_native":{}, + "applications:prebuilt_hap":{}, + "sample:hello":{}, + "wpa_supplicant-2.9:wpa_supplicant-2.9":{}, + ``` + + +## 编译 + +DevEco Device Tool支持Hi3516DV300开发板的源码一键编译功能,提供编译工具链和编译环境依赖的检测及一键安装,简化复杂编译环境的同时,提升了编译的效率。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> Hi3516DV300编译环境为Ubuntu环境。 + +1. 在菜单栏中点击**Project Settings**,进入Hi3516DV300工程配置界面。 + + ![zh-cn_image_0000001274745038](figures/zh-cn_image_0000001274745038.png) + +2. 在**Tool Chain**页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**Install**,自动安装所需工具链。 + + ![zh-cn_image_0000001292531862](figures/zh-cn_image_0000001292531862.png) + +3. 安装Hi3516DV300相关工具链,部分工具安装需要使用root权限,请在**TERMINAL**窗口输入用户密码进行安装。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + + ![zh-cn_image_0000001274748606](figures/zh-cn_image_0000001274748606.png) + + 工具链自动安装完成后如下图所示。 + + ![zh-cn_image_0000001296270098](figures/zh-cn_image_0000001296270098.png) + +4. 在**hi3516dv300**配置页签中,设置源码的编译类型**build_type**,默认为“debug”类型,请根据需要进行修改。修改完成后,点击**Save**进行保存。 + + ![zh-cn_image_0000001325269477](figures/zh-cn_image_0000001325269477.png) + +5. 在**PROJECT TASKS**中,点击对应开发板下的**Build**,执行编译。 + + ![zh-cn_image_0000001292849062](figures/zh-cn_image_0000001292849062.png) + +6. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 + + ![zh-cn_image_0000001366345198](figures/zh-cn_image_0000001366345198.png) + + 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的烧录操作。 + + +## 烧录 + +烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 + +Hi3516DV300的镜像烧录通过Windows环境进行烧录,开发者启动烧录操作后,DevEco Device Tool通过Remote远程模式,将Ubuntu环境下编译生成的待烧录程序文件拷贝至Windows目录下,然后通过Windows的烧录工具将程序文件烧录至开发板中。 + +Hi3516DV300开发板标准系统的烧录方式包括USB烧录、网口烧录两种方式,本文采用USB方式进行烧录。 + + +### 前提条件 + +- 请安装Hi3516DV300开发板串口驱动程序,请参考[Hi3516DV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)。 + +- 请安装Hi3516DV300开发板USB驱动程序,请参考[Hi3516DV300开发板USB驱动安装](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)。 + + +### 操作步骤 + +1. 请连接好电脑和待烧录开发板,需要连接USB口和串口,具体可参考[Hi3516开发板介绍](quickstart-appendix-hi3516.md)。 + +2. 在DevEco Device Tool中,选择**REMOTE DEVELOPMENT > Local PC**,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001326512673](figures/zh-cn_image_0000001326512673.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001275432904](figures/zh-cn_image_0000001275432904.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 + + ![zh-cn_image_0000001285658392](figures/zh-cn_image_0000001285658392.png) + +3. 在菜单栏中点击**Project Settings**按钮,进入Hi3516DV300工程配置界面。 + + ![zh-cn_image_0000001275752808](figures/zh-cn_image_0000001275752808.png) + +4. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 + + ![Phoenix-upload](figures/Phoenix-upload.png) + +5. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions_profile、upload_port和upload_protocol。 + - upload_partitions_profile:选择待烧录程序的配置文件(已预置默认的配置文件),该配置文件会指定烧录文件名称、起始烧录地址、地址长度等信息;同时请勾选**Enable to use upload_partitions_profile for upload**选项。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如需修改烧录profile文件,在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 + > + > 首次烧录,请勾选**Enable to use upload_partitions_profile for upload**选项,会自动生成upload_partitions文件。再次烧录时,可根据实际情况选择生成upload_partitions文件进行自定义烧录,也可以再勾选**Enable to use upload_partitions_profile for upload**选项,使用upload_partitions_profile重新生成upload_partitions文件用于烧录。 + - upload_protocol:选择烧录协议,固定选择“hiburn-usb”。 + - upload_port:选择已查询到的串口号。 + + ![zh-cn_image_0000001338622229](figures/zh-cn_image_0000001338622229.png) + +6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +7. 点击hi3516dv300下的**Upload**按钮。 + + ![zh-cn_image_0000001276281922](figures/zh-cn_image_0000001276281922.png) + + 此时待烧录文件会从Ubuntu系统传输到Windows下,传输完成后界面显示“Operation paused, Please press Enter key to continue”时,请点击**Enter**键启动烧录。 + + ![zh-cn_image_0000001326201857](figures/zh-cn_image_0000001326201857.png) + +8. 在终端窗口显示如下提示信息时,请在15秒内,按住Update键,插拔USB线,最后松开Update键启动烧录。 + + ![zh-cn_image_0000001276122010](figures/zh-cn_image_0000001276122010.png) + + 启动烧录后,界面提示**SUCCESS**信息时,表示烧录成功。 + + ![zh-cn_image_0000001275802150](figures/zh-cn_image_0000001275802150.png) + +9. 烧录成功后,请根据运行章节进行操作,启动系统。 + + +## 运行 + + +### 启动系统 + +烧录完成后通过以下步骤启动系统: + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 初次烧写标准系统,需要完成以下配置,后续烧写或者启动,可以跳过以下操作。 + +1. 在DevEco Device Tool中,点击Monitor,打开串口工具。 + + ![quickstart-appendix-hi3516-ide-run](figures/quickstart-appendix-hi3516-ide-run.png) + +2. 重启开发板,在倒计时结束前,按任意键进入系统。 + + ![press-any-key-to-enter-the-system](figures/press-any-key-to-enter-the-system.gif) + +3. 通过以下两条命令设置启动参数。 + + ``` + setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)'; + ``` + + + ``` + setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000' + ``` + + ![setenv-bootargs](figures/setenv-bootargs.png) + +4. 保存参数设置。 + + ``` + save + ``` + + ![Save the parameter settings](figures/quickstart-appendix-hi3516-ide-run-set.png) + +5. 重启开发板,完成系统启动。 + + ``` + reset + ``` + + ![start the system](figures/quickstart-appendix-hi3516-ide-run-start.png) + + +### 运行“Hello World” + +设备启动后打开串口工具,在任意目录下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 + +![helloworld](figures/helloworld.png) + + +### 下一步 + +恭喜!您已经完成了标准系统的快速入门,接下来可[开发一个小示例](../guide/device-clock-guide.md),进一步熟悉OpenHarmony的开发。 diff --git a/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-pkg.md b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-pkg.md new file mode 100644 index 0000000000000000000000000000000000000000..838d824279bd88f0c3e33a1284dba93a3a18c74e --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-pkg.md @@ -0,0 +1,310 @@ +# Hi3516标准系统入门(命令行方式) + + +除小型系统外,Hi3516DV300开发板还支持标准系统。此章节简要介绍如何使用命令行在Hi3516DV300开发板上进行标准系统的开发。 + + +下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 + + +在进行开发之前,请首先完成[搭建开发环境](quickstart-pkg-prepare.md)。 + + +## 编写“Hello World”程序 + + +### 示例目录 + + +``` +applications/sample/hello + │── BUILD.gn + │── include + │ └── helloworld.h + │── src + │ └── helloworld.c + ├── bundle.json + build + └── subsystem_config.json + vendor/hisilicon + └── Hi3516DV300 + └── config.json +``` + + +### 开发步骤 + +请在源码目录中通过以下步骤创建“Hello World”应用程序: + +1. 创建目录,编写业务代码。 + 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 + + + ``` + #include + #include "helloworld.h" + int main(int argc, char **argv) + { + HelloPrint(); + return 0; + } + void HelloPrint() + { + printf("\n\n"); + printf("\n\t\tHello World!\n"); + printf("\n\n"); + } + ``` + + 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。 + + + ``` + #ifndef HELLOWORLD_H + #define HELLOWORLD_H + #ifdef __cplusplus + #if __cplusplus + extern "C" { + #endif + #endif + void HelloPrint(); + #ifdef __cplusplus + #if __cplusplus + } + #endif + #endif + #endif // HELLOWORLD_H + ``` + +2. 新建编译组织文件。 + 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示: + + ``` + import("//build/ohos.gni") # 导入编译模板 + ohos_executable("helloworld") { # 可执行模块 + sources = [ # 模块源码 + "src/helloworld.c" + ] + include_dirs = [ # 模块依赖头文件目录 + "include" + ] + cflags = [] + cflags_c = [] + cflags_cc = [] + ldflags = [] + configs = [] + deps =[] # 部件内部依赖 + part_name = "hello" # 所属部件名称,必选 + install_enable = true # 是否默认安装(缺省默认不安装),可选 + } + ``` + 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。 + + ``` + { + "name": "@ohos/hello", + "description": "Hello world example.", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "applications/sample/hello" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "hello", + "subsystem": "sample", + "syscap": [], + "features": [], + "adapted_system_type": [ "mini", "small", "standard" ], + "rom": "10KB", + "ram": "10KB", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [ + "//applications/sample/hello:helloworld" + ], + "inner_kits": [], + "test": [] + } + } + } + ``` + + bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。 + +3. 修改子系统配置文件。 + 在build/subsystem_config.json中添加新建的子系统的配置。 + + + ``` + "sample": { + "path": "applications/sample/hello", + "name": "sample" + }, + ``` + +4. 修改产品配置文件。 + 在vendor/hisilicon/Hi3516DV300/config.json中添加对应的hello部件,直接添加到原有部件后即可。 + + + ``` + "usb:usb_manager_native":{}, + "applications:prebuilt_hap":{}, + "sample:hello":{}, + "wpa_supplicant-2.9:wpa_supplicant-2.9":{}, + ``` + + +## 编译 + +OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](quickstart-pkg-common-build.md#使用buildsh脚本编译源码)。 + +想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建指南](../subsystems/subsys-build-all.md)。 + + +### 前提条件 + +- 已正确[安装库和工具集](quickstart-pkg-install_package.md)。 + +- 已正确[安装编译工具](quickstart-pkg-install_tool.md)。 + +- “Hello World”程序已编写完成。 + +- 可正常登录Ubuntu环境。 + + +### 操作步骤 + +请进入源码根目录,执行如下命令进行编译: + +1. 设置编译路径。 + + ``` + hb set + ``` + +2. 选择当前路径。 + + ``` + . + ``` + +3. 在hisilicon下选择hispark_taurus_standard并回车。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > + > 同样的开发板在适配不同的场景时,要采用的编译形态不同(即此处要选择的product不同),请参考[编译形态整体说明](quickstart-appendix-compiledform.md)。 + + **图1** Hi3516编译设置图例   + + ![quick-start-hi3516-standard-build](figures/quick-start-hi3516-standard-build.png) + +4. 执行编译。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > - 单独编译一个部件(例如hello),可使用“hb build -T _目标名称_”进行编译。 + > + > - 增量编译整个产品,可使用“hb build”进行编译。 + > + > - 完整编译整个产品,可使用“hb build -f”进行编译。 + > + > 此处以完整编译整个产品为例进行说明。 + + + ``` + hb build -f + ``` + +5. 编译结束后,出现“build success”字样,则证明构建成功。 + > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** + > 编译结果文件及编译日志文件获取路径:out/hi3516dv300。 + + +## 烧录 + +针对Hi3516DV300开发板,除了DevEco Device Tool(操作方法请参考[烧录](quickstart-appendix-hi3516-ide.md#烧录))外,还可以使用HiTool进行烧录。 + + +### 前提条件 + +- 开发板相关源码已编译完成,已形成烧录文件。 + +- 客户端(操作平台,例如Windows系统)已下载并安装[HiTool工具](http://www.hihope.org/download/download.aspx)。 + +- 客户端(操作平台,例如Windows系统)已安装USB驱动,可参考[Hi3516DV300开发板USB驱动安装指导](https://gitee.com/link?target=https%3A%2F%2Fdevice.harmonyos.com%2Fcn%2Fdocs%2Fdocumentation%2Fguide%2Fusb_driver-0000001058690393)。 + +- 客户端已安装串口终端工具(例如IPOP)。 + +- 使用USB线缆、串口线缆连接客户端与开发板。 + + +### 操作步骤 + +1. 准备烧录相关文件。 + 1. 在客户端新建用于保存烧录文件的文件夹,例如D:\L2。 + 2. 将编译完成的源码包下载至客户端并解压,将烧录相关文件拷贝至步骤1中新建的文件夹。 + + Hi3516DV300开发板烧写所需文件为:boot.img、Hi3516DV300-emmc.xml、system.img、u-boot-hi3516dv300_emmc.bin、uImage、updater.img、userdata.img、vendor.img。 + +2. 使用HiTool烧录。 + 1. 打开HiTool。 + 2. 设置HiTool参数。 + + 传输方式选择USB口,烧写方式选择烧写eMMC(单板的存储介质为eMMC)。 + 3. 单击浏览在步骤1创建的文件夹中选择烧写配置文件(例如Hi3516DV300-emmc.xml)。 + + ![quickstart-hi3516-standard-hitool-select](figures/quickstart-hi3516-standard-hitool-select.png) + 4. 单击烧写后,按住开发板上串口旁的按钮(Update键),并拔插USB线(上下电)。。 + + 烧录开始后,可以在HiTool工具下方的控制台区域观察到烧录过程中的打印信息。 + + 烧录完成后,HiTool弹出提示框显示烧写成功。 + 5. 单击确定。 + +3. 导入启动参数。 + 1. 使用终端工具打开串口。 + 2. 拔插开发板电源使其重启,3s内在串口终端输入回车。 + + 终端界面中出现hisilicon \#表示已连接开发板串口。 + 3. 在串口终端拷贝如下启动参数后,按回车完成配置。 + + ``` + setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused androidboot.selinux=permissive rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)';setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000' + + saveenv + + reset + ``` + + > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** + > 输入启动参数时,请勿自行删除其中的空行。 + + +## 运行 + +系统启动成功后,取源码out目录下的helloworld可执行文件放入系统的bin目录,通过以下步骤运行“Hello World”。 + + +### 操作步骤 + +1. 在启动界面进入bin目录。 + + ``` + cd bin + ``` + +2. 进入bin目录后可以看到helloworld文件,通过以下命令运行helloworld程序。 + + ``` + ./helloworld + ``` + + 界面打印“Hello World!”,程序运行成功。 + + +### 下一步学习 + +恭喜!您已经完成了标准系统的快速入门,接下来可[开发一个小示例](../guide/device-clock-guide.md),进一步熟悉OpenHarmony的开发。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516.md similarity index 95% rename from zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md rename to zh-cn/device-dev/quick-start/quickstart-appendix-hi3516.md index a43dbaf8b6b3035f0195a28b098f4cd9b0d3c63a..1f56afc1af080d41f646129e58634742205266d3 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md +++ b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516.md @@ -7,7 +7,7 @@ Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代I **图1** Hi3516单板正面外观图   -![zh-cn_image_0000001271234773](figures/zh-cn_image_0000001271234773.png) +![zh-cn_image_0000001305463846](figures/zh-cn_image_0000001305463846.png) ## 开发板规格 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3861.md b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3861.md similarity index 83% rename from zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3861.md rename to zh-cn/device-dev/quick-start/quickstart-appendix-hi3861.md index ae64948ed8e076d7054cca45b3da1bf3afe5cb93..349fc1f2f967e0920e66c4c66076b177ab510f28 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3861.md +++ b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3861.md @@ -3,17 +3,17 @@ ## 简介 -Hi3861开发板是一片大约2cm\*5cm大小的开发板,是一款高度集成的2.4GHz WLAN SoC芯片,集成IEEE 802.11b/g/n基带和RF(Radio Frequency)电路。支持OpenHarmony,并配套提供开放、易用的开发和调试运行环境。 +Hi3861开发板是一片大约2cm\*5cm大小的开发板,是一款高度集成的2.4GHz WLAN SoC芯片,集成IEEE 802.11b/g/n基带和RF(Radio Frequency)电路。支持,并配套提供开放、易用的开发和调试运行环境。 **图1** Hi3861开发板外观图   -![zh-cn_image_0000001226634692](figures/zh-cn_image_0000001226634692.png) +![hi3861-front](figures/hi3861-front.png) 另外,Hi3861开发板还可以通过与Hi3861底板连接,扩充自身的外设能力,底板如下图所示。 **图2** Hi3861底板外观图   -![zh-cn_image_0000001226794660](figures/zh-cn_image_0000001226794660.png) +![hi3861-rear](figures/hi3861-rear.png) - RF电路包括功率放大器PA(Power Amplifier)、低噪声放大器LNA(Low Noise Amplifier)、RF Balun、天线开关以及电源管理等模块;支持20MHz标准带宽和5MHz/10MHz窄带宽,提供最大72.2Mbit/s物理层速率。 @@ -25,7 +25,7 @@ Hi3861开发板是一片大约2cm\*5cm大小的开发板,是一款高度集成 **图3** Hi3861功能框图   -![zh-cn_image_0000001271234729](figures/zh-cn_image_0000001271234729.png) +![hi3861-function](figures/hi3861-function.png) ## 资源和约束 @@ -47,22 +47,22 @@ Hi3861开发板资源十分有限,整板共2MB FLASH,352KB RAM。在编写 | 其他信息 | - 封装:QFN-32,5mm×5mm
- 工作温度:-40℃ ~ +85℃ | -## OpenHarmony关键特性 +## 关键特性 -OpenHarmony基于Hi3861平台提供了多种开放能力,提供的关键组件如下表所示。 +基于Hi3861平台提供了多种开放能力,提供的关键组件如下表所示。 - **表2** OpenHarmony关键组件列表 + **表2** 关键组件列表 | 组件名 | 能力介绍 | | -------- | -------- | | WLAN服务 | 提供WLAN服务能力。包括:station和hotspot模式的连接、断开、状态查询等。 | | 模组外设控制 | 提供操作外设的能力。包括:I2C、I2S、ADC、UART、SPI、SDIO、GPIO、PWM、FLASH等。 | -| 分布式软总线 | 在OpenHarmony分布式网络中,提供设备被发现、数据传输的能力。 | +| 分布式软总线 | 在分布式网络中,提供设备被发现、数据传输的能力。 | | 设备安全绑定 | 提供在设备互联场景中,数据在设备之间的安全流转的能力。 | | 基础加解密 | 提供密钥管理、加解密等能力。 | -| 系统服务管理 | 系统服务管理基于面向服务的架构,提供了OpenHarmony统一化的系统服务开发框架。 | -| 启动引导 | 提供系统服务的启动入口标识。在系统服务管理启动时,调用bootstrap标识的入口函数,并启动系统服务。 | +| 系统服务管理 | 系统服务管理基于面向服务的架构,提供了统一化的系统服务开发框架。 | +| 启动引导 | 提供系统服务的启动入口标识。在系统服务管理启动时,调用boostrap标识的入口函数,并启动系统服务。 | | 系统属性 | 提供获取与设置系统属性的能力。 | | 基础库 | 提供公共基础库能力。包括:文件操作、KV存储管理等。 | | DFX | 提供DFX能力。包括:流水日志、时间打点等。 | -| XTS | 提供OpenHarmony生态认证测试套件的集合能力。 | +| XTS | 提供生态认证测试套件的集合能力。 | diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-rk3568.md b/zh-cn/device-dev/quick-start/quickstart-appendix-rk3568.md similarity index 93% rename from zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-rk3568.md rename to zh-cn/device-dev/quick-start/quickstart-appendix-rk3568.md index 05d773ad33b3fd23db4ba33de70f1c8769dceab9..ab9a1d713f248507c48e97763e6ff5a6a5e37b90 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-rk3568.md +++ b/zh-cn/device-dev/quick-start/quickstart-appendix-rk3568.md @@ -7,11 +7,11 @@ RK3568开发板基于Rockchip RK3568芯片,集成双核心架构GPU以及高 **图1** RK3568开发板正面   -![zh-cn_image_0000001271442129](figures/zh-cn_image_0000001271442129.png) +![rk3568-front](figures/rk3568-front.png) **图2** RK3568开发板背面   -![zh-cn_image_0000001271322293](figures/zh-cn_image_0000001271322293.png) +![rk3568-rear](figures/rk3568-rear.png) ## 开发板规格 diff --git a/zh-cn/device-dev/quick-start/quickstart-build.md b/zh-cn/device-dev/quick-start/quickstart-build.md deleted file mode 100644 index 4e2363163cbd3c5577fd3d245e29279dc042564c..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-build.md +++ /dev/null @@ -1,40 +0,0 @@ -# 编译形态整体说明 -**编译构建支持的产品列表** (点击链接可知道具体产品配置及其相关差异) - -| 编译形态 | 开发板 | 主芯片 | 内核 | 系统类型 | -| ----------------------------- | --------------- | ----------- | ----------- | ----------- | -| [neptune100](https://gitee.com/openharmony/vendor_hihope/blob/master/neptune_iotlink_demo/config.json) | neptune100 | winnermicro | liteos_m | mini | -| [rk3568](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/config.json) | rk3568 | rockchip | linux | standard | -| [rk3568_mini_system](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568_mini_system/config.json) | rk3568 | rockchip | linux | standard | -| [bearpi_hm_micro](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_micro/config.json) | bearpi_hm_micro | stm32mp1xx | liteos_a | small | -| [bearpi_hm_nano](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_nano/config.json) | bearpi_hm_nano | hi3861v100 | liteos_m | mini | -| [wifiiot_hispark_pegasus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus/config.json) | hispark_pegasus | hi3861v100 | liteos_m | mini | -| [ipcamera_hispark_aries](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_aries/config.json) | hispark_aries | hi3518ev300 | liteos_a | small | -| [ipcamera_hispark_taurus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus/config.json) | hispark_taurus | hi3516dv300 | liteos_a | small | -| [ipcamera_hispark_taurus_linux](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_linux/config.json) | hispark_taurus | hi3516dv300 | linux | small | -| [hispark_taurus_standard](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_standard/config.json) | hispark_taurus | hi3516dv300 | linux | standard | -| [watchos](https://gitee.com/openharmony/vendor_hisilicon/blob/master/watchos/config.json) | hispark_taurus | hi3516dv300 | linux | standard | -| [hispark_phoenix](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_phoenix/config.json) | hispark_phoenix | hi3751v350 | linux | standard | -| [hispark_taurus_mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_mini_system/config.json) | hispark_taurus | hi3516dv300 | liteos_a | mini | -| [hispark_pegasus_mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus_mini_system/config.json) | hispark_pegasus | hi3861v100 | liteos_m | mini | -| [gr5515_sk_iotlink_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_iotlink_demo/config.json) | gr5515_sk | gr551x | liteos_m | mini | -| [gr5515_sk_xts_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_xts_demo/config.json) | gr5515_sk | gr551x | liteos_m | mini | -| [wifi_demo](https://gitee.com/openharmony/vendor_asrmicro/blob/master/wifi_demo/config.json) | dev_wifi_a | asr582x | liteos_m | mini | -| [xts_demo](https://gitee.com/openharmony/vendor_asrmicro/blob/master/xts_demo/config.json) | dev_wifi_a | asr582x | liteos_m | mini | -| [display_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/display_demo/config.json) | v200zr | bes2600 | liteos_m | mini | -| [xts_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/xts_demo/config.json) | v200zr | bes2600 | liteos_m | mini | -| [iotlink_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/iotlink_demo/config.json) | v200zr | bes2600 | liteos_m | mini | -| [mini_distributed_music_player](https://gitee.com/openharmony/vendor_bestechnic/blob/master/mini_distributed_music_player/config.json) | v200zr | bes2600 | liteos_m | mini | -| [niobe407](https://gitee.com/openharmony/vendor_talkweb/blob/master/niobe407/config.json) | niobe407 | stm32f4xx | liteos_m | mini | -| [qemu_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_mini_system_demo/config.json) | arm_mps2_an386 | qemu | liteos_m | mini | -| [qemu_cksy_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_csky_mini_system_demo/config.json) | SmartL_E802 | qemu | liteos_m | mini | -| [qemu_cm55_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_cm55_mini_system_demo/config.json) | arm_mps3_an547 | qemu | liteos_m | mini | -| [qemu_xtensa_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_xtensa_mini_system_demo/config.json) | esp32 | qemu | liteos_m | mini | -| [qemu_riscv_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_riscv32_mini_system_demo/config.json) | ricsv32_virt | qemu | liteos_m | mini | -| [qemu_ca7_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_ca7_mini_system_demo/config.json) | arm_virt | qemu | liteos_a | small | -| [qemu_small_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_small_system_demo/config.json) | arm_virt | qemu | liteos_a | small | -| [qemu_arm_linux_min](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_min/config.json) | qemu-arm-linux | qemu | linux | standard | -| [qemu_arm_linux_headless](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_headless/config.json) | qemu-arm-linux | qemu | linux | standard | -| [iotlink_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/iotlink_demo/config.json) | cst85_wblink | chipsea | liteos_m | mini | -| [dsoftbus_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/dsoftbus_demo/config.json) | cst85_wblink | chipsea | liteos_m | mini | -| [xts_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/xts_demo/config.json) | cst85_wblink | chipsea | liteos_m | mini | diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3516-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-3516-build.md new file mode 100644 index 0000000000000000000000000000000000000000..58f0db0f1884e541ae936562633e125cbf460172 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3516-build.md @@ -0,0 +1,41 @@ +# 编译 + + +DevEco Device Tool支持Hi3516DV300开发板的源码一键编译功能,提供编译工具链和编译环境依赖的检测及一键安装,简化复杂编译环境的同时,提升了编译的效率。 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> Hi3516DV300编译环境为Ubuntu环境。 + + +1. 在菜单栏中点击**Project Settings**,进入Hi3516DV300工程配置界面。 + + ![zh-cn_image_0000001274745038](figures/zh-cn_image_0000001274745038.png) + +2. 在“Tool Chain”页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可单击**Install**,自动安装所需工具链。 + + ![zh-cn_image_0000001307480750](figures/zh-cn_image_0000001307480750.png) + +3. 安装Hi3516DV300相关工具链,部分工具安装需要使用root权限,请在“TERMINAL”窗口输入用户密码进行安装。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + + ![zh-cn_image_0000001360080305](figures/zh-cn_image_0000001360080305.png) + + 工具链自动安装完成后如下图所示。 + + ![zh-cn_image_0000001307320918](figures/zh-cn_image_0000001307320918.png) + +4. 在“hi3516dv300”配置页签中,设置源码的编译类型**build_type**,默认为“debug”类型,请根据需要进行修改。修改完成后,单击**Save**进行保存。 + + ![zh-cn_image_0000001307160958](figures/zh-cn_image_0000001307160958.png) + +5. 在“PROJECT TASKS”中,单击对应开发板下的**Build**,执行编译。 + + ![zh-cn_image_0000001360439881](figures/zh-cn_image_0000001360439881.png) + +6. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 + + ![zh-cn_image_0000001307480754](figures/zh-cn_image_0000001307480754.png) + + 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[Hi3516DV300开发板烧录](quickstart-ide-3516-burn.md)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3516-burn.md b/zh-cn/device-dev/quick-start/quickstart-ide-3516-burn.md new file mode 100644 index 0000000000000000000000000000000000000000..75eb1d896ca2158da0a636055841bdd8f7d5dbb4 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3516-burn.md @@ -0,0 +1,70 @@ +# 烧录 + + +烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 + + +Hi3516DV300的镜像烧录通过Windows环境进行烧录,开发者启动烧录操作后,DevEco Device Tool通过Remote远程模式,将Ubuntu环境下编译生成的待烧录程序文件拷贝至Windows目录下,然后通过Windows的烧录工具将程序文件烧录至开发板中。 + + +Hi3516DV300开发板小型系统的烧录方式包括USB烧录、网口烧录两种方式,本文采用USB方式进行烧录。 + + +## 前提条件 + +- 代码已[编译](quickstart-ide-3516-build.md)完成。 + +- 请安装Hi3516DV300开发板串口驱动程序,请参考[Hi3516DV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)。 + +- 请安装Hi3516DV300开发板USB驱动程序,请参考[Hi3516DV300开发板USB驱动安装](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)。 + + +## 操作步骤 + +1. 请连接好电脑和待烧录开发板,需要连接USB口和串口,具体可参考[Hi3516DV300开发板介绍](quickstart-appendix-hi3516.md)。 + +2. 在DevEco Device Tool中,选择**REMOTE DEVELOPMENT > Local PC**,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001326512673](figures/zh-cn_image_0000001326512673.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001275432904](figures/zh-cn_image_0000001275432904.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 + + ![zh-cn_image_0000001285658392](figures/zh-cn_image_0000001285658392.png) + +3. 在菜单栏中点击**Project Settings**按钮,进入Hi3516DV300工程配置界面。 + + ![zh-cn_image_0000001275752808](figures/zh-cn_image_0000001275752808.png) + +4. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 + + ![Phoenix-upload](figures/Phoenix-upload.png) + +5. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 + - upload_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。DevEco Device Tool已预置默认的烧录文件信息,包括起始地址、分区大小、待烧录文件地址等,开发者可根据实际情况进行调整,点击每个待烧录文件后的![zh-cn_image_0000001275592884](figures/zh-cn_image_0000001275592884.png)按钮进行修改。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 + + ![3516-small-partitions](figures/3516-small-partitions.png) + + - upload_protocol:选择烧录协议,固定选择“hiburn-usb”。 + - upload_port:选择已查询到的串口号。 + + ![3516-small-usb](figures/3516-small-usb.png) + +6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +7. 点击hi3516dv300下的**Upload**按钮。 + + ![zh-cn_image_0000001326234609](figures/zh-cn_image_0000001326234609.png) + + 此时待烧录文件会从Ubuntu系统传输到Windows下,传输完成后界面显示“Operation paused, Please press Enter key to continue”时,请点击**Enter**键启动烧录。 + + ![zh-cn_image_0000001275835836](figures/zh-cn_image_0000001275835836.png) + +8. 在终端窗口显示如下提示信息时,请在15秒内,按住Update键,插拔USB线,最后松开Update键启动烧录。 + + ![zh-cn_image_0000001326412233](figures/zh-cn_image_0000001326412233.png) + + 启动烧录后,界面提示**SUCCESS**信息时,表示烧录成功。 + + ![zh-cn_image_0000001276317464](figures/zh-cn_image_0000001276317464.png) + +9. 烧录成功后,请根据运行章节进行操作,启动系统。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md b/zh-cn/device-dev/quick-start/quickstart-ide-3516-helloworld.md similarity index 67% rename from zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md rename to zh-cn/device-dev/quick-start/quickstart-ide-3516-helloworld.md index a8273bfc8b33dfdb950434eef48c0f2f3c1121af..7096ec89d43fdb9a655f752812a16fe506215cbb 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3516-helloworld.md @@ -4,12 +4,17 @@ 下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 +## 前提条件 + +已参考[创建工程并获取源码](quickstart-ide-import-project.md),创建Hi3516开发板的源码工程。 + + ## 示例目录 示例完整目录如下: - + ``` applications/sample/hello │── BUILD.gn @@ -20,13 +25,13 @@ applications/sample/hello ## 开发步骤 -请在源码目录中通过以下步骤创建“Hello World”应用程序: +请在源码目录中通过以下步骤创建“Hello World”应用程序。 1. 新建目录及源码。 + + 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改OHOS为World)。当前应用程序可支持标准C及C++的代码开发。 - 新建**applications/sample/hello/src/helloworld.c**目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改OHOS为World)。当前应用程序可支持标准C及C++的代码开发。 - - + ``` #include @@ -41,10 +46,10 @@ applications/sample/hello ``` 2. 新建编译组织文件。 + + 新建applications/sample/hello/BUILD.gn文件,内容如下所示: - 新建**applications/sample/hello/BUILD.gn**文件,内容如下所示: - - + ``` import("//build/lite/config/component/lite_component.gni") lite_component("hello-OHOS") { @@ -57,10 +62,13 @@ applications/sample/hello ``` 3. 添加新组件。 + + 修改文件build/lite/components/applications.json,添加组件hello_world_app的配置,如下所示为**applications.json**文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - 修改文件**build/lite/components/communication.json**,添加组件hello_world_app的配置,如下所示为communication.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 本章节操作是以OpenHarmony-v3.1-Release版本为例进行操作的,该版本中,组件配置文件为build/lite/components/applications.json;若源码版本大于等于OpenHarmony 3.2 Beta2时,组件配置文件为build/lite/components/communication.json。 - + ``` { "components": [ @@ -120,10 +128,10 @@ applications/sample/hello ``` 4. 修改单板配置文件。 + + 修改文件vendor/hisilicon/hispark_taurus/config.json,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - 修改文件**vendor/hisilicon/hispark_taurus/config.json**,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - - + ``` { "subsystem": "applications", diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-3516-running.md similarity index 55% rename from zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-running.md rename to zh-cn/device-dev/quick-start/quickstart-ide-3516-running.md index f6dab623d690f2f62b8888c36fbe1ff441698024..de3a6b16bbd43a75f31f6688cf742ac5e28f8185 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-running.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3516-running.md @@ -5,23 +5,23 @@ 在完成Hi3516DV300的烧录后,还需要设置BootLoader引导程序,才能运行OpenHarmony系统。 -1. 在Hi3516DV300任务中,点击Configure bootloader(Boot OS)进行配置即可。 +1. 在Hi3516DV300任务中,单击Configure bootloader(Boot OS)进行配置即可。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > DevEco Device Tool针对Hi3516DV300开发板的BootLoader设置进行了适配,无需开发者手动修改。 - ![zh-cn_image_0000001226794644](figures/zh-cn_image_0000001226794644.png) + ![bootloader](figures/bootloader.png) 2. 提示如下图中的重启开发板的提示信息时,重启开发板,然后在控制台输出“SUCCESS”表示设置成功。 - ![zh-cn_image_0000001227114584](figures/zh-cn_image_0000001227114584.png) + ![reset_success](figures/reset_success.png) -3. 在任务栏点击**Monitor**按钮,启动串口工具。 +3. 在任务栏单击**Monitor**按钮,启动串口工具。 - ![zh-cn_image_0000001271234705](figures/zh-cn_image_0000001271234705.png) + ![monitor](figures/monitor.png) -4. 当界面打印回显信息,点击Enter按钮,直到界面显示OHOS \#信息,表示系统启动成功。 +4. 当界面打印回显信息,单击Enter按钮,直到界面显示OHOS \#信息,表示系统启动成功。 - ![zh-cn_image_0000001271594709](figures/zh-cn_image_0000001271594709.png) + ![reboot-success](figures/reboot-success.png) ## 运行“Hello World” @@ -29,22 +29,26 @@ 系统启动成功后,通过以下步骤运行“Hello World”。 1. 在启动界面进入bin目录。 - + ``` cd bin ``` 2. 进入bin目录后可以看到helloworld文件,通过以下命令运行helloworld程序。 - + ``` ./helloworld ``` 界面打印“Hello World!”,程序运行成功。 - ![zh-cn_image_0000001271354693](figures/zh-cn_image_0000001271354693.png) + ![zh-cn_image_0000001360320977](figures/zh-cn_image_0000001360320977.png) ## 下一步学习 -恭喜您,已完成Hi3516的快速上手!建议您下一步进入[带屏摄像头类产品开发](../guide/device-camera-control-overview.md)的学习 。 +恭喜您,已完成Hi3516的快速上手!建议您进行下一步学习 。可参考: + +- [屏幕和摄像头控制](../guide/device-camera-control-overview.md) + +- [视觉应用开发](../guide/device-camera-visual-overview.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3568-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-3568-build.md new file mode 100644 index 0000000000000000000000000000000000000000..923fe7bbaf0ee4ebcd696de0e14a21cc020fe7d1 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3568-build.md @@ -0,0 +1,41 @@ +# 编译 + + +DevEco Device Tool支持Rockchip RK3568开发板的源码一键编译功能,提供编译工具链和编译环境依赖的检测及一键安装,简化复杂编译环境的同时,提升了编译的效率。 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> RK3568编译环境为Ubuntu环境。 + + +1. 在菜单栏中点击**Project Settings**,进入RK3568工程配置界面。 + + ![zh-cn_image_0000001327669509](figures/zh-cn_image_0000001327669509.png) + +2. 在**Tool Chain**页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**Install**,自动安装所需工具链。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + + ![zh-cn_image_0000001292531806](figures/zh-cn_image_0000001292531806.png) + + 安装RK3568相关工具链,部分工具的安装需要使用root权限,请在**TERMINAL**窗口输入用户密码进行安装。 + + ![zh-cn_image_0000001327429541](figures/zh-cn_image_0000001327429541.png) + + 工具链自动安装完成后如下图所示。 + + ![zh-cn_image_0000001349388493](figures/zh-cn_image_0000001349388493.png) + +3. 在**hh_scdy200**配置页签中,设置源码的编译类型**build_type**,默认为"debug"类型,请根据需要进行修改。然后点击**Save**进行保存。 + + ![zh-cn_image_0000001276354454](figures/zh-cn_image_0000001276354454.png) + +4. 在DevEco Device Tool界面的**PROJECT TASKS**中,点击对应开发板下的**Build**,执行编译。 + + ![zh-cn_image_0000001265516901](figures/zh-cn_image_0000001265516901.png) + +5. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 + + ![zh-cn_image_0000001307162054](figures/zh-cn_image_0000001307162054.png) + + 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[RK3568开发板烧录](quickstart-ide-3568-burn.md)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3568-burn.md b/zh-cn/device-dev/quick-start/quickstart-ide-3568-burn.md new file mode 100644 index 0000000000000000000000000000000000000000..a8a3a5267de371fbe6189fdd0a7f215554edbaaf --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3568-burn.md @@ -0,0 +1,58 @@ +# 烧录 + + +烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 + + +RK3568的镜像烧录通过Windows环境进行烧录,开发者启动烧录操作后,DevEco Device Tool通过Remote远程模式,将Ubuntu环境下编译生成的待烧录程序文件拷贝至Windows目录下,然后通过Windows的烧录工具将程序文件烧录至开发板中。 + + +## 前提条件 + +[下载](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows/DriverAssitant_v5.1.1.zip)并安装驱动DriverInstall.exe。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 如果已经安装旧版本的烧写工具,请先点击"驱动卸载"按钮卸载驱动,然后再点击"驱动安装"按钮安装驱动。 + + +## 操作步骤 + +1. 请连接好电脑和待烧录开发板,连接USB接口,具体可参考[RK3568开发板介绍](quickstart-appendix-rk3568.md)。 + +2. 在DevEco Device Tool中,选择**REMOTE DEVELOPMENT > Local PC**,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001326512673](figures/zh-cn_image_0000001326512673.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001275432904](figures/zh-cn_image_0000001275432904.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 + + ![zh-cn_image_0000001285658392](figures/zh-cn_image_0000001285658392.png) + +3. 在菜单栏中点击**Project Settings**按钮,进入RK3568工程配置界面。 + + ![zh-cn_image_0000001330777737](figures/zh-cn_image_0000001330777737.png) + +4. 在**Tool Chain**页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的**Install**按钮在线安装。 + + ![3865-uploader](figures/3865-uploader.png) + +5. 在**hh_scdy200**页签,设置烧录选项,包括upload_partitions和upload_protocol。 + - **upload_partitions_profile**:选择待烧录程序的配置文件,该配置文件会指定烧录文件名称、起始烧录地址、地址长度等信息;同时请勾选**Enable to use upload_partitions_profile for upload**选项。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如需修改烧录profile文件,在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 + > + > 首次烧录,请勾选**Enable to use upload_partitions_profile for upload**选项,会自动生成upload_partitions文件。再次烧录时,可根据实际情况选择生成upload_partitions文件进行自定义烧录,也可以再勾选**Enable to use upload_partitions_profile for upload**选项,使用upload_partitions_profile重新生成upload_partitions文件用于烧录。 + - **upload_protocol**:选择烧录协议,固定选择“upgrade”。 + + ![zh-cn_image_0000001338663697](figures/zh-cn_image_0000001338663697.png) + +6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +7. 在**PROJECT TASKS**中,点击hh_scdy200下的**Upload**按钮启动烧录。 + + ![zh-cn_image_0000001280147358](figures/zh-cn_image_0000001280147358.png) + +8. 当屏幕提示“Operation paused,Please press Enter key to continue”,请按**回车键**继续。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果开发板未处于烧录模式,屏幕会提示“The board is not in Loader mode.Please Hold on the VOL+key...”,此时,请长按音量+键,3秒后点击**RESET**键,然后再过3秒放开音量+键,使开发板进入烧录模式。 + + 等待开发板烧录完成,当屏幕提示如下信息时,表示烧录成功。 + + ![zh-cn_image_0000001327549705](figures/zh-cn_image_0000001327549705.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-create.md b/zh-cn/device-dev/quick-start/quickstart-ide-3568-helloworld.md similarity index 85% rename from zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-create.md rename to zh-cn/device-dev/quick-start/quickstart-ide-3568-helloworld.md index 3068b2e0a99a3ed41915ecfe378ff18bd695cd05..cbd93e684bfcff79a1e518114b4d21af9e6cdd18 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-create.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3568-helloworld.md @@ -4,11 +4,16 @@ 下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 +## 前提条件 + +已参考[创建工程并获取源码](quickstart-ide-import-project.md),创建RK3568开发板的源码工程。 + + ## 示例目录 示例完整目录如下。 - + ``` applications/sample/hello │── BUILD.gn @@ -19,22 +24,21 @@ applications/sample/hello ├── bundle.json build └── subsystem_config.json -vendor/hisilicon -└── Hi3516DV300 - └── config.json +productdefine/common +└── products + └── rk3568.json ``` ## 开发步骤 -请在源码目录中通过以下步骤创建“Hello World”应用程序: - +请在源码目录中通过以下步骤创建“Hello World”应用程序。 1. 创建目录,编写业务代码。 - + 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 - + ``` #include #include "helloworld.h" @@ -55,7 +59,7 @@ vendor/hisilicon 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。 - + ``` #ifndef HELLOWORLD_H #define HELLOWORLD_H @@ -76,9 +80,8 @@ vendor/hisilicon ``` 2. 新建编译组织文件。 - 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示: - + ``` import("//build/ohos.gni") # 导入编译模板 ohos_executable("helloworld") { # 可执行模块 @@ -99,7 +102,7 @@ vendor/hisilicon } ``` 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。 - + ``` { "name": "@ohos/hello", @@ -138,9 +141,10 @@ vendor/hisilicon bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。 3. 修改子系统配置文件。 - + 在build/subsystem_config.json中添加新建的子系统的配置。 - + + ``` "sample": { "path": "applications/sample/hello", @@ -149,9 +153,12 @@ vendor/hisilicon ``` 4. 修改产品配置文件。 - - 在vendor/hisilicon/Hi3516DV300/config.json中添加对应的hello部件,直接添加到原有部件后即可。 - + + 在productdefine/common/products/rk3568.json中添加对应的hello部件,直接添加到原有部件后即可。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 本章节操作是以OpenHarmony-v3.1-Release版本为例进行操作的,该版本中,RK3568的配置文件为productdefine/common/products/rk3568.json;若源码版本大于OpenHarmony-v3.1-Release时,RK3568的配置文件为vendor/hihope/rk3568/config.json。 + + ``` "usb:usb_manager_native":{}, "applications:prebuilt_hap":{}, diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3568-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-3568-running.md new file mode 100644 index 0000000000000000000000000000000000000000..786634e696a78dcb56a0773d9e82a5b09536ba41 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3568-running.md @@ -0,0 +1,21 @@ +# 运行 + + +## 启动系统 + +烧录完成重启开发板后,系统将会自动启动。开发板附带的屏幕呈现以下界面,表明系统已运行成功。 + + **图1** 系统启动效果图   + + ![quickstart-pkg-3568-running-restart](figures/quickstart-pkg-3568-running-restart.png) + + +## 运行“Hello World” + +1. 设备启动后打开串口工具(以putty为例),波特率设置为1500000,连接设备。 + + ![rk3568-run-configuration](figures/rk3568-run-configuration.png) + +2. 打开串口后,在任意目录(以设备根目录为例)下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 + + ![helloworld](figures/helloworld.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3861-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-3861-build.md new file mode 100644 index 0000000000000000000000000000000000000000..fe688893ece0b4c486cb58c4fe08ea9cb5234d89 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3861-build.md @@ -0,0 +1,41 @@ +# 编译 + + +DevEco Device Tool支持Hi3861V100开发板的源码一键编译功能,提供编译工具链和编译环境依赖的检测及一键安装,简化复杂编译环境的同时,提升了编译的效率。 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> Hi3861V100编译环境为Ubuntu环境。 + + +1. 在菜单栏中点击**Project Settings**,进入Hi3861工程配置界面。 + + ![zh-cn_image_0000001275483042](figures/zh-cn_image_0000001275483042.png) + +2. 在**Tool Chain**页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**Install**,自动安装所需工具链。 + + ![zh-cn_image_0000001333256741](figures/zh-cn_image_0000001333256741.png) + +3. 安装Hi3861V100相关工具链,部分工具安装需要使用root权限,请在**TERMINAL**窗口输入用户密码进行安装。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + + ![zh-cn_image_0000001280938208](figures/zh-cn_image_0000001280938208.png) + + 工具链自动安装完成后如下图所示。 + + ![zh-cn_image_0000001281378224](figures/zh-cn_image_0000001281378224.png) + +4. 在**hi3861**配置页签中,设置源码的编译类型**build_type**,默认为"debug"类型,请根据需要进行修改。然后点击**Save**进行保存。 + + ![zh-cn_image_0000001333581089](figures/zh-cn_image_0000001333581089.png) + +5. 在DevEco Device Tool界面的**PROJECT TASKS**中,点击对应开发板下的**Build**,执行编译。 + + ![zh-cn_image_0000001281221352](figures/zh-cn_image_0000001281221352.png) + +6. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 + + ![zh-cn_image_0000001405938781](figures/zh-cn_image_0000001405938781.png) + + 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[Hi3861V100开发板烧录](quickstart-ide-3861-burn.md)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3861-burn.md b/zh-cn/device-dev/quick-start/quickstart-ide-3861-burn.md new file mode 100644 index 0000000000000000000000000000000000000000..607463264e079110e64934138b7a805dabcc5d67 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3861-burn.md @@ -0,0 +1,54 @@ +# 烧录 + + +烧录是指将编译后的程序文件下载到开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 + + +Hi3861V100的镜像烧录通过Windows环境进行烧录,开发者启动烧录操作后,DevEco Device Tool通过Remote远程模式,将Ubuntu环境下编译生成的待烧录程序文件拷贝至Windows目录下,然后通过Windows的烧录工具将程序文件烧录至开发板中。 + + +## 前提条件 + +- 代码已[编译](quickstart-ide-3861-build.md)完成。 + +- 根据[USB转串口驱动安装指南](https://device.harmonyos.com/cn/docs/documentation/guide/hi3861-drivers-0000001058153433)安装USB转串口的驱动程序。 + + +## 操作步骤 + +1. 请连接好电脑和待烧录开发板,需要连接USB口,具体可参考[Hi3861V100开发板介绍](quickstart-appendix-hi3861.md)。 + +2. 在DevEco Device Tool中,选择**REMOTE DEVELOPMENT > Local PC**,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001326512673](figures/zh-cn_image_0000001326512673.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001275432904](figures/zh-cn_image_0000001275432904.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 + + ![zh-cn_image_0000001285658392](figures/zh-cn_image_0000001285658392.png) + +3. 在菜单栏中点击**Project Settings**按钮,进入Hi3861V100工程配置界面。 + + ![zh-cn_image_0000001333802045](figures/zh-cn_image_0000001333802045.png) + +4. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 + + ![Phoenix-upload](figures/Phoenix-upload.png) + +5. 在“hi3861”页签,设置烧录选项,包括upload_port、upload_protocol和upload_partitions。 + - upload_port:选择已查询的串口号。 + - upload_protocol:选择烧录协议,选择“hiburn-serial”。 + - upload_partitions:选择待烧录的文件名称。DevEco Device Tool已预置默认的烧录文件信息,如果需要修改待烧录文件地址,可点击每个待烧录文件后的![zh-cn_image_0000001333642545](figures/zh-cn_image_0000001333642545.png)按钮进行修改。 + + ![zh-cn_image_0000001345770181](figures/zh-cn_image_0000001345770181.png) + +6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +7. 在“PROJECT TASKS”中,点击hi3861下的**Upload**按钮,启动烧录。 + + ![zh-cn_image_0000001333322693](figures/zh-cn_image_0000001333322693.png) + +8. 启动烧录后,显示如下提示信息时,请在15秒内,按下开发板上的RST按钮重启开发板。 + + ![hi3861-upload-restart](figures/hi3861-upload-restart.png) + + 重新上电后,界面提示如下信息时,表示烧录成功。 + + ![zh-cn_image_0000001281002722](figures/zh-cn_image_0000001281002722.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-helloworld.md b/zh-cn/device-dev/quick-start/quickstart-ide-3861-helloworld.md similarity index 75% rename from zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-helloworld.md rename to zh-cn/device-dev/quick-start/quickstart-ide-3861-helloworld.md index 9a511787ec586b345bebbd4c6b8f93852e4b5122..4c4794ef02fbf6e9389630753efc6455baac0108 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-helloworld.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3861-helloworld.md @@ -4,13 +4,20 @@ 下方将通过修改源码的方式展示如何编写简单程序,输出“Hello world”。请在下载的源码目录中进行下述操作。 +## 前提条件 + +已参考[创建工程并获取源码](quickstart-ide-import-project.md),创建Hi3861开发板的源码工程。 + + +## 操作步骤 + 1. 确定目录结构。 - 开发者编写业务时,务必先在./applications/sample/wifi-iot/app路径下新建一个目录(或一套目录结构),用于存放业务源码文件。 + 开发者编写业务代码时,务必先在./applications/sample/wifi-iot/app路径下新建一个目录(或一套目录结构),用于存放业务源码文件。 例如:在app下新增业务my_first_app,其中hello_world.c为业务代码,BUILD.gn为编译脚本,具体规划目录结构如下: - + ``` . └── applications @@ -39,12 +46,12 @@ ``` 3. 编写用于将业务构建成静态库的BUILD.gn文件。 - + 新建./applications/sample/wifi-iot/app/my_first_app下的BUILD.gn文件,并完成如下配置。 如步骤1所述,BUILD.gn文件由三部分内容(目标、源文件、头文件路径)构成,需由开发者完成填写。 - + ``` static_library("myapp") { sources = [ @@ -61,10 +68,13 @@ - include_dirs中指定source所需要依赖的.h文件路径。 4. 添加新组件。 + + 修改文件build/lite/components/applications.json,添加组件hello_world_app的配置,如下所示为applications.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - 修改文件**build/lite/components/communication.json**,添加组件hello_world_app的配置,如下所示为communication.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 本章节操作是以OpenHarmony-v3.1-Release版本为例进行操作的,该版本中,组件配置文件为build/lite/components/applications.json;若源码版本大于等于OpenHarmony 3.2 Beta2时,组件配置文件为build/lite/components/communication.json。 - + ``` { "components": [ @@ -124,10 +134,10 @@ ``` 5. 修改单板配置文件。 + + 修改文件vendor/hisilicon/hispark_pegasus/config.json,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - 修改文件**vendor/hisilicon/hispark_pegasus/config.json**,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - - + ``` { "subsystem": "applications", diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3861-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-3861-running.md new file mode 100644 index 0000000000000000000000000000000000000000..fb7f8d06fc4d649663f870e77f6c29e9f1232bec --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3861-running.md @@ -0,0 +1,126 @@ +# 运行 + + +## 联网配置 + +由于Hi3861为WLAN模组,您可以在版本编译及烧录后,通过如下操作,使开发板实现联网功能。 + +1. 保持Windows工作台和Hi3861 WLAN模组的连接状态,在**PROJECT TASKS**中,单击**Monitor**,打开串口终端。 + + **图1** 打开DevEco串口终端 + + ![zh-cn_image_0000001406299413](figures/quickstart-ide-3861-running-mirror.png) + +2. 复位Hi3861 WLAN模组,终端界面显示“ready to OS start”,则启动成功。 + + **图2** Hi3861 WLAN模组复位成功示意图 + + ![quickstart-ide-3861-running-restart](figures/quickstart-ide-3861-running-restart.png) + +3. 在DevEco的串口终端中,依次执行如下AT命令,启动STA模式,连接指定AP热点,并开启DHCP功能。 + + ``` + AT+STARTSTA # 启动STA模式 + AT+SCAN # 扫描周边AP + AT+SCANRESULT # 显示扫描结果 + AT+CONN="SSID",,2,"PASSWORD" # 连接指定AP,其中SSID/PASSWORD为待连接的热点名称和密码 + AT+STASTAT # 查看连接结果 + AT+DHCP=wlan0,1 # 通过DHCP向AP请求wlan0的IP地址 + ``` + +4. 查看Hi3861 WLAN模组与网关联通是否正常,如下图所示。 + + ``` + AT+IFCFG # 查看模组接口IP + AT+PING=X.X.X.X # 检查模组与网关的联通性,其中X.X.X.X需替换为实际的网关地址 + ``` + + **图3** Hi3861 WLAN模组联网成功示意图 + + ![quickstart-ide-3861-running-success](figures/quickstart-ide-3861-running-success.png) + + +## 调测验证 + +完成烧录及联网之后,用户可根据需要进行调试验证。目前调试验证的方法有以下两种,开发者可以根据具体业务情况选择。 + +1. 通过printf打印日志 + +2. 通过asm文件定位panic问题 + +由于本示例业务简单,采用printf打印日志的调试方式即可。下方将介绍这两种调试手段的使用方法。 + + +### printf打印 + +代码中增加printf维测,信息会直接打印到串口上。开发者可在业务关键路径或业务异常位置增加日志打印,如下所示: + + +``` +void HelloWorld(void) +{ + printf("[DEMO] Hello world.\n"); +} +``` + + +### 根据asm文件进行问题定位 + + 系统异常退出时,会在串口上打印异常退出原因调用栈信息,如下文所示。通过解析异常栈信息可以定位异常位置。 + +``` +=======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*** +``` + +为解析上述调用栈信息,需要使用到Hi3861_wifiiot_app.asm文件,该文件记录了代码中函数在Flash上的符号地址以及反汇编信息。asm文件会随版本打包一同构建输出,存放在./out/wifiiot/路径下。 + +1. 将调用栈CallStack信息保存到txt文档中,以便于编辑。(可选) + +2. 打开asm文件,并搜索CallStack中的地址,列出对应的函数名信息。通常只需找出前几个栈信息对应的函数,就可明确异常代码方向。 + + ``` + 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. 根据以上调用栈信息,可以定位WadRecvCB函数中出现了异常。 + + ![hi3861-test](figures/hi3861-test.png) + +4. 完成代码排查及修改。 + + +## 运行结果 + +示例代码编译、烧录、运行、调测后,重启开发板后将自动在界面输出如下结果: + + +``` +ready to OS start +FileSystem mount ok. +wifi init success! +[DEMO] Hello world. +``` + + +## 下一步学习 + +恭喜,您已完成Hi3861 WLAN模组快速上手!建议您下一步进入的学习 。可参考: + +- [LED外设控制](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/guide/device-wlan-led-control.md) + +- [集成三方SDK](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/guide/device-wlan-sdk.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-env--win.md b/zh-cn/device-dev/quick-start/quickstart-ide-env--win.md new file mode 100644 index 0000000000000000000000000000000000000000..055d303163bd564fdc49e6f66765bda88de1eef8 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-env--win.md @@ -0,0 +1,54 @@ +# 搭建Windows环境 + +在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,建议使用Ubuntu的编译环境对源码进行编译。 + +在以上的设备开发场景中,可以搭建一套Windows+Ubuntu混合开发的环境,其中使用Windows平台的DevEco Device Tool可视化界面进行相关操作,通过远程连接的方式对接Ubuntu下的DevEco Device Tool(可以不安装Visual Studio Code),然后对Ubuntu下的源码进行开发、编译、烧录等操作。 + +本章节介绍开发所需Windows环境的搭建方法。 + +## 系统要求 + +- Windows 10 64位系统。 + +- Windows系统上安装的DevEco Device Tool为3.0 Release版本。 + + +## 操作步骤 + +1. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Windows版。 + +2. 解压DevEco Device Tool压缩包,双击安装包程序,单击**Next**进行安装。 + +3. 设置DevEco Device Tool的安装路径,请注意安装路径不能包含中文字符,**不建议安装到C盘目录**,单击**Next**。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果您已安装DevEco Device Tool 3.0 Beta2及以前的版本,则在安装新版本时,会先卸载旧版本,卸载过程中出现错误提示“Error during uninstallation process: Cannot remove directory...”时,请单击**Ignore**继续安装,该错误不影响新版本的安装。 + + ![zh-cn_image_0000001326386753](figures/zh-cn_image_0000001326386753.png) + +4. 根据安装向导提示,勾选要自动安装的软件。 + 1. 在弹出**VS Code installation confirm**页面,勾选“Install VS Code 1.62.2automatically”,单击**Next**。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果检测到Visual Studio Code已安装,且版本为1.62及以上,则会跳过该步骤。 + + ![zh-cn_image_0000001285965546](figures/zh-cn_image_0000001285965546.png) + 2. 在弹出的**Python select page**选择“Download from Huawei mirror”,单击**Next**。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果系统已安装可兼容的Python版本(Python 3.8~3.9版本),可选择“Use one of compatible on your PC”。 + + ![zh-cn_image_0000001285965778](figures/zh-cn_image_0000001285965778.png) + +5. 在以下界面单击**Next**。 + + ![zh-cn_image_0000001285806330](figures/zh-cn_image_0000001285806330.png) + +6. 请详细阅读以下界面的用户协议和隐私声明,需勾选“I accept the licenses”后,才能继续下一步的安装。 + + ![zh-cn_image_0000001275586896](figures/zh-cn_image_0000001275586896.png) + +7. 继续等待DevEco Device Tool安装向导自动安装DevEco Device Tool插件,直至安装完成,单击**Finish**,关闭DevEco Device Tool安装向导。 + + ![zh-cn_image_0000001275267040](figures/zh-cn_image_0000001275267040.png) + +8. 打开Visual Studio Code,进入DevEco Device Tool工具界面。至此,DevEco Device Tool Windows开发环境安装完成。 + + ![zh-cn_image_0000001338012765](figures/zh-cn_image_0000001338012765.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-env-remote.md b/zh-cn/device-dev/quick-start/quickstart-ide-env-remote.md new file mode 100644 index 0000000000000000000000000000000000000000..a6c260e917f5b49cb1f04cd4b7f9ae3bd78d9e50 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-env-remote.md @@ -0,0 +1,73 @@ +# 配置远程访问环境 + + +在搭建了Windows和Ubuntu开发环境后,需要通过下述设置,使得Windows可以远程访问Ubuntu,为后续烧录文件的传输做好准备。 + + +## 安装SSH服务并获取远程访问的IP地址 + +1. 在Ubuntu系统中,打开终端工具,执行如下命令安装SSH服务。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果执行该命令失败,提示openssh-server和openssh-client依赖版本不同,请根据CLI界面提示信息,安装openssh-client相应版本后(例如:sudo apt-get install openssh-client=1:8.2p1-4),再重新执行该命令安装openssh-server。 + + + ``` + sudo apt-get install openssh-server + ``` + +2. 执行如下命令,启动SSH服务。 + + ``` + sudo systemctl start ssh + ``` + +3. 执行如下命令,获取当前用户的IP地址,用于Windows系统远程访问Ubuntu环境。 + + ``` + ifconfig + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果执行ifconfig命令提示“command-not-found”,请执行**sudo apt-get install net-tools**命令安装网络查询工具,然后重新查询IP地址。 + + ![zh-cn_image_0000001215737140](figures/zh-cn_image_0000001215737140.png) + + +## 安装Remote SSH + +1. 打开Windows系统下的Visual Studio Code,点击![zh-cn_image_0000001239080359](figures/zh-cn_image_0000001239080359.png),在插件市场的搜索输入框中输入“remote-ssh”。 + + ![zh-cn_image_0000001285647778](figures/zh-cn_image_0000001285647778.png) + +2. 点击Remote-SSH的**Install**,安装Remote-SSH。安装成功后,在**INSTALLED**下可以看到已安装Remote-SSH。 + + ![zh-cn_image_0000001238880335](figures/zh-cn_image_0000001238880335.png) + + +## 远程连接Ubuntu环境 + +1. 打开Windows系统的Visual Studio Code,点击![zh-cn_image_0000001238760373](figures/zh-cn_image_0000001238760373.png),在**SSH TARGETS**下,单击+。 + + ![zh-cn_image_0000001215878922](figures/zh-cn_image_0000001215878922.png) + +2. 在弹出的SSH连接命令输入框中输入“ssh _username_\@_ip_address_”,其中ip_address为要连接的远程计算机的IP地址,username为登录远程计算机的帐号。 + + ![zh-cn_image_0000001215879750](figures/zh-cn_image_0000001215879750.png) + +3. 在弹出的输入框中,选择SSH configuration文件,选择默认的第一选项即可。 + + ![zh-cn_image_0000001260519729](figures/zh-cn_image_0000001260519729.png) + +4. 在SSH TARGETS中,找到远程计算机,点击![zh-cn_image_0000001194080414](figures/zh-cn_image_0000001194080414.png),打开远程计算机。 + + ![zh-cn_image_0000001215720398](figures/zh-cn_image_0000001215720398.png) + +5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机 。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 在Windows系统远程访问Ubuntu过程中,需要频繁的输入密码进行连接,为解决该问题,您可以使用SSH公钥来进行设置,设置方法请参考[注册远程访问Ubuntu环境的公钥](https://device.harmonyos.com/cn/docs/documentation/guide/ide-registering-public-key-0000001247162706)。 + + ![zh-cn_image_0000001215897530](figures/zh-cn_image_0000001215897530.png) + + 连接成功后,等待在远程计算机用户目录下的.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。至此,环境搭建完成,如下图所示,左下角显示远程连接计算机的IP地址。 + + ![zh-cn_image_0000001338102621](figures/zh-cn_image_0000001338102621.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-env-ubuntu.md b/zh-cn/device-dev/quick-start/quickstart-ide-env-ubuntu.md new file mode 100644 index 0000000000000000000000000000000000000000..bfda5a1b0d8e37bf4252ba381c4fa3f2943be04e --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-env-ubuntu.md @@ -0,0 +1,64 @@ +# 搭建Ubuntu环境 + +在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,建议使用Ubuntu的编译环境对源码进行编译。 + +在以上的设备开发场景中,可以搭建一套Windows+Ubuntu混合开发的环境,其中使用Windows平台的DevEco Device Tool可视化界面进行相关操作,通过远程连接的方式对接Ubuntu下的DevEco Device Tool(可以不安装Visual Studio Code),然后对Ubuntu下的源码进行开发、编译、烧录等操作。 + +本章节介绍开发所需Ubuntu环境的搭建方法。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 如果没有Ubuntu系统,可在Windows系统中通过虚拟机方式搭建Ubuntu系统,具体请参考[Ubuntu系统安装指导](https://developer.huawei.com/consumer/cn/training/course/video/C101639987816176315)。Ubuntu系统安装完成后,请根据指导完成[Ubuntu基础环境配置](https://developer.huawei.com/consumer/cn/training/course/video/C101639988048536240),然后再根据本章节进行DevEco Device Tool工具的安装。 + + +## 系统要求 + +- Ubuntu系统要求:Ubuntu18.04~21.10版本,内存推荐16 GB及以上。 + +- Ubuntu系统的用户名不能包含中文字符。 + + +## 操作步骤 + +1. 将Ubuntu Shell环境修改为bash。 + 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据子步骤2,将Ubuntu shell修改为bash。 + + ``` + ls -l /bin/sh + ``` + + ![zh-cn_image_0000001226764302](figures/zh-cn_image_0000001226764302.png) + 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 + + ``` + sudo dpkg-reconfigure dash + ``` + + ![ubuntu-dash-to-bash](figures/ubuntu-dash-to-bash.png) + +2. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Linux版本。 + +3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 + 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.1.0.200.zip为软件包名称,请根据实际进行修改。 + + ``` + unzip devicetool-linux-tool-3.1.0.200.zip + ``` + 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.1.0.200.sh请根据实际进行修改。 + + ``` + chmod u+x devicetool-linux-tool-3.1.0.200.sh + ``` + +4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.1.0.200.sh请根据实际进行修改。 + + ``` + sudo ./devicetool-linux-tool-3.1.0.200.sh + ``` + +5. 在用户协议和隐私声明签署界面,请详细阅读用户协议和隐私声明,需签署同意用户协议和隐私声明才能进行下一步的安装,可通过键盘的上下按键进行选择。 + + ![zh-cn_image_0000001340557741](figures/zh-cn_image_0000001340557741.png) + + 安装完成后,当界面输出“DevEco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 + + ![zh-cn_image_0000001338201457](figures/zh-cn_image_0000001338201457.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-env.md b/zh-cn/device-dev/quick-start/quickstart-ide-env.md new file mode 100644 index 0000000000000000000000000000000000000000..3cb3ffb46bf738617f74bbc0a651a3d641db4d2a --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-env.md @@ -0,0 +1,7 @@ +# 搭建开发环境 + + +在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,建议使用Ubuntu的编译环境对源码进行编译。 + + +在以上的设备开发场景中,可以搭建一套Windows+Ubuntu混合开发的环境,其中使用Windows平台的DevEco Device Tool可视化界面进行相关操作,通过远程连接的方式对接Ubuntu下的DevEco Device Tool(可以不安装Visual Studio Code),然后对Ubuntu下的源码进行开发、编译、烧录等操作。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-import-project.md b/zh-cn/device-dev/quick-start/quickstart-ide-import-project.md new file mode 100644 index 0000000000000000000000000000000000000000..4692ddf4862e7397586a9abd19f00caed050a1f0 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-import-project.md @@ -0,0 +1,41 @@ +# 创建工程并获取源码 + + +在通过DevEco Device Tool创建OpenHarmony工程时,可自动下载相应版本的OpenHarmony源码,源码类型包括OpenHarmony Stable Version、OpenHarmony Sample和HarmonyOS Connect Solution。 + + +OpenHarmony Stable Version源码为OpenHarmony稳定版本源码,通过镜像站点获取,支持OpenHarmony-v1.1.4-LTS、OpenHarmony-v3.0.3-LTS和OpenHarmony-v3.1-Release版本。 + + +镜像站点的源码,一般取自该稳定版本的发布时间点,因此,通过镜像站点获取的源码可能不是该版本最新源码。如果您需要获取对应版本的最新源码,请参考[从码云仓库获取源码](../get-code/sourcecode-acquire.md),获取源码后,请参考《[HUAWEI DevEco Device Tool 使用指南](https://device.harmonyos.com/cn/docs/documentation/guide/service_introduction-0000001050166905)》的“导入OpenHarmony源码”章节,在DevEco Device Tool中导入源码。 + + +此处以下载OpenHarmony Stable Version源码为例,说明操作过程。关于OpenHarmony Sample和HarmonyOS Connect Solution源码的下载,可参考《[HUAWEI DevEco Device Tool 使用指南](https://device.harmonyos.com/cn/docs/documentation/guide/service_introduction-0000001050166905)》。 + + +## 前提条件 + +只有在Windows环境通过Remote SSH远程连接上Ubuntu环境的情况下,才可以创建OpenHarmony新工程,具体请参考[搭建开发环境](quickstart-ide-env--win.md)。否则,在DevEco Device Tool的Home界面没有“**New Project**”按钮。 + + +## 操作步骤 + +OpenHarmony稳定版本源码,支持OpenHarmony-v1.1.4-LTS、OpenHarmony-v3.0.3-LTS和OpenHarmony-v3.1-Release版本。 + +1. 打开DevEco Device Tool,进入Home页,点击**New Project**创建新工程。 + + ![zh-cn_image_0000001272258726](figures/zh-cn_image_0000001272258726.png) + +2. 在新工程的配置向导页,配置工程相关信息,包括: + - **OpenHarmony Source Code**:选择需要下载的OpenHarmony源码,请选择**OpenHarmony Stable Version**下的源码版本,支持OpenHarmony-v1.1.4-LTS、OpenHarmony-v3.0.3-LTS和OpenHarmony-v3.1-Release版本。 + - **Project Name**:设置工程名称。 + - **Project Path**:选择工程文件存储路径。 + - **SOC**:选择支持的芯片。 + - **Board**:选择支持的开发板。 + - **Product**:选择产品。 + + ![zh-cn_image_0000001338187673](figures/zh-cn_image_0000001338187673.png) + +3. 工程配置完成后,点击**Confirm**,DevEco Device Tool会自动启动OpenHarmony源码的下载。由于OpenHarmony稳定版本源码包体积较大,请耐心等待源码下载完成。 + + ![zh-cn_image_0000001338536201](figures/zh-cn_image_0000001338536201.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-appendix.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-appendix.md new file mode 100644 index 0000000000000000000000000000000000000000..37735011da2235266fe5a6397df0cca595609111 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-appendix.md @@ -0,0 +1,11 @@ +# 附录 + + + +- **[Hi3516开发板介绍](quickstart-appendix-hi3516.md)** + +- **[Hi3861开发板介绍](quickstart-appendix-hi3861.md)** + +- **[RK3568开发板介绍](quickstart-appendix-rk3568.md)** + +- **[编译形态整体说明](quickstart-appendix-compiledform.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-create-project.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-create-project.md deleted file mode 100644 index 95011ede77ffcc9c1493fb241c9a8de7044d0724..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-create-project.md +++ /dev/null @@ -1,22 +0,0 @@ -# 导入源码工程 - - -在完成[搭建Windows+Ubuntu混合开发环境](../quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md)和[获取源码](../quick-start/quickstart-ide-lite-sourcecode-acquire.md)后,您需要在Windows环境中按照如下步骤创建源码工程,之后方可在DevEco Device Tool中进行后续的操作。 - - -1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 - - ![zh-cn_image_0000001278358765](figures/zh-cn_image_0000001278358765.png) - -2. 选择OpenHarmony源码根目录路径,然后再选择**Import OpenHarmony Source**选项,点击**Import**进行导入。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 工程存储路径不能包含中文字符、空格。如果工程存储路径包含中文字符或空格,可能导致编译失败。 - - ![zh-cn_image_0000001271477045](figures/zh-cn_image_0000001271477045.png) - -3. 在Import Project界面,选择**Product**后,会自动填充对应的SOC、Board、Company和Kernel信息,然后Ohos Ver选择对应的OpenHarmony源码版本。 - - ![zh-cn_image_0000001271237242](figures/zh-cn_image_0000001271237242.png) - -4. 点击**Open**打开工程或源码。 \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md deleted file mode 100644 index 59b87777f61132550f187d59ee32b712754ef3f7..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md +++ /dev/null @@ -1,178 +0,0 @@ -# 搭建Windows+Ubuntu混合开发环境 - - -通常在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,需要使用Ubuntu的编译环境对源码进行编译。 - - -在以上的设备开发场景中,可以搭建一套Windows+Ubuntu混合开发的环境,其中使用Windows平台的DevEco Device Tool可视化界面进行相关操作,通过远程连接的方式对接Ubuntu下的DevEco Device Tool(可以不安装Visual Studio Code),然后对Ubuntu下的源码进行开发、编译、烧录等操作。 - - -## 系统要求 - -- Windows系统要求:Windows10 64位系统。 - -- Ubuntu系统要求:Ubuntu18.04~21.10版本,内存推荐16 GB及以上。 - -- Ubuntu系统的用户名不能包含中文字符。 - -- Windows和Ubuntu系统上安装的DevEco Device Tool为3.0 Release版本。 - - -## 搭建Ubuntu环境 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 如果没有Ubuntu系统,可在Windows系统中通过虚拟机方式搭建Ubuntu系统,具体请参考[Ubuntu系统安装指导](https://developer.huawei.com/consumer/cn/training/course/video/C101639987816176315)。Ubuntu系统安装完成后,请根据指导完成[Ubuntu基础环境配置](https://developer.huawei.com/consumer/cn/training/course/video/C101639988048536240),然后再根据本章节进行DevEco Device Tool工具的安装。 - -1. 将Ubuntu Shell环境修改为bash。 - 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2将Ubuntu shell修改为bash。 - - ``` - ls -l /bin/sh - ``` - - ![zh-cn_image_0000001226764302](figures/zh-cn_image_0000001226764302.png) - 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 - - ``` - sudo dpkg-reconfigure dash - ``` - - ![zh-cn_image_0000001243641075](figures/zh-cn_image_0000001243641075.png) - -2. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Linux版本。 - -3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 - 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.401.zip为软件包名称,请根据实际进行修改。 - - ``` - unzip devicetool-linux-tool-3.0.0.401.zip - ``` - 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.401.sh请根据实际进行修改。 - - ``` - chmod u+x devicetool-linux-tool-3.0.0.401.sh - ``` - -4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.401.sh请根据实际进行修改。 - - ``` - sudo ./devicetool-linux-tool-3.0.0.401.sh - ``` - -5. 在用户协议和隐私声明签署界面,请详细阅读用户协议和隐私声明,需签署同意用户协议和隐私声明才能进行下一步的安装。 - - ![zh-cn_image_0000001322167645.png](figures/zh-cn_image_0000001322167645.png) - - 安装完成后,当界面输出“DevEco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 - - ![zh-cn_image_0000001198722374](figures/zh-cn_image_0000001198722374.png) - - -## 搭建Windows开发环境 - -1. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download)Windows版。 - -2. 解压DevEco Device Tool压缩包,双击安装包程序,点击Next进行安装。 - -3. 设置DevEco Device Tool的安装路径,请注意安装路径不能包含中文字符,同时建议安装到非系统盘符,点击**Next**。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果您已安装DevEco Device Tool 3.0 Beta2及以前的版本,则在安装新版本时,会先卸载旧版本,卸载过程中出现如下错误提示时,请点击“Ignore”继续安装,该错误不影响新版本的安装。 - > - > ![zh-cn_image_0000001239275843](figures/zh-cn_image_0000001239275843.png) - - ![zh-cn_image_0000001270076961](figures/zh-cn_image_0000001270076961.png) - -4. 根据安装向导提示,勾选要自动安装的软件。 - 1. 在弹出VSCode installation confirm页面,勾选“Install VScode 1.62.2automatically”,点击**Next**。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果检测到Visual Studio Code已安装,且版本为1.62及以上,则会跳过该步骤。 - - ![zh-cn_image_0000001237801283](figures/zh-cn_image_0000001237801283.png) - 2. 在弹出的Python select page选择“Download from Huawei mirror”,点击**Next**。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果系统已安装可兼容的Python版本(Python 3.8~3.9版本),可选择“Use one of compatible on your PC”。 - - ![zh-cn_image_0000001193983334](figures/zh-cn_image_0000001193983334.png) - -5. 在以下界面点击**Next**。 - - ![zh-cn_image_0000001259180828](figures/zh-cn_image_0000001259180828.png) - -6. 请详细阅读以下界面的用户协议和隐私声明,这里须勾选"I accept the licenses",然后点击Next,安装向导才会继续进行软件下载和安装。 - - ![zh-cn_image_0000001307019009](figures/zh-cn_image_0000001307019009.png) - -7. 继续等待DevEco Device Tool安装向导自动安装DevEco Device Tool插件,直至安装完成,点击**Finish**,关闭DevEco Device Tool安装向导。 - - ![zh-cn_image_0000001239650137](figures/zh-cn_image_0000001239650137.png) - -8. 打开Visual Studio Code,进入DevEco Device Tool工具界面。至此,DevEco Device Tool Windows开发环境安装完成。 - - ![zh-cn_image_0000001225760456](figures/zh-cn_image_0000001225760456.png) - - -## 配置Windows远程访问Ubuntu环境 - - -### 安装SSH服务并获取远程访问的IP地址 - -1. 在Ubuntu系统中,打开终端工具,执行如下命令安装SSH服务。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果执行该命令失败,提示openssh-server和openssh-client依赖版本不同,请根据CLI界面提示信息,安装openssh-client相应版本后(例如:sudo apt-get install openssh-client=1:8.2p1-4),再重新执行该命令安装openssh-server。 - - - ``` - sudo apt-get install openssh-server - ``` - -2. 执行如下命令,启动SSH服务。 - - ``` - sudo systemctl start ssh - ``` - -3. 执行如下命令,获取当前用户的IP地址,用于Windows系统远程访问Ubuntu环境。 - - ``` - ifconfig - ``` - - ![zh-cn_image_0000001215737140](figures/zh-cn_image_0000001215737140.png) - - -### 安装Remote SSH - -1. 打开Windows系统下的Visual Studio Code,点击![zh-cn_image_0000001239080359](figures/zh-cn_image_0000001239080359.png),在插件市场的搜索输入框中输入“remote-ssh”。 - - ![zh-cn_image_0000001193920448](figures/zh-cn_image_0000001193920448.png) - -2. 点击Remote-SSH的**Install**按钮,安装Remote-SSH。安装成功后,在**INSTALLED**下可以看到已安装Remote-SSH。 - - ![zh-cn_image_0000001238880335](figures/zh-cn_image_0000001238880335.png) - - -### 远程连接Ubuntu环境 - -1. 打开Windows系统的Visual Studio Code,点击![zh-cn_image_0000001238760373](figures/zh-cn_image_0000001238760373.png),在REMOTE EXPLORER页面点击+按钮。 - - ![zh-cn_image_0000001215878922](figures/zh-cn_image_0000001215878922.png) - -2. 在弹出的SSH连接命令输入框中输入“ssh _username_\@_ip_address_”,其中ip_address为要连接的远程计算机的IP地址,username为登录远程计算机的帐号。 - - ![zh-cn_image_0000001215879750](figures/zh-cn_image_0000001215879750.png) - -3. 在弹出的输入框中,选择SSH configuration文件,选择默认的第一选项即可。 - - ![zh-cn_image_0000001260519729](figures/zh-cn_image_0000001260519729.png) - -4. 在SSH TARGETS中,找到远程计算机,点击![zh-cn_image_0000001194080414](figures/zh-cn_image_0000001194080414.png),打开远程计算机。 - - ![zh-cn_image_0000001215720398](figures/zh-cn_image_0000001215720398.png) - -5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机 。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 在Windows系统远程访问Ubuntu过程中,需要频繁的输入密码进行连接,为解决该问题,您可以使用SSH公钥来进行设置,设置方法请参考[注册远程访问Ubuntu环境的公钥](https://device.harmonyos.com/cn/docs/documentation/guide/ide-registering-public-key-0000001247162706)。 - - ![zh-cn_image_0000001215897530](figures/zh-cn_image_0000001215897530.png) - - 连接成功后,等待在远程计算机.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3516.md deleted file mode 100644 index c4d4506d4e5db33de6b5dd682f74d5f8fb14f99a..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3516.md +++ /dev/null @@ -1,20 +0,0 @@ -# Hi3516开发板介绍 - - -## 简介 - -Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP(Image Signal Processor)、H.265视频压缩编码器以及高性能NNIE引擎,具备低码率、高画质、低功耗等特点,并具备强劲的智能处理和分析能力。 - - **图1** Hi3516单板正面外观图   - -![zh-cn_image_0000001271234717](figures/zh-cn_image_0000001271234717.png) - - -## 开发板规格 - - **表1** Hi3516开发板规格清单 - -| 规格类型 | 规格清单 | -| -------- | -------- | -| **处理器及内部存储** | - Hi3516DV300芯片
- DDR3 1GB
- eMMC4.5,8GB容量 | -| **外部器件** | - 以太网口
- 音频视频
  - 1路语音输入
  - 1路单声道(AC_L)输出,接3W功放(LM4871)
  - MicroHDMI(1路HDMI 1.4)
- 摄像头
  - 传感器IMX335
  - 镜头M12,焦距4mm,光圈1.8
- 显示屏
  - LCD连接器(2.35寸)
  - LCD连接器(5.5寸)
- 外部器件及接口
  - SD卡接口
  - JTAG/I2S接口
  - ADC接口
  - 舵机接口
  - Grove连接器
  - USB2.0(Type C)
  - 功能按键3个,2个用户自定义按键,1个升级按键
  - LED指示灯,绿灯,红灯 | 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 deleted file mode 100644 index 253db99a5d4911f27d38845c50346af85ca022e2..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md +++ /dev/null @@ -1,42 +0,0 @@ -# 轻量与小型系统入门概述 - - -## 简介 - -OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存≥128KiB)。通过本文,开发者可以快速熟悉OpenHarmony轻量和小型系统的环境搭建、编译、烧录、调测以及运行“Hello World”等。 - -考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: - -- IDE方式:完全采用IDE(DevEco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 - -- 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 - OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 - -本文采用DevEco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[轻量和小型系统快速入门(安装包方式)](../quick-start/quickstart-lite-overview.md)。 - - -## 开发环境 - -推荐开发者采用Windows+Ubuntu环境进行OpenHarmony开发: - -- Windows:用于源码开发、烧录等。 - -- Ubuntu:用于源码编译。 - -本文将介绍如何基于Windows+Ubuntu环境进行OpenHarmony的开发。 - - -## 开发板 - -本文基于以下两款典型开发板进行开发介绍 :Hi3861 WLAN模组、Hi3516DV300。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-ide-lite-introduction-hi3861.md),开发者可根据需要自行购买开发板。 - - -## 开发流程 - -轻量和小型系统快速入门流程如下图所示。 - - - **图1** 轻量和小型系统快速入门开发流程  - -  - ![zh-cn_image_0000001226634676](figures/zh-cn_image_0000001226634676.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-building.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-building.md deleted file mode 100644 index 937b4772a83123586812c89ea37246bbb632c00a..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-building.md +++ /dev/null @@ -1,35 +0,0 @@ -# 编译 - - -1. 在菜单栏中点击**Project Settings**按钮,进入Hi3516DV300工程配置界面。 - - ![zh-cn_image_0000001265492885](figures/zh-cn_image_0000001265492885.png) - -2. 在Tool Chain页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**Install**按钮,自动安装所需工具链。 - - ![zh-cn_image_0000001265652869](figures/zh-cn_image_0000001265652869.png) - -3. 安装Hi3516DV300相关工具链,部分工具安装需要使用root权限,请在“TERMINAL”窗口输入用户密码进行安装。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 - - ![zh-cn_image_0000001220852753](figures/zh-cn_image_0000001220852753.png) - - 工具链自动安装完成后如下图所示。 - - ![zh-cn_image_0000001220852754](figures/zh-cn_image_0000001220852754.png) - -4. 在“hi3516dv300”配置页签中,设置源码的编译类型**build_type**,默认为“debug“类型,请根据需要进行修改。然后点击**Save**按钮进行保存。 - - ![zh-cn_image_0000001221172711](figures/zh-cn_image_0000001221172711.png) - -5. 在“PROJECT TASKS”中,点击对应开发板下的**Build**按钮,执行编译。 - - ![zh-cn_image_0000001265772913](figures/zh-cn_image_0000001265772913.png) - -6. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 - - ![zh-cn_image_0000001221012766](figures/zh-cn_image_0000001221012766.png) - - 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[Hi3516DV300开发板烧录](quickstart-ide-lite-steps-hi3516-burn.md)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-burn.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-burn.md deleted file mode 100644 index 88e14f957404ba4a2eea28cbf00424f40af8c590..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-burn.md +++ /dev/null @@ -1,63 +0,0 @@ -# 烧录 - - -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 - -Hi3516DV300的镜像烧录通过Windows环境进行烧录,开发者启动烧录操作后,DevEco Device Tool通过Remote远程模式,将Ubuntu环境下编译生成的待烧录程序文件拷贝至Windows目录下,然后通过Windows的烧录工具将程序文件烧录至开发板中。 - -Hi3516DV300开发板小型系统的烧录方式包括USB烧录、网口烧录两种方式,本文采用USB方式进行烧录。 - - -1. 请连接好电脑和待烧录开发板,需要连接USB口和串口,具体可参考[Hi3516DV300开发板介绍](quickstart-lite-introduction-hi3516.md)。 - -2. 根据[Hi3516DV300开发板串口驱动安装指导](https://gitee.com/link?target=https%3A%2F%2Fdevice.harmonyos.com%2Fcn%2Fdocs%2Fdocumentation%2Fguide%2Fhi3516_hi3518-drivers-0000001050743695)、[Hi3516DV300开发板USB驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)安装USB驱动及USB转串口的驱动。若您的设备中已安装此驱动,请忽略该步骤。 - -3. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 - - ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) - - -4. 在菜单栏中点击**Project Settings**按钮,进入Hi3516DV300工程配置界面。 - - ![zh-cn_image_0000001198566364](figures/zh-cn_image_0000001198566364.png) - -5. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 - - ![zh-cn_image_0000001198566365](figures/zh-cn_image_0000001198566365.png) - -6. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 - - - upload_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。DevEco Device Tool已预置默认的烧录文件信息,包括起始地址、分区大小、待烧录文件地址等,开发者可根据实际情况进行调整,点击每个待烧录文件后的![zh-cn_image_0000001275592884.png](figures/zh-cn_image_0000001275592884.png)按钮进行修改。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 - - ![zh-cn_image_0000001312778829](figures/zh-cn_image_0000001312778829.png) - - - upload_protocol:选择烧录协议,固定选择“hiburn-usb”。 - - - upload_port:选择已查询到的串口号。 - - ![zh-cn_image_0000001223190441](figures/zh-cn_image_0000001223190441.png) - -7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -8. 点击hi3516dv300下的**Upload**按钮。 - - ![zh-cn_image_0000001266887264](figures/zh-cn_image_0000001266887264.png) - - 此时待烧录文件会从Ubuntu系统传输到Windows下,传输完成后界面显示“Operation paused, Please press Enter key to continue”时,请点击**Enter**键启动烧录。 - - ![zh-cn_image_0000001114129426](figures/zh-cn_image_0000001114129426.png) - -9. 在终端窗口显示如下提示信息时,请在15秒内,按住Update键,插拔USB线,最后松开Update键启动烧录。 - - ![zh-cn_image_0000001326412233.png](figures/zh-cn_image_0000001326412233.png) - - 启动烧录后,界面提示**SUCCESS**信息时,表示烧录成功。 - - ![zh-cn_image_0000001160649343](figures/zh-cn_image_0000001160649343.png) - -10. 烧录成功后,请根据运行章节进行操作,启动系统。 \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-building.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-building.md deleted file mode 100644 index f7b9d1cf364c7d9ccf62295dc7822d75f002f7cc..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-building.md +++ /dev/null @@ -1,37 +0,0 @@ -# 编译 - - -1. 在菜单栏中点击**Project Settings**按钮,进入Hi3861工程配置界面。 - - ![zh-cn_image_0000001265785209](figures/zh-cn_image_0000001265785209.png) - -2. 在Tool Chain页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**Install**按钮,自动安装所需工具链。 - - ![zh-cn_image_0000001221025048](figures/zh-cn_image_0000001221025048.png) - - - -3. 安装Hi3861V100相关工具链,部分工具安装需要使用root权限,请在“TERMINAL”窗口输入用户密码进行安装。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 - - ![zh-cn_image_0000001280938208.png](figures/zh-cn_image_0000001280938208.png) - - 工具链自动安装完成后如下图所示。 - - ![zh-cn_image_0000001221344980](figures/zh-cn_image_0000001221344980.png) - -4. 在“hi3861”配置页签中,设置源码的编译类型**build_type**,默认为"debug"类型,请根据需要进行修改。然后点击**Save**按钮进行保存。 - - ![zh-cn_image_0000001265945173](figures/zh-cn_image_0000001265945173.png) - -5. 在DevEco Device Tool界面的“PROJECT TASKS”中,点击对应开发板下的**Build**按钮,执行编译。 - - ![zh-cn_image_0000001265505181](figures/zh-cn_image_0000001265505181.png) - -6. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 - - ![zh-cn_image_0000001265665157](figures/zh-cn_image_0000001265665157.png) - - 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[Hi3861V100开发板烧录](quickstart-ide-lite-steps-hi3861-burn.md)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-burn.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-burn.md deleted file mode 100644 index 205c3cd0e15b87090af7ee978c7d1d132ae1b3d7..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-burn.md +++ /dev/null @@ -1,48 +0,0 @@ -# 烧录 - - -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 - -Hi3861V100的镜像烧录通过Windows环境进行烧录,开发者启动烧录操作后,DevEco Device Tool通过Remote远程模式,将Ubuntu环境下编译生成的带烧录程序文件拷贝至Windows目录下,然后通过Windows的烧录工具将程序文件烧录至开发板中。 - -Hi3861V100开发板支持串口烧录方式,在Windows下通过以下步骤进行烧录: - - -1. 请连接好电脑和待烧录开发板,需要连接USB口,具体可参考[Hi3861V100开发板介绍](quickstart-lite-introduction-hi3861.md)。 - -2. 根据[Hi3861V100开发板串口驱动安装指导](https://gitee.com/link?target=https%3A%2F%2Fdevice.harmonyos.com%2Fcn%2Fdocs%2Fdocumentation%2Fguide%2Fhi3861-drivers-0000001058153433)安装USB转串口的驱动程序。若您的设备中已安装此驱动,请忽略该步骤。 - -3. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 - - ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) - -4. 在菜单栏中点击**Project Settings**按钮,进入Hi3861V100工程配置界面。 - - ![zh-cn_image_0000001333802045.png](figures/zh-cn_image_0000001333802045.png) - -5. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 - - ![zh-cn_image_0000001198943768](figures/zh-cn_image_0000001198943768.png) - -6. 在“hi3861”页签,设置烧录选项,包括upload_port、upload_protocol和upload_partitions。 - - upload_port:选择已查询的串口号。 - - upload_protocol:选择烧录协议,选择“hiburn-serial”。 - - upload_partitions:选择待烧录的文件名称。DevEco Device Tool已预置默认的烧录文件信息,如果需要修改待烧录文件地址,可点击每个待烧录文件后的![zh-cn_image_0000001333642545.png](figures/zh-cn_image_0000001333642545.png)按钮进行修改。 - - ![zh-cn_image_0000001243704061](figures/zh-cn_image_0000001243704061.png) - -7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -8. 点击**Open**打开工程文件,然后在“PROJECT TASKS”中,点击hi3861下的**Upload**按钮,启动烧录。 - - ![zh-cn_image_0000001216440138](figures/zh-cn_image_0000001216440138.png) - -9. 启动烧录后,显示如下提示信息时,请在15秒内,按下开发板上的RST按钮重启开发板。 - - ![zh-cn_image_0000001198466090](figures/zh-cn_image_0000001198466090.png) - - 重新上电后,界面提示如下信息时,表示烧录成功。 - - ![zh-cn_image_0000001216761476](figures/zh-cn_image_0000001216761476.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-debug.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-debug.md deleted file mode 100644 index 8c4ed6fb8cb55c6699a959379921b92cc5e26a35..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-debug.md +++ /dev/null @@ -1,64 +0,0 @@ -# 调试验证 - - -完成烧录及联网之后,用户可根据需要进行调试验证。目前调试验证的方法有以下两种,开发者可以根据具体业务情况选择。 - - -1. 通过printf打印日志 - -2. 通过asm文件定位panic问题 - - -由于本示例业务简单,采用printf打印日志的调试方式即可。下方将介绍这两种调试手段的使用方法。 - - -## printf打印 - -代码中增加printf维测,信息会直接打印到串口上。开发者可在业务关键路径或业务异常位置增加日志打印,如下所示: - - -``` -void HelloWorld(void) -{ - printf("[DEMO] Hello world.\n"); -} -``` - - -## 根据asm文件进行问题定位 - - 系统异常退出时,会在串口上打印异常退出原因调用栈信息,如下文所示。通过解析异常栈信息可以定位异常位置。 - -``` -=======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*** -``` - -为解析上述调用栈信息,需要使用到Hi3861_wifiiot_app.asm文件,该文件记录了代码中函数在Flash上的符号地址以及反汇编信息。asm文件会随版本打包一同构建输出,存放在./out/wifiiot/路径下。 - -1. 将调用栈CallStack信息保存到txt文档中,以便于编辑。(可选) - -2. 打开asm文件,并搜索CallStack中的地址,列出对应的函数名信息。通常只需找出前几个栈信息对应的函数,就可明确异常代码方向。 - - ``` - 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. 根据以上调用栈信息,可以定位WadRecvCB函数中出现了异常。 - ![zh-cn_image_0000001226634668](figures/zh-cn_image_0000001226634668.png) - -4. 完成代码排查及修改。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md deleted file mode 100644 index 20517b0667532451695b32f8603f6f5e7c29fe96..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md +++ /dev/null @@ -1,39 +0,0 @@ -# 联网 - - -完成版本编译及烧录后,下面开始介绍如何在串口终端上执行AT命令,使Hi3861 WLAN模组联网。 - - -1. 保持Windows工作台和Hi3861 WLAN模组的连接状态,在DevEco工具最下方,点击“DevEco:Serial Monitor”按钮。 - - **图1** 打开DevEco串口终端示意图   - - ![zh-cn_image_0000001226634700](figures/zh-cn_image_0000001226634700.png) - -2. 复位Hi3861 WLAN模组,终端界面显示“ready to OS start”,则启动成功。 - - **图2** Hi3861 WLAN模组复位成功示意图   - - ![zh-cn_image_0000001271594733](figures/zh-cn_image_0000001271594733.png) - -3. 在DevEco的串口终端中,依次执行如下AT命令,启动STA模式,连接指定AP热点,并开启DHCP功能。 - - ``` - AT+STARTSTA # 启动STA模式 - AT+SCAN # 扫描周边AP - AT+SCANRESULT # 显示扫描结果 - AT+CONN="SSID",,2,"PASSWORD" # 连接指定AP,其中SSID/PASSWORD为待连接的热点名称和密码 - AT+STASTAT # 查看连接结果 - AT+DHCP=wlan0,1 # 通过DHCP向AP请求wlan0的IP地址 - ``` - -4. 查看Hi3861 WLAN模组与网关联通是否正常,如下图所示。 - - ``` - AT+IFCFG # 查看模组接口IP - AT+PING=X.X.X.X # 检查模组与网关的联通性,其中X.X.X.X需替换为实际的网关地址 - ``` - - **图3** Hi3861 WLAN模组联网成功示意图   - - ![zh-cn_image_0000001227114612](figures/zh-cn_image_0000001227114612.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-running.md deleted file mode 100644 index 0cb0b304b8157fe5a1adf5b37cd423c92ebde916..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-running.md +++ /dev/null @@ -1,19 +0,0 @@ -# 运行 - - -## 运行结果 - -示例代码编译、烧录、运行、调测后,重启开发板后将自动在界面输出如下结果: - - -``` -ready to OS start -FileSystem mount ok. -wifi init success! -[DEMO] Hello world. -``` - - -## 下一步学习 - -恭喜,您已完成Hi3861 WLAN模组快速上手!建议您下一步进入[WLAN产品开发](../guide/device-wlan-led-control.md)的学习 。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-hi3516.md deleted file mode 100644 index ffa925d2b6fc6ab25e1edbc8b618473dc8af5eb8..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-hi3516.md +++ /dev/null @@ -1,20 +0,0 @@ -# Hi3516开发板介绍 - - -## 开发板简介 - -Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP(Image Signal Processor)、H.265视频压缩编码器以及高性能NNIE引擎,具备低码率、高画质、低功耗等特点,并具备强劲的智能处理和分析能力。 - - **图1** Hi3516单板正面外观图   - -![zh-cn_image_0000001227082182](figures/zh-cn_image_0000001227082182.png) - - -## 开发板规格 - - **表1** Hi3516开发板规格清单 - -| 规格类型 | 规格清单 | -| -------- | -------- | -| **处理器及内部存储** | - Hi3516DV300芯片
- DDR3 1GB
- eMMC4.5,8GB容量 | -| **外部器件** | - 以太网口
- 音频视频
  - 1路语音输入
  - 1路单声道(AC_L)输出,接3W功放(LM4871)
  - MicroHDMI(1路HDMI 1.4)
- 摄像头
  - 传感器IMX335
  - 镜头M12,焦距4mm,光圈1.8
- 显示屏
  - LCD连接器(2.35寸)
  - LCD连接器(5.5寸)
- 外部器件及接口
  - SD卡接口
  - JTAG/I2S接口
  - ADC接口
  - 舵机接口
  - Grove连接器
  - USB2.0(Type C)
  - 功能按键3个,2个用户自定义按键,1个升级按键
  - LED指示灯,绿灯,红灯 | diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-create-project.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-create-project.md deleted file mode 100644 index ec82ec30048681ac246efdc3cbb6f583026abc75..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-create-project.md +++ /dev/null @@ -1,23 +0,0 @@ -# 导入源码工程 - - -在完成[搭建Windows+Ubuntu混合开发环境](../quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md)和[获取源码](../quick-start/quickstart-ide-standard-sourcecode-acquire.md)后,您需要在Windows环境中按照如下步骤导入源码工程,之后方可在DevEco Device Tool中进行后续的操作。 - - -1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 - - ![zh-cn_image_0000001278358765](figures/zh-cn_image_0000001278358765.png) - -2. 选择OpenHarmony源码根目录路径,然后再选择**Import OpenHarmony Source**选项,点击**Import**进行导入。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 工程存储路径不能包含中文字符、空格。如果工程存储路径包含中文字符或空格,可能导致编译失败。 - - ![zh-cn_image_0000001271477045](figures/zh-cn_image_0000001271477045.png) - -3. 在Import Project界面,选择**Product**后,会自动填充对应的SOC、Board、Company和Kernel信息,然后Ohos Ver选择对应的OpenHarmony源码版本。 - - ![zh-cn_image_0000001271448821](figures/zh-cn_image_0000001271448821.png) - -4. 点击**Open**打开工程或源码。 - diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md deleted file mode 100644 index 2aca8528314802708a912e73b784a351d4a8bbf0..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md +++ /dev/null @@ -1,190 +0,0 @@ -# 搭建Windows+Ubuntu混合开发环境 - - -通常在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,建议使用Ubuntu的编译环境对源码进行编译。 - - -在以上的设备开发场景中,可以搭建一套Windows+Ubuntu混合开发的环境,其中使用Windows平台的DevEco Device Tool可视化界面进行相关操作,通过远程连接的方式对接Ubuntu下的DevEco Device Tool(可以不安装Visual Studio Code),然后对Ubuntu下的源码进行开发、编译、烧录等操作。 - - -## 系统要求 - -- Windows系统要求:Windows10 64位系统。 - -- Ubuntu系统要求:Ubuntu18.04~21.10版本,内存推荐16 GB及以上。 - -- Ubuntu系统的用户名不能包含中文字符。 - -- Windows和Ubuntu系统上安装的DevEco Device Tool为3.0 Release版本。 - - -## 搭建Ubuntu环境 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> -> 如果没有Ubuntu系统,可在Windows系统中通过虚拟机方式搭建Ubuntu系统,具体请参考[Ubuntu系统安装指导](https://developer.huawei.com/consumer/cn/training/course/video/C101639987816176315)。Ubuntu系统安装完成后,请根据指导完成[Ubuntu基础环境配置](https://developer.huawei.com/consumer/cn/training/course/video/C101639988048536240),然后再根据本章节进行DevEco Device Tool工具的安装。 - -1. 将Ubuntu Shell环境修改为bash。 - 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2,将Ubuntu shell修改为bash。 - - ``` - ls -l /bin/sh - ``` - - ![zh-cn_image_0000001226764302](figures/zh-cn_image_0000001226764302.png) - 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 - - ``` - sudo dpkg-reconfigure dash - ``` - - ![zh-cn_image_0000001243641075](figures/zh-cn_image_0000001243641075.png) - -2. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Linux版本。 - -3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 - - 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.401.zip为软件包名称,请根据实际进行修改。 - - ``` - unzip devicetool-linux-tool-3.0.0.401.zip - ``` - 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.401.sh请根据实际进行修改。 - - ``` - chmod u+x devicetool-linux-tool-3.0.0.401.sh - ``` - -4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.401.sh请根据实际进行修改。 - - ``` - sudo ./devicetool-linux-tool-3.0.0.401.sh - ``` - -5. 在用户协议和隐私声明签署界面,请详细阅读用户协议和隐私声明,需签署同意用户协议和隐私声明才能进行下一步的安装。 - - ![zh-cn_image_0000001322167645.png](figures/zh-cn_image_0000001322167645.png) - - 安装完成后,当界面输出“DevEco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 - - ![zh-cn_image_0000001198722374](figures/zh-cn_image_0000001198722374.png) - - - -## 搭建Windows开发环境 - -1. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Windows版。 - -2. 解压DevEco Device Tool压缩包,双击安装包程序,点击Next进行安装。 - -3. 设置DevEco Device Tool的安装路径,请注意安装路径不能包含中文字符,同时建议安装到非系统盘符,点击**Next**。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如果您已安装DevEco Device Tool 3.0 Beta2及以前的版本,则在安装新版本时,会先卸载旧版本,卸载过程中出现如下错误提示时,请点击“Ignore”继续安装,该错误不影响新版本的安装。 - > - > ![zh-cn_image_0000001239275843](figures/zh-cn_image_0000001239275843.png) - - ![zh-cn_image_0000001270076961](figures/zh-cn_image_0000001270076961.png) - -4. 根据安装向导提示,勾选要自动安装的软件。 - 1. 在弹出VSCode installation confirm页面,勾选“Install VScode 1.62.2automatically”,点击**Next**。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果检测到Visual Studio Code已安装,且版本为1.62及以上,则会跳过该步骤。 - - ![zh-cn_image_0000001237801283](figures/zh-cn_image_0000001237801283.png) - - 2. 在弹出的Python select page选择“Download from Huawei mirror”,点击**Next**。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果系统已安装可兼容的Python版本(Python 3.8~3.9版本),可选择“Use one of compatible on your PC”。 - - ![zh-cn_image_0000001193983334](figures/zh-cn_image_0000001193983334.png) - -5. 在以下界面点击**Next**。 - - ![zh-cn_image_0000001259180828](figures/zh-cn_image_0000001259180828.png) - -6. 请详细阅读以下界面的用户协议和隐私声明,这里须勾选"I accept the licenses",然后点击Next,安装向导才会继续进行软件下载和安装。 - - ![zh-cn_image_0000001307019009](figures/zh-cn_image_0000001307019009.png) - -7. 继续等待DevEco Device Tool安装向导自动安装DevEco Device Tool插件,直至安装完成,点击**Finish**,关闭DevEco Device Tool安装向导。 - - ![zh-cn_image_0000001239650137](figures/zh-cn_image_0000001239650137.png) - -8. 打开Visual Studio Code,进入DevEco Device Tool工具界面。至此,DevEco Device Tool Windows开发环境安装完成。 - - ![zh-cn_image_0000001225760456](figures/zh-cn_image_0000001225760456.png) - - -## 配置Windows远程访问Ubuntu环境 - - -### 安装SSH服务并获取远程访问的IP地址 - -1. 在Ubuntu系统中,打开终端工具,执行如下命令安装SSH服务。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如果执行该命令失败,提示openssh-server和openssh-client依赖版本不同,请根据CLI界面提示信息,安装openssh-client相应版本后(例如:sudo apt-get install openssh-client=1:8.2p1-4),再重新执行该命令安装openssh-server。 - - - ``` - sudo apt-get install openssh-server - ``` - -2. 执行如下命令,启动SSH服务。 - - ``` - sudo systemctl start ssh - ``` - -3. 执行如下命令,获取当前用户的IP地址,用于Windows系统远程访问Ubuntu环境。 - - ``` - ifconfig - ``` - - ![zh-cn_image_0000001215737140](figures/zh-cn_image_0000001215737140.png) - - -### 安装Remote SSH - -1. 打开Windows系统下的Visual Studio Code,点击![zh-cn_image_0000001239080359](figures/zh-cn_image_0000001239080359.png),在插件市场的搜索输入框中输入“remote-ssh”。 - - ![zh-cn_image_0000001193920448](figures/zh-cn_image_0000001193920448.png) - -2. 点击Remote-SSH的**Install**按钮,安装Remote-SSH。安装成功后,在**INSTALLED**下可以看到已安装Remote-SSH。 - - ![zh-cn_image_0000001238880335](figures/zh-cn_image_0000001238880335.png) - - -### 远程连接Ubuntu环境 - -1. 打开Windows系统的Visual Studio Code,点击![zh-cn_image_0000001238760373](figures/zh-cn_image_0000001238760373.png),在REMOTE EXPLORER页面点击+按钮。 - - ![zh-cn_image_0000001215878922](figures/zh-cn_image_0000001215878922.png) - -2. 在弹出的SSH连接命令输入框中输入“ssh _username_\@_ip_address_”,其中ip_address为要连接的远程计算机的IP地址,username为登录远程计算机的帐号。 - - ![zh-cn_image_0000001215879750](figures/zh-cn_image_0000001215879750.png) - -3. 在弹出的输入框中,选择SSH configuration文件,选择默认的第一选项即可。 - - ![zh-cn_image_0000001260519729](figures/zh-cn_image_0000001260519729.png) - -4. 在SSH TARGETS中,找到远程计算机,点击![zh-cn_image_0000001194080414](figures/zh-cn_image_0000001194080414.png),打开远程计算机。 - - ![zh-cn_image_0000001215720398](figures/zh-cn_image_0000001215720398.png) - -5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机 。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 在Windows系统远程访问Ubuntu过程中,需要频繁的输入密码进行连接,为解决该问题,您可以使用SSH公钥来进行设置,设置方法请参考[注册远程访问Ubuntu环境的公钥](https://device.harmonyos.com/cn/docs/documentation/guide/ide-registering-public-key-0000001247162706)。 - - ![zh-cn_image_0000001215897530](figures/zh-cn_image_0000001215897530.png) - - 连接成功后,等待在远程计算机.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。 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 deleted file mode 100644 index cffc577473ef8d842cc2c13517a113008295d36a..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md +++ /dev/null @@ -1,41 +0,0 @@ -# 标准系统入门概述 - - -## 简介 - -OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文,开发者可以快速熟悉OpenHarmony标准系统的环境搭建、编译、烧录、调测以及运行“Hello World”等。 - -考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: - -- IDE方式:完全采用IDE(DevEco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 - -- 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 - OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 - -本文采用DevEco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[标准系统快速入门(安装包方式)](quickstart-standard-overview.md)。 - - -## 开发环境 - -推荐开发者采用Windows+Ubuntu环境进行OpenHarmony开发: - -- Windows:用于源码开发、烧录等。 - -- Ubuntu:用于源码编译。 - -本文将介绍如何基于Windows+Ubuntu环境进行OpenHarmony的开发。 - - -## 开发板 - -本文选取了两款典型开发板:Hi3516DV300、RK3568,并基于上述两款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-ide-standard-board-introduction-hi3516.md),开发者可根据需要自行购买开发板。 - - -## 开发流程 - -标准系统快速入门流程如下图所示: - - **图1** 标准系统快速入门开发流程 - -  - ![zh-cn_image_0000001271562257](figures/zh-cn_image_0000001271562257.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-build.md deleted file mode 100644 index 69cd37abf642a33c9710e3adc052e58c31eae7ce..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-build.md +++ /dev/null @@ -1,35 +0,0 @@ -# 编译 - - -1. 在Projects中,点击**Settings**按钮,进入Hi3516DV300配置界面。 - - ![zh-cn_image_0000001265492885](figures/zh-cn_image_0000001265492885.png) - -2. 在Tool Chain页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**Install**按钮,自动安装所需工具链。 - - ![zh-cn_image_0000001227277128](figures/zh-cn_image_0000001227277128.png) - -3. 安装Hi3516DV300相关工具链,部分工具安装需要使用root权限,请在“TERMINAL”窗口输入用户密码进行安装。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 - - ![zh-cn_image_0000001220852755](figures/zh-cn_image_0000001220852755.png) - - 工具链自动安装完成后如下图所示。 - - ![zh-cn_image_0000001227757036](figures/zh-cn_image_0000001227757036.png) - -4. 在“hi3516dv300”配置页签中,设置源码的编译类型**build_type**,默认为“debug“类型,请根据需要进行修改。然后点击**Save**按钮进行保存。 - - ![zh-cn_image_0000001221172711](figures/zh-cn_image_0000001221172711.png) - -5. 在“PROJECT TASKS”中,点击对应开发板下的**Build**按钮,执行编译。 - - ![zh-cn_image_0000001265772913](figures/zh-cn_image_0000001265772913.png) - -6. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 - - ![zh-cn_image_0000001221012768](figures/zh-cn_image_0000001221012768.png) - - 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[Hi3516DV300开发板烧录](quickstart-ide-standard-running-hi3516-burning.md)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-burning.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-burning.md deleted file mode 100644 index 31cc342d29853acb97c9d7207df8cf18f733cc30..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-burning.md +++ /dev/null @@ -1,66 +0,0 @@ -# 烧录 - - -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 - -Hi3516DV300开发板小型系统的烧录方式包括USB烧录、网口烧录两种方式,本文采用USB方式进行烧录。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 使用USB烧录方式,在DevEco Device Tool 2.2 Beta2及更高版本中支持。 - - -1. 请连接好电脑和待烧录开发板,需要连接USB口和串口,具体可参考[Hi3516DV300开发板介绍](quickstart-lite-introduction-hi3516.md)。 - -2. 根据[Hi3516DV300开发板串口驱动安装指导](https://gitee.com/link?target=https%3A%2F%2Fdevice.harmonyos.com%2Fcn%2Fdocs%2Fdocumentation%2Fguide%2Fhi3516_hi3518-drivers-0000001050743695)、[Hi3516DV300开发板USB驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)安装USB驱动及USB转串口的驱动。若您的设备中已安装此驱动,请忽略该步骤。 - -3. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 - - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 - - ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) - -4. 在菜单栏中点击**Project Settings**按钮,进入Hi3516DV300工程配置界面。 - - ![zh-cn_image_0000001198566364](figures/zh-cn_image_0000001198566364.png) - -5. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 - - ![zh-cn_image_0000001198566365](figures/zh-cn_image_0000001198566365.png) - -6. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 - - - upload_partitions:选择待烧录程序的配置文件(已预置默认的配置文件),该配置文件会指定烧录文件名称、起始烧录地址、地址长度等信息;同时请勾选**Enable to use upload_partitions_profile for upload**选项。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如需修改烧录profile文件,在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 - > - > 首次烧录,请勾选**Enable to use upload_partitions_profile for upload**选项,会自动生成upload_partitions文件。再次烧录时,可根据实际情况选择生成upload_partitions文件进行自定义烧录,也可以再勾选**Enable to use upload_partitions_profile for upload**选项,使用upload_partitions_profile重新生成upload_partitions文件用于烧录。 - - - upload_protocol:选择烧录协议,固定选择“hiburn-usb”。 - - - upload_port:选择已查询的串口号。 - - ![zh-cn_image_0000001177478136](figures/zh-cn_image_0000001177478136.png) - -7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -8. 点击hi3516dv300下的**Upload**按钮。 - - ![zh-cn_image_0000001267532292](figures/zh-cn_image_0000001267532292.png) - - 此时待烧录文件会从Ubuntu系统传输到Windows下,传输完成后界面显示“Operation paused, Please press Enter key to continue”时,请点击**Enter**键启动烧录。 - - ![zh-cn_image_0000001114129427](figures/zh-cn_image_0000001114129427.png) - -9. 在终端窗口显示如下提示信息时,请在15秒内,按住Update键,插拔USB线,最后松开Update键启动烧录。 - - ![zh-cn_image_0000001326412233.png](figures/zh-cn_image_0000001326412233.png) - - 启动烧录后,界面提示**SUCCESS**信息时,表示烧录成功。 - - ![zh-cn_image_0000001160649344](figures/zh-cn_image_0000001160649344.png) - -11. 烧录成功后,请根据运行章节进行操作,启动系统。 \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-running.md deleted file mode 100644 index 862d9d8eeb6b3e574264a79e8aff4e8cb0a66556..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-running.md +++ /dev/null @@ -1,57 +0,0 @@ -# 运行 - - -## 启动系统 - -烧录完成后通过以下步骤启动系统: - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 初次烧写标准系统,需要完成以下配置,后续烧写或者启动,可以跳过以下操作。 - -1. 在DevEco Device Tool中,点击Monitor,打开串口工具。 - - ![zh-cn_image_0000001227082162](figures/zh-cn_image_0000001227082162.png) - -2. 重启开发板,在倒计时结束前,按任意键进入系统。 - - ![zh-cn_image_0000001271202289](figures/zh-cn_image_0000001271202289.gif) - -3. 通过以下两条命令设置启动参数。 - - ``` - setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)'; - ``` - - - ``` - setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000' - ``` - - ![zh-cn_image_0000001271562269](figures/zh-cn_image_0000001271562269.png) - -4. 保存参数设置。 - - ``` - save - ``` - - ![zh-cn_image_0000001226762210](figures/zh-cn_image_0000001226762210.png) - -5. 重启开发板,完成系统启动。 - - ``` - reset - ``` - - ![zh-cn_image_0000001226602238](figures/zh-cn_image_0000001226602238.png) - - -## 运行“Hello World” - -设备启动后打开串口工具,在任意目录下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 - -![zh-cn_image_0000001271322277](figures/zh-cn_image_0000001271322277.png) - -## 下一步 - -恭喜!您已经完成了OpenHarmony标准系统的快速入门,接下来可[开发一个小示例](../guide/device-clock-guide.md),进一步熟悉OpenHarmony的开发。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-build.md deleted file mode 100644 index af04bf580d6b453a928e221207f573e2e88dc6aa..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-build.md +++ /dev/null @@ -1,35 +0,0 @@ -# 编译 - - -1. 在菜单栏中点击**Project Settings**按钮,进入RK3568工程配置界面。 - - ![zh-cn_image_0000001265492885](figures/zh-cn_image_0000001265492885.png) - -2. 在Toolchain页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**Install**按钮,自动安装所需工具链。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 - - ![zh-cn_image_0000001221356692](figures/zh-cn_image_0000001221356692.png) - - 安装RK3568相关工具链,部分工具的安装需要使用root权限,请在“TERMINAL”窗口输入用户密码进行安装。 - - ![zh-cn_image_0000001327429541.png](figures/zh-cn_image_0000001327429541.png) - - 工具链自动安装完成后如下图所示。 - - ![zh-cn_image_0000001265676877](figures/zh-cn_image_0000001265676877.png) - -3. 在“hh_scdy200”配置页签中,设置源码的编译类型**build_type**,默认为"debug类型,请根据需要进行修改。然后点击**Save**按钮进行保存。 - - ![zh-cn_image_0000001276354454.png](figures/zh-cn_image_0000001276354454.png) - -4. 在DevEco Device Tool界面的“PROJECT TASKS”中,点击对应开发板下的**Build**按钮,执行编译。 - - ![zh-cn_image_0000001265516901](figures/zh-cn_image_0000001265516901.png) - -5. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 - - ![zh-cn_image_0000001222361042](figures/zh-cn_image_0000001222361042.png) - - 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[RK3568开发板烧录](quickstart-standard-running-rk3568-burning.md)。 \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md deleted file mode 100644 index 52365db0887c7792c76fee7de2a14f0da820279a..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md +++ /dev/null @@ -1,61 +0,0 @@ -# 烧录 - - -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 - -RK3568的镜像烧录通过Windows环境进行烧录,开发者启动烧录操作后,DevEco Device Tool通过Remote远程模式,将Ubuntu环境下编译生成的带烧录程序文件拷贝至Windows目录下,然后通过Windows的烧录工具将程序文件烧录至开发板中。 - - -1. [下载](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows/DriverAssitant_v5.1.1.zip)并安装驱动DriverInstall.exe。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如果已经安装旧版本的烧写工具,请先点击"驱动卸载"按钮卸载驱动,然后再点击"驱动安装"按钮安装驱动。 - -2. 请连接好电脑和待烧录开发板,连接USB接口,具体可参考[RK3568开发板介绍](quickstart-standard-board-introduction-rk3568.md)。 - -3. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 - - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 - - ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) - - -4. 在菜单栏中点击**Project Settings**按钮,进入RK3568工程配置界面。 - - ![zh-cn_image_0000001198566364](figures/zh-cn_image_0000001198566364.png) - -5. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 - - ![zh-cn_image_0000001239661509](figures/zh-cn_image_0000001239661509.png) - - -6. 在“hh_scdy200”页签,设置烧录选项,包括upload_partitions和upload_protocol。 - - - upload_partitions_profile:选择待烧录程序的配置文件,该配置文件会指定烧录文件名称、起始烧录地址、地址长度等信息;同时请勾选**Enable to use upload_partitions_profile for upload**选项。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如需修改烧录profile文件,在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 - > - > 首次烧录,请勾选**Enable to use upload_partitions_profile for upload**选项,会自动生成upload_partitions文件。再次烧录时,可根据实际情况选择生成upload_partitions文件进行自定义烧录,也可以再勾选**Enable to use upload_partitions_profile for upload**选项,使用upload_partitions_profile重新生成upload_partitions文件用于烧录。 - - - upload_protocol:选择烧录协议,固定选择“upgrade”。 - - ![zh-cn_image_0000001194504874](figures/zh-cn_image_0000001194504874.png) - -7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -8. 在“PROJECT TASKS”中,点击hh_scdy200下的**Upload**按钮启动烧录。 - - ![zh-cn_image_0000001194821710](figures/zh-cn_image_0000001194821710.png) - -9. 当屏幕提示“Operation paused,Please press Enter key to continue”,请按回车键继续。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如果开发板未处于烧录模式,屏幕会提示“The board is not in Loader mode.Please Hold on the VOL+key...”,此时,请长按音量+键,3秒后点击RESET键,然后再过3秒放开音量+键,使开发板进入烧录模式。 - - 等待开发板烧录完成,当屏幕提示如下信息时,表示烧录成功。 - - ![zh-cn_image_0000001194984912](figures/zh-cn_image_0000001194984912.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-running.md deleted file mode 100644 index 649bd3b631ab879c825156347e1440ad405e1055..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-running.md +++ /dev/null @@ -1,21 +0,0 @@ -# 运行 - - -## 启动系统 - -镜像烧录完成重启开发板后,系统将会自动启动。开发板附带的屏幕呈现以下界面,表明系统已运行成功。 - - **图1** 系统启动效果图   - -![zh-cn_image_0000001226762222](figures/zh-cn_image_0000001226762222.jpg) - - -## 运行“Hello World” - -1. 设备启动后打开串口工具(以putty为例),波特率设置为1500000,连接设备。 - - ![zh-cn_image_0000001226602250](figures/zh-cn_image_0000001226602250.png) - -2. 打开串口后,在任意目录(以设备根目录为例)下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 - - ![zh-cn_image_0000001226922154](figures/zh-cn_image_0000001226922154.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-sourcecode-acquire.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-sourcecode-acquire.md deleted file mode 100644 index 61042cdc21a5b90f62344abe7dfbba0f402ddf28..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-sourcecode-acquire.md +++ /dev/null @@ -1,91 +0,0 @@ -# 获取源码 - - -在Ubuntu环境下通过以下步骤获取OpenHarmony源码。 - - -## 前提条件 - -1. 注册码云gitee帐号。 - -2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 - -3. 安装git客户端和git-lfs。(上述工具已在搭建环境章节安装。如已安装,请忽略) - - 更新软件源: - - ``` - sudo apt-get update - ``` - - 通过以下命令安装: - - ``` - sudo apt-get install git git-lfs - ``` - -4. 配置用户信息。 - - ``` - git config --global user.name "yourname" - git config --global user.email "your-email-address" - git config --global credential.helper store - ``` - -5. 执行如下命令安装码云repo工具。 - - 下述命令中的安装路径以"~/bin"为例,请用户自行创建所需目录。 - - ``` - mkdir ~/bin - curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo - chmod a+x ~/bin/repo - pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests - ``` - -6. 将repo添加到环境变量。 - - ``` - vim ~/.bashrc # 编辑环境变量 - export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息 - source ~/.bashrc # 应用环境变量 - ``` - - -## 获取方式 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> -> Master主干为开发分支,开发者可通过Master主干获取最新特性。发布分支代码相对比较稳定,开发者可基于发布分支代码进行商用功能开发。 - -- **OpenHarmony主干代码获取** - - 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 - - ``` - repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - - 方式二:通过repo + https下载。 - - - ``` - repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - -- **OpenHarmony发布分支代码获取** - - OpenHarmony各个版本发布分支的源码获取方式请参考[Release-Notes](../../release-notes/Readme.md)。 - - -### 执行prebuilts - - 在源码根目录下执行prebuilts脚本,安装编译器及二进制工具。 - -``` -bash build/prebuilts_download.sh -``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide.md b/zh-cn/device-dev/quick-start/quickstart-ide.md new file mode 100644 index 0000000000000000000000000000000000000000..71922baa6fda1c56abffed4f57542990f2ac6701 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide.md @@ -0,0 +1,25 @@ +# 使用IDE快速入门 + + +- 基于IDE入门 + - 搭建开发环境 + - [搭建Windows环境](quickstart-ide-env--win.md) + - [搭建Ubuntu环境](quickstart-ide-env-ubuntu.md) + - [配置远程访问环境](quickstart-ide-env-remote.md) + - [创建工程并获取源码](quickstart-ide-import-project.md) + - 轻量系统(基于Hi3861开发板) + - [编写“Hello World”程序](quickstart-ide-3861-helloworld.md) + - [编译](quickstart-ide-3861-build.md) + - [烧录](quickstart-ide-3861-burn.md) + - [运行](quickstart-ide-3861-running.md) + - 小型系统(基于Hi3516开发板) + - [编写“Hello World”程序](quickstart-ide-3516-helloworld.md) + - [编译](quickstart-ide-3516-build.md) + - [烧录](quickstart-ide-3516-burn.md) + - [运行](quickstart-ide-3516-running.md) + - 标准系统(基于RK3568开发板) + - [编写“Hello World”程序](quickstart-ide-3568-helloworld.md) + - [编译](quickstart-ide-3568-build.md) + - [烧录](quickstart-ide-3568-burn.md) + - [运行](quickstart-ide-3568-running.md) + diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md b/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md deleted file mode 100644 index 4191e188ce30666c067fd2e130d20593c526903a..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md +++ /dev/null @@ -1,422 +0,0 @@ -# 搭建轻量与小型系统环境 - - -## 系统要求 - -- Windows系统要求:Windows10 64位系统。 - -- Ubuntu系统要求:Ubuntu18.04~21.10版本,内存推荐16 GB及以上。 - -- Windows系统和Ubuntu系统的用户名不能包含中文字符。 - -- Windows和Ubuntu上安装的DevEco Device Tool为3.0 Release版本。 - - -## 安装必要的库和工具 - -编译OpenHarmony需要一些库和工具,可以通过以下步骤进行安装。 - -相应操作在Ubuntu环境中进行。 - -1. 使用如下apt-get命令安装后续操作所需的库和工具: - - ``` - 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 libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev - ``` - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中: - > - > - Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。 - > - > - Java要求java8及以上版本,此处以java8为例。 - -2. 将python 3.8设置为默认python版本。 - - 查看python 3.8的位置: - - - ``` - which python3.8 - ``` - - 将python和python3切换为python3.8: - - ``` - sudo update-alternatives --install /usr/bin/python python {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置 - sudo update-alternatives --install /usr/bin/python3 python3 {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置 - ``` - - -## 安装DevEco Device Tool - -通过Windows系统远程访问Ubuntu环境进行烧录等操作,需要先在Windows和Ubuntu下分别安装DevEco Device Tool。 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> DevEco Device Tool是OpenHarmony的一站式开发工具,支持源码开发、编译、烧录,调测等,本文主要用其远端连接Ubuntu环境进行烧录和运行。 - - -### 安装Window版本DevEco Device Tool - -1. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Windows版。 - -2. 解压DevEco Device Tool压缩包,双击安装包程序,点击Next进行安装。 - -3. 设置DevEco Device Tool的安装路径,请注意安装路径不能包含中文字符,同时建议安装到非系统盘符,点击**Next**。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果您已安装DevEco Device Tool 3.0 Beta2及以前的版本,则在安装新版本时,会先卸载旧版本,卸载过程中出现如下错误提示时,请点击“Ignore”继续安装,该错误不影响新版本的安装。 - > - > ![zh-cn_image_0000001239275843](figures/zh-cn_image_0000001239275843.png) - - ![zh-cn_image_0000001270076961](figures/zh-cn_image_0000001270076961.png) - -4. 根据安装向导提示,勾选要自动安装的软件。 - - 1. 在弹出VSCode installation confirm页面,勾选“Install VScode 1.62.2automatically”,点击**Next**。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果检测到Visual Studio Code已安装,且版本为1.62及以上,则会跳过该步骤。 - - ![zh-cn_image_0000001237801283](figures/zh-cn_image_0000001237801283.png) - - 2. 在弹出的Python select page选择“Download from Huawei mirror”,点击**Next**。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果系统已安装可兼容的Python版本(Python 3.8~3.9版本),可选择“Use one of compatible on your PC”。 - - - ![zh-cn_image_0000001193983334](figures/zh-cn_image_0000001193983334.png) - -5. 在以下界面点击**Next**。 - - ![zh-cn_image_0000001259180828](figures/zh-cn_image_0000001259180828.png) - -6. 请详细阅读以下界面的用户协议和隐私声明,这里须勾选"I accept the licenses",然后点击Next,安装向导才会继续进行软件下载和安装。 - - ![zh-cn_image_0000001307019009](figures/zh-cn_image_0000001307019009.png) - -7. 继续等待DevEco Device Tool安装向导自动安装DevEco Device Tool插件,直至安装完成,点击**Finish**,关闭DevEco Device Tool安装向导。 - - ![zh-cn_image_0000001239650137](figures/zh-cn_image_0000001239650137.png) - -8. 打开Visual Studio Code,进入DevEco Device Tool工具界面。至此,DevEco Device Tool Windows开发环境安装完成。 - - ![zh-cn_image_0000001225760456](figures/zh-cn_image_0000001225760456.png) - - -### 安装Ubuntu版本DevEco Device Tool - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 如果没有Ubuntu系统,可在Windows系统中通过虚拟机方式搭建Ubuntu系统,具体请参考[Ubuntu系统安装指导](https://developer.huawei.com/consumer/cn/training/course/video/C101639987816176315)。Ubuntu系统安装完成后,请根据指导完成[Ubuntu基础环境配置](https://developer.huawei.com/consumer/cn/training/course/video/C101639988048536240),然后再根据本章节进行DevEco Device Tool工具的安装。 - -1. 将Ubuntu Shell环境修改为bash。 - - 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2,将Ubuntu shell修改为bash。 - - ``` - ls -l /bin/sh - ``` - - ![zh-cn_image_0000001226764302](figures/zh-cn_image_0000001226764302.png) - - 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 - - ``` - sudo dpkg-reconfigure dash - ``` - - ![zh-cn_image_0000001243641075](figures/zh-cn_image_0000001243641075.png) - -2. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Linux版本。 - -3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 - - 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.401.zip为软件包名称,请根据实际进行修改。 - - ``` - unzip devicetool-linux-tool-3.0.0.401.zip - ``` - 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.401.sh请根据实际进行修改。 - - ``` - chmod u+x devicetool-linux-tool-3.0.0.401.sh - ``` - -4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.401.sh请根据实际进行修改。 - - ``` - sudo ./devicetool-linux-tool-3.0.0.401.sh - ``` - -5. 在用户协议和隐私声明签署界面,请详细阅读用户协议和隐私声明,需签署同意用户协议和隐私声明才能进行下一步的安装。 - - - - ![zh-cn_image_0000001322167645.png](figures/zh-cn_image_0000001322167645.png) - - 安装完成后,当界面输出“DevEco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 - - ![zh-cn_image_0000001198722374](figures/zh-cn_image_0000001198722374.png) - - -## 配置Windows远程访问Ubuntu环境 - - -### 安装SSH服务并获取远程访问的IP地址 - -1. 在Ubuntu系统中,打开终端工具,执行如下命令安装SSH服务。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果执行该命令失败,提示openssh-server和openssh-client依赖版本不同,请根据CLI界面提示信息,安装openssh-client相应版本后(例如:sudo apt-get install openssh-client=1:8.2p1-4),再重新执行该命令安装openssh-server。 - - - ``` - sudo apt-get install openssh-server - ``` - -2. 执行如下命令,启动SSH服务。 - - ``` - sudo systemctl start ssh - ``` - -3. 执行如下命令,获取当前用户的IP地址,用于Windows系统远程访问Ubuntu环境。 - - ``` - ifconfig - ``` - - ![zh-cn_image_0000001215737140](figures/zh-cn_image_0000001215737140.png) - - -### 安装Remote SSH - -1. 打开Windows系统下的Visual Studio Code,点击![zh-cn_image_0000001239080359](figures/zh-cn_image_0000001239080359.png),在插件市场的搜索输入框中输入“remote-ssh”。 - - ![zh-cn_image_0000001193920448](figures/zh-cn_image_0000001193920448.png) - -2. 点击Remote-SSH的**Install**按钮,安装Remote-SSH。安装成功后,在**INSTALLED**下可以看到已安装Remote-SSH。 - - ![zh-cn_image_0000001238880335](figures/zh-cn_image_0000001238880335.png) - - -### 远程连接Ubuntu环境 - -1. 打开Windows系统的Visual Studio Code,点击![zh-cn_image_0000001238760373](figures/zh-cn_image_0000001238760373.png),在REMOTE EXPLORER页面点击+按钮。 - - ![zh-cn_image_0000001215878922](figures/zh-cn_image_0000001215878922.png) - -2. 在弹出的SSH连接命令输入框中输入“ssh _username_\@_ip_address_”,其中ip_address为要连接的远程计算机的IP地址,username为登录远程计算机的帐号。 - - ![zh-cn_image_0000001215879750](figures/zh-cn_image_0000001215879750.png) - -3. 在弹出的输入框中,选择SSH configuration文件,选择默认的第一选项即可。 - - ![zh-cn_image_0000001260519729](figures/zh-cn_image_0000001260519729.png) - -4. 在SSH TARGETS中,找到远程计算机,点击![zh-cn_image_0000001194080414](figures/zh-cn_image_0000001194080414.png),打开远程计算机。 - - ![zh-cn_image_0000001215720398](figures/zh-cn_image_0000001215720398.png) - -5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机 。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 在Windows系统远程访问Ubuntu过程中,需要频繁的输入密码进行连接,为解决该问题,您可以使用SSH公钥来进行设置,设置方法请参考[注册远程访问Ubuntu环境的公钥](https://device.harmonyos.com/cn/docs/documentation/guide/ide-registering-public-key-0000001247162706)。 - - ![zh-cn_image_0000001215897530](figures/zh-cn_image_0000001215897530.png) - - 连接成功后,等待在远程计算机.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。 - - -## 获取源码 - -在Ubuntu环境下通过以下步骤获取OpenHarmony源码。 - - -### 准备工作 - -1. 注册码云gitee帐号。 - -2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 - -3. 安装git客户端和git-lfs。(上述工具已在安装必要的库和工具小节安装。如已安装,请忽略) - - 更新软件源: - - ``` - sudo apt-get update - ``` - - 通过以下命令安装: - - ``` - sudo apt-get install git git-lfs - ``` - -4. 配置用户信息。 - - ``` - git config --global user.name "yourname" - git config --global user.email "your-email-address" - git config --global credential.helper store - ``` - -5. 执行如下命令安装码云repo工具。 - - 下述命令中的安装路径以"~/bin"为例,请用户自行创建所需目录。 - - ``` - mkdir ~/bin - curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo - chmod a+x ~/bin/repo - pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests - ``` - -6. 将repo添加到环境变量。 - - ``` - vim ~/.bashrc # 编辑环境变量 - export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息 - source ~/.bashrc # 应用环境变量 - ``` - - -### 获取方式 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> Master主干为开发分支,开发者可通过Master主干获取最新特性。发布分支代码相对比较稳定,开发者可基于发布分支代码进行商用功能开发。 - -- **OpenHarmony主干代码获取** - - 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 - - ``` - repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - - 方式二:通过repo + https下载。 - - - ``` - repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - -- **OpenHarmony发布分支代码获取** - - OpenHarmony各个版本发布分支的源码获取方式请参考[Release-Notes](../../release-notes/Readme.md)。 - - -### 执行prebuilts - - 在源码根目录下执行prebuilts脚本,安装编译器及二进制工具。 - -``` -bash build/prebuilts_download.sh -``` - - -## 安装编译工具 - -想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建指导](../subsystems/subsys-build-all.md)。 - -相关操作在Ubuntu环境下进行。 - - -### 安装hb - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 如需安装代理,请参考[配置代理](../quick-start/quickstart-lite-reference.md#配置代理)。 - -1. 运行如下命令安装hb并更新至最新版本 - - ``` - pip3 install --user build/lite - ``` - -2. 设置环境变量 - - ``` - vim ~/.bashrc - ``` - - 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 - - ``` - export PATH=~/.local/bin:$PATH - ``` - - 执行如下命令更新环境变量。 - - ``` - source ~/.bashrc - ``` - -3. 在源码目录执行"hb -h",界面打印以下信息即表示安装成功: - - ``` - 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 - ``` - -> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** -> - 可采用以下命令卸载hb: -> -> ``` -> pip3 uninstall ohos-build -> ``` -> -> - 若安装hb的过程中遇到问题,请参见下文[常见问题](../quick-start/quickstart-lite-faq-hb.md)进行解决。 - - -### 安装LLVM(仅OpenHarmony_v1.x分支/标签需要) - -> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** -> 如果下载的源码为OpenHarmony_v1.x分支/标签,请按下面的步骤安装12.0.1版本的llvm。 -> -> 如果下载的源码为Master及非OpenHarmony_v1.x分支/标签,可直接跳过本小节,hb会自动下载最新的llvm。 - -1. 打开Linux编译服务器终端。 - -2. [下载LLVM工具](https://repo.huaweicloud.com/openharmony/compiler/clang/12.0.1-530132/linux/clang-530132-linux-x86_64.tar.bz2)。 - -3. 解压LLVM安装包至~/llvm路径下。 - - ``` - tar -jxvf clang.tar.bz2 -C ~/ - mv ~/clang-530132/ ~/llvm - ``` - -4. 设置环境变量。 - - ``` - vim ~/.bashrc - ``` - - 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 - - - ``` - export PATH=~/llvm/bin:$PATH - ``` - -5. 生效环境变量。 - - ``` - source ~/.bashrc - ``` 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 deleted file mode 100644 index 548e6164d6e4825b97621f001209a910a9cf2b68..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-faq-burning.md +++ /dev/null @@ -1,128 +0,0 @@ -# 烧录异常 - - -## 烧写选择串口后提示“Error: Opening COMxx: Access denied” - -- **现象描述** - 点击烧写并选择串口后,出现Error: Opening COMxx: Access denied。 - - **图1** 打开串口失败图  - - ![zh-cn_image_0000001226634728](figures/zh-cn_image_0000001226634728.png) - -- **可能原因** - 串口已经被占用。 - -- **解决办法** - -1. 按图依次选择下拉框,查找带有serial-xx的终端。 - - **图2** 查找是否存在占用串口的终端   - - ![zh-cn_image_0000001226954644](figures/zh-cn_image_0000001226954644.png) - -2. 点击标号中的垃圾桶图标,关闭串口。 - - **图3** 关闭串口终端  - - - ![zh-cn_image_0000001271234761](figures/zh-cn_image_0000001271234761.png) - -3. 重新点击烧写,选择串口并开始烧写程序。 - - **图4** 重新启动烧写任务   - - ![zh-cn_image_0000001271594765](figures/zh-cn_image_0000001271594765.png) - - -## Windows电脑与单板网络连接失败 - -- **现象描述** - 点击烧写并选择串口后,无法获取文件。 - - **图5** 网络不通,单板无法获取文件图   - - ![zh-cn_image_0000001271234757](figures/zh-cn_image_0000001271234757.png) - -- **可能原因** - 单板网络与Windows电脑不联通。 - - Windows电脑防火墙未允许Visual Studio Code联网。 - -- **解决方法** - -1. 检查网线是否连接。 - -2. 点击Windows防火墙。 - - **图6** 网络防火墙设置图   - - ![zh-cn_image_0000001226634732](figures/zh-cn_image_0000001226634732.png) - -3. 点击“允许应用通过防火墙”。 - - **图7** 防火墙和网络保护界面图   - - ![zh-cn_image_0000001271354749](figures/zh-cn_image_0000001271354749.png) - -4. 查找Visual Studio Code应用。 - - **图8** 查找Visual Studio Code应用图   - - ![zh-cn_image_0000001271234765](figures/zh-cn_image_0000001271234765.png) - -5. 勾选Visual Studio Code的专用和公用网络的访问权限。 - - **图9** 允许Visual Studio Code应用访问网络   - - ![zh-cn_image_0000001271474585](figures/zh-cn_image_0000001271474585.png) - - -## 烧写失败 - -- **现象描述** - 点击烧写并选择串口后,出现无法烧写的情况。 - -- **可能原因** - 安装IDE插件DevEco后未重启。 - -- **解决方法** - 重启IDE。 - - -## (Hi3516)串口无回显 - -- **现象描述** - 串口显示已连接,重启单板后,回车无任何回显。 - -- **可能原因1** - 串口连接错误。 - -- **解决办法** - 修改串口号。 - - 请查看设备管理器,确认连接单板的串口与终端中连接串口是否一致,若不一致,请按烧写选择串口后提示error-opening-comxx-access-denied修改串口号。 - -- **可能原因2** - 单板U-boot被损坏。 - -- **解决办法** - 烧写U-boot。 - - 若上述步骤依旧无法连接串口,可能由于单板U-boot损坏,按下述步骤烧写U-boot。 - -1. 获取引导文件U-boot。 - - > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** - > 单板的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)中描述的烧写方法,选择对应单板的U-boot文件进行烧写。 - -3. 烧写完成后,登录串口如下图所示。 - - **图10** U-boot烧写完成串口显示图  - - - ![zh-cn_image_0000001271234753](figures/zh-cn_image_0000001271234753.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-faq-hb.md b/zh-cn/device-dev/quick-start/quickstart-lite-faq-hb.md deleted file mode 100644 index 9accfa1781e1ae816c3d304f005e942809ffcf2c..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-faq-hb.md +++ /dev/null @@ -1,71 +0,0 @@ -# hb安装异常 - - -## hb安装过程中出现乱码、段错误 - -- **现象描述** - 执行“python3 -m pip install --user ohos-build”出现乱码、段错误(segmentation fault)。 - -- **可能原因** - pip版本过低。 - -- **解决办法** - 执行如下命令升级pip。 - - - ``` - python3 -m pip install -U pip - ``` - - -## hb安装过程中提示"cannot import 'sysconfig' from 'distutils'" - -- **现象描述** - 执行“python3 -m pip install --user ohos-build”提示"cannot import 'sysconfig' from 'distutils'" - -- **可能原因** - 缺少distutils模块。 - -- **解决办法** - 执行如下命令安装。 - - - ``` - sudo apt-get install python3.8-distutils - ``` - - -## hb安装过程中提示"module 'platform' has no attribute 'linux_distribution'" - -- **现象描述** - 执行“python3 -m pip install --user ohos-build”提示"module 'platform' has no attribute 'linux_distribution'" - -- **可能原因** - python3 pip安装兼容性问题。 - -- **解决办法** - 执行如下命令重新安装pip。 - - - ``` - sudo apt remove python3-pip - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python get-pip.py - ``` - - -## hb安装过程中提示"Could not find a version that satisfies the requirement ohos-build" - -- **现象描述** - 执行“python3 -m pip install --user ohos-build”提示"Could not find a version that satisfies the requirement ohos-build" - -- **可能原因** - 可能是网络环境较差导致的安装失败。 - -- **解决办法** - 1. 请检查网络连接是否正常。如果网络有问题,请修复网络问题后重新安装。 - 2. 若网络正常,请尝试指定临时pypi源的方式安装: - - ``` - python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ohos-build - ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-ide-directory.md b/zh-cn/device-dev/quick-start/quickstart-lite-ide-directory.md deleted file mode 100644 index 283321b0ad7b6f307cd71713c885f9bc1d69d981..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-ide-directory.md +++ /dev/null @@ -1,23 +0,0 @@ -## 轻量和小型系统快速入门(IDE方式) - -- [轻量与小型系统入门概述](quickstart-ide-lite-overview.md) -- 准备轻量与小型系统环境 - - [搭建Windows+Ubuntu混合开发环境](quickstart-ide-lite-env-setup-win-ubuntu.md) - - [获取源码](quickstart-ide-lite-sourcecode-acquire.md) -- [导入源码工程](quickstart-ide-lite-create-project.md) -- 运行“Hello World” - - Hi3861开发板 - - [编写“Hello World”程序](quickstart-ide-lite-steps-hi3861-helloworld.md) - - [编译](quickstart-ide-lite-steps-hi3861-building.md) - - [烧录](quickstart-ide-lite-steps-hi3861-burn.md) - - [联网](quickstart-ide-lite-steps-hi3861-netconfig.md) - - [调试验证](quickstart-ide-lite-steps-hi3861-debug.md) - - [运行](quickstart-ide-lite-steps-hi3861-running.md) - - Hi3516开发板 - - [编写“Hello World”程序](quickstart-ide-lite-steps-hi3516-helloworld.md) - - [编译](quickstart-ide-lite-steps-hi3516-building.md) - - [烧录](quickstart-ide-lite-steps-hi3516-burn.md) - - [运行](quickstart-ide-lite-steps-hi3516-running.md) -- 附录 - - [Hi3861开发板介绍](quickstart-ide-lite-introduction-hi3861.md) - - [Hi3516开发板介绍](quickstart-ide-lite-introduction-hi3516.md) \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3861.md b/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3861.md deleted file mode 100644 index 2dfd5c24e1fc416a7e9c35268616c1b2619b0ac6..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3861.md +++ /dev/null @@ -1,68 +0,0 @@ -# Hi3861开发板介绍 - - -## 简介 - -Hi3861开发板是一片大约2cm\*5cm大小的开发板,是一款高度集成的2.4GHz WLAN SoC芯片,集成IEEE 802.11b/g/n基带和RF(Radio Frequency)电路。支持OpenHarmony,并配套提供开放、易用的开发和调试运行环境。 - - **图1** Hi3861开发板外观图   - - ![zh-cn_image_0000001271474569](figures/zh-cn_image_0000001271474569.png) - -另外,Hi3861开发板还可以通过与Hi3861底板连接,扩充自身的外设能力,底板如下图所示。 - - **图2** Hi3861底板外观图   - -![zh-cn_image_0000001226954632](figures/zh-cn_image_0000001226954632.png) - -- RF电路包括功率放大器PA(Power Amplifier)、低噪声放大器LNA(Low Noise Amplifier)、RF Balun、天线开关以及电源管理等模块;支持20MHz标准带宽和5MHz/10MHz窄带宽,提供最大72.2Mbit/s物理层速率。 - -- Hi3861 WLAN基带支持正交频分复用(OFDM)技术,并向下兼容直接序列扩频(DSSS)和补码键控(CCK)技术,支持IEEE 802.11 b/g/n协议的各种数据速率。 - -- Hi3861芯片集成高性能32bit微处理器、硬件安全引擎以及丰富的外设接口,外设接口包括SPI(Synchronous Peripheral Interface)、UART(Universal Asynchronous Receiver & Transmitter)、I2C(The Inter Integrated Circuit)、PWM(Pulse Width Modulation)、GPIO(General Purpose Input/Output)和多路ADC(Analog to Digital Converter),同时支持高速SDIO2.0(Secure Digital Input/Output)接口,最高时钟可达50MHz;芯片内置SRAM(Static Random Access Memory)和Flash,可独立运行,并支持在Flash上运行程序。 - -- Hi3861芯片适用于智能家电等物联网智能终端领域。 - - **图3** Hi3861功能框图   - -![zh-cn_image_0000001226794688](figures/zh-cn_image_0000001226794688.png) - - -## 资源和约束 - -Hi3861开发板资源十分有限,整板共2MB FLASH,352KB RAM。在编写业务代码时,需注意资源使用效率。 - - -## 开发板规格 - - **表1** Hi3861开发板规格清单 - -| 规格类型 | 规格清单 | -| -------- | -------- | -| 通用规格 | - 1×1 2.4GHz频段(ch1~ch14)
- PHY支持IEEE 802.11b/g/n
- MAC支持IEEE802.11 d/e/h/i/k/v/w
- 内置PA和LNA,集成TX/RX Switch、Balun等
- 支持STA和AP形态,作为AP时最大支持6 个STA接入
- 支持WFA WPA/WPA2 personal、WPS2.0
- 支持与BT/BLE芯片共存的2/3/4 线PTA方案
- 电源电压输入范围:2.3V~3.6V
- IO电源电压支持1.8V和3.3V
- 支持RF自校准方案
- 低功耗:
  - Ultra Deep Sleep模式:5μA \@3.3V
  - DTIM1:1.5mA \@3.3V
  - DTIM3:0.8mA \@3.3V | -| PHY特性 | - 支持IEEE802.11b/g/n单天线所有的数据速率
- 支持最大速率:72.2Mbps\@HT20 MCS7
- 支持标准20MHz带宽和5M/10M窄带宽
- 支持STBC
- 支持Short-GI | -| MAC特性 | - 支持A-MPDU,A-MSDU
- 支持Blk-ACK
- 支持QoS,满足不同业务服务质量需求 | -| CPU子系统 | - 高性能 32bit微处理器,最大工作频率160MHz
- 内嵌SRAM 352KB、ROM 288KB
- 内嵌 2MB Flash | -| 外围接口 | - 1个SDIO接口、2个SPI接口、2个I2C接口、3个UART接口、15个GPIO接口、7路ADC输入、6路PWM、1个I2S接口(注:上述接口通过复用实现)
- 外部主晶体频率40M或24M | -| 其他信息 | - 封装:QFN-32,5mm×5mm
- 工作温度:-40℃ ~ +85℃ | - - -## OpenHarmony关键特性 - -OpenHarmony基于Hi3861平台提供了多种开放能力,提供的关键组件如下表所示。 - - **表2** OpenHarmony关键组件列表 - -| 组件名 | 能力介绍 | -| -------- | -------- | -| WLAN服务 | 提供WLAN服务能力。包括:station和hotspot模式的连接、断开、状态查询等。 | -| 模组外设控制 | 提供操作外设的能力。包括:I2C、I2S、ADC、UART、SPI、SDIO、GPIO、PWM、FLASH等。 | -| 分布式软总线 | 在OpenHarmony分布式网络中,提供设备被发现、数据传输的能力。 | -| 设备安全绑定 | 提供在设备互联场景中,数据在设备之间的安全流转的能力。 | -| 基础加解密 | 提供密钥管理、加解密等能力。 | -| 系统服务管理 | 系统服务管理基于面向服务的架构,提供了OpenHarmony统一化的系统服务开发框架。 | -| 启动引导 | 提供系统服务的启动入口标识。在系统服务管理启动时,调用bootstrap标识的入口函数,并启动系统服务。 | -| 系统属性 | 提供获取与设置系统属性的能力。 | -| 基础库 | 提供公共基础库能力。包括:文件操作、KV存储管理等。 | -| DFX | 提供DFX能力。包括:流水日志、时间打点等。 | -| XTS | 提供OpenHarmony生态认证测试套件的集合能力。 | diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-overview.md b/zh-cn/device-dev/quick-start/quickstart-lite-overview.md deleted file mode 100644 index f6de41cb0e96858a5fb0e75ab17fdab7bf5e9176..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-overview.md +++ /dev/null @@ -1,40 +0,0 @@ -# 轻量与小型系统入门概述 - - -## 简介 - -OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存≥128KiB)。通过本文,开发者可以快速熟悉OpenHarmony标准系统的环境搭建、编译、烧录、调测以及运行“Hello World”等。 - -考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: - -- IDE方式:完全采用IDE(DevEco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 - -- 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 - -本文采用安装包方式进行介绍,习惯使用DevEco Device Tool的开发者可参考[轻量与小型系统快速入门(IDE方式)](../quick-start/quickstart-ide-lite-overview.md)。 - - -## 开发环境 - -推荐开发者采用Windows+Ubuntu环境进行OpenHarmony开发: - -- Windows:用于源码开发、烧录等。 - -- Ubuntu:用于源码编译。 - -本文将介绍如何基于Windows+Ubuntu环境进行OpenHarmony的开发。 - - -## 开发板 - -本文基于以下两款典型开发板进行开发介绍 :Hi3861 WLAN模组、Hi3516DV300。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-lite-introduction-hi3861.md),开发者可根据需要自行购买开发板。 - - -## 开发流程 - -轻量和小型系统快速入门流程如下图所示。 - - **图1** 轻量和小型系统快速入门开发流程  - -  -![zh-cn_image_0000001227114628](figures/zh-cn_image_0000001227114628.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-package-directory.md b/zh-cn/device-dev/quick-start/quickstart-lite-package-directory.md deleted file mode 100644 index 487f50ff678af8fe4239158ad10f18e05cc1a1a4..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-package-directory.md +++ /dev/null @@ -1,29 +0,0 @@ -## 轻量和小型系统快速入门(安装包方式) - -- [轻量与小型系统入门概述](quickstart-lite-overview.md) -- [搭建轻量与小型系统环境](quickstart-lite-env-setup.md) -- 运行“Hello World” - - Hi3861开发板 - - [安装Hi3861开发板环境](quickstart-lite-steps-hi3861-setting.md) - - [编写“Hello World”程序](quickstart-lite-steps-hi3861-helloworld.md) - - [编译](quickstart-lite-steps-hi3861-building.md) - - [烧录](quickstart-lite-steps-hi3861-burn.md) - - [联网](quickstart-lite-steps-hi3861-netconfig.md) - - [调试验证](quickstart-lite-steps-hi3861-debug.md) - - [运行](quickstart-lite-steps-hi3861-running.md) - - Hi3516开发板 - - [安装Hi3516开发板环境](quickstart-lite-steps-hi3516-setting.md) - - [编写“Hello World”程序](quickstart-lite-steps-hi3516-helloworld.md) - - [编译](quickstart-lite-steps-hi3516-building.md) - - [烧录](quickstart-lite-steps-hi3516-burn.md) - - [运行](quickstart-lite-steps-hi3516-running.md) -- 常见问题 - - [hb安装异常](quickstart-lite-faq-hb.md) - - [编译异常](quickstart-lite-faq-compose.md) - - [烧录异常](quickstart-lite-faq-burning.md) -- 附录 - - 开发板介绍 - - [Hi3861开发板介绍](quickstart-lite-introduction-hi3861.md) - - [Hi3516开发板介绍](quickstart-lite-introduction-hi3516.md) - - [参考信息](quickstart-lite-reference.md) - - [使用HiTool烧录代码](quickstart-lite-hitool.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-reference.md b/zh-cn/device-dev/quick-start/quickstart-lite-reference.md deleted file mode 100644 index 513f7e8667a3133b4cf81d275b5a38749207beea..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-reference.md +++ /dev/null @@ -1,68 +0,0 @@ -# 参考信息 - - -## 使用build.sh脚本编译源码 - -1. 进入源码根目录,执行如下命令进行版本编译。 - - ``` - ./build.sh --product-name name --ccache - ``` - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > _name_为产品名称,例如Hi3516DV300、rk3568等。 - -2. 检查编译结果。编译完成后,log中显示如下: - - ``` - post_process - =====build name successful. - ``` - - 编译所生成的文件都归档在out/{device_name}/目录下,结果镜像输出在out/{device_name}/packages/phone/images/ 目录下。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 其他模块化编译操作,可参见[编译构建指导](../subsystems/subsys-build-all.md)。 - - -## 配置代理 - - -### 配置Python代理 - -1. 新建代理配置文件。 - - ``` - mkdir ~/.pipvim ~/.pip/pip.conf - ``` - -2. 在文件中写入如下代理信息并保存退出。 - - ``` - [global] - index-url = http://代理网址 - trusted-host = 可信任的镜像地址 - timeout = 120 - ``` - - -### 配置NPM代理 - -1. 新建代理配置文件。 - - ``` - vim ~/.npmrc - ``` - -2. 在文件中写入如下代理信息并保存退出。 - - ``` - registry=http://代理网址 - strict-ssl=false - ``` - -3. 将以下内容添加到.bashrc中并保存退出。 - - ``` - export NPM_REGISTRY=http://代理网址 - source .bashrc - ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-burn.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-burn.md deleted file mode 100644 index e5dbb23c0e0a6b73ddcd259482c766c2735a4c2f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-burn.md +++ /dev/null @@ -1,88 +0,0 @@ -# 烧录 - - -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 - - -Hi3516DV300支持USB烧录、网口烧录和串口烧录三种方式,本文采用USB方式进行烧录。相关操作在Windows环境下进行 。 - - -## 导入源码 - -在编译完成后,[保证Windows系统可以远程访问Ubuntu环境](quickstart-lite-env-setup.md)的情况下,您还需要通过以下步骤将编译好的源码导入DevEco Device Tool,方可进行烧录。 - -1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 - - ![zh-cn_image_0000001278358765](figures/zh-cn_image_0000001278358765.png) - -2. 选择OpenHarmony源码根目录路径(需要访问Ubuntu下的源码目录),然后再选择**Import OpenHarmony Source**选项,点击**Import**进行导入。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 工程存储路径不能包含中文字符、空格。 - - ![zh-cn_image_0000001271477045](figures/zh-cn_image_0000001271477045.png) - -3. 在Import Project界面,选择**Product**后,会自动填充对应的SOC、Board、Company和Kernel信息,然后**Ohos Ver**选择对应的OpenHarmony源码版本。 - - ![zh-cn_image_0000001279586409](figures/zh-cn_image_0000001279586409.png) - -4. 点击**Open**打开工程或源码。 - -## 烧录 - -完成源码导入后,通过以下步骤进行烧录: - -1. 请连接好电脑和待烧录开发板,需要连接USB口和串口,具体可参考[Hi3516DV300开发板介绍](quickstart-lite-introduction-hi3516.md)。 - -2. 根据[Hi3516DV300开发板串口驱动安装指导](https://gitee.com/link?target=https%3A%2F%2Fdevice.harmonyos.com%2Fcn%2Fdocs%2Fdocumentation%2Fguide%2Fhi3516_hi3518-drivers-0000001050743695)、[Hi3516DV300开发板USB驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)安装USB驱动及USB转串口的驱动。若您的设备中已安装此驱动,请忽略该步骤。 - -3. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 - - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 - - ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) - -4. 在菜单栏中点击**Project Settings**按钮,进入Hi3516DV300工程配置界面。 - - ![zh-cn_image_0000001198566364](figures/zh-cn_image_0000001198566364.png) - -5. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 - - ![zh-cn_image_0000001198566365](figures/zh-cn_image_0000001198566365.png) - -6. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 - - - upload_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。DevEco Device Tool已预置默认的烧录文件信息,包括起始地址、分区大小、待烧录文件地址等,开发者可根据实际情况进行调整,点击每个待烧录文件后的![zh-cn_image_0000001275592884.png](figures/zh-cn_image_0000001275592884.png)按钮进行修改。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 - - ![zh-cn_image_0000001312778829](figures/zh-cn_image_0000001312778829.png) - - - upload_protocol:选择烧录协议,固定选择“hiburn-usb”。 - - - upload_port:选择已查询到的串口号。 - - ![zh-cn_image_0000001223190441](figures/zh-cn_image_0000001223190441.png) - -7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -8. 点击hi3516dv300下的**Upload**按钮。 - - ![zh-cn_image_0000001266887264](figures/zh-cn_image_0000001266887264.png) - - 此时待烧录文件会从Ubuntu系统传输到Windows下,传输完成后界面显示“Operation paused, Please press Enter key to continue”时,请点击**Enter**键启动烧录。 - - ![zh-cn_image_0000001114129426](figures/zh-cn_image_0000001114129426.png) - -9. 在终端窗口显示如下提示信息时,请在15秒内,按住Update键,插拔USB线,最后松开Update键启动烧录。 - - ![zh-cn_image_0000001326412233.png](figures/zh-cn_image_0000001326412233.png) - - 启动烧录后,界面提示**SUCCESS**信息时,表示烧录成功。 - - ![zh-cn_image_0000001160649343](figures/zh-cn_image_0000001160649343.png) - -10. 烧录成功后,请根据运行章节进行操作,启动系统。 - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md deleted file mode 100644 index a8f2cd561872bcef41a49661adedb274b7cd252f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md +++ /dev/null @@ -1,51 +0,0 @@ -# 运行 - - -## 启动系统 - -在完成Hi3516DV300的烧录后,还需要设置BootLoader引导程序,才能运行OpenHarmony系统。 - -1. 在Hi3516DV300任务中,点击**Configure bootloader(Boot OS)**进行配置即可。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > DevEco Device Tool针对Hi3516DV300开发板的BootLoader设置进行了适配,无需开发者手动修改。 - - ![zh-cn_image_0000001209906547](figures/zh-cn_image_0000001209906547.png) - -2. 提示如下图中的重启开发板的提示信息时,重启开发板,然后在控制台输出“SUCCESS”表示设置成功。 - - ![zh-cn_image_0000001210385161](figures/zh-cn_image_0000001210385161.png) - -3. 在任务栏点击**Monitor**按钮,启动串口工具。 - - ![zh-cn_image_0000001164506870](figures/zh-cn_image_0000001164506870.png) - -4. 当界面打印回显信息,点击Enter按钮,直到界面显示OHOS \#信息,表示系统启动成功。 - - ![zh-cn_image_0000001198626874](figures/zh-cn_image_0000001198626874.png) - - -## 运行“Hello World” - -系统启动成功后,取源码out目录下的helloworld可执行文件放入系统的bin目录,通过以下步骤运行“Hello World”。 - -1. 在启动界面进入bin目录。 - - ``` - cd bin - ``` - -2. 进入bin目录后可以看到helloworld文件,通过以下命令运行helloworld程序。 - - ``` - ./helloworld - ``` - - 界面打印“Hello World!”,程序运行成功。 - - ![zh-cn_image_0000001271234769](figures/zh-cn_image_0000001271234769.png) - - -## 下一步学习 - -恭喜您,已完成Hi3516DV300的快速上手!建议您下一步进入[带屏摄像头产品开发](../guide/device-camera-control-overview.md)的学习 。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md deleted file mode 100644 index 1c1342c8b3125cecae0517ef6c8a72e52e3e92b0..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md +++ /dev/null @@ -1,30 +0,0 @@ -# 安装Hi3516开发板环境 - - -## Hi3516工具要求 - - -### 硬件要求 - -- Hi3516DV300 IoT Camera开发板 - -- USB转串口线、网线(Linux工作台通过USB转串口线、网线与Hi3516DV300 开发板连接) - - -### 软件要求 - -Hi3516DV300开发板对Linux服务器通用环境配置需要的工具及其用途如下表所示。 - - **表1** Linux服务器开发工具及用途 - -| 开发工具 | 用途 | -| -------- | -------- | -| dosfstools、mtools、mtd-utils | 文件打包工具 | -| Java虚拟机环境 | 编译、调试和运行Java程序 | - - -## 安装Linux服务器工具 - -Hi3516DV300依赖以下工具:dosfstools、mtools、mtd-utils、Java运行时环境(JRE)和Java sdk 开发工具包。 - -上述工具已在[安装必要的库和工具](../quick-start/quickstart-lite-env-setup.md)环节完成安装,此处无需再进行安装。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md deleted file mode 100644 index c281e7aa447c87e77b8f31bc21b6d1279042eb20..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md +++ /dev/null @@ -1,76 +0,0 @@ -# 烧录 - - -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 - - -Hi3861V100开发板支持串口烧录方式,在Windows下通过以下步骤进行烧录: - - -## 导入源码 - -在编译完成后,[保证Windows系统可以远程访问Ubuntu环境](quickstart-lite-env-setup.md)的情况下,您还需要通过以下步骤将编译好的源码导入DevEco Device Tool,方可进行烧录。 - -1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 - - ![zh-cn_image_0000001278358765](figures/zh-cn_image_0000001278358765.png) - -2. 选择OpenHarmony源码根目录路径(需要访问Ubuntu下的源码目录),然后再选择**Import OpenHarmony Source**选项,点击**Import**进行导入。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 工程存储路径不能包含中文字符、空格。 - - ![zh-cn_image_0000001271477045](figures/zh-cn_image_0000001271477045.png) - -3. 在Import Project界面,选择**Product**后,会自动填充对应的SOC、Board、Company和Kernel信息,然后**Ohos Ver**选择对应的OpenHarmony源码版本。 - - ![zh-cn_image_0000001279425450](figures/zh-cn_image_0000001279425450.png) - -4. 点击**Open**打开工程或源码。 - - -## 烧录 - -完成源码导入后,通过以下步骤进行烧录: - -1. 请连接好电脑和待烧录开发板,需要连接USB口,具体可参考[Hi3861V100开发板介绍](quickstart-lite-introduction-hi3861.md)。 - -2. 根据[Hi3861V100开发板串口驱动安装指导](https://gitee.com/link?target=https%3A%2F%2Fdevice.harmonyos.com%2Fcn%2Fdocs%2Fdocumentation%2Fguide%2Fhi3861-drivers-0000001058153433)安装USB转串口的驱动程序。若您的设备中已安装此驱动,请忽略该步骤。 - -3. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 - - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 - - ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) - - -4. 在菜单栏中点击**Project Settings**按钮,进入Hi3861V100工程配置界面。 - - ![zh-cn_image_0000001333802045.png](figures/zh-cn_image_0000001333802045.png) - -5. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 - - ![zh-cn_image_0000001198943768](figures/zh-cn_image_0000001198943768.png) - -6. 在“hi3861”页签,设置烧录选项,包括upload_port、upload_protocol和upload_partitions。 - - - upload_port:选择已查询的串口号。 - - upload_protocol:选择烧录协议,选择“hiburn-serial”。 - - upload_partitions:选择待烧录的文件名称。DevEco Device Tool已预置默认的烧录文件信息,如果需要修改待烧录文件地址,可点击每个待烧录文件后的![zh-cn_image_0000001333642545.png](figures/zh-cn_image_0000001333642545.png)按钮进行修改。 - - ![zh-cn_image_0000001243704061](figures/zh-cn_image_0000001243704061.png) - -7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -8. 点击**Open**打开工程文件,然后在“PROJECT TASKS”中,点击hi3861下的**Upload**按钮,启动烧录。 - - ![zh-cn_image_0000001216440138](figures/zh-cn_image_0000001216440138.png) - -9. 启动烧录后,显示如下提示信息时,请在15秒内,按下开发板上的RST按钮重启开发板。 - - ![zh-cn_image_0000001198466090](figures/zh-cn_image_0000001198466090.png) - - 重新上电后,界面提示如下信息时,表示烧录成功。 - - ![zh-cn_image_0000001216761476](figures/zh-cn_image_0000001216761476.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-debug.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-debug.md deleted file mode 100644 index 15b35d82ffd79fd8830ea582e268ddc8272901c9..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-debug.md +++ /dev/null @@ -1,65 +0,0 @@ -# 调试验证 - - -完成烧录及联网之后,用户可根据需要进行调试验证。目前调试验证的方法有以下两种,开发者可以根据具体业务情况选择。 - - -1. 通过printf打印日志 - -2. 通过asm文件定位panic问题 - - -由于本示例业务简单,采用printf打印日志的调试方式即可。下方将介绍这两种调试手段的使用方法。 - - -## printf打印 - -代码中增加printf维测,信息会直接打印到串口上。开发者可在业务关键路径或业务异常位置增加日志打印,如下所示: - - -``` -void HelloWorld(void) -{ - printf("[DEMO] Hello world.\n"); -} -``` - - -## 根据asm文件进行问题定位 - - 系统异常退出时,会在串口上打印异常退出原因调用栈信息,如下文所示。通过解析异常栈信息可以定位异常位置。 - -``` -=======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*** -``` - -为解析上述调用栈信息,需要使用到Hi3861_wifiiot_app.asm文件,该文件记录了代码中函数在Flash上的符号地址以及反汇编信息。asm文件会随版本打包一同构建输出,存放在./out/wifiiot/路径下。 - -1. 将调用栈CallStack信息保存到txt文档中,以便于编辑。(可选) - -2. 打开asm文件,并搜索CallStack中的地址,列出对应的函数名信息。通常只需找出前几个栈信息对应的函数,就可明确异常代码方向。 - - ``` - 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. 根据以上调用栈信息,可以定位WadRecvCB函数中出现了异常。 - - ![zh-cn_image_0000001271354733](figures/zh-cn_image_0000001271354733.png) - -4. 完成代码排查及修改。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-netconfig.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-netconfig.md deleted file mode 100644 index 7e4199ccba9197a1068faf9f589853a28d4283f7..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-netconfig.md +++ /dev/null @@ -1,44 +0,0 @@ -# 联网 - - -完成版本编译及烧录后,下面开始介绍如何在串口终端上执行AT命令,使Hi3861 WLAN模组联网。 - - -1. 保持Windows工作台和WLAN模组的连接状态,在DevEco Device Tool最下方,点击“DevEco:Serial Monitor”按钮。 - - **图1** 打开DevEco Device Tool串口终端示意图   - - ![zh-cn_image_0000001227114644](figures/zh-cn_image_0000001227114644.png) - -2. 复位Hi3861 WLAN模组,终端界面显示“ready to OS start”,则启动成功。 - - **图2** Hi3861 WLAN模组复位成功示意图 -   - ![zh-cn_image_0000001226794704](figures/zh-cn_image_0000001226794704.png) - -3. 在串口终端中,依次执行如下AT命令,启动STA模式,连接指定AP热点,并开启DHCP功能。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 开发板启动后,串口会打印测试用例信息,待测试用例信息打印完成后再执行AT指令,否则AT指令会被测试用例信息覆盖。 - - - - ``` - AT+STARTSTA # 启动STA模式 - AT+SCAN # 扫描周边AP - AT+SCANRESULT # 显示扫描结果 - AT+CONN="SSID",,2,"PASSWORD" # 连接指定AP,其中SSID/PASSWORD为待连接的热点名称和密码 - AT+STASTAT # 查看连接结果 - AT+DHCP=wlan0,1 # 通过DHCP向AP请求wlan0的IP地址 - ``` - -4. 查看Hi3861 WLAN模组与网关联通是否正常,如下图所示。 - - ``` - AT+IFCFG # 查看模组接口IP - AT+PING=X.X.X.X # 检查模组与网关的联通性,其中X.X.X.X需替换为实际的网关地址 - ``` - - **图3** Hi3861 WLAN模组联网成功示意图   - - ![zh-cn_image_0000001226954648](figures/zh-cn_image_0000001226954648.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md deleted file mode 100644 index 0f23817a5b3b146379be6e17488df078578fcd8a..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md +++ /dev/null @@ -1,19 +0,0 @@ -# 运行 - - -## 运行结果 - -示例代码编译、烧录、运行、调测后,重启开发板后将自动在界面输出如下结果: - - -``` -ready to OS start -FileSystem mount ok. -wifi init success! -[DEMO] Hello world. -``` - - -## 下一步学习 - -恭喜,您已完成Hi3861 WLAN模组快速上手!建议您下一步进入[WLAN产品开发](../guide/device-wlan-led-control.md)的学习 。 diff --git a/zh-cn/device-dev/quick-start/quickstart-overview.md b/zh-cn/device-dev/quick-start/quickstart-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..6d7ebc91b73a41bb3d25b892c317692fe7351784 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-overview.md @@ -0,0 +1,53 @@ +# 快速入门概述 + + +OpenHarmony是一款面向全场景的开源分布式操作系统,采用组件化设计,支持在128KiB到xGiB RAM资源的设备上运行系统组件,设备开发者可基于目标硬件能力自由选择系统组件进行集成。 + + +OpenHarmony当前定义了三种基础系统类型,设备开发者通过选择基础系统类型完成必选组件集配置后,便可实现其最小系统的开发。这三种基础系统类型的参考定义如下: + + + **表1** 基础类型系统简介 + +| 类型 | 处理器 | 最小内存 | 能力 | +| -------- | -------- | -------- | -------- | +| 轻量系统(mini system) | MCU类处理器(例如Arm Cortex-M、RISC-V 32位的设备) | 128KiB | 提供多种轻量级网络协议,轻量级的图形框架,以及丰富的IOT总线读写部件等。可支撑的产品如智能家居领域的连接类模组、传感器设备、穿戴类设备等。 | +| 小型系统(small system) | 应用处理器(例如Arm Cortex-A的设备) | 1MiB | 提供更高的安全能力、标准的图形框架、视频编解码的多媒体能力。可支撑的产品如智能家居领域的IP Camera、电子猫眼、路由器以及智慧出行域的行车记录仪等。 | +| 标准系统(standard system) | 应用处理器(例如Arm Cortex-A的设备) | 128MiB | 提供增强的交互能力、3D GPU以及硬件合成能力、更多控件以及动效更丰富的图形能力、完整的应用框架。可支撑的产品如高端的冰箱显示屏。 | + + +本文通过介绍OpenHarmony系统的开发环境搭建、编译、烧录、调测以及运行“Hello World”等,引导开发者快速熟悉OpenHarmony设备开发的基本流程和方法。 + + +## 操作方式 + +考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: + + **表2** 入门方式 + +| 方式 | 工具 | 特点 | 适用人群 | +| -------- | -------- | -------- | -------- | +| [基于IDE入门](quickstart-ide-env--win.md) | IDE(DevEco Device Tool) | 完全采用IDE进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。
DevEco Device Tool采用Windows+Ubuntu混合开发环境:
- 在Windows上主要进行代码开发、代码调试、烧录等操作。
- 在Ubuntu环境实现源码编译。
DevEco Device Tool提供界面化的操作接口,可以为您提供更快捷的开发体验。 | - 不熟悉命令行操作的开发者
- 习惯界面化操作的开发者 | +| [基于命令行入门](quickstart-pkg-prepare.md) | 命令行工具包 | 通过命令行方式下载安装编译依赖工具,在Linux系统中进行编译时,相关操作通过命令实现;在Windows系统中使用开发板厂商提供的工具进行代码烧录。
命令行方式提供了简便统一的工具链安装方式。 | 习惯使用命令行操作的开发者 | + + +## 开发板 + +本文选取了如下三款典型开发板,用于介绍不同系统的开发过程,开发者可根据需要自行购买开发板。 + + **表3** 开发板-系统对应关系 + +| 名称 | 适配系统 | 简介 | +| -------- | -------- | -------- | +| Hi3861 WLAN模组 | 轻量 | [Hi3861开发板介绍](quickstart-appendix-hi3861.md) | +| Hi3516DV300 | 小型 | [Hi3516开发板介绍](quickstart-appendix-hi3516.md) | +| RK3568 | 标准 | [RK3568开发板介绍](quickstart-appendix-rk3568.md) | + + +## 开发流程 + +设备开发快速入门流程如下图所示。 + + **图1** 快速入门开发流程 + +![quickstart-overview-process](figures/quickstart-overview-process.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-building.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3516-build.md similarity index 60% rename from zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-building.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-3516-build.md index d8e832cb33df4d07a5551cfe806231c484bceff5..1ad02e122bdf98ed1b2ad896993c96746eb115f3 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-building.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3516-build.md @@ -1,32 +1,49 @@ # 编译 -OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](quickstart-lite-reference.md)。 +OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](quickstart-pkg-common-build.md#使用buildsh脚本编译源码)。 -请进入源码根目录,执行如下命令进行编译: +想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建指南](../subsystems/subsys-build-all.md)。 + + +## 前提条件 + +- 已正确[安装库和工具集](quickstart-pkg-install_package.md)。 + +- 已正确[安装编译工具](quickstart-pkg-install_tool.md)。 + +- “Hello World”程序已编写完成。 + +- 可正常登录Ubuntu环境。 +## 操作步骤 + +请进入源码根目录,执行如下命令进行编译: + 1. 设置编译路径。 - + ``` hb set ``` 2. 选择当前路径。 - + ``` . ``` 3. 在hisilicon下选择ipcamera_hispark_taurus并回车。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > + > 同样的开发板在适配不同的场景时,要采用的编译形态不同(即此处要选择的product不同),请参考[编译形态整体说明](quickstart-appendix-compiledform.md)。 **图1** Hi3516编译设置图例   - - ![zh-cn_image_0000001317198053](figures/zh-cn_image_0000001317198053.png) + + ![quickstart-lite-3516-build](figures/quickstart-lite-3516-build.png) 4. 执行编译。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 单独编译一个部件(例如hello),可使用“hb build -T _目标名称_”进行编译。 > @@ -36,13 +53,12 @@ OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build. > > 此处以完整编译整个产品为例进行说明。 - + ``` hb build -f ``` 5. 编译结束后,出现“build success”字样,则证明构建成功。 - > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** > 烧录相关文件获取路径: > diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-hitool.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3516-burn.md similarity index 68% rename from zh-cn/device-dev/quick-start/quickstart-lite-hitool.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-3516-burn.md index 42eab5ebde54416cdf603d25f599d46c7f8e47b3..130f18d0703c39bdd6e1bffbc26161d2f9c0faef 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-hitool.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3516-burn.md @@ -1,7 +1,7 @@ -# 使用HiTool烧录代码 +# 烧录 -针对Hi3516DV300开发板,除了DevEco Device Tool外,还可以使用HiTool进行烧录。 +针对Hi3516DV300开发板,除了DevEco Device Tool(操作方法请参考[烧录](quickstart-ide-3516-burn.md))外,还可以使用HiTool进行烧录。 ## 前提条件 @@ -10,7 +10,7 @@ - 客户端(操作平台,例如Windows系统)已下载并安装[HiTool工具](http://www.hihope.org/download/download.aspx)。 -- 客户端(操作平台,例如Windows系统)已安装USB驱动,可参考[Hi3516DV300/Hi3518EV300开发板USB驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)。 +- 客户端(操作平台,例如Windows系统)已安装USB驱动,可参考[Hi3516DV300开发板USB驱动安装指导](https://gitee.com/link?target=https%3A%2F%2Fdevice.harmonyos.com%2Fcn%2Fdocs%2Fdocumentation%2Fguide%2Fusb_driver-0000001058690393)。 - 客户端已安装串口终端工具(例如IPOP)。 @@ -20,15 +20,12 @@ ## 操作步骤 1. 准备烧录相关文件。 - - 1. 在客户端新建用于保存烧录文件的文件夹,例如D:\liteos或D:\linux。 - + 1. 在客户端新建用于保存烧录文件的文件夹,例如“D:\liteos”或“D:\linux”。 2. 将烧录所需烧写配置文件和启动引导文件保存到新建的文件夹中。 - - - 其小型系统(LiteOS)烧写配置文件为L1_3516_liteos.xml,其启动引导文件为“[u-boot-hi3516dv300.bin](https://gitee.com/openharmony/device_board_hisilicon/tree/master/hispark_taurus/uboot/out/boot)”。 + - 其L1_LiteOS烧写配置文件为L1_3516_liteos.xml,其启动引导文件为“[u-boot-hi3516dv300.bin](https://gitee.com/openharmony/device_board_hisilicon/tree/master/hispark_taurus/uboot/out/boot)”。 其中L1_3516_liteos.xml文件需要开发者自行准备,模板如下: - + ``` @@ -38,10 +35,10 @@ ``` - - 其小型系统(Linux)烧写配置文件为L1_3516_linux.xml,其启动引导文件为“[u-boot-hi3516dv300.bin](https://gitee.com/openharmony/device_board_hisilicon/tree/master/hispark_taurus/uboot/out/boot)”。 + - 其L1_Linux烧写配置文件为L1_3516_linux.xml,其启动引导文件为“[u-boot-hi3516dv300.bin](https://gitee.com/openharmony/device_board_hisilicon/tree/master/hispark_taurus/uboot/out/boot)”。 其中L1_3516_linux.xml文件需要开发者自行准备,模板如下: - + ``` @@ -53,52 +50,43 @@ ``` 3. 将编译完成的源码包下载至客户端并解压,将烧录相关文件拷贝至步骤1中新建的文件夹。 + + 针对Hi3516开发板(轻量级系统使用LiteOS内核或Linux内核根据业务实际需要选择): - 针对Hi3516开发板(小型系统使用LiteOS内核或Linux内核根据业务实际需要选择): - - - 其小型系统(LiteOS)烧写所需文件为:OHOS_Image.bin、rootfs_vfat.img、userfs_vfat.img - - 其小型系统(Linux)烧写所需文件为:uImage_hi3516dv300_smp、rootfs_ext4.img、userfs_ext4.img、userdata_ext4.img + - 其L1_LiteOS烧写所需文件为:OHOS_Image.bin、rootfs_vfat.img、userfs_vfat.img + - 其L1_Linux烧写所需文件为:uImage_hi3516dv300_smp、rootfs_ext4.img、userfs_ext4.img、userdata_ext4.img 2. 使用HiTool烧录。 - 1. 打开HiTool。 - 2. 设置HiTool参数。 - - 传输方式选择USB口,烧写方式选择烧写eMMC(单板的存储介质为eMMC)。 - + + 传输方式选择USB口,烧写方式选择烧写eMMC(单板的存储介质为eMMC)。 3. 单击浏览在步骤1创建的文件夹中选择烧写配置文件(例如L1_3516_linux.xml)。 - - ![image](figures/zh-cn_image_0000001249937195.png) - + + ![zh-cn_image_0000001249937195](figures/zh-cn_image_0000001249937195.png) 4. 单击烧写后,按住开发板上串口旁的按钮(Update键),并拔插USB线(上下电)。 + + 烧录开始后,可以在HiTool工具下方的控制台区域观察到烧录过程中的打印信息。 - 烧录开始后,可以在HiTool工具下方的控制台区域观察到烧录过程中的打印信息。 - - 烧录完成后,HiTool弹出提示框显示烧写成功。 - + 烧录完成后,HiTool弹出提示框显示烧写成功。 5. 单击确定。 3. 导入启动参数。 - 1. 使用终端工具打开串口。 - 2. 拔插开发板电源使其重启,3s内在串口终端输入回车。 - - 终端界面中出现hisilicon \#表示已连接开发板串口。 - + + 终端界面中出现“hisilicon \#”表示已连接开发板串口。 3. 在串口终端拷贝如下启动参数后,按回车完成配置。 - - - 其小型系统(LiteOS)对应的启动参数为: - + - 其L1_LiteOS对应的启动参数为: + ``` setenv bootcmd "mmc read 0x0 0x80000000 0x800 0x4800;go 0x80000000"; setenv bootargs "console=ttyAMA0,115200n8 root=emmc fstype=vfat rootaddr=10M rootsize=50M rw"; saveenv - reset + sa;reset ``` - - 其小型系统(Linux)对应的启动参数为: - + - 其L1_Linux对应的启动参数为: + ``` setenv bootargs "mem=128M console=ttyAMA0,115200 root=/dev/mmcblk0p3 rw rootfstype=ext4 rootwait blkdevparts=mmcblk0:1M(boot),9M(kernel),50M(rootfs),50M(userfs),1024M(userdata)" setenv bootcmd "mmc read 0x0 0x82000000 0x800 0x4800; mw 0x10FF0044 0x0600;mw 0x120D2010 0x00000000;mw 0x120D2400 0x000000ff;mw 0x120D2010 0x00000000; bootm 0x82000000" diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-helloworld.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3516-helloworld.md similarity index 78% rename from zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-helloworld.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-3516-helloworld.md index a8273bfc8b33dfdb950434eef48c0f2f3c1121af..996a536b881a24f41c9f00c255b5c4b82a470df0 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-helloworld.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3516-helloworld.md @@ -9,7 +9,7 @@ 示例完整目录如下: - + ``` applications/sample/hello │── BUILD.gn @@ -20,13 +20,13 @@ applications/sample/hello ## 开发步骤 -请在源码目录中通过以下步骤创建“Hello World”应用程序: +请在源码目录中通过以下步骤创建“Hello World”应用程序。 1. 新建目录及源码。 + + 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改OHOS为World)。当前应用程序可支持标准C及C++的代码开发。 - 新建**applications/sample/hello/src/helloworld.c**目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改OHOS为World)。当前应用程序可支持标准C及C++的代码开发。 - - + ``` #include @@ -41,10 +41,10 @@ applications/sample/hello ``` 2. 新建编译组织文件。 + + 新建applications/sample/hello/BUILD.gn文件,内容如下所示: - 新建**applications/sample/hello/BUILD.gn**文件,内容如下所示: - - + ``` import("//build/lite/config/component/lite_component.gni") lite_component("hello-OHOS") { @@ -57,10 +57,10 @@ applications/sample/hello ``` 3. 添加新组件。 + + 修改文件build/lite/components/communication.json,添加组件hello_world_app的配置,如下所示为**communication.json**文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - 修改文件**build/lite/components/communication.json**,添加组件hello_world_app的配置,如下所示为communication.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - - + ``` { "components": [ @@ -120,10 +120,10 @@ applications/sample/hello ``` 4. 修改单板配置文件。 + + 修改文件vendor/hisilicon/hispark_taurus/config.json,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - 修改文件**vendor/hisilicon/hispark_taurus/config.json**,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - - + ``` { "subsystem": "applications", diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-3516-running.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3516-running.md new file mode 100644 index 0000000000000000000000000000000000000000..612cc2eaee9133a711590e9b0dc0c1ef75ec41a0 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3516-running.md @@ -0,0 +1,32 @@ +# 运行 + + +系统启动成功后,取源码out目录下的helloworld可执行文件放入系统的bin目录,通过以下步骤运行“Hello World”。 + + +## 操作步骤 + +1. 在启动界面进入bin目录。 + + ``` + cd bin + ``` + +2. 进入bin目录后可以看到helloworld文件,通过以下命令运行helloworld程序。 + + ``` + ./helloworld + ``` + + 界面打印“Hello World!”,程序运行成功。 + + ![quickstart-pkg-3516-running](figures/quickstart-pkg-3516-running.png) + + +## 下一步学习 + +恭喜您,已完成Hi3516的快速上手!建议您下一步进学习 。可参考: + +- [屏幕和摄像头控制](../guide/device-camera-control-overview.md) + +- [视觉应用开发](../guide/device-camera-visual-overview.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3568-build.md similarity index 55% rename from zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-3568-build.md index 88eeac16d99dd0862961af1891b50d7567206854..99fa901251cf78df2941076ccdd7dee354cd6c8a 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3568-build.md @@ -1,40 +1,58 @@ # 编译 -OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](quickstart-standard-reference.md)。 +OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](quickstart-pkg-common-build.md#使用buildsh脚本编译源码)。 -在Ubuntu环境下进入源码根目录,执行如下命令进行编译: +想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建指南](../subsystems/subsys-build-all.md)。 + + +## 前提条件 + +- 已正确[安装库和工具集](quickstart-pkg-install_package.md)。 + +- 已正确[安装编译工具](quickstart-pkg-install_tool.md)。 + +- “Hello World”程序已编写完成。 + +- 可正常登录Ubuntu环境。 +## 操作步骤 + +在Ubuntu环境下进入源码根目录,执行如下命令进行编译: + 1. 设置编译路径。 - + ``` hb set ``` 2. 选择当前路径。 - + ``` . ``` 3. 在hihope下选择rk3568并回车。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > + > 同样的开发板在适配不同的场景时,要采用的编译形态不同(即此处要选择的product不同),请参考[编译形态整体说明](quickstart-appendix-compiledform.md)。 **图1** RK3568编译设置图例   - - ![zh-cn_image_0000001268598074](figures/zh-cn_image_0000001268598074.png) + + ![quickstart-standard-rk3568-build](figures/quickstart-standard-rk3568-build.png) 4. 默认情况下,编译的是32位系统,若不需要调整,则跳过此步骤。 + 如需编译为64位系统,请执行如下命令: - + ``` hb build --target-cpu arm64 ``` 5. 执行编译。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 单独编译一个部件(例如hello),可使用“hb build -T _目标名称_”进行编译。 > @@ -44,11 +62,11 @@ OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build. > > 此处以完整编译整个产品为例进行说明。 - + ``` hb build -f ``` -6. 编译结束后,出现“rk3568 build success”字样,说明构建成功。 +6. 编译结束后,出现“rk3568 build success”字样,则证明构建成功。 > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** > 编译结果文件及编译日志文件获取路径:out/rk3568。 diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-3568-burn.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3568-burn.md new file mode 100644 index 0000000000000000000000000000000000000000..8bb06bf8507d5f1b387157513eec9f49ea495795 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3568-burn.md @@ -0,0 +1,16 @@ +# 烧录 + + +针对RK3568开发板,除了DevEco Device Tool外(操作方法请参考[烧录](quickstart-ide-3568-burn.md)),还可以使用RKDevTool进行烧录。 + + +## 前提条件 + +- 开发板相关源码已编译完成,已形成烧录文件。 + +- 客户端(操作平台,例如Windows系统)已下载并安装[RKDevTool工具和USB驱动](https://gitee.com/hihope_iot/docs/tree/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows)。 + + +## 操作步骤 + +使用RKDevTool的详细操作方法,请参考《[HiHope_DAYU200烧录指导](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/docs/%E7%83%A7%E5%BD%95%E6%8C%87%E5%AF%BC%E6%96%87%E6%A1%A3.md)》。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3568-helloworld.md similarity index 98% rename from zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-3568-helloworld.md index 1a93c4a0abf6b21548d32ec2b48ac6bf89f1a042..7eae011a60cd1ed8d11ec6215fc8666b6ca88dae 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3568-helloworld.md @@ -8,7 +8,7 @@ 示例完整目录如下。 - + ``` applications/sample/hello │── BUILD.gn @@ -27,13 +27,13 @@ vendor/hihope ## 开发步骤 -请在源码目录中通过以下步骤创建“Hello World”应用程序: +请在源码目录中通过以下步骤创建“Hello World”应用程序。 1. 创建目录,编写业务代码。 - + 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 - + ``` #include #include "helloworld.h" @@ -54,7 +54,7 @@ vendor/hihope 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。 - + ``` #ifndef HELLOWORLD_H #define HELLOWORLD_H @@ -75,9 +75,8 @@ vendor/hihope ``` 2. 新建编译组织文件。 - 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示: - + ``` import("//build/ohos.gni") # 导入编译模板 ohos_executable("helloworld") { # 可执行模块 @@ -98,7 +97,7 @@ vendor/hihope } ``` 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。 - + ``` { "name": "@ohos/hello", @@ -137,10 +136,10 @@ vendor/hihope bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。 3. 修改子系统配置文件。 - + 在build/subsystem_config.json中添加新建的子系统的配置。 - + ``` "sample": { "path": "applications/sample/hello", @@ -149,7 +148,7 @@ vendor/hihope ``` 4. 修改产品配置文件。 - + 在vendor/hihope/rk3568/config.json中添加对应的hello部件,直接添加到原有部件后即可。 ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-3568-running.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3568-running.md new file mode 100644 index 0000000000000000000000000000000000000000..13013f95b8041f5a1f2e0bc20c97b47bcb40afa8 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3568-running.md @@ -0,0 +1,21 @@ +# 运行 + + +## 启动系统 + +烧录完成重启开发板后,系统将会自动启动。开发板附带的屏幕呈现以下界面,表明系统已运行成功。 + + **图1** 系统启动效果图   + +![quickstart-pkg-3568-running-restart](figures/quickstart-pkg-3568-running-restart.png) + + +## 运行“Hello World” + +1. 设备启动后打开串口工具(以putty为例),波特率设置为1500000,连接设备。 + + ![rk3568-run-configuration](figures/rk3568-run-configuration.png) + +2. 打开串口后,在任意目录(以设备根目录为例)下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 + + ![helloworld](figures/helloworld.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-building.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3861-build.md similarity index 55% rename from zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-building.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-3861-build.md index 34efde6b4e3910ffc15f21e1656b2362f1d29abb..e5fb2573c49559e797313f93cfbe486387e557c3 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-building.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3861-build.md @@ -1,32 +1,51 @@ # 编译 -OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](quickstart-lite-reference.md)。 +OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](quickstart-pkg-common-build.md#使用buildsh脚本编译源码)。 -在Ubuntu环境下进入源码根目录,执行如下命令进行编译: +想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建指南](../subsystems/subsys-build-all.md)。 + + +## 前提条件 + +- 已正确[安装库和工具集](quickstart-pkg-install_package.md)。 + +- 已正确[安装编译工具](quickstart-pkg-install_tool.md)。 + +- 已正确[安装Hi3861特有工具](quickstart-pkg-3861-tool.md)。 + +- “Hello World”程序已编写完成。 +- 可正常登录Ubuntu环境。 + + +## 操作步骤 + +在Ubuntu环境下进入源码根目录,执行如下命令进行编译: 1. 设置编译路径。 - + ``` hb set ``` 2. 选择当前路径。 - + ``` . ``` 3. 在hisilicon下选择wifiiot_hispark_pegasus并回车。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > + > 同样的开发板在适配不同的场景时,要采用的编译形态不同(即此处要选择的product不同),请参考[编译形态整体说明](quickstart-appendix-compiledform.md)。 **图1** Hi3861编译设置图例   - ![zh-cn_image_0000001317078157](figures/zh-cn_image_0000001317078157.png) + ![quickstart-lite-3861-build](figures/quickstart-lite-3861-build.png) 4. 执行编译。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 单独编译一个部件(例如hello),可使用“hb build -T _目标名称_”进行编译。 > @@ -36,12 +55,11 @@ OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build. > > 此处以完整编译整个产品为例进行说明。 - + ``` hb build -f ``` 5. 编译结束后,出现“build success”字样,则证明构建成功。 - > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** > 编译结果文件及编译日志获取路径:out/hispark_pegasus/wifiiot_hispark_pegasus。 diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-3861-burn.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3861-burn.md new file mode 100644 index 0000000000000000000000000000000000000000..878fdda09e59b99a1fea851eb317d4476ccff61b --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3861-burn.md @@ -0,0 +1,58 @@ +# 烧录 + + +针对Hi3861开发板,除了DevEco Device Tool(操作方法请参考[烧录](quickstart-ide-3861-burn.md))外,还可以使用Hiburn进行烧录。 + + +## 前提条件 + +- 开发板相关源码已编译完成,已形成烧录文件。 + +- 客户端(操作平台,例如Windows系统)已下载并安装[HiBurn工具](https://gitee.com/hihope_iot/docs/tree/master/HiSpark_WiFi_IoT/Software/tools)。 + +- 客户端(操作平台,例如Windows系统)已安装USB驱动,可参考[USB驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3861-drivers-0000001058153433)。 + +- 客户端已安装串口终端工具(例如IPOP)。 + +- 使用USB线缆连接客户端与开发板。 + + +## 操作步骤 + +1. 准备烧录相关文件。 + 1. 在客户端新建用于保存烧录文件的文件夹,例如“D:\hi3861”。 + 2. 将编译完成的源码包下载至客户端并解压,将烧录相关文件拷贝至步骤1中新建的文件夹。 + 烧写所需文件为:Hi3861_wifiiot_app_allinone.bin、Hi3861_loader_signed.bin + +2. 使用HiBurn烧录。 + 1. 打开HiBurn。 + 2. 设置HiBurn参数,根据实际情况选择COM口,勾选“Select all”和“Auto burn”。 + + **图1** HiBurn烧写界面参数设置   + + ![quickstart-pkg-3861-burn-hiburn](figures/quickstart-pkg-3861-burn-hiburn.png) + + 3. 单击Select file在步骤1创建的文件夹中选择烧写文件Hi3861_wifiiot_app_allinone.bin。 + + **图2** hiburn文件选择完成   + + ![quickstart-pkg-3861-burn-selectfile](figures/quickstart-pkg-3861-burn-selectfile.png) + + 4. 确保COM口选择正确,然后单击Connect后,按一下开发板上串口旁的按钮(Reset键)开始烧写。 + 烧录开始后,可以在HiBurn工具下方的控制台区域观察到烧录过程中的打印信息。 + + 烧录完成后,控制台区域会打印提示"Execution Successful"。 + + **图3** 单击"Connect"后   + + ![quickstart-pkg-3861-burn-connect](figures/quickstart-pkg-3861-burn-connect.png) + + **图4** 单击开发板重置按键后,烧写中   + + ![quickstart-pkg-3861-burn-burning](figures/quickstart-pkg-3861-burn-burning.png) + + **图5** 烧写完成   + + ![quickstart-pkg-3861-burn-end](figures/quickstart-pkg-3861-burn-end.png) + + 5. 单击Disconnect断开连接。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3861-helloworld.md similarity index 86% rename from zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-3861-helloworld.md index 9a511787ec586b345bebbd4c6b8f93852e4b5122..1c9bee175ef535d7f6355eac402fb01d8d51cd4c 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3861-helloworld.md @@ -5,12 +5,12 @@ 1. 确定目录结构。 - + 开发者编写业务时,务必先在./applications/sample/wifi-iot/app路径下新建一个目录(或一套目录结构),用于存放业务源码文件。 例如:在app下新增业务my_first_app,其中hello_world.c为业务代码,BUILD.gn为编译脚本,具体规划目录结构如下: - + ``` . └── applications @@ -23,9 +23,9 @@ ``` 2. 编写业务代码。 - + 新建./applications/sample/wifi-iot/app/my_first_app下的hello_world.c文件,在hello_world.c中新建业务入口函数HelloWorld,并实现业务逻辑。并在代码最下方,使用OpenHarmony启动恢复模块接口SYS_RUN()启动业务。(SYS_RUN定义在ohos_init.h文件中) - + ``` #include #include "ohos_init.h" @@ -39,12 +39,12 @@ ``` 3. 编写用于将业务构建成静态库的BUILD.gn文件。 - + 新建./applications/sample/wifi-iot/app/my_first_app下的BUILD.gn文件,并完成如下配置。 如步骤1所述,BUILD.gn文件由三部分内容(目标、源文件、头文件路径)构成,需由开发者完成填写。 - + ``` static_library("myapp") { sources = [ @@ -61,10 +61,10 @@ - include_dirs中指定source所需要依赖的.h文件路径。 4. 添加新组件。 + + 修改文件build/lite/components/communication.json,添加组件hello_world_app的配置,如下所示为communication.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - 修改文件**build/lite/components/communication.json**,添加组件hello_world_app的配置,如下所示为communication.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - - + ``` { "components": [ @@ -124,10 +124,10 @@ ``` 5. 修改单板配置文件。 + + 修改文件vendor/hisilicon/hispark_pegasus/config.json,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - 修改文件**vendor/hisilicon/hispark_pegasus/config.json**,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - - + ``` { "subsystem": "applications", diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-3861-running.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3861-running.md new file mode 100644 index 0000000000000000000000000000000000000000..884893f1412e1be2f966bea769b13636f00a322e --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3861-running.md @@ -0,0 +1,120 @@ +# 运行 + + +## 联网配置 + +由于Hi3861为WLAN模组,您可以在版本编译及烧录后,通过如下操作,使开发板实现联网功能。 + +1. 保持Windows工作台和Hi3861 WLAN模组的连接状态,确认串口终端显示正常。 + +2. 复位Hi3861 WLAN模组,终端界面显示“ready to OS start”,则启动成功。 + + **图1** Hi3861 WLAN模组复位成功示意图   + + ![quickstart-pkg-3861-running-restart](figures/quickstart-pkg-3861-running-restart.png) + +3. 依次执行如下AT命令,启动STA模式,连接指定AP热点,并开启DHCP功能。 + + ``` + AT+STARTSTA # 启动STA模式 + AT+SCAN # 扫描周边AP + AT+SCANRESULT # 显示扫描结果 + AT+CONN="SSID",,2,"PASSWORD" # 连接指定AP,其中SSID/PASSWORD为待连接的热点名称和密码 + AT+STASTAT # 查看连接结果 + AT+DHCP=wlan0,1 # 通过DHCP向AP请求wlan0的IP地址 + ``` + +4. 查看Hi3861 WLAN模组与网关联通是否正常,如下图所示。 + + ``` + AT+IFCFG # 查看模组接口IP + AT+PING=X.X.X.X # 检查模组与网关的联通性,其中X.X.X.X需替换为实际的网关地址 + ``` + + **图2** Hi3861 WLAN模组联网成功示意图   + ![quickstart-pkg-3861-running-success](figures/quickstart-pkg-3861-running-success.png) + + +## 调测验证 + +完成烧录及联网之后,用户可根据需要进行调试验证。目前调试验证的方法有以下两种,开发者可以根据具体业务情况选择。 + +1. 通过printf打印日志 + +2. 通过asm文件定位panic问题 + +由于本示例业务简单,采用printf打印日志的调试方式即可。下方将介绍这两种调试手段的使用方法。 + + +### printf打印 + +代码中增加printf维测,信息会直接打印到串口上。开发者可在业务关键路径或业务异常位置增加日志打印,如下所示: + + +``` +void HelloWorld(void) +{ + printf("[DEMO] Hello world.\n"); +} +``` + + +### 根据asm文件进行问题定位 + + 系统异常退出时,会在串口上打印异常退出原因调用栈信息,如下文所示。通过解析异常栈信息可以定位异常位置。 + +``` +=======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*** +``` + +为解析上述调用栈信息,需要使用到Hi3861_wifiiot_app.asm文件,该文件记录了代码中函数在Flash上的符号地址以及反汇编信息。asm文件会随版本打包一同构建输出,存放在./out/wifiiot/路径下。 + +1. 将调用栈CallStack信息保存到txt文档中,以便于编辑。(可选) + +2. 打开asm文件,并搜索CallStack中的地址,列出对应的函数名信息。通常只需找出前几个栈信息对应的函数,就可明确异常代码方向。 + + ``` + 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. 根据以上调用栈信息,可以定位WadRecvCB函数中出现了异常。 + + ![hi3861-test](figures/hi3861-test.png) + +4. 完成代码排查及修改。 + + +## 运行结果 + +示例代码编译、烧录、运行、调测后,重启开发板后将自动在界面输出如下结果: + + +``` +ready to OS start +FileSystem mount ok. +wifi init success! +[DEMO] Hello world. +``` + +下一步学习 + +恭喜,您已完成Hi3861 WLAN模组快速上手!建议您下一步进入的学习 。可参考: + +- [LED外设控制](../guide/device-wlan-led-control.md) + +- [集成三方SDK](../guide/device-wlan-sdk.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-setting.md b/zh-cn/device-dev/quick-start/quickstart-pkg-3861-tool.md similarity index 93% rename from zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-setting.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-3861-tool.md index a662874ab7a5e86d68a66a189f38ea5621dab041..88b666c840e86275e328d6661b704b722a15b64b 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-setting.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-3861-tool.md @@ -1,21 +1,10 @@ -# 安装Hi3861开发板环境 +# 安装Hi3861开发板特有环境 -## Hi3861工具要求 +除上述[安装库和工具集](quickstart-pkg-install_package.md)和[安装编译工具](quickstart-pkg-install_tool.md)外,针对Hi3861开发板还需要安装特定的编译工具。 -### 硬件要求 - -- Linux工作台 - -- Hi3861 WLAN模组 - -- USB Type-C线(Linux工作台通过USB与Hi3861开发板连接) - - -### 软件要求 - -Hi3861 WLAN模组需要的工具如下表所示。 +## 工具要求 **表1** Hi3861 WLAN模组需要安装的编译工具 @@ -26,40 +15,42 @@ Hi3861 WLAN模组需要的工具如下表所示。 | gcc riscv32 | 编译构建工具 | -## 安装编译工具 +## 操作步骤 -编译Hi3861 WLAN模组需要一些特定的编译工具,在Ubuntu下通过以下步骤安装。 +相关操作在Ubuntu环境下进行。 ### 安装Scons 1. 运行如下命令,安装SCons安装包。 - + ``` python3 -m pip install scons ``` 2. 运行如下命令,查看是否安装成功。如果安装成功,查询结果下图所示。 - + ``` scons -v ``` **图1** SCons安装成功界面,版本要求3.0.4以上   - ![zh-cn_image_0000001271234749](figures/zh-cn_image_0000001271234749.png) + + ![hi3861-scons-install-success](figures/hi3861-scons-install-success.png) ### 安装python模块 1. 运行如下命令,安装python模块setuptools。 - + ``` pip3 install setuptools ``` 2. 安装GUI menuconfig工具(Kconfiglib),建议安装Kconfiglib 13.2.0+版本,任选如下一种方式。 + - **命令行方式:** - + ``` sudo pip3 install kconfiglib ``` @@ -67,15 +58,16 @@ Hi3861 WLAN模组需要的工具如下表所示。 1. 下载.whl文件(例如:kconfiglib-13.2.0-py2.py3-none-any.whl)。 下载路径:“[https://pypi.org/project/kconfiglib#files](https://pypi.org/project/kconfiglib#files)” 2. 运行如下命令,安装.whl文件。 - + ``` sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl ``` 3. 安装pycryptodome,任选如下一种方式。 - 安装升级文件签名依赖的Python组件包,包括:pycryptodome、six、ecdsa。安装ecdsa依赖six,请先安装six,再安装ecdsa。 + + 安装升级文件签名依赖的Python组件包,包括:pycryptodome、six、ecdsa。安装ecdsa依赖six,请先安装six,再安装ecdsa。 - **命令行方式:** - + ``` sudo pip3 install pycryptodome ``` @@ -84,14 +76,14 @@ Hi3861 WLAN模组需要的工具如下表所示。 1. 下载.whl文件(例如:pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl)。 下载路径:“[https://pypi.org/project/pycryptodome/#files](https://pypi.org/project/pycryptodome/#files)”。 2. 运行如下命令,安装.whl文件。 - + ``` sudo pip3 install pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl ``` 4. 安装six,任选如下一种方式。 - **命令行方式:** - + ``` sudo pip3 install six --upgrade --ignore-installed six ``` @@ -99,14 +91,14 @@ Hi3861 WLAN模组需要的工具如下表所示。 1. 下载.whl文件(例如:six-1.12.0-py2.py3-none-any.whl)。 下载路径:“[https://pypi.org/project/six/#files](https://pypi.org/project/six/#files)” 2. 运行如下命令,安装.whl文件。 - + ``` sudo pip3 install six-1.12.0-py2.py3-none-any.whl ``` 5. 安装ecdsa,任选如下一种方式。 - **命令行方式:** - + ``` sudo pip3 install ecdsa ``` @@ -114,7 +106,7 @@ Hi3861 WLAN模组需要的工具如下表所示。 1. 下载.whl文件(例如:ecdsa-0.14.1-py2.py3-none-any.whl)。 下载路径:“[https://pypi.org/project/ecdsa/#files](https://pypi.org/project/ecdsa/#files)” 2. 运行如下命令,安装.whl文件。 - + ``` sudo pip3 install ecdsa-0.14.1-py2.py3-none-any.whl ``` @@ -130,31 +122,31 @@ Hi3861 WLAN模组需要的工具如下表所示。 1. 打开Linux编译服务器终端。 2. 下载riscv-gnu-toolchain交叉编译工具链。 - + ``` git clone --recursive https://gitee.com/mirrors/riscv-gnu-toolchain.git ``` 3. 打开文件夹riscv-gnu-toolchain,先删除空文件夹,以防止下载newlib,binutils,gcc时冲突。 - + ``` cd riscv-gnu-toolchain && rm -rf riscv-newlib && rm -rf riscv-binutils && rm -rf riscv-gcc ``` 4. 下载riscv-newlib-3.0.0。 - + ``` git clone -b riscv-newlib-3.0.0 https://github.com/riscv/riscv-newlib.git ``` 5. 下载riscv-binutils-2.31.1。 - + ``` git clone -b riscv-binutils-2.31.1 https://github.com/riscv/riscv-binutils-gdb.git ``` 6. 下载riscv-gcc-7.3.0。 - + ``` git clone -b riscv-gcc-7.3.0 https://github.com/riscv/riscv-gcc ``` @@ -163,43 +155,43 @@ Hi3861 WLAN模组需要的工具如下表所示。 访问gcc官方补丁链接[89411](https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=026216a753ef0a757a9e368a59fa667ea422cf09;hp=2a23a1c39fb33df0277abd4486a3da64ae5e62c2),[86724](https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=gcc/graphite.h;h=be0a22b38942850d88feb159603bb846a8607539;hp=4e0e58c60ab83f1b8acf576e83330466775fac17;hb=b1761565882ed6a171136c2c89e597bc4dd5b6bf;hpb=fbd5f023a03f9f60c6ae36133703af5a711842a3),按照补丁链接中要求的修改,手动将变更添加到对应的.c和.h文件中,注意由于patch版本与下载的gcc版本有所偏差,行数有可能对应不上,请自行查找patch中的关键字定位到对应行。 8. 下载[GMP 6.1.2](https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2),并解压安装。 - + ``` tar -xvf gmp-6.1.2.tar.bz2 && mkdir build_gmp && cd build_gmp && ../gmp-6.1.2/configure --prefix=/usr/local/gmp-6.1.2 --disable-shared --enable-cxx && make && make install ``` 9. 下载[mpfr-4.0.2 ](https://www.mpfr.org/mpfr-4.0.2/mpfr-4.0.2.tar.gz),并解压安装。 - + ``` tar -xvf mpfr-4.0.2.tar.gz && mkdir build_mpfr && cd build_mpfr && ../mpfr-4.0.2/configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2 --disable-shared && make && make install ``` 10. 下载[mpc-1.1.0](https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz) ,并解压安装。 - + ``` tar -xvf mpc-1.1.0.tar.gz && mkdir build_mpc && cd build_mpc && ../mpc-1.1.0/configure --prefix=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 --disable-shared && make && make install ``` 11. 打开文件夹riscv-gnu-toolchain,新建工具链输出目录。 - + ``` cd /opt && mkdir gcc_riscv32 ``` 12. 编译binutils。 - + ``` mkdir build_binutils && cd build_binutils && ../riscv-binutils-gdb/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32/riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install && cd .. ``` 13. 编译newlib。 - + ``` mkdir build_newlib && cd build_newlib && ../riscv-newlib/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" \CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install && cd .. ``` 14. 编译gcc。 - + ``` mkdir build_gcc && cd build_gcc && ../riscv-gcc/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" LDFLAGS="-Wl,-z,relro,-z,now,-z,noexecstack" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --with-headers="/opt/gcc-riscv32/riscv32-unknown-elf/include" --with-mpc=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 && make -j16 && make install ``` @@ -212,27 +204,27 @@ Hi3861 WLAN模组需要的工具如下表所示。 > tar -xvf gcc_riscv32-linux-7.3.0.tar.gz -C ~ > ``` - - + +​ ``` vim ~/.bashrc ``` 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 - + ``` export PATH=~/gcc_riscv32/bin:$PATH ``` 16. 生效环境变量。 - + ``` source ~/.bashrc ``` 17. Shell命令行中输入如下命令,如果能正确显示编译器版本号,表明编译器安装成功。 - + ``` riscv32-unknown-elf-gcc -v ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-common-build.md b/zh-cn/device-dev/quick-start/quickstart-pkg-common-build.md new file mode 100644 index 0000000000000000000000000000000000000000..6319febfdea4701cb670b15db526ab7c3815e7ec --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-common-build.md @@ -0,0 +1,22 @@ +# 使用build.sh脚本编译源码 + + +1. 进入源码根目录,执行如下命令进行版本编译。 + + ``` + ./build.sh --product-name name --ccache + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > _name_为产品名称,例如Hi3516DV300、rk3568等。 + +2. 检查编译结果。编译完成后,log中显示如下: + + ``` + post_process + =====build name successful. + ``` + + 编译所生成的文件都归档在out/{device_name}/目录下,结果镜像输出在out/{device_name}/packages/phone/images/ 目录下。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 其他模块化编译操作,可参见[编译构建指南](../subsystems/subsys-build-all.md)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-faq-compose.md b/zh-cn/device-dev/quick-start/quickstart-pkg-common-builderr.md similarity index 90% rename from zh-cn/device-dev/quick-start/quickstart-lite-faq-compose.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-common-builderr.md index ee73ec25bd0a8d61f0a204cc1e0f6e72ed5d1edb..e4a05c711efb25399630870e7b9cf59fdf7e7cc7 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-faq-compose.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-common-builderr.md @@ -1,18 +1,21 @@ -# 编译异常 +# 编译异常处理 ## Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt_pkg” - **现象描述** + Linux编译服务器终端输入不识别的命令时,提示"ImportError: No module named apt_pkg" - **可能原因** + python3 apt安装兼容性问题。 - **解决办法** + 执行如下命令重新安装python3-apt。 - + ``` sudo apt-get remove python3-apt sudo apt-get install python3-apt @@ -22,33 +25,38 @@ ## 编译构建过程中,提示找不到“python” - **现象描述** + 编译构建过程中出现以下错误: - + ``` -bash: /usr/bin/python: No such file or directory ``` - **可能原因**1 + 没有装python。 - **解决办法** + 请使用如下命令安装Python,下方以Python3.8为例。 - + ``` sudo apt-get install python3.8 ``` - **可能原因2** + usr/bin目录下没有python软链接 - ![zh-cn_image_0000001271354745](figures/zh-cn_image_0000001271354745.png) + ![faq-python-error](figures/faq-python-error.png) - **解决办法** + 请运行以下命令添加软链接: - + ``` # cd /usr/bin/ # which python3 @@ -58,22 +66,24 @@ 例: - ![zh-cn_image_0000001227114636](figures/zh-cn_image_0000001227114636.png) + ![faq-python-add-soft-link](figures/faq-python-add-soft-link.png) ## 编译构建过程中,提示找不到“python3” - **现象描述** - - ![zh-cn_image_0000001227114640](figures/zh-cn_image_0000001227114640.png) + + ![faq-python3-not-found](figures/faq-python3-not-found.png) - **可能原因** + 没有装python3。 - **解决办法** + 请使用如下命令安装Python3。 - + ``` sudo apt-get install python3.8 ``` @@ -82,14 +92,16 @@ ## 安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH” - **现象描述** + 安装python3过程中出现以下错误: - + ``` configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details ``` - **可能原因** + 环境中未安装“gcc”。 - **解决办法** @@ -100,14 +112,16 @@ ## 安装python3过程中,提示“-bash: make: command not found” - **现象描述** + 安装python3过程中出现以下错误: - + ``` -bash: make: command not found ``` - **可能原因** + 环境中未安装“make”。 - **解决办法** @@ -118,18 +132,19 @@ ## 安装python3过程中,提示“No module named '_ctypes'” - **现象描述** + 安装python3过程中出现以下错误: - + ``` ModuleNotFoundError:No module named ‘_ctypes’ ``` - **可能原因** + 环境中未安装“libffi”和“libffi-devel”。 - **解决办法** - 1. 通过命令“apt-get install libffi\* -y”,在线安装。 2. 完成后,重新安装python3。 @@ -137,25 +152,26 @@ ## 编译构建过程中,提示“No module named 'Crypto'” - **现象描述** + 编译构建过程中出现以下错误: - + ``` ModuleNotFoundError: No module named 'Crypto' ``` - **可能原因** + 环境中未安装“Crypto”。 - **解决办法** - 方法1:通过命令“pip3 install Crypto”,在线安装。 方法2:离线安装。 通过网页[https://pypi.org/project/pycrypto/#files](https://pypi.org/project/pycrypto/#files),下载源码。 - ![zh-cn_image_0000001226794696](figures/zh-cn_image_0000001226794696.png) + ![faq-download-pycrypto](figures/faq-download-pycrypto.png) 将源码放置在Linux服务器中,解压,并安装“python3 setup.py install”。 @@ -165,25 +181,26 @@ ## (Hi3861)编译构建过程中,提示“No module named 'ecdsa'” - **现象描述** + 编译构建过程中出现以下错误: - + ``` ModuleNotFoundError:No module named 'ecdsa' ``` - **可能原因** + 环境中未安装“ecdsa”。 - **解决办法** - 方法1:通过命令“pip3 install ecdsa”,在线安装。 方法2:离线安装 通过网页[https://pypi.org/project/ecdsa/#files](https://pypi.org/project/ecdsa/#files),下载安装包。 - ![zh-cn_image_0000001271594753](figures/zh-cn_image_0000001271594753.png) + ![faq-download-ecdsa](figures/faq-download-ecdsa.png) 将安装包放置Linux服务器中,并安装“pip3 install ecdsa-0.15-py2.py3-none-any.whl”。 @@ -193,25 +210,26 @@ ## (Hi3861)编译构建过程中,提示“Could not find a version that satisfies the requirement six>=1.9.0” - **现象描述** + 编译构建过程中出现以下错误: - + ``` Could not find a version that satisfies the requirement six>=1.9.0 ``` - **可能原因** + 环境中未安装合适的“six”。 - **解决办法** - 方法1:通过命令“pip3 install six”,在线安装。 方法2:离线安装。 通过网页[https://pypi.org/project/six/#files](https://pypi.org/project/six/#files),下载安装包。 - ![zh-cn_image_0000001271474573](figures/zh-cn_image_0000001271474573.png) + ![faq-download-six](figures/faq-download-six.png) 将源码放置在Linux服务器中,并安装“pip3 install six-1.14.0-py2.py3-none-any.whl”。 @@ -221,25 +239,28 @@ ## (Hi3861)编译构建过程中,提示找不到“-lgcc” - **现象描述** + 编译构建过程中出现以下错误: - + ``` riscv32-unknown-elf-ld: cannot find -lgcc ``` - **可能原因** + 交叉编译器gcc_riscv32的PATH添加错误,如下,在"bin"后多添加了一个“/”,应该删除。 - + ``` ~/gcc_riscv32/bin/:/data/toolchain/ ``` - **解决办法** + 重新修改gcc_riscv32的PATH,将多余的“/”删除。 - + ``` ~/gcc_riscv32/bin:/data/toolchain/ ``` @@ -248,15 +269,18 @@ ## (Hi3861)安装kconfiglib时,遇到lsb_release错误 - **现象描述** + 安装kconfiglib过程中遇到如下错误打印: - + ``` subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1. ``` - **可能原因** + lsb_release模块基于的python版本与现有python版本不一致。 - **解决办法** + 执行"find / -name lsb_release",找到lsb_release位置并删除,如:"sudo rm -rf /usr/bin/lsb_release"。 diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-common-burnerr.md b/zh-cn/device-dev/quick-start/quickstart-pkg-common-burnerr.md new file mode 100644 index 0000000000000000000000000000000000000000..37d5448406177c8ac2e245bbb15092d400ab4ac6 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-common-burnerr.md @@ -0,0 +1,122 @@ +# 烧录异常处理 + + +## 烧写选择串口后提示“Error: Opening COMxx: Access denied” + +- **现象描述** + + 单击烧写并选择串口后,出现Error: Opening COMxx: Access denied。 + + **图1** 打开串口失败图   + + ![hi3516-faq-serial-access-denied](figures/hi3516-faq-serial-access-denied.png) + +- **可能原因** + + 串口已经被占用。 + +- **解决办法** + +1. 按图依次选择下拉框,查找带有serial-xx的终端。 + + **图2** 查找是否存在占用串口的终端   + + ![hi3516-faq-serial-check](figures/hi3516-faq-serial-check.png) + +2. 单击标号中的垃圾桶图标,关闭串口。 + + **图3** 关闭串口终端   + + ![hi3516-faq-serial-close-terminal](figures/hi3516-faq-serial-close-terminal.png) + +3. 重新单击烧写,选择串口并开始烧写程序。 + + **图4** 重新启动烧写任务   + + ![hi3516-faq-serial-reburn](figures/hi3516-faq-serial-reburn.png) + + +## Windows电脑与单板网络连接失败 + +- **现象描述** + + 单击烧写并选择串口后,无法获取文件。 + + **图5** 网络不通,单板无法获取文件图   + + ![hi3516-faq-network-fail](figures/hi3516-faq-network-fail.png) + +- **可能原因** + + 单板网络与Windows电脑不联通。 + + Windows电脑防火墙未允许Visual Studio Code联网。 + +- **解决方法** + +1. 检查网线是否连接。 + +2. 单击Windows防火墙。 + + **图6** 网络防火墙设置图   + + ![hi3516-faq-firewall-setting](figures/hi3516-faq-firewall-setting.png) + +3. 单击“允许应用通过防火墙”。 + + **图7** 防火墙和网络保护界面图   + + ![hi3516-faq-firewall-setting-allow](figures/hi3516-faq-firewall-setting-allow.png) + +4. 查找Visual Studio Code应用。 + + **图8** 查找Visual Studio Code应用图   + + ![hi3516-faq-firewall-find-vscode](figures/hi3516-faq-firewall-find-vscode.png) + +5. 勾选Visual Studio Code的专用和公用网络的访问权限。 + + **图9** 允许Visual Studio Code应用访问网络   + + ![hi3516-faq-firewall-vscode-allow-network](figures/hi3516-faq-firewall-vscode-allow-network.png) + + +## (Hi3516)串口无回显 + +- **现象描述** + + 串口显示已连接,重启单板后,回车无任何回显。 + +- **可能原因1** + + 串口连接错误。 + +- **解决办法** + + 修改串口号。 + + 请查看设备管理器,确认连接单板的串口与终端中连接串口是否一致,若不一致,请按[串口访问失败的步骤](#烧写选择串口后提示error-opening-comxx-access-denied)修改串口号。 + +- **可能原因2** + + 单板U-boot被损坏。 + +- **解决办法** + + 烧写U-boot。 + + 若上述步骤依旧无法连接串口,可能由于单板U-boot损坏,按下述步骤烧写U-boot。 + +1. 获取引导文件U-boot。 + > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** + > 单板的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/upload_hi3516_small_system-0000001326267405)中描述的烧写方法,选择对应单板的U-boot文件进行烧写。 + +3. 烧写完成后,登录串口如下图所示。 + + **图10** U-boot烧写完成串口显示图   + + ![hi3516-faq-burn-uboot-success](figures/hi3516-faq-burn-uboot-success.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-faq-hb.md b/zh-cn/device-dev/quick-start/quickstart-pkg-common-hberr.md similarity index 93% rename from zh-cn/device-dev/quick-start/quickstart-standard-faq-hb.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-common-hberr.md index 9accfa1781e1ae816c3d304f005e942809ffcf2c..bdedcf08c819bcbb38e26caebf858f23a1d32cba 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-faq-hb.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-common-hberr.md @@ -1,18 +1,21 @@ -# hb安装异常 +# hb安装异常处理 ## hb安装过程中出现乱码、段错误 - **现象描述** + 执行“python3 -m pip install --user ohos-build”出现乱码、段错误(segmentation fault)。 - **可能原因** + pip版本过低。 - **解决办法** + 执行如下命令升级pip。 - + ``` python3 -m pip install -U pip ``` @@ -21,15 +24,18 @@ ## hb安装过程中提示"cannot import 'sysconfig' from 'distutils'" - **现象描述** + 执行“python3 -m pip install --user ohos-build”提示"cannot import 'sysconfig' from 'distutils'" - **可能原因** + 缺少distutils模块。 - **解决办法** + 执行如下命令安装。 - + ``` sudo apt-get install python3.8-distutils ``` @@ -38,15 +44,18 @@ ## hb安装过程中提示"module 'platform' has no attribute 'linux_distribution'" - **现象描述** + 执行“python3 -m pip install --user ohos-build”提示"module 'platform' has no attribute 'linux_distribution'" - **可能原因** + python3 pip安装兼容性问题。 - **解决办法** + 执行如下命令重新安装pip。 - + ``` sudo apt remove python3-pip curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py @@ -57,15 +66,17 @@ ## hb安装过程中提示"Could not find a version that satisfies the requirement ohos-build" - **现象描述** + 执行“python3 -m pip install --user ohos-build”提示"Could not find a version that satisfies the requirement ohos-build" - **可能原因** - 可能是网络环境较差导致的安装失败。 + + 可能是网络环境较差导致的安装失败。 - **解决办法** 1. 请检查网络连接是否正常。如果网络有问题,请修复网络问题后重新安装。 2. 若网络正常,请尝试指定临时pypi源的方式安装: - + ``` python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ohos-build ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-common-proxy.md b/zh-cn/device-dev/quick-start/quickstart-pkg-common-proxy.md new file mode 100644 index 0000000000000000000000000000000000000000..04321a5b064375a50da2c94ac7cc66aebf86bcff --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-common-proxy.md @@ -0,0 +1,42 @@ +# 配置代理 + + +### 配置Python代理 + +1. 新建代理配置文件。 + + ``` + mkdir ~/.pipvim ~/.pip/pip.conf + ``` + +2. 在文件中写入如下代理信息并保存退出。 + + ``` + [global] + index-url = http://代理网址 + trusted-host = 可信任的镜像地址 + timeout = 120 + ``` + + +### 配置NPM代理 + +1. 新建代理配置文件。 + + ``` + vim ~/.npmrc + ``` + +2. 在文件中写入如下代理信息并保存退出。 + + ``` + registry=http://代理网址 + strict-ssl=false + ``` + +3. 将以下内容添加到.bashrc中并保存退出。 + + ``` + export NPM_REGISTRY=http://代理网址 + source .bashrc + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-env.md b/zh-cn/device-dev/quick-start/quickstart-pkg-env.md new file mode 100644 index 0000000000000000000000000000000000000000..313c291e3e917767472787f90f4b74cb68de948f --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-env.md @@ -0,0 +1,4 @@ +# 搭建开发环境 + + +在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,建议使用Ubuntu的编译环境对源码进行编译。同时,开发板的烧录需要在Windows环境中进行。 diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-info.md b/zh-cn/device-dev/quick-start/quickstart-pkg-info.md new file mode 100644 index 0000000000000000000000000000000000000000..aa2bd522a5e6f8487e5bf0b38a881d6069f2286f --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-info.md @@ -0,0 +1,13 @@ +# 常用信息 + + + +- **[配置代理](quickstart-pkg-common-proxy.md)** + +- **[使用build.sh脚本编译源码](quickstart-pkg-common-build.md)** + +- **[hb安装异常处理](quickstart-pkg-common-hberr.md)** + +- **[编译异常处理](quickstart-pkg-common-builderr.md)** + +- **[烧录异常处理](quickstart-pkg-common-burnerr.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-install_package.md b/zh-cn/device-dev/quick-start/quickstart-pkg-install_package.md new file mode 100644 index 0000000000000000000000000000000000000000..541b0e7ef851edcf98189115245045898dba914d --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-install_package.md @@ -0,0 +1,37 @@ +# 安装库和工具集 + + +使用命令行进行设备开发时,可以通过以下步骤安装编译OpenHarmony需要的库和工具。 + + +相应操作在Ubuntu环境中进行。 + + +1. 使用如下apt-get命令安装后续操作所需的库和工具: + + ``` + 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 libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中: + > + > - Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。 + > + > - Java要求java8及以上版本,此处以java8为例。 + +2. 将Python 3.8设置为默认Python版本。 + + 查看Python 3.8的位置: + + + ``` + which python3.8 + ``` + + 将Python和Python3切换为Python 3.8: + + ``` + sudo update-alternatives --install /usr/bin/python python {Python 3.8 路径} 1 #{Python 3.8 路径}为上一步查看的Python 3.8的位置 + sudo update-alternatives --install /usr/bin/python3 python3 {Python 3.8 路径} 1 #{Python 3.8 路径}为上一步查看的Python 3.8的位置 + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-install_tool.md b/zh-cn/device-dev/quick-start/quickstart-pkg-install_tool.md new file mode 100644 index 0000000000000000000000000000000000000000..54883773c4ea30aa1acd55e5bdd1f56297c51f3b --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-install_tool.md @@ -0,0 +1,102 @@ +# 安装编译工具 + + +## 安装编译工具 + +想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建指南](../subsystems/subsys-build-all.md)。 + +相关操作在Ubuntu环境下进行。 + + +### 安装hb + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 如需安装代理,请参考[配置代理](quickstart-pkg-common-proxy.md)。 + +1. 运行如下命令安装hb并更新至最新版本 + + ``` + pip3 install --user build/lite + ``` + +2. 设置环境变量 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/.local/bin:$PATH + ``` + + 执行如下命令更新环境变量。 + + ``` + source ~/.bashrc + ``` + +3. 在源码目录执行"hb -h",界面打印以下信息即表示安装成功: + + ``` + 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 + ``` + +> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** +> - 可采用以下命令卸载hb: +> +> ``` +> pip3 uninstall ohos-build +> ``` +> +> - 若安装hb的过程中遇到问题,请参见下文[常见问题](quickstart-pkg-common-hberr.md)进行解决。 + + +### 安装LLVM(仅OpenHarmony_v1.x分支/标签需要) + +> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** +> 如果下载的源码为OpenHarmony_v1.x分支/标签,请按下面的步骤安装9.0.0版本的llvm。 +> +> 如果下载的源码为Master及非OpenHarmony_v1.x分支/标签,可直接跳过本小节,hb会自动下载最新的llvm。 + +1. 打开Linux编译服务器终端。 + +2. [下载LLVM工具](https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-36191/linux/llvm-linux-9.0.0-36191.tar)。 + +3. 解压LLVM安装包至~/llvm路径下。 + + ``` + tar -zxvf llvm.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + + ``` + export PATH=~/llvm/bin:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-prepare.md b/zh-cn/device-dev/quick-start/quickstart-pkg-prepare.md new file mode 100644 index 0000000000000000000000000000000000000000..62abffed40b0d40ba7c093e1e03302e4cb963a69 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-prepare.md @@ -0,0 +1,93 @@ +# 准备开发环境 + + +在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,建议使用Ubuntu的编译环境对源码进行编译。同时,开发板的烧录需要在Windows环境中进行。 + +在基于命令行方式开发的过程中,除下述[Windows环境要求](#windows环境要求)、[Ubuntu环境要求](#ubuntu环境要求)外,不对开发设备做另外的要求,请用户自行准备Windows环境、Ubuntu环境。本章节主要介绍通过Samba服务器实现Windows环境远程连接Ubuntu环境的方法。 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> OpenHarmony还为开发者提供了[Docker环境](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/gettools-acquire.md),整合的docker包在很大程度上简化了编译前的环境配置,习惯使用命令行的开发者也可以选择Docker环境进行编译 。 + + +进行工具安装之前,需要做如下准备。 + + +## Windows环境要求 + +源码烧录需要Windows10 64位的系统环境。 + + +## Ubuntu环境要求 + +- Ubuntu18.04及以上版本,内存推荐16 GB及以上。 + +- Ubuntu系统的用户名不能包含中文字符。 + + +## 远程访问准备 + +当在Windows下进行烧录时,开发者需要访问Ubuntu环境下的源码和镜像文件。您可以使用习惯的文件传输或共享工具实现文件的共享或传输。 + +此处介绍通过Samba服务器进行连接的操作方法。 + + +### 配置Samba服务器 + +在Ubuntu环境下进行以下操作: + +1. 安装Samba软件包。 + + ``` + sudo apt-get install samba samba-common + ``` + +2. 修改Samba配置文件,配置共享信息。 + 打开配置文件: + + ``` + sudo gedit /etc/samba/smb.conf + ``` + + 在配置文件末尾添加以下配置信息(根据实际需要配置相关内容): + + + ``` + [Share] #在Windows中映射的根文件夹名称(此处以“Share”为例) + comment = Shared Folder #共享信息说明 + path = /home/share #共享目录 + valid users = username #可以访问该共享目录的用户(Ubuntu的用户名) + directory mask = 0775 #默认创建的目录权限 + create mask = 0775 #默认创建的文件权限 + public = yes #是否公开 + writable = yes #是否可写 + available = yes #是否可获取 + browseable = yes #是否可浏览 + ``` + +3. 添加Samba服务器用户和访问密码。 + + ``` + sudo smbpasswd -a username #用户名为Ubuntu用户名。输入命令后,根据提示设置密码。 + ``` + +4. 重启Samba服务。 + + ``` + sudo service smbd restart + ``` + + +### 设置Windows映射 + +在Windows环境下进行以下操作: + +1. 右键计算机选择映射网络驱动器,输入共享文件夹信息。在文件夹输入框填入Ubuntu设备的IP地址和Ubuntu共享文件夹的路径。 + + ![quickstart-pkg-prepare-networkdriver](figures/quickstart-pkg-prepare-networkdriver.png) + +2. 输入Samba服务器的访问用户名和密码([在配置Samba服务器时已完成配置](#配置samba服务器))。 + + ![quickstart-pkg-prepare-setsamba](figures/quickstart-pkg-prepare-setsamba.png) + +3. 用户名和密码输入完成后即可在Windows下看到Linux的共享目录,并可对其进行访问。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-sourcecode-acquire.md b/zh-cn/device-dev/quick-start/quickstart-pkg-sourcecode.md similarity index 73% rename from zh-cn/device-dev/quick-start/quickstart-ide-lite-sourcecode-acquire.md rename to zh-cn/device-dev/quick-start/quickstart-pkg-sourcecode.md index 99ada780545742afc03f3ce5c0b29698142bb018..897b3cea39728f27f7fefcc56420c33fcb21485a 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-sourcecode-acquire.md +++ b/zh-cn/device-dev/quick-start/quickstart-pkg-sourcecode.md @@ -10,22 +10,22 @@ 2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 -3. 安装git客户端和git-lfs。(上述工具已在搭建环境章节安装。如已安装,请忽略) - +3. 安装git客户端和git-lfs。(上述工具已在安装必要的库和工具小节安装。如已安装,请忽略) + 更新软件源: - + ``` sudo apt-get update ``` 通过以下命令安装: - + ``` sudo apt-get install git git-lfs ``` 4. 配置用户信息。 - + ``` git config --global user.name "yourname" git config --global user.email "your-email-address" @@ -33,9 +33,9 @@ ``` 5. 执行如下命令安装码云repo工具。 - + 下述命令中的安装路径以"~/bin"为例,请用户自行创建所需目录。 - + ``` mkdir ~/bin curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo @@ -44,7 +44,7 @@ ``` 6. 将repo添加到环境变量。 - + ``` vim ~/.bashrc # 编辑环境变量 export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息 @@ -55,12 +55,17 @@ ## 获取方式 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> Master主干为开发分支,开发者可通过Master主干获取最新特性。发布分支代码相对比较稳定,开发者可基于发布分支代码进行商用功能开发。 +> 发布分支代码相对比较稳定,开发者可基于发布分支代码进行商用功能开发。Master主干为开发分支,开发者可通过Master主干获取最新特性。 -- **OpenHarmony主干代码获取** +- **OpenHarmony发布分支代码获取** + + OpenHarmony各个版本发布分支的源码获取方式请参考[Release-Notes](../../release-notes/Readme.md)。 - 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 - + +- **OpenHarmony主干代码获取** + + 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 + ``` repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify repo sync -c @@ -69,22 +74,18 @@ 方式二:通过repo + https下载。 - + ``` repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify repo sync -c repo forall -c 'git lfs pull' ``` -- **OpenHarmony发布分支代码获取** - - OpenHarmony各个版本发布分支的源码获取方式请参考[Release-Notes](../../release-notes/Readme.md)。 - -### 执行prebuilts +## 执行prebuilts 在源码根目录下执行prebuilts脚本,安装编译器及二进制工具。 - + ``` bash build/prebuilts_download.sh ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg.md b/zh-cn/device-dev/quick-start/quickstart-pkg.md new file mode 100644 index 0000000000000000000000000000000000000000..b13f806e0f01e594a5393aeb13a7dd60c59a36a8 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-pkg.md @@ -0,0 +1,31 @@ +# 使用命令行快速入门 + + +- 基于命令行入门 + - 搭建开发环境 + - [准备开发环境](quickstart-pkg-prepare.md) + - [安装库和工具集](quickstart-pkg-install_package.md) + - [获取源码](quickstart-pkg-sourcecode.md) + - [安装编译工具](quickstart-pkg-install_tool.md) + - 轻量系统(基于Hi3861开发板) + - [安装Hi3861开发板特有环境](quickstart-pkg-3861-tool.md) + - [编写“Hello World”程序](quickstart-pkg-3861-helloworld.md) + - [编译](quickstart-pkg-3861-build.md) + - [烧录](quickstart-pkg-3861-burn.md) + - [运行](quickstart-pkg-3861-running.md) + - 小型系统(基于Hi3516开发板) + - [编写“Hello World”程序](quickstart-pkg-3516-helloworld.md) + - [编译](quickstart-pkg-3516-build.md) + - [烧录](quickstart-pkg-3516-burn.md) + - [运行](quickstart-pkg-3516-running.md) + - 标准系统(基于RK3568开发板) + - [编写“Hello World”程序](quickstart-pkg-3568-helloworld.md) + - [编译](quickstart-pkg-3568-build.md) + - [烧录](quickstart-pkg-3568-burn.md) + - [运行](quickstart-pkg-3568-running.md) + - 常用信息 + - [配置代理](quickstart-pkg-common-proxy.md) + - [使用build.sh脚本编译源码](quickstart-pkg-common-build.md) + - [hb安装异常处理](quickstart-pkg-common-hberr.md) + - [编译异常处理](quickstart-pkg-common-builderr.md) + - [烧录异常处理](quickstart-pkg-common-burnerr.md) \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-hi3516.md deleted file mode 100644 index 4840b3381104344ffed9a8efaee8130b4944969b..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-hi3516.md +++ /dev/null @@ -1,20 +0,0 @@ -# Hi3516开发板介绍 - - -## 开发板简介 - -Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP(Image Signal Processor)、H.265视频压缩编码器以及高性能NNIE引擎,具备低码率、高画质、低功耗等特点,并具备强劲的智能处理和分析能力。 - - **图1** Hi3516单板正面外观图   - -![zh-cn_image_0000001226922318](figures/zh-cn_image_0000001226922318.png) - - -## 开发板规格 - - **表1** Hi3516开发板规格清单 - -| 规格类型 | 规格清单 | -| -------- | -------- | -| **处理器及内部存储** | - Hi3516DV300芯片
- DDR3 1GB
- eMMC4.5,8GB容量 | -| **外部器件** | - 以太网口
- 音频视频
  - 1路语音输入
  - 1路单声道(AC_L)输出,接3W功放(LM4871)
  - MicroHDMI(1路HDMI 1.4)
- 摄像头
  - 传感器IMX335
  - 镜头M12,焦距4mm,光圈1.8
- 显示屏
  - LCD连接器(2.35寸)
  - LCD连接器(5.5寸)
- 外部器件及接口
  - SD卡接口
  - JTAG/I2S接口
  - ADC接口
  - 舵机接口
  - Grove连接器
  - USB2.0(Type C)
  - 功能按键3个,2个用户自定义按键,1个升级按键
  - LED指示灯,绿灯,红灯 | diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-rk3568.md b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-rk3568.md deleted file mode 100644 index 24c654595917bcbcc0641ae0ccc8f6959ad6b520..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-rk3568.md +++ /dev/null @@ -1,41 +0,0 @@ -# RK3568开发板介绍 - - -## 开发板简介 - -RK3568开发板基于Rockchip RK3568芯片,集成双核心架构GPU以及高效能NPU;搭载四核64位Cortex-A55处理器,采用22nm先进工艺,主频高达2.0GHz;支持蓝牙、Wi-Fi、音频、视频和摄像头等功能,拥有丰富的扩展接口,支持多种视频输入输出接口;配置双千兆自适应RJ45以太网口,可满足NVR、工业网关等多网口产品需求。 - - **图1** RK3568开发板正面 -   -![zh-cn_image_0000001271442261](figures/zh-cn_image_0000001271442261.png) - - **图2** RK3568开发板背面  -  -![zh-cn_image_0000001226602394](figures/zh-cn_image_0000001226602394.png) - - -## 开发板规格 - - **表1** RK3568开发板规格说明 - -| 规格类型 | 规格清单 | -| -------- | -------- | -| 显示接口 | - 1×HDMI2.0(Type-A)接口,支持4K/60fps输出
- 2×MIPI接口,支1920\*1080\@60fps输出
- 1×eDP接口,支持2K\@60fps输出 | -| 音频接口 | - 1×8ch I2S/TDM/PDM
- 1×HDMI音频输出
- 1×喇叭输出
- 1×耳机输出
- 1×麦克风,板载音频输入 | -| 以太网 | 2×GMAC(10/100/1000M) | -| 无线网络 | SDIO接口,支持WIFI6 5G/2.5G,BT4.2 | -| 摄像头接口 | MIPI-CSI2,1x4-lane/2x2-lane\@2.5Gbps/lane | -| USB | - 2×USB2.0 Host,Type-A
- 1×USB3.0 Host,Type-A
- 1×USB3.0 OTG | -| PCIe | 1×2Lanes PCIe3.0 Connector (RC Mode) | -| SATA | 1×SATA3.0 Connector | -| SDMMC | 1×Micro SD Card3.0 | -| 按键 | - 1×Vol+/Recovery
- 1×Reset
- 1×Power
- 1×Vol-
- 1×Mute | -| 调试 | 1×调试串口 | -| RTC | 1×RTC | -| IR | 1×IR | -| 三色灯 | 3×LED | -| G-sensor | 1×G-sensor | -| FAN | 1×Fan | -| 扩展接口 | 20Pin扩展接口包括:
- 2×ADC接口
- 2×I2C接口
- 7×GPIO口(或者3×gpio + 4×uart信号)
- 3×VCC电源(12V、3.3V、5V) | -| 底板尺寸 | 180mm×130mm | -| PCB规格 | 4 层板 | diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-env-setup.md b/zh-cn/device-dev/quick-start/quickstart-standard-env-setup.md deleted file mode 100644 index 1a22f7864fceb0ed8c11314110b1ff8a892a3301..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-env-setup.md +++ /dev/null @@ -1,384 +0,0 @@ -# 搭建标准系统环境 - - -## 系统要求 - -- Windows系统要求:Windows10 64位系统。 - -- Ubuntu系统要求:Ubuntu18.04~21.10版本,内存推荐16 GB及以上。 - -- Windows系统和Ubuntu系统的用户名不能包含中文字符。 - -- Windows和Ubuntu上安装的DevEco Device Tool为3.0 Release版本。 - - -## 安装必要的库和工具 - -编译OpenHarmony需要一些库和工具,可以通过以下步骤进行安装。 - -相应操作在Ubuntu环境中进行。 - -1. 使用如下apt-get命令安装后续操作所需的库和工具: - - ``` - 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 libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev - ``` - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中: - > - > - Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。 - > - > - Java要求java8及以上版本,此处以java8为例。 - -2. 将python 3.8设置为默认python版本。 - - 查看python 3.8的位置: - - - ``` - which python3.8 - ``` - - 将python和python3切换为python3.8: - - ``` - sudo update-alternatives --install /usr/bin/python python {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置 - sudo update-alternatives --install /usr/bin/python3 python3 {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置 - ``` - - -## 安装DevEco Device Tool - -通过Windows系统远程访问Ubuntu环境进行烧录等操作,需要先在Windows和Ubuntu下分别安装DevEco Device Tool。 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> DevEco Device Tool是OpenHarmony的一站式开发工具,支持源码开发、编译、烧录,调测等,本文主要用其远端链接Ubuntu环境进行烧录和运行。 - - -### 安装Window版本DevEco Device Tool - -1. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Windows版。 - -2. 解压DevEco Device Tool压缩包,双击安装包程序,点击Next进行安装。 - -3. 设置DevEco Device Tool的安装路径,请注意安装路径不能包含中文字符,同时建议安装到非系统盘符,点击**Next**。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如果您已安装DevEco Device Tool 3.0 Beta2及以前的版本,则在安装新版本时,会先卸载旧版本,卸载过程中出现如下错误提示时,请点击“Ignore”继续安装,该错误不影响新版本的安装。 - > - > ![zh-cn_image_0000001239275843](figures/zh-cn_image_0000001239275843.png) - - ![zh-cn_image_0000001270076961](figures/zh-cn_image_0000001270076961.png) - -4. 根据安装向导提示,勾选要自动安装的软件。 - - 1. 在弹出VSCode installation confirm页面,勾选“Install VScode 1.62.2automatically”,点击**Next**。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果检测到Visual Studio Code已安装,且版本为1.62及以上,则会跳过该步骤。 - - ![zh-cn_image_0000001237801283](figures/zh-cn_image_0000001237801283.png) - - 2. 在弹出的Python select page选择“Download from Huawei mirror”,点击**Next**。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果系统已安装可兼容的Python版本(Python 3.8~3.9版本),可选择“Use one of compatible on your PC”。 - - ![zh-cn_image_0000001193983334](figures/zh-cn_image_0000001193983334.png) - -5. 在以下界面点击**Next**。 - - ![zh-cn_image_0000001259180828](figures/zh-cn_image_0000001259180828.png) - -6. 请详细阅读以下界面的用户协议和隐私声明,这里须勾选"I accept the licenses",然后点击Next,安装向导才会继续进行软件下载和安装。 - - ![zh-cn_image_0000001307019009](figures/zh-cn_image_0000001307019009.png) - -7. 继续等待DevEco Device Tool安装向导自动安装DevEco Device Tool插件,直至安装完成,点击**Finish**,关闭DevEco Device Tool安装向导。 - - ![zh-cn_image_0000001239650137](figures/zh-cn_image_0000001239650137.png) - -8. 打开Visual Studio Code,进入DevEco Device Tool工具界面。至此,DevEco Device Tool Windows开发环境安装完成。 - - ![zh-cn_image_0000001225760456](figures/zh-cn_image_0000001225760456.png) - - -### 安装Ubuntu版本DevEco Device Tool - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 如果没有Ubuntu系统,可在Windows系统中通过虚拟机方式搭建Ubuntu系统,具体请参考[Ubuntu系统安装指导](https://developer.huawei.com/consumer/cn/training/course/video/C101639987816176315)。Ubuntu系统安装完成后,请根据指导完成[Ubuntu基础环境配置](https://developer.huawei.com/consumer/cn/training/course/video/C101639988048536240),然后再根据本章节进行DevEco Device Tool工具的安装。 - - -1. 将Ubuntu Shell环境修改为bash。 - - 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2,将Ubuntu shell修改为bash。 - - ``` - ls -l /bin/sh - ``` - - ![zh-cn_image_0000001226764302](figures/zh-cn_image_0000001226764302.png) - - 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 - - ``` - sudo dpkg-reconfigure dash - ``` - - ![zh-cn_image_0000001243641075](figures/zh-cn_image_0000001243641075.png) - -2. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Linux版本。 - -3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 - - 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.401.zip为软件包名称,请根据实际进行修改。 - - ``` - unzip devicetool-linux-tool-3.0.0.401.zip - ``` - 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.401.sh请根据实际进行修改。 - - ``` - chmod u+x devicetool-linux-tool-3.0.0.401.sh - ``` - -4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.401.sh请根据实际进行修改。 - - ``` - sudo ./devicetool-linux-tool-3.0.0.401.sh - ``` - -5. 在用户协议和隐私声明签署界面,请详细阅读用户协议和隐私声明,需签署同意用户协议和隐私声明才能进行下一步的安装。 - - ![zh-cn_image_0000001322167645.png](figures/zh-cn_image_0000001322167645.png) - - 安装完成后,当界面输出“DevEco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 - - ![zh-cn_image_0000001198722374](figures/zh-cn_image_0000001198722374.png) - - -## 配置Windows远程访问Ubuntu环境 - - -### 安装SSH服务并获取远程访问的IP地址 - -1. 在Ubuntu系统中,打开终端工具,执行如下命令安装SSH服务。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如果执行该命令失败,提示openssh-server和openssh-client依赖版本不同,请根据CLI界面提示信息,安装openssh-client相应版本后(例如:sudo apt-get install openssh-client=1:8.2p1-4),再重新执行该命令安装openssh-server。 - - - ``` - sudo apt-get install openssh-server - ``` - -2. 执行如下命令,启动SSH服务。 - - ``` - sudo systemctl start ssh - ``` - -3. 执行如下命令,获取当前用户的IP地址,用于Windows系统远程访问Ubuntu环境。 - - ``` - ifconfig - ``` - - ![zh-cn_image_0000001215737140](figures/zh-cn_image_0000001215737140.png) - - -### 安装Remote SSH - -1. 打开Windows系统下的Visual Studio Code,点击![zh-cn_image_0000001239080359](figures/zh-cn_image_0000001239080359.png),在插件市场的搜索输入框中输入“remote-ssh”。 - - ![zh-cn_image_0000001193920448](figures/zh-cn_image_0000001193920448.png) - -2. 点击Remote-SSH的**Install**按钮,安装Remote-SSH。安装成功后,在**INSTALLED**下可以看到已安装Remote-SSH。 - - ![zh-cn_image_0000001238880335](figures/zh-cn_image_0000001238880335.png) - - -### 远程连接Ubuntu环境 - -1. 打开Windows系统的Visual Studio Code,点击![zh-cn_image_0000001238760373](figures/zh-cn_image_0000001238760373.png),在REMOTE EXPLORER页面点击+按钮。 - - ![zh-cn_image_0000001215878922](figures/zh-cn_image_0000001215878922.png) - -2. 在弹出的SSH连接命令输入框中输入“ssh _username_\@_ip_address_”,其中ip_address为要连接的远程计算机的IP地址,username为登录远程计算机的帐号。 - - ![zh-cn_image_0000001215879750](figures/zh-cn_image_0000001215879750.png) - -3. 在弹出的输入框中,选择SSH configuration文件,选择默认的第一选项即可。 - - ![zh-cn_image_0000001260519729](figures/zh-cn_image_0000001260519729.png) - -4. 在SSH TARGETS中,找到远程计算机,点击![zh-cn_image_0000001194080414](figures/zh-cn_image_0000001194080414.png),打开远程计算机。 - - ![zh-cn_image_0000001215720398](figures/zh-cn_image_0000001215720398.png) - -5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机 。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 在Windows系统远程访问Ubuntu过程中,需要频繁的输入密码进行连接,为解决该问题,您可以使用SSH公钥来进行设置,设置方法请参考[注册远程访问Ubuntu环境的公钥](https://device.harmonyos.com/cn/docs/documentation/guide/ide-registering-public-key-0000001247162706)。 - - ![zh-cn_image_0000001215897530](figures/zh-cn_image_0000001215897530.png) - - 连接成功后,等待在远程计算机.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。 - - -## 获取源码 - -在Ubuntu环境下通过以下步骤获取OpenHarmony源码。 - - -### 准备工作 - -1. 注册码云gitee帐号。 - -2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 - -3. 安装git客户端和git-lfs。(上述工具已在安装必要的库和工具小节安装。如已安装,请忽略) - - 更新软件源: - - ``` - sudo apt-get update - ``` - - 通过以下命令安装: - - ``` - sudo apt-get install git git-lfs - ``` - -4. 配置用户信息。 - - ``` - git config --global user.name "yourname" - git config --global user.email "your-email-address" - git config --global credential.helper store - ``` - -5. 执行如下命令安装码云repo工具。 - - 下述命令中的安装路径以"~/bin"为例,请用户自行创建所需目录。 - - ``` - mkdir ~/bin - curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo - chmod a+x ~/bin/repo - pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests - ``` - -6. 将repo添加到环境变量。 - - ``` - vim ~/.bashrc # 编辑环境变量 - export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息 - source ~/.bashrc # 应用环境变量 - ``` - - -### 获取方式 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> Master主干为开发分支,开发者可通过Master主干获取最新特性。发布分支代码相对比较稳定,开发者可基于发布分支代码进行商用功能开发。 - -- **OpenHarmony主干代码获取** - - 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 - - ``` - repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - - 方式二:通过repo + https下载。 - - - ``` - repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - -- **OpenHarmony发布分支代码获取** - - OpenHarmony各个版本发布分支的源码获取方式请参考[Release-Notes](../../release-notes/Readme.md)。 - - -### 执行prebuilts - - 在源码根目录下执行prebuilts脚本,安装编译器及二进制工具。 - -``` -bash build/prebuilts_download.sh -``` - - -## 安装编译工具 - -hb是OpenHarmony的编译工具,可通过以下步骤在Ubuntu下进行安装。想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建指导](../subsystems/subsys-build-all.md)。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 如需安装代理,请参考[配置代理](../quick-start/quickstart-standard-reference.md#配置代理)。 - - -1. 运行如下命令安装hb并更新至最新版本 - - ``` - pip3 install --user build/lite - ``` - -2. 设置环境变量 - - ``` - vim ~/.bashrc - ``` - - 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 - - ``` - export PATH=~/.local/bin:$PATH - ``` - - 执行如下命令更新环境变量。 - - ``` - source ~/.bashrc - ``` - -3. 在源码目录执行"hb -h",界面打印以下信息即表示安装成功: - - ``` - 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 - ``` - - -> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** -> - 可采用以下命令卸载hb: -> -> ``` -> pip3 uninstall ohos-build -> ``` -> -> - 若安装hb的过程中遇到问题,请参见下文[常见问题](../quick-start/quickstart-standard-faq-hb.md)进行解决。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-faq-burning.md b/zh-cn/device-dev/quick-start/quickstart-standard-faq-burning.md deleted file mode 100644 index 59f633eea2e5f66cb296521ef0462ae6e8ac5d42..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-faq-burning.md +++ /dev/null @@ -1,92 +0,0 @@ -# 烧录异常 - - -## 烧写选择串口后提示“Error: Opening COMxx: Access denied” - -- **现象描述** - - 点击烧写并选择串口后,出现Error: Opening COMxx: Access denied。 - - **图1** 打开串口失败图   - - ![zh-cn_image_0000001271202461](figures/zh-cn_image_0000001271202461.png) - -- **可能原因** - 串口已经被占用。 - -- **解决办法** - -1. 按图依次选择下拉框,查找带有serial-xx的终端。 - - **图2** 查找是否存在占用串口的终端   - - ![zh-cn_image_0000001271202473](figures/zh-cn_image_0000001271202473.png) - -2. 点击标号中的垃圾桶图标,关闭串口。 - - **图3** 关闭串口终端   - - ![zh-cn_image_0000001271202469](figures/zh-cn_image_0000001271202469.png) - -3. 重新点击烧写,选择串口并开始烧写程序。 - - **图4** 重新启动烧写任务   - - ![zh-cn_image_0000001271562449](figures/zh-cn_image_0000001271562449.png) - - -## Windows电脑与单板网络连接失败 - -- **现象描述** - - 点击烧写并选择串口后,无法获取文件。 - - **图5** 网络不通,单板无法获取文件图   - - ![zh-cn_image_0000001226922306](figures/zh-cn_image_0000001226922306.png) - -- **可能原因** - - 单板网络与Windows电脑不联通。 - - Windows电脑防火墙未允许Visual Studio Code联网。 - -- **解决方法** - -1. 检查网线是否连接。 - -2. 点击Windows防火墙。 - - **图6** 网络防火墙设置图   - - ![zh-cn_image_0000001227082322](figures/zh-cn_image_0000001227082322.png) - -3. 点击“允许应用通过防火墙”。 - - **图7** 防火墙和网络保护界面图   - - ![zh-cn_image_0000001271202457](figures/zh-cn_image_0000001271202457.png) - -4. 查找Visual Studio Code应用。 - - **图8** 查找Visual Studio Code应用图   - - ![zh-cn_image_0000001271562445](figures/zh-cn_image_0000001271562445.png) - -5. 勾选Visual Studio Code的专用和公用网络的访问权限。 - - **图9** 允许Visual Studio Code应用访问网络  -  - ![zh-cn_image_0000001271442273](figures/zh-cn_image_0000001271442273.png) - - -## 烧写失败 - -- **现象描述** - 点击烧写并选择串口后,出现无法烧写的情况。 - -- **可能原因** - 安装IDE插件DevEco后未重启。 - -- **解决方法** - 重启IDE。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-faq-compose.md b/zh-cn/device-dev/quick-start/quickstart-standard-faq-compose.md deleted file mode 100644 index 10bd0232f170ce1efeb3d2f90b4ed4e2d4077e90..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-faq-compose.md +++ /dev/null @@ -1,161 +0,0 @@ -# 编译异常 - - -## Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt_pkg” - -- **现象描述** - Linux编译服务器终端输入不识别的命令时,提示"ImportError: No module named apt_pkg" - -- **可能原因** - python3 apt安装兼容性问题。 - -- **解决办法** - 执行如下命令重新安装python3-apt。 - - - ``` - sudo apt-get remove python3-apt - sudo apt-get install python3-apt - ``` - - -## 编译构建过程中,提示找不到“python” - -- **现象描述** - 编译构建过程中出现以下错误: - - - ``` - -bash: /usr/bin/python: No such file or directory - ``` - -- **可能原因**1 - 没有装python。 - -- **解决办法** - 请使用如下命令安装Python,下方以Python3.8为例。 - - - ``` - sudo apt-get install python3.8 - ``` - -- **可能原因2** - usr/bin目录下没有python软链接 - - ![zh-cn_image_0000001226922322](figures/zh-cn_image_0000001226922322.png) - -- **解决办法** - 请运行以下命令添加软链接: - - - ``` - # cd /usr/bin/ - # which python3 - # ln -s /usr/local/bin/python3 python - # python --version - ``` - - 例: - - ![zh-cn_image_0000001271562453](figures/zh-cn_image_0000001271562453.png) - - -## 编译构建过程中,提示找不到“python3” - -- **现象描述** - - ![zh-cn_image_0000001226602414](figures/zh-cn_image_0000001226602414.png) - -- **可能原因** - 没有装python3。 - -- **解决办法** - 请使用如下命令安装Python3。 - - - ``` - sudo apt-get install python3.8 - ``` - - -## 安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH” - -- **现象描述** - 安装python3过程中出现以下错误: - - - ``` - configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details - ``` - -- **可能原因** - 环境中未安装“gcc”。 - -- **解决办法** - 1. 通过命令“apt-get install gcc”在线安装。 - 2. 完成后,重新安装python3。 - - -## 安装python3过程中,提示“-bash: make: command not found” - -- **现象描述** - 安装python3过程中出现以下错误: - - - ``` - -bash: make: command not found - ``` - -- **可能原因** - 环境中未安装“make”。 - -- **解决办法** - 1. 通过命令“apt-get install make”在线安装。 - 2. 完成后,重新安装python3。 - - -## 安装python3过程中,提示“No module named '_ctypes'” - -- **现象描述** - 安装python3过程中出现以下错误: - - - ``` - ModuleNotFoundError:No module named ‘_ctypes’ - ``` - -- **可能原因** - 环境中未安装“libffi”和“libffi-devel”。 - -- **解决办法** - 1. 通过命令“apt-get install libffi\* -y”,在线安装。 - 2. 完成后,重新安装python3。 - - -## 编译构建过程中,提示“No module named 'Crypto'” - -- **现象描述** - 编译构建过程中出现以下错误: - - - ``` - ModuleNotFoundError: No module named 'Crypto' - ``` - -- **可能原因** - 环境中未安装“Crypto”。 - -- **解决办法** - - 方法1:通过命令“pip3 install Crypto”,在线安装。 - - 方法2:离线安装。 - - 通过网页[https://pypi.org/project/pycrypto/#files](https://pypi.org/project/pycrypto/#files),下载源码。 - - ![zh-cn_image_0000001227082334](figures/zh-cn_image_0000001227082334.png) - - 将源码放置在Linux服务器中,解压,并安装“python3 setup.py install”。 - - 完成上述安装后,重新构建。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-hitool.md b/zh-cn/device-dev/quick-start/quickstart-standard-hitool.md deleted file mode 100644 index a77bcfb579eee7bd3371e1991f4984d4e127afae..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-hitool.md +++ /dev/null @@ -1,69 +0,0 @@ -# 使用HiTool烧录代码 - - -针对Hi3516DV300开发板,除了DevEco Device Tool外,还可以使用HiTool进行烧录。 - - -## 前提条件 - -- 开发板相关源码已编译完成,已形成烧录文件。 - -- 客户端(操作平台,例如Windows系统)已下载并安装[HiTool工具](http://www.hihope.org/download/download.aspx)。 - -- 客户端(操作平台,例如Windows系统)已安装USB驱动,可参考[Hi3516DV300/Hi3518EV300开发板USB驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)。 - -- 客户端已安装串口终端工具(例如IPOP)。 - -- 使用USB线缆、串口线缆连接客户端与开发板。 - - -## 操作步骤 - -1. 准备烧录相关文件。 - - 1. 在客户端新建用于保存烧录文件的文件夹,例如D:\L2。 - - 2. 将编译完成的源码包下载至客户端并解压,将烧录相关文件拷贝至步骤1中新建的文件夹。 - - Hi3516DV300开发板烧写所需文件为:boot.img、Hi3516DV300-emmc.xml、system.img、u-boot-hi3516dv300_emmc.bin、uImage、updater.img、userdata.img、vendor.img。 - -2. 使用HiTool烧录。 - - 1. 打开HiTool。 - - 2. 设置HiTool参数。 - - 传输方式选择USB口,烧写方式选择烧写eMMC(单板的存储介质为eMMC)。 - - 3. 单击浏览在步骤1创建的文件夹中选择烧写配置文件(例如Hi3516DV300-emmc.xml)。 - - ![zh-cn_image_0000001249937194](figures/zh-cn_image_0000001249937194.png) - - 4. 单击烧写后,按住开发板上串口旁的按钮(Update键),并拔插USB线(上下电)。 - - 烧录开始后,可以在HiTool工具下方的控制台区域观察到烧录过程中的打印信息。 - - 烧录完成后,HiTool弹出提示框显示烧写成功。 - - 5. 单击确定。 - -3. 导入启动参数。 - - 1. 使用终端工具打开串口。 - - 2. 拔插开发板电源使其重启,3s内在串口终端输入回车。 - - 终端界面中出现hisilicon \#表示已连接开发板串口。 - - 3. 在串口终端拷贝如下启动参数后,按回车完成配置。 - - ``` - setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused androidboot.selinux=permissive rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)';setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000' - - saveenv - - reset - ``` - - > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** - > 输入启动参数时,请勿自行删除其中的空行。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-ide-directory.md b/zh-cn/device-dev/quick-start/quickstart-standard-ide-directory.md deleted file mode 100644 index 23c92d7e820d16ba8ec5c3ca55dc2ad598006c4e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-ide-directory.md +++ /dev/null @@ -1,22 +0,0 @@ -## 标准系统快速入门(IDE方式) - -- [标准系统入门概述](quickstart-ide-standard-overview.md) -- 准备标准系统环境 - - [搭建Windows+Ubuntu混合开发环境](quickstart-ide-standard-env-setup-win-ubuntu.md) - - [获取源码](quickstart-ide-standard-sourcecode-acquire.md) -- [导入源码工程](quickstart-ide-standard-create-project.md) -- 运行“Hello World” - - Hi3516开发板 - - [编写“Hello World”程序](quickstart-ide-standard-running-hi3516-create.md) - - [编译](quickstart-ide-standard-running-hi3516-build.md) - - [烧录](quickstart-ide-standard-running-hi3516-burning.md) - - [运行](quickstart-ide-standard-running-hi3516-running.md) - - RK3568开发板 - - [编写“Hello World”程序](quickstart-ide-standard-running-rk3568-create.md) - - [编译](quickstart-ide-standard-running-rk3568-build.md) - - [烧录](quickstart-ide-standard-running-rk3568-burning.md) - - [运行](quickstart-ide-standard-running-rk3568-running.md) -- 附录 - - [Hi3516开发板介绍](quickstart-ide-standard-board-introduction-hi3516.md) - - [RK3568开发板介绍](quickstart-ide-standard-board-introduction-rk3568.md) - - [编译形态整体说明](quickstart-build.md) \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-overview.md b/zh-cn/device-dev/quick-start/quickstart-standard-overview.md deleted file mode 100644 index a565f4412d378c2afa376e85d8267cc330418ae5..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-overview.md +++ /dev/null @@ -1,41 +0,0 @@ -# 标准系统入门概述 - - -## 简介 - -OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文,开发者可以快速熟悉OpenHarmony标准系统的环境搭建、编译、烧录、调测以及运行“Hello World”等。 - -考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: - -- IDE方式:完全采用IDE(DevEco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 - -- 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 - OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 - -本文采用安装包方式进行介绍,习惯使用DevEco Device Tool的开发者可参考[标准系统快速入门(IDE方式)](../quick-start/quickstart-ide-standard-overview.md)。 - - -## 开发环境 - -推荐开发者采用Windows+Ubuntu环境进行OpenHarmony开发: - -- Windows:用于源码开发、烧录等。 - -- Ubuntu:用于源码编译。 - -本文将介绍如何基于Windows+Ubuntu环境进行OpenHarmony的开发。 - - -## 开发板 - -本文选取了两款典型开发板:Hi3516DV300、RK3516,并基于上述两款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-standard-board-introduction-hi3516.md),开发者可根据需要自行购买开发板。 - - -## 开发流程 - -标准系统快速入门流程如下图所示。 - - **图1** 标准系统快速入门开发流程   - - -![zh-cn_image_0000001227082314](figures/zh-cn_image_0000001227082314.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-package-directory.md b/zh-cn/device-dev/quick-start/quickstart-standard-package-directory.md deleted file mode 100644 index 9173ab71c468560ac1fbbe3374771a16c0a9414a..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-package-directory.md +++ /dev/null @@ -1,26 +0,0 @@ -## 标准系统快速入门(安装包方式) - -- [标准系统入门概述](quickstart-standard-overview.md) -- [搭建标准系统环境](quickstart-standard-env-setup.md) -- 运行“Hello World” - - Hi3516开发板 - - [编写“Hello World”程序](quickstart-std-3516-create.md) - - [编译](quickstart-standard-running-hi3516-build.md) - - [烧录](quickstart-standard-running-hi3516-burning.md) - - [运行](quickstart-standard-running-hi3516-running.md) - - RK3568开发板 - - [编写“Hello World”程序](quickstart-standard-running-rk3568-create.md) - - [编译](quickstart-standard-running-rk3568-build.md) - - [烧录](quickstart-standard-running-rk3568-burning.md) - - [运行](quickstart-standard-running-rk3568-running.md) -- 常见问题 - - [hb安装异常](quickstart-standard-faq-hb.md) - - [编译异常](quickstart-standard-faq-compose.md) - - [烧录异常](quickstart-standard-faq-burning.md) -- 附录 - - 开发板介绍 - - [Hi3516开发板介绍](quickstart-standard-board-introduction-hi3516.md) - - [RK3568开发板介绍](quickstart-standard-board-introduction-rk3568.md) - - [编译形态整体说明](quickstart-build.md) - - [参考信息](quickstart-standard-reference.md) - - [使用HiTool烧录代码](quickstart-standard-hitool.md) \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-reference.md b/zh-cn/device-dev/quick-start/quickstart-standard-reference.md deleted file mode 100644 index 513f7e8667a3133b4cf81d275b5a38749207beea..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-reference.md +++ /dev/null @@ -1,68 +0,0 @@ -# 参考信息 - - -## 使用build.sh脚本编译源码 - -1. 进入源码根目录,执行如下命令进行版本编译。 - - ``` - ./build.sh --product-name name --ccache - ``` - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > _name_为产品名称,例如Hi3516DV300、rk3568等。 - -2. 检查编译结果。编译完成后,log中显示如下: - - ``` - post_process - =====build name successful. - ``` - - 编译所生成的文件都归档在out/{device_name}/目录下,结果镜像输出在out/{device_name}/packages/phone/images/ 目录下。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 其他模块化编译操作,可参见[编译构建指导](../subsystems/subsys-build-all.md)。 - - -## 配置代理 - - -### 配置Python代理 - -1. 新建代理配置文件。 - - ``` - mkdir ~/.pipvim ~/.pip/pip.conf - ``` - -2. 在文件中写入如下代理信息并保存退出。 - - ``` - [global] - index-url = http://代理网址 - trusted-host = 可信任的镜像地址 - timeout = 120 - ``` - - -### 配置NPM代理 - -1. 新建代理配置文件。 - - ``` - vim ~/.npmrc - ``` - -2. 在文件中写入如下代理信息并保存退出。 - - ``` - registry=http://代理网址 - strict-ssl=false - ``` - -3. 将以下内容添加到.bashrc中并保存退出。 - - ``` - export NPM_REGISTRY=http://代理网址 - source .bashrc - ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md deleted file mode 100644 index 0183bd5f33a601d4d5ad2755f2e4df6c9a5f8096..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md +++ /dev/null @@ -1,47 +0,0 @@ -# 编译 - - -OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](quickstart-standard-reference.md)。 - - -在Ubuntu环境下进入源码根目录,执行如下命令进行编译: - - -1. 设置编译路径。 - - ``` - hb set - ``` - -2. 选择当前路径。 - - ``` - . - ``` - -3. 在hisilicon下选择hispark_taurus_standard并回车。 - - **图1** Hi3516编译设置图例   - - ![zh-cn_image_0000001268278138](figures/zh-cn_image_0000001268278138.png) - -4. 执行编译。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - 单独编译一个部件(例如hello),可使用“hb build -T _目标名称_”进行编译。 - > - > - 增量编译整个产品,可使用“hb build”进行编译。 - > - > - 完整编译整个产品,可使用“hb build -f”进行编译。 - > - > 此处以完整编译整个产品为例进行说明。 - - - ``` - hb build -f - ``` - -5. 编译结束后,出现“build success”字样,则证明构建成功。 - - > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** - > 编译结果文件及编译日志文件获取路径:out/hi3516dv300。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-burning.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-burning.md deleted file mode 100644 index 07260e729ed7d3709762cb918658b040ac99c446..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-burning.md +++ /dev/null @@ -1,89 +0,0 @@ -# 烧录 - - -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 - -Hi3516DV300开发板小型系统的烧录方式包括USB烧录、网口烧录两种方式,本文采用USB方式进行烧录。 - -## 导入源码 - -在编译完成后,[保证Windows系统可以远程访问Ubuntu环境](quickstart-standard-env-setup.md)的情况下,您还需要通过以下步骤将编译好的源码导入DevEco Device Tool,方可进行烧录。 - -1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 - - ![zh-cn_image_0000001278358765](figures/zh-cn_image_0000001278358765.png) - -2. 选择OpenHarmony源码根目录路径(需要访问Ubuntu下的源码目录),然后再选择**Import OpenHarmony Source**选项,点击**Import**进行导入。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 工程存储路径不能包含中文字符、空格。 - - ![zh-cn_image_0000001271477045](figures/zh-cn_image_0000001271477045.png) - -3. 在Import Project界面,选择**Product**后,会自动填充对应的SOC、Board、Company和Kernel信息,然后**Ohos Ver**选择对应的OpenHarmony源码版本。 - - ![zh-cn_image_0000001279426717](figures/zh-cn_image_0000001279426717.png) - -4. 点击**Open**打开工程或源码。 - - -## 烧录 - -完成源码导入后,通过以下步骤进行烧录: - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 使用USB烧录方式,在DevEco Device Tool 2.2 Beta2及更高版本中支持。 - -1. 请连接好电脑和待烧录开发板,需要连接USB口和串口,具体可参考[Hi3516DV300开发板介绍](quickstart-lite-introduction-hi3516.md)。 - -2. 根据[Hi3516DV300/Hi3518EV300开发板串口驱动安装指导](https://gitee.com/link?target=https%3A%2F%2Fdevice.harmonyos.com%2Fcn%2Fdocs%2Fdocumentation%2Fguide%2Fhi3516_hi3518-drivers-0000001050743695)、[Hi3516DV300/Hi3518EV300开发板USB驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)安装USB驱动及USB转串口的驱动。若您的设备中已安装此驱动,请忽略该步骤。 - -3. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 - - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 - - ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) - -4. 在菜单栏中点击**Project Settings**按钮,进入Hi3516DV300工程配置界面。 - - ![zh-cn_image_0000001198566364](figures/zh-cn_image_0000001198566364.png) - -5. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 - - ![zh-cn_image_0000001198566365](figures/zh-cn_image_0000001198566365.png) - -6. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 - - - upload_partitions:选择待烧录程序的配置文件(已预置默认的配置文件),该配置文件会指定烧录文件名称、起始烧录地址、地址长度等信息;同时请勾选**Enable to use upload_partitions_profile for upload**选项。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如需修改烧录profile文件,在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 - > - > 首次烧录,请勾选**Enable to use upload_partitions_profile for upload**选项,会自动生成upload_partitions文件。再次烧录时,可根据实际情况选择生成upload_partitions文件进行自定义烧录,也可以再勾选**Enable to use upload_partitions_profile for upload**选项,使用upload_partitions_profile重新生成upload_partitions文件用于烧录。 - - - upload_protocol:选择烧录协议,固定选择“hiburn-usb”。 - - - upload_port:选择已查询的串口号。 - - ![zh-cn_image_0000001177478136](figures/zh-cn_image_0000001177478136.png) - -7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -8. 点击hi3516dv300下的**Upload**按钮。 - - ![zh-cn_image_0000001267532292](figures/zh-cn_image_0000001267532292.png) - - 此时待烧录文件会从Ubuntu系统传输到Windows下,传输完成后界面显示“Operation paused, Please press Enter key to continue”时,请点击**Enter**键启动烧录。 - - ![zh-cn_image_0000001114129427](figures/zh-cn_image_0000001114129427.png) - -9. 在终端窗口显示如下提示信息时,请在15秒内,按住Update键,插拔USB线,最后松开Update键启动烧录。 - - ![zh-cn_image_0000001326412233.png](figures/zh-cn_image_0000001326412233.png) - - 启动烧录后,界面提示**SUCCESS**信息时,表示烧录成功。 - - ![zh-cn_image_0000001160649344](figures/zh-cn_image_0000001160649344.png) - -10. 烧录成功后,请根据运行章节进行操作,启动系统。 \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-running.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-running.md deleted file mode 100644 index e90e3789ff218595885a032473793ec9b113bcdc..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-running.md +++ /dev/null @@ -1,57 +0,0 @@ -# 运行 - - -## 启动系统 - -烧录完成后在Windows下通过以下步骤启动系统: - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 初次烧写标准系统,需要完成以下配置,后续烧写或者启动,可以跳过以下操作。 - -1. 在DevEco Device Tool中,点击Monitor,打开串口工具。 - - ![zh-cn_image_0000001226762374](figures/zh-cn_image_0000001226762374.png) - -2. 重启开发板,在倒计时结束前,按任意键进入系统。 - - ![zh-cn_image_0000001271442265](figures/zh-cn_image_0000001271442265.gif) - -3. 通过以下两条命令设置启动参数。 - - ``` - setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)'; - ``` - - - ``` - setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000' - ``` - - ![zh-cn_image_0000001271322437](figures/zh-cn_image_0000001271322437.png) - -4. 保存参数设置。 - - ``` - save - ``` - - ![zh-cn_image_0000001271562437](figures/zh-cn_image_0000001271562437.png) - -5. 重启开发板,完成系统启动。 - - ``` - reset - ``` - - ![zh-cn_image_0000001226762378](figures/zh-cn_image_0000001226762378.png) - - -## 运行“Hello World” - -设备启动后打开串口工具,在任意目录下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 - -![zh-cn_image_0000001226602398](figures/zh-cn_image_0000001226602398.png) - -## 下一步 - -恭喜!您已经完成了OpenHarmony标准系统的快速入门,接下来可[开发一个小示例](../guide/device-clock-guide.md),进一步熟悉OpenHarmony的开发。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burning.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burning.md deleted file mode 100644 index 6f213903a0c4a6ae9e107dbeb3176095cbe1decf..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burning.md +++ /dev/null @@ -1,86 +0,0 @@ -# 烧录 - - -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 - -RK3568的镜像烧录通过Windows环境进行烧录。 - - -## 导入源码 - -在编译完成后,[保证Windows系统可以远程访问Ubuntu环境](quickstart-standard-env-setup.md)的情况下,您还需要通过以下步骤将编译好的源码导入DevEco Device Tool,方可进行烧录。 - -1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 - - ![zh-cn_image_0000001278358765](figures/zh-cn_image_0000001278358765.png) - -2. 选择OpenHarmony源码根目录路径(需要访问Ubuntu下的源码目录),然后再选择**Import OpenHarmony Source**选项,点击**Import**进行导入。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 工程存储路径不能包含中文字符、空格。 - - ![zh-cn_image_0000001271477045](figures/zh-cn_image_0000001271477045.png) - -3. 在Import Project界面,选择**Product**后,会自动填充对应的SOC、Board、Company和Kernel信息,然后**Ohos Ver**选择对应的OpenHarmony源码版本。 - - ![zh-cn_image_0000001279587085](figures/zh-cn_image_0000001279587085.png) - -4. 点击**Open**打开工程或源码。 - - -## 烧录 - -完成源码导入后,通过以下步骤进行烧录: - -1. [下载](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows/DriverAssitant_v5.1.1.zip)并安装驱动DriverInstall.exe。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如果已经安装旧版本的烧写工具,请先点击"驱动卸载"按钮卸载驱动,然后再点击"驱动安装"按钮安装驱动。 - -2. 请连接好电脑和待烧录开发板,连接USB接口,具体可参考[RK3568开发板介绍](quickstart-standard-board-introduction-rk3568.md)。 - -3. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 - - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 - - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 - - ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) - -4. 在菜单栏中点击**Project Settings**按钮,进入RK3568工程配置界面。 - - ![zh-cn_image_0000001198566364](figures/zh-cn_image_0000001198566364.png) - -5. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 - - ![zh-cn_image_0000001239661509](figures/zh-cn_image_0000001239661509.png) - -6. 在“hh_scdy200”页签,设置烧录选项,包括upload_partitions和upload_protocol。 - - - upload_partitions_profile:选择待烧录程序的配置文件,该配置文件会指定烧录文件名称、起始烧录地址、地址长度等信息;同时请勾选**Enable to use upload_partitions_profile for upload**选项。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如需修改烧录profile文件,在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 - > - > 首次烧录,请勾选**Enable to use upload_partitions_profile for upload**选项,会自动生成upload_partitions文件。再次烧录时,可根据实际情况选择生成upload_partitions文件进行自定义烧录,也可以再勾选**Enable to use upload_partitions_profile for upload**选项,使用upload_partitions_profile重新生成upload_partitions文件用于烧录。 - - - upload_protocol:选择烧录协议,固定选择“upgrade”。 - - ![zh-cn_image_0000001194504874](figures/zh-cn_image_0000001194504874.png) - -7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -8. 在“PROJECT TASKS”中,点击hh_scdy200下的**Upload**按钮启动烧录。 - - ![zh-cn_image_0000001194821710](figures/zh-cn_image_0000001194821710.png) - -9. 当屏幕提示“Operation paused,Please press Enter key to continue”,请按回车键继续。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - > 如果开发板未处于烧录模式,屏幕会提示“The board is not in Loader mode.Please Hold on the VOL+key...”,此时,请长按音量+键,3秒后点击RESET键,然后再过3秒放开音量+键,使开发板进入烧录模式。 - - 等待开发板烧录完成,当屏幕提示如下信息时,表示烧录成功。 - - ![zh-cn_image_0000001194984912](figures/zh-cn_image_0000001194984912.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md deleted file mode 100644 index 43f763c2c8dbb0149da71cfb37a5d223a8048ab4..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md +++ /dev/null @@ -1,159 +0,0 @@ -# 编写“Hello World”程序 - - -下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 - - -## 示例目录 - - 示例完整目录如下。 - -``` -applications/sample/hello -│ │── BUILD.gn -│ │── include -│ │ └── helloworld.h -│ │── src -│ │ └── helloworld.c -│ └── bundle.json -build -└── subsystem_config.json -vendor/hihope -└── rk3568 - └── config.json -``` - - -## 开发步骤 - -请在源码目录中通过以下步骤创建“Hello World”应用程序: - -1. 创建目录,编写业务代码。 - - 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OH)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 - - - ``` - #include - #include "helloworld.h" - - int main(int argc, char **argv) - { - HelloPrint(); - return 0; - } - - void HelloPrint() - { - printf("\n\n"); - printf("\n\t\tHello World!\n"); - printf("\n\n"); - } - ``` - - 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。 - - - ``` - #ifndef HELLOWORLD_H - #define HELLOWORLD_H - #ifdef __cplusplus - #if __cplusplus - extern "C" { - #endif - #endif - - void HelloPrint(); - - #ifdef __cplusplus - #if __cplusplus - } - #endif - #endif - #endif // HELLOWORLD_H - ``` - -2. 新建编译组织文件。 - - 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示: - - ``` - import("//build/ohos.gni") # 导入编译模板 - ohos_executable("helloworld") { # 可执行模块 - sources = [ # 模块源码 - "src/helloworld.c" - ] - include_dirs = [ # 模块依赖头文件目录 - "include" - ] - cflags = [] - cflags_c = [] - cflags_cc = [] - ldflags = [] - configs = [] - deps =[] # 部件内部依赖 - part_name = "hello" # 所属部件名称,必选 - install_enable = true # 是否默认安装(缺省默认不安装),可选 - } - ``` - 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。 - - ``` - { - "name": "@ohos/hello", - "description": "Hello world example.", - "version": "3.1", - "license": "Apache License 2.0", - "publishAs": "code-segment", - "segment": { - "destPath": "applications/sample/hello" - }, - "dirs": {}, - "scripts": {}, - "component": { - "name": "hello", - "subsystem": "sample", - "syscap": [], - "features": [], - "adapted_system_type": [ "mini", "small", "standard" ], - "rom": "10KB", - "ram": "10KB", - "deps": { - "components": [], - "third_party": [] - }, - "build": { - "sub_component": [ - "//applications/sample/hello:helloworld" - ], - "inner_kits": [], - "test": [] - } - } - } - ``` - - bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。 - -3. 修改子系统配置文件。 - - 在build/subsystem_config.json中添加新建的子系统的配置。 - - - ``` - "sample": { - "path": "applications/sample/hello", - "name": "sample" - }, - ``` - -4. 修改产品配置文件。 - - 在vendor/hihope/rk3568/config.json中添加对应的hello部件,直接添加到原有部件后即可。 - - ``` - "usb:usb_manager_native":{}, - "applications:prebuilt_hap":{}, - "sample:hello":{}, - "wpa_supplicant-2.9:wpa_supplicant-2.9":{}, - ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-running.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-running.md deleted file mode 100644 index caa6e2df154873b6c36288c36f779966ba5cf2ab..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-running.md +++ /dev/null @@ -1,21 +0,0 @@ -# 运行 - - -## 启动系统 - -镜像烧录完成重启开发板后,系统将会自动启动。开发板附带的屏幕呈现以下界面,表明系统已运行成功。 - - **图1** 系统启动效果图   - -![zh-cn_image_0000001226602406](figures/zh-cn_image_0000001226602406.jpg) - - -## 运行“Hello World” - -1. 设备启动后打开串口工具(以putty为例),波特率设置为1500000,连接设备。 - - ![zh-cn_image_0000001226922310](figures/zh-cn_image_0000001226922310.png) - -2. 打开串口后,在任意目录(以设备根目录为例)下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 - - ![zh-cn_image_0000001271202465](figures/zh-cn_image_0000001271202465.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-std-3516-create.md b/zh-cn/device-dev/quick-start/quickstart-std-3516-create.md deleted file mode 100644 index cfffb34b1dc8c4d2c68d9ed1189e1c4b2f0b13be..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-std-3516-create.md +++ /dev/null @@ -1,162 +0,0 @@ -# 编写“Hello World”程序 - - -下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 - - -## 示例目录 - -示例完整目录如下。 - - -``` -applications/sample/hello -│── BUILD.gn -│── include -│ └── helloworld.h -│── src -│ └── helloworld.c -├── bundle.json -build -└── subsystem_config.json -vendor/hisilicon -└── Hi3516DV300 - └── config.json -``` - - -## 开发步骤 - -请在源码目录中通过以下步骤创建“Hello World”应用程序: - - -1. 创建目录,编写业务代码。 - - 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OH)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 - - - ``` - #include - #include "helloworld.h" - - int main(int argc, char **argv) - { - HelloPrint(); - return 0; - } - - void HelloPrint() - { - printf("\n\n"); - printf("\n\t\tHello World!\n"); - printf("\n\n"); - } - ``` - - 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。 - - - ``` - #ifndef HELLOWORLD_H - #define HELLOWORLD_H - #ifdef __cplusplus - #if __cplusplus - extern "C" { - #endif - #endif - - void HelloPrint(); - - #ifdef __cplusplus - #if __cplusplus - } - #endif - #endif - #endif // HELLOWORLD_H - ``` - -2. 新建编译组织文件。 - - 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示: - - ``` - import("//build/ohos.gni") # 导入编译模板 - ohos_executable("helloworld") { # 可执行模块 - sources = [ # 模块源码 - "src/helloworld.c" - ] - include_dirs = [ # 模块依赖头文件目录 - "include" - ] - cflags = [] - cflags_c = [] - cflags_cc = [] - ldflags = [] - configs = [] - deps =[] # 部件内部依赖 - part_name = "hello" # 所属部件名称,必选 - install_enable = true # 是否默认安装(缺省默认不安装),可选 - } - ``` - 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。 - - ``` - { - "name": "@ohos/hello", - "description": "Hello world example.", - "version": "3.1", - "license": "Apache License 2.0", - "publishAs": "code-segment", - "segment": { - "destPath": "applications/sample/hello" - }, - "dirs": {}, - "scripts": {}, - "component": { - "name": "hello", - "subsystem": "sample", - "syscap": [], - "features": [], - "adapted_system_type": [ "mini", "small", "standard" ], - "rom": "10KB", - "ram": "10KB", - "deps": { - "components": [], - "third_party": [] - }, - "build": { - "sub_component": [ - "//applications/sample/hello:helloworld" - ], - "inner_kits": [], - "test": [] - } - } - } - ``` - - bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。 - -3. 修改子系统配置文件。 - - 在build/subsystem_config.json中添加新建的子系统的配置。 - - - ``` - "sample": { - "path": "applications/sample/hello", - "name": "sample" - }, - ``` - -4. 修改产品配置文件。 - - 在vendor/hisilicon/Hi3516DV300/config.json中添加对应的hello部件,直接添加到原有部件后即可。 - - - ``` - "usb:usb_manager_native":{}, - "applications:prebuilt_hap":{}, - "sample:hello":{}, - "wpa_supplicant-2.9:wpa_supplicant-2.9":{}, - ``` diff --git a/zh-cn/device-dev/subsystems/subsys-build-all.md b/zh-cn/device-dev/subsystems/subsys-build-all.md index 8dd82206e54844b7e37866a4cecfb0e776168de8..21fafa4d6f941cc48eb601f742cd9488c2165c91 100644 --- a/zh-cn/device-dev/subsystems/subsys-build-all.md +++ b/zh-cn/device-dev/subsystems/subsys-build-all.md @@ -92,7 +92,7 @@ OpenHarmony编译子系统是以GN和Ninja构建为基座,对构建和配置 # export PATH=~/.local/bin:$PATH ``` - ![icon-note.gif](public_sys-resources/icon-note.gif)**注意**:上述安装ohos-build的过程中会安装编译工具hb,但有时会出现hb安装不成功的情况,若安装不成功,则按照[hb安装](../../device-dev/quick-start/quickstart-lite-env-setup.md#安装hb)重新安装。 + ![icon-note.gif](public_sys-resources/icon-note.gif)**注意**:上述安装ohos-build的过程中会安装编译工具hb,但有时会出现hb安装不成功的情况,若安装不成功,则按照[hb安装](../../device-dev/quick-start/quickstart-pkg-install_tool.md#安装hb)重新安装。 ## 配置规则 diff --git a/zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guide.md b/zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guide.md index d6175848914f1bb1caee3cd219fdff1930c7aeaa..c88c1dbd54038b5bfe40d14a628578d465bba81e 100644 --- a/zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guide.md @@ -30,7 +30,7 @@ 2. 环境准备 - 环境配置所需要的Kconfiglib已内置在OpenHarmony自带的hb工具中,如需安装hb工具,可参考:[hb安装教程](../quick-start/quickstart-lite-env-setup.md#安装hb) + 环境配置所需要的Kconfiglib已内置在OpenHarmony自带的hb工具中,如需安装hb工具,可参考:[hb安装教程](../quick-start/quickstart-pkg-install_tool.md#安装hb) 3. 开启可视化配置界面 diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 2b0e46fb6da156fa6ae0c5d6755b8d9becf93be3..1fe6576b25b528ca3483740deb6463590ebf4154 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -1,204 +1,70 @@ # OpenHarmony设备开发文档 - [设备开发导读](device-dev-guide.md) - 快速开始 - - 轻量和小型系统快速入门(IDE方式,推荐) - - - [轻量与小型系统入门概述](quick-start/quickstart-ide-lite-overview.md) - - - 准备轻量与小型系统环境 - - - [搭建Windows+Ubuntu混合开发环境](quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md) - - - [获取源码](quick-start/quickstart-ide-lite-sourcecode-acquire.md) - - - [导入源码工程](quick-start/quickstart-ide-lite-create-project.md) - - - 运行“Hello World” - - - Hi3861开发板 - - - [编写“Hello World”程序](quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md) - - - [编译](quick-start/quickstart-ide-lite-steps-hi3861-building.md) - - - [烧录](quick-start/quickstart-ide-lite-steps-hi3861-burn.md) - - - [联网](quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md) - - - [调试验证](quick-start/quickstart-ide-lite-steps-hi3861-debug.md) - - - [运行](quick-start/quickstart-ide-lite-steps-hi3861-running.md) - - - Hi3516开发板 - - - [编写“Hello World”程序](quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md) - - - [编译](quick-start/quickstart-ide-lite-steps-hi3516-building.md) - - - [烧录](quick-start/quickstart-ide-lite-steps-hi3516-burn.md) - - - [运行](quick-start/quickstart-ide-lite-steps-hi3516-running.md) - - - 附录 - - - [Hi3861开发板介绍](quick-start/quickstart-ide-lite-introduction-hi3861.md) - - - [Hi3516开发板介绍](quick-start/quickstart-ide-lite-introduction-hi3516.md) - - - [编译形态整体说明](quick-start/quickstart-build.md) - - - 轻量和小型系统快速入门(安装包方式) - - - [轻量与小型系统入门概述](quick-start/quickstart-lite-overview.md) - - - [搭建轻量与小型系统环境](quick-start/quickstart-lite-env-setup.md) - - - 运行“Hello World” - - - Hi3861开发板 - - - [安装Hi3861开发板环境](quick-start/quickstart-lite-steps-hi3861-setting.md) - - - [编写“Hello World”程序](quick-start/quickstart-lite-steps-hi3861-helloworld.md) - - - [编译](quick-start/quickstart-lite-steps-hi3861-building.md) - - - [烧录](quick-start/quickstart-lite-steps-hi3861-burn.md) - - - [联网](quick-start/quickstart-lite-steps-hi3861-netconfig.md) - - - [调试验证](quick-start/quickstart-lite-steps-hi3861-debug.md) - - - [运行](quick-start/quickstart-lite-steps-hi3861-running.md) - - - Hi3516开发板 - - - [安装Hi3516开发板环境](quick-start/quickstart-lite-steps-hi3516-setting.md) - - - [编写“Hello World”程序](quick-start/quickstart-lite-steps-hi3516-helloworld.md) - - - [编译](quick-start/quickstart-lite-steps-hi3516-building.md) - - - [烧录](quick-start/quickstart-lite-steps-hi3516-burn.md) - - - [运行](quick-start/quickstart-lite-steps-hi3516-running.md) - - - 常见问题 - - - [hb安装异常](quick-start/quickstart-lite-faq-hb.md) - - - [编译异常](quick-start/quickstart-lite-faq-compose.md) - - - [烧录异常](quick-start/quickstart-lite-faq-burning.md) - - - 附录 - - - 开发板介绍 - - - [Hi3861开发板介绍](quick-start/quickstart-lite-introduction-hi3861.md) - - - [Hi3516开发板介绍](quick-start/quickstart-lite-introduction-hi3516.md) - - - [参考信息](quick-start/quickstart-lite-reference.md) - - - [使用HiTool烧录代码](quick-start/quickstart-lite-hitool.md) - - - [编译形态整体说明](quick-start/quickstart-build.md) - - - 标准系统快速入门(IDE方式,推荐) - - - [标准系统入门概述](quick-start/quickstart-ide-standard-overview.md) - - - 准备标准系统环境 - - - [搭建Windows+Ubuntu混合开发环境](quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md) - - - [获取源码](quick-start/quickstart-ide-standard-sourcecode-acquire.md) - - - [导入源码工程](quick-start/quickstart-ide-standard-create-project.md) - - - 运行“Hello World” - - - Hi3516开发板 - - - [编写“Hello World”程序](quick-start/quickstart-ide-standard-running-hi3516-create.md) - - - [编译](quick-start/quickstart-ide-standard-running-hi3516-build.md) - - - [烧录](quick-start/quickstart-ide-standard-running-hi3516-burning.md) - - - [运行](quick-start/quickstart-ide-standard-running-hi3516-running.md) - - - RK3568开发板 - - - [编写“Hello World”程序](quick-start/quickstart-ide-standard-running-rk3568-create.md) - - - [编译](quick-start/quickstart-ide-standard-running-rk3568-build.md) - - - [烧录](quick-start/quickstart-ide-standard-running-rk3568-burning.md) - - - [运行](quick-start/quickstart-ide-standard-running-rk3568-running.md) - - - 附录 - - - [Hi3516开发板介绍](quick-start/quickstart-ide-standard-board-introduction-hi3516.md) - - - [RK3568开发板介绍](quick-start/quickstart-ide-standard-board-introduction-rk3568.md) - - - [编译形态整体说明](quick-start/quickstart-build.md) - - - 标准系统快速入门(安装包方式) - - - [标准系统入门概述](quick-start/quickstart-standard-overview.md) - - - [搭建标准系统环境](quick-start/quickstart-standard-env-setup.md) - - - 运行“Hello World” - - - Hi3516开发板 - - - [编写“Hello World”程序](quick-start/quickstart-std-3516-create.md) - - - [编译](quick-start/quickstart-standard-running-hi3516-build.md) - - - [烧录](quick-start/quickstart-standard-running-hi3516-burning.md) - - - [运行](quick-start/quickstart-standard-running-hi3516-running.md) - - - RK3568开发板 - - - [编写“Hello World”程序](quick-start/quickstart-standard-running-rk3568-create.md) - - - [编译](quick-start/quickstart-standard-running-rk3568-build.md) - - - [烧录](quick-start/quickstart-standard-running-rk3568-burning.md) - - - [运行](quick-start/quickstart-standard-running-rk3568-running.md) - - - 常见问题 - - - [hb安装异常](quick-start/quickstart-standard-faq-hb.md) - - - [编译异常](quick-start/quickstart-standard-faq-compose.md) - - - [烧录异常](quick-start/quickstart-standard-faq-burning.md) - - - 附录 - - - 开发板介绍 - - - [Hi3516开发板介绍](quick-start/quickstart-standard-board-introduction-hi3516.md) - - - [RK3568开发板介绍](quick-start/quickstart-standard-board-introduction-rk3568.md) - - - [参考信息](quick-start/quickstart-standard-reference.md) - - - [使用HiTool烧录代码](quick-start/quickstart-standard-hitool.md) - - - [编译形态整体说明](quick-start/quickstart-build.md) + - [快速入门概述](quick-start/quickstart-overview.md) + - 基于IDE开发 + - 搭建开发环境 + - [搭建Windows环境](quick-start/quickstart-ide-env--win.md) + - [搭建Ubuntu环境](quick-start/quickstart-ide-env-ubuntu.md) + - [配置远程访问环境](quick-start/quickstart-ide-env-remote.md) + - [创建工程并获取源码](quick-start/quickstart-ide-import-project.md) + - 轻量系统(基于Hi3861开发板) + - [编写“Hello World”程序](quick-start/quickstart-ide-3861-helloworld.md) + - [编译](quick-start/quickstart-ide-3861-build.md) + - [烧录](quick-start/quickstart-ide-3861-burn.md) + - [运行](quick-start/quickstart-ide-3861-running.md) + - 小型系统(基于Hi3516开发板) + - [编写“Hello World”程序](quick-start/quickstart-ide-3516-helloworld.md) + - [编译](quick-start/quickstart-ide-3516-build.md) + - [烧录](quick-start/quickstart-ide-3516-burn.md) + - [运行](quick-start/quickstart-ide-3516-running.md) + - 标准系统(基于RK3568开发板) + - [编写“Hello World”程序](quick-start/quickstart-ide-3568-helloworld.md) + - [编译](quick-start/quickstart-ide-3568-build.md) + - [烧录](quick-start/quickstart-ide-3568-burn.md) + - [运行](quick-start/quickstart-ide-3568-running.md) + - 基于命令行开发 + - 搭建开发环境 + - [准备开发环境](quick-start/quickstart-pkg-prepare.md) + - [安装库和工具集](quick-start/quickstart-pkg-install_package.md) + - [获取源码](quick-start/quickstart-pkg-sourcecode.md) + - [安装编译工具](quick-start/quickstart-pkg-install_tool.md) + - 轻量系统(基于Hi3861开发板) + - [安装Hi3861开发板特有环境](quick-start/quickstart-pkg-3861-tool.md) + - [编写“Hello World”程序](quick-start/quickstart-pkg-3861-helloworld.md) + - [编译](quick-start/quickstart-pkg-3861-build.md) + - [烧录](quick-start/quickstart-pkg-3861-burn.md) + - [运行](quick-start/quickstart-pkg-3861-running.md) + - 小型系统(基于Hi3516开发板) + - [编写“Hello World”程序](quick-start/quickstart-pkg-3516-helloworld.md) + - [编译](quick-start/quickstart-pkg-3516-build.md) + - [烧录](quick-start/quickstart-pkg-3516-burn.md) + - [运行](quick-start/quickstart-pkg-3516-running.md) + - 标准系统(基于RK3568开发板) + - [编写“Hello World”程序](quick-start/quickstart-pkg-3568-helloworld.md) + - [编译](quick-start/quickstart-pkg-3568-build.md) + - [烧录](quick-start/quickstart-pkg-3568-burn.md) + - [运行](quick-start/quickstart-pkg-3568-running.md) + - 常用信息 + - [配置代理](quick-start/quickstart-pkg-common-proxy.md) + - [使用build.sh脚本编译源码](quick-start/quickstart-pkg-common-build.md) + - [hb安装异常处理](quick-start/quickstart-pkg-common-hberr.md) + - [编译异常处理](quick-start/quickstart-pkg-common-builderr.md) + - [烧录异常处理](quick-start/quickstart-pkg-common-burnerr.md) + - 附录 + - [Hi3516开发板介绍](quick-start/quickstart-appendix-hi3516.md) + - [Hi3861开发板介绍](quick-start/quickstart-appendix-hi3861.md) + - [RK3568开发板介绍](quick-start/quickstart-appendix-rk3568.md) + - [编译形态整体说明](quick-start/quickstart-appendix-compiledform.md) + - [Hi3516标准系统入门(IDE方式)](quick-start/quickstart-appendix-hi3516-ide.md) + - [Hi3516标准系统入门(命令行方式)](quick-start/quickstart-appendix-hi3516-pkg.md) + - [获取源码](get-code/sourcecode-acquire.md) - [隐私保护](security/security-privacy-protection.md) - [安全指南](security/security-guidelines-overall.md) +- 隐私和安全 + - [隐私保护](security/security-privacy-protection.md) + - [安全指南](security/security-guidelines-overall.md) - 移植 @@ -444,6 +310,7 @@ - [标准系统内核编译与构建指导](kernel/kernel-standard-build.md) - 内核增强特性 - [Enhanced SWAP特性介绍](kernel/kernel-standard-mm-eswap.md) + - [NewIP内核协议栈介绍](kernel/kernel-standard-newip.md) - 任务调度 - [关联线程组调度](kernel/kernel-standard-sched-rtg.md) - [CPU轻量级隔离](kernel/kernel-standard-sched-cpuisolation.md) @@ -579,6 +446,8 @@ - [IPC通信鉴权开发指导](subsystems/subsys-security-communicationverify.md) - [设备安全等级管理开发指导](subsystems/subsys-security-devicesecuritylevel.md) - [OpenHarmony通用密钥库系统开发指导](subsystems/subsys-security-huks-guide.md) + - [应用特权配置指导](subsystems/subsys-app-privilege-config-guide.md) + - [预置应用配置指导](subsystems/subsys-preinstall-app-config-guide.md) - 启动恢复 - [启动恢复子系统概述](subsystems/subsys-boot-overview.md) - init启动引导组件 @@ -623,13 +492,6 @@ - WLAN连接类产品 - [LED外设控制](guide/device-wlan-led-control.md) - [集成三方SDK](guide/device-wlan-sdk.md) - - 无屏摄像头类产品 - - 摄像头控制 - - [概述](guide/device-iotcamera-control-overview.md) - - 示例开发 - - [拍照开发指导](guide/device-iotcamera-control-demo-photodevguide.md) - - [录像开发指导](guide/device-iotcamera-control-demo-videodevguide.md) - - [应用实例](guide/device-iotcamera-control-example.md) - 带屏摄像头类产品 - 屏幕和摄像头控制 - [概述](guide/device-camera-control-overview.md) @@ -675,10 +537,9 @@ - [内核常见问题](faqs/faqs-kernel.md) - [移植常见问题](faqs/faqs-porting.md) - [启动恢复常见问题](faqs/faqs-startup.md) - - [系统应用常见问题](faqs/faqs-system-applications.md) - + - [系统应用常见问题](faqs/faqs-system-applications.md) - HDI接口参考 - - 模块 + - 模块 - [Audio](reference/hdi-apis/_audio.md) - [Battery](reference/hdi-apis/battery.md) - [Camera](reference/hdi-apis/_camera.md) @@ -901,4 +762,17 @@ - [VerifyAllocInfo](reference/hdi-apis/_verify_alloc_info.md) - [VibratorInterface](reference/hdi-apis/_vibrator_interface.md) - [VideoPortCap](reference/hdi-apis/_video_port_cap.md) - + + - CMSIS API参考 + - [CMSIS](reference/kernel/cmsis/_c_m_s_i_s-_r_t_o_s.md) + - 结构体 + - [osEventFlagsAttr_t](reference/kernel/cmsis/os_event_flags_attr__t.md) + - [osMemoryPoolAttr_t](reference/kernel/cmsis/os_memory_pool_attr__t.md) + - [osMessageQueueAttr_t](reference/kernel/cmsis/os_message_queue_attr__t.md) + - [osMutexAttr_t](reference/kernel/cmsis/os_mutex_attr__t.md) + - [osSemaphoreAttr_t](reference/kernel/cmsis/os_semaphore_attr__t.md) + - [osThreadAttr_t](reference/kernel/cmsis/os_thread_attr__t.md) + - [osTimerAttr_t](reference/kernel/cmsis/os_timer_attr__t.md) + - [osVersion_t](reference/kernel/cmsis/os_version__t.md) + + \ No newline at end of file diff --git "a/zh-cn/readme/\346\226\207\344\273\266\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\346\226\207\344\273\266\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" index 54361e43cb60a5f154a611efe0703a5b6e350887..3f354b0775995e7b3b3094f59b1c6c31897cbc4d 100644 --- "a/zh-cn/readme/\346\226\207\344\273\266\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\346\226\207\344\273\266\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" @@ -21,7 +21,7 @@ | 存储管理 | 1. 提供数据备份恢复框架能力,支持系统和应用数据备份克隆等场景;
2. 提供应用空间清理和统计、配额管控等空间管理能力;
3. 提供挂载管理、外卡管理、设备管理及多用户管理等存储存储管理能力。 | | 公共文件 | 1. 公共数据沙箱隔离,保证用户数据安全、纯净;
2. 统一公共数据访问入口,仅medialibrary;
3. 提供统一的FMF的文件管理框架;
4. 支持分布式和端云能力。 | | 应用文件 | 1. 为应用提供安全的沙箱隔离技术,保证应用数据安全基础上权限最小化;
2. 支持应用间文件分享和文件跨设备分享,支持群组分享;
3. 应用可以像使用本地文件一样使用分布式和云端文件。 | -| 分布式能力 | 1. 提供基础分布式跨端访问能力,支持同账号分布式访问和异账号临时访问;
2. 支持端云协同能力,用户和应用无感数据位置;
3. 支持文件跨端迁移能力,支撑应用迁移、分布式剪切板等分布式场景。 | +| 分布式能力 | 1. 提供基础分布式跨端访问能力,支持同账号分布式访问和异账号临时访问;
2. 支持端云协同能力,用户和应用无需感知数据位置;
3. 支持文件跨端迁移能力,支撑应用迁移、分布式剪切板等分布式场景。 | | 基础文件系统 | 1. 支持ext4、f2fs、exfat、ntfs等本地文件系统;
2. 支持分布式文件系统、nfs等网络文件系统;
3. 文件系统相关工具。 | @@ -39,7 +39,6 @@ [filemanagement_file_api](https://gitee.com/openharmony/filemanagement_file_api) -[distributeddatamgr_file](https://gitee.com/openharmony/distributeddatamgr_file) 存储管理 diff --git a/zh-cn/release-notes/OpenHarmony-v3.2-beta3.md b/zh-cn/release-notes/OpenHarmony-v3.2-beta3.md new file mode 100644 index 0000000000000000000000000000000000000000..58f46c6929ab2f5cbcdeb4a0f3340e4cce3de5a3 --- /dev/null +++ b/zh-cn/release-notes/OpenHarmony-v3.2-beta3.md @@ -0,0 +1,224 @@ +# OpenHarmony 3.2 Beta3 + + +## 版本概述 + +当前版本在OpenHarmony 3.2 Beta2的基础上,更新支持或优化增强的能力如下: + +**标准系统基础能力增强** + +泛sensor提供马达优先级管理能力。 + +多模输入提供鼠标样式和速度设置、鼠标上报事件增强,配置序列拉起应用,键鼠穿越等特性。 + +Misc服务新增剪贴板、上传下载、锁屏、输入法框架等模块基础特性。 + +内核子系统新增内存压力通知AMS、回收优先级管理支持常驻系统服务,回收优先级管理支持区分extension状态等基础能力。 + +DFX支持faultloggerd混合JS/Native栈打印,hilog domain白名单管理和日志统计功能,hisysevent、hiappeventssh事件能力增强,hidumper内存分类信息优化。 + +单元测试框架新增参数化数据驱动能力;UI测试框架新增抛滑及复杂手势如双指捏合能力接口;xdevice增加任务执行完成后搜集设备DFX日志能力等。 + +编译运行时新增支持严格模式的ES2021、模块化支持、Runtime 调试调优增强、字节码热重载等。 + +帐号服务新增用户身份认证服务;权限服务新增支持精准定位或模糊定位,以及其他能力增强;新增隐私管理服务。 + +媒体子系统新增支持音频解码、音频编码、视频解码、视频编码native接口、支持播放音画同步和启动时间优化、支持基于HDI codec接口的视频硬件编解码能力、支持分布式音频,音量、设备状态管理,设备监听和投播功能、支持分布式相机预览,拍照和录像。 + +**标准系统应用开发框架增强** + +事件和通知新增适配DLP;新增支持子系统发送通知。 + +支持webview复制粘贴,支持基础音视频播放,支持https双向认证等能力。 + +元能力新增权限校验整改、启动规则、快速修复、卡片可分可合。 + +ArkUI组件能力增强;资源、媒体查询能力增强;内存、性能优化;DFX能力增强;工具链能力增强。 + +DeviceProfile适配分布式数据库自动同步策略,以及采集信息补齐。 + +包管理新增支持缩略图、预览Extension,部分特性新增支持可裁剪配置、支持防呆机制、支持预置应用特定能力管理,安装流程支持hap包不解压,支持快速修复机制。 + +系统服务管理支持跨设备加载系统服务,foundation进程重启恢复机制,分布式组件管理支持多用户跨设备调用,迁移框架支持单实例Ability迁移等。 + +**标准系统分布式能力增强** + +分布式数据库支持跨设备跨应用分享、RDB支持远程查询/数据库加密特性、支持应用分身,KVDB支持备份恢复/按条件同步/设备上线优先集中同步系统数据。 + + +## 配套关系 + + **表1** 版本软件和工具配套关系 + +| 软件 | 版本 | 备注 | +| -------- | -------- | -------- | +| OpenHarmony | 3.2 Beta3 | NA | +| Public SDK | Ohos_sdk_public 3.2.7.5 (API Version 9 Beta3) | 面向应用开发者提供,不包含需要使用系统权限的系统接口。
通过DevEco Studio默认获取的SDK为Public SDK。 | +| Full SDK | Ohos_sdk_full 3.2.7.5 (API Version 9 Beta3) | 面向OEM厂商提供,包含了需要使用系统权限的系统接口。
使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](../application-dev/quick-start/full-sdk-switch-guide.md)。 | +| HUAWEI DevEco Studio(可选) | 3.0 Release | OpenHarmony应用开发推荐使用 | +| HUAWEI DevEco Device Tool(可选) | 3.0 Release | OpenHarmony智能设备集成开发环境推荐使用 | + + +## 源码获取 + + +### 前提条件 + +1. 注册码云gitee帐号。 + +2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 + +3. 安装[git客户端](https://gitee.com/link?target=https%3A%2F%2Fgit-scm.com%2Fbook%2Fzh%2Fv2%2F%25E8%25B5%25B7%25E6%25AD%25A5-%25E5%25AE%2589%25E8%25A3%2585-Git)和[git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)并配置用户信息。 + + ``` + git config --global user.name "yourname" + git config --global user.email "your-email-address" + git config --global credential.helper store + ``` + +4. 安装码云repo工具,可以执行如下命令。 + + ``` + curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中chmod a+x /usr/local/bin/repo + pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests + ``` + + +### 通过repo获取 + +**方式一(推荐)** + +通过repo + ssh 下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 + +- 从版本分支获取源码。可获取该版本分支的最新源码,包括版本发布后在该分支的合入。 + ``` + repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.2-Beta3 --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +- 从版本发布Tag节点获取源码。可获取与版本发布时完全一致的源码。 + ``` + repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.2-Beta3 --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +**方式二** + +通过repo + https 下载。 + +- 从版本分支获取源码。可获取该版本分支的最新源码,包括版本发布后在该分支的合入。 + ``` + repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony-3.2-Beta3 --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +- 从版本发布Tag节点获取源码。可获取与版本发布时完全一致的源码。 + ``` + repo init -u https://gitee.com/openharmony/manifest -b refs/tags/OpenHarmony-v3.2-Beta3 --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +### 从镜像站点获取 + +**表2** 获取源码路径 + +| 版本源码 | **版本信息** | **下载站点** | **SHA256校验码** | +| --------------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| 全量代码(标准、轻量和小型系统) | 3.2 Beta3 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/code-v3.2-Beta3.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/code-v3.2-Beta3.tar.gz.sha256) | +| Hi3861轻量系统解决方案(二进制) | 3.2 Beta3 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_pegasus.tar.gz.sha256) | +| Hi3516轻量系统解决方案-LiteOS(二进制) | 3.2 Beta3 | [站点](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_taurus_LiteOS.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_taurus_LiteOS.tar.gz.sha256) | +| Hi3516轻量系统解决方案-Linux(二进制) | 3.2 Beta3 | [站点](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_taurus_Linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_taurus_Linux.tar.gz.sha256) | +| RK3568标准系统解决方案(二进制) | 3.2 Beta3 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/dayu200_standard_arm32.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/dayu200_standard_arm32.tar.gz.sha256) | +| 标准系统Full SDK包(Mac) | 3.2.7.5 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-mac-full.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-mac-full.tar.gz.sha256) | +| 标准系统Full SDK包(Windows\Linux) | 3.2.7.5 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-windows_linux-full.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-windows_linux-full.tar.gz.sha256) | +| 标准系统Public SDK包(Mac) | 3.2.7.5 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-mac-public.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-mac-public.tar.gz.sha256) | +| 标准系统Public SDK包(Windows\Linux) | 3.2.7.5 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-windows_linux-public.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-windows_linux-public.tar.gz.sha256) | + + + +## 更新说明 + +本版本在OpenHarmony 3.2 Beta2的基础上有如下变更。 + + +### 特性变更 + + **表3** 版本特性变更表 + +| 子系统名称 | 标准系统 | 轻量、小型系统 | +| -------- | -------- | -------- | +| 元能力 | 新增权限校验整改、启动规则、快速修复、卡片可分可合。
主要涉及如下需求:
I581RO 【新增特性】最近任务列表适配加密文件沙箱进程
I581SE 【新增特性】AMS对沙箱进程增加权限校验
I581XD 【新增特性】应用捕获JS Crash异常
I581YL 【新增特性】支持卡片分享
I58213 【增强特性】提供监听Service/Data/Extension关联关系状态能力
I5824D 【新增特性】JS runtime支持worker
I5825N 【新增特性】不解压HAP加载应用代码
I5826I 【新增特性】不解压HAP加载应用资源
I5826Y 【新增特性】加载依赖HAP包中的代码
I5HQEM 【新增特性】上下文支持监听WindowStage生命周期
I5MVKZ 【新增特性】应用内加载卡片
I5OD2E 【新增特性】快速修复服务 - 安装补丁
I5ODCD 【新增特性】快速修复服务 - 查询补丁
I5PXW4 【特性增强】支持查询监听进程/组件可见性等状态能力
I5Q8IU 【新增特性】应用内卡片强制刷新
I5QGMS 【新增特性】应用内卡片事件管理 | NA | +| 包管理 | 新增支持缩略图、预览Extension,部分特性新增支持可裁剪配置、支持防呆机制、支持预置应用特定能力管理,安装流程支持hap包不解压,支持快速修复机制。
主要涉及如下需求:
I5MZ33 【新增特性】支持extension的类型为缩略图、预览
I56WAY【新增特性】包管理特性可裁剪配置
I56WA0【新增特性】防呆机制
I56W8O【新增特性】预置应用特定能力管理
I56WGB【新增特性】安装流程适配hap包不解压
I5N7AD【新增特性】支持补丁包的部署
I5MZ6Z【新增特性】支持补丁包的开机扫描 | NA | +| DFX | 支持faultloggerd混合JS/Native栈打印,hilog domain白名单管理和日志统计功能,hisysevent、hiappeventssh事件能力增强,hidumper内存分类信息优化。
主要涉及如下需求:
I5PJ9O 【新增规格】【faultloggerd部件】混合JS/Native栈打印
I5OA3F 【新增规格】【DFX子系统】【hisysevent部件】提升HiSysEvent的订阅查询接口易用性
I5NU4L 【新增特性】【hilog部件】系统domain白名单管理
I5NU71 【新增特性】【hilog部件】日志统计功能
I5NU7F 【新增特性】【hilog部件】日志服务权限管理
I5KDIG 【新增规格】【DFX子系统】【hisysevent部件】订阅功能提供应对系统事件风暴能力
I5L2RV 【新增规格】【DFX子系统】【hisysevent部件】查询功能提供应对系统事件风暴能力
I5LFCZ 【新增规格】【DFX子系统】【hisysevent部件】系统事件存储处理提供应用系统事件风暴能力
I5FNPQ 【新增规格】【DFX子系统】【hisysevent部件】系统事件打点接口提供应对事件风暴能力
I5NTOS 【新增规格】【DFX子系统】【hiappevent部件】hiappevent的事件清理能力
I5NTOD 【新增规格】【DFX子系统】【hiappevent部件】hiappevent的事件查询能力
I5LB4N 【新增规格】【DFX子系统】【hiappevent部件】hiappevent的事件订阅能力
I5KYYI 【新增规格】【DFX子系统】【hiappevent部件】hiappevent的事件分发能力
I5K0X6 【新增规格】【DFX子系统】【hiappevent部件】hiappevent的事件管理能力
I5NULM 【新增规格】【DFX子系统】【hiview部件】提供读取内核事件处理能力
I5NWZQ 【新增特性】对进程SMAPS进一步进行分类,在hidumper信息导出时候展示更加细致的分类信息
I5GXTG 【新增特性】hidumper权限隐私优化 | NA | +| 测试子系统 | 单元测试框架新增参数化数据驱动能力;UI测试框架新增抛滑及复杂手势如双指捏合能力接口;xdevice增加任务执行完成后搜集设备DFX日志能力等。
主要涉及如下需求:
I5LI56 【新增规格】集成DFX提供日志采集工具
I5LUI8 【新增规格】单元测试框架增加参数化驱动能力
I5L5DL 【新增规格】UI测试框架新增fling和复杂手势相关接口
I5K2LZ 【新增规格】单元/UI测试框架资料刷新
I5MQTL 【新增特性】wukong稳定性工具基础能力资料开发readme更新 | NA | +| 系统服务管理子系统 | 支持跨设备加载系统服务,foundation进程重启恢复机制,分布式组件管理支持多用户跨设备调用,迁移框架支持单实例Ability迁移等。
主要涉及如下需求:
I5KMF7【samgr】【增强特性】远程加载系统服务
I5IZ7R【safwk】【新增特性】foundation进程重启恢复机制
I5LO67【分布式组件管理】【新增特性】DMS适配多用户
I5I5FV【分布式组件管理】【新增特性】支持单实例Ability迁移
I5OJD【分布式组件管理】【新增特性】支持组件状态自动迁移
I5NOA1【分布式组件管理】【新增特性】目标端设备上DMS上报应用信息 | NA | +| DeviceProfile子系统 | DeviceProfile适配分布式数据库自动同步策略,以及采集信息补齐。
主要涉及如下需求:
I5QPGN【device_profile部件】【增强特性】DP适配数据库自动同步策略
I5J7PW【device_profile部件】【增强特性】补齐DP基础信息 | NA | +| 事件通知子系统 | 事件和通知新增适配DLP;新增支持子系统发送通知。
主要涉及如下需求:
I582TY【新增规格】通知适配DLP
I582VA 【新增规格】事件适配DLP
I5P1GU【distributed_notification_service部件】支持子系统发送通知 | NA | +| 多模输入子系统 | 提供鼠标样式和速度设置、鼠标上报事件增强,配置序列拉起应用,键鼠穿越等特性。
主要涉及如下需求:
I530UX 【新增特性】支持修改鼠标移动速度
I530VT 【新增特性】支持显示/隐藏鼠标图标
I530XP 【新增特性】支持鼠标加速算法
I530XS  【新增特性】支持多种鼠标样式
I530UQ 【新增特性】分布式输入
I5HMF3 【增强特性】支持鼠标离开窗口时上报事件
I5HMEF 【增强特性】鼠标上报事件增强
I5HMD9 【input部件】配置按键序列拉起Ability
I5P6TG 键鼠穿越鼠标光标自适应显示
I5P6UW 键鼠穿越状态管理
I5HMCX 【新增特性】支持键盘功能按键使能去使能
I5HMCB 【input部件】输入设备相关的多热区 | NA | +| 泛sensor服务子系统 | 提供马达优先级管理能力。
主要涉及如下需求:
I53SGE 【新增规格】支持马达优先级管理 | NA | +| 分布式数据管理子系统 | 支持跨设备跨应用分享、RDB支持远程查询/数据库加密特性、支持应用分身,KVDB支持备份恢复/按条件同步/设备上线优先集中同步系统数据。
主要涉及如下需求:
I5JV75【新增特性】【relational_store部件】支持远程查询特性
I5LBDS【新增特性】【kv_store部件】支持DLP沙箱应用的数据独立隔离
I5JZM1【data_object部件】分布式数据对象支持应用分身
I5OM83【kv_store部件】支持按条件同步数据
I5OE57【新增特性】【relational_store部件】数据库加密保存
I5QN1E【kv_store部件】设备上线优先集中同步系统数据 | NA | +| web子系统 | 支持webview复制粘贴,支持基础音视频播放,支持https双向认证等能力。
主要涉及如下需求:
I5QA3D【新增特性】webview支持页面图文混排内容的选中和复制
I5P97S【增强特性】web支持w3c input标签自动获焦下绑定输入法
I5P001【增强特性】webview支持shift连选多个文字
I5OZZ8【新增特性】webview支持鼠标左键滑动选词
I5OURV【增强特性】webview支持软键盘弹出效果优化
I5ORNO【新增特性】支持webview的https的双向校验
I5OESN【增强特性】webview支持w3c draggable属性
I5O4BN【新增特性】webview剪切板对接系统剪切板
I5O4BB【新增特性】webview支持页面图片(渲染图)的获取
I5O4B5【新增特性】webview支持页面input标签粘贴纯文本
I5O4AZ【新增特性】webview支持页面纯文本的获取
I5NXG9【新增规格】web组件touch、scroll、gesture事件支持
I5LIL6【新增特性】web组件的应用和h5的消息交互
I5JTLQ【新增规格】web组件长按区域手柄绘制事件通知
I5HRX9【新增特性】webview支持多媒体播放基础能力 | NA | +| 内核子系统 | 新增内存压力通知AMS、回收优先级管理支持常驻系统服务,回收优先级管理支持区分extension状态等基础能力。
新增前向CFI保护。
内核编译切换为CLANG编译器。
主要涉及如下需求:
I5K0VE  通知AMS内存等级
I5BND4  上报adj模块系统应用被查杀后是否能够重启
I5BNEC  提供监听Service/Data/Extension关联关系转态能力
I5MXBS  Forward-Edge CFI,内核新增前向CFI能力
I5P4FB  使能前向CFI
I5LX3A  Building Linux with Clang/LLVM | NA | +| 媒体子系统 | 支持分布式音频、音量、设备状态管理,设备监听和投播功能;支持3.5mm耳机设备;支持分布式相机预览、拍照和录像功能,meta信息管理支持。
I5NYBJ 【性能】媒体播放启动时间
I5NYCF 【新增特性】支持基于HDI codec接口的视频硬编码能力
I5NYCP 【新增特性】支持基于HDI codec接口的视频硬解码能力
I5OOKN 【新增特性】支持h.265格式视频硬解码
I5OOKW 【新增特性】支持h.265格式视频硬编码
I5OWXY 【新增特性】支持音频解码native接口
I5OXCD 【新增特性】支持音频编码native接口
I5P8N0 【新增特性】支持视频编码native接口
I5O336 【新增特性】支持单应用音频投播和系统所有音频投播
I5OEWG 【新增特性】支持系统应用设置和获取单个音频流的音量 | NA | +| 语言编译运行时子系统 | 前端编译性能提升,如es2abc。
运行时性能提升优化,如ISA重构优化、汇编解释器、TSAOT等。
新增功能,如支持严格模式的ES2021、模块化支持、Runtime 调试调优增强、字节码热重载等。
具体如下:
I5MYM9 【新增规格】运行时多模块单abc文件合并适配
I59TAQ【新增规格】支持TSAOT优化编译器标准编译lowering和优化pass(规格)描述
I5OJ8Q【新增规格】IDE属性查看功能补齐已支持的2021规范定义的类型
I5ODV4 【新增特性】 支持字节码补丁文件卸载功能
I5OXSC 【新增特性】 支持字节码补丁文件加载功能
I5HNNZ 【新增特性】使能加载器的命名空间
I5HVQE  【新增特性】线程stacksize根据产品配置,增加stack pageguard保护
I5MCUF【增强特性】libc增加CAPI接口,支持pthread等符号
I5HVNH【新增特性】RM.006.增强动态库符号管理
I5HVQ0 【新增特性】RM.008.musl支持fortify功能
I5KT7X 【新增特性】RM.002.提供API头文件API检测功能
I5TB3Y 【新增特性】ABI默认使用emutls特性
I5R119  【增强特性】拆分加载器与libc内存使用
支持clang工具链的开源构建
I5MYM9【新增规格】前端编译工具链支持模块化编译
I5IKO1【新增规格】前端abc支持commonjs模块
I5RRAJ【新增规格】补丁文件源码识别工具
I5PRFT【新增规格】补丁字节码编译工具
I5RHDH【新增规格】支持方舟字节码热加载
I5RA7C【新增规格】支持strict模式2021
I5HRUY【新增规格】es2abc支持js转换方舟字节码 | NA | +| 帐号&程序访问控制子系统 | 帐号服务新增用户身份认证服务;权限服务新增支持精准定位或模糊定位,以及其他能力增强;新增隐私管理服务。
主要涉及如下需求:
I5N90B【新增规格】应用帐号适配沙箱应用
I5N90O【新增规格】帐号子系统新增用户身份认证服务
I5NOQI【新增特性】权限服务支持精准定位或模糊定位
I5NT1X【新增特性】权限使用记录管理增强
I5NU8U【新增特性】权限弹框UX界面增强
I5P4IU【新增特性】新增隐私管理服务
I5P530【新增特性】位置服务使用状态管理 | NA | +| 全球化子系统 | 新增支持翻译伪本地化能力。
涉及如下需求:
I4WLSJ 【新增特性】翻译伪本地化能力 | NA | +| Misc服务子系统 | 新增剪贴板、上传下载、锁屏、输入法框架等模块基础特性。
主要涉及如下需求:
I5JPMG 【request部件】【download】后台任务通知
I5NXHK 【input_method_fwk部件】输入法框架支持仅绑定输入法innerkits接口和独立控制软键盘显隐的js接口
I5NG2X 【theme_screenlock部件】支持特定系统应用请求锁定屏幕
I5IU1Z  支持向剪贴板数据增加图片内容的数据项
I5OGA3  支持设备级的跨设备剪贴板开关
I5NMKI 【pasteboard部件】支持向剪贴板数据增加二进制数据
I5MAMN  支持剪贴板数据范围限制在应用内
I5OX20 【input_method_fwk部件】输入法框架支持获取输入法扩展 | NA | +| ArkUI子系统 | ArkUI组件能力增强;资源、媒体查询能力增强;内存、性能优化;DFX能力增强;工具链能力增强。
主要涉及如下需求:
I5IZZ7 【ace_engine_standard部件】panel组件支持单独设置每个角的borderRadius
I5JQ1R 【ace_engine_standard部件】支持图片复制粘贴
I5JQ3F 【ace_engine_standard部件】输入框能力增强
I5JQ3J 【ace_engine_standard部件】stack组件新增事件拓传机制
I5JQ54 【ace_engine_standard部件】指定控件获取焦点
I5MX7J 【ace_engine_standard部件】list列表支持左滑/右滑及回弹效果
I5MWS0 【ace_engine_standard部件】panel组件弹出高度通知给开发者
I5IZVY 【ace_engine_standard部件】键鼠接入时支持组件刷新
I5JQ5Y 【ace_engine_standard部件】走焦能力增强
I5IY7K 【新增需求】【ace_engine_standard部件】主题能力支持
I5MWTB 【ace_engine_standard部件】媒体查询支持vp查询
I5IZU9 【ace_engine_standard部件】ui_service常驻内存优化
I5JQ26 【ace_engine_standard部件】Vsync请求机制流程优化
I5JQ2O 【ace_engine部件】公共资源预加载
I5JQ2D 【ace_engine_standard部件】Move事件重采样优化
I5IZXS 【toolchain部件】DFX打印错误堆栈时支持显示开发者变量名称原文
I5IZYG 【toolchain部件】DFX打印错误堆栈时支持显示开发者变量名称原文
I5IZX0 【toolchain部件】编译支持解析$r新增bundleName和moduleName参数
I5J09I 【toolchain部件】\@Builder 支持export导出 | NA | + + + + +### 芯片及开发板适配 + +芯片及开发板适配状态请参考[SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig-devboard/sig_devboard_cn.md)信息。 + + +### Samples + + **表4** 新增Samples + +| 子系统 | 名称 | 简介 | 开发语言 | +| -------- | -------- | -------- | -------- | +| ArkUI | [HealthyDiet:健康饮食](https://gitee.com/openharmony/applications_app_samples/tree/master/ETSUI/HealthyDiet) | 这是一个记录饮食和查看食物信息的应用,主要用于管理饮食健康。可以添加饮食信息,包括食物的种类、重量以及用餐时间,如早餐、 午餐、晚餐和夜宵,并能统计得到相应用餐时间的总热量值、总蛋白质、总脂肪和总碳水值,并且用柱状图的形式展示出来。 | eTS | +| ArkUI | [MusicAlbum:一多音乐专辑主页](https://gitee.com/openharmony/applications_app_samples/tree/master/MultiDeviceAppDev/MusicAlbum) | 本示例展示了音乐专辑主页,使用一次开发多端部署中介绍的自适应布局能力和响应式布局能力进行多设备(或多窗口尺寸)适配,保证应用在不同设备或不同窗口尺寸下可以正常显示。 | eTS | +| 元能力、文件管理 | [Share:分享](https://gitee.com/openharmony/applications_app_samples/tree/master/Share/Share) | 分享的主要工作是实现:发送方将文本,链接,图片文件三种类型分享给三方应用,同时能够在三方应用中分别呈现出来。 | eTS | +| 元能力 | [GalleryForm:图库卡片](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/GalleryForm) | 本示例是模拟图库卡片,实现对图库中的照片在卡片中显示,定时刷新卡片内容等功能。 | eTS | +| ArkUI | [AppMarket:一多应用市场首页](https://gitee.com/openharmony/applications_app_samples/tree/master/MultiDeviceAppDev/AppMarket) | 本示例展示了应用市场首页,页面中包括Tab栏、运营横幅、精品应用、精品游戏等。 | eTS | +| ArkUI | [Weather:一多天气](https://gitee.com/openharmony/applications_app_samples/tree/master/MultiDeviceAppDev/Weather) | 本示例展示一个天气应用界面,包括首页、城市管理、添加城市、更新时间弹窗,体现一次开发,多端部署的能力。 | eTS | +| 媒体 | [MediaCollections:媒体管理合集](https://gitee.com/openharmony/applications_app_samples/tree/master/media/MediaCollections) | 本示例展示了网络流播放能力、音视频播控能力、音量调节能力等。 | eTS | + +请访问[Samples](https://gitee.com/openharmony/app_samples)仓了解更多信息。 + + +## 修复缺陷列表 + + **表5** 修复缺陷ISSUE列表 + +| ISSUE单 | 问题描述 | +| -------- | -------- | +| I5I4GJ | 通过IDE连接RK3568设备概率断连。 | +| I5HTGF | 相机拍出来照片跟预览相比顺时针旋转90度。 | +| I5FUNB | linux内核漏洞同步
CVE-2022-1462 | + + + +## 遗留缺陷列表 + + **表6** 遗留缺陷列表 + +| ISSUE | 问题描述 | 影响 | 计划解决日期 | +| -------- | -------- | -------- | -------- | +| I59PWR | 在RK3568设备上对Openharmony 进行内存测试,com.ohos.launcher基线值84279KB,超基线200MB | 占用内存超过预期,但不影响整机内存的正常使用。 | 10月20号 | +| I59QII | 在RK3568设备上对Openharmony 进行常驻内存测试,netmanager进程 基线值1241KB,实测值3884KB,超基线2.58Mony 进行内存测试,netmanager进程 基线值1241KB,超基线1MB | 占用内存超过预期,但不影响整机内存的正常使用。 | 10月20号 | +| I5LH57 | 在RK3568设备上对Openharmony 进行常驻内存测试,telephony 进程 基线值8434KB,实测值10329KB,超基线1.85MB | 占用内存超过预期,但不影响整机内存的正常使用。 | 10月20号 | +| I5Q5PR | 在RK3568设备上对Openharmony 进行常驻内存测试,wifi_hal_service进程 基线值 829KB,实测值4374KB,超基线3.4MB | 占用内存超过预期,但不影响整机内存的正常使用。已达成,无功能影响 | 10月20号 | +| I5T71O | 在RK3568设备上对Openharmony 进行动态内存测试,com.ohos.settings进程 基线值 15824 KB,实测值 76123KB,超基线58.8MB | 占用内存超过预期,但不影响整机内存的正常使用。 | 10月20号 | +| I5S40B | 联系人列表滑动帧率标准值:54fps,实际值:30.3fps,较基线少23.7fps | 影响负载胜率指标,依赖于ArkUI框架重构,重构需求交付时间10月15号。 | 10月15号 | +| I5MVDK | 对 /data/data/.pulse_dir/runtime/cli 进行socketfuzz出现crash | 进行socketfuzz测试,发生进程crash。 | 10月18日 | +| I5M3UO | [TTE WRC team] New line injection via Wi-Fi SSID name in wifi_manager_service | WIFI的SSID输入非法字符(\n), 配置文件存储并解析会出现异常。 | 10月12日 | +| I5T8FV | 校验权限在系统中未定义未真实生效 | 权限未在系统中定义,鉴权时不通过,无进程可申请该权限,当前无业务调用。 | 10月18日 | diff --git a/zh-cn/release-notes/Readme.md b/zh-cn/release-notes/Readme.md index bcecbe9d2288800cacc9df870d35ca4fdd1e515b..090ebf20f802b3c21388c2555e4adf46800025da 100644 --- a/zh-cn/release-notes/Readme.md +++ b/zh-cn/release-notes/Readme.md @@ -1,6 +1,7 @@ # OpenHarmony Release Notes ## OpenHarmony 3.x Releases +- [OpenHarmony v3.2 Beta3 (2022-09-30)](OpenHarmony-v3.2-beta3.md) - [OpenHarmony v3.1.2 Release (2022-08-24)](OpenHarmony-v3.1.2-release.md) - [OpenHarmony v3.2 Beta2 (2022-07-30)](OpenHarmony-v3.2-beta2.md) - [OpenHarmony v3.2 Beta1 (2022-05-31)](OpenHarmony-v3.2-beta1.md) diff --git a/zh-cn/website.md b/zh-cn/website.md index 6171cc9bfc7fba331873424b1f86b7adade5f129..c70f36e9a26d351ddda95f6fcc4d2211aae092a3 100644 --- a/zh-cn/website.md +++ b/zh-cn/website.md @@ -4,6 +4,7 @@ - [术语](glossary.md) - 版本说明 - OpenHarmony 3.x Releases + - [OpenHarmony v3.2 Beta3 (2022-09-30)](release-notes/OpenHarmony-v3.2-beta3.md) - [OpenHarmony v3.2 Beta2 (2022-07-30)](release-notes/OpenHarmony-v3.2-beta2.md) - [OpenHarmony v3.2 Beta1 (2022-05-31)](release-notes/OpenHarmony-v3.2-beta1.md) - [OpenHarmony v3.1.1 Release (2022-05-31)](release-notes/OpenHarmony-v3.1.1-release.md) @@ -14,13 +15,13 @@ - [OpenHarmony v3.0.2 LTS (2022-03-18)](release-notes/OpenHarmony-v3.0.2-LTS.md) - [OpenHarmony v3.0.1 LTS (2022-01-12)](release-notes/OpenHarmony-v3.0.1-LTS.md) - [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md) - + - OpenHarmony 2.x Releases - [OpenHarmony v2.2 beta2 (2021-08-04)](release-notes/OpenHarmony-v2.2-beta2.md) - [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md) - OpenHarmony 1.x Releases - + - [OpenHarmony v1.1.4 LTS (2022-02-11)](release-notes/OpenHarmony-v1-1-4-LTS.md) - [OpenHarmony v1.1.3 LTS (2021-09-30)](release-notes/OpenHarmony-v1-1-3-LTS.md) - [OpenHarmony v1.1.2 LTS (2021-08-04)](release-notes/OpenHarmony-v1.1.2-LTS.md) @@ -150,4 +151,3 @@ - [写作规范](contribute/写作规范.md) - [社区沟通与交流](contribute/社区沟通与交流.md) - [FAQ](contribute/FAQ.md) - \ No newline at end of file