提交 9902201d 编写于 作者: J jiangminsen

Merge remote-tracking branch 'upstream/master'

...@@ -397,7 +397,7 @@ zh-cn/application-dev/reference/apis/js-apis-notification.md @jayleehw @RayShih ...@@ -397,7 +397,7 @@ zh-cn/application-dev/reference/apis/js-apis-notification.md @jayleehw @RayShih
zh-cn/application-dev/reference/apis/js-apis-observer.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785 zh-cn/application-dev/reference/apis/js-apis-observer.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-osAccount.md @nianCode @zengyawen @JiDong-CS @murphy1984 zh-cn/application-dev/reference/apis/js-apis-osAccount.md @nianCode @zengyawen @JiDong-CS @murphy1984
zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @feng-aiwen @ge-yafang @gong-a-shi @logic42 zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @han-zhengshi @ge-yafang @logic42
zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-plainarray.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-plainarray.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-pointer.md @yuanxinying @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-pointer.md @yuanxinying @ningningW @cococoler @alien0208
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
- master:最新开发版本。 - master:最新开发版本。
- OpenHarmony 3.2 Beta5版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.2-beta5.md)了解版本详情。 - OpenHarmony 3.2 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.2-release.md)了解版本详情。
- OpenHarmony 3.1 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.1-release.md)了解版本详情。 - OpenHarmony 3.1 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.1-release.md)了解版本详情。
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
- [@ohos.data.dataShareResultSet (DataShare Result Set)](js-apis-data-DataShareResultSet.md) - [@ohos.data.dataShareResultSet (DataShare Result Set)](js-apis-data-DataShareResultSet.md)
- [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md) - [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md) - [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md)
- [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md) - [@ohos.data.preferences (User Preferences)](js-apis-data-preferences.md)
- [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md) - [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md)
- [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md) - [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
- [@ohos.file.fileUri (File URI)](js-apis-file-fileUri.md) - [@ohos.file.fileUri (File URI)](js-apis-file-fileUri.md)
- [@ohos.file.fs (File Management)](js-apis-file-fs.md) - [@ohos.file.fs (File Management)](js-apis-file-fs.md)
- [@ohos.file.hash (File Hash Processing)](js-apis-file-hash.md) - [@ohos.file.hash (File Hash Processing)](js-apis-file-hash.md)
- [@ohos.file.picker (Picker)](js-apis-file-picker.md) - [@ohos.file.picker (File Picker)](js-apis-file-picker.md)
- [@ohos.file.securityLabel (Data Label)](js-apis-file-securityLabel.md) - [@ohos.file.securityLabel (Data Label)](js-apis-file-securityLabel.md)
- [@ohos.file.statvfs (File System Space Statistics)](js-apis-file-statvfs.md) - [@ohos.file.statvfs (File System Space Statistics)](js-apis-file-statvfs.md)
- [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md) - [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md)
...@@ -267,7 +267,7 @@ ...@@ -267,7 +267,7 @@
- [@ohos.request (Upload and Download)](js-apis-request.md) - [@ohos.request (Upload and Download)](js-apis-request.md)
- Connectivity - Connectivity
- [@ohos.bluetooth (Bluetooth) (To Be Deprecated Soon)](js-apis-bluetooth.md) - [@ohos.bluetooth (Bluetooth)(To Be Deprecated Soon)](js-apis-bluetooth.md)
- [@ohos.bluetoothManager (Bluetooth)(js-apis-bluetoothManager.md) - [@ohos.bluetoothManager (Bluetooth)(js-apis-bluetoothManager.md)
- [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md) - [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md)
- [@ohos.nfc.cardEmulation (Standard NFC Card Emulation)](js-apis-cardEmulation.md) - [@ohos.nfc.cardEmulation (Standard NFC Card Emulation)](js-apis-cardEmulation.md)
...@@ -276,8 +276,8 @@ ...@@ -276,8 +276,8 @@
- [@ohos.rpc (RPC)](js-apis-rpc.md) - [@ohos.rpc (RPC)](js-apis-rpc.md)
- [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md) - [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md)
- [@ohos.wifiManagerExt (WLAN Extension)](js-apis-wifiManagerExt.md) - [@ohos.wifiManagerExt (WLAN Extension)](js-apis-wifiManagerExt.md)
- [@ohos.wifi (To Be Deprecated Soon)](js-apis-wifi.md) - [@ohos.wifi (WLAN)(To Be Deprecated Soon)](js-apis-wifi.md)
- [@ohos.wifiext (To Be Deprecated Soon)](js-apis-wifiext.md) - [@ohos.wifiext (WLAN Extension)(To Be Deprecated Soon)](js-apis-wifiext.md)
- tag - tag
- [nfctech (Standard NFC Technologies)](js-apis-nfctech.md) - [nfctech (Standard NFC Technologies)](js-apis-nfctech.md)
- [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md) - [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md)
......
...@@ -547,7 +547,7 @@ startBluetoothDiscovery(): void ...@@ -547,7 +547,7 @@ startBluetoothDiscovery(): void
Starts Bluetooth scan to discover remote devices. Starts Bluetooth scan to discover remote devices.
**Rquired permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION **Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
...@@ -652,6 +652,98 @@ try { ...@@ -652,6 +652,98 @@ try {
``` ```
## bluetoothManager.setDevicePinCode<sup>10+</sup><a name="setDevicePinCode"></a>
setDevicePinCode(device: string, code: string, callback: AsyncCallback&lt;void&gt;): void
Sets the PIN for the device when [PinType](#pintype10) is **PIN_TYPE_ENTER_PIN_CODE** or **PIN_TYPE_PIN_16_DIGITS**.
**Required permissions**: ohos.permission.MANAGE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------- | ---- | -------------------------------- |
| device | string | Yes | MAC address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
| code | string | Yes | PIN to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
**Error codes**
For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
| ID| Error Message|
| -------- | ---------------------------- |
|2900001 | Service stopped. |
|2900003 | Bluetooth switch is off. |
|2900099 | Operation failed. |
**Example**
```js
//callback
try {
bluetoothManager.setDevicePinCode('11:22:33:44:55:66', '12345', (err, data) => {
console.info('setDevicePinCode,device name err:' + JSON.stringify(err) + ',device name:' + JSON.stringify(data));
});
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
}
```
## bluetoothManager.setDevicePinCode<sup>10+</sup><a name="setDevicePinCode"></a>
setDevicePinCode(device: string, code: string): Promise&lt;void&gt;
Sets the PIN for the device when [PinType](#pintype10) is **PIN_TYPE_ENTER_PIN_CODE** or **PIN_TYPE_PIN_16_DIGITS**. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MANAGE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------- | ---- | -------------------------------- |
| device | string | Yes | MAC address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
| code | string | Yes | PIN to set. |
**Return value**
| Type | Description |
| ------------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
| ID| Error Message|
| -------- | ---------------------------- |
|2900001 | Service stopped. |
|2900003 | Bluetooth switch is off. |
|2900099 | Operation failed. |
**Example**
```js
//promise
try {
bluetoothManager.setDevicePinCode('11:22:33:44:55:66', '12345').then(() => {
console.info('setDevicePinCode');
}, error => {
console.info('setDevicePinCode: errCode:' + error.code + ',errMessage' + error.message);
})
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
}
```
## bluetoothManager.on('bluetoothDeviceFind') ## bluetoothManager.on('bluetoothDeviceFind')
on(type: "bluetoothDeviceFind", callback: Callback&lt;Array&lt;string&gt;&gt;): void on(type: "bluetoothDeviceFind", callback: Callback&lt;Array&lt;string&gt;&gt;): void
...@@ -1385,7 +1477,7 @@ Creates a **GattServer** instance. ...@@ -1385,7 +1477,7 @@ Creates a **GattServer** instance.
| Type | Description | | Type | Description |
| ------------------------- | ------------------------------------ | | ------------------------- | ------------------------------------ |
| [GattServer](#gattserver) | **GattServer** instance created. Before using an API of the server, you must create a **GattSever** instance.| | [GattServer](#gattserver) | **GattServer** instance created. Before using an API of this class, you must create a **GattSever** instance.|
**Example** **Example**
...@@ -2333,17 +2425,6 @@ Obtains the network sharing status. ...@@ -2333,17 +2425,6 @@ Obtains the network sharing status.
| --------------------- | --------------------------------- | | --------------------- | --------------------------------- |
| boolean | Returns **true** if tethering is available over a Bluetooth PAN; return **false** otherwise.| | boolean | Returns **true** if tethering is available over a Bluetooth PAN; return **false** otherwise.|
**Error codes**
For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
| ID| Error Message|
| -------- | ---------------------------- |
|2900001 | Service stopped. |
|2900003 | Bluetooth switch is off. |
|2900004 | Profile is not supported. |
|2900099 | Operation failed. |
**Example** **Example**
```js ```js
...@@ -3258,7 +3339,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3258,7 +3339,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901000 | Read forbidden. | |2901000 | Read forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -3327,7 +3408,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3327,7 +3408,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901000 | Read forbidden. | |2901000 | Read forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -3382,7 +3463,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3382,7 +3463,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901000 | Read forbidden. | |2901000 | Read forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -3444,7 +3525,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3444,7 +3525,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901000 | Read forbidden. | |2901000 | Read forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -3491,7 +3572,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3491,7 +3572,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901001 | Write forbidden. | |2901001 | Write forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -3545,7 +3626,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3545,7 +3626,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901001 | Write forbidden. | |2901001 | Write forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -4016,17 +4097,18 @@ Defines the characteristic API parameters. ...@@ -4016,17 +4097,18 @@ Defines the characteristic API parameters.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| ------------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- | | ------------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.| | serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
| characteristicUuid | string | Yes | Yes | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.| | characteristicUuid | string | Yes | Yes | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
| characteristicValue | ArrayBuffer | Yes | Yes | Binary value of the characteristic. | | characteristicValue | ArrayBuffer | Yes | Yes | Binary value of the characteristic. |
| descriptors | Array&lt;[BLEDescriptor](#bledescriptor)&gt; | Yes | Yes | List of descriptors of the characteristic. | | descriptors | Array&lt;[BLEDescriptor](#bledescriptor)&gt; | Yes | Yes | List of descriptors of the characteristic. |
| properties<sup>10+</sup> | [GattProperties](#gattproperties10) | Yes | Yes | Properties of the characteristic. |
## BLEDescriptor ## BLEDescriptor
Defines the descriptor API parameters. Defines the BLE descriptor.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
...@@ -4229,6 +4311,7 @@ Defines the scan result. ...@@ -4229,6 +4311,7 @@ Defines the scan result.
| deviceId | string | Yes | No | Address of the scanned device, for example, XX:XX:XX:XX:XX:XX.| | deviceId | string | Yes | No | Address of the scanned device, for example, XX:XX:XX:XX:XX:XX.|
| rssi | number | Yes | No | RSSI of the device. | | rssi | number | Yes | No | RSSI of the device. |
| data | ArrayBuffer | Yes | No | Advertisement packets sent by the device. | | data | ArrayBuffer | Yes | No | Advertisement packets sent by the device. |
| deviceName<sup>10+</sup> | string | Yes | No | Name of the device detected. |
## BluetoothState ## BluetoothState
...@@ -4308,6 +4391,7 @@ Defines the pairing request parameters. ...@@ -4308,6 +4391,7 @@ Defines the pairing request parameters.
| -------- | ------ | ---- | ---- | ----------- | | -------- | ------ | ---- | ---- | ----------- |
| deviceId | string | Yes | No | ID of the device to pair.| | deviceId | string | Yes | No | ID of the device to pair.|
| pinCode | string | Yes | No | Key for the device pairing. | | pinCode | string | Yes | No | Key for the device pairing. |
| pinType<sup>10+</sup> | [PinType](#pintype10) | Yes | No | Type of the device to pair. |
## BondStateParam<a name="BondStateParam"></a> ## BondStateParam<a name="BondStateParam"></a>
...@@ -4334,6 +4418,21 @@ Defines the profile state change parameters. ...@@ -4334,6 +4418,21 @@ Defines the profile state change parameters.
| state | [ProfileConnectionState](#profileconnectionstate) | Yes | No | Profile connection state of the device.| | state | [ProfileConnectionState](#profileconnectionstate) | Yes | No | Profile connection state of the device.|
## GattProperties<sup>10+</sup><a name="GattProperties"></a>
Defines the properties of a GATT characteristic.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Read-only | Mandatory | Description |
| -------- | ------ | ---- | ---- | ----------- |
| write<sup>10+</sup> | boolean | Yes | Yes | Permits writes of the characteristic value (with a response).|
| writeNoResponse<sup>10+</sup> | boolean | Yes | Yes | Permits writes of the characteristic value (without a response).|
| read<sup>10+</sup> | boolean | Yes | Yes | Permits reads of the characteristic value.|
| notify<sup>10+</sup> | boolean | Yes | Yes | Permits notifications of the characteristic value.|
| indicate<sup>10+</sup> | boolean | Yes | Yes | Permits notifications of the characteristic value without acknowledgement.|
## DeviceClass<a name="DeviceClass"></a> ## DeviceClass<a name="DeviceClass"></a>
Defines the class of a Bluetooth device. Defines the class of a Bluetooth device.
...@@ -4347,7 +4446,6 @@ Defines the class of a Bluetooth device. ...@@ -4347,7 +4446,6 @@ Defines the class of a Bluetooth device.
| classOfDevice | number | Yes | No | Class of the device. | | classOfDevice | number | Yes | No | Class of the device. |
## MajorClass<a name="MajorClass"></a> ## MajorClass<a name="MajorClass"></a>
Enumerates the major classes of Bluetooth devices. Enumerates the major classes of Bluetooth devices.
...@@ -4489,3 +4587,21 @@ Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOS ...@@ -4489,3 +4587,21 @@ Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOS
| PROFILE_HANDS_FREE_AUDIO_GATEWAY | 4 | HFP profile. | | PROFILE_HANDS_FREE_AUDIO_GATEWAY | 4 | HFP profile. |
| PROFILE_HID_HOST | 6 | Human Interface Device (HID) profile. | | PROFILE_HID_HOST | 6 | Human Interface Device (HID) profile. |
| PROFILE_PAN_NETWORK | 7 | PAN profile. | | PROFILE_PAN_NETWORK | 7 | PAN profile. |
## PinType<sup>10+</sup><a name="PinType"></a>
Enumerates the Bluetooth pairing types.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
| -------------------------------- | ------ | --------------- |
| PIN_TYPE_ENTER_PIN_CODE<sup>10+</sup> | 0 | The user needs to enter the PIN displayed on the peer device.|
| PIN_TYPE_ENTER_PASSKEY<sup>10+</sup> | 1 | The user needs to enter the PASSKEY displayed on the peer device. |
| PIN_TYPE_CONFIRM_PASSKEY<sup>10+</sup> | 2 | The user needs to confirm the PASSKEY displayed on the local device. |
| PIN_TYPE_NO_PASSKEY_CONSENT<sup>10+</sup> | 3 | There is no PASSKEY, and the user needs to accept or reject the pairing request. |
| PIN_TYPE_NOTIFY_PASSKEY<sup>10+</sup> | 4 | The user needs to enter the PASSKEY displayed on the local device on the peer device. |
| PIN_TYPE_DISPLAY_PIN_CODE<sup>10+</sup> | 5 | The user needs to enter the PIN displayed on the peer device for Bluetooth 2.0 devices. |
| PIN_TYPE_OOB_CONSENT<sup>10+</sup> | 6 | The user needs to accept or reject the out of band (OOB) pairing request. |
| PIN_TYPE_PIN_16_DIGITS<sup>10+</sup> | 7 | The user needs to enter the 16-digit PIN displayed on the peer device. |
# @ohos.data.preferences (Preferences) # @ohos.data.preferences (User Preferences)
The **Preferences** module provides APIs for processing data in the form of key-value (KV) pairs and supports persistence of the KV pairs when required. The **user preferences** module provides APIs for processing data in the form of key-value (KV) pairs and supports persistence of the KV pairs when required.
The key is of the string type, and the value can be a number, a string, a Boolean value, or an array of numbers, strings, or Boolean values. The key is of the string type, and the value can be a number, a string, a Boolean value, or an array of numbers, strings, or Boolean values.
...@@ -176,12 +176,12 @@ The deleted **Preferences** instance cannot be used for data operations. Otherwi ...@@ -176,12 +176,12 @@ The deleted **Preferences** instance cannot be used for data operations. Otherwi
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | ---------------------------------------------------- | | -------- | ------------------------------------- | ---- | ---------------------------------------------------- |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md). | | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md). |
| name | string | Yes | Name of the **Preferences** instance to delete. | | name | string | Yes | Name of the **Preferences** instance to delete. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
**Error codes** **Error codes**
For details about the following error codes, see [Preference Error Codes](../errorcodes/errorcode-preferences.md). For details about the error codes, see [User Preference Error Codes](../errorcodes/errorcode-preferences.md).
| ID| Error Message | | ID| Error Message |
| -------- | ------------------------------| | -------- | ------------------------------|
...@@ -213,6 +213,7 @@ Stage model: ...@@ -213,6 +213,7 @@ Stage model:
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
try { try {
...@@ -257,7 +258,7 @@ The deleted **Preferences** instance cannot be used for data operations. Otherwi ...@@ -257,7 +258,7 @@ The deleted **Preferences** instance cannot be used for data operations. Otherwi
**Error codes** **Error codes**
For details about the following error codes, see [Preference Error Codes](../errorcodes/errorcode-preferences.md). For details about the error codes, see [User Preference Error Codes](../errorcodes/errorcode-preferences.md).
| ID| Error Message | | ID| Error Message |
| -------- | ------------------------------| | -------- | ------------------------------|
...@@ -288,6 +289,7 @@ Stage model: ...@@ -288,6 +289,7 @@ Stage model:
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
try{ try{
...@@ -348,6 +350,7 @@ Stage model: ...@@ -348,6 +350,7 @@ Stage model:
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
try { try {
...@@ -500,7 +503,7 @@ try { ...@@ -500,7 +503,7 @@ try {
promise.then((data) => { promise.then((data) => {
console.info("Got the value of 'startup'. Data: " + data); console.info("Got the value of 'startup'. Data: " + data);
}).catch((err) => { }).catch((err) => {
console.info("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message); console.info("Failed to obtain the value of 'startup'. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to obtain the value of 'startup'. code =" + err.code + ", message =" + err.message); console.info("Failed to obtain the value of 'startup'. code =" + err.code + ", message =" + err.message);
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
- [DataShare Error Codes](errorcode-datashare.md) - [DataShare Error Codes](errorcode-datashare.md)
- [Distributed Data Object Error Codes](errorcode-distributed-dataObject.md) - [Distributed Data Object Error Codes](errorcode-distributed-dataObject.md)
- [Distributed KV Store Error Codes](errorcode-distributedKVStore.md) - [Distributed KV Store Error Codes](errorcode-distributedKVStore.md)
- [Preferences Error Codes](errorcode-preferences.md) - [User Preference Error Codes](errorcode-preferences.md)
- File Management - File Management
- [File Management Error Codes](errorcode-filemanagement.md) - [File Management Error Codes](errorcode-filemanagement.md)
- Telephony Service - Telephony Service
......
# Preferences Error Codes # User Preference Error Codes
> **NOTE** > **NOTE**
> >
> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). > This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md).
## 15500010 Failed to Delete Preferences ## 15500010 Failed to Delete the User Preference Persistence File
**Error Message** **Error Message**
Failed to delete preferences. Failed to delete preferences.
**Description** **Description**
Failed to delete the preference. The operation of deleting the user preference persistence file failed.
**Possible Causes** **Possible Causes**
......
# User Authentication Error Codes # User Authentication Error Codes
> **NOTE** > **NOTE**
> >
> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). > This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md).
## 201 Permission Verification Failed
For details, see [Universal Error Codes](./errorcode-universal.md).
## 202 Invoker Is Not a System Application
For details, see [Universal Error Codes](./errorcode-universal.md).
## 401 Parameter Check Failed.
For details, see [Universal Error Codes](./errorcode-universal.md).
## 12500001 Authentication Failed ## 12500001 Authentication Failed
**Error Message** **Error Message**
......
...@@ -397,7 +397,7 @@ ...@@ -397,7 +397,7 @@
import Ability from '@ohos.app.ability.UIAbility'; import Ability from '@ohos.app.ability.UIAbility';
``` ```
2. 获取Caller通信接口。 2. 获取Caller通信接口。
Ability的context属性实现了startAbilityByCall方法,用于获取指定通用组件的Caller通信接口。如下示例通过this.context获取Ability实例的context属性,使用startAbilityByCall拉起Callee被调用端并获取Caller通信接口,注册Caller的onRelease监听。应用开发者根据实际业务需要做相应处理。 Ability的context属性实现了startAbilityByCall方法,用于获取指定通用组件的Caller通信接口。如下示例通过this.context获取Ability实例的context属性,使用startAbilityByCall拉起Callee被调用端并获取Caller通信接口,注册Caller的onRelease和onRemoteStateChange监听。应用开发者根据实际业务需要做相应处理。
```ts ```ts
...@@ -418,6 +418,14 @@ ...@@ -418,6 +418,14 @@
console.info(`remote caller onRelease is called ${msg}`); console.info(`remote caller onRelease is called ${msg}`);
}) })
console.info('remote caller register OnRelease succeed'); console.info('remote caller register OnRelease succeed');
// 注册caller的协同场景下跨设备组件状态变化监听通知
try {
caller.onRemoteStateChange((str) => {
console.log('Remote state changed ' + str);
});
} catch (error) {
console.log('Caller.onRemoteStateChange catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
} }
}).catch((error) => { }).catch((error) => {
console.error(`get remote caller failed with ${error}`); console.error(`get remote caller failed with ${error}`);
......
...@@ -41,8 +41,17 @@ AVPlayer主要工作是将Audio/Video媒体资源转码为可供渲染的图像 ...@@ -41,8 +41,17 @@ AVPlayer主要工作是将Audio/Video媒体资源转码为可供渲染的图像
## 兼容性说明 ## 兼容性说明
视频播放支持的视频格式分必选规格和可选规格。必选规格为所有厂商均支持的视频格式。对于可选规格,厂商将基于实际情况决定是否实现。建议开发者做兼容处理,保证全平台兼容。
推荐使用主流的播放格式和主流分辨率,不建议开发者自制非常或者异常码流,以免产生无法播放、卡住、花屏等兼容性问题。若发生此类问题不会影响系统,退出码流播放即可。 推荐使用主流的播放格式和主流分辨率,不建议开发者自制非常或者异常码流,以免产生无法播放、卡住、花屏等兼容性问题。若发生此类问题不会影响系统,退出码流播放即可。
| 视频格式 | 是否必选规格 |
|:--------:|:-----:|
| H264 | 是 |
| MPEG2 | 否 |
| MPEG4 | 否 |
| H263 | 否 |
| VP8 | 否 |
主流的播放格式和主流分辨率如下: 主流的播放格式和主流分辨率如下:
| 视频容器规格 | 规格描述 | 分辨率 | | 视频容器规格 | 规格描述 | 分辨率 |
......
...@@ -77,7 +77,7 @@ export class AVRecorderDemo { ...@@ -77,7 +77,7 @@ export class AVRecorderDemo {
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : media.CodecMimeType.VIDEO_MPEG4, videoCodec : media.CodecMimeType.VIDEO_AVC,
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
...@@ -369,7 +369,7 @@ export class VideoRecorderDemo { ...@@ -369,7 +369,7 @@ export class VideoRecorderDemo {
let videoProfile = { let videoProfile = {
fileFormat : media.ContainerFormatType.CFT_MPEG_4, fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : media.CodecMimeType.VIDEO_MPEG4, videoCodec : media.CodecMimeType.VIDEO_AVC,
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
...@@ -487,4 +487,4 @@ export class VideoRecorderDemo { ...@@ -487,4 +487,4 @@ export class VideoRecorderDemo {
音视频录制APP案例包含:创建实例、设置录制参数、获取输入surface、开始录制、暂停录制、恢复录制、停止录制、释放资源等流程。 音视频录制APP案例包含:创建实例、设置录制参数、获取输入surface、开始录制、暂停录制、恢复录制、停止录制、释放资源等流程。
详细代码可参考:[AVRecorderDemo]([multimedia_player_framework: Implementation of media playback and recording | 媒体播放和录制功能实现 - Gitee.com](https://gitee.com/openharmony/multimedia_player_framework/tree/master/test/appdemo/AVRecorderDemo)) 详细代码可参考:[AVRecorderDemo]([multimedia_player_framework: Implementation of media playback and recording | 媒体播放和录制功能实现 - Gitee.com](https://gitee.com/openharmony/multimedia_player_framework/tree/master/test/sample/AVRecorder))
\ No newline at end of file \ No newline at end of file
...@@ -25,8 +25,16 @@ ...@@ -25,8 +25,16 @@
3. 媒体服务把帧数据flush给surface buffer。 3. 媒体服务把帧数据flush给surface buffer。
## 兼容性说明 ## 兼容性说明
视频播放支持的视频格式分必选规格和可选规格。必选规格为所有厂商均支持的视频格式。对于可选规格,厂商将基于实际情况决定是否实现。建议开发者做兼容处理,保证全平台兼容。
推荐使用视频软件主流的播放格式和主流分辨率,不建议开发者自制非常或者异常码流,以免产生无法播放、卡住、花屏等兼容性问题。若发生此类问题不会影响系统,退出码流播放即可。 推荐使用主流的播放格式和主流分辨率,不建议开发者自制非常或者异常码流,以免产生无法播放、卡住、花屏等兼容性问题。若发生此类问题不会影响系统,退出码流播放即可。
| 视频格式 | 是否必选规格 |
|:--------:|:-----:|
| H264 | 是 |
| MPEG2 | 否 |
| MPEG4 | 否 |
| H263 | 否 |
| VP8 | 否 |
主流的播放格式和主流分辨率如下: 主流的播放格式和主流分辨率如下:
......
...@@ -84,7 +84,7 @@ export class VideoRecorderDemo { ...@@ -84,7 +84,7 @@ export class VideoRecorderDemo {
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : 'mp4', fileFormat : 'mp4',
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : 'video/mp4v-es', videoCodec : 'video/avc',
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
......
...@@ -793,6 +793,11 @@ Wi-Fi P2P群组信息已更改。 ...@@ -793,6 +793,11 @@ Wi-Fi P2P群组信息已更改。
- 值:usual.event.HTTP_PROXY_CHANGE - 值:usual.event.HTTP_PROXY_CHANGE
- 订阅者所需权限:无 - 订阅者所需权限:无
## COMMON_EVENT_DOMAIN_ACCOUNT_STATUS_CHANGED<sup>10+<sup>
表示域账号状态发生变化。
- 值:usual.event.DOMAIN_ACCOUNT_STATUS_CHANGED
- 订阅者所需权限:无
## COMMON_EVENT_SIM_STATE_CHANGED<sup>10+<sup> ## COMMON_EVENT_SIM_STATE_CHANGED<sup>10+<sup>
提示SIM卡状态更新。 提示SIM卡状态更新。
- 值:usual.event.SIM_STATE_CHANGED - 值:usual.event.SIM_STATE_CHANGED
......
...@@ -574,6 +574,49 @@ release(): void; ...@@ -574,6 +574,49 @@ release(): void;
} }
``` ```
## Caller.onRemoteStateChange
onRemoteStateChange(callback: OnRemoteStateChangeCallback): void;
注册协同场景下跨设备组件状态变化监听通知。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | [OnRemoteStateChangeCallback](#onremotestatechangecallback) | 是 | 返回onRemoteStateChange回调结果。 |
**示例:**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
let caller;
let dstDeviceId: string;
export default class MainAbility extends UIAbility {
onWindowStageCreate(windowStage: Window.WindowStage) {
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
deviceId: dstDeviceId
}).then((obj) => {
caller = obj;
try {
caller.onRemoteStateChange((str) => {
console.log('Remote state changed ' + str);
});
} catch (error) {
console.log('Caller.onRemoteStateChange catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
}).catch((err) => {
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
})
}
}
```
## Caller.on ## Caller.on
on(type: 'release', callback: OnReleaseCallback): void; on(type: 'release', callback: OnReleaseCallback): void;
...@@ -841,6 +884,16 @@ off(method: string): void; ...@@ -841,6 +884,16 @@ off(method: string): void;
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| (msg: string) | 是 | 否 | function | 调用者注册的侦听器函数接口的原型。 | | (msg: string) | 是 | 否 | function | 调用者注册的侦听器函数接口的原型。 |
## OnRemoteStateChangeCallback
(msg: string): void;
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore
| 名称 | 可读 | 可写 | 类型 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| (msg: string) | 是 | 否 | function | 调用者注册的协同场景下组件状态变化监听函数接口的原型。 |
## CalleeCallback ## CalleeCallback
(indata: rpc.MessageSequence): rpc.Parcelable; (indata: rpc.MessageSequence): rpc.Parcelable;
......
...@@ -101,3 +101,181 @@ dateTimeManager.setDateTime(wantTemp, 1526003846000).then(() => { ...@@ -101,3 +101,181 @@ dateTimeManager.setDateTime(wantTemp, 1526003846000).then(() => {
console.log("error code:" + error.code + " error message:" + error.message); console.log("error code:" + error.code + " error message:" + error.message);
}) })
``` ```
## dateTimeManager.disallowModifyDateTime<sup>10+</sup>
disallowModifyDateTime(admin: Want, disallow: boolean, callback: AsyncCallback\<void>): void
禁止修改系统时间。使用callback异步回调。
**需要权限:** ohos.permission.ENTERPRISE_SET_DATETIME
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| disallow | boolean | 是 | true 表示禁止修改系统时间,false表示允许修改系统时间。 |
| callback | AsyncCallback\<void> | 是 | 回调函数。当禁止修改系统时间设置成功err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
dateTimeManager.disallowModifyDateTime(wantTemp, true, (error) => {
if (error) {
console.log("error code:" + error.code + " error message:" + error.message);
}
})
```
## dateTimeManager.disallowModifyDateTime<sup>10+</sup>
disallowModifyDateTime(admin: Want, disallow: boolean): Promise\<void>
禁止修改系统时间。使用Promise异步回调。
**需要权限:** ohos.permission.ENTERPRISE_SET_DATETIME
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| disallow | boolean | 是 | true 表示禁止修改系统时间,false表示允许修改系统时间。 |
**返回值:**
| 类型 | 说明 |
| ----- | ----------------------------------- |
| Promise\<void> | Promise对象。无返回结果的Promise对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
dateTimeManager.disallowModifyDateTime(wantTemp, true).then(() => {
}).catch((error) => {
console.log("error code:" + error.code + " error message:" + error.message);
})
```
## dateTimeManager.isModifyDateTimeDisallowed<sup>10+</sup>
isModifyDateTimeDisallowed(admin: Want, callback: AsyncCallback\<boolean>): void
查询是否允许修改系统时间。使用callback异步回调。
**需要权限:** ohos.permission.ENTERPRISE_SET_DATETIME
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| callback | AsyncCallback\<boolean> | 是 | 回调函数。callbac方式返回是否禁止修改系统时间策略。true表示禁止修改系统时间,否则表示允许修改系统时间。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
dateTimeManager.isModifyDateTimeDisallowed(wantTemp, (error) => {
if (error) {
console.log("error code:" + error.code + " error message:" + error.message);
}
})
```
## dateTimeManager.isModifyDateTimeDisallowed<sup>10+</sup>
isModifyDateTimeDisallowed(admin: Want): Promise\<boolean>
查询是否允许修改系统时间。使用Promise异步回调。
**需要权限:** ohos.permission.ENTERPRISE_SET_DATETIME
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
**返回值:**
| 类型 | 说明 |
| ----- | ----------------------------------- |
| Promise\<boolean> | Promise对象。promise方式返回是否禁止修改系统时间策略。true表示禁止修改系统时间,否则表示允许修改系统时间。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
dateTimeManager.disallowModifyDateTime(wantTemp).then(() => {
}).catch((error) => {
console.log("error code:" + error.code + " error message:" + error.message);
})
```
\ No newline at end of file
...@@ -102,3 +102,247 @@ wifiManager.isWifiActive(wantTemp).then((result) => { ...@@ -102,3 +102,247 @@ wifiManager.isWifiActive(wantTemp).then((result) => {
console.log("error code:" + error.code + " error message:" + error.message); console.log("error code:" + error.code + " error message:" + error.message);
}); });
``` ```
## wifiManager.setWifiProfile
setWifiProfile(admin: Want, profile: WifiProfile, callback: AsyncCallback&lt;void&gt;): void
配置wifi连接到指定网络,使用callback异步回调。
**需要权限:** ohos.permission.ENTERPRISE_SET_WIFI
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 |
| profile | [WifiProfile](#wifiprofile) | 是 | WLAN配置信息 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let profile : WifiProfile = {
"ssid": "name",
"preSharedKey": "passwd",
"securityType": wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK
};
wifiManager.setWifiProfile(wantTemp, profile, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
return;
}
console.log("set wifi success");
});
```
## wifiManager.setWifiProfile
setWifiProfile(admin: Want, profile: WifiProfile): Promise&lt;void&gt;
配置wifi连接到指定网络,使用promise异步回调。
**需要权限:** ohos.permission.ENTERPRISE_SET_WIFI
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 |
| profile | [WifiProfile](#wifiprofile) | 是 | WLAN配置信息 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let profile : WifiProfile = {
"ssid": "name",
"preSharedKey": "passwd",
"securityType": wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK
};
wifiManager.isWifiActive(wantTemp, profile).then(() => {
console.log("set wifi success");
}).catch(error => {
console.log("error code:" + error.code + " error message:" + error.message);
});
```
## WifiProfile
WLAN配置信息
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | --------| ---- | ----- | ------------------------------- |
| ssid | string | 是 | 否 | 热点的SSID,编码格式为UTF-8。 |
| bssid | string | 是 | 否 | 热点的BSSID。 |
| preSharedKey | string | 是 | 否 | 热点的密钥。 |
| isHiddenSsid | boolean | 是 | 否 | 是否是隐藏网络。 |
| securityType | [WifiSecurityType](#wifisecuritytype) | 是 | 否 | 加密类型。 |
| creatorUid | number | 是 | 否 | 创建用户的ID。 |
| disableReason | number | 是 | 否 | 禁用原因。 |
| netId | number | 是 | 否 | 分配的网络ID。 |
| randomMacType | number | 是 | 否 | 随机MAC类型 |
| randomMacAddr | string | 是 | 否 | 随机MAC地址 |
| ipType | [IpType](#iptype) | 是 | 否 | IP地址类型 |
| staticIp | [IpProfile](#ipprofile) | 是 | 否 | 静态IP配置信息。 |
| eapProfile | [WifiEapProfile](#wifieapprofile) | 是 | 否 | 可扩展身份验证协议配置。 |
## WifiSecurityType
表示加密类型的枚举。
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| WIFI_SEC_TYPE_INVALID | 0 | 无效加密类型。 |
| WIFI_SEC_TYPE_OPEN | 1 | 开放加密类型。 |
| WIFI_SEC_TYPE_WEP | 2 | Wired&nbsp;Equivalent&nbsp;Privacy&nbsp;(WEP)加密类型。 |
| WIFI_SEC_TYPE_PSK | 3 | Pre-shared&nbsp;key&nbsp;(PSK)加密类型。 |
| WIFI_SEC_TYPE_SAE | 4 | Simultaneous&nbsp;Authentication&nbsp;of&nbsp;Equals&nbsp;(SAE)加密类型。 |
| WIFI_SEC_TYPE_EAP | 5 | EAP加密类型。 |
| WIFI_SEC_TYPE_EAP_SUITE_B | 6 | Suite-B 192位加密类型。 |
| WIFI_SEC_TYPE_OWE | 7 | 机会性无线加密类型。 |
| WIFI_SEC_TYPE_WAPI_CERT | 8 | WAPI-Cert加密类型。 |
| WIFI_SEC_TYPE_WAPI_PSK | 9 | WAPI-PSK加密类型。 |
## IpType
表示IP类型的枚举。
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| STATIC | 0 | 静态IP。 |
| DHCP | 1 | 通过DHCP获取。 |
| UNKNOWN | 2 | 未指定。 |
## IpProfile
IP配置信息。
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| ipAddress | number | 是 | 否 | IP地址。 |
| gateway | number | 是 | 否 | 网关。 |
| prefixLength | number | 是 | 否 | 掩码。 |
| dnsServers | number[] | 是 | 否 | DNS服务器。 |
| domains | Array&lt;string&gt; | 是 | 否 | 域信息。 |
## WifiEapProfile
可扩展身份验证协议配置信息。
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
| **名称** | **类型** | **可读** | **可写** | **说明** |
| -------- | -------- | -------- | -------- | -------- |
| eapMethod | [EapMethod](#eapmethod) | 是 | 否 | EAP认证方式。 |
| phase2Method | [Phase2Method](#phase2method) | 是 | 否 | 第二阶段认证方式。 |
| identity | string | 是 | 否 | 身份信息。 |
| anonymousIdentity | string | 是 | 否 | 匿名身份。 |
| password | string | 是 | 否 | 密码。 |
| caCertAliases | string | 是 | 否 | CA 证书别名。 |
| caPath | string | 是 | 否 | CA 证书路径。 |
| clientCertAliases | string | 是 | 否 | 客户端证书别名。 |
| certEntry | Uint8Array | 是 | 是 | CA 证书内容。 |
| certPassword | string | 是 | 是 | CA证书密码。 |
| altSubjectMatch | string | 是 | 否 | 替代主题匹配。 |
| domainSuffixMatch | string | 是 | 否 | 域后缀匹配。 |
| realm | string | 是 | 否 | 通行证凭证的领域。 |
| plmn | string | 是 | 否 | 公共陆地移动网的直通凭证提供商。 |
| eapSubId | number | 是 | 否 | SIM卡的子ID。 |
## EapMethod
表示EAP认证方式的枚举。
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| EAP_NONE | 0 | 不指定。 |
| EAP_PEAP | 1 | PEAP类型。 |
| EAP_TLS | 2 | TLS类型。 |
| EAP_TTLS | 3 | TTLS类型。 |
| EAP_PWD | 4 | PWD类型。 |
| EAP_SIM | 5 | SIM类型。 |
| EAP_AKA | 6 | AKA类型。 |
| EAP_AKA_PRIME | 7 | AKA Prime类型。 |
| EAP_UNAUTH_TLS | 8 | UNAUTH TLS类型。 |
## Phase2Method
表示第二阶段认证方式的枚举。
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| PHASE2_NONE | 0 | 不指定。 |
| PHASE2_PAP | 1 | PAP类型。 |
| PHASE2_MSCHAP | 2 | MSCHAP类型。 |
| PHASE2_MSCHAPV2 | 3 | MSCHAPV2类型。 |
| PHASE2_GTC | 4 | GTC类型。 |
| PHASE2_SIM | 5 | SIM类型。 |
| PHASE2_AKA | 6 | AKA类型。 |
| PHASE2_AKA_PRIME | 7 | AKA Prime类型。 |
...@@ -121,7 +121,7 @@ try { ...@@ -121,7 +121,7 @@ try {
generateKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void> generateKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void>
生成密钥,使用Promise方式异步返回结果,基于密钥不出TEE原则,通过promise不会返回密钥材料内容,只用于表示此次调用是否成功。 生成密钥,使用Promise方式异步返回结果基于密钥不出TEE原则,通过promise不会返回密钥材料内容,只用于表示此次调用是否成功。
**系统能力**:SystemCapability.Security.Huks **系统能力**:SystemCapability.Security.Huks
...@@ -1084,7 +1084,7 @@ isKeyItemExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback\< ...@@ -1084,7 +1084,7 @@ isKeyItemExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<
| -------- | --------------------------- | ---- | --------------------------------------- | | -------- | --------------------------- | ---- | --------------------------------------- |
| keyAlias | string | 是 | 所需查找的密钥的别名。 | | keyAlias | string | 是 | 所需查找的密钥的别名。 |
| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | | options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 |
| callback | AsyncCallback\<boolean> | 是 | 回调函数。若密钥存在,data为true,若密钥不存在,则error中会输出不存在的error code | | callback | AsyncCallback\<boolean> | 是 | 回调函数。若密钥存在,data为true,若密钥不存在,则error中会输出密钥不存在的error code。 |
**示例:** **示例:**
...@@ -1128,7 +1128,7 @@ isKeyItemExist(keyAlias: string, options: HuksOptions) : Promise\<boolean> ...@@ -1128,7 +1128,7 @@ isKeyItemExist(keyAlias: string, options: HuksOptions) : Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | --------------------------------------- | | ----------------- | --------------------------------------- |
| Promise\<boolean> | Promise对象。密钥存在时,可通过then 进行密钥存在后的相关处理,若不存在,可通过error 处理密钥不存在后的相关业务操作 | | Promise\<boolean> | Promise对象。密钥存在时,可通过then进行密钥存在后的相关处理,若不存在,可通过error处理密钥不存在后的相关业务操作。 |
**示例:** **示例:**
...@@ -1920,16 +1920,16 @@ async function huksAbort() { ...@@ -1920,16 +1920,16 @@ async function huksAbort() {
| HUKS_TAG_DERIVE_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 24 | 表示派生密钥的大小。 | | HUKS_TAG_DERIVE_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 24 | 表示派生密钥的大小。 |
| HUKS_TAG_IMPORT_KEY_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 25 | 表示导入的密钥类型。 | | HUKS_TAG_IMPORT_KEY_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 25 | 表示导入的密钥类型。 |
| HUKS_TAG_UNWRAP_ALGORITHM_SUITE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 26 | 表示导入加密密钥的套件。 | | HUKS_TAG_UNWRAP_ALGORITHM_SUITE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 26 | 表示导入加密密钥的套件。 |
| HUKS_TAG_ACTIVE_DATETIME<sup>deprecated</sup> | HuksTagType.HUKS_TAG_TYPE_ULONG \| 201 | 原为证书业务预留字段,当前证书管理已独立,此字段废弃,不再预留。 | | HUKS_TAG_ACTIVE_DATETIME<sup>(deprecated)</sup> | HuksTagType.HUKS_TAG_TYPE_ULONG \| 201 | 原为证书业务预留字段,当前证书管理已独立,此字段废弃,不再预留。 |
| HUKS_TAG_ORIGINATION_EXPIRE_DATETIME<sup>deprecated</sup> | HuksTagType.HUKS_TAG_TYPE_ULONG \| 202 | 原为证书业务预留字段,当前证书管理已独立,此字段废弃,不再预留。 | | HUKS_TAG_ORIGINATION_EXPIRE_DATETIME<sup>(deprecated)</sup> | HuksTagType.HUKS_TAG_TYPE_ULONG \| 202 | 原为证书业务预留字段,当前证书管理已独立,此字段废弃,不再预留。 |
| HUKS_TAG_USAGE_EXPIRE_DATETIME<sup>deprecated</sup> | HuksTagType.HUKS_TAG_TYPE_ULONG \| 203 | 原为证书业务预留字段,当前证书管理已独立,此字段废弃,不再预留。 | | HUKS_TAG_USAGE_EXPIRE_DATETIME<sup>(deprecated)</sup> | HuksTagType.HUKS_TAG_TYPE_ULONG \| 203 | 原为证书业务预留字段,当前证书管理已独立,此字段废弃,不再预留。 |
| HUKS_TAG_CREATION_DATETIME<sup>deprecated</sup> | HuksTagType.HUKS_TAG_TYPE_ULONG \| 204 | 原为证书业务预留字段,当前证书管理已独立,此字段废弃,不再预留。 | | HUKS_TAG_CREATION_DATETIME<sup>(deprecated)</sup> | HuksTagType.HUKS_TAG_TYPE_ULONG \| 204 | 原为证书业务预留字段,当前证书管理已独立,此字段废弃,不再预留。 |
| HUKS_TAG_ALL_USERS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 301 | 预留 | | HUKS_TAG_ALL_USERS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 301 | 预留 |
| HUKS_TAG_USER_ID | HuksTagType.HUKS_TAG_TYPE_UINT \| 302 | 表示当前密钥属于哪个userID | | HUKS_TAG_USER_ID | HuksTagType.HUKS_TAG_TYPE_UINT \| 302 | 表示当前密钥属于哪个userID |
| HUKS_TAG_NO_AUTH_REQUIRED | HuksTagType.HUKS_TAG_TYPE_BOOL \| 303 | 预留。 | | HUKS_TAG_NO_AUTH_REQUIRED | HuksTagType.HUKS_TAG_TYPE_BOOL \| 303 | 预留。 |
| HUKS_TAG_USER_AUTH_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 304 | 表示用户认证类型。从[HuksUserAuthType](#huksuserauthtype9)中选择,需要与安全访问控制类型同时设置。支持同时指定两种用户认证类型,如:安全访问控制类型指定为HKS_SECURE_ACCESS_INVALID_NEW_BIO_ENROLL时,密钥访问认证类型可以指定以下三种: HKS_USER_AUTH_TYPE_FACE 、HKS_USER_AUTH_TYPE_FINGERPRINT、HKS_USER_AUTH_TYPE_FACE \| HKS_USER_AUTH_TYPE_FINGERPRINT | | HUKS_TAG_USER_AUTH_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 304 | 表示用户认证类型。从[HuksUserAuthType](#huksuserauthtype9)中选择,需要与安全访问控制类型同时设置。支持同时指定两种用户认证类型,如:安全访问控制类型指定为HKS_SECURE_ACCESS_INVALID_NEW_BIO_ENROLL时,密钥访问认证类型可以指定以下三种: HKS_USER_AUTH_TYPE_FACE 、HKS_USER_AUTH_TYPE_FINGERPRINT、HKS_USER_AUTH_TYPE_FACE \| HKS_USER_AUTH_TYPE_FINGERPRINT |
| HUKS_TAG_AUTH_TIMEOUT | HuksTagType.HUKS_TAG_TYPE_UINT \| 305 | 表示authtoken 单次有效期。 | | HUKS_TAG_AUTH_TIMEOUT | HuksTagType.HUKS_TAG_TYPE_UINT \| 305 | 表示authtoken单次有效期。 |
| HUKS_TAG_AUTH_TOKEN | HuksTagType.HUKS_TAG_TYPE_BYTES \| 306 | 用于传入authToken 的字段 | | HUKS_TAG_AUTH_TOKEN | HuksTagType.HUKS_TAG_TYPE_BYTES \| 306 | 用于传入authToken的字段 |
| HUKS_TAG_KEY_AUTH_ACCESS_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 307 | 表示安全访问控制类型。从[HuksAuthAccessType](#huksauthaccesstype9)中选择,需要和用户认证类型同时设置。 | | HUKS_TAG_KEY_AUTH_ACCESS_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 307 | 表示安全访问控制类型。从[HuksAuthAccessType](#huksauthaccesstype9)中选择,需要和用户认证类型同时设置。 |
| HUKS_TAG_KEY_SECURE_SIGN_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 308 | 表示生成或导入密钥时,指定该密钥的签名类型。 | | HUKS_TAG_KEY_SECURE_SIGN_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 308 | 表示生成或导入密钥时,指定该密钥的签名类型。 |
| HUKS_TAG_CHALLENGE_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 309 | 表示密钥使用时生成的challenge类型。从[HuksChallengeType](#hukschallengetype9)中选择 | | HUKS_TAG_CHALLENGE_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 309 | 表示密钥使用时生成的challenge类型。从[HuksChallengeType](#hukschallengetype9)中选择 |
...@@ -1968,7 +1968,7 @@ async function huksAbort() { ...@@ -1968,7 +1968,7 @@ async function huksAbort() {
| HUKS_TAG_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10006 | 预留。 | | HUKS_TAG_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10006 | 预留。 |
| HUKS_TAG_KEY_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10007 | 表示密钥版本的Tag。 | | HUKS_TAG_KEY_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10007 | 表示密钥版本的Tag。 |
| HUKS_TAG_PAYLOAD_LEN | HuksTagType.HUKS_TAG_TYPE_UINT \| 10008 | 预留。 | | HUKS_TAG_PAYLOAD_LEN | HuksTagType.HUKS_TAG_TYPE_UINT \| 10008 | 预留。 |
| HUKS_TAG_AE_TAG | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10009 | 用于传入GCM模式中的AEAD 数据的字段。 | | HUKS_TAG_AE_TAG | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10009 | 用于传入GCM模式中的AEAD数据的字段。 |
| HUKS_TAG_IS_KEY_HANDLE | HuksTagType.HUKS_TAG_TYPE_ULONG \| 10010 | 预留。 | | HUKS_TAG_IS_KEY_HANDLE | HuksTagType.HUKS_TAG_TYPE_ULONG \| 10010 | 预留。 |
| HUKS_TAG_OS_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10101 | 表示操作系统版本的Tag。 | | HUKS_TAG_OS_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10101 | 表示操作系统版本的Tag。 |
| HUKS_TAG_OS_PATCHLEVEL | HuksTagType.HUKS_TAG_TYPE_UINT \| 10102 | 表示操作系统补丁级别的Tag。 | | HUKS_TAG_OS_PATCHLEVEL | HuksTagType.HUKS_TAG_TYPE_UINT \| 10102 | 表示操作系统补丁级别的Tag。 |
......
...@@ -1138,7 +1138,7 @@ setBitrate(bitrate: number): void ...@@ -1138,7 +1138,7 @@ setBitrate(bitrate: number): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------------------------------------------------------ | | ------- | ------ | ---- | ------------------------------------------------------------ |
| bitrate | number | 是 | 指定比特率,可以通过[availableBitrates](#availableBitrates_on)事件获得当前HLS协议流可用的比特率,如果用户指定的比特率不在此列表中,则播放器将从可用比特率列表中选择最小和最接近的比特率。 | | bitrate | number | 是 | 指定比特率,可以通过[availableBitrates](#availableBitrates_on)事件获得当前HLS协议流可用的比特率,如果用户指定的比特率不在此列表中,则播放器将从可用比特率列表中选择最小和最接近的比特率。如果通过availableBitrates时间获得的比特率列表长度为0,则不支持指定比特率,也不会产生bitrateDone回调。 |
**示例:** **示例:**
...@@ -1203,7 +1203,7 @@ on(type: 'availableBitrates', callback: (bitrates: Array\<number>) => void): voi ...@@ -1203,7 +1203,7 @@ on(type: 'availableBitrates', callback: (bitrates: Array\<number>) => void): voi
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | ---- | ------------------------------------------------------------ | | -------- | -------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | HLS协议可用比特率上报事件回调类型,支持的事件:'availableBitrates',只会在prepared之后上报一次。 | | type | string | 是 | HLS协议可用比特率上报事件回调类型,支持的事件:'availableBitrates',只会在prepared之后上报一次。 |
| callback | function | 是 | HLS协议可用比特率上报事件回调方法,使用数组存放支持的比特率。 | | callback | function | 是 | HLS协议可用比特率上报事件回调方法,使用数组存放支持的比特率。如果数组长度为0,则不支持指定比特率。 |
**示例:** **示例:**
...@@ -1762,7 +1762,7 @@ let AVRecorderProfile = { ...@@ -1762,7 +1762,7 @@ let AVRecorderProfile = {
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : media.CodecMimeType.VIDEO_MPEG4, videoCodec : media.CodecMimeType.VIDEO_AVC,
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
...@@ -1833,7 +1833,7 @@ let AVRecorderProfile = { ...@@ -1833,7 +1833,7 @@ let AVRecorderProfile = {
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : media.CodecMimeType.VIDEO_MPEG4, videoCodec : media.CodecMimeType.VIDEO_AVC,
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
...@@ -2535,7 +2535,7 @@ avRecorder.off('error'); ...@@ -2535,7 +2535,7 @@ avRecorder.off('error');
| audioSampleRate | number | 否 | 音频采样率,选择音频录制时必填。 | | audioSampleRate | number | 否 | 音频采样率,选择音频录制时必填。 |
| fileFormat | [ContainerFormatType](#containerformattype8) | 是 | 文件的容器格式,必要参数。 | | fileFormat | [ContainerFormatType](#containerformattype8) | 是 | 文件的容器格式,必要参数。 |
| videoBitrate | number | 否 | 视频编码比特率,选择视频录制时必填。 | | videoBitrate | number | 否 | 视频编码比特率,选择视频录制时必填。 |
| videoCodec | [CodecMimeType](#codecmimetype8) | 否 | 视频编码格式,选择视频录制时必填。当前仅支持VIDEO_AVC和VIDEO_MPEG4。 | | videoCodec | [CodecMimeType](#codecmimetype8) | 否 | 视频编码格式,选择视频录制时必填。需要查询设备支持的编码能力(包括编码格式,分辨率大小等)。 |
| videoFrameWidth | number | 否 | 视频帧的宽,选择视频录制时必填。 | | videoFrameWidth | number | 否 | 视频帧的宽,选择视频录制时必填。 |
| videoFrameHeight | number | 否 | 视频帧的高,选择视频录制时必填。 | | videoFrameHeight | number | 否 | 视频帧的高,选择视频录制时必填。 |
| videoFrameRate | number | 否 | 视频帧率,选择视频录制时必填。 | | videoFrameRate | number | 否 | 视频帧率,选择视频录制时必填。 |
...@@ -2644,7 +2644,7 @@ let videoProfile = { ...@@ -2644,7 +2644,7 @@ let videoProfile = {
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : 'mp4', fileFormat : 'mp4',
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : 'video/mp4v-es', videoCodec : 'video/avc',
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
...@@ -2715,7 +2715,7 @@ let videoProfile = { ...@@ -2715,7 +2715,7 @@ let videoProfile = {
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : 'mp4', fileFormat : 'mp4',
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : 'video/mp4v-es', videoCodec : 'video/avc',
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
......
...@@ -399,7 +399,7 @@ discoveryService.stopSearchingMDNS(); ...@@ -399,7 +399,7 @@ discoveryService.stopSearchingMDNS();
### on('discoveryStart') ### on('discoveryStart')
on(type: 'discoveryStart', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MDNS_ERR}>): void on(type: 'discoveryStart', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MdnsError}>): void
订阅开启监听mDNS服务的通知。 订阅开启监听mDNS服务的通知。
...@@ -410,7 +410,7 @@ on(type: 'discoveryStart', callback: Callback<{serviceInfo: LocalServiceInfo, er ...@@ -410,7 +410,7 @@ on(type: 'discoveryStart', callback: Callback<{serviceInfo: LocalServiceInfo, er
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
|-------------|--------------|-----------|-----------------------------------------------------| |-------------|--------------|-----------|-----------------------------------------------------|
| type | string | 是 |订阅事件,固定为'discoveryStart'。<br>discoveryStart:开始搜索局域网内的mDNS服务事件。 | | type | string | 是 |订阅事件,固定为'discoveryStart'。<br>discoveryStart:开始搜索局域网内的mDNS服务事件。 |
| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MDNS_ERR](#mdns_err)}> | 是 | mDNS服务的信息和事件错误信息。 | | callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MdnsError](#mdnserror)}> | 是 | mDNS服务的信息和事件错误信息。 |
**示例:** **示例:**
...@@ -428,7 +428,7 @@ discoveryService.stopSearchingMDNS(); ...@@ -428,7 +428,7 @@ discoveryService.stopSearchingMDNS();
### on('discoveryStop') ### on('discoveryStop')
on(type: 'discoveryStop', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MDNS_ERR}>): void on(type: 'discoveryStop', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MdnsError}>): void
订阅停止监听mDNS服务的通知。 订阅停止监听mDNS服务的通知。
...@@ -439,7 +439,7 @@ on(type: 'discoveryStop', callback: Callback<{serviceInfo: LocalServiceInfo, err ...@@ -439,7 +439,7 @@ on(type: 'discoveryStop', callback: Callback<{serviceInfo: LocalServiceInfo, err
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
|-------------|--------------|-----------|-----------------------------------------------------| |-------------|--------------|-----------|-----------------------------------------------------|
| type | string | 是 |订阅事件,固定为'discoveryStop'。<br>discoveryStop:停止搜索局域网内的mDNS服务事件。 | | type | string | 是 |订阅事件,固定为'discoveryStop'。<br>discoveryStop:停止搜索局域网内的mDNS服务事件。 |
| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MDNS_ERR](#mdns_err)}> | 是 | mDNS服务的信息和事件错误信息。 | | callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MdnsError](#mdnserror)}> | 是 | mDNS服务的信息和事件错误信息。 |
**示例:** **示例:**
...@@ -538,7 +538,7 @@ mDNS服务属性信息 ...@@ -538,7 +538,7 @@ mDNS服务属性信息
| key | string | 是 | mDNS服务属性键值,键值长度应该小于9个字符。 | | key | string | 是 | mDNS服务属性键值,键值长度应该小于9个字符。 |
| value | Array\<number> | 是 | mDNS服务属性值。 | | value | Array\<number> | 是 | mDNS服务属性值。 |
## MDNS_ERR ## MdnsError
mDNS错误信息。 mDNS错误信息。
......
...@@ -376,11 +376,11 @@ let record = pasteboard.createUriRecord('dataability:///com.example.myapplicatio ...@@ -376,11 +376,11 @@ let record = pasteboard.createUriRecord('dataability:///com.example.myapplicatio
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- |--------------------------------------------------------------------------------------------| | -------- | -------- | -------- | -------- |--------------------------------------------------------------------------------------------|
| additions<sup>7+</sup> | {[key:string]:object} | 是 | 是 | 设置的其他附加属性数据, 暂不支持。 | | additions<sup>7+</sup> | {[key:string]:object} | 是 | 是 | 设置其他附加属性数据。 |
| mimeTypes<sup>7+</sup> | Array&lt;string&gt; | 是 | 否 | 剪贴板内容条目的数据类型,非重复的类型列表。 | | mimeTypes<sup>7+</sup> | Array&lt;string&gt; | 是 | 否 | 剪贴板内容条目的数据类型,非重复的类型列表。 |
| tag<sup>7+</sup> | string | 是 | 是 | 用户自定义标签, 暂不支持。 | | tag<sup>7+</sup> | string | 是 | 是 | 用户自定义标签。 |
| timestamp<sup>7+</sup> | number | 是 | 否 | 剪贴板数据的写入时间戳(单位:ms)。 | | timestamp<sup>7+</sup> | number | 是 | 否 | 剪贴板数据的写入时间戳(单位:ms)。 |
| localOnly<sup>7+</sup> | boolean | 是 | 是 | 配置剪贴板内容是否为“仅在本地”, 默认值为true。暂不支持, 推荐使用shareOption属性。<br/>- 配置为true时,表示内容仅在本地,不会在设备之间传递。<br/>- 配置为false时,表示内容将在设备间传递。 | | localOnly<sup>7+</sup> | boolean | 是 | 是 | 配置剪贴板内容是否为“仅在本地”,默认值为false。暂不支持,推荐使用shareOption属性。<br/>- 配置为true时,表示内容仅在本地,不会在设备之间传递。<br/>- 配置为false时,表示内容将在设备间传递。 |
| shareOption<sup>9+</sup> | [ShareOption](#shareoption9) | 是 | 是 | 指示剪贴板数据可以粘贴到的范围,如果未设置或设置不正确,则默认值为CROSSDEVICE。 | | shareOption<sup>9+</sup> | [ShareOption](#shareoption9) | 是 | 是 | 指示剪贴板数据可以粘贴到的范围,如果未设置或设置不正确,则默认值为CROSSDEVICE。 |
## PasteDataRecord<sup>7+</sup> ## PasteDataRecord<sup>7+</sup>
......
...@@ -1543,7 +1543,7 @@ closeRawFd(path: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -1543,7 +1543,7 @@ closeRawFd(path: string, callback: AsyncCallback&lt;void&gt;): void
``` ```
### closeRawFd<sup>8+</sup> ### closeRawFd<sup>9+</sup>
closeRawFd(path: string): Promise&lt;void&gt; closeRawFd(path: string): Promise&lt;void&gt;
......
...@@ -25,7 +25,7 @@ zipFile(inFile: string, outFile: string, options: Options): Promise&lt;void&gt; ...@@ -25,7 +25,7 @@ zipFile(inFile: string, outFile: string, options: Options): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-application-context.md)。 | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-inner-application-context.md)。 |
| outFile | string | 是 | 指定压缩结果的文件路径(文件的扩展名zip)。 | | outFile | string | 是 | 指定压缩结果的文件路径(文件的扩展名zip)。 |
| options | [Options](#options) | 是 | 压缩的可选参数。 | | options | [Options](#options) | 是 | 压缩的可选参数。 |
...@@ -50,9 +50,9 @@ let options = { ...@@ -50,9 +50,9 @@ let options = {
}; };
zlib.zipFile(inFile, outFile, options).then((data) => { zlib.zipFile(inFile, outFile, options).then((data) => {
console.log('zipFile result is ' + JSON.Stringify(data)); console.log('zipFile result is ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log('error is ' + JSON.Stringify(err)); console.log('error is ' + JSON.stringify(err));
}); });
``` ```
...@@ -71,9 +71,9 @@ let options = { ...@@ -71,9 +71,9 @@ let options = {
}; };
zlib.zipFile(inFile , outFile, options).then((data) => { zlib.zipFile(inFile , outFile, options).then((data) => {
console.log('zipFile result is ' + JSON.Stringify(data)); console.log('zipFile result is ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.log('error is ' + JSON.Stringify(err)); console.log('error is ' + JSON.stringify(err));
}); });
``` ```
...@@ -91,7 +91,7 @@ unzipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt; ...@@ -91,7 +91,7 @@ unzipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定的待解压缩文件的文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-application-context.md)。 | | inFile | string | 是 | 指定的待解压缩文件的文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-inner-application-context.md)。 |
| outFile | string | 是 | 指定的解压文件路径。 | | outFile | string | 是 | 指定的解压文件路径。 |
| options | [Options](#options) | 是 | 解压的可选参数。 | | options | [Options](#options) | 是 | 解压的可选参数。 |
...@@ -116,9 +116,9 @@ let options = { ...@@ -116,9 +116,9 @@ let options = {
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
}; };
zlib.unzipFile(inFile, outFile, options).then((data) => { zlib.unzipFile(inFile, outFile, options).then((data) => {
console.log('unzipFile result is ' + JSON.Stringify(data)); console.log('unzipFile result is ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.log('error is ' + JSON.Stringify(err)); console.log('error is ' + JSON.stringify(err));
}) })
``` ```
...@@ -134,7 +134,7 @@ compressFile(inFile: string, outFile: string, options: Options, callback: AsyncC ...@@ -134,7 +134,7 @@ compressFile(inFile: string, outFile: string, options: Options, callback: AsyncC
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-application-context.md)。 | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-inner-application-context.md)。 |
| outFile | string | 是 | 指定的解压文件路径。 | | outFile | string | 是 | 指定的解压文件路径。 |
| options | [Options](#options) | 是 | 压缩的配置参数。 | | options | [Options](#options) | 是 | 压缩的配置参数。 |
| AsyncCallback<**void**> | callback | 否 | 压缩时的回调函数。 | | AsyncCallback<**void**> | callback | 否 | 压缩时的回调函数。 |
...@@ -182,7 +182,7 @@ compressFile(inFile: string, outFile: string, options: Options): Promise\<void>; ...@@ -182,7 +182,7 @@ compressFile(inFile: string, outFile: string, options: Options): Promise\<void>;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-application-context.md)。 | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-inner-application-context.md)。 |
| outFile | string | 是 | 指定的解压文件路径。 | | outFile | string | 是 | 指定的解压文件路径。 |
| options | [Options](#options) | 是 | 压缩的配置参数。 | | options | [Options](#options) | 是 | 压缩的配置参数。 |
...@@ -232,7 +232,7 @@ decompressFile(inFile: string, outFile: string, options: Options, callback: Asyn ...@@ -232,7 +232,7 @@ decompressFile(inFile: string, outFile: string, options: Options, callback: Asyn
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定的待解压缩文件的文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-application-context.md)。 | | inFile | string | 是 | 指定的待解压缩文件的文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-inner-application-context.md)。 |
| outFile | string | 是 | 指定的解压后的目录路径。 | | outFile | string | 是 | 指定的解压后的目录路径。 |
| options | [Options](#options) | 是 | 解压的配置参数。 | | options | [Options](#options) | 是 | 解压的配置参数。 |
| AsyncCallback<**void**> | callback | 否 | 解压是的回调函数。 | | AsyncCallback<**void**> | callback | 否 | 解压是的回调函数。 |
...@@ -281,7 +281,7 @@ decompressFile(inFile: string, outFile: string, options: Options): Promise\<void ...@@ -281,7 +281,7 @@ decompressFile(inFile: string, outFile: string, options: Options): Promise\<void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定的待解压缩文件的文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-application-context.md)。 | | inFile | string | 是 | 指定的待解压缩文件的文件路径,路径必须为沙箱路径,沙箱路径可以通过context获取,可参考[FA模型](js-apis-inner-app-context.md)[Stage模型](js-apis-inner-application-context.md)。 |
| outFile | string | 是 | 指定的解压后的目录路径。 | | outFile | string | 是 | 指定的解压后的目录路径。 |
| options | [Options](#options) | 是 | 解压时的配置参数。 | | options | [Options](#options) | 是 | 解压时的配置参数。 |
......
...@@ -89,7 +89,13 @@ struct ButtonExample { ...@@ -89,7 +89,13 @@ struct ButtonExample {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Text('Normal button').fontSize(9).fontColor(0xCCCCCC) Text('Normal button').fontSize(9).fontColor(0xCCCCCC)
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Button('OK', { type: ButtonType.Normal, stateEffect: true }).borderRadius(8).backgroundColor(0x317aff).width(90) Button('OK', { type: ButtonType.Normal, stateEffect: true })
.borderRadius(8)
.backgroundColor(0x317aff)
.width(90)
.onClick(() => {
console.log('ButtonType.Normal')
})
Button({ type: ButtonType.Normal, stateEffect: true }) { Button({ type: ButtonType.Normal, stateEffect: true }) {
Row() { Row() {
LoadingProgress().width(20).height(20).margin({ left: 12 }).color(0xFFFFFF) LoadingProgress().width(20).height(20).margin({ left: 12 }).color(0xFFFFFF)
......
...@@ -195,7 +195,7 @@ struct NavigationExample { ...@@ -195,7 +195,7 @@ struct NavigationExample {
.width(336) .width(336)
.height(40) .height(40)
.backgroundColor('#FFFFFF') .backgroundColor('#FFFFFF')
.margin({ top: 8, left: 12 }) .margin({ top: 8 })
List({ space: 12, initialIndex: 0 }) { List({ space: 12, initialIndex: 0 }) {
ForEach(this.arr, (item) => { ForEach(this.arr, (item) => {
...@@ -212,8 +212,8 @@ struct NavigationExample { ...@@ -212,8 +212,8 @@ struct NavigationExample {
}, item => item) }, item => item)
} }
.height(324) .height(324)
.width('100%') .width(336)
.margin({ top: 12, left: 12 }) .margin({ top: 12 })
} }
.title(this.NavigationTitle) .title(this.NavigationTitle)
.menus(this.NavigationMenus) .menus(this.NavigationMenus)
......
...@@ -77,7 +77,7 @@ struct FillStyleExample { ...@@ -77,7 +77,7 @@ struct FillStyleExample {
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.fillStyle = '#0000ff' this.context.fillStyle = '#0000ff'
this.context.fillRect(20, 160, 150, 100) this.context.fillRect(20, 20, 150, 100)
}) })
} }
.width('100%') .width('100%')
...@@ -1653,35 +1653,35 @@ clip(path: Path2D, fillRule?: CanvasFillRule): void ...@@ -1653,35 +1653,35 @@ clip(path: Path2D, fillRule?: CanvasFillRule): void
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct Clip { struct Clip {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
let region = new Path2D() let region = new Path2D()
region.moveTo(30, 90) region.moveTo(30, 90)
region.lineTo(110, 20) region.lineTo(110, 20)
region.lineTo(240, 130) region.lineTo(240, 130)
region.lineTo(60, 130) region.lineTo(60, 130)
region.lineTo(190, 20) region.lineTo(190, 20)
region.lineTo(270, 90) region.lineTo(270, 90)
region.closePath() region.closePath()
this.context.clip(region,"evenodd") this.context.clip(region,"evenodd")
this.context.fillStyle = "rgb(0,255,0)" this.context.fillStyle = "rgb(0,255,0)"
this.context.fillRect(0, 0, this.context.width, this.context.height) this.context.fillRect(0, 0, this.context.width, this.context.height)
}) })
}
.width('100%')
.height('100%')
} }
.width('100%')
.height('100%')
} }
}
``` ```
![zh-cn_image_000000127777779](figures/zh-cn_image_000000127777779.png) ![zh-cn_image_000000127777779](figures/zh-cn_image_000000127777779.png)
...@@ -2104,29 +2104,29 @@ getImageData(sx: number, sy: number, sw: number, sh: number): ImageData ...@@ -2104,29 +2104,29 @@ getImageData(sx: number, sy: number, sw: number, sh: number): ImageData
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct GetImageData { struct GetImageData {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private img:ImageBitmap = new ImageBitmap("/common/images/1234.png") private img:ImageBitmap = new ImageBitmap("/common/images/1234.png")
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.drawImage(this.img,0,0,130,130) this.context.drawImage(this.img,0,0,130,130)
var imagedata = this.context.getImageData(50,50,130,130) var imagedata = this.context.getImageData(50,50,130,130)
this.context.putImageData(imagedata,150,150) this.context.putImageData(imagedata,150,150)
}) })
}
.width('100%')
.height('100%')
} }
.width('100%')
.height('100%')
} }
}
``` ```
![zh-cn_image_000000127777780](figures/zh-cn_image_000000127777780.png) ![zh-cn_image_000000127777780](figures/zh-cn_image_000000127777780.png)
...@@ -2248,40 +2248,40 @@ getLineDash(): number[] ...@@ -2248,40 +2248,40 @@ getLineDash(): number[]
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct CanvasGetLineDash { struct CanvasGetLineDash {
@State message: string = 'Hello World' @State message: string = 'Hello World'
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
build() { build() {
Row() { Row() {
Column() { Column() {
Text(this.message) Text(this.message)
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
.onClick(()=>{ .onClick(()=>{
console.error('before getlinedash clicked') console.error('before getlinedash clicked')
let res = this.context.getLineDash() let res = this.context.getLineDash()
console.error(JSON.stringify(res)) console.error(JSON.stringify(res))
}) })
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() => { .onReady(() => {
this.context.arc(100, 75, 50, 0, 6.28) this.context.arc(100, 75, 50, 0, 6.28)
this.context.setLineDash([10,20]) this.context.setLineDash([10,20])
this.context.stroke() this.context.stroke()
let res = this.context.getLineDash() let res = this.context.getLineDash()
}) })
}
.width('100%')
} }
.width('100%') .height('100%')
} }
.height('100%')
} }
}
``` ```
![zh-cn_image_000000127777778](figures/zh-cn_image_000000127777778.png) ![zh-cn_image_000000127777778](figures/zh-cn_image_000000127777778.png)
...@@ -2376,26 +2376,26 @@ toDataURL(type?: string, quality?: number): string ...@@ -2376,26 +2376,26 @@ toDataURL(type?: string, quality?: number): string
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct ToDataURL { struct ToDataURL {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var dataURL = this.context.toDataURL() var dataURL = this.context.toDataURL()
}) })
}
.width('100%')
.height('100%')
} }
.width('100%')
.height('100%')
} }
}
``` ```
...@@ -2512,7 +2512,7 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void ...@@ -2512,7 +2512,7 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void
grad.addColorStop(0.5, '#ffffff') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00') grad.addColorStop(1.0, '#00ff00')
this.context.fillStyle = grad this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500) this.context.fillRect(0, 0, 400, 400)
}) })
} }
.width('100%') .width('100%')
...@@ -2563,7 +2563,7 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, ...@@ -2563,7 +2563,7 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number,
grad.addColorStop(0.5, '#ffffff') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00') grad.addColorStop(1.0, '#00ff00')
this.context.fillStyle = grad this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500) this.context.fillRect(0, 0, 440, 440)
}) })
} }
.width('100%') .width('100%')
......
...@@ -47,7 +47,7 @@ struct Page45 { ...@@ -47,7 +47,7 @@ struct Page45 {
grad.addColorStop(0.5, '#ffffff') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00') grad.addColorStop(1.0, '#00ff00')
this.context.fillStyle = grad this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500) this.context.fillRect(0, 0, 400, 400)
}) })
} }
.width('100%') .width('100%')
......
...@@ -24,29 +24,29 @@ ImageData对象可以存储canvas渲染的像素数据。 ...@@ -24,29 +24,29 @@ ImageData对象可以存储canvas渲染的像素数据。
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct Translate { struct Translate {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private img:ImageBitmap = new ImageBitmap("/common/images/1234.png") private img:ImageBitmap = new ImageBitmap("common/images/1234.png")
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.drawImage(this.img,0,0,130,130) this.context.drawImage(this.img,0,0,130,130)
var imagedata = this.context.getImageData(50,50,130,130) var imagedata = this.context.getImageData(50,50,130,130)
this.context.putImageData(imagedata,150,150) this.context.putImageData(imagedata,150,150)
}) })
}
.width('100%')
.height('100%')
} }
.width('100%')
.height('100%')
} }
}
``` ```
![zh-cn_image_000000127777780](figures/zh-cn_image_000000127777780.png) ![zh-cn_image_000000127777780](figures/zh-cn_image_000000127777780.png)
......
# Path2D对象 # Path2D对象
路径对象,支持通过对象的接口进行路径的描述,并通过Canvas的stroke接口进行绘制。 路径对象,支持通过对象的接口进行路径的描述,并通过Canvas的stroke接口或者fill接口进行绘制。
> **说明:** > **说明:**
> >
......
...@@ -29,7 +29,7 @@ Flex(value?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: Fle ...@@ -29,7 +29,7 @@ Flex(value?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: Fle
| direction | [FlexDirection](ts-appendix-enums.md#flexdirection) | 否 | FlexDirection.Row | 子组件在Flex容器上排列的方向,即主轴的方向。 | | direction | [FlexDirection](ts-appendix-enums.md#flexdirection) | 否 | FlexDirection.Row | 子组件在Flex容器上排列的方向,即主轴的方向。 |
| wrap | [FlexWrap](ts-appendix-enums.md#flexwrap) | 否 | FlexWrap.NoWrap | Flex容器是单行/列还是多行/列排列。<br/>**说明:** <br/>在多行布局时,通过交叉轴方向,确认新行堆叠方向。 | | wrap | [FlexWrap](ts-appendix-enums.md#flexwrap) | 否 | FlexWrap.NoWrap | Flex容器是单行/列还是多行/列排列。<br/>**说明:** <br/>在多行布局时,通过交叉轴方向,确认新行堆叠方向。 |
| justifyContent | [FlexAlign](ts-appendix-enums.md#flexalign) | 否 | FlexAlign.Start | 所有子组件在Flex容器主轴上的对齐格式。 | | justifyContent | [FlexAlign](ts-appendix-enums.md#flexalign) | 否 | FlexAlign.Start | 所有子组件在Flex容器主轴上的对齐格式。 |
| alignItems | [ItemAlign](ts-appendix-enums.md#itemalign) | 否 | ItemAlign.Start | 所以子组件在Flex容器交叉轴上的对齐格式。 | | alignItems | [ItemAlign](ts-appendix-enums.md#itemalign) | 否 | ItemAlign.Start | 所有子组件在Flex容器交叉轴上的对齐格式。 |
| alignContent | [FlexAlign](ts-appendix-enums.md#flexalign) | 否 | FlexAlign.Start | 交叉轴中有额外的空间时,多行内容的对齐方式。仅在wrap为Wrap或WrapReverse下生效。 | | alignContent | [FlexAlign](ts-appendix-enums.md#flexalign) | 否 | FlexAlign.Start | 交叉轴中有额外的空间时,多行内容的对齐方式。仅在wrap为Wrap或WrapReverse下生效。 |
......
...@@ -48,7 +48,7 @@ Grid(scroller?: Scroller) ...@@ -48,7 +48,7 @@ Grid(scroller?: Scroller)
| rowsTemplate | string | 设置当前网格布局行的数量,不设置时默认1行。<br/>例如,&nbsp;'1fr&nbsp;1fr&nbsp;2fr'是将父组件分三行,将父组件允许的高分为4等份,第一行占1份,第二行占一份,第三行占2份。<br/>**说明:** <br/>设置为'0fr',则这一行的行宽为0,这一行GridItem不显示。设置为其他非法值,按固定1行处理。 | | rowsTemplate | string | 设置当前网格布局行的数量,不设置时默认1行。<br/>例如,&nbsp;'1fr&nbsp;1fr&nbsp;2fr'是将父组件分三行,将父组件允许的高分为4等份,第一行占1份,第二行占一份,第三行占2份。<br/>**说明:** <br/>设置为'0fr',则这一行的行宽为0,这一行GridItem不显示。设置为其他非法值,按固定1行处理。 |
| columnsGap | [Length](ts-types.md#length) | 设置列与列的间距。<br/>默认值:0<br/>**说明:** <br/>设置为小于0的值时,按默认值显示。 | | columnsGap | [Length](ts-types.md#length) | 设置列与列的间距。<br/>默认值:0<br/>**说明:** <br/>设置为小于0的值时,按默认值显示。 |
| rowsGap | [Length](ts-types.md#length) | 设置行与行的间距。<br/>默认值:0<br/>**说明:** <br/>设置为小于0的值时,按默认值显示。 | | rowsGap | [Length](ts-types.md#length) | 设置行与行的间距。<br/>默认值:0<br/>**说明:** <br/>设置为小于0的值时,按默认值显示。 |
| scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。<br/>默认值:BarState.Off | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。<br/>默认值:BarState.Off<br/>**说明:** <br/>API version 9及以下版本默认值为BarState.Off,API version 10的默认值为BarState.Auto。 |
| scrollBarColor | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Color](ts-appendix-enums.md#color) | 设置滚动条的颜色。 | | scrollBarColor | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Color](ts-appendix-enums.md#color) | 设置滚动条的颜色。 |
| scrollBarWidth | string \| number | 设置滚动条的宽度。宽度设置后,滚动条正常状态和按压状态宽度均为滚动条的宽度值。<br/>默认值:4<br/>单位:vp | | scrollBarWidth | string \| number | 设置滚动条的宽度。宽度设置后,滚动条正常状态和按压状态宽度均为滚动条的宽度值。<br/>默认值:4<br/>单位:vp |
| cachedCount | number | 设置预加载的GridItem的数量,只在[LazyForEach](../../quick-start/arkts-rendering-control.md#数据懒加载)中生效。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)<br/>默认值:1<br/>**说明:** <br>设置缓存后会在Grid显示区域上下各缓存cachedCount*列数个GridItem。<br/>[LazyForEach](../../quick-start/arkts-rendering-control.md#数据懒加载)超出显示和缓存范围的GridItem会被释放。<br/>设置为小于0的值时,按默认值显示。 | | cachedCount | number | 设置预加载的GridItem的数量,只在[LazyForEach](../../quick-start/arkts-rendering-control.md#数据懒加载)中生效。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)<br/>默认值:1<br/>**说明:** <br>设置缓存后会在Grid显示区域上下各缓存cachedCount*列数个GridItem。<br/>[LazyForEach](../../quick-start/arkts-rendering-control.md#数据懒加载)超出显示和缓存范围的GridItem会被释放。<br/>设置为小于0的值时,按默认值显示。 |
......
...@@ -53,7 +53,7 @@ List(value?:{space?: number&nbsp;|&nbsp;string, initialIndex?: number, scroller? ...@@ -53,7 +53,7 @@ List(value?:{space?: number&nbsp;|&nbsp;string, initialIndex?: number, scroller?
| -------- | -------- | -------- | | -------- | -------- | -------- |
| listDirection | [Axis](ts-appendix-enums.md#axis) | 设置List组件排列方向。<br/>默认值:Axis.Vertical<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | listDirection | [Axis](ts-appendix-enums.md#axis) | 设置List组件排列方向。<br/>默认值:Axis.Vertical<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| divider | {<br/>strokeWidth:&nbsp;[Length](ts-types.md#length),<br/>color?:[ResourceColor](ts-types.md#resourcecolor),<br/>startMargin?:&nbsp;Length,<br/>endMargin?:&nbsp;Length<br/>}&nbsp;\|&nbsp;null | 设置ListItem分割线样式,不支持设置百分比,默认无分割线。<br/>- strokeWidth:&nbsp;分割线的线宽。<br/>- color:&nbsp;分割线的颜色。<br/>- startMargin:&nbsp;分割线与列表侧边起始端的距离。<br/>- endMargin:&nbsp;分割线与列表侧边结束端的距离。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>endMargin +startMargin 不能超过列宽度。 <br/>startMargin和endMargin不支持设置百分比。<br/>List的分割线画在主轴方向两个子组件之间,第一个子组件上方和最后一个子组件下方不会绘制分割线。<br/>多列模式下,ListItem与ListItem之间的分割线起始边距从每一列的交叉轴方向起始边开始计算,其他情况从List交叉轴方向起始边开始计算。 | | divider | {<br/>strokeWidth:&nbsp;[Length](ts-types.md#length),<br/>color?:[ResourceColor](ts-types.md#resourcecolor),<br/>startMargin?:&nbsp;Length,<br/>endMargin?:&nbsp;Length<br/>}&nbsp;\|&nbsp;null | 设置ListItem分割线样式,不支持设置百分比,默认无分割线。<br/>- strokeWidth:&nbsp;分割线的线宽。<br/>- color:&nbsp;分割线的颜色。<br/>- startMargin:&nbsp;分割线与列表侧边起始端的距离。<br/>- endMargin:&nbsp;分割线与列表侧边结束端的距离。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>endMargin +startMargin 不能超过列宽度。 <br/>startMargin和endMargin不支持设置百分比。<br/>List的分割线画在主轴方向两个子组件之间,第一个子组件上方和最后一个子组件下方不会绘制分割线。<br/>多列模式下,ListItem与ListItem之间的分割线起始边距从每一列的交叉轴方向起始边开始计算,其他情况从List交叉轴方向起始边开始计算。 |
| scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。<br/>默认值:BarState.Off<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。<br/>默认值:BarState.Off<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:** <br/>API version 9及以下版本默认值为BarState.Off,API version 10的默认值为BarState.Auto。 |
| cachedCount | number | 设置列表中ListItem/ListItemGroup的预加载数量,只在[LazyForEach](../../quick-start/arkts-rendering-control.md#数据懒加载)中生效,其中ListItemGroup将作为一个整体进行计算,ListItemGroup中的所有ListItem会一次性全部加载出来。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)<br/>默认值:1<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:** <br/>单列模式下,会在List显示的ListItem前后各缓存cachedCount个ListItem。<br/>多列模式下, 会在List显示的ListItem前后各缓存cachedCount*列数个ListItem。 | | cachedCount | number | 设置列表中ListItem/ListItemGroup的预加载数量,只在[LazyForEach](../../quick-start/arkts-rendering-control.md#数据懒加载)中生效,其中ListItemGroup将作为一个整体进行计算,ListItemGroup中的所有ListItem会一次性全部加载出来。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)<br/>默认值:1<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:** <br/>单列模式下,会在List显示的ListItem前后各缓存cachedCount个ListItem。<br/>多列模式下, 会在List显示的ListItem前后各缓存cachedCount*列数个ListItem。 |
| editMode<sup>(deprecated)</sup> | boolean | 声明当前List组件是否处于可编辑模式。<br/>从API version9开始废弃。<br/>默认值:false | | editMode<sup>(deprecated)</sup> | boolean | 声明当前List组件是否处于可编辑模式。<br/>从API version9开始废弃。<br/>默认值:false |
| edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置组件的滑动效果,支持弹簧效果和阴影效果。<br/>默认值:EdgeEffect.Spring<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置组件的滑动效果,支持弹簧效果和阴影效果。<br/>默认值:EdgeEffect.Spring<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
...@@ -218,69 +218,3 @@ struct ListLanesExample { ...@@ -218,69 +218,3 @@ struct ListLanesExample {
``` ```
![list](figures/list1.gif) ![list](figures/list1.gif)
```ts
// xxx.ets
@Entry
@Component
struct ListDividerTest {
private arr: number[] = [0, 1, 2, 3]
@Builder header() {
Text('header')
.width('100%')
.height(50)
.fontSize(16)
.textAlign(TextAlign.Center)
.backgroundColor(0xFFEECC)
}
@Builder footer() {
Text('footer')
.width('100%')
.height(40)
.fontSize(16)
.textAlign(TextAlign.Center)
.backgroundColor(0xFFEECC)
}
@Builder item(index: number) {
Text('item' + index)
.width('100%').height(80)
.fontSize(16)
.textAlign(TextAlign.Center)
}
build() {
Column() {
List() {
ForEach(this.arr, (item) => {
ListItem() {
this.item(item)
}
}, item => item)
ListItemGroup({ header: this.header, footer: this.footer }) {
ForEach(this.arr, (item) => {
ListItem() {
this.item(item)
}
}, item => item)
}
.divider({ strokeWidth: 2, color: Color.Red, startMargin: 20, endMargin: 10 })
ForEach(this.arr, (item) => {
ListItem() {
this.item(item)
}
}, item => item)
}
.lanes(2)
.divider({ strokeWidth: 2, color: Color.Red, startMargin: 20, endMargin: 10 })
.margin(10).borderWidth(1)
}.width("100%")
.height("100%")
}
}
```
![ListDivider](figures/ListDivider.png)
\ No newline at end of file
...@@ -43,7 +43,7 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr ...@@ -43,7 +43,7 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr
| barMode | BarMode | TabBar布局模式,具体描述见BarMode枚举说明。<br/>默认值:BarMode.Fixed | | barMode | BarMode | TabBar布局模式,具体描述见BarMode枚举说明。<br/>默认值:BarMode.Fixed |
| barWidth | number&nbsp;\|&nbsp;Length<sup>8+</sup> | TabBar的宽度值。<br/>**说明:** <br/>设置为小于0或大于Tabs宽度值时,按默认值显示。 | | barWidth | number&nbsp;\|&nbsp;Length<sup>8+</sup> | TabBar的宽度值。<br/>**说明:** <br/>设置为小于0或大于Tabs宽度值时,按默认值显示。 |
| barHeight | number&nbsp;\|&nbsp;Length<sup>8+</sup> | TabBar的高度值。<br/>**说明:** <br/>设置为小于0或大于Tabs宽度值时,按默认值显示。 | | barHeight | number&nbsp;\|&nbsp;Length<sup>8+</sup> | TabBar的高度值。<br/>**说明:** <br/>设置为小于0或大于Tabs宽度值时,按默认值显示。 |
| animationDuration | number | TabContent滑动动画时长。不设置时,点击切换页签无动画,滑动切换有动画;设置时,点击切换和滑动切换都有动画。<br/>默认值:200 <br/>**说明:** <br/>设置为小于0或百分比时,按默认值显示。| | animationDuration | number | TabContent滑动动画时长。不设置时,点击切换页签无动画,滑动切换有动画;设置时,点击切换和滑动切换都有动画。<br/>默认值:300 <br/>**说明:** <br/>设置为小于0或百分比时,按默认值显示。|
| divider<sup>10+</sup> | [DividerStyle](#dividerstyle10对象说明) \| null | 用于设置区分TabBar和TabContent的分割线样式设置分割线样式,默认不显示分割线。<br/> DividerStyle: 分割线的样式;<br/> null: 不显示分割线。 | | divider<sup>10+</sup> | [DividerStyle](#dividerstyle10对象说明) \| null | 用于设置区分TabBar和TabContent的分割线样式设置分割线样式,默认不显示分割线。<br/> DividerStyle: 分割线的样式;<br/> null: 不显示分割线。 |
| FadingEdge<sup>10+</sup> | boolean | 设置页签超过容器宽度时是否渐隐消失<br />默认值:true | | FadingEdge<sup>10+</sup> | boolean | 设置页签超过容器宽度时是否渐隐消失<br />默认值:true |
......
...@@ -58,35 +58,41 @@ struct LineExample { ...@@ -58,35 +58,41 @@ struct LineExample {
Column({ space: 10 }) { Column({ space: 10 }) {
// 线条绘制的起止点坐标均是相对于Line组件本身绘制区域的坐标 // 线条绘制的起止点坐标均是相对于Line组件本身绘制区域的坐标
Line() Line()
.width(200)
.height(150)
.startPoint([0, 0]) .startPoint([0, 0])
.endPoint([50, 100]) .endPoint([50, 100])
.stroke(Color.Black) .stroke(Color.Black)
.backgroundColor('#F5F5F5') .backgroundColor('#F5F5F5')
Line() Line()
.width(200) .width(200)
.height(200) .height(150)
.startPoint([50, 50]) .startPoint([50, 50])
.endPoint([150, 150]) .endPoint([150, 150])
.strokeWidth(5) .strokeWidth(5)
.stroke(Color.Orange) .stroke(Color.Orange)
.strokeOpacity(0.5) .strokeOpacity(0.5)
.backgroundColor('#F5F5F5') .backgroundColor('#F5F5F5')
// 当坐标点设置的值超出Line组件的宽高范围时,线条会画出组件绘制区域 // strokeDashOffset用于定义关联虚线strokeDashArray数组渲染时的偏移
Line({ width: 50, height: 50 }) Line()
.width(200)
.height(150)
.startPoint([0, 0]) .startPoint([0, 0])
.endPoint([100, 100]) .endPoint([100, 100])
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(3) .strokeWidth(3)
.strokeDashArray([10, 3]) .strokeDashArray([10, 3])
.strokeDashOffset(5)
.backgroundColor('#F5F5F5') .backgroundColor('#F5F5F5')
// strokeDashOffset用于定义关联虚线strokeDashArray数组渲染时的偏移 // 当坐标点设置的值超出Line组件的宽高范围时,线条会画出组件绘制区域
Line({ width: 50, height: 50 }) Line()
.width(50)
.height(50)
.startPoint([0, 0]) .startPoint([0, 0])
.endPoint([100, 100]) .endPoint([100, 100])
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(3) .strokeWidth(3)
.strokeDashArray([10, 3]) .strokeDashArray([10, 3])
.strokeDashOffset(5)
.backgroundColor('#F5F5F5') .backgroundColor('#F5F5F5')
} }
} }
...@@ -151,12 +157,16 @@ struct LineExample { ...@@ -151,12 +157,16 @@ struct LineExample {
build() { build() {
Column() { Column() {
Line() Line()
.width(300)
.height(30)
.startPoint([50, 30]) .startPoint([50, 30])
.endPoint([300, 30]) .endPoint([300, 30])
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(10) .strokeWidth(10)
// 设置strokeDashArray的数组间隔为 50 // 设置strokeDashArray的数组间隔为 50
Line() Line()
.width(300)
.height(30)
.startPoint([50, 20]) .startPoint([50, 20])
.endPoint([300, 20]) .endPoint([300, 20])
.stroke(Color.Black) .stroke(Color.Black)
...@@ -164,6 +174,8 @@ struct LineExample { ...@@ -164,6 +174,8 @@ struct LineExample {
.strokeDashArray([50]) .strokeDashArray([50])
// 设置strokeDashArray的数组间隔为 50, 10 // 设置strokeDashArray的数组间隔为 50, 10
Line() Line()
.width(300)
.height(30)
.startPoint([50, 20]) .startPoint([50, 20])
.endPoint([300, 20]) .endPoint([300, 20])
.stroke(Color.Black) .stroke(Color.Black)
...@@ -171,6 +183,8 @@ struct LineExample { ...@@ -171,6 +183,8 @@ struct LineExample {
.strokeDashArray([50, 10]) .strokeDashArray([50, 10])
// 设置strokeDashArray的数组间隔为 50, 10, 20 // 设置strokeDashArray的数组间隔为 50, 10, 20
Line() Line()
.width(300)
.height(30)
.startPoint([50, 20]) .startPoint([50, 20])
.endPoint([300, 20]) .endPoint([300, 20])
.stroke(Color.Black) .stroke(Color.Black)
...@@ -178,6 +192,8 @@ struct LineExample { ...@@ -178,6 +192,8 @@ struct LineExample {
.strokeDashArray([50, 10, 20]) .strokeDashArray([50, 10, 20])
// 设置strokeDashArray的数组间隔为 50, 10, 20, 30 // 设置strokeDashArray的数组间隔为 50, 10, 20, 30
Line() Line()
.width(300)
.height(30)
.startPoint([50, 20]) .startPoint([50, 20])
.endPoint([300, 20]) .endPoint([300, 20])
.stroke(Color.Black) .stroke(Color.Black)
......
...@@ -74,9 +74,10 @@ struct PathExample { ...@@ -74,9 +74,10 @@ struct PathExample {
.fontSize(11) .fontSize(11)
.fontColor(0xCCCCCC) .fontColor(0xCCCCCC)
.width('90%') .width('90%')
// 绘制一条长900px,宽3vp的直线 // 绘制一条长600px,宽3vp的直线
Path() Path()
.height(10) .width('600px')
.height('10px')
.commands('M0 0 L600 0') .commands('M0 0 L600 0')
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(3) .strokeWidth(3)
...@@ -88,16 +89,22 @@ struct PathExample { ...@@ -88,16 +89,22 @@ struct PathExample {
// 绘制直线图形 // 绘制直线图形
Flex({ justifyContent: FlexAlign.SpaceBetween }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) {
Path() Path()
.width('210px')
.height('310px')
.commands('M100 0 L200 240 L0 240 Z') .commands('M100 0 L200 240 L0 240 Z')
.fillOpacity(0) .fillOpacity(0)
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(3) .strokeWidth(3)
Path() Path()
.width('210px')
.height('310px')
.commands('M0 0 H200 V200 H0 Z') .commands('M0 0 H200 V200 H0 Z')
.fillOpacity(0) .fillOpacity(0)
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(3) .strokeWidth(3)
Path() Path()
.width('210px')
.height('310px')
.commands('M100 0 L0 100 L50 200 L150 200 L200 100 Z') .commands('M100 0 L0 100 L50 200 L150 200 L200 100 Z')
.fillOpacity(0) .fillOpacity(0)
.stroke(Color.Black) .stroke(Color.Black)
...@@ -108,16 +115,22 @@ struct PathExample { ...@@ -108,16 +115,22 @@ struct PathExample {
// 绘制弧线图形 // 绘制弧线图形
Flex({ justifyContent: FlexAlign.SpaceBetween }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) {
Path() Path()
.width('250px')
.height('310px')
.commands("M0 300 S100 0 240 300 Z") .commands("M0 300 S100 0 240 300 Z")
.fillOpacity(0) .fillOpacity(0)
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(3) .strokeWidth(3)
Path() Path()
.width('210px')
.height('310px')
.commands('M0 150 C0 100 140 0 200 150 L100 300 Z') .commands('M0 150 C0 100 140 0 200 150 L100 300 Z')
.fillOpacity(0) .fillOpacity(0)
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(3) .strokeWidth(3)
Path() Path()
.width('210px')
.height('310px')
.commands('M0 100 A30 20 20 0 0 200 100 Z') .commands('M0 100 A30 20 20 0 0 200 100 Z')
.fillOpacity(0) .fillOpacity(0)
.stroke(Color.Black) .stroke(Color.Black)
......
...@@ -70,6 +70,8 @@ struct ShapeExample { ...@@ -70,6 +70,8 @@ struct ShapeExample {
Ellipse().width(300).height(50).offset({ x: 0, y: 60 }) Ellipse().width(300).height(50).offset({ x: 0, y: 60 })
Path().width(300).height(10).commands('M0 0 L900 0').offset({ x: 0, y: 120 }) Path().width(300).height(10).commands('M0 0 L900 0').offset({ x: 0, y: 120 })
} }
.width(350)
.height(140)
.viewPort({ x: -2, y: -2, width: 304, height: 130 }) .viewPort({ x: -2, y: -2, width: 304, height: 130 })
.fill(0x317AF7) .fill(0x317AF7)
.stroke(Color.Black) .stroke(Color.Black)
...@@ -83,6 +85,8 @@ struct ShapeExample { ...@@ -83,6 +85,8 @@ struct ShapeExample {
Shape() { Shape() {
Rect().width(300).height(50) Rect().width(300).height(50)
} }
.width(350)
.height(80)
.viewPort({ x: 0, y: 0, width: 320, height: 70 }) .viewPort({ x: 0, y: 0, width: 320, height: 70 })
.fill(0x317AF7) .fill(0x317AF7)
.stroke(Color.Black) .stroke(Color.Black)
...@@ -91,6 +95,8 @@ struct ShapeExample { ...@@ -91,6 +95,8 @@ struct ShapeExample {
Shape() { Shape() {
Rect().width(300).height(50) Rect().width(300).height(50)
} }
.width(350)
.height(80)
.viewPort({ x: -5, y: -5, width: 320, height: 70 }) .viewPort({ x: -5, y: -5, width: 320, height: 70 })
.fill(0x317AF7) .fill(0x317AF7)
.stroke(Color.Black) .stroke(Color.Black)
...@@ -101,6 +107,8 @@ struct ShapeExample { ...@@ -101,6 +107,8 @@ struct ShapeExample {
Shape() { Shape() {
Path().width(300).height(10).commands('M0 0 L900 0') Path().width(300).height(10).commands('M0 0 L900 0')
} }
.width(350)
.height(20)
.viewPort({ x: 0, y: -5, width: 300, height: 20 }) .viewPort({ x: 0, y: -5, width: 300, height: 20 })
.stroke(0xEE8443) .stroke(0xEE8443)
.strokeWidth(10) .strokeWidth(10)
...@@ -109,6 +117,8 @@ struct ShapeExample { ...@@ -109,6 +117,8 @@ struct ShapeExample {
Shape() { Shape() {
Path().width(300).height(10).commands('M0 0 L900 0') Path().width(300).height(10).commands('M0 0 L900 0')
} }
.width(350)
.height(20)
.viewPort({ x: 0, y: -5, width: 300, height: 20 }) .viewPort({ x: 0, y: -5, width: 300, height: 20 })
.stroke(0xEE8443) .stroke(0xEE8443)
.strokeWidth(10) .strokeWidth(10)
...@@ -118,6 +128,8 @@ struct ShapeExample { ...@@ -118,6 +128,8 @@ struct ShapeExample {
Shape() { Shape() {
Path().width(300).height(10).commands('M0 0 L900 0') Path().width(300).height(10).commands('M0 0 L900 0')
} }
.width(350)
.height(20)
.viewPort({ x: 0, y: -5, width: 300, height: 20 }) .viewPort({ x: 0, y: -5, width: 300, height: 20 })
.stroke(0xEE8443) .stroke(0xEE8443)
.strokeWidth(10) .strokeWidth(10)
...@@ -126,6 +138,8 @@ struct ShapeExample { ...@@ -126,6 +138,8 @@ struct ShapeExample {
Shape() { Shape() {
Path().width(300).height(10).commands('M0 0 L900 0') Path().width(300).height(10).commands('M0 0 L900 0')
} }
.width(350)
.height(20)
.viewPort({ x: 0, y: -5, width: 300, height: 20 }) .viewPort({ x: 0, y: -5, width: 300, height: 20 })
.stroke(0xEE8443) .stroke(0xEE8443)
.strokeWidth(10) .strokeWidth(10)
...@@ -135,7 +149,9 @@ struct ShapeExample { ...@@ -135,7 +149,9 @@ struct ShapeExample {
Shape() { Shape() {
Path().width(200).height(60).commands('M0 0 L400 0 L400 150 Z') Path().width(200).height(60).commands('M0 0 L400 0 L400 150 Z')
} }
.viewPort({ x: -80, y: -5, width: 310, height: 90 }) .width(300)
.height(200)
.viewPort({ x: -20, y: -5, width: 310, height: 90 })
.fill(0x317AF7) .fill(0x317AF7)
.stroke(0xEE8443) .stroke(0xEE8443)
.strokeWidth(10) .strokeWidth(10)
...@@ -147,3 +163,4 @@ struct ShapeExample { ...@@ -147,3 +163,4 @@ struct ShapeExample {
``` ```
![zh-cn_image_0000001184628104](figures/zh-cn_image_0000001184628104.png) ![zh-cn_image_0000001184628104](figures/zh-cn_image_0000001184628104.png)
\ No newline at end of file
...@@ -66,7 +66,7 @@ struct FillStyleExample { ...@@ -66,7 +66,7 @@ struct FillStyleExample {
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.offContext.fillStyle = '#0000ff' this.offContext.fillStyle = '#0000ff'
this.offContext.fillRect(20, 160, 150, 100) this.offContext.fillRect(20, 20, 150, 100)
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
...@@ -1752,39 +1752,39 @@ clip(path:Path2D, fillRule?: CanvasFillRule): void ...@@ -1752,39 +1752,39 @@ clip(path:Path2D, fillRule?: CanvasFillRule): void
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct Clip { struct Clip {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings)
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
let region = new Path2D() let region = new Path2D()
region.moveTo(30, 90) region.moveTo(30, 90)
region.lineTo(110, 20) region.lineTo(110, 20)
region.lineTo(240, 130) region.lineTo(240, 130)
region.lineTo(60, 130) region.lineTo(60, 130)
region.lineTo(190, 20) region.lineTo(190, 20)
region.lineTo(270, 90) region.lineTo(270, 90)
region.closePath() region.closePath()
this.offContext.clip(region,"evenodd") this.offContext.clip(region,"evenodd")
this.offContext.fillStyle = "rgb(0,255,0)" this.offContext.fillStyle = "rgb(0,255,0)"
this.offContext.fillRect(0, 0, 600, 600) this.offContext.fillRect(0, 0, 600, 600)
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
}
.width('100%')
.height('100%')
} }
.width('100%')
.height('100%')
} }
}
``` ```
![zh-cn_image_000000127777779](figures/zh-cn_image_000000127777779.png) ![zh-cn_image_000000127777779](figures/zh-cn_image_000000127777779.png)
...@@ -2189,6 +2189,27 @@ getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap ...@@ -2189,6 +2189,27 @@ getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap
| ---------------------------------------- | ------------ | | ---------------------------------------- | ------------ |
| [PixelMap](../apis/js-apis-image.md#pixelmap7) | 新的PixelMap对象 | | [PixelMap](../apis/js-apis-image.md#pixelmap7) | 新的PixelMap对象 |
### setPixelMap
setPixelMap(value?: PixelMap): void
将当前传入[PixelMap](../apis/js-apis-image.md#pixelmap7)对象绘制在画布上。
**参数:**
| 参数 | 类型 | 必填 | 默认值 | 描述 |
| ---- | ------ | ---- | ---- | --------------- |
| sx | number | 是 | 0 | 需要输出的区域的左上角x坐标。 |
| sy | number | 是 | 0 | 需要输出的区域的左上角y坐标。 |
| sw | number | 是 | 0 | 需要输出的区域的宽度。 |
| sh | number | 是 | 0 | 需要输出的区域的高度。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------------- | ------------ |
| [PixelMap](../apis/js-apis-image.md#pixelmap7) | 新的PixelMap对象 |
### getImageData ### getImageData
...@@ -2216,32 +2237,32 @@ getImageData(sx: number, sy: number, sw: number, sh: number): ImageData ...@@ -2216,32 +2237,32 @@ getImageData(sx: number, sy: number, sw: number, sh: number): ImageData
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct GetImageData { struct GetImageData {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings)
private img:ImageBitmap = new ImageBitmap("/common/images/1234.png") private img:ImageBitmap = new ImageBitmap("/common/images/1234.png")
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.offContext.drawImage(this.img,0,0,130,130) this.offContext.drawImage(this.img,0,0,130,130)
var imagedata = this.offContext.getImageData(50,50,130,130) var imagedata = this.offContext.getImageData(50,50,130,130)
this.offContext.putImageData(imagedata,150,150) this.offContext.putImageData(imagedata,150,150)
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
}
.width('100%')
.height('100%')
} }
.width('100%')
.height('100%')
} }
}
``` ```
![zh-cn_image_000000127777780](figures/zh-cn_image_000000127777780.png) ![zh-cn_image_000000127777780](figures/zh-cn_image_000000127777780.png)
...@@ -2319,31 +2340,31 @@ setLineDash(segments: number[]): void ...@@ -2319,31 +2340,31 @@ setLineDash(segments: number[]): void
**示例:** **示例:**
```ts ```ts
@Entry @Entry
@Component @Component
struct SetLineDash { struct SetLineDash {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings)
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.offContext.arc(100, 75, 50, 0, 6.28) this.offContext.arc(100, 75, 50, 0, 6.28)
this.offContext.setLineDash([10,20]) this.offContext.setLineDash([10,20])
this.offContext.stroke() this.offContext.stroke()
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
}
.width('100%')
.height('100%')
} }
.width('100%')
.height('100%')
} }
}
``` ```
![zh-cn_image_000000127777772](figures/zh-cn_image_000000127777772.png) ![zh-cn_image_000000127777772](figures/zh-cn_image_000000127777772.png)
...@@ -2364,42 +2385,42 @@ getLineDash(): number[] ...@@ -2364,42 +2385,42 @@ getLineDash(): number[]
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct OffscreenCanvasGetLineDash { struct OffscreenCanvasGetLineDash {
@State message: string = 'Hello World' @State message: string = 'Hello World'
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings)
build() { build() {
Row() { Row() {
Column() { Column() {
Text(this.message) Text(this.message)
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
.onClick(()=>{ .onClick(()=>{
console.error('before getlinedash clicked') console.error('before getlinedash clicked')
let res = this.offContext.getLineDash() let res = this.offContext.getLineDash()
console.error(JSON.stringify(res)) console.error(JSON.stringify(res))
}) })
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() => { .onReady(() => {
this.offContext.arc(100, 75, 50, 0, 6.28) this.offContext.arc(100, 75, 50, 0, 6.28)
this.offContext.setLineDash([10,20]) this.offContext.setLineDash([10,20])
this.offContext.stroke() this.offContext.stroke()
let res = this.offContext.getLineDash() let res = this.offContext.getLineDash()
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
}
.width('100%')
} }
.width('100%') .height('100%')
} }
.height('100%')
} }
}
``` ```
![zh-cn_image_000000127777778](figures/zh-cn_image_000000127777778.png) ![zh-cn_image_000000127777778](figures/zh-cn_image_000000127777778.png)
...@@ -2429,28 +2450,28 @@ toDataURL(type?: string, quality?: number): string ...@@ -2429,28 +2450,28 @@ toDataURL(type?: string, quality?: number): string
**示例:** **示例:**
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct ToDataURL { struct ToDataURL {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings)
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var dataURL = this.offContext.toDataURL() var dataURL = this.offContext.toDataURL()
}) })
}
.width('100%')
.height('100%')
} }
.width('100%')
.height('100%')
} }
}
``` ```
...@@ -2527,33 +2548,33 @@ restore(): void ...@@ -2527,33 +2548,33 @@ restore(): void
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct CanvasExample { struct CanvasExample {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings)
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.offContext.save() // save the default state this.offContext.save() // save the default state
this.offContext.fillStyle = "#00ff00" this.offContext.fillStyle = "#00ff00"
this.offContext.fillRect(20, 20, 100, 100) this.offContext.fillRect(20, 20, 100, 100)
this.offContext.restore() // restore to the default state this.offContext.restore() // restore to the default state
this.offContext.fillRect(150, 75, 100, 100) this.offContext.fillRect(150, 75, 100, 100)
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
}
.width('100%')
.height('100%')
} }
.width('100%')
.height('100%')
} }
}
``` ```
![zh-cn_image_000000127777781](figures/zh-cn_image_000000127777781.png) ![zh-cn_image_000000127777781](figures/zh-cn_image_000000127777781.png)
...@@ -2568,33 +2589,33 @@ save(): void ...@@ -2568,33 +2589,33 @@ save(): void
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct CanvasExample { struct CanvasExample {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings)
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.offContext.save() // save the default state this.offContext.save() // save the default state
this.offContext.fillStyle = "#00ff00" this.offContext.fillStyle = "#00ff00"
this.offContext.fillRect(20, 20, 100, 100) this.offContext.fillRect(20, 20, 100, 100)
this.offContext.restore() // restore to the default state this.offContext.restore() // restore to the default state
this.offContext.fillRect(150, 75, 100, 100) this.offContext.fillRect(150, 75, 100, 100)
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
}
.width('100%')
.height('100%')
} }
.width('100%')
.height('100%')
} }
}
``` ```
![zh-cn_image_000000127777781](figures/zh-cn_image_000000127777781.png) ![zh-cn_image_000000127777781](figures/zh-cn_image_000000127777781.png)
...@@ -2637,7 +2658,7 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void ...@@ -2637,7 +2658,7 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void
grad.addColorStop(0.5, '#ffffff') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00') grad.addColorStop(1.0, '#00ff00')
this.offContext.fillStyle = grad this.offContext.fillStyle = grad
this.offContext.fillRect(0, 0, 500, 500) this.offContext.fillRect(0, 0, 400, 400)
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
...@@ -2691,7 +2712,7 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, ...@@ -2691,7 +2712,7 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number,
grad.addColorStop(0.5, '#ffffff') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00') grad.addColorStop(1.0, '#00ff00')
this.offContext.fillStyle = grad this.offContext.fillStyle = grad
this.offContext.fillRect(0, 0, 500, 500) this.offContext.fillRect(0, 0, 440, 440)
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## 概述 ## 概述
AudioDecoder模块提供用于音频解码功能的函数。 AudioDecoder模块提供用于音频解码功能的函数。该模块在部分设备上可能不支持,可以通过[CanIUse](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/syscap.md)接口确认。
@syscap SystemCapability.Multimedia.Media.AudioDecoder @syscap SystemCapability.Multimedia.Media.AudioDecoder
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## 概述 ## 概述
AudioEncoder模块提供用于音频编码功能的函数。 AudioEncoder模块提供用于音频编码功能的函数。该模块在部分设备上可能不支持,可以通过[CanIUse](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/syscap.md)接口确认。
@syscap SystemCapability.Multimedia.Media.AudioEncoder @syscap SystemCapability.Multimedia.Media.AudioEncoder
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## 概述 ## 概述
CodecBase模块提供运行音视频编解码通用的结构体、字符常量、枚举。 CodecBase模块提供运行音视频编解码通用的结构体、字符常量、枚举。该模块在部分设备上可能不支持,可以通过[CanIUse](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/syscap.md)接口确认。
@syscap SystemCapability.Multimedia.Media.CodecBase @syscap SystemCapability.Multimedia.Media.CodecBase
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## 概述 ## 概述
VideoDecoder模块提供用于视频解码功能的函数。 VideoDecoder模块提供用于视频解码功能的函数。该模块在部分设备上可能不支持,可以通过[CanIUse](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/syscap.md)接口确认。
@syscap SystemCapability.Multimedia.Media.VideoDecoder @syscap SystemCapability.Multimedia.Media.VideoDecoder
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## 概述 ## 概述
VideoEncoder模块提供用于视频编码功能的函数和枚举。 VideoEncoder模块提供用于视频编码功能的函数和枚举。该模块在部分设备上可能不支持,可以通过[CanIUse](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/syscap.md)接口确认。
@syscap SystemCapability.Multimedia.Media.VideoEncoder @syscap SystemCapability.Multimedia.Media.VideoEncoder
......
...@@ -195,6 +195,16 @@ WorkSchedulerExtensionAbility类拥有如下API接口,具体的API介绍详见 ...@@ -195,6 +195,16 @@ WorkSchedulerExtensionAbility类拥有如下API接口,具体的API介绍详见
} }
``` ```
## 限制
为了降低WorkSchedulerExtensionAbility能力被三方应用滥用的风险,在WorkSchedulerExtensionAbility中限制以下接口的调用
- @ohos.backgroundTaskManager.d.ts
- @ohos.resourceschedule.backgroundTaskManager.d.ts
- @ohos.multimedia.camera.d.ts
- @ohos.multimedia.audio.d.ts
- @ohos.multimedia.media.d.ts
## 相关实例 ## 相关实例
针对WorkSchedulerExtensionAbility开发,有以下相关示例可供参考: 针对WorkSchedulerExtensionAbility开发,有以下相关示例可供参考:
......
...@@ -92,12 +92,12 @@ listener.on('change', onPortrait) ...@@ -92,12 +92,12 @@ listener.on('change', onPortrait)
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ |
| height | 应用页面显示区域的高度。 | | height | 应用页面可绘制区域的高度。 |
| min-height | 应用页面显示区域的最小高度。 | | min-height | 应用页面可绘制区域的最小高度。 |
| max-height | 应用页面显示区域的最大高度。 | | max-height | 应用页面可绘制区域的最大高度。 |
| width | 应用页面显示区域的宽度。 | | width | 应用页面可绘制区域的宽度。 |
| min-width | 应用页面显示区域的最小宽度。 | | min-width | 应用页面可绘制区域的最小宽度。 |
| max-width | 应用页面显示区域的最大宽度。 | | max-width | 应用页面可绘制区域的最大宽度。 |
| resolution | 设备的分辨率,支持dpi,dppx和dpcm单位。其中:<br/>-&nbsp; dpi表示每英寸中物理像素个数,1dpi≈0.39dpcm;<br/>-&nbsp; dpcm表示每厘米上的物理像素个数,1dpcm&nbsp;&nbsp; 2.54dpi;<br/>-&nbsp; dppx表示每个px中的物理像素数(此单位按96px=1英寸为基准,与页面中的px单位计算方式不同),1dppx&nbsp; =&nbsp; 96dpi。 | | resolution | 设备的分辨率,支持dpi,dppx和dpcm单位。其中:<br/>-&nbsp; dpi表示每英寸中物理像素个数,1dpi≈0.39dpcm;<br/>-&nbsp; dpcm表示每厘米上的物理像素个数,1dpcm&nbsp;&nbsp; 2.54dpi;<br/>-&nbsp; dppx表示每个px中的物理像素数(此单位按96px=1英寸为基准,与页面中的px单位计算方式不同),1dppx&nbsp; =&nbsp; 96dpi。 |
| min-resolution | 设备的最小分辨率。 | | min-resolution | 设备的最小分辨率。 |
| max-resolution | 设备的最大分辨率。 | | max-resolution | 设备的最大分辨率。 |
......
...@@ -28,3 +28,8 @@ typedef enum { ...@@ -28,3 +28,8 @@ typedef enum {
### 按序加载(默认加载策略) ### 按序加载(默认加载策略)
配置文件中的priority(取值范围为整数0到200)是用来表示host(驱动容器)和驱动的优先级。不同的host内的驱动,host的priority值越小,驱动加载优先级越高;同一个host内驱动的priority值越小,加载优先级越高。 配置文件中的priority(取值范围为整数0到200)是用来表示host(驱动容器)和驱动的优先级。不同的host内的驱动,host的priority值越小,驱动加载优先级越高;同一个host内驱动的priority值越小,加载优先级越高。
### 异常恢复(用户态驱动)
当驱动服务异常退出时,恢复策略如下:
- preload字段配置为0(DEVICE_PRELOAD_ENABLE)或1(DEVICE_PRELOAD_ENABLE_STEP2)的驱动服务,由启动模块拉起host并重新加载服务。
- preload字段配置为2(DEVICE_PRELOAD_DISABLE)的驱动服务,需业务模块注册HDF的服务状态监听器,当收到服务退出消息时,业务模块调用LoadDevice重新加载服务。
...@@ -198,12 +198,12 @@ OpenHarmony是由开放原子开源基金会(OpenAtom Foundation)孵化及 ...@@ -198,12 +198,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) | 418.1 MB | | 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) | 418.1 MB |
| RELEASE-NOTES | 3.0 | [站点](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/zh-cn/release-notes/OpenHarmony-v3.0-LTS.md) | - | - | | RELEASE-NOTES | 3.0 | [站点](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/zh-cn/release-notes/OpenHarmony-v3.0-LTS.md) | - | - |
| **最新发布版本源码** | **版本信息** | **下载站点** | **SHA256校验码** | **软件包容量** | | **最新发布版本源码** | **版本信息** | **下载站点** | **SHA256校验码** | **软件包容量** |
| 全量代码Beta版本(标准、轻量和小型系统) | 3.2 Beta5 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/code-v3.2-Beta5.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/code-v3.2-Beta5.tar.gz.sha256) | 21.3 GB | | 全量代码Beta版本(标准、轻量和小型系统) | 3.2 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/code-v3.2-Release.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/code-v3.2-Release.tar.gz.sha256) | 21.8 GB |
| Hi3861解决方案(二进制) | 3.2 Beta5 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/hispark_pegasus.tar.gz.sha256) | 22.9 MB | | Hi3861解决方案(二进制) | 3.2 Release| [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/hispark_pegasus.tar.gz.sha256) | 22.9 MB |
| Hi3516解决方案-LiteOS(二进制) | 3.2 Beta5 | [站点](https://repo.huaweicloud.com/openharmony/os/3.2-Beta5/hispark_taurus_LiteOS.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Beta5/hispark_taurus_LiteOS.tar.gz.sha256) | 293.6 MB | | Hi3516解决方案-LiteOS(二进制) | 3.2 Release| [站点](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_LiteOS.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_LiteOS.tar.gz.sha256) | 294.3 MB |
| Hi3516解决方案-Linux(二进制) | 3.2 Beta5 | [站点](hispark_taurus_Linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Beta5/hispark_taurus_Linux.tar.gz.sha256) | 174.3 MB | | Hi3516解决方案-Linux(二进制) | 3.2 Release| [站点](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_Linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_Linux.tar.gz.sha256) | 174.3 MB |
| RK3568标准系统解决方案(二进制) | 3.2 Beta5 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/dayu200_standard_arm32_20230201.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/dayu200_standard_arm32_20230201.tar.gz.sha256) | 3.9 GB | | RK3568标准系统解决方案(二进制) | 3.2 Release| [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Release//dayu200_standard_arm32.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.2-Release//dayu200_standard_arm32.tar.gz.sha256) | 3.9 GB |
| RELEASE-NOTES | 3.2 Beta5 | [站点](../../release-notes/OpenHarmony-v3.2-beta5.md) | - | - | | RELEASE-NOTES | 3.2 Release| [站点](../../release-notes/OpenHarmony-v3.2-release.md) | - | - |
| **编译工具链** | **版本信息** | **下载站点** | **SHA256校验码** | **软件包容量** | | **编译工具链** | **版本信息** | **下载站点** | **SHA256校验码** | **软件包容量** |
| 编译工具链获取清单 | - | [站点](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/) | - | - | | 编译工具链获取清单 | - | [站点](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/) | - | - |
......
此差异已折叠。
# OpenHarmony Release Notes # OpenHarmony Release Notes
## OpenHarmony 3.x Releases ## OpenHarmony 3.x Releases
- [OpenHarmony v3.2 Release (2023-04-09)](OpenHarmony-v3.2-release.md)
- [OpenHarmony v3.2 Beta5 (2023-01-31)](OpenHarmony-v3.2-beta5.md) - [OpenHarmony v3.2 Beta5 (2023-01-31)](OpenHarmony-v3.2-beta5.md)
- [OpenHarmony v3.2 Beta4 (2022-11-30)](OpenHarmony-v3.2-beta4.md) - [OpenHarmony v3.2 Beta4 (2022-11-30)](OpenHarmony-v3.2-beta4.md)
- [OpenHarmony v3.2 Beta3 (2022-09-30)](OpenHarmony-v3.2-beta3.md) - [OpenHarmony v3.2 Beta3 (2022-09-30)](OpenHarmony-v3.2-beta3.md)
......
# HUKS子系统ChangeLog
OpenHarmony 4.0.6.1 版本相较于OpenHarmony 之前的版本,HUKS的API使用权限变更如下。
## cl.huks.1 attestKeyItem接口使用权限变更
attestKeyItem是基于设备证书链封装业务公钥对用户指定的密钥进行证明,如果设备证书随意导出涉及用户隐私风险,所以此接口需要增加系统权限管控。
**变更影响**
对于不具备system权限或者ohos.permission.ACCESS_IDS权限的应用,无法正常使用attestKeyItem接口。
**关键的接口/组件变更**
- 涉及接口
attestKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksReturnResult\>): void;
attestKeyItem(keyAlias: string, options: HuksOptions): Promise\<HuksReturnResult\>;
- 变更前:
只针对传入ATTESTATION_ID相关TAG的应用校验AccessToken权限,其它情况无接口权限的限制。
- 变更后:
只有具备system权限的系统应用或者申请了ohos.permission.ACCESS_IDS权限的普通应用才能正常使用attestKeyItem接口。
**适配指导**
已经具备system权限的应用则可以正常使用attestKeyItem接口,其余普通应用需申请ohos.permission.ACCESS_IDS权限即可,申请方法参考[ACL权限配置说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6%E5%88%97%E8%A1%A8acl%E8%AF%B4%E6%98%8E)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册