提交 378b63df 编写于 作者: G ge-yafang

Merge branch 'master' of https://gitee.com/ge-yafang/docs

......@@ -18,15 +18,15 @@
- master:最新开发版本。
- OpenHarmony 3.2 Beta2版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.2-beta2.md)了解版本详情。
- OpenHarmony 3.2 Beta3版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.2-beta3.md)了解版本详情。
- OpenHarmony 3.1 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.1-release.md)了解版本详情。
已更新至OpenHarmony 3.1.1 Release,点击[此处](zh-cn/release-notes/OpenHarmony-v3.1.1-release.md)了解版本详情。
版本已更新至OpenHarmony 3.1.3 Release,点击[此处](zh-cn/release-notes/OpenHarmony-v3.1.3-release.md)了解版本详情。
- OpenHarmony 3.0 LTS版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.0-LTS.md)了解版本详情。
该版本已更新至OpenHarmony 3.0.5 LTS,点击[此处](zh-cn/release-notes/OpenHarmony-v3.0.5-LTS.md)了解版本详情。
该版本已更新至OpenHarmony 3.0.6 LTS,点击[此处](zh-cn/release-notes/OpenHarmony-v3.0.6-LTS.md)了解版本详情。
- OpenHarmony 2.2 Beta2版本:点击[此处](zh-cn/release-notes/OpenHarmony-v2.2-beta2.md)了解版本详情。
......@@ -34,7 +34,7 @@
### 历史稳定版本
OpenHarmony_v1.x_release:OpenHarmony 1.1.4 LTS稳定版本,点击[此处](zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md)了解版本详情。
OpenHarmony_v1.x_release:OpenHarmony 1.1.5 LTS稳定版本,点击[此处](zh-cn/release-notes/OpenHarmony-v1.1.5-LTS.md)了解版本详情。
如需了解更多版本详情,点击[此处](zh-cn/release-notes/)
......
......@@ -137,9 +137,9 @@
| Name | Description |
| -------- | ---------------------- |
| Top | Top edge in the vertical direction. |
| Center<sup>(deprecated) </sup> | Center position in the vertical direction.<br> This API is deprecated since API version 9. |
| Center<sup>(deprecated) </sup> | Center position in the vertical direction.<br>This API is deprecated since API version 9. |
| Bottom | Bottom edge in the vertical direction. |
| Baseline<sup>(deprecated) </sup> | Text baseline position in the cross axis direction.<br> This API is deprecated since API version 9.|
| Baseline<sup>(deprecated) </sup> | Text baseline position in the cross axis direction.<br>This API is deprecated since API version 9. |
| Start | Start position in the horizontal direction. |
| Middle<sup>(deprecated) </sup> | Center position in the horizontal direction.<br>This API is deprecated since API version 9. |
| End | End position in the horizontal direction. |
......@@ -249,7 +249,7 @@
| End | The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one.|
| SpaceBetween | The child components are evenly distributed along the main axis. The space between any two adjacent components is the same. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same.|
| SpaceAround | The child components are evenly distributed along the main axis. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components.|
| SpaceEvenly | The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same.|
| SpaceEvenly | The child components are evenly distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between any two adjacent components are the same. |
## ItemAlign
......@@ -355,9 +355,9 @@
| Name | Description |
| -------- | -------------------------------------- |
| Clip | Extra-long text is truncated. |
| Clip | Extra-long text is clipped. |
| Ellipsis | An ellipsis (...) is used to represent clipped text.|
| None | No truncation or ellipsis is used for extra-long text. |
| None | No clipping or ellipsis is used for extra-long text. |
## TextDecorationType
......@@ -413,9 +413,9 @@
| Name | Description |
| ----------- | -------------------- |
| None | Copy and paste is not allowed. |
| InApp | Intra-application copy and paste is allowed.|
| LocalDevice | Intra-device copy and paste is allowed.|
| None | Copy is not allowed. |
| InApp | Intra-application copy is allowed.|
| LocalDevice | Intra-device copy is allowed.|
## HitTestMode<sup>9+</sup>
......
......@@ -40,6 +40,22 @@ For easier maintenance and evolution, comply with the following principles when
12. When software introduction depends on other dependency software, it is not allowed to nest the dependency software in the subdirectory of the software introduction, and all dependency softwares must be placed in separate repository, and name it in the format of **third_party_*****softwareName***, because nested placement of dependency software may lead to multiple versions of the same software, old versions of security vulnerabilities cannot be fixed in a timely, and will risk the opensource compliance issues.
- Dependency software are named in the compiled BUILD.gn with part name by prefixing the newly software introduction name, e.g. part_name = "software_introduction_name_dependency software_name".
- The inter-component dependencies between software introduction and dependency software are resolved via external_deps.
13. OpenHarmony's archiving directory requirements for third-party software introduction.
- If you don't have a really good reason to store it elsewhere and under one of the permitted licenses belongs in third_party.
- For the dedicated third-party software introduction which belongs to the specail devboard, and is is not suitable introduced into the OpenHarmony platform, you could apply to store it in the following locations, Naming it in the format of **softwareName**, where **softwareName** must be an official name, and create README.OpenSource description file in the corresponding directory; Creating BUILD.gn to build it independently to support the automatic collection of open source obligation declaration.
```
device/soc/$(SOC_COMPANY)/third_party
device/board/$(BOARD_COMPANY)/third_party
vendor/$(PRODUCT_COMPANY)/third_party
```
14. Precompiled binary or toolchain used in the OpenHarmony, the following information needs to be provided.
- The source code corresponding to the pre-compiled binary or toolchain, which needs to store the corresponding source code in the OpenHarmony community, and provide the corresponding build guide, and provide open source obligation statement guide;
- Third-party software introduction for precompiled binary or toolchain, need to meet the principles 1 ~ 13;
- The [prebuilt toolchain's description documentation](./prebuilts-readme-template.md): including source code acquisition address, build instructions, update methods, archived in the toolchain root directory with the toolchain build;
- The root directory corresponding to the pre-compiled binary or toolchain needs to provide notice file of the full open source obligation statement;
- If the precompiled binary files come from upstream service platform (e.g. npm packages, etc.). We need to provide the following information in the place where the binary is archived, first we need to provide a general description with the name **README**, include the following information: background description of the introduction and official website; next we need to provide a opensource obligation statement file with the name **NOTICE**, include the following information: software name, version, copyrights, and license information of every third-party open-source software.
### Software Introduction Process
......@@ -64,10 +80,10 @@ Follow the process described in the [SIG Management Regulations](https://gitee.c
| Check Item| Description| Self-Check Result Example|
| :----- | :----- | :----- |
| Software name| Provide the official name of the software and the repository name to which the software is introduced. The repository name is in the format of **third_party**_**softwareName**.| third_party_**softwareName**|
| Official website| Provide the official website link of the software.| https://softwaresite |
| Official website| Provide the official website link of the software.| <https://softwaresite> |
| Software version| Provide the version number of the software to be introduced. The version number must be an official version number released by the community. Do not modify the version number or introduce a version that is not officially released.| 1.0.0 |
| Software version release date| Provide the official release date of the software version.| 2021.01.01 |
| Software version address| Provide the official download URL of the version. Note that the URL must be able to locate the release package of the specific version.| https://gitee.com/softwarecodesite/v1.0.0.zip |
| Software version address| Provide the official download URL of the version. Note that the URL must be able to locate the release package of the specific version.| <https://gitee.com/softwarecodesite/v1.0.0.zip> |
| Software license| Provide the official license name of the version and the relative path of the license file. If there are multiple licenses, list them all and describe their relationship, for example, And, Or, or different licenses for different directories.| Apache-2.0 |
| Software lifecycle| Describe whether the software has an LTS version, how frequent a version is released, code submitted to the community in the last year, issue resolution status, and whether end of maintenance or evolution is notified.| No LTS version; one version released every six months; 10 code submissions in the last six months|
| Security vulnerabilities| List disclosed security vulnerabilities in the software, including the vulnerability number, severity, link, and whether patches or solutions are available.| No disclosed vulnerabilities.|
......@@ -121,9 +137,9 @@ Confirm the issues found by the OAT tool and configure the **OAT.xml** file. For
]
```
#### PMC Review
#### Open source software introduction Review
Refer to the [SIG Management Regulations](https://gitee.com/openharmony/community/tree/master/sig). The PMC will arrange the SIG request review and repository construction based on the received PR.
Refer to the [SIG-Architecture](https://gitee.com/openharmony/community/blob/master/sig/sig-architecture/sig-architecture_cn.md). The SIG-Architecture will arrange the review of the applying of creating new repository.
### License Requirements for Third-Party Open-Source Software
......@@ -131,66 +147,66 @@ Refer to the [SIG Management Regulations](https://gitee.com/openharmony/communit
2. The software license must be compatible with the license for the code repository.
3. The following licenses for third-party open-source software are recommended in the OpenHarmony project:
* Apache License 2.0
* Mulan Permissive Software License, Version 2
* BSD 2-clause
* BSD 3-clause
* DOM4J License
* PostgreSQL License
* Eclipse Distribution License 1.0
* MIT
* ISC
* ICU
* University of Illinois/NCSA
* W3C Software License
* zlib/libpng
* Academic Free License 3.0
* Python Software Foundation License
* Python Imaging Library Software License
* Boost Software License Version 1.0
* WTF Public License
* UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
* Zope Public License 2.0
- Apache License 2.0
- Mulan Permissive Software License, Version 2
- BSD 2-clause
- BSD 3-clause
- DOM4J License
- PostgreSQL License
- Eclipse Distribution License 1.0
- MIT
- ISC
- ICU
- University of Illinois/NCSA
- W3C Software License
- zlib/libpng
- Academic Free License 3.0
- Python Software Foundation License
- Python Imaging Library Software License
- Boost Software License Version 1.0
- WTF Public License
- UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
- Zope Public License 2.0
4. The following licenses for third-party open-source software are not recommended in the OpenHarmony project:
* GNU GPL 1, 2, 3
* GNU Affero GPL 3
* GNU LGPL 2, 2.1, 3
* QPL
* Sleepycat License
* Server Side Public License (SSPL) version 1
* Code Project Open License (CPOL)
* BSD-4-Clause/BSD-4-Clause (University of California-Specific)
* Facebook BSD+Patents license
* NPL 1.0/NPL 1.1
* The Solipsistic Eclipse Public License
* The "Don't Be A Dick" Public License
* JSON License
* Binary Code License (BCL)
* Intel Simplified Software License
* JSR-275 License
* Microsoft Limited Public License
* Amazon Software License (ASL)
* Java SDK for Satori RTM license
* Redis Source Available License (RSAL)
* Booz Allen Public License
* Creative Commons Non-Commercial
* Sun Community Source License 3.0
* Common Development and Distribution Licenses: CDDL 1.0 and CDDL 1.1
* Common Public License: CPL 1.0
* Eclipse Public License: EPL 1.0
* IBM Public License: IPL 1.0
* Mozilla Public Licenses: MPL 1.0, MPL 1.1, and MPL 2.0
* Sun Public License: SPL 1.0
* Open Software License 3.0
* Erlang Public License
* UnRAR License
* SIL Open Font License
* Ubuntu Font License Version 1.0
* IPA Font License Agreement v1.0
* Ruby License
* Eclipse Public License 2.0: EPL 2.0
- GNU GPL 1, 2, 3
- GNU Affero GPL 3
- GNU LGPL 2, 2.1, 3
- QPL
- Sleepycat License
- Server Side Public License (SSPL) version 1
- Code Project Open License (CPOL)
- BSD-4-Clause/BSD-4-Clause (University of California-Specific)
- Facebook BSD+Patents license
- NPL 1.0/NPL 1.1
- The Solipsistic Eclipse Public License
- The "Don't Be A Dick" Public License
- JSON License
- Binary Code License (BCL)
- Intel Simplified Software License
- JSR-275 License
- Microsoft Limited Public License
- Amazon Software License (ASL)
- Java SDK for Satori RTM license
- Redis Source Available License (RSAL)
- Booz Allen Public License
- Creative Commons Non-Commercial
- Sun Community Source License 3.0
- Common Development and Distribution Licenses: CDDL 1.0 and CDDL 1.1
- Common Public License: CPL 1.0
- Eclipse Public License: EPL 1.0
- IBM Public License: IPL 1.0
- Mozilla Public Licenses: MPL 1.0, MPL 1.1, and MPL 2.0
- Sun Public License: SPL 1.0
- Open Software License 3.0
- Erlang Public License
- UnRAR License
- SIL Open Font License
- Ubuntu Font License Version 1.0
- IPA Font License Agreement v1.0
- Ruby License
- Eclipse Public License 2.0: EPL 2.0
If you want to introduce the software that complies with the unrecommended licenses listed in **4** or other licenses that are not mentioned, send an email to oh-legal@openatom.io.
......
Prebuilts for Clang/LLVM-based tools used in OpenHarmony
====================================================
1. For the latest version of this doc, please make sure to visit:
[OpenHarmony Clang/LLVM-based Tools Readme Doc](https://gitee.com/openharmony/third_party_llvm-project/blob/master/llvm-build/README.md)
2. Build Instructions
------------------
```
# Get source code
repo init -u https://gitee.com/openharmony/manifest.git -b llvm_toolchain-dev
repo sync -c
repo forall -c 'git lfs pull'
cp -r toolchain/llvm-project/llvm-build toolchain
# Build Clang/LLVM-based prebuilts tool
./toolchain/llvm-project/llvm-build/env_prepare.sh
python3 ./toolchain/llvm-build/build.py
```
3. Update Prebuilts
----------------
From an OpenHarmony project run:
```
$ ./build/prebuilts_download.sh
```
......@@ -59,7 +59,8 @@ import image from '@ohos.multimedia.image'
import media from '@ohos.multimedia.media'
// 创建CameraManager对象
let cameraManager = await camera.getCameraManager(null)
context: any = getContext(this)
let cameraManager = await camera.getCameraManager(this.context)
if (!cameraManager) {
console.error('Failed to get the CameraManager instance');
}
......@@ -78,14 +79,10 @@ for (let index = 0; index < cameraArray.length; index++) {
}
// 创建相机输入流
let cameraInput
await cameraManager.createCameraInput(cameraArray[0].cameraId).then((input) => {
console.log('Promise returned with the CameraInput instance');
cameraInput = input
})
let cameraInput = await cameraManager.createCameraInput(cameraArray[0])
// 获取相机设备支持的输出流能力
let cameraOutputCap = await camera.getSupportedOutputCapability(cameraInput);
let cameraOutputCap = await cameraManager.getSupportedOutputCapability(cameraArray[0]);
if (!cameraOutputCap) {
console.error("outputCapability outputCapability == null || undefined")
} else {
......@@ -112,8 +109,8 @@ if (!metadataObjectTypesArray) {
console.error("createOutput metadataObjectTypesArray == null || undefined")
}
// 创建预览输出流
let previewOutput = await camera.createPreviewOutput(previewProfilesArray[0], surfaceId)
// 创建预览输出流,其中参数 surfaceId 参考下面 XComponent 组件,预览流为XComponent组件提供的surface
let previewOutput = await cameraManager.createPreviewOutput(previewProfilesArray[0], surfaceId)
if (!previewOutput) {
console.error("Failed to create the PreviewOutput instance.")
}
......@@ -123,7 +120,7 @@ let imageReceiver = await image.createImageReceiver(1920, 1080, 4, 8)
// 获取照片显示SurfaceId
let photoSurfaceId = await imageReceiver.getReceivingSurfaceId()
// 创建拍照输出流
let photoOutput = await this.camera.createPhotoOutput(photoProfilesArray[0], photoSurfaceId)
let photoOutput = await cameraManager.createPhotoOutput(photoProfilesArray[0], photoSurfaceId)
if (!photoOutput) {
console.error('Failed to create the PhotoOutput instance.');
return;
......@@ -155,20 +152,21 @@ let videoConfig = {
// 创建录像输出流
let videoRecorder
await media.createVideoRecorder().then((recorder) => {
media.createVideoRecorder().then((recorder) => {
console.log('createVideoRecorder called')
videoRecorder = recorder
})
// 设置视频录制的参数
await videoRecorder.prepare(videoConfig)
videoRecorder.prepare(videoConfig)
//获取录像SurfaceId
await videoRecorder.getInputSurface().then((id) => {
let videoSurfaceId
videoRecorder.getInputSurface().then((id) => {
console.log('getInputSurface called')
videoSurfaceId = id
})
// 创建VideoOutput对象
let videoOutput = camera.createVideoOutput(videoProfilesArray[0], videoSurfaceId)
let videoOutput = await cameraManager.createVideoOutput(videoProfilesArray[0], videoSurfaceId)
if (!videoOutput) {
console.error('Failed to create the videoOutput instance.');
return;
......@@ -205,11 +203,11 @@ build() {
```typescript
function getImageReceiverSurfaceId() {
var receiver = image.createImageReceiver(640, 480, 4, 8)
let receiver = image.createImageReceiver(640, 480, 4, 8)
console.log(TAG + 'before ImageReceiver check')
if (receiver !== undefined) {
console.log('ImageReceiver is ok')
surfaceId1 = await receiver.getReceivingSurfaceId()
surfaceId1 = receiver.getReceivingSurfaceId()
console.log('ImageReceived id: ' + JSON.stringify(surfaceId1))
} else {
console.log('ImageReceiver is not ok')
......@@ -399,17 +397,17 @@ videoOutput.start(async (err) => {
});
// 开始录像
await videoRecorder.start().then(() => {
videoRecorder.start().then(() => {
console.info('videoRecorder start success');
}
// 停止录像
await videoRecorder.stop().then(() => {
videoRecorder.stop().then(() => {
console.info('stop success');
}
// 停止录像输出流
await videoOutput.stop((err) => {
videoOutput.stop((err) => {
if (err) {
console.error('Failed to stop the video output ${err.message}');
return;
......@@ -424,22 +422,22 @@ await videoOutput.stop((err) => {
```typescript
// 停止当前会话
await captureSession.stop()
captureSession.stop()
// 释放相机输入流
await cameraInput.release()
cameraInput.release()
// 释放预览输出流
await previewOutput.release()
previewOutput.release()
// 释放拍照输出流
await photoOutput.release()
photoOutput.release()
// 释放录像输出流
await videoOutput.release()
videoOutput.release()
// 释放会话
await captureSession.release()
captureSession.release()
// 会话置空
captureSession = null
......
# 页面级变量的状态管理
@State、@Prop、@Link、@Provide、Consume、@ObjectLink、@Observed和@Watch用于管理页面级变量的状态。
@State、@Prop、@Link、@Provide、@Consume、@ObjectLink、@Observed和@Watch用于管理页面级变量的状态。
请参考[状态变量多种数据类型声明的使用限制](./arkts-restrictions-and-extensions.md)了解@State、@Provide、 @Link和@Consume四种状态变量的约束条件。
......
......@@ -92,9 +92,6 @@ app对象包含应用全局配置信息,内部结构说明参见表2。
| vendor | 标识对应用开发厂商的描述。字符串长度不超过255字节。 | 字符串 | 可缺省,缺省值为空 |
| version | 标识应用的版本信息。参考表3。 | 对象 | 否 |
| apiVersion | 标识应用程序所依赖的OpenHarmony API版本。参考表4。 | 对象 | 可缺省,缺省值为空 |
| singleton | 标识应用是否开启单例模式,仅支持系统应用,三方应用配置不生效。如果配置为true,在多用户场景下,该应用仍然单实例运行,不会随用户切换而变动,该字段从API8开始支持。 | 布尔值 | 可缺省,缺省值为false |
| removable | 标识应用是否可卸载,仅支持系统应用,三方应用配置不生效,该字段从API8开始支持。 | 布尔值 | 可缺省,缺省值为true |
| userDataClearable | 标识是否允许应用清除用户数据,仅支持系统应用,三方应用配置不生效,该字段从API8开始支持。 | 布尔值 | 可缺省,缺省值为true |
表3 version内部结构说明
......
......@@ -221,7 +221,7 @@
- [@ohos.multimodalInput.inputDevice (输入设备)](js-apis-inputdevice.md)
- [@ohos.multimodalInput.inputDeviceCooperate (键鼠穿越管理)](js-apis-cooperate.md)
- [@ohos.multimodalInput.inputEvent (输入事件)](js-apis-inputevent.md)
- [@ohos.multimodalInput.inputEventClient (注入按键)](js-apis-inputeventclient.md)
- [@ohos.multimodalInput.inputEventClient (按键注入)](js-apis-inputeventclient.md)
- [@ohos.multimodalInput.inputMonitor (输入监听)](js-apis-inputmonitor.md)
- [@ohos.multimodalInput.keyCode (键值)](js-apis-keycode.md)
- [@ohos.multimodalInput.keyEvent (按键输入事件)](js-apis-keyevent.md)
......
......@@ -34,7 +34,7 @@ create(options: AnimatorOptions): AnimatorResult
**示例:**
```js
var options = {
let options = {
duration: 1500,
easing: 'friction',
delay: 0,
......@@ -79,7 +79,7 @@ reset(options: AnimatorOptions): void
**示例:**
```js
var options = {
let options = {
duration: 1500,
easing: 'friction',
delay: 0,
......@@ -266,7 +266,7 @@ export default {
animator: null
},
onInit() {
var options = {
let options = {
duration: 1500,
easing: 'friction',
delay: 0,
......@@ -279,7 +279,7 @@ export default {
this.animator = animator.create(options);
},
Show() {
var options1 = {
let options1 = {
duration: 1500,
easing: 'friction',
delay: 0,
......@@ -294,7 +294,7 @@ export default {
} catch(error) {
console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`);
}
var _this = this;
let _this = this;
this.animator.onframe = function(value) {
_this.divWidth = value;
_this.divHeight = value;
......@@ -353,7 +353,7 @@ createAnimator(options: AnimatorOptions): AnimatorResult
**示例:**
```js
var options = {
let options = {
duration: 1500,
easing: 'friction',
delay: 0,
......
......@@ -24,9 +24,9 @@ import Want from '@ohos.application.Want';
| uri | 只读 | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 |
| type | 只读 | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:"text/xml" 、 "image/*"等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| flags | 只读 | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](js-apis-featureAbility.md#flags说明)。 |
| action | 只读 | string | 否 | 表示action选项描述。 |
| parameters | 只读 | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br>ohos.aafwk.callerPid 表示拉起方的pid。<br>ohos.aafwk.param.callerToken 表示拉起方的token。<br>ohos.aafwk.param.callerUid 表示发起方的uid。[Bundle](js-apis-Bundle.md)模块中userId参数,可用于获取应用信息、包信息等,具体参考:[Bundle](js-apis-Bundle.md)。 |
| entities | 只读 | Array\<string> | 否 | 表示entities相关描述。 |
| action | 只读 | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。 |
| parameters | 只读 | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br>ohos.aafwk.callerPid 表示拉起方的pid。<br>ohos.aafwk.param.callerToken 表示拉起方的token。<br>ohos.aafwk.param.callerUid 表示[bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。 |
| entities | 只读 | Array\<string> | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器),在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。 |
| moduleName<sup>9+</sup> | 只读 | string | 否 | 表示待启动的Ability所属的模块(module)。 |
**示例:**
......
......@@ -8,17 +8,17 @@
## 使用说明
通过abilityDelegator中的executeShellCommand方法来获取。
通过abilityDelegator中的[executeShellCommand](js-apis-application-abilityDelegator.md#executeshellcommand)方法来获取。
```js
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator;
var cmd = "cmd";
var timeout = 100;
import AbilityDelegatorRegistry from "@ohos.application.abilityDelegatorRegistry";
let abilityDelegator;
let cmd = "cmd";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => {
console.info("executeShellCommand promise");
abilityDelegator.executeShellCommand(cmd, (err: any, data: any) => {
console.info("executeShellCommand callback, failed: ", err);
console.info("executeShellCommand callback, success: ", data);
});
```
......@@ -30,5 +30,5 @@ Shell命令执行结果
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------- | ------ | ---- | ---- | ------------------------------------------------------------ |
| stdResult | string | 是 | 是 | 标准输出内容 |
| exitCode | number | 是 | 是 | 结果码 |
| stdResult | string | 是 | 是 | 标准输出内容 |
| exitCode | number | 是 | 是 | 结果码 |
......@@ -9,7 +9,7 @@
## 导入模块
```
import defaultAppMgr from '@ohos.bundle.defaultAppManager'
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
```
## defaultAppMgr.ApplicationType
......
......@@ -60,7 +60,7 @@ buffer数组的列表。
## EncodingBlob
证书链数据,在证书链校验时,作为入参传入
带编码格式的证书二进制数组
### 属性
......@@ -1029,7 +1029,7 @@ console.info("key hex:" + uint8ArrayToShowStr(encodedKey.data)); // 输出全
getEncoded() : DataBlob
以同步方法,获取二进制形式的密钥内容。
以同步方法,获取二进制形式的密钥内容。公钥格式满足ASN.1语法、X.509规范、DER编码格式。
**系统能力:** SystemCapability.Security.CryptoFramework
......@@ -1065,7 +1065,7 @@ console.info("key encoded:" + Uint8ArrayToShowStr(encodedKey.data));
getEncoded() : DataBlob
以同步方法,获取二进制形式的密钥内容。
以同步方法,获取二进制形式的密钥内容。私钥格式满足ASN.1语法,PKCS#8规范、DER编码方式。
**系统能力:** SystemCapability.Security.CryptoFramework
......@@ -1437,11 +1437,9 @@ keyGenPromise.then( keyPair => {
**密钥转换说明**
1. RSA二进制密钥数据,按keysize(32位) ,nsize(keysize/8), esize(e实际长度),dsize(keysize/8),nval(大数n的二进制数据),eval(大数e的二进制数据),dval(大数d的二进制数据)拼接形成。
2. RSA二进制密钥数据中,nsize和dsize为密钥位数/8,esize为具体的实际长度。
3. RSA私钥数据需要包含keysize,nsize,esize,dsize,nval,eval,dval的全部数据,公钥材料中dsize设置为0,缺省dval的数据。
4. RSA二进制密钥数据中,keysize、nsize、esize和dsize为32位二进制数据,数据的大小端格式请按设备CPU默认格式,密钥材料(nval、eval、dval)统一为大端格式。
5. convertKey接口中,公钥和私钥二进制数据为可选项,可单独传入公钥或私钥的数据,生成对应只包含公钥或私钥的KeyPair对象。
1. 非对称密钥(RSA、ECC)的公钥和私钥调用getEncoded()方法后,分别返回X.509格式和PKCS#8格式的二进制数据,此数据可用于跨应用传输或持久化存储。
2. 当调用convertKey方法将外来二进制数据转换为算法库非对称密钥对象时,公钥应满足ASN.1语法、X.509规范、DER编码格式,私钥应满足ASN.1语法、PKCS#8规范、DER编码格式。
3. convertKey方法中,公钥和密钥二进制数据非必选项,可单独传入公钥或私钥的数据,生成对应只包含公钥或私钥的KeyPair对象。
## cryptoFramework.createCipher
......
......@@ -77,10 +77,12 @@ createFileAccessHelper(context: Context, wants: Array&lt;Want&gt;) : FileAccessH
let fileAccesssHelper = null;
// wantInfo 从getFileAccessAbilityInfo()获取
// 创建只连接媒体库服务的helper对象
let wantInfo = {
let wantInfos = [
{
"bundleName": "com.ohos.medialibrary.medialibrarydata",
"abilityName": "FileExtensionAbility",
}
},
]
try {
fileAccesssHelper = fileAccess.createFileAccessHelper(this.context, wantInfos);
if (!fileAccesssHelper)
......@@ -211,7 +213,7 @@ listFile(filter?: Filter) : FileIterator
let fileIterator = rootInfo.listFile();
// 含过滤器实现的listFile
// let fileIterator = rootInfo.listFile(filter);
if (fileIterator) {
if (!fileIterator) {
console.error("listFile interface returns an undefined object");
return;
}
......@@ -261,7 +263,7 @@ scanFile(filter?: Filter) : FileIterator
let fileIterator = rootInfo.scanFile();
// 含过滤器实现的scanFile
// let fileIterator = rootInfo.scanFile(filter);
if (fileIterator) {
if (!fileIterator) {
console.error("scanFile interface returns undefined object");
return;
}
......@@ -311,7 +313,7 @@ listFile(filter?: Filter) : FileIterator
let fileIterator = fileInfoDir.listFile();
// 含过滤器实现的listFile
// let fileIterator = rootInfo.listFile(filter);
if (fileIterator) {
if (!fileIterator) {
console.error("listFile interface returns an undefined object");
return;
}
......@@ -362,7 +364,7 @@ scanFile(filter?: Filter) : FileIterator;
let fileIterator = fileInfoDir.scanFile();
// 含过滤器实现的scanFile
// let fileIterator = rootInfo.scanFile(filter);
if (fileIterator) {
if (!fileIterator) {
console.error("scanFile interface returns an undefined object");
return;
}
......@@ -451,12 +453,12 @@ mkDir(parentUri: string, displayName: string) : Promise&lt;string&gt;
let dirName = "dirTest"
let dirUri = null;
try {
dirUri = await fileAccessHelper.mkDir(sourceUri, displayName)
dirUri = await fileAccessHelper.mkDir(sourceUri, dirName)
if (!dirUri) {
console.error("mkDir return undefined object");
return;
}
console.log("mkDir sucess, fileUri: " + JSON.stringify(fileUri));
console.log("mkDir sucess, dirUri: " + JSON.stringify(dirUri));
} catch (error) {
console.error("mkDir failed, error " + error);
};
......
......@@ -68,7 +68,7 @@ stat(path: string): Promise&lt;Stat&gt;
```js
let filePath = pathDir + "test.txt";
fileio.stat(filePath).then(function(stat){
console.info("getFileInfo succeed:"+ JSON.stringify(stat));
console.info("getFileInfo succeed, the size of file is " + stat.size);
}).catch(function(err){
console.info("getFileInfo failed with error:"+ err);
});
......@@ -153,7 +153,7 @@ opendir(path: string): Promise&lt;Dir&gt;
```js
let dirPath = pathDir + "/testDir";
fileio.opendir(dirPath).then(function(dir){
console.info("opendir succeed:"+ JSON.stringify(dir));
console.info("opendir succeed");
}).catch(function(err){
console.info("opendir failed with error:"+ err);
});
......@@ -1178,7 +1178,7 @@ fstat(fd: number): Promise&lt;Stat&gt;
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
fileio.fstat(fd).then(function(stat){
console.info("fstat succeed:"+ JSON.stringify(stat));
console.info("fstat succeed, the size of file is "+ stat.size);
}).catch(function(err){
console.info("fstat failed with error:"+ err);
});
......@@ -1525,7 +1525,7 @@ lstat(path: string): Promise&lt;Stat&gt;
```js
let filePath = pathDir + "/test.txt";
fileio.lstat(filePath).then(function(stat){
console.info("get link status succeed:"+ JSON.stringify(stat));
console.info("get link status succeed, " + the size of file is + stat.size);
}).catch(function(err){
console.info("get link status failed with error:"+ err);
});
......@@ -3166,7 +3166,7 @@ read(): Promise&lt;Dirent&gt;
```js
dir.read().then(function (dirent){
console.log("read succeed:"+JSON.stringify(dirent));
console.log("read succeed, the name of dirent is " + dirent.name);
}).catch(function(err){
console.info("read failed with error:"+ err);
});
......@@ -3193,7 +3193,7 @@ read(callback: AsyncCallback&lt;Dirent&gt;): void
dir.read(function (err, dirent) {
if (dirent) {
// do something
console.log("read succeed:"+JSON.stringify(dirent));
console.log("read succeed, the name of file is " + dirent.name);
}
});
```
......
# 组合按键
InputConsumer模块提供对按键事件的监听
组合按键订阅模块,用于处理组合按键的订阅
> **说明:**
>
......@@ -21,7 +21,7 @@ import inputConsumer from '@ohos.multimodalInput.inputConsumer';
on(type: "key", keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;): void
开始监听组合按键事件, 当满足条件的组合按键输入事件发生时,将keyOptions回调到入参callback表示的回调函数上
订阅组合按键,当满足条件的组合按键输入事件发生时,使用Callback异步方式上报组合按键数据
**系统能力:** SystemCapability.MultimodalInput.Input.InputConsumer
......@@ -29,22 +29,20 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;): v
| 参数 | 类型 | 必填 | 说明 |
| ---------- | -------------------------- | ---- | ---------------------------------------- |
| type | string | 是 | 监听输入事件类型,只支持“key”。 |
| keyOptions | [keyOptions](#keyoptions) | 是 | 组合键选项,用来指定组合键输入时应该符合的条件。 |
| callback | Callback&lt;KeyOptions&gt; | 是 | 回调函数。当满足条件的按键输入产生时,回调到此函数,以传入的KeyOptions为入参。 |
| type | string | 是 | 事件类型,目前只支持”key“。 |
| keyOptions | [keyOptions](#keyoptions) | 是 | 组合键选项。 |
| callback | Callback&lt;KeyOptions&gt; | 是 | 回调函数,当满足条件的组合按键输入事件发生时,异步上报组合按键数据。 |
**示例:**
```js
let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 }
let callback = function (keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
}
let powerKeyCode = 18;
try {
inputConsumer.on(inputConsumer.SubscribeType.KEY, keyOptions, callback);
inputConsumer.on("key", {preKeys: [], finalKey: powerKeyCode, isFinalKeyDown: true, finalKeyDownDuration: 0}, keyOptions => {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
});
} catch (error) {
console.info(`inputConsumer.on, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`);
console.log(`Subscribe failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -53,7 +51,7 @@ try {
off(type: "key", keyOptions: KeyOptions, callback?: Callback&lt;KeyOptions&gt;): void
停止监听组合按键事件
取消订阅组合按键
**系统能力:** SystemCapability.MultimodalInput.Input.InputConsumer
......@@ -61,35 +59,49 @@ off(type: "key", keyOptions: KeyOptions, callback?: Callback&lt;KeyOptions&gt;):
| 参数 | 类型 | 必填 | 说明 |
| ---------- | -------------------------- | ---- | ------------------------------- |
| type | string | 是 | 监听输入事件类型,只支持“key”。 |
| keyOptions | [keyOptions](#keyoptions) | 是 | 开始监听时传入的keyOptions。 |
| callback | Callback&lt;KeyOptions&gt; | 是 | 开始监听时与KeyOption一同传入的回调函数&nbsp;。 |
| type | string | 是 | 事件类型,当前只支持”key“。 |
| keyOptions | [keyOptions](#keyoptions) | 是 | 组合键选项。 |
| callback | Callback&lt;KeyOptions&gt; | 否 | 需要取消订阅的回调函数,若无此参数,则取消当前应用的组合键选项已订阅的所有回调函数。 |
**示例:**
```js
let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 }
// 取消订阅单个回调函数
let callback = function (keyOptions) {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
}
let keyOption = {preKeys: [], finalKey: powerKeyCode, isFinalKeyDown: true, finalKeyDownDuration: 0};
try {
inputConsumer.on("key", keyOption, callback);
inputConsumer.off("key", keyOption, callback);
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// 取消订阅所有回调函数
let callback = function (keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
}
let keyOption = {preKeys: [], finalKey: powerKeyCode, isFinalKeyDown: true, finalKeyDownDuration: 0};
try {
inputConsumer.off(inputConsumer.SubscribeType.KEY, keyOptions, callback);
inputConsumer.on("key", keyOption, callback);
inputConsumer.off("key", keyOption);
} catch (error) {
console.info(`inputConsumer.off, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`);
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## KeyOptions
组合键输入事件发生时,组合键满足的选项。
组合键选项。
**系统能力:** SystemCapability.MultimodalInput.Input.InputConsumer
| 参数 | 类型 | 必填 | 说明 |
| -------------------- | ------- | ---- | ------------------------ |
| preKeys | Array | 是 | 组合键前置按键集合,可为空,前置按键无顺序要求。 |
| finalKey | Number | 是 | 组合键最后按键,不能为空。 |
| isFinalKeyDown | boolean | 是 | 组合键最后按键是按下还是抬起,默认是按下。 |
| finalKeyDownDuration | Number | 是 | 组合键最后按键按下持续时长,默认无时长要求。 |
| preKeys | Array | 是 | 前置按键集合,数量范围[0, 4],前置按键无顺序要求。 |
| finalKey | Number | 是 | 最终按键,此项必填,最终按键触发上报回调函数。 |
| isFinalKeyDown | boolean | 是 | 最终按键状态。 |
| finalKeyDownDuration | Number | 是 | 最终按键保持按下持续时间,为0时立即触发回调函数,大于0时,当isFinalKeyDown为true,则最终按键按下超过此时长后触发回调函数,当isFinalKeyDown为false,则最终按键按下到抬起时间小于此时长时触发回调函数。 |
# 注入按键
# 按键注入
InputEventClient模块提供了注入按键能力。
按键注入模块,提供按键注入能力。
> **说明:**
>
......@@ -21,7 +21,7 @@ import inputEventClient from '@ohos.multimodalInput.inputEventClient';
injectEvent({KeyEvent: KeyEvent}): void
注入按键,KeyEvent为注入按键的描述信息
按键注入,当前仅支持返回键(键值2)注入
**系统能力:** SystemCapability.MultimodalInput.Input.InputSimulator
......@@ -29,41 +29,43 @@ injectEvent({KeyEvent: KeyEvent}): void
| 参数 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | --------- |
| KeyEvent | [KeyEvent](#keyevent) | 是 | 注入按键的描述信息 |
| KeyEvent | [KeyEvent](#keyevent) | 是 | 按键注入描述信息。 |
**示例:**
```js
try {
var keyEvent = {
let backKeyDown = {
isPressed: true,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
}
inputEventClient.injectKeyEvent({ KeyEvent: keyEvent });
var keyEvent1 = {
inputEventClient.injectKeyEvent({ KeyEvent: backKeyDown });
let backKeyUp = {
isPressed: false,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
};
inputEventClient.injectKeyEvent({ KeyEvent: keyEvent1 });
inputEventClient.injectKeyEvent({ KeyEvent: backKeyUp });
} catch (error) {
console.info("injectKeyEvent " + error.code + " " + error.message);
console.log(`Failed to inject KeyEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## KeyEvent
注入按键的描述信息。
按键注入描述信息。
**系统能力:** SystemCapability.MultimodalInput.Input.InputSimulator
| 参数 | 类型 | 必填 | 说明 |
| --------------- | ------- | ---- | --------- |
| isPressed | boolean | 是 | 按键是否按下 |
| keyCode | number | 是 | 按键键值 |
| keyDownDuration | number | 是 | 按键按下持续时间 |
| isIntercepted | boolean | 是 | 按键是否可以被拦截 |
| --------------- | ------- | ---- | -------------------------- |
| isPressed | boolean | 是 | 按键是否按下。 |
| keyCode | number | 是 | 按键键值,当前只支持back键。 |
| keyDownDuration | number | 是 | 按键按下持续时间。 |
| isIntercepted | boolean | 是 | 按键是否可以被拦截。 |
......@@ -37,11 +37,11 @@ on(type: "touch", receiver: TouchEventReceiver): void
```js
try {
inputMonitor.on("touch", (data)=> {
console.info(`monitorOnTouchEvent success ${JSON.stringify(data)}`);
console.log(`Monitor on TouchEvent success ${JSON.stringify(data)}`);
return false;
});
} catch (error) {
console.info("onMonitor " + error.code + " " + error.message)
console.log(`Failed to monitor on TouchEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -66,11 +66,11 @@ on(type: "mouse", receiver: Callback&lt;MouseEvent&gt;): void
```js
try {
inputMonitor.on("mouse", (data)=> {
console.info(`monitorOnMouseEvent success ${JSON.stringify(data)}`);
console.log(`Monitor on MouseEvent success ${JSON.stringify(data)}`);
return false;
});
} catch (error) {
console.info("onMonitor " + error.code + " " + error.message)
console.log(`Failed to monitor on MouseEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -95,25 +95,25 @@ off(type: "touch", receiver?: TouchEventReceiver): void
**示例:**
```js
// 取消所有监听。
// 取消监听全局触屏事件
try {
inputMonitor.off("touch");
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
console.log(`Failed to monitor off TouchEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
// 单独取消receiver的监听。
callback:function(data) {
console.info(`call success ${JSON.stringify(data)}`);
console.log(`call success ${JSON.stringify(data)}`);
},
try {
inputMonitor.on("touch", this.callback);
} catch (error) {
console.info("onTouchMonitor " + error.code + " " + error.message)
}
console.log(`Failed to monitor on TouchEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
},
try {
inputMonitor.off("touch",this.callback);
} catch (error) {
console.info("offTouchMonitor " + error.code + " " + error.message)
console.log(`Failed to monitor off TouchEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -135,25 +135,25 @@ off(type: "mouse", receiver?: Callback&lt;MouseEvent&gt;): void
**示例:**
```js
// 取消所有监听。
// 取消监听全局鼠标事件
try {
inputMonitor.off("mouse");
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
console.log(`Failed to monitor off MouseEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
// 单独取消receiver的监听。
callback:function(data) {
console.info(`call success ${JSON.stringify(data)}`);
console.log(`call success ${JSON.stringify(data)}`);
},
try {
inputMonitor.on("mouse", this.callback);
} catch (error) {
console.info("onMouseMonitor " + error.code + " " + error.message)
}
console.log(`Failed to monitor on MouseEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
},
try {
inputMonitor.off("mouse", this.callback);
} catch (error) {
console.info("offMouseMonitor " + error.code + " " + error.message)
console.log(`Failed to monitor off MouseEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -187,6 +187,6 @@ try {
});
inputMonitor.off("touch");
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
console.log(`Failed to monitor off TouchEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -8,7 +8,7 @@ KeyCode模块提供了按键类设备的键值。
## 导入模块
```js
import {KeyCode} from '@ohos.multimodalInput.keyCode'
import {KeyCode} from '@ohos.multimodalInput.keyCode';
```
## KeyCode
......
......@@ -9,7 +9,7 @@ KeyEvent模块提供了设备可以上报的按键事件。
## 导入模块
```js
import {Action,Key,KeyEvent} from '@ohos.multimodalInput.keyEvent';
import {Action, Key, KeyEvent} from '@ohos.multimodalInput.keyEvent';
```
## Action
......@@ -17,8 +17,8 @@ import {Action,Key,KeyEvent} from '@ohos.multimodalInput.keyEvent';
**系统能力**:SystemCapability.MultimodalInput.Input.Core
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| ------ | ------ | ---- | ---- | ---- |
| CANCEL | number | 是 | 否 | 取消 |
| ------ | -------- | ---- | ---- | -------- |
| CANCEL | number | 是 | 否 | 取消按钮 |
| DOWN | number | 是 | 否 | 按下按钮 |
| UP | number | 是 | 否 | 抬起按钮 |
......@@ -27,9 +27,9 @@ import {Action,Key,KeyEvent} from '@ohos.multimodalInput.keyEvent';
**系统能力**:SystemCapability.MultimodalInput.Input.Core
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| ----------- | ------- | ---- | ---- | ------ |
| ----------- | -------- | ---- | ---- | -------------- |
| code | KeyCode | 是 | 否 | 按键码 |
| pressedTime | number | 是 | 否 | 按下时间 |
| pressedTime | number | 是 | 否 | 按下持续的时间 |
| deviceId | number | 是 | 否 | 按键所属设备 |
## KeyEvent
......@@ -37,7 +37,7 @@ import {Action,Key,KeyEvent} from '@ohos.multimodalInput.keyEvent';
**系统能力**:SystemCapability.MultimodalInput.Input.Core
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| ----------- | ------- | ---- | ---- | -------------------- |
| ----------- | -------- | ---- | ---- | ------------------------------ |
| action | Action | 是 | 否 | 按键动作 |
| key | Key | 是 | 否 | 当前发生变化的按键 |
| unicodeChar | number | 是 | 否 | 按键对应的uniCode字符 |
......
......@@ -16,8 +16,8 @@ import {Action,Button,Axis,AxisValue,MouseEvent} from '@ohos.multimodalInput.mou
**系统能力**:SystemCapability.MultimodalInput.Input.Core
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| ----------- | ------ | ---- | ---- | ---------- |
| CANCEL | number | 是 | 否 | 取消 |
| ----------- | -------- | ---- | ---- | -------------------- |
| CANCEL | number | 是 | 否 | 取消动作 |
| MOVE | number | 是 | 否 | 鼠标移动 |
| BUTTON_DOWN | number | 是 | 否 | 鼠标按钮按下 |
| BUTTON_UP | number | 是 | 否 | 鼠标按钮抬起 |
......
......@@ -64,29 +64,57 @@ import tag from '@ohos.nfc.tag';
import tag from '@ohos.nfc.tag';
onCreate(want, launchParam) {
// add other code here
// add other code here...
// want is initialized by nfc service, contains tag info for this found tag
var tagInfo = tag.getTagInfo(want);
if (tagInfo == undefined) {
var tagInfo;
try {
tag.getTagInfo(want);
} catch (error) {
console.log("tag.getTagInfo catched error: " + error);
}
if (tagInfo == null || tagInfo == undefined) {
console.log("no TagInfo to be created, ignore it.");
return;
}
// get the supported technologies for this found tag.
var isNfcATag = false;
var isIsoDepTag = false;
for (var i = 0; i < tagInfo.technology.length; i++) {
if (tagInfo.technology[i] == tag.NFC_A) {
isNfcATag = true;
break;
}
// also check for technology: tag.NFC_B/NFC_F/NFC_V/ISO_DEP/NDEF/MIFARE_CLASSIC/MIFARE_ULTRALIGHT/NDEF_FORMATABLE
if (tagInfo.technology[i] == tag.ISO_DEP) {
isIsoDepTag = true;
}
// also check for technology: tag.NFC_B/NFC_F/NFC_V/NDEF/MIFARE_CLASSIC/MIFARE_ULTRALIGHT/NDEF_FORMATABLE
}
// use NfcA APIs to access the found tag.
if (isNfcATag) {
var nfcA = tag.getNfcATag(taginfo);
var nfcA;
try {
nfcA = tag.getNfcATag(taginfo);
} catch (error) {
console.log("tag.getNfcATag catched error: " + error);
}
// other code to read or write this found tag.
}
// use the same code to handle for "NfcA/NfcB/NfcF/NfcV/IsoDep/Ndef/MifareClassic/MifareUL/NdefFormatable", such as:
// var isoDep = tag.getIsoDepTag(taginfo);
// use getIsoDep APIs to access the found tag.
if (isIsoDepTag) {
var isoDep;
try {
isoDep = tag.getIsoDep(taginfo);
} catch (error) {
console.log("tag.getIsoDep catched error: " + error);
}
// other code to read or write this found tag.
}
// use the same code to handle for "NfcA/NfcB/NfcF/NfcV/Ndef/MifareClassic/MifareUL/NdefFormatable".
}
```
......@@ -154,99 +182,135 @@ getNfcVTag(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag)
| -------- | ---------------- |
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | NFC V类型Tag对象。 |
## tag.getIsoDepTag<sup>9+</sup>
## tag.getIsoDep<sup>9+</sup>
getIsoDepTag(tagInfo: [TagInfo](#taginfo)): [IsoDepTag](js-apis-nfctech.md#isoDepTag9 )
getIsoDep(tagInfo: [TagInfo](#taginfo)): [IsoDepTag](js-apis-nfctech.md#isoDepTag9 )
获取IsoDep类型Tag对象,通过该对象可访问Iso Dep技术类型的Tag。
**需要权限**:ohos.permission.NFC_TAG
获取IsoDep类型Tag对象,通过该对象可访问支持IsoDep技术类型的Tag。
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ---------- | ------------------|
| [IsoDepTag](js-apis-nfctech.md#isodeptag9) | Iso Dep类型Tag对象。 |
## tag.getNdefTag<sup>9+</sup>
| [IsoDepTag](js-apis-nfctech.md#isodeptag9) | IsoDep类型Tag对象,通过该对象访问IsoDep类型的相关接口。 |
getNdefTag(tagInfo: [TagInfo](#taginfo)): [NdefTag](js-apis-nfctech.md#ndeftag9)
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息|
| ------- | -------|
| 3100201 | Tag running state of service is abnormal. |
获取Ndef类型Tag对象,通过该对象可访问Ndef技术类型的Tag。
## tag.getNdef<sup>9+</sup>
getNdef(tagInfo: [TagInfo](#taginfo)): [NdefTag](js-apis-nfctech.md#ndeftag9)
**需要权限**:ohos.permission.NFC_TAG
获取NDEF类型Tag对象,通过该对象可访问支持NDEF技术类型的Tag。
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ---------| -------------- |
| [NdefTag](js-apis-nfctech.md#ndeftag9) | Ndef类型Tag对象。|
| [NdefTag](js-apis-nfctech.md#ndeftag9) | NDEF类型Tag对象,通过该对象访问NDEF类型的相关接口。|
## tag.getMifareClassicTag<sup>9+</sup>
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息|
| ------- | -------|
| 3100201 | Tag running state of service is abnormal. |
getMifareClassicTag(tagInfo: [TagInfo](#taginfo)): [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9)
## tag.getMifareClassic<sup>9+</sup>
获取Mifare Classic类型Tag对象,通过该对象访问Mifare Classic技术类型的Tag。
getMifareClassic(tagInfo: [TagInfo](#taginfo)): [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9)
**需要权限**:ohos.permission.NFC_TAG
获取MIFARE Classic类型Tag对象,通过该对象访问支持MIFARE Classic技术类型的Tag。
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ----------------- | ------------------------|
| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | Mifare Classic类型Tag对象。 |
| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | MIFARE Classic类型Tag对象,通过该对象访问MIFARE Classic类型的相关接口。 |
## tag.getMifareUltralightTag<sup>9+</sup>
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息|
| ------- | -------|
| 3100201 | Tag running state of service is abnormal. |
getMifareUltralightTag(tagInfo: [TagInfo](#taginfo)): [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9)
## tag.getMifareUltralight<sup>9+</sup>
获取Mifare Ultralight类型Tag对象,通过该对象可访问Mifare Ultralight技术类型的Tag。
getMifareUltralight(tagInfo: [TagInfo](#taginfo)): [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9)
**需要权限**:ohos.permission.NFC_TAG
获取MIFARE Ultralight类型Tag对象,通过该对象可访问支持MIFARE Ultralight技术类型的Tag。
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| -------------------- | ---------------------------|
| [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | Mifare Ultralight类型Tag对象。 |
| [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | MIFARE Ultralight类型Tag对象,通过该对象访问MIFARE Ultralight类型的相关接口。 |
## tag.getNdefFormatableTag<sup>9+</sup>
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息|
| ------- | -------|
| 3100201 | Tag running state of service is abnormal. |
getNdefFormatableTag(tagInfo: [TagInfo](#taginfo)): [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag9)
## tag.getNdefFormatable<sup>9+</sup>
获取Ndef Formatable类型Tag对象,通过该对象可访问Ndef Formatable技术类型的Tag。
getNdefFormatable(tagInfo: [TagInfo](#taginfo)): [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag9)
**需要权限**:ohos.permission.NFC_TAG
获取NDEF Formatable类型Tag对象,通过该对象可访问支持NDEF Formatable技术类型的Tag。
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
| **类型** | **说明** |
| ------------------ | --------------------------|
| [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | Ndef Formatable类型Tag对象。 |
| [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | NDEF Formatable类型Tag对象,通过该对象访问NDEF Formatable类型的相关接口。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息|
| ------- | -------|
| 3100201 | Tag running state of service is abnormal. |
## tag.getTagInfo<sup>9+</sup>
getTagInfo(want: Want): [TagInfo](#taginfo)
getTagInfo(want: [Want](js-apis-application-Want.md#Want)): [TagInfo](#taginfo)
从Want中获取TagInfo,Want是被NFC服务初始化,包含了TagInfo所需的属性值。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| want | [Want](js-apis-application-Want.md#Want) | 是 | 分发Ability时,在系统onCreate入口函数的参数中获取。 |
**返回值:**
| **类型** | **说明** |
| ------------------ | --------------------------|
| [TagInfo](#taginfo) | TagInfo对象,用于获取不同技术类型的Tag对象。 |
......@@ -255,8 +319,6 @@ getTagInfo(want: Want): [TagInfo](#taginfo)
NFC服务在读取到标签时给出的对象,通过改对象属性,应用知道该标签支持哪些技术类型,并使用匹配的技术类型来调用相关接口。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
| **参数名** | **类型** | **说明** |
......@@ -268,8 +330,6 @@ NFC服务在读取到标签时给出的对象,通过改对象属性,应用
## NdefRecord<sup>9+</sup>
NDEF标签Record属性的定义,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
| **参数名** | **类型** | **说明** |
| -------- | -------- | -------- |
......@@ -281,8 +341,6 @@ NDEF标签Record属性的定义,参考NDEF标签技术规范《NFCForum-TS-NDE
## 技术类型定义
NFC Tag有多种不同的技术类型,定义常量描述不同的技术类型。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
| **参数名** | **常量值** | **说明** |
| -------- | -------- | -------- |
......@@ -292,15 +350,13 @@ NFC Tag有多种不同的技术类型,定义常量描述不同的技术类型
| NFC_F | 4 | NFC-F(JIS 6319-4)技术。|
| NFC_V | 5 | NFC-V(ISO 15693)技术。|
| NDEF | 6 | NDEF技术。|
| MIFARE_CLASSIC | 8 | Mifare Classic技术。|
| MIFARE_ULTRALIGHT | 9 | Mifare Utralight技术。|
| MIFARE_CLASSIC | 8 | MIFARE Classic技术。|
| MIFARE_ULTRALIGHT | 9 | MIFARE Utralight技术。|
| NDEF_FORMATABLE<sup>9+</sup> | 10 | 可以格式化的NDEF技术。|
## TnfType<sup>9+</sup>
NDEF Record的TNF(Type Name Field)类型值,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
| **参数名** | **常量值** | **说明** |
| -------- | -------- | -------- |
......@@ -315,8 +371,6 @@ NDEF Record的TNF(Type Name Field)类型值,参考NDEF标签技术规范《NFC
## NDEF Record RTD类型定义
NDEF Record的RTD(Record Type Definition)类型值,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
| **参数名** | **常量值** | **说明** |
| -------- | -------- | -------- |
......@@ -326,8 +380,6 @@ NDEF Record的RTD(Record Type Definition)类型值,参考NDEF标签技术规
## NfcForumType<sup>9+</sup>
NFC Forum标准里面Tag类型的定义。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
| **参数名** | **常量值** | **说明** |
| -------- | -------- | -------- |
......@@ -335,25 +387,21 @@ NFC Forum标准里面Tag类型的定义。
| NFC_FORUM_TYPE_2 | 2 | NFC论坛类型2。 |
| NFC_FORUM_TYPE_3 | 3 | NFC论坛类型3。 |
| NFC_FORUM_TYPE_4 | 4 | NFC论坛类型4。 |
| MIFARE_CLASSIC | 101 | Mifare Classic类型。 |
| MIFARE_CLASSIC | 101 | MIFARE Classic类型。 |
## MifareClassicType<sup>9+</sup>
MifareClassic标签类型的定义。
**需要权限**:ohos.permission.NFC_TAG
MIFARE Classic标签类型的定义。
**系统能力**:SystemCapability.Communication.NFC.Core
| **参数名** | **常量值** | **说明** |
| -------- | -------- | -------- |
| TYPE_UNKNOWN | -1 | 未知Mifare类型。 |
| TYPE_CLASSIC | 0 | Mifare Classic类型。|
| TYPE_PLUS | 1 | Mifare Plus类型。|
| TYPE_PRO | 2 | Mifare Pro类型。 |
| TYPE_UNKNOWN | 0 | 未知MIFARE类型。 |
| TYPE_CLASSIC | 1 | MIFARE Classic类型。|
| TYPE_PLUS | 2 | MIFARE Plus类型。|
| TYPE_PRO | 3 | MIFARE Pro类型。 |
## MifareClassicSize<sup>9+</sup>
MifareClassic标签存储大小的定义。
**需要权限**:ohos.permission.NFC_TAG
MIFARE Classic标签存储大小的定义。
**系统能力**:SystemCapability.Communication.NFC.Core
| **参数名** | **常量值** | **说明** |
......@@ -363,15 +411,13 @@ MifareClassic标签存储大小的定义。
| MC_SIZE_2K | 2048 | 每个标签32个扇区,每个扇区4个块。 |
| MC_SIZE_4K | 4096 | 每个标签40个扇区,每个扇区4个块。|
### MifareUltralightType<sup>9+</sup>
MifareUltralight标签类型的定义。
**需要权限**:ohos.permission.NFC_TAG
## MifareUltralightType<sup>9+</sup>
MIFARE Ultralight标签类型的定义。
**系统能力**:SystemCapability.Communication.NFC.Core
| **参数名** | **常量值** | **说明** |
| -------- | -------- | -------- |
| TYPE_UNKOWN | -1 | 未知的 Mifare 类型。 |
| TYPE_ULTRALIGHT | 1 | Mifare Ultralight类型。|
| TYPE_ULTRALIGHT_C | 2 | Mifare UltralightC 类型。 |
| TYPE_UNKOWN | 0 | 未知的 MIFARE 类型。 |
| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight类型。|
| TYPE_ULTRALIGHT_C | 2 | MIFARE UltralightC 类型。 |
<!--no_check-->
\ No newline at end of file
# 鼠标指针
鼠标指针管理模块,用于提供鼠标指针相关属性接口
鼠标指针管理模块,用于查询和设置鼠标指针相关属性
> **说明**:
>
......@@ -12,11 +12,11 @@
import pointer from '@ohos.multimodalInput.pointer';
```
## pointer.setPointerVisibele<sup>9+</sup>
## pointer.setPointerVisible<sup>9+</sup>
setPointerVisible(visible: boolean, callback: AsyncCallback&lt;void&gt;): void
设置鼠标指针显示或者隐藏,使用callback异步回调
设置鼠标指针显示或者隐藏,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -24,18 +24,22 @@ setPointerVisible(visible: boolean, callback: AsyncCallback&lt;void&gt;): void
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------------------------- |
| visible | boolean | 是 | 鼠标指针显示或者隐藏状态,true: 鼠标指针显示; false: 鼠标指针隐藏。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当设置鼠标显示或隐藏成功,err为undefined,否则为错误对象。 |
| visible | boolean | 是 | 鼠标指针是否显示。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例**
```js
try {
pointer.setPointerVisible(true, (err, data) => {
pointer.setPointerVisible(true, (error) => {
if (error) {
console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Set pointer visible success`);
});
} catch (err) {
console.log(`Set pointer visible failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
} catch (error) {
console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -43,7 +47,7 @@ try {
setPointerVisible(visible: boolean): Promise&lt;void&gt;
设置鼠标指针显示或者隐藏,使用Promise方式作为异步方法
设置鼠标指针显示或者隐藏,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -51,23 +55,23 @@ setPointerVisible(visible: boolean): Promise&lt;void&gt;
| 参数 | 类型 | 必填 | 说明 |
| ------- | ------- | ---- | ---------------------------------------- |
| visible | boolean | 是 | 鼠标指针显示或者隐藏状态,true: 鼠标指针显示; false: 鼠标指针隐藏。 |
| visible | boolean | 是 | 鼠标指针是否显示。 |
**返回值**
| 参数 | 说明 |
| ------------------- | ------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。 |
| Promise&lt;void&gt; | Promise对象。 |
**示例**
```js
try {
pointer.setPointerVisible(false).then(data => {
console.log(`Set mouse pointer visible success`);
pointer.setPointerVisible(false).then(() => {
console.log(`Set pointer visible success`);
});
} catch {
console.log(`Set mouse pointer visible failed err=${JSON.stringify(data)}, msg=${JSON.stringify(message)}`);
} catch (error) {
console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -75,7 +79,7 @@ try {
isPointerVisible(callback: AsyncCallback&lt;boolean&gt;): void
获取鼠标指针显示或隐藏状态,使用callback异步回调
获取鼠标指针显示或隐藏状态,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -83,17 +87,21 @@ isPointerVisible(callback: AsyncCallback&lt;boolean&gt;): void
| 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,异步返回查询结果。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,异步返回鼠标指针显示或隐藏状态。 |
**示例**
```js
try {
pointer.isPointerVisible(visible, (err, data) => {
console.log(`The mouse pointer visible attributes is ` + visible);
pointer.isPointerVisible((error, visible) => {
if (error) {
console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
});
} catch (err) {
console.log(`The mouse pointer visible attributes is failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
} catch (error) {
console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -101,7 +109,7 @@ try {
isPointerVisible(): Promise&lt;boolean&gt;
获取鼠标指针显示或隐藏状态,使用Promise方式作为异步方法
获取鼠标指针显示或隐藏状态,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -109,25 +117,21 @@ isPointerVisible(): Promise&lt;boolean&gt;
| 参数 | 说明 |
| ---------------------- | ------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于异步获取结果。 |
| Promise&lt;boolean&gt; | Promise对象,异步返回鼠标指针显示或隐藏状态。 |
**示例**
```js
try {
pointer.isPointerVisible().then((data) => {
console.log(`The mouse pointer visible attributes is success. data=${JSON.stringify(data)}`);
});
} catch (err) {
ponsole.info(`The mouse pointer visible attributes is failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
}
pointer.isPointerVisible().then((visible) => {
console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
});
```
## pointer.setPointerSpeed<sup>9+</sup>
setPointerSpeed(speed: number, callback: AsyncCallback&lt;void&gt;): void
设置鼠标移动速度,使用callback异步回调
设置鼠标移动速度,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -135,18 +139,22 @@ setPointerSpeed(speed: number, callback: AsyncCallback&lt;void&gt;): void
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------- |
| speed | number | 是 | 鼠标移动速度设置挡位值1-11,最大值:11,最小值:1,标准值:5。 |
| callback | AysncCallback&lt;void&gt; | 是 | 回调函数。当设置鼠标速度成功,err为undefined,否则为错误对象。 |
| speed | number | 是 | 鼠标移动速度,范围1-11,默认为5。 |
| callback | AysncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例**
```js
try {
pointer.setPointerSpeed(5, (err, data) => {
pointer.setPointerSpeed(5, (error) => {
if (error) {
console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Set pointer speed success`);
});
} catch (err) {
console.log(`Set pointer speed failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -154,7 +162,7 @@ try {
setPointerSpeed(speed: number): Promise&lt;void&gt;
设置鼠标移动速度,使用Promise异步回调
设置鼠标移动速度,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -162,23 +170,23 @@ setPointerSpeed(speed: number): Promise&lt;void&gt;
| 参数 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----------------------------------- |
| speed | number | 是 | 鼠标移动速度设置挡位值1-11,最大值:11,最小值:1,标准值:5。 |
| speed | number | 是 | 鼠标移动速度,范围1-11,默认为5。 |
**返回值**
| 参数 | 说明 |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
| Promise&lt;void&gt; | Promise对象。 |
**示例**
```js
try {
pointer.setPointerSpeed(5).then(data => {
pointer.setPointerSpeed(5).then(() => {
console.log(`Set pointer speed success`);
});
} catch (err) {
console.log(`Set pointer speed failed err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
} catch (error) {
console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -186,7 +194,7 @@ try {
getPointerSpeed(callback: AsyncCallback&lt;number&gt;): void
获取当前鼠标移动速度,使用callback异步回调
获取鼠标移动速度,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -194,17 +202,21 @@ getPointerSpeed(callback: AsyncCallback&lt;number&gt;): void
| 参数 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,异步返回查询结果。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,异步返回鼠标移动速度。 |
**示例**
```js
try {
pointer.getPointerSpeed(speed, (err, data) => {
console.log(`The pointer speed is ` + speed);
pointer.getPointerSpeed(speed, (error, speed) => {
if (error) {
console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`);
});
} catch (err) {
console.log(`Failed to get the pointer speed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -212,7 +224,7 @@ try {
getPointerSpeed(): Promise&lt;number&gt;
获取当前鼠标移动速度,使用Promise异步回调
获取当前鼠标移动速度,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -220,17 +232,17 @@ getPointerSpeed(): Promise&lt;number&gt;
| 参数 | 说明 |
| --------------------- | ------------------- |
| Promise&lt;number&gt; | Promise实例,用于异步获取结果。 |
| Promise&lt;number&gt; | Promise实例,异步返回鼠标移动速度。 |
**示例**
```js
try {
pointer.getPointerSpeed().then(data => {
console.log(`Get pointer speed success. data=${JSON.stringify(data)}`);
pointer.getPointerSpeed().then(speed => {
console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`);
});
} catch (err) {
console.log(`Get pointer speed failed err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
} catch (error) {
console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -238,7 +250,7 @@ try {
getPointerStyle(windowId: number, callback: AsyncCallback&lt;PointerStyle&gt;): void
获取鼠标样式类型,使用callback异步回调
获取鼠标样式类型,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -246,29 +258,27 @@ getPointerStyle(windowId: number, callback: AsyncCallback&lt;PointerStyle&gt;):
| 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------- |
| windowId | number | 是 | 输入设备的窗口id。 |
| callback | AsyncCallback&lt;[PointerStyle](#pointerstyle9)&gt; | 是 | 回调函数,异步返回查询结果。 |
| windowId | number | 是 | 窗口id。 |
| callback | AsyncCallback&lt;[PointerStyle](#pointerstyle9)&gt; | 是 | 回调函数,异步返回鼠标样式类型。 |
**示例**
```js
// 获取设备的鼠标样式。
import window from '@ohos.window';
var windowClass = null;
window.getTopWindow((err, data) => {
windowClass = data;
windowClass.getProperties((err, data) => {
var windowId = data.id;
window.getTopWindow((error, win) => {
win.getProperties((error, properties) => {
var windowId = properties.id;
if (windowId < 0) {
console.log(`Invalid windowId`);
return;
}
try {
pointer.getPointerStyle(windowId, (err, ret) => {
console.log(`The mouse pointer style is: ` + ret);
pointer.getPointerStyle(windowId, (error, style) => {
console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
});
} catch (err) {
console.log(`Failed to get the pointer style. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
} catch (error) {
console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
});
});
......@@ -278,7 +288,7 @@ window.getTopWindow((err, data) => {
getPointerStyle(windowId: number): Promise&lt;PointerStyle&gt;
获取鼠标样式类型,使用Promise方式作为异步方法
获取鼠标样式类型,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -286,28 +296,26 @@ getPointerStyle(windowId: number): Promise&lt;PointerStyle&gt;
| 参数 | 说明 |
| ---------------------------------------- | ------------------- |
| Promise&lt;[PointerStyle](#pointerstyle9)&gt; | Promise实例,用于异步获取结果。 |
| Promise&lt;[PointerStyle](#pointerstyle9)&gt; | Promise实例,异步返回鼠标样式类型。 |
**示例**
```js
// 获取设备的鼠标样式。
import window from '@ohos.window';
var windowClass = null;
window.getTopWindow((err, data) => {
windowClass = data;
windowClass.getProperties((err, data) => {
var windowId = data.id;
window.getTopWindow((error, win) => {
win.getProperties((error, properties) => {
var windowId = properties.id;
if (windowId < 0) {
console.log(`Invalid windowId`);
return;
}
try {
pointer.getPointerStyle(windowId).then((ret) => {
console.log(`The mouse pointer style is: ` + ret);
pointer.getPointerStyle(windowId).then((style) => {
console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
});
} catch (err) {
console.log(`Get pointer style failed err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
} catch (error) {
console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
});
});
......@@ -317,7 +325,7 @@ window.getTopWindow((err, data) => {
setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback&lt;void&gt;): void
设置鼠标的样式类型,使用callback异步回调
设置鼠标样式类型,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -325,30 +333,28 @@ setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCal
| 参数 | 类型 | 必填 | 说明 |
| ------------ | ------------------------------ | ---- | ----------------------------------- |
| windowId | number | 是 | 输入设备的窗口id。 |
| windowId | number | 是 | 窗口id。 |
| pointerStyle | [PointerStyle](#pointerstyle9) | 是 | 鼠标样式id。 |
| callback | AysncCallback&lt;void&gt; | 是 | 回调函数。当设置样式成功,err为undefined,否则为错误对象。 |
| callback | AysncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例**
```js
// 设置设备的鼠标样式。
import window from '@ohos.window';
var windowClass = null;
window.getTopWindow((err, data) => {
windowClass = data;
windowClass.getProperties((err, data) => {
var windowId = data.id;
window.getTopWindow((error, win) => {
win.getProperties((error, properties) => {
var windowId = properties.id;
if (windowId < 0) {
console.log(`Invalid windowId`);
return;
}
try {
pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, (err) => {
console.log(`Successfully set mouse pointer style`);
pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => {
console.log(`Set pointer style success`);
});
} catch (err) {
console.log(`Failed to set the pointer style. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
} catch (error) {
console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
});
});
......@@ -357,7 +363,7 @@ window.getTopWindow((err, data) => {
setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise&lt;void&gt;
设置鼠标的样式类型,使用Promise方式作为异步方法
设置鼠标样式类型,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -365,37 +371,35 @@ setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise&lt;void&g
| 参数 | 类型 | 必填 | 说明 |
| ------------------- | ------------------------------ | ---- | ---------------- |
| windowId | number | 是 | 输入设备的窗口id。 |
| windowId | number | 是 | 窗口id。 |
| pointerStyle | [PointerStyle](#pointerstyle9) | 是 | 鼠标样式id。 |
| Promise&lt;void&gt; | void | 是 | 无返回结果的Promise对象。 |
| Promise&lt;void&gt; | void | 是 | Promise对象。 |
**示例**
```js
// 设置设备的鼠标样式。
import window from '@ohos.window';
var windowClass = null;
window.getTopWindow((err, data) => {
windowClass = data;
windowClass.getProperties((err, data) => {
var windowId = data.id;
window.getTopWindow((error, win) => {
win.getProperties((error, properties) => {
var windowId = properties.id;
if (windowId < 0) {
console.log(`Invalid windowId`);
return;
}
try {
pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => {
console.log(`Successfully set mouse pointer style`);
console.log(`Set pointer style success`);
});
} catch (err) {
console.log(`Failed to set the pointer style. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
} catch (error) {
console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
});
});
```
## PointerStyle<sup>9+</sup>
定义鼠标样式类型。
鼠标样式类型。
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer
......@@ -440,5 +444,3 @@ window.getTopWindow((err, data) => {
| MIDDLE_BTN_SOUTH_EAST | 36 | 向东南滚动 |
| MIDDLE_BTN_SOUTH_WEST | 37 | 向西南滚动 |
| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | 四向锥形移动 |
\ No newline at end of file
# ProcessRunningInfo<sup>(deprecated)</sup>
ProcessRunningInfo模块提供对进程运行信息进行设置和查询的能力。
模块提供对进程运行信息进行设置和查询的能力。
> **说明:**
> - 本模块接口从API Version 9 开始废弃,建议使用[ProcessRunningInformation<sup>9+</sup>](js-apis-processrunninginformation.md)替代。
> - 本模块接口从API version 9 开始废弃,建议使用[ProcessRunningInformation<sup>9+</sup>](js-apis-processrunninginformation.md)替代。
> - 本模块首批接口从API version 8 开始支持。
## 使用说明
通过appManager来获取。
通过appManager[getProcessRunningInfos](js-apis-appmanager.md#appmanagergetprocessrunninginfosdeprecated)方法来获取。
```js
import appManager from '@ohos.application.appManager';
appManager.getProcessRunningInfos((error,data) => {
console.log("getProcessRunningInfos error: " + error.code + " data: " + JSON.stringify(data));
app.getProcessRunningInfos().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
```
......
......@@ -604,7 +604,7 @@ router.getParams();
| 名称 | 描述 |
| -------- | ---------------------------------------- |
| Standard | 标准模式。 |
| Standard | 标准模式。 <br/>目标页面会被添加到页面路由栈顶,无论栈中是否存在相同url的页面。 |
| Single | 单实例模式。<br/>如果目标页面的url在页面栈中已经存在同url页面,离栈顶最近的页面会被移动到栈顶,移动后的页面为新建页。<br/>如目标页面的url在页面栈中不存在同url页面,按标准模式跳转。 |
## 完整示例
......
......@@ -3307,7 +3307,7 @@ readInterfaceToken(): string
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let interfaceToken = data.readInterfaceToken();
console.log("RpcServer: interfaceToken is " + interfaceToken);
return true;
......@@ -3438,7 +3438,7 @@ getWritableBytes(): number
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let getWritableBytes = data.getWritableBytes();
console.log("RpcServer: getWritableBytes is " + getWritableBytes);
return true;
......@@ -7130,7 +7130,7 @@ static getCallingPid(): number
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let callerPid = rpc.IPCSkeleton.getCallingPid();
console.log("RpcServer: getCallingPid result: " + callerPid);
return true;
......@@ -7157,7 +7157,7 @@ static getCallingUid(): number
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let callerUid = rpc.IPCSkeleton.getCallingUid();
console.log("RpcServer: getCallingUid result: " + callerUid);
return true;
......@@ -7185,7 +7185,7 @@ static getCallingTokenId(): number;
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let callerTokenId = rpc.IPCSkeleton.getCallingTokenId();
console.log("RpcServer: getCallingTokenId result: " + callerTokenId);
return true;
......@@ -7212,7 +7212,7 @@ static getCallingDeviceID(): string
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let callerDeviceID = rpc.IPCSkeleton.getCallingDeviceID();
console.log("RpcServer: callerDeviceID is: " + callerDeviceID);
return true;
......@@ -7239,7 +7239,7 @@ static getLocalDeviceID(): string
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID();
console.log("RpcServer: localDeviceID is: " + localDeviceID);
return true;
......@@ -7266,7 +7266,7 @@ static isLocalCalling(): boolean
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let isLocalCalling = rpc.IPCSkeleton.isLocalCalling();
console.log("RpcServer: isLocalCalling is: " + isLocalCalling);
return true;
......@@ -7385,7 +7385,7 @@ static resetCallingIdentity(): string
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let callingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
console.log("RpcServer: callingIdentity is: " + callingIdentity);
return true;
......@@ -7412,7 +7412,7 @@ static restoreCallingIdentity(identity : string): void
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let callingIdentity = null;
try {
callingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
......@@ -7452,7 +7452,7 @@ static setCallingIdentity(identity : string): boolean
```
class Stub extends rpc.RemoteObject {
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
let callingIdentity = null;
try {
callingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
......@@ -7818,7 +7818,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
### onRemoteRequest<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[onRemoteRequestEx](#onremoterequestex9)类替代。
>从API version 9 开始不再维护,建议使用[onRemoteMessageRequest](#onremotemessagerequest9)类替代。
onRemoteRequest(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean
......@@ -7874,14 +7874,14 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里处理
}
```
### onRemoteRequestEx<sup>9+</sup>
### onRemoteMessageRequest<sup>9+</sup>
onRemoteRequestEx(code : number, data : MessageSequence, reply: MessageSequence, options : MessageOption): boolean | Promise\<boolean>
onRemoteMessageRequest(code : number, data : MessageSequence, reply: MessageSequence, options : MessageOption): boolean | Promise\<boolean>
> **说明:**
>
>* 开发者应优先选择重载onRemoteRequestEx方法,其中可以自由实现同步和异步的消息处理。
>* 开发者同时重载onRemoteRequest和onRemoteRequestEx方法时,仅onRemoteRequestEx方法生效。
>* 开发者应优先选择重载onRemoteMessageRequest方法,其中可以自由实现同步和异步的消息处理。
>* 开发者同时重载onRemoteRequest和onRemoteMessageRequest方法时,仅onRemoteMessageRequest方法生效。
sendMessageRequest请求的响应处理函数,服务端在该函数里同步或异步地处理请求,回复结果。
......@@ -7900,10 +7900,10 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
| 类型 | 说明 |
| ----------------- | ---------------------------------------------------------------------------------------------- |
| boolean | 若在onRemoteRequestEx中同步地处理请求,则返回一个布尔值:操作成功,则返回true;否则返回false。 |
| Promise\<boolean> | 若在onRemoteRequestEx中异步地处理请求,则返回一个Promise对象。 |
| boolean | 若在onRemoteMessageRequest中同步地处理请求,则返回一个布尔值:操作成功,则返回true;否则返回false。 |
| Promise\<boolean> | 若在onRemoteMessageRequest中异步地处理请求,则返回一个Promise对象。 |
**重载onRemoteRequestEx方法同步处理请求示例:**
**重载onRemoteMessageRequest方法同步处理请求示例:**
```ets
class MyDeathRecipient {
......@@ -7920,9 +7920,9 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
isObjectDead(): boolean {
return false;
}
onRemoteRequestEx(code, data, reply, option) {
onRemoteMessageRequest(code, data, reply, option) {
if (code === 1) {
console.log("RpcServer: sync onRemoteRequestEx is called");
console.log("RpcServer: sync onRemoteMessageRequest is called");
return true;
} else {
console.log("RpcServer: unknown code: " + code);
......@@ -7932,7 +7932,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
}
```
**重载onRemoteRequestEx方法异步处理请求示例:**
**重载onRemoteMessageRequest方法异步处理请求示例:**
```ets
class MyDeathRecipient {
......@@ -7949,9 +7949,9 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
isObjectDead(): boolean {
return false;
}
async onRemoteRequestEx(code, data, reply, option) {
async onRemoteMessageRequest(code, data, reply, option) {
if (code === 1) {
console.log("RpcServer: async onRemoteRequestEx is called");
console.log("RpcServer: async onRemoteMessageRequest is called");
} else {
console.log("RpcServer: unknown code: " + code);
return false;
......@@ -7964,7 +7964,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
}
```
**同时重载onRemoteRequestEx和onRemoteRequest方法同步处理请求示例:**
**同时重载onRemoteMessageRequest和onRemoteRequest方法同步处理请求示例:**
```ets
class MyDeathRecipient {
......@@ -7983,17 +7983,17 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
}
onRemoteRequest(code, data, reply, option) {
if (code === 1) {
console.log("RpcServer: sync onRemoteRequestEx is called");
console.log("RpcServer: sync onRemoteMessageRequest is called");
return true;
} else {
console.log("RpcServer: unknown code: " + code);
return false;
}
}
// 同时调用仅会执行onRemoteRequestEx
onRemoteRequestEx(code, data, reply, option) {
// 同时调用仅会执行onRemoteMessageRequest
onRemoteMessageRequest(code, data, reply, option) {
if (code === 1) {
console.log("RpcServer: async onRemoteRequestEx is called");
console.log("RpcServer: async onRemoteMessageRequest is called");
} else {
console.log("RpcServer: unknown code: " + code);
return false;
......@@ -8004,7 +8004,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
}
```
**同时重载onRemoteRequestEx和onRemoteRequest方法异步处理请求示例:**
**同时重载onRemoteMessageRequest和onRemoteRequest方法异步处理请求示例:**
```ets
class MyDeathRecipient {
......@@ -8030,10 +8030,10 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
return false;
}
}
// 同时调用仅会执行onRemoteRequestEx
async onRemoteRequestEx(code, data, reply, option) {
// 同时调用仅会执行onRemoteMessageRequest
async onRemoteMessageRequest(code, data, reply, option) {
if (code === 1) {
console.log("RpcServer: async onRemoteRequestEx is called");
console.log("RpcServer: async onRemoteMessageRequest is called");
} else {
console.log("RpcServer: unknown code: " + code);
return false;
......
......@@ -13,64 +13,82 @@ import tag from '@ohos.nfc.tag';
## tagSession
tagSession是所有[Nfc tag 技术类型](js-apis-nfctech.md)的基类, 提供建立连接和发送数据等共同接口。
tagSession是所有[NFC Tag技术类型](js-apis-nfctech.md)的基类, 提供建立连接和发送数据等共同接口。
需要通过其子类来访问以下接口。在下面的示例中 统一用 getXXTag表示获取子类实例的方法。
需要通过其子类来访问以下接口。在下面的示例中 统一用 getXXX()表示获取子类实例的方法。
具体使用时,请根据实际采用的Nfc tag技术,选择对应的方法,具体请参见[nfcTag](js-apis-nfcTag.md)文档。
### tagSession.connectTag
connectTag(): boolean;
### tagSession.getTagInfo
和标签建立连接;
getTagInfo(): tag.TagInfo
在从标签读取数据或将数据写入标签之前,必须调用此方法
获取该Tag被分发时,NFC服务所提供的Tag数据对象
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
| **类型** | **说明** |
| ------------------ | --------------------------|
| boolean | 连接建立成功返回 true,失败返回false。 |
| TagInfo | NFC服务所提供的Tag数据对象。 |
**示例:**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an Object given by nfc service when tag is dispatched.
let isNfcConnected = tag.getXXXTag(taginfo).connectTag();
console.log("isNfcConnected:" +isNfcConnected);
// see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched.
// the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ...
let tagInfo = tag.getXXX(tagInfo).getTagInfo();
console.log("tag tagInfo: " + tagInfo);
```
### tagSession.reset()
### tagSession.connectTag
reset(): void
connectTag(): boolean;
重置与标签的连接,并恢复将数据写入标签的默认超时时间
和标签建立连接。在从标签读取数据或将数据写入标签之前,必须调用此方法
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
| **类型** | **说明** |
| ------------------ | --------------------------|
| boolean | 方法执行成功返回 true,失败返回false。 |
| boolean | 连接建立成功返回true,失败返回false。 |
**示例:**
```js
import tag from '@ohos.nfc.tag';
// see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched.
// the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ...
let connectStatus = tag.getXXX(tagInfo).connectTag();
console.log("connectStatus: " + connectStatus);
```
### tagSession.reset()
reset(): void
重置与标签的连接。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
**示例:**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an Object given by nfc service when tag is dispatched.
let reset = tag.getXXXTag(taginfo).reset();
console.log("reset:" +reset);
// see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched.
// the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ...
tag.getXXX(tagInfo).reset();
```
### tagSession.isTagConnected
......@@ -84,19 +102,19 @@ isTagConnected(): boolean
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
| **类型** | **说明** |
| ------------------ | --------------------------|
| boolean | 已建立连接返回 true,未建立连接返回false。 |
**示例:**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an Object given by nfc service when tag is dispatched.
let isTagConnected = tag.getXXXTag(taginfo).isTagConnected();
console.log("isTagConnected:" +isTagConnected);
// see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched.
// the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ...
let isTagConnected = tag.getXXX(tagInfo).isTagConnected();
console.log("isTagConnected: " + isTagConnected);
```
### tagSession.getMaxSendLength
......@@ -110,17 +128,160 @@ getMaxSendLength(): number
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
| **类型** | **说明** |
| ------------------ | --------------------------|
| number | 可以发送到标签的最大数据长度,非负数。 |
**示例:**
```js
import tag from '@ohos.nfc.tag';
// see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched.
// the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ...
let maxSendLen = tag.getXXX(tagInfo).getMaxSendLength();
console.log("tag maxSendLen: " + maxSendLen);
```
### tagSession.getSendDataTimeout
getSendDataTimeout(): number
查询发送数据到Tag的等待超时时间,单位是毫秒。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
**返回值:**
| **类型** | **说明** |
| ------------------ | --------------------------|
| number | 可以发送到标签的最大数据长度。 |
| number | 发送数据到Tag的等待超时时间,单位是毫秒,非负数。 |
**示例:**
```js
import tag from '@ohos.nfc.tag';
// see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched.
// the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ...
let sendDataTimeout = tag.getXXX(tagInfo).getSendDataTimeout();
console.log("tag sendDataTimeout: " + sendDataTimeout);
```
### tagSession.setSendDataTimeout
setSendDataTimeout(timeout: number): boolean
查询发送数据到Tag的等待超时时间,单位是毫秒。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | -------------------------------------- |
| timeout | number | 是 | 超时时间,单位毫秒,非负值。 |
**返回值:**
| **类型** | **说明** |
| ------------------ | --------------------------|
| boolean | 设置超时时间成功返回true,设置失败返回false。 |
**示例:**
```js
import tag from '@ohos.nfc.tag';
// see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched.
// the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ...
let timeoutMs = 700; // change it to be correct.
let setStatus = tag.getXXX(tagInfo).setSendDataTimeout(timeoutMs);
console.log("tag setSendDataTimeout setStatus: " + setStatus);
```
### tagSession.sendData
sendData(data: number[]): Promise<number[]>
发送指令到Tag上,使用Promise方式作为异步方法。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | -------------------------------------- |
| data | number[] | 是 | 要发送的指令。每个number十六进制表示,范围是0x00~0xFF。 |
**返回值:**
| **类型** | **说明** |
| ------------------ | --------------------------|
| Promise<number[]> | 对端Tag对指令的响应数据。每个number十六进制表示,范围是0x00~0xFF。|
**示例:**
```js
import tag from '@ohos.nfc.tag';
// see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched.
// the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ...
// connect the tag at first if not connected.
if (!tag.getXXX(tagInfo).isTagConnected()) {
if (!tag.getXXX(tagInfo).connectTag()) {
console.log("tagSession connectTag failed.");
return;
}
}
let cmdData = [0x01, 0x02, ...]; // change the raw data to be correct.
tag.getXXX(tagInfo).sendData(cmdData).then((response) => {
console.log("tagSession sendData Promise response: " + response);
}).catch((err)=> {
console.log("tagSession sendData Promise err: " + err);
});
```
### tagSession.sendData
sendData(data: number[], callback: AsyncCallback<number[]>): void
发送指令到Tag上,使用AsyncCallback方式作为异步方法。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | -------------------------------------- |
| data | number[] | 是 | 要发送的指令。每个number十六进制表示,范围是0x00~0xFF。 |
| callback | AsyncCallback<number[]> | 是 | 回调函数,返回响应数据。每个number十六进制表示,范围是0x00~0xFF。 |
**示例:**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an Object given by nfc service when tag is dispatched.
let mazSendLen = tag.getXXXTag(taginfo).getMaxSendLength();
console.log("mazSendLen:" +mazSendLen);
// see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched.
// the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ...
// connect the tag at first if not connected.
if (!tag.getXXX(tagInfo).isTagConnected()) {
if (!tag.getXXX(tagInfo).connectTag()) {
console.log("tagSession connectTag failed.");
return;
}
}
let cmdData = [0x01, 0x02, ...]; // change the raw data to be correct.
tag.getXXX(tagInfo).sendData(cmdData, (err, response)=> {
if (err) {
console.log("tagSession sendData AsyncCallback err: " + err);
} else {
console.log("tagSession sendData AsyncCallback response: " + response);
}
});
```
......@@ -24,9 +24,9 @@
除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性:
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| ------------------ | ----------- | -------- | ---- | ---------------------------------------- |
| ------------------ | ----------- | -------- | ---- | ------------------------------------------------------------ |
| placement | string | rightTop | 否 | 事件提醒的数字标记或者圆点标记的位置,可选值为:<br/>-&nbsp;right:位于组件右边框。<br/>-&nbsp;rightTop:位于组件边框右上角。<br/>-&nbsp;left:位于组件左边框。 |
| count | number | 0 | 否 | 设置提醒的消息数,默认为0。当设置相应的提醒消息数大于0时,消息提醒会变成数字标记类型,未设置消息数或者消息数不大于0时,消息提醒将采用圆点标记<br/>当数字设置大于maxcount时,将使用maxcount显示。count属性最大支持整数值为2147483647。 |
| count | number | 0 | 否 | 设置提醒的消息数,默认为0,为0时不显示。当设置相应的提醒消息数大于0时,消息提醒会变成数字标记类型<br/>当数字设置大于maxcount时,将使用maxcount显示。count属性最大支持整数值为2147483647。 |
| visible | boolean | false | 否 | 是否显示消息提醒,当收到新信息提醒时可以设置该属性为true,显示相应的消息提醒,如果需要使用数字标记类型,同时需要设置相应的count属性。 |
| maxcount | number | 99 | 否 | 最大消息数限制,当收到新信息提醒大于该限制时,标识数字会进行省略,仅显示maxcount+。<br/>maxcount属性支持的最大整数值为2147483647。 |
| config | BadgeConfig | - | 否 | 设置新事件标记相关配置属性。 |
......@@ -107,4 +107,4 @@ export default {
}
```
![zh-cn_image_0000001177265268](figures/zh-cn_image_0000001177265268.png)
![zh-cn_image_000000117726526811](figures/zh-cn_image_000000117726526811.png)
......@@ -73,3 +73,5 @@ struct AttrAnimationExample {
}
}
```
![animation](figures/animation.gif)
\ No newline at end of file
# 文档中涉及到的内置枚举值
# 枚举说明
## Color
......
......@@ -30,10 +30,10 @@
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ------- | ----------------------------------- | ---- | ------------- |
| label | [ResourceStr](ts-types.md#resourcestr) | 否 | 按钮文本内容。 |
| options | { type?: ButtonType, stateEffect?: boolean } | 否 | 见方法1参数说明。 |
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ------- | ----------------------------------- | ---- | ------------- |
| label | [ResourceStr](ts-types.md#resourcestr) | 否 | 按钮文本内容。 |
| options | { type?: ButtonType, stateEffect?: boolean } | 否 | 见方法1参数说明。 |
## 属性
......@@ -89,9 +89,6 @@ struct ButtonExample {
Text('loading').fontSize(12).fontColor(0xffffff).margin({ left: 5, right: 12 })
}.alignItems(VerticalAlign.Center).width(90).height(40)
}.backgroundColor(0x317aff)
.onClick((event: ClickEvent) => {
AlertDialog.show({ message: 'The login is successful' })
})
Button('Disable', { type: ButtonType.Capsule, stateEffect: false }).opacity(0.4)
.backgroundColor(0x317aff).width(90)
......@@ -112,3 +109,4 @@ struct ButtonExample {
}
```
![button](figures/button.gif)
\ No newline at end of file
......@@ -64,7 +64,7 @@ struct GaugeExample {
// 参数设置当前值为75,属性设置值为25,属性设置优先级高
Gauge({ value: 75 })
.value(25) //属性和参数都设置时以参数为准
.value(25) // 属性和参数都设置时以参数为准
.width(200).height(200)
.colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1]])
......
......@@ -75,9 +75,9 @@ caretPosition(value: number): void
@Entry
@Component
struct SearchExample {
@State changeValue: string = '';
@State submitValue: string = '';
controller: SearchController = new SearchController();
@State changeValue: string = ''
@State submitValue: string = ''
controller: SearchController = new SearchController()
build() {
Column() {
......@@ -92,16 +92,16 @@ struct SearchExample {
.placeholderFont({ size: 14, weight: 400 })
.textFont({ size: 14, weight: 400 })
.onSubmit((value: string) => {
this.submitValue = value;
this.submitValue = value
})
.onChange((value: string) => {
this.changeValue = value;
this.changeValue = value
})
.margin(20)
Button('Set caretPosition 1')
.onClick(() => {
// 设置光标位置到输入的第一个字符后
this.controller.caretPosition(1);
this.controller.caretPosition(1)
})
}.width('100%')
}
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册