diff --git a/docker/CHANGELOG.md b/docker/CHANGELOG.md old mode 100644 new mode 100755 index c293b830db2a72958e65485bffa18a06396cca15..ab06f14091985eed7a30233c18eb2df2cecaa03c --- a/docker/CHANGELOG.md +++ b/docker/CHANGELOG.md @@ -1,3 +1,9 @@ +### 1.0.0 (2022/03/09) + +合并轻设备和富设备系统docker编译环境。 + + + ### 0.0.7 (2022/02/16) 增加安装doxygen工具。 diff --git a/docker/CHANGELOG_en.md b/docker/CHANGELOG_en.md old mode 100644 new mode 100755 index 1dac4c8e523bf0c6adf63e1c93d289e5a158254e..94189f8d74234167006312d822bad65006ee40a9 --- a/docker/CHANGELOG_en.md +++ b/docker/CHANGELOG_en.md @@ -1,10 +1,16 @@ +### 1.0.0 (2022/03/09) + +Combine the docker build environment of Mini-System Devices (reference memory ≥ 128 KB), Small-System Devices (reference memory ≥ 1 MB) and Standard-System Devices (reference memory ≥ 128 MB). + + + ### 0.0.7 (2022/02/16) Added the installation of doxygen. -### 0.0.6(2022/02/10) +### 0.0.6 (2022/02/10) 1\. Updated hb. diff --git a/docker/Dockerfile b/docker/Dockerfile index 9e5371eae3bdb34a3cc2e0238bf7e47f65c36e55..70560a93c1dd890bf8b6ff1d9f03d2e778adbfe0 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -12,80 +12,71 @@ # limitations under the License. -FROM ubuntu:20.04 -MAINTAINER dongjinguang@huawei.com +FROM ubuntu:18.04 WORKDIR /home/openharmony -RUN apt-get update -y \ - && apt-get install curl wget -y \ - && apt-get install vim -y \ - && apt-get install ssh -y \ - && apt-get install git -y \ - && apt-get install python3.8 -y \ - && apt-get install python3-pip -y \ - && apt-get install dosfstools -y \ - && apt-get install mtools -y \ - && apt-get install scons -y \ - && apt-get install make -y \ - && apt-get install libffi-dev -y \ - && apt-get install zip -y \ - && apt-get install python3-distutils -y \ - && apt-get install binutils -y \ - && apt-get install mtd-utils -y \ - && apt-get install libc6-dev-x32 -y \ - && DEBIAN_FRONTEND="noninteractive" TZ="America/New_York" apt-get -y install tzdata \ - && apt-get install default-jre -y \ - && apt-get install default-jdk -y \ - && apt-get install bison -y \ - && apt-get install flex -y \ - && apt-get install bc -y \ - && apt-get install doxygen -y \ - && apt-get install u-boot-tools -y \ - && apt-get install gcc-arm-linux-gnueabi -y \ - && apt-get install build-essential \ - && apt-get install locales \ - && apt-get install ruby -y \ +RUN sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list \ + && sed -i "s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list \ + && apt-get update -y \ + && apt-get install -y apt-utils binutils bison flex bc build-essential make mtd-utils gcc-arm-linux-gnueabi u-boot-tools python3.8 python3-pip git zip unzip curl wget gcc g++ ruby=1:2.5.1 dosfstools mtools default-jre default-jdk scons python3.8-distutils perl openssl libssl-dev cpio git-lfs m4 ccache zlib1g-dev tar rsync liblz4-tool genext2fs binutils-dev device-tree-compiler e2fsprogs git-core gnupg gnutls-bin gperf lib32ncurses5-dev libffi-dev zlib* libelf-dev libx11-dev libgl1-mesa-dev lib32z1-dev xsltproc x11proto-core-dev libc6-dev-i386 libxml2-dev lib32z-dev libdwarf-dev \ + && apt-get install -y grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5 libncurses5-dev libncursesw5 libstdc++6 python2.7 gcc-arm-none-eabi \ + && apt-get install -y vim ssh locales \ + && apt-get install -y doxygen \ && locale-gen "en_US.UTF-8" \ - && rm -rf /bin/sh /usr/bin/python /usr/bin/python3 \ + && rm -rf /bin/sh /usr/bin/python /usr/bin/python3 /usr/bin/python3m \ && ln -s /bin/bash /bin/sh \ && ln -s /usr/bin/python3.8 /usr/bin/python3 \ + && ln -s /usr/bin/python3.8 /usr/bin/python3m \ && ln -s /usr/bin/python3.8 /usr/bin/python \ - && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple setuptools \ - && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple kconfiglib \ - && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple pycryptodome \ - && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple ecdsa \ - && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple ohos-build \ + && curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/bin/repo \ + && chmod +x /usr/bin/repo \ + && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple requests setuptools pymongo kconfiglib pycryptodome ecdsa ohos-build pyyaml prompt_toolkit==1.0.14 redis json2html yagmail python-jenkins \ + && pip3 install esdk-obs-python --trusted-host pypi.org \ + && pip3 install six --upgrade --ignore-installed six \ && mkdir -p /home/tools \ + && mkdir -p /home/tools/gn \ && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/clang/10.0.1-62608/linux/llvm.tar.gz \ && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar \ && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz \ && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar \ && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/gn/1717/linux/gn-linux-x86-1717.tar.gz \ - && wget -P /home/tools https://mirrors.huaweicloud.com/nodejs/v12.20.0/node-v12.20.0-linux-x64.tar.gz \ - && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/develop_tools/hmos_app_packing_tool.jar \ - && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/develop_tools/hapsigntoolv2.jar \ - && tar xvf /home/tools/llvm.tar.gz -C /home/tools \ - && tar xvf /home/tools/hc-gen-0.65-linux.tar -C /home/tools \ - && tar xvf /home/tools/gcc_riscv32-linux-7.3.0.tar.gz -C /home/tools \ - && tar xvf /home/tools/ninja.1.9.0.tar -C /home/tools \ - && tar xvf /home/tools/gn-linux-x86-1717.tar.gz -C /home/tools \ - && tar xvf /home/tools/node-v12.20.0-linux-x64.tar.gz -C /home/tools \ + && wget -P /home/tools https://mirrors.huaweicloud.com/nodejs/v14.15.4/node-v14.15.4-linux-x64.tar.xz \ + && wget -P /home/tools https://hm-verify.obs.cn-north-4.myhuaweicloud.com/qemu-5.2.0.tar.xz \ + && tar -xvf /home/tools/llvm.tar.gz -C /home/tools \ + && tar -xvf /home/tools/hc-gen-0.65-linux.tar -C /home/tools \ + && tar -xvf /home/tools/gcc_riscv32-linux-7.3.0.tar.gz -C /home/tools \ + && tar -xvf /home/tools/ninja.1.9.0.tar -C /home/tools \ + && tar -xvf /home/tools/gn-linux-x86-1717.tar.gz -C /home/tools/gn \ + && tar -xJf /home/tools/node-v14.15.4-linux-x64.tar.xz -C /home/tools \ + && cp /home/tools/node-v14.15.4-linux-x64/bin/node /usr/local/bin \ + && ln -s /home/tools/node-v14.15.4-linux-x64/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ + && ln -s /home/tools/node-v14.15.4-linux-x64/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ + && tar -xJf /home/tools/qemu-5.2.0.tar.xz -C /home/tools \ && sed -i '$aexport PATH=/home/tools/llvm/bin:$PATH' /root/.bashrc \ && sed -i '$aexport PATH=/home/tools/hc-gen:$PATH' /root/.bashrc \ && sed -i '$aexport PATH=/home/tools/gcc_riscv32/bin:$PATH' /root/.bashrc \ && sed -i '$aexport PATH=/home/tools/ninja:$PATH' /root/.bashrc \ - && sed -i '$aexport PATH=/home/tools/node-v12.20.0-linux-x64/bin:$PATH' /root/.bashrc \ - && sed -i '$aexport PATH=/home/tools:$PATH' /root/.bashrc \ + && sed -i '$aexport PATH=/home/tools/node-v14.15.4-linux-x64/bin:$PATH' /root/.bashrc \ + && sed -i '$aexport PATH=/home/tools/gn:$PATH' /root/.bashrc \ && sed -i '$aexport PATH=/root/.local/bin:$PATH' /root/.bashrc \ && export PATH=/home/tools/llvm/bin:$PATH \ && export PATH=/home/tools/hc-gen:$PATH \ && export PATH=/home/tools/gcc_riscv32/bin:$PATH \ && export PATH=/home/tools/ninja:$PATH \ && export PATH=/home/tools/node-v12.20.0-linux-x64/bin:$PATH \ - && export PATH=/home/tools:$PATH \ + && export PATH=/home/tools/gn:$PATH \ && export PATH=/root/.local/bin:$PATH \ + && cd /home/tools/qemu-5.2.0 \ + && mkdir build \ + && cd build \ + && ../configure --target-list=arm-softmmu \ + && make -j \ + && make install \ + && cd /home/openharmony \ && rm -rf /home/tools/*.tar \ && rm -rf /home/tools/*.gz \ + && rm -rf /home/tools/*.xz \ + && rm -rf /home/tools/qemu-5.2.0 \ && npm install -g @ohos/hpm-cli --registry https://mirrors.huaweicloud.com/repository/npm/ ENV LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 diff --git a/docker/README.md b/docker/README.md index 6f536192dcc4a7ea2254aab53b7ea6049ce558dd..d38a6f295c20e79da128ae47d1debdc48b4004e7 100755 --- a/docker/README.md +++ b/docker/README.md @@ -2,30 +2,29 @@ ### Docker镜像简介 -本文为小型和轻量系统类设备Docker使用指导,[点此查看](https://gitee.com/openharmony/docs/blob/master/docker/standard/Readme.md)标准系统类设备使用指导。 +本文为OpenHarmony的Docker编译环境使用指导。 OpenHarmony的Docker镜像托管在**HuaweiCloud SWR**上,开发者可以通过该镜像在很大程度上简化编译前的环境配置。 目前容器化构建选项支持情况如下: -| Docker镜像仓库 | 标签 | 说明 | -| :----------------------------------------------------------- | :------ | :----------------------------------------------------------- | -| `swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker` | `0.0.7` | 已经预安装OpenHarmony版本的编译环境,支持轻量系统类设备(参考内存≥128KB)和小型系统类设备(参考内存≥1MB)的版本构建。 | +| Docker镜像仓库 | 标签 | 说明 | +| :----------------------------------------------------------- | :------ | :------------------------------------ | +| `swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker` | `1.0.0` | 已经预安装OpenHarmony版本的编译环境。 | ### 使用方式及步骤 - 开发者在配置好开发环境后,可以通过以下步骤来使用我们提供的Docker环境。详情请参见[Docker编译环境](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/gettools-acquire.md)。 + 开发者在下载好源码后,可以通过以下步骤来使用我们提供的Docker环境。详情请参见[Docker编译环境](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/gettools-acquire.md)。 1. 获取Docker镜像 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境 ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 3. 通过如下命令启动不同平台的编译 ``` - hb set #设置工作目录。 - . #输入源码所在目录,点(.)表示当前目录。 - 在显示的页面中通过键盘上下键选择需要编译的平台,通过回车确定选择。 + hb set #在显示的页面中通过键盘上下键选择需要编译的平台,通过回车确定选择。 hb build -f #执行编译。 ``` + diff --git a/docker/README_en.md b/docker/README_en.md old mode 100644 new mode 100755 index c41dab5a571836e7fc860fc60cef2423daa165f0..9853079a565ee82d2a752ec134b6c29acc7ab43b --- a/docker/README_en.md +++ b/docker/README_en.md @@ -2,30 +2,28 @@ ### Docker Image -This document provides guidance on building the Docker image for mini- and small-system devices. For details about how to build the Docker image for standard-system devices, see [OpenHarmony Docker Image](https://gitee.com/openharmony/docs/blob/master/docker/standard/Readme-en.md) +This document provides guidance on building the Docker image for mini- and small-system devices. The Docker image of OpenHarmony is hosted on [HUAWEI Cloud SWR](https://auth.huaweicloud.com/authui/login.html?service=https%3A%2F%2Fconsole.huaweicloud.com%2Fswr%2F%3Fregion%3Dcn-south-1%26cloud_route_state%3D%2Fapp%2Fwarehouse%2FwarehouseMangeDetail%2Fgoldensir%2Fopenharmony-docker%2Fopenharmony-docker%3Ftype%3DownImage&locale=en-us#/login). Using the Docker image will help simplify environment configurations needed for the building. The following table lists container-based options needed for building in the standalone Docker environment. -| Docker Image Repository | Tag | Description | -| :----------------------------------------------------------- | :------ | :----------------------------------------------------------- | -| `swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker` | `0.0.7` | The OpenHarmony build environment has been pre-installed. This repository applies to Mini-System Devices (reference memory ≥ 128 KB) and Small-System Devices (reference memory ≥ 1 MB). | +| Docker Image Repository | Tag | Description | +| :----------------------------------------------------------- | :------ | :-------------------------------------------------------- | +| `swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker` | `1.0.0` | The OpenHarmony build environment has been pre-installed. | ### Usage - After configuring the development environments, perform the steps below to access the Docker environment. + After downloading the OpenHarmony code, perform the steps below to access the Docker environment. 1. Obtain the Docker image. ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment: ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 3. Run the following script to start building for different platforms. ``` - hb set # Set the working directory. - . # Enter the directory where the source code is stored. If the code is stored in the current directory, enter a period (.). - Press the Up or Down key to select the platform to build on, then press Enter. + hb set # Press the Up or Down key to select the platform to build on, then press Enter. hb build -f # Start building. ``` diff --git a/docker/build.sh b/docker/build.sh index 0c8b1fc8b366bf308a245a0e0d2de01be4986ba9..e1a7618251929cd060b0e33c4763e4bb5e5f9057 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -docker build -t openharmony-docker:0.0.7 . +docker build -t openharmony-docker:1.0.0 . diff --git a/docker/standard/CHANGELOG.md b/docker/standard/CHANGELOG.md deleted file mode 100644 index c37b6bc9eefa502a81f7a28c37063a16ca665504..0000000000000000000000000000000000000000 --- a/docker/standard/CHANGELOG.md +++ /dev/null @@ -1,36 +0,0 @@ - ### 0.0.8(2022/01/16) - -新增安装doxygen。 - - ### 0.0.7(2022/01/11) - -新增安装genext2fs和liblz4-tool。 - - ### 0.0.6(2022/01/04) - -新增安装hb。 - - ### 0.0.5(2021/10/28) - -新增安装tar、binutils、git-lfs、gnutls-bin、python3.8、python3-pip、cpio。 - - ### 0.0.4(2021/09/18) - -1、删除编译依赖的工具预装。 - -2、增加安装ruby。 - - ### 0.0.3(2021/08/30) - -1、更新llvm版本从10.0.1-62608更新到10.0.1-69957。 - -2、增加安装gcc_aarch64。 - - ### 0.0.2(2021/08/11) - -新增安装llvm-10.0.1-62608和restool工具。 - - ### 0.0.1(2021/06/02) - -提供OpenHarmony 2.0版本docker编译环境,预装编译依赖工具。 - diff --git a/docker/standard/CHANGELOG_en.md b/docker/standard/CHANGELOG_en.md deleted file mode 100644 index ce1cceda1cc1fab4f061a0b3dd3db106a88ad27c..0000000000000000000000000000000000000000 --- a/docker/standard/CHANGELOG_en.md +++ /dev/null @@ -1,35 +0,0 @@ - ### 0.0.8 (2022/01/16) - -Added the installation of doxygen. - - ### 0.0.7 (2022/01/11) - -Added the installation of genext2fs and liblz4-tool. - - ### 0.0.6 (2022/01/04) - -Added the installation of hb. - - ### 0.0.5 (2021/10/28) - -Added the installation of tar, binutils, git-lfs, gnutls-bin, python3.8, python3-pip, and cpio. - - ### 0.0.4 (2021/09/18) - -1\. Removed pre-installed build dependency tools. - -2\. Added the Ruby installation. - - ### 0.0.3 (2021/08/30) - -1\. Updated LLVM from 10.0.1-62608 to 10.0.1-69957. - -2\. Added the installation of gcc_aarch64. - - ### 0.0.2 (2021/08/11) - -Added the installation of llvm-10.0.1-62608 and restool. - - ### 0.0.1 (2021/06/02) - -Provided a Docker build environment for OpenHarmony 2.0 and pre-installed build dependency tools. \ No newline at end of file diff --git a/docker/standard/Readme-en.md b/docker/standard/Readme-en.md deleted file mode 100755 index cdfc3cc4a00bccf3d43cfbd20716d7b7979f3258..0000000000000000000000000000000000000000 --- a/docker/standard/Readme-en.md +++ /dev/null @@ -1,31 +0,0 @@ -## Standalone Docker Environment - -This document provides guidance on building the Docker image for standard-system devices. For details about how to build the Docker image for mini- and small-system devices, see [OpenHarmony Docker Image](https://gitee.com/openharmony/docs/blob/master/docker/README_en.md) - -The Docker image of OpenHarmony is hosted on [HUAWEI Cloud SWR](https://auth.huaweicloud.com/authui/login.html?service=https%3A%2F%2Fconsole.huaweicloud.com%2Fswr%2F%3Fregion%3Dcn-south-1%26cloud_route_state%3D%2Fapp%2Fwarehouse%2FwarehouseMangeDetail%2Fgoldensir%2Fopenharmony-docker%2Fopenharmony-docker%3Ftype%3DownImage&locale=en-us#/login). Using the Docker image will help simplify environment configurations needed for the building. After configuring the development environments, perform the steps below to access the Docker environment. The following steps use Ubuntu as an example (Windows is also supported). - -### Setting Up the Docker Environment for Standard-System Devices (reference memory ≥ 128 MB) - -1. Obtain the Docker image. -``` -docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 -``` -2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment: -``` -docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 -``` - -### Building for Standard-System Devices (reference memory ≥ 128 MB) -Run the following script to start building for Standard-System Devices (reference memory ≥ 128 MB) - -``` -./build.sh --product-name {product_name} --ccache -``` -**{product_name}** indicates the platform supported by the current distribution, for example, Hi3516DV300, rk3568. -Files generated during compilation are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory. - - - -**Note** - -You can exit Docker by simply running the **exit** command. \ No newline at end of file diff --git a/docker/standard/Readme.md b/docker/standard/Readme.md deleted file mode 100755 index 5997c8b0ade534df555b6c10dda852c26470c1fe..0000000000000000000000000000000000000000 --- a/docker/standard/Readme.md +++ /dev/null @@ -1,31 +0,0 @@ -## 独立Docker环境 - -本文为标准系统类设备Docker使用指导,[点此查看](https://gitee.com/openharmony/docs/blob/master/docker/README.md)小型和轻量系统类设备使用指导。 - -OpenHarmony的Docker镜像托管在HuaweiCloud SWR上。开发者可以通过该镜像在很大程度上简化编译前的环境配置。开发者在配置好开发环境后,通过以下步骤来使用Docker环境。 - -### 搭建Docker环境-标准系统类设备(参考内存≥128MB) - -1. 获取Docker镜像。 -``` -docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 -``` -2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 -``` -docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 -``` - -### 编译源码-标准系统类设备(参考内存≥128MB) -通过如下编译脚本启动标准系统类设备(参考内存≥128MB)的编译。 - -``` -./build.sh --product-name {product_name} --ccache -``` -{product_name}为当前版本支持的平台。比如:Hi3516DV300、rk3568等。 -编译所生成的文件都归档在out/{device_name}/目录下,结果镜像输出在 out/{device_name}/packages/phone/images/ 目录下。 - - - -**说明** - - 退出Docker执行exit命令即可。 \ No newline at end of file diff --git a/docker/standard/build.sh b/docker/standard/build.sh deleted file mode 100755 index d51927c8ef85f25177137361ea5e22fa0c3da081..0000000000000000000000000000000000000000 --- a/docker/standard/build.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -docker build -t openharmony-docker-standard:0.0.8 . diff --git a/docker/standard/dockerfile b/docker/standard/dockerfile deleted file mode 100755 index 5451542fc8a01443781d940093001760ad4bfc5b..0000000000000000000000000000000000000000 --- a/docker/standard/dockerfile +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM ubuntu:18.04 -WORKDIR /home/openharmony - -ARG DEBIAN_FRONTEND=noninteractive -ARG PREBUILTS_DIR=/home/prebuilts -ARG HOME_TOOLS=/home/tools - -RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak - -COPY sources.list /etc/apt - -RUN apt-get update \ - && apt-get install -y \ - apt-utils \ - vim \ - tar \ - binutils \ - software-properties-common \ - openssh-server \ - iputils-ping \ - curl \ - net-tools \ - bsdmainutils \ - kmod \ - bc \ - rsync \ - gawk \ - ssh \ - ccache \ - zip \ - python-dev \ - make \ - m4 \ - gcc-multilib \ - ca-certificates-java \ - unzip \ - python3-yaml \ - perl \ - openssl \ - libssl1.1 \ - gnupg \ - xsltproc \ - x11proto-core-dev \ - tcl \ - python3-crypto \ - python-yaml \ - python-crypto \ - libxml2-utils \ - libxml2-dev \ - libx11-dev \ - libssl-dev \ - libgl1-mesa-dev \ - lib32z1-dev \ - lib32ncurses5-dev \ - g++-multilib \ - flex \ - bison \ - doxygen \ - git \ - git-lfs \ - subversion \ - tofrodos \ - pigz \ - expect \ - python3-xlrd \ - python-xlrd \ - wget \ - git-core \ - gperf \ - build-essential \ - zlib1g-dev \ - libc6-dev-i386 \ - lib32z-dev \ - openjdk-8-jdk \ - ruby \ - gnutls-bin \ - python3.8 \ - python3-pip \ - cpio \ - genext2fs \ - doxygen \ - liblz4-tool \ - && rm -rf /bin/sh /usr/bin/python /usr/bin/python3 \ - && ln -s /bin/bash /bin/sh \ - && ln -s /usr/bin/python3.8 /usr/bin/python3 \ - && ln -s /usr/bin/python3.8 /usr/bin/python \ - && python3 -m pip install --user ohos-build \ - && mkdir -p $PREBUILTS_DIR/prebuilts $HOME_TOOLS - -RUN wget -P $HOME_TOOLS https://mirrors.huaweicloud.com/nodejs/v12.18.4/node-v12.18.4-linux-x64.tar.gz \ - && wget -P $HOME_TOOLS https://mirrors.huaweicloud.com/nodejs/v12.18.4/node-v12.18.4-darwin-x64.tar.gz \ - && tar xvf $HOME_TOOLS/node-v12.18.4-linux-x64.tar.gz -C $PREBUILTS_DIR/prebuilts \ - && tar xvf $HOME_TOOLS/node-v12.18.4-darwin-x64.tar.gz -C $PREBUILTS_DIR/prebuilts \ - && sed -i '$aexport PATH='"$PREBUILTS_DIR"'/prebuilts/node-v12.18.4-linux-x64/bin:$PATH' /root/.bashrc \ - && sed -i '$aexport PATH='"$PREBUILTS_DIR"'/prebuilts/hc-gen:$PATH' /root/.bashrc \ - && export PATH=$PATH:$PREBUILTS_DIR/prebuilts/node-v12.18.4-linux-x64/bin \ - && export PATH=$PATH:$PREBUILTS_DIR/prebuilts/hc-gen \ - && rm -rf $HOME_TOOLS \ - && npm install -g @ohos/hpm-cli --registry https://registry.npm.taobao.org diff --git a/docker/standard/sources.list b/docker/standard/sources.list deleted file mode 100755 index 78030974c6f1729f8d290a59aa3c83f30cc4c472..0000000000000000000000000000000000000000 --- a/docker/standard/sources.list +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -deb http://mirrors.ustc.edu.cn/ubuntu/ bionic main multiverse restricted universe -deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main multiverse restricted universe -deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main multiverse restricted universe -deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main multiverse restricted universe -deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main multiverse restricted universe -deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic main multiverse restricted universe -deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main multiverse restricted universe -deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main multiverse restricted universe -deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main multiverse restricted universe -deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main multiverse restricted universe \ No newline at end of file diff --git a/en/application-dev/ability/service-ability.md b/en/application-dev/ability/service-ability.md index 6b1556354adf1f55e937559831fe359072292345..64522a6375f4ccf0f564c56a561bdbb592fa0b7f 100644 --- a/en/application-dev/ability/service-ability.md +++ b/en/application-dev/ability/service-ability.md @@ -29,19 +29,19 @@ ```javascript export default { onStart(want) { - console.log('SerivceAbility onStart'); + console.log('ServiceAbility onStart'); }, onCommand(want, restart, startId) { - console.log('SerivceAbility onCommand'); + console.log('ServiceAbility onCommand'); }, onConnect(want) { - console.log('SerivceAbility OnConnect'); + console.log('ServiceAbility OnConnect'); }, onDisconnect() { - console.log('SerivceAbility OnDisConnect'); + console.log('ServiceAbility OnDisConnect'); }, onStop() { - console.log('SerivceAbility onStop'); + console.log('ServiceAbility onStop'); }, } ``` @@ -170,17 +170,17 @@ export default { mMyStub = new MyStub("ServiceAbility-test"); }, onCommand(want, restart, startId) { - console.log('SerivceAbility onCommand'); + console.log('ServiceAbility onCommand'); }, onConnect(want) { - console.log('SerivceAbility OnConnect'); + console.log('ServiceAbility OnConnect'); return mMyStub; }, onDisconnect() { - console.log('SerivceAbility OnDisConnect'); + console.log('ServiceAbility OnDisConnect'); }, onStop() { - console.log('SerivceAbility onStop'); + console.log('ServiceAbility onStop'); }, } ``` @@ -252,17 +252,17 @@ export default { mMyStub = new MyStub("ServiceAbility-test"); }, onCommand(want, restart, startId) { - console.log('SerivceAbility onCommand'); + console.log('ServiceAbility onCommand'); }, onConnect(want) { - console.log('SerivceAbility OnConnect'); + console.log('ServiceAbility OnConnect'); return mMyStub; }, onDisconnect() { - console.log('SerivceAbility OnDisConnect'); + console.log('ServiceAbility OnDisConnect'); }, onStop() { - console.log('SerivceAbility onStop'); + console.log('ServiceAbility onStop'); }, } ``` diff --git a/en/application-dev/media/audio-overview.md b/en/application-dev/media/audio-overview.md index 5aac5895bc5d0fc7db7ae0351095b1acf265f8e0..c313e9315eb46c440efb116e318148a666d44012 100755 --- a/en/application-dev/media/audio-overview.md +++ b/en/application-dev/media/audio-overview.md @@ -1,8 +1,8 @@ # Audio Overview -OpenHarmony provides the audio module for your application to implement audio-related features, including audio playback and volume management. +You can use APIs provided by the audio module to implement audio-related features, including audio playback and volume management. ->![](../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE** >Due to permission issues, the above features are temporarily unavailable for the standard system. ## Basic Concepts diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md index c3fa3085f88b515ef084d2517807a6155787f083..8fc52e97652cd9755d7f2e3a2094913301cd5709 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle.md +++ b/en/application-dev/reference/apis/js-apis-Bundle.md @@ -12,7 +12,11 @@ SystemCapability.BundleManager.BundleFramework ## Required Permissions -None +| Required Permissions| Permission Level| Description| +|-------| --------- | ---- | +| ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about the current application.| +| ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED| system_basic | Permission to query information about all applications.| +| ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall applications.| ## bundle.getApplicationInfo @@ -20,62 +24,35 @@ getApplicationInfo(bundleName: string, bundleFlags: number, userId: number): Pro Obtains the application information of the specified user based on a given bundle name in asynchronous mode. This method uses a promise to return the result. -**Permission required** +**Required permissions** ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ------ | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes| Bundle name of the application.| -| bundleFlags | number | Yes| Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | Yes| User ID.| +| bundleName | string | Yes | Bundle name of the application. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** -| Type| Description| +| Type | Description| | ----------- | -------- | | Promise\ | Promise used to return the application information.| **Example** ```js -bundle.getApplicationInfo('com.example.myapplicationInstall', 8, 0).then((data) => { - console.info("name: for begin"); - console.info("name:" + data.name); - console.info("bundleName:" + data.bundleName); - console.info("description:" + data.description); - console.info("descriptionId:" + data.descriptionId); - console.info("iconPath:" + data.iconPath); - console.info("iconId:" + data.iconId); - console.info("label:" + data.label); - console.info("labelId:" + data.labelId); - console.info("deviceId:" + data.deviceId); - console.info("signatureKey:" + data.signatureKey); - console.info("process:" + data.process); - console.info("isSystemApp:" + data.isSystemApp); - console.info("isLauncherApp:" + data.isLauncherApp); - console.info("supportedModes:" + data.supportedModes); - - console.info('getApplicationInfo permissions length [' + data.permissions.length + ']'); - for (var j = 0; j < data.permissions.length; j++) { - console.info("permissions[" + j + "]:" + data.permissions[j]); - } - console.info('getApplicationInfo moduleSourceDirs length [' + data.moduleSourceDirs.length + ']'); - for (var j = 0; j < data.moduleSourceDirs.length; j++) { - console.info("moduleSourceDirs[" + j + "]:" + data.moduleSourceDirs[j]); - } - console.info('getApplicationInfo moduleInfos length [' + data.moduleInfos.length + ']'); - for (var j = 0; j < data.moduleInfos.length; j++) { - console.info("moduleInfos[" + j + "]moduleName:" + data.moduleInfos[j].moduleName); - console.info("moduleInfos[" + j + "]moduleSourceDir:" + data.moduleInfos[j].moduleSourceDir); - } - console.info("entryDir:" + data.entryDir); - console.info("codePath:" + data.codePath); - console.info("dataDir:" + data.dataDir); - console.info("dataBaseDir:" + data.dataBaseDir); - console.info("cacheDir:" + data.cacheDir); +let bundleName = "com.example.myapplication"; +let bundleFlags = 0; +let userId = 100; +bundle.getApplicationInfo(bundleName, bundleFlags, userId) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -87,152 +64,69 @@ getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, call Obtains the application information of the specified user based on a given bundle name in asynchronous mode. This method uses a callback to return the result. -**Permission required** +**Required permissions** ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ------------------------------- | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes| Bundle name of the application.| -| bundleFlags | number | Yes| Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | Yes| User ID.| -| callback | AsyncCallback\ | Yes| Callback used to return the application information.| +| bundleName | string | Yes | Bundle name of the application. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback\ | Yes | Callback used to return the application information. | **Example** ```js -bundle.getApplicationInfo('com.example.myapplicationInstall', 8, 0, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info("name: for begin"); - console.info("name:" + data.name); - console.info("bundleName:" + data.bundleName); - console.info("description:" + data.description); - console.info("descriptionId:" + data.descriptionId); - console.info("iconPath:" + data.iconPath); - console.info("iconId:" + data.iconId); - console.info("label:" + data.label); - console.info("labelId:" + data.labelId); - console.info("deviceId:" + data.deviceId); - console.info("signatureKey:" + data.signatureKey); - console.info("process:" + data.process); - console.info("isSystemApp:" + data.isSystemApp); - console.info("isLauncherApp:" + data.isLauncherApp); - console.info("supportedModes:" + data.supportedModes); - - console.info('getApplicationInfo permissions length [' + data.permissions.length + ']'); - for (var j = 0; j < data.permissions.length; j++) { - console.info("permissions[" + j + "]:" + data.permissions[j]); - } - console.info('getApplicationInfo moduleSourceDirs length [' + data.moduleSourceDirs.length + ']'); - for (var j = 0; j < data.moduleSourceDirs.length; j++) { - console.info("moduleSourceDirs[" + j + "]:" + data.moduleSourceDirs[j]); - } - console.info('getApplicationInfo moduleInfos length [' + data.moduleInfos.length + ']'); - for (var j = 0; j < data.moduleInfos.length; j++) { - console.info("moduleInfos[" + j + "]moduleName:" + data.moduleInfos[j].moduleName); - console.info("moduleInfos[" + j + "]moduleSourceDir:" + data.moduleInfos[j].moduleSourceDir); - } - console.info("entryDir:" + data.entryDir); - console.info("codePath:" + data.codePath); - console.info("dataDir:" + data.dataDir); - console.info("dataBaseDir:" + data.dataBaseDir); - console.info("cacheDir:" + data.cacheDir); -} +let bundleName = "com.example.myapplication"; +let bundleFlags = 0; +let userId = 100; +bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); + }) ``` ## bundle.getAllBundleInfo -getAllBundleInfo(bundleFlag: BundleFlag): Promise> +getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise> Obtains the information of all available bundles in the system in asynchronous mode. This method uses a promise to return the result. -**Permission required** +**Required permissions** ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ---------- | ---- | ----------------------------------------------------------- | -| bundleFlag | BundleFlag | Yes| Type of information that will be returned.
**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| +| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** -| Type| Description| +| Type | Description | | --------------------------- | ----------------------------------- | | Promise> | Promise used to return the information of all available bundles.| **Example** ```js -bundle.getAllBundleInfo(0).then((data) => { - for (var i = 0; i < data.length; i++) { - console.info("index[" + i + "].name: for begin"); - console.info("index[" + i + "].name:" + data[i].name); - console.info("index[" + i + "].label:" + data[i].label); - console.info("index[" + i + "].description:" + data[i].description); - console.info("index[" + i + "].vendor:" + data[i].vendor); - console.info("index[" + i + "].versionCode:" + data[i].versionCode); - console.info("index[" + i + "].versionName:" + data[i].versionName); - console.info("index[" + i + "].jointUserId:" + data[i].jointUserId); - console.info("index[" + i + "].minSdkVersion:" + data[i].minSdkVersion); - console.info("index[" + i + "].maxSdkVersion:" + data[i].maxSdkVersion); - console.info("index[" + i + "].mainEntry:" + data[i].mainEntry); - console.info("index[" + i + "].cpuAbi:" + data[i].cpuAbi); - console.info("index[" + i + "].appId:" + data[i].appId); - console.info("index[" + i + "].compatibleVersion:" + data[i].compatibleVersion); - console.info("index[" + i + "].targetVersion:" + data[i].targetVersion); - console.info("index[" + i + "].releaseType:" + data[i].releaseType); - console.info("index[" + i + "].uid:" + data[i].uid); - console.info("index[" + i + "].gid:" + data[i].gid); - console.info("index[" + i + "].seInfo:" + data[i].seInfo); - console.info("index[" + i + "].entryModuleName:" + data[i].entryModuleName); - console.info("index[" + i + "].isKeepAlive:" + data[i].isKeepAlive); - console.info("index[" + i + "].isNativeApp:" + data[i].isNativeApp); - console.info("index[" + i + "].installTime:" + data[i].installTime); - console.info("index[" + i + "].updateTime:" + data[i].updateTime); - console.info("index[" + i + "].appInfo.name:" + data[i].applicationInfo.name); - console.info("index[" + i + "].appInfo.bundleName:" + data[i].applicationInfo.bundleName); - console.info('getAllBundleInfo reqPermissions length [' + data[i].reqPermissions.length + ']'); - for (var j = 0; j < data[i].reqPermissions.length; j++) { - console.info("index[" + i + "]reqPermissions[" + j + "]:" + data[i].reqPermissions[j]); - } - console.info('getAllBundleInfo defPermissions length [' + data[i].defPermissions.length + ']'); - for (var j = 0; j < data[i].defPermissions.length; j++) { - console.info("index[" + i + "]defPermissions[" + j + "]:" + data[i].defPermissions[j]); - } - - console.info('getAllBundleInfo hapModuleNames length [' + data[i].hapModuleNames.length + ']'); - for (var j = 0; j < data[i].hapModuleNames.length; j++) { - console.info("index[" + i + "]hapModuleNames[" + j + "]:" + data[i].hapModuleNames[j]); - } - console.info('getAllBundleInfo moduleNames length [' + data[i].moduleNames.length + ']'); - for (var j = 0; j < data[i].moduleNames.length; j++) { - console.info("index[" + i + "]moduleNames[" + j + "]:" + data[i].moduleNames[j]); - } - console.info('getAllBundleInfo modulePublicDirs length [' + data[i].modulePublicDirs.length + ']'); - for (var j = 0; j < data[i].modulePublicDirs.length; j++) { - console.info("index[" + i + "]modulePublicDirs[" + j + "]:" + data[i].modulePublicDirs[j]); - } - console.info('getAllBundleInfo moduleDirs length [' + data[i].moduleDirs.length + ']'); - for (var j = 0; j < data[i].moduleDirs.length; j++) { - console.info("index[" + i + "]moduleDirs[" + j + "]:" + data[i].moduleDirs[j]); - } - console.info('getAllBundleInfo moduleResPaths length [' + data[i].moduleResPaths.length + ']'); - for (var j = 0; j < data[i].moduleResPaths.length; j++) { - console.info("index[" + i + "]moduleResPaths[" + j + "]:" + data[i].moduleResPaths[j]); - } - console.info('getAllBundleInfo abilityInfo length [' + data[i].abilityInfos.length + ']'); - for (var j = 0; j < data[i].abilityInfos.length; j++) { - console.info("index[" + i + "]abilityInfos[" + j + "]name:" + data[i].abilityInfos[j].name); - console.info("index[" + i + "]abilityInfos[" + j + "]package:" + data[i].abilityInfos[j].package); - } - } +let bundleFlag = 0; +let userId = 100; +bundle.getAllBundleInfo(bundleFlag, userId) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -244,177 +138,103 @@ getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| -| callback | AsyncCallback> | Yes| Callback used to return the information of all available bundles.| +| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. | **Example** ```js -bundle.getAllBundleInfo(0, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info('xxx getAllBundleInfo data length [' + data.length + ']'); - for (var i = 0; i < data.length; i++) { - console.info("index[" + i + "].name: for begin"); - console.info("index[" + i + "].name:" + data[i].name); - console.info("index[" + i + "].label:" + data[i].label); - console.info("index[" + i + "].description:" + data[i].description); - console.info("index[" + i + "].vendor:" + data[i].vendor); - console.info("index[" + i + "].versionCode:" + data[i].versionCode); - console.info("index[" + i + "].versionName:" + data[i].versionName); - console.info("index[" + i + "].jointUserId:" + data[i].jointUserId); - console.info("index[" + i + "].minSdkVersion:" + data[i].minSdkVersion); - console.info("index[" + i + "].maxSdkVersion:" + data[i].maxSdkVersion); - console.info("index[" + i + "].mainEntry:" + data[i].mainEntry); - console.info("index[" + i + "].cpuAbi:" + data[i].cpuAbi); - console.info("index[" + i + "].appId:" + data[i].appId); - console.info("index[" + i + "].compatibleVersion:" + data[i].compatibleVersion); - console.info("index[" + i + "].targetVersion:" + data[i].targetVersion); - console.info("index[" + i + "].releaseType:" + data[i].releaseType); - console.info("index[" + i + "].uid:" + data[i].uid); - console.info("index[" + i + "].gid:" + data[i].gid); - console.info("index[" + i + "].seInfo:" + data[i].seInfo); - console.info("index[" + i + "].entryModuleName:" + data[i].entryModuleName); - console.info("index[" + i + "].isKeepAlive:" + data[i].isKeepAlive); - console.info("index[" + i + "].isNativeApp:" + data[i].isNativeApp); - console.info("index[" + i + "].installTime:" + data[i].installTime); - console.info("index[" + i + "].updateTime:" + data[i].updateTime); - console.info("index[" + i + "].appInfo.name:" + data[i].applicationInfo.name); - console.info("index[" + i + "].appInfo.bundleName:" + data[i].applicationInfo.bundleName); - console.info('getAllBundleInfo reqPermissions length [' + data[i].reqPermissions.length + ']'); - for (var j = 0; j < data[i].reqPermissions.length; j++) { - console.info("index[" + i + "]reqPermissions[" + j + "]:" + data[i].reqPermissions[j]); - } - console.info('getAllBundleInfo defPermissions length [' + data[i].defPermissions.length + ']'); - for (var j = 0; j < data[i].defPermissions.length; j++) { - console.info("index[" + i + "]defPermissions[" + j + "]:" + data[i].defPermissions[j]); - } +let bundleFlag = 0; +bundle.getAllBundleInfo(bundleFlag, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); + }) +``` - console.info('getAllBundleInfo hapModuleNames length [' + data[i].hapModuleNames.length + ']'); - for (var j = 0; j < data[i].hapModuleNames.length; j++) { - console.info("index[" + i + "]hapModuleNames[" + j + "]:" + data[i].hapModuleNames[j]); - } - console.info('getAllBundleInfo moduleNames length [' + data[i].moduleNames.length + ']'); - for (var j = 0; j < data[i].moduleNames.length; j++) { - console.info("index[" + i + "]moduleNames[" + j + "]:" + data[i].moduleNames[j]); - } - console.info('getAllBundleInfo modulePublicDirs length [' + data[i].modulePublicDirs.length + ']'); - for (var j = 0; j < data[i].modulePublicDirs.length; j++) { - console.info("index[" + i + "]modulePublicDirs[" + j + "]:" + data[i].modulePublicDirs[j]); - } - console.info('getAllBundleInfo moduleDirs length [' + data[i].moduleDirs.length + ']'); - for (var j = 0; j < data[i].moduleDirs.length; j++) { - console.info("index[" + i + "]moduleDirs[" + j + "]:" + data[i].moduleDirs[j]); - } - console.info('getAllBundleInfo moduleResPaths length [' + data[i].moduleResPaths.length + ']'); - for (var j = 0; j < data[i].moduleResPaths.length; j++) { - console.info("index[" + i + "]moduleResPaths[" + j + "]:" + data[i].moduleResPaths[j]); - } - console.info('getAllBundleInfo abilityInfo length [' + data[i].abilityInfos.length + ']'); - for (var j = 0; j < data[i].abilityInfos.length; j++) { - console.info("index[" + i + "]abilityInfos[" + j + "]name:" + data[i].abilityInfos[j].name); - console.info("index[" + i + "]abilityInfos[" + j + "]package:" + data[i].abilityInfos[j].package); - } - } -} + +## bundle.getAllBundleInfo + +getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void + +Obtains the information of all available bundles in the system in asynchronous mode. This method uses a callback to return the result. + +**Required permissions** + +ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------- | ---- | ------------------------------------------------------------ | +| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. | + +**Example** + +```js +let bundleFlag = 0; +let userId = 100; +bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); + }) ``` ## bundle.getBundleInfo -getBundleInfo(bundleName: string, bundleFlags: number): Promise\ +getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\ Obtains the bundle information based on a given bundle name in asynchronous mode. This method uses a promise to return the result. -**Permission required** +**Required permissions** ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ------ | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes| Bundle name.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| +| bundleName | string | Yes | Bundle name. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| options | BundleOptions | No | Includes **userId** and **networkId**. | **Return value** -| Type| Description| +| Type | Description | | -------------------- | ------------------------------------------ | | Promise\ | Promise used to return the bundle information.| **Example** ```js -bundle.getBundleInfo('com.example.myapplicationInstall', 1).then((data) => { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("vendor:" + data.vendor); - console.info("versionCode:" + data.versionCode); - console.info("versionName:" + data.versionName); - console.info("jointUserId:" + data.jointUserId); - console.info("minSdkVersion:" + data.minSdkVersion); - console.info("maxSdkVersion:" + data.maxSdkVersion); - console.info("mainEntry:" + data.mainEntry); - console.info("cpuAbi:" + data.cpuAbi); - console.info("appId:" + data.appId); - console.info("compatibleVersion:" + data.compatibleVersion); - console.info("targetVersion:" + data.targetVersion); - console.info("releaseType:" + data.releaseType); - console.info("uid:" + data.uid); - console.info("gid:" + data.gid); - console.info("seInfo:" + data.seInfo); - console.info("entryModuleName:" + data.entryModuleName); - console.info("isKeepAlive:" + data.isKeepAlive); - console.info("isNativeApp:" + data.isNativeApp); - console.info("installTime:" + data.installTime); - console.info("updateTime:" + data.updateTime); - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - console.info('getBundleInfo reqPermissions length [' + data.reqPermissions.length + ']'); - for (var j = 0; j < data.reqPermissions.length; j++) { - console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]); - } - console.info('getBundleInfo defPermissions length [' + data.defPermissions.length + ']'); - for (var j = 0; j < data.defPermissions.length; j++) { - console.info("defPermissions[" + j + "]:" + data.defPermissions[j]); - } - - console.info('getBundleInfo hapModuleNames length [' + data.hapModuleNames.length + ']'); - for (var j = 0; j < data.hapModuleNames.length; j++) { - console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]); - } - console.info('getBundleInfo moduleNames length [' + data.moduleNames.length + ']'); - for (var j = 0; j < data.moduleNames.length; j++) { - console.info("moduleNames[" + j + "]:" + data.moduleNames[j]); - } - console.info('getBundleInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']'); - for (var j = 0; j < data.modulePublicDirs.length; j++) { - console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]); - } - console.info('getBundleInfo moduleDirs length [' + data.moduleDirs.length + ']'); - for (var j = 0; j < data.moduleDirs.length; j++) { - console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]); - } - console.info('getBundleInfo moduleResPaths length [' + data.moduleResPaths.length + ']'); - for (var j = 0; j < data.moduleResPaths.length; j++) { - console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]); - } - console.info('getBundleInfo abilityInfo length [' + data.abilityInfos.length + ']'); - for (var j = 0; j < data.abilityInfos.length; j++) { - console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name); - console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package); - } +let bundleName = "com.example.myapplication"; +let bundleFlags = 1; +let options = { + "userId" : 100, + "networkId" : null +}; +bundle.getBundleInfo(bundleName, bundleFlags, options) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -426,87 +246,70 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< Obtains the bundle information based on a given bundle name in asynchronous mode. This method uses a callback to return the result. -**Permission required** +**Required permissions** ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | -------------------------- | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes| Bundle name.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| -| callback | AsyncCallback\ | Yes| Callback used to return the bundle information.| +| bundleName | string | Yes | Bundle name. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| callback | AsyncCallback\ | Yes | Callback used to return the bundle information. | **Example** ```js -bundle.getBundleInfo('com.example.myapplicationInstall', 1, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("vendor:" + data.vendor); - console.info("versionCode:" + data.versionCode); - console.info("versionName:" + data.versionName); - console.info("jointUserId:" + data.jointUserId); - console.info("minSdkVersion:" + data.minSdkVersion); - console.info("maxSdkVersion:" + data.maxSdkVersion); - console.info("mainEntry:" + data.mainEntry); - console.info("cpuAbi:" + data.cpuAbi); - console.info("appId:" + data.appId); - console.info("compatibleVersion:" + data.compatibleVersion); - console.info("targetVersion:" + data.targetVersion); - console.info("releaseType:" + data.releaseType); - console.info("uid:" + data.uid); - console.info("gid:" + data.gid); - console.info("seInfo:" + data.seInfo); - console.info("entryModuleName:" + data.entryModuleName); - console.info("isKeepAlive:" + data.isKeepAlive); - console.info("isNativeApp:" + data.isNativeApp); - console.info("installTime:" + data.installTime); - console.info("updateTime:" + data.updateTime); - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - console.info('getBundleInfo reqPermissions length [' + data.reqPermissions.length + ']'); - for (var j = 0; j < data.reqPermissions.length; j++) { - console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]); - } - console.info('getBundleInfo defPermissions length [' + data.defPermissions.length + ']'); - for (var j = 0; j < data.defPermissions.length; j++) { - console.info("defPermissions[" + j + "]:" + data.defPermissions[j]); - } - - console.info('getBundleInfo hapModuleNames length [' + data.hapModuleNames.length + ']'); - for (var j = 0; j < data.hapModuleNames.length; j++) { - console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]); - } - console.info('getBundleInfo moduleNames length [' + data.moduleNames.length + ']'); - for (var j = 0; j < data.moduleNames.length; j++) { - console.info("moduleNames[" + j + "]:" + data.moduleNames[j]); - } - console.info('getBundleInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']'); - for (var j = 0; j < data.modulePublicDirs.length; j++) { - console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]); - } - console.info('getBundleInfo moduleDirs length [' + data.moduleDirs.length + ']'); - for (var j = 0; j < data.moduleDirs.length; j++) { - console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]); - } - console.info('getBundleInfo moduleResPaths length [' + data.moduleResPaths.length + ']'); - for (var j = 0; j < data.moduleResPaths.length; j++) { - console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]); - } - console.info('getBundleInfo abilityInfo length [' + data.abilityInfos.length + ']'); - for (var j = 0; j < data.abilityInfos.length; j++) { - console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name); - console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package); - } -} +let bundleName = "com.example.myapplication"; +let bundleFlags = 1; +bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) ``` +## bundle.getBundleInfo + +getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\): void + +Obtains the bundle information based on a given bundle name in asynchronous mode. This method uses a callback to return the result. + +**Required permissions** + +ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | -------------------------- | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| options | BundleOptions | Yes | Includes **userId** and **networkId**. | +| callback | AsyncCallback\ | Yes | Callback used to return the bundle information. | + +**Example** + +```js +let bundleName = "com.example.myapplication"; +let bundleFlags = 1; +let options = { + "userId" : 100, + "networkId" : null +}; +bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) +``` + ## bundle.getAllApplicationInfo @@ -514,64 +317,33 @@ getAllApplicationInfo(bundleFlags: number, userId: number): Promise**0**: The default application information will be returned.
**8**: The application information containing the permission information will be returned.| -| userId | number | Yes| User ID.| +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** -| Type| Description| +| Type | Description | | -------------------------------- | ------------------------------------------------ | | Promise> | Promise used to return the application information.| **Example** ```js -bundle.getAllApplicationInfo(8, 0).then((data) => { - console.info('xxx getAllApplicationInfo data length [' + data.length + ']'); - for (var i = 0; i < data.length; i++) { - console.info("index[" + i + "].name: for begin"); - console.info("index[" + i + "].name:" + data[i].name); - console.info("index[" + i + "].bundleName:" + data[i].bundleName); - console.info("index[" + i + "].description:" + data[i].description); - console.info("index[" + i + "].descriptionId:" + data[i].descriptionId); - console.info("index[" + i + "].iconPath:" + data[i].iconPath); - console.info("index[" + i + "].iconId:" + data[i].iconId); - console.info("index[" + i + "].label:" + data[i].label); - console.info("index[" + i + "].labelId:" + data[i].labelId); - console.info("index[" + i + "].deviceId:" + data[i].deviceId); - console.info("index[" + i + "].signatureKey:" + data[i].signatureKey); - console.info("index[" + i + "].process:" + data[i].process); - console.info("index[" + i + "].isSystemApp:" + data[i].isSystemApp); - console.info("index[" + i + "].isLauncherApp:" + data[i].isLauncherApp); - console.info("index[" + i + "].supportedModes:" + data[i].supportedModes); - - console.info('getAllApplicationInfo Async permissions length [' + data[i].permissions.length + ']'); - for (var j = 0; j < data[i].permissions.length; j++) { - console.info("index[" + i + "]permissions[" + j + "]:" + data[i].permissions[j]); - } - console.info('getAllApplicationInfo Async moduleSourceDirs length [' + data[i].moduleSourceDirs.length + ']'); - for (var j = 0; j < data[i].moduleSourceDirs.length; j++) { - console.info("index[" + i + "]moduleSourceDirs[" + j + "]:" + data[i].moduleSourceDirs[j]); - } - console.info('getAllApplicationInfo Async moduleInfos length [' + data[i].moduleInfos.length + ']'); - for (var j = 0; j < data[i].moduleInfos.length; j++) { - console.info("index[" + i + "]moduleInfos[" + j + "]moduleName:" + data[i].moduleInfos[j].moduleName); - console.info("index[" + i + "]moduleInfos[" + j + "]moduleSourceDir:" + data[i].moduleInfos[j].moduleSourceDir); - } - console.info("index[" + i + "].entryDir:" + data[i].entryDir); - console.info("index[" + i + "].codePath:" + data[i].codePath); - console.info("index[" + i + "].dataDir:" + data[i].dataDir); - console.info("index[" + i + "].dataBaseDir:" + data[i].dataBaseDir); - console.info("index[" + i + "].cacheDir:" + data[i].cacheDir); - } +let bundleFlags = 8; +let userId = 100; +bundle.getAllApplicationInfo(bundleFlags, userId) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -583,62 +355,30 @@ getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallba Obtains the information about all installed applications of the specified user. This method uses a callback to return the result. -**Permission required** +**Required permissions** -ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO +ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | -------------------------------------- | ---- | ------------------------------------------------------ | -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default application information will be returned.
**8**: The application information containing the permission information will be returned.| -| userId | number | Yes| User ID.| -| callback | AsyncCallback> | Yes| Callback used to return the application information.| +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback> | Yes | Callback used to return the application information. | **Example** ```js -bundle.getAllApplicationInfo(8, 0, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info('xxx getAllApplicationInfo data length [' + data.length + ']'); - for (var i = 0; i < data.length; i++) { - console.info("index[" + i + "].name: for begin"); - console.info("index[" + i + "].name:" + data[i].name); - console.info("index[" + i + "].bundleName:" + data[i].bundleName); - console.info("index[" + i + "].description:" + data[i].description); - console.info("index[" + i + "].descriptionId:" + data[i].descriptionId); - console.info("index[" + i + "].iconPath:" + data[i].iconPath); - console.info("index[" + i + "].iconId:" + data[i].iconId); - console.info("index[" + i + "].label:" + data[i].label); - console.info("index[" + i + "].labelId:" + data[i].labelId); - console.info("index[" + i + "].deviceId:" + data[i].deviceId); - console.info("index[" + i + "].signatureKey:" + data[i].signatureKey); - console.info("index[" + i + "].process:" + data[i].process); - console.info("index[" + i + "].isSystemApp:" + data[i].isSystemApp); - console.info("index[" + i + "].isLauncherApp:" + data[i].isLauncherApp); - console.info("index[" + i + "].supportedModes:" + data[i].supportedModes); - - console.info('getAllApplicationInfo Async permissions length [' + data[i].permissions.length + ']'); - for (var j = 0; j < data[i].permissions.length; j++) { - console.info("index[" + i + "]permissions[" + j + "]:" + data[i].permissions[j]); - } - console.info('getAllApplicationInfo Async moduleSourceDirs length [' + data[i].moduleSourceDirs.length + ']'); - for (var j = 0; j < data[i].moduleSourceDirs.length; j++) { - console.info("index[" + i + "]moduleSourceDirs[" + j + "]:" + data[i].moduleSourceDirs[j]); - } - console.info('getAllApplicationInfo Async moduleInfos length [' + data[i].moduleInfos.length + ']'); - for (var j = 0; j < data[i].moduleInfos.length; j++) { - console.info("index[" + i + "]moduleInfos[" + j + "]moduleName:" + data[i].moduleInfos[j].moduleName); - console.info("index[" + i + "]moduleInfos[" + j + "]moduleSourceDir:" + data[i].moduleInfos[j].moduleSourceDir); - } - console.info("index[" + i + "].entryDir:" + data[i].entryDir); - console.info("index[" + i + "].codePath:" + data[i].codePath); - console.info("index[" + i + "].dataDir:" + data[i].dataDir); - console.info("index[" + i + "].dataBaseDir:" + data[i].dataBaseDir); - console.info("index[" + i + "].cacheDir:" + data[i].cacheDir); - } -} +let bundleFlags = 8; +let userId = 100; +bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) ``` @@ -649,101 +389,38 @@ queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise**0**: The default ability information will be returned.
**2**: The ability information containing the permission information will be returned.
**4**: The ability information containing the application information will be returned.| -| userId | number | No| User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| +| want | Want | Yes | Want that contains the bundle name. | +| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** -| Type| Description| +| Type | Description | | ---------------------------- | ---------------------------- | | Promise\>| Promise used to return the ability information.| **Example** ```js -bundle.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplicationInstall", - abilityName: "com.example.myapplication.MainAbility", - }, - } -}, 1, 0, -}).then((data) => { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("iconPath:" + data.iconPath); - console.info("visible:" + data.visible); - console.info("kind:" + data.kind); - console.info("uri:" + data.uri); - console.info("process:" + data.process); - console.info("package:" + data.package); - console.info("bundleName:" + data.bundleName); - console.info("moduleName:" + data.moduleName); - console.info("applicationName:" + data.applicationName); - console.info("deviceId:" + data.deviceId); - console.info("codePath:" + data.codePath); - console.info("resourcePath:" + data.resourcePath); - console.info("libPath:" + data.libPath); - - console.info('queryAbilityInfo permissions length [' + data.permissions.length + ']'); - for (var j = 0; j < data.permissions.length; j++) { - console.info("permissions[" + j + "]:" + data.permissions[j]); - } - console.info('queryAbilityInfo deviceTypes length [' + data.deviceTypes.length + ']'); - for (var j = 0; j < data.deviceTypes.length; j++) { - console.info("deviceTypes[" + j + "]:" + data.deviceTypes[j]); - } - console.info('queryAbilityInfo deviceCapabilities length [' + data.deviceCapabilities.length + ']'); - for (var j = 0; j < data.deviceCapabilities.length; j++) { - console.info("deviceCapabilities[" + j + "]:" + data.deviceCapabilities[j]); - } - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - // ability type: 0:UNKNOWN, 1:PAGE, 2:SERVICE, 3:DATA - console.info("type:" + data.type); - // orientation: 0:UNSPECIFIED, 1:LANDSCAPE, 2:PORTRAIT, 3:FOLLOWRECENT, - console.info("orientation:" + data.orientation); - // launchMode: 0:SINGLETON, 1:SINGLETOP, 2:STANDARD - console.info("launchMode:" + data.launchMode); - - // the enum of AbilityType - console.info("AbilityType:" + bundle.AbilityType.UNKNOWN); - console.info("AbilityType:" + bundle.AbilityType.PAGE); - console.info("AbilityType:" + bundle.AbilityType.SERVICE); - console.info("AbilityType:" + bundle.AbilityType.DATA); - if (data.type == bundle.AbilityType.PAGE) { - console.info("this AbilityType is PAGE"); - } - // the enum of DisplayOrientation - console.info("DisplayOrientation:" + bundle.DisplayOrientation.UNSPECIFIED); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.LANDSCAPE); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.PORTRAIT); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.FOLLOWRECENT); - if (data.orientation == bundle.DisplayOrientation.UNSPECIFIED) { - console.info("this DisplayOrientation is UNSPECIFIED"); - } - // the enum of LaunchMode - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETON); - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETOP); - console.info("LaunchMode:" + bundle.LaunchMode.STANDARD); - if (data.launchMode == bundle.LaunchMode.STANDARD) { - console.info("this LaunchMode is STANDARD"); - } - +let bundleFlags = 0; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; +bundle.queryAbilityByWant(want, bundleFlags, userId) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -757,93 +434,29 @@ Obtains the ability information of the specified user based on a given want. Thi **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| want | Want | Yes| Want that contains the bundle name.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default ability information will be returned.
**2**: The ability information containing the permission information will be returned.
**4**: The ability information containing the application information will be returned.| -| userId | number | Yes| User ID.| -| callback | AsyncCallback> | Yes| Callback used to return the ability information.| +| want | Want | Yes | Want that contains the bundle name. | +| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback> | Yes | Callback used to return the ability information. | **Example** ```js -bundle.queryAbilityByWant( - { - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplicationInstall", - abilityName: "com.example.myapplication.MainAbility", - }, - } - }, 1, 0, - }, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("iconPath:" + data.iconPath); - console.info("visible:" + data.visible); - console.info("kind:" + data.kind); - console.info("uri:" + data.uri); - console.info("process:" + data.process); - console.info("package:" + data.package); - console.info("bundleName:" + data.bundleName); - console.info("moduleName:" + data.moduleName); - console.info("applicationName:" + data.applicationName); - console.info("deviceId:" + data.deviceId); - console.info("codePath:" + data.codePath); - console.info("resourcePath:" + data.resourcePath); - console.info("libPath:" + data.libPath); - - console.info('queryAbilityInfo permissions length [' + data.permissions.length + ']'); - for (var j = 0; j < data.permissions.length; j++) { - console.info("permissions[" + j + "]:" + data.permissions[j]); - } - console.info('queryAbilityInfo deviceTypes length [' + data.deviceTypes.length + ']'); - for (var j = 0; j < data.deviceTypes.length; j++) { - console.info("deviceTypes[" + j + "]:" + data.deviceTypes[j]); - } - console.info('queryAbilityInfo deviceCapabilities length [' + data.deviceCapabilities.length + ']'); - for (var j = 0; j < data.deviceCapabilities.length; j++) { - console.info("deviceCapabilities[" + j + "]:" + data.deviceCapabilities[j]); - } - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - // ability type: 0:UNKNOWN, 1:PAGE, 2:SERVICE, 3:DATA - console.info("type:" + data.type); - // orientation: 0:UNSPECIFIED, 1:LANDSCAPE, 2:PORTRAIT, 3:FOLLOWRECENT, - console.info("orientation:" + data.orientation); - // launchMode: 0:SINGLETON, 1:SINGLETOP, 2:STANDARD - console.info("launchMode:" + data.launchMode); - - // the enum of AbilityType - console.info("AbilityType:" + bundle.AbilityType.UNKNOWN); - console.info("AbilityType:" + bundle.AbilityType.PAGE); - console.info("AbilityType:" + bundle.AbilityType.SERVICE); - console.info("AbilityType:" + bundle.AbilityType.DATA); - if (data.type == bundle.AbilityType.PAGE) { - console.info("this AbilityType is PAGE"); - } - // the enum of DisplayOrientation - console.info("DisplayOrientation:" + bundle.DisplayOrientation.UNSPECIFIED); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.LANDSCAPE); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.PORTRAIT); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.FOLLOWRECENT); - if (data.orientation == bundle.DisplayOrientation.UNSPECIFIED) { - console.info("this DisplayOrientation is UNSPECIFIED"); - } - // the enum of LaunchMode - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETON); - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETOP); - console.info("LaunchMode:" + bundle.LaunchMode.STANDARD); - if (data.launchMode == bundle.LaunchMode.STANDARD) { - console.info("this LaunchMode is STANDARD"); - } -} +let bundleFlags = 0; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; +bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) ``` ## bundle.queryAbilityByWant @@ -854,288 +467,65 @@ Obtains the ability information based on a given want. This method uses an async **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| want | Want | Yes| Want that contains the bundle name.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default ability information will be returned.
**2**: The ability information containing the permission information will be returned.
**4**: The ability information containing the application information will be returned.| -| callback | AsyncCallback> | Yes| Callback used to return the ability information.| - -**Example** - -```js -bundle.queryAbilityByWant( - { - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplicationInstall", - abilityName: "com.example.myapplication.MainAbility", - }, - } - }, 1, - }, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("iconPath:" + data.iconPath); - console.info("visible:" + data.visible); - console.info("kind:" + data.kind); - console.info("uri:" + data.uri); - console.info("process:" + data.process); - console.info("package:" + data.package); - console.info("bundleName:" + data.bundleName); - console.info("moduleName:" + data.moduleName); - console.info("applicationName:" + data.applicationName); - console.info("deviceId:" + data.deviceId); - console.info("codePath:" + data.codePath); - console.info("resourcePath:" + data.resourcePath); - console.info("libPath:" + data.libPath); - - console.info('queryAbilityInfo permissions length [' + data.permissions.length + ']'); - for (var j = 0; j < data.permissions.length; j++) { - console.info("permissions[" + j + "]:" + data.permissions[j]); - } - console.info('queryAbilityInfo deviceTypes length [' + data.deviceTypes.length + ']'); - for (var j = 0; j < data.deviceTypes.length; j++) { - console.info("deviceTypes[" + j + "]:" + data.deviceTypes[j]); - } - console.info('queryAbilityInfo deviceCapabilities length [' + data.deviceCapabilities.length + ']'); - for (var j = 0; j < data.deviceCapabilities.length; j++) { - console.info("deviceCapabilities[" + j + "]:" + data.deviceCapabilities[j]); - } - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - // ability type: 0:UNKNOWN, 1:PAGE, 2:SERVICE, 3:DATA - console.info("type:" + data.type); - // orientation: 0:UNSPECIFIED, 1:LANDSCAPE, 2:PORTRAIT, 3:FOLLOWRECENT, - console.info("orientation:" + data.orientation); - // launchMode: 0:SINGLETON, 1:SINGLETOP, 2:STANDARD - console.info("launchMode:" + data.launchMode); - - // the enum of AbilityType - console.info("AbilityType:" + bundle.AbilityType.UNKNOWN); - console.info("AbilityType:" + bundle.AbilityType.PAGE); - console.info("AbilityType:" + bundle.AbilityType.SERVICE); - console.info("AbilityType:" + bundle.AbilityType.DATA); - if (data.type == bundle.AbilityType.PAGE) { - console.info("this AbilityType is PAGE"); - } - // the enum of DisplayOrientation - console.info("DisplayOrientation:" + bundle.DisplayOrientation.UNSPECIFIED); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.LANDSCAPE); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.PORTRAIT); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.FOLLOWRECENT); - if (data.orientation == bundle.DisplayOrientation.UNSPECIFIED) { - console.info("this DisplayOrientation is UNSPECIFIED"); - } - // the enum of LaunchMode - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETON); - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETOP); - console.info("LaunchMode:" + bundle.LaunchMode.STANDARD); - if (data.launchMode == bundle.LaunchMode.STANDARD) { - console.info("this LaunchMode is STANDARD"); - } -} -``` - -## bundle.getBundleArchiveInfo - -getBundleArchiveInfo(hapFilePath: string, bundleFlags: number): Promise\ - -Obtains the bundle information from a given HAP file in asynchronous mode. This method uses a promise to return the result. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ----------- | ------ | ---- | ------------------------------------------------------------ | -| hapFilePath | string | Yes| Path of the HAP file.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| - -**Return value** - -| Type| Description| -| -------------------- | ------------------------------------------ | -| Promise\ | Promise used to return the bundle information.| +| want | Want | Yes | Want that contains the bundle name. | +| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| callback | AsyncCallback> | Yes | Callback used to return the ability information. | **Example** ```js -bundle.getBundleArchiveInfo('/data/test.hap', 1).then((data) => { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("vendor:" + data.vendor); - console.info("versionCode:" + data.versionCode); - console.info("versionName:" + data.versionName); - console.info("jointUserId:" + data.jointUserId); - console.info("minSdkVersion:" + data.minSdkVersion); - console.info("maxSdkVersion:" + data.maxSdkVersion); - console.info("mainEntry:" + data.mainEntry); - console.info("cpuAbi:" + data.cpuAbi); - console.info("appId:" + data.appId); - console.info("compatibleVersion:" + data.compatibleVersion); - console.info("targetVersion:" + data.targetVersion); - console.info("releaseType:" + data.releaseType); - console.info("uid:" + data.uid); - console.info("gid:" + data.gid); - console.info("seInfo:" + data.seInfo); - console.info("entryModuleName:" + data.entryModuleName); - console.info("isKeepAlive:" + data.isKeepAlive); - console.info("isNativeApp:" + data.isNativeApp); - console.info("installTime:" + data.installTime); - console.info("updateTime:" + data.updateTime); - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - console.info('getBundleArchiveInfo reqPermissions length [' + data.reqPermissions.length + ']'); - for (var j = 0; j < data.reqPermissions.length; j++) { - console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]); - } - console.info('getBundleArchiveInfo defPermissions length [' + data.defPermissions.length + ']'); - for (var j = 0; j < data.defPermissions.length; j++) { - console.info("defPermissions[" + j + "]:" + data.defPermissions[j]); - } - console.info('getBundleArchiveInfo hapModuleNames length [' + data.hapModuleNames.length + ']'); - for (var j = 0; j < data.hapModuleNames.length; j++) { - console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]); - } - console.info('getBundleArchiveInfo moduleNames length [' + data.moduleNames.length + ']'); - for (var j = 0; j < data.moduleNames.length; j++) { - console.info("moduleNames[" + j + "]:" + data.moduleNames[j]); - } - console.info('getBundleArchiveInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']'); - for (var j = 0; j < data.modulePublicDirs.length; j++) { - console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]); - } - console.info('getBundleArchiveInfo moduleDirs length [' + data.moduleDirs.length + ']'); - for (var j = 0; j < data.moduleDirs.length; j++) { - console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]); - } - console.info('getBundleArchiveInfo moduleResPaths length [' + data.moduleResPaths.length + ']'); - for (var j = 0; j < data.moduleResPaths.length; j++) { - console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]); - } - console.info('getBundleArchiveInfo abilityInfo length [' + data.abilityInfos.length + ']'); - for (var j = 0; j < data.abilityInfos.length; j++) { - console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name); - console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package); - } +let bundleFlags = 0; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; +bundle.queryAbilityByWant(want, bundleFlags, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); }) ``` -## bundle.getBundleArchiveInfo - -getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\): void - -Obtains the bundle information from a given HAP file in asynchronous mode. This method uses a callback to return the result. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ----------- | ------------------------- | ---- | ------------------------------------------------------------ | -| hapFilePath | string | Yes| Path of the HAP file.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| -| callback | AsyncCallback | Yes| Callback used to return the bundle information.| - -**Example** - -```js -bundle.getBundleArchiveInfo('/data/test.hap', 1, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("vendor:" + data.vendor); - console.info("versionCode:" + data.versionCode); - console.info("versionName:" + data.versionName); - console.info("jointUserId:" + data.jointUserId); - console.info("minSdkVersion:" + data.minSdkVersion); - console.info("maxSdkVersion:" + data.maxSdkVersion); - console.info("mainEntry:" + data.mainEntry); - console.info("cpuAbi:" + data.cpuAbi); - console.info("appId:" + data.appId); - console.info("compatibleVersion:" + data.compatibleVersion); - console.info("targetVersion:" + data.targetVersion); - console.info("releaseType:" + data.releaseType); - console.info("uid:" + data.uid); - console.info("gid:" + data.gid); - console.info("seInfo:" + data.seInfo); - console.info("entryModuleName:" + data.entryModuleName); - console.info("isKeepAlive:" + data.isKeepAlive); - console.info("isNativeApp:" + data.isNativeApp); - console.info("installTime:" + data.installTime); - console.info("updateTime:" + data.updateTime); - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - console.info('getBundleArchiveInfo reqPermissions length [' + data.reqPermissions.length + ']'); - for (var j = 0; j < data.reqPermissions.length; j++) { - console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]); - } - console.info('getBundleArchiveInfo defPermissions length [' + data.defPermissions.length + ']'); - for (var j = 0; j < data.defPermissions.length; j++) { - console.info("defPermissions[" + j + "]:" + data.defPermissions[j]); - } - console.info('getBundleArchiveInfo hapModuleNames length [' + data.hapModuleNames.length + ']'); - for (var j = 0; j < data.hapModuleNames.length; j++) { - console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]); - } - console.info('getBundleArchiveInfo moduleNames length [' + data.moduleNames.length + ']'); - for (var j = 0; j < data.moduleNames.length; j++) { - console.info("moduleNames[" + j + "]:" + data.moduleNames[j]); - } - console.info('getBundleArchiveInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']'); - for (var j = 0; j < data.modulePublicDirs.length; j++) { - console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]); - } - console.info('getBundleArchiveInfo moduleDirs length [' + data.moduleDirs.length + ']'); - for (var j = 0; j < data.moduleDirs.length; j++) { - console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]); - } - console.info('getBundleArchiveInfo moduleResPaths length [' + data.moduleResPaths.length + ']'); - for (var j = 0; j < data.moduleResPaths.length; j++) { - console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]); - } - console.info('getBundleArchiveInfo abilityInfo length [' + data.abilityInfos.length + ']'); - for (var j = 0; j < data.abilityInfos.length; j++) { - console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name); - console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package); - } -} -``` - ## bundle.getBundleInstaller getBundleInstaller(): Promise Obtains the bundle installer in asynchronous mode. This method uses a promise to return the result. +**Required permissions** + +ohos.permission.INSTALL_BUNDLE + **Return value** -| Type| Description| +| Type | Description | | ------------------------ | --------------------------------------------------- | | Promise | Promise used to return the bundle installer.| **Example** ```js -bundle.getBundleInstaller().then((data) => { - data.install(['/data/test.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } - }, OnReceiveinstallEvent); - - function OnReceiveinstallEvent(err, data) { - console.info("name: for begin"); - console.info("install result code:" + data.status); - console.info("install result msg:" + data.statusMessage); - } +let bundleFilePaths = ['/data/test.hap']; +let param = { + userId : 100, + installFlag : 1, + isKeepData : false +}; +bundle.getBundleInstaller() +.then((installerObject) => { + console.info('Operation successful. '); + installerObject.install(bundleFilePaths, param) + .then((data) => { + console.info('Operation successful. Data:' + JSON.stringify(data)); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -1145,141 +535,401 @@ getBundleInstaller(callback: AsyncCallback): void; Obtains the bundle installer in asynchronous mode. This method uses a callback to return the result. +**Required permissions** + +ohos.permission.INSTALL_BUNDLE + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ------------------------------ | ---- | ------------------------------------------------- | -| callback | AsyncCallback | Yes| Callback used to return the bundle installer.| +| callback | AsyncCallback | Yes | Callback used to return the bundle installer.| **Example** ```js -bundle.getBundleInstaller((err, data)=>{ - data.uninstall('com.example.myapplication', { - userId: 0, - installFlag: 1, - isKeepData: false - }, OnReceiveinstallEvent); - - function OnReceiveinstallEvent(err, data) { - console.info("name: for begin"); - console.info("uninstall result code:" + data.status); - console.info("uninstall result msg:" + data.statusMessage); - } +let bundleFilePaths = ['/data/test.hap']; +let param = { + userId : 100, + installFlag : 1, + isKeepData : false +}; +bundle.getBundleInstaller((err, installerObject) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + } + console.info('Operation successful. Data:' + JSON.stringify(installerObject)); + installerObject.install(bundleFilePaths, param, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + } + console.info('Operation successful. Data:' + JSON.stringify(data)); + }) }) ``` -## bundle.getAllShortcutInfo -getAllShortcutInfo(bundleName: string): Promise> +## bundle.getLaunchWantForBundle + +getLaunchWantForBundle(bundleName: string): Promise\ + +Obtains the **Want** object that launches the specified application in asynchronous mode. This method uses a promise to return the result. -Obtains the shortcut information of the specified bundle in asynchronous mode. This method uses a promise to return the result. +**Required permissions** + +ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ------ | ---- | -------- | -| bundleName | string | Yes| Bundle name.| +| bundleName | string | Yes | Bundle name of the application.| **Return value** -| Type| Description| -| ----------------------------- | ---------------------------------------------------- | -| Promise\> | Promise used to return the shortcut information.| +| Type | Description | +| --------------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the **Want** object.| **Example** ```js -bundle.getAllShortcutInfo('com.example.third1').then((data) => { - console.log("getAllShortcutInfo data:" + data); -}); +let bundleName = "com.example.myapplication"; +bundle.getLaunchWantForBundle(bundleName) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}) ``` +## bundle.getLaunchWantForBundle +getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void; -## bundle.getAllShortcutInfo +Obtains the **Want** object that launches the specified application in asynchronous mode. This method uses a callback to return the result. -getAllShortcutInfo(bundleName: string, callback: AsyncCallback>): void +**Required permissions** -Obtains the shortcut information of the specified bundle in asynchronous mode. This method uses a callback to return the result. +ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED **Parameters** -| Name| Type| Mandatory| Description| -| ---------- | ------------------------------------ | ---- | -------------------------------------------------- | -| bundleName | string | Yes| Bundle name.| -| callback | AsyncCallback<> | Yes| Callback used to return the shortcut information.| +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------- | +| bundleName | string | Yes | Bundle name of the application.| +| callback | AsyncCallback\ | Yes | Callback used to return the **Want** object.| **Example** ```js -bundle.getAllShortcutInfo('com.example.third1', OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.log("getAllShortcutInfo data:" + data); -} +let bundleName = "com.example.myapplication"; +bundle.getLaunchWantForBundle(bundleName, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) ``` -## bundle.checkPermission -checkPermission(bundleName: string, permission: string): Promise\ +## bundle.getNameForUid + +getNameForUid(uid: number): Promise\ -Checks whether a bundle has the specified permission in asynchronous mode. This method uses a promise to return the result. +Obtains the bundle name based on a UID in asynchronous mode. This method uses a promise to return the result. **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ------ | ---- | -------- | -| bundleName | string | Yes| Bundle name.| -| permission | string | Yes| Permission name.| +| uid | number | Yes | UID based on which the bundle name is to obtain.| **Return value** -| Type| Description| +| Type | Description | | --------------------- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the verification result.
**-1**: The bundle does not have the specified permission.
**0**: The bundle has the specified permission.| +| Promise\ | Promise used to return the bundle name.| **Example** ```js -bundle.checkPermission('com.example.actsbmscheckpermissiontest', 'com.permission.CAMERA').then((data) => { - console.log("checkPermission data:" + data); -}); +let uid = 20010005; +bundle.getNameForUid(uid) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}) ``` -## bundle.checkPermission +## bundle.getNameForUid -checkPermission(bundleName: string, permission: string, callback: AsyncCallback\): void +getNameForUid(uid: number, callback: AsyncCallback): void; -Checks whether a bundle has the specified permission in asynchronous mode. This method uses a callback to return the result. +Obtains the bundle name based on a UID in asynchronous mode. This method uses a callback to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| ---------- | --------------------------- | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes| Bundle name.| -| permission | string | Yes| Permission name.| -| callback | AsyncCallback\ | Yes| Callback used to return the verification result.
**-1**: The bundle does not have the specified permission.
**0**: The bundle has the specified permission.| +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------- | +| uid | number | Yes | UID based on which the bundle name is to obtain.| +| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.| **Example** ```js -bundle.checkPermission('com.example.actsbmscheckpermissiontest', 'com.permission.CAMERA', OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.log("checkPermission data:" + data); -} +let uid = 20010005; +bundle.getNameForUid(uid, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) ``` + ## ElementName -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ----------- | -------- | ------ | ---- | ------------------------------------------------------------ | -| deviceId | Read-only| string | No| ID of the device that runs the ability.| -| bundleName | Read-only| string | Yes| Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| -| abilityName | Read-only| string | Yes| Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| +| deviceId | Read-only | string | No | ID of the device that runs the ability. | +| bundleName | Read-only | string | Yes | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| +| abilityName | Read-only | string | Yes | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| +| uri | Read-only | string | No | Resource ID.| +| shortName | Read-only | string | No | Short name of the **ElementName**.| ## InstallStatus -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ------------- | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| status | Read-only| InstallErrorCode | Yes| Installation result code.
SUCCESS = 0
STATUS_INSTALL_FAILURE = 1
STATUS_INSTALL_FAILURE_ABORTED = 2
STATUS_INSTALL_FAILURE_INVALID = 3
STATUS_INSTALL_FAILURE_CONFLICT = 4
STATUS_INSTALL_FAILURE_STORAGE = 5
STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6
STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B
STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C
STATUS_ABILITY_NOT_FOUND = 0x40
STATUS_BMS_SERVICE_ERROR = 0x41 | -| statusMessage | Read-only| string | Yes| Message indicating the installation result.| +| status | Read-only | InstallErrorCode | Yes | Installation result code.
SUCCESS = 0
STATUS_INSTALL_FAILURE = 1
STATUS_INSTALL_FAILURE_ABORTED = 2,
STATUS_INSTALL_FAILURE_INVALID = 3
STATUS_INSTALL_FAILURE_CONFLICT = 4
STATUS_INSTALL_FAILURE_STORAGE = 5
STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6
STATUS_UNINSTALL_FAILURE = 7
STATUS_UNINSTALL_FAILURE_BLOCKED = 8
STATUS_UNINSTALL_FAILURE_ABORTED = 9
STATUS_UNINSTALL_FAILURE_CONFLICT = 10
STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B
STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C
STATUS_RECOVER_FAILURE_INVALID = 0x0D
STATUS_ABILITY_NOT_FOUND = 0x40
STATUS_BMS_SERVICE_ERROR = 0x41
STATUS_FAILED_NO_SPACE_LEFT = 0x42
STATUS_GRANT_REQUEST_PERMISSIONS_FAILED = 0x43
STATUS_INSTALL_PERMISSION_DENIED = 0x44
STATUS_UNINSTALL_PERMISSION_DENIED = 0x45 | + +## BundleFlag + +Enumerates the bundle flags. + +| Name | Default Value| Description | +| ------ | ------ | ------ | +| GET_BUNDLE_DEFAULT | 0x00000000 | Obtains the default application information.| +| GET_BUNDLE_WITH_ABILITIES | 0x00000001 | Obtains the bundle information with the ability information.| +| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000002 | Obtains the ability information with the permission information.| +| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | Obtains the ability information with the application information.| +| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | Obtains the application information with the permission information.| +| GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | Obtains the bundle information with the information about the required permissions.| +| GET_ABILITY_INFO_WITH_METADATA | 0x00000020 | Obtains the ability metadata information.| +| GET_APPLICATION_INFO_WITH_METADATA | 0x00000040 | Obtains the application metadata information.| +| GET_ABILITY_INFO_SYSTEMAPP_ONLY | 0x00000080 | Obtains only the ability information with information about system applications.| +| GET_ABILITY_INFO_WITH_DISABLE | 0x00000100 | Obtains information about disabled abilities.| +| GET_APPLICATION_INFO_WITH_DISABLE | 0x00000200 | Obtains information about disabled applications.| +| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information.| + +## BundleOptions + +Describes the bundle options. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| userId | number | Yes| Yes| User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| +| networkId | string | Yes| Yes| Network ID. The default value is **null**.| + +## BundleInfo + +Describes the application bundle information. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| name | string | Yes | No | Bundle name. | +| type | string | Yes | No | Bundle type. | +| appId | string | Yes | No | ID of the application to which the bundle belongs. | +| uid | number | Yes | No | UID of the application to which the bundle belongs. | +| installTime | number | Yes | No | Time when the HAP file is installed. | +| updateTime | number | Yes | No | Time when the HAP file is updated. | +| appInfo | ApplicationInfo | Yes | No | Application configuration information. | +| abilityInfo | Array | Yes | No | Ability configuration information. | +| reqPermissions | Array | Yes | No | Array of the permissions to request from the system. | +| reqPermissionDetails | Array | Yes | No | Detailed information of the permissions to request from the system.| +| vendor | string | Yes | No | Vendor of the bundle. | +| versionCode | number | Yes | No | Version number of the bundle. | +| versionName | string | Yes | No | Version description of the bundle. | +| compatibleVersion | number | Yes | No | Earliest SDK version required for running the bundle. | +| targetVersion | number | Yes | No | Latest SDK version required for running the bundle. | +| isCompressNativeLibs | boolean | Yes | No | Whether to compress the native library of the bundle. The default value is **true**. | +| hapModuleInfo | Array | Yes | No | Module configuration information. | +| entryModuleName | string | Yes | No | Name of the entry module. | +| cpuAbi | string | Yes | No | cpuAbi information of the bundle. | +| isSilentInstallation | string | Yes | No | Whether to install the bundle in silent mode. | +| minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. | +| entryInstallationFree | boolean | Yes| No| Whether installation-free is supported for the entry.| +| reqPermissionStates | Array | Yes| No| Permission grant state.| + +## ApplicationInfo + +Describes the application information. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| name | string | Yes | No | Application name. | +| description | string | Yes | No | Application description. | +| descriptionId | number | Yes | No | Application description ID. | +| systemApp | boolean | Yes | No | Whether the application is a system application. The default value is **false**. | +| enabled | boolean | Yes | No | Whether the application is enabled. The default value is **true**. | +| label | string | Yes | No | Application label. | +| labelId | string | Yes | No | Application label ID. | +| icon | string | Yes | No | Application icon. | +| iconId | string | Yes | No | Application icon ID. | +| process | string | Yes | No | Process in which this application runs. If this parameter is not set, the bundle name is used by default.| +| supportedModes | number | Yes | No | Running modes supported by the application. | +| moduleSourceDirs | Array | Yes | No | Relative paths for storing application resources. | +| permissions | Array | Yes | No | Permissions required for accessing the application. | +| moduleInfos | Array | Yes | No | Application module information. | +| entryDir | string | Yes | No | Path for storing application files. | +| customizeData | Map> | Yes | Yes | Custom data of the application. | +| codePath | string | Yes| No| Installation directory of the application.| +| metaData | Map> | Yes| No| Custom metadata of the application.| +| removable | boolean | Yes| No| Whether the application is removable.| +| accessTokenId | number | Yes| No| Access token ID of the application.| +| uid | number | Yes| No| UID of the application.| + +## ModuleInfo + +Describes the application module information. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| moduleName | string | Yes | No | Module name.| +| moduleSourceDir | string | Yes | No | Installation directory.| + +## CustomizeData + +Describes the custom metadata. + +| Name | Type | Readable| Writable| Description | +| ----- | ------ | ---- | ---- | ---------------- | +| name | string | Yes | Yes | Custom metadata name.| +| value | string | Yes | Yes | Custom metadata value. | +| extra | string | Yes | Yes | Custom resources. | + + +## HapModuleInfo + +Describes the HAP module information. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| name | string | Yes | No | Module name. | +| description | string | Yes | No | Module description. | +| descriptionId | number | Yes | No | Module description ID. | +| icon | string | Yes | No | Module icon. | +| label | string | Yes | No | Module label. | +| labelId | number | Yes | No | Module label ID. | +| iconId | number | Yes | No | Module icon ID. | +| backgroundImg | string | Yes | No | Module background image. | +| supportedModes | number | Yes | No | Modes supported by the module. | +| reqCapabilities | Array | Yes | No | Capabilities required for module running.| +| deviceTypes | Array | Yes | No | An array of supported device types.| +| abilityInfo | Array | Yes | No | Ability information. | +| moduleName | string | Yes | No | Module name. | +| mainAbilityName | string | Yes | No | Name of the entry ability. | +| installationFree | boolean | Yes | No | Whether installation-free is supported. | +| mainElementName | string | Yes| No| Information about the entry ability.| + +## ReqPermissionDetail + +Describes the detailed information of the permissions to request from the system. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| name | string | Yes | Yes | Name of the permission to request. | +| reason | string | Yes | Yes | Reason for requesting the permission. | +| usedScene | UsedScene | Yes| Yes| Application scenario and timing for using the permission.| + +## UsedScene + +Describes the application scenario and timing for using the permission. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| abilities | Array | Yes | Yes | Abilities that use the permission.| +| when | string | Yes | Yes | Time when the permission is used. | + + +## AbilityInfo + +Describes ability information. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| bundleName | string | Yes | No | Application bundle name. | +| name | string | Yes | No | Ability name. | +| label | string | Yes | No | Ability name visible to users. | +| description | string | Yes | No | Ability description. | +| icon | string | Yes | No | Index of the ability icon resource file. | +| descriptionId | number | Yes | No | Ability description ID. | +| iconId | number | Yes | No | Ability icon ID. | +| moduleName | string | Yes | No | Name of the HAP file to which the ability belongs. | +| process | string | Yes | No | Process in which this ability runs. If this parameter is not set, the bundle name is used by default.| +| targetAbility | string | Yes | No | Target ability that this ability alias points to. | +| backgroundModes | number | Yes | No | Background service mode of the ability. | +| isVisible | boolean | Yes | No | Whether the ability can be called by other applications. | +| formEnabled | boolean | Yes | No | Whether the ability provides the service widget capability. | +| type | AbilityType | Yes | No | Ability type. | +| orientation | DisplayOrientation | Yes | No | Ability display orientation. | +| launchMode | LaunchMode | Yes | No | Ability launch mode. | +| permissions | Array | Yes | No | Permissions required for other applications to call the ability.| +| deviceTypes | Array | Yes | No | Device types supported by the ability. | +| deviceCapabilities | Array | Yes | No | Device capabilities required for the ability. | +| readPermission | string | Yes | No | Permission required for reading the ability data. | +| writePermission | string | Yes | No | Permission required for writing data to the ability. | +| applicationInfo | ApplicationInfo | Yes | No | Application configuration information. | +| formEntity | number | Yes | No | Area where the ability form can be displayed. | +| minFormHeight | number | Yes | No | Minimum height of the ability form. | +| defaultFormHeight | number | Yes | No | Default height of the ability form. | +| minFormWidth | number | Yes | No | Minimum width of the ability form. | +| defaultFormWidth | number | Yes | No | Default width of the ability form. | +| uri | string | Yes | No | URI of the ability. | +| customizeData | Map> | Yes | Yes | Custom data of the ability. | +| labelId | number | Yes | No | Ability label ID. | +| subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability. | +| metaData | Array | Yes| No| Custom metadata of the ability.| +| enabled | boolean | Yes| No| Whether the ability is enabled.| + +## AbilityType + +Describes the ability type. + +| Name | Type| Description | +| ------- | ---- | --------------------------- | +| UNKNOWN | None | Unknown ability type. | +| PAGE | None | Ability that has a UI. | +| SERVICE | None | Ability that does not have a UI. | +| DATA | None | Ability that is used to provide data access services.| + +## DisplayOrientation + +Describes the display orientation. + +| Name | Type| Description | +| ------------- | ---- | ------------------------ | +| UNSPECIFIED | None | The system automatically determines the display orientation. | +| LANDSCAPE | None | Landscape orientation. | +| PORTRAIT | None | Portrait orientation. | +| FOLLOW_RECENT | None | The page ability orientation is the same as that of the nearest ability in the stack.| + +## LaunchMode + +Describes the launch mode. + +| Name | Type| Description | +| ----------- | ---- | ------------------- | +| UNSPECIFIED | 0 | The ability has only one instance.| +| STANDARD | 1 | The ability can have multiple instances. | + +## AbilitySubType + +Describes the ability subtype. + +| Name | Type| Description | +| ----------- | ---- | ----------------------------- | +| UNSPECIFIED | 0 | Undefined ability subtype. | +| CA | 1 | Ability that has a UI.| diff --git a/en/application-dev/reference/apis/js-apis-Context.md b/en/application-dev/reference/apis/js-apis-Context.md index 57a9f803f3fa4a5929e43eb01db6e651bff3b1f4..ea7efb523f253f83fec2133b7a9acb37ddd5727d 100644 --- a/en/application-dev/reference/apis/js-apis-Context.md +++ b/en/application-dev/reference/apis/js-apis-Context.md @@ -25,12 +25,16 @@ Obtains the local root directory of the application. This method uses a callback If this method is called for the first time, a root directory is created. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | -------------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the local root directory of the application.| +| callback | AsyncCallback\ | Yes | Callback used to return the local root directory of the application.| **Example** @@ -52,9 +56,13 @@ Obtains the local root directory of the application. This method uses a promise If this method is called for the first time, a root directory is created. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | ---------------- | ---------------------- | | Promise\ | Promise used to return the local root directory of the application.| @@ -76,14 +84,18 @@ verifyPermission(permission: string, options: PermissionOptions, callback: Async Verifies whether a specific PID and UID have the given permission. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | --------------------------------------- | ---- | ------------------------------------- | -| permission | string | Yes| Name of the permission to verify.| -| options | [PermissionOptions](#permissionoptions) | Yes| Permission options.| -| callback | AsyncCallback\ | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| +| permission | string | Yes | Name of the permission to verify. | +| options | [PermissionOptions](#permissionoptions) | Yes | Permission options. | +| callback | AsyncCallback\ | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| **Example** @@ -107,10 +119,10 @@ Verifies whether the current PID and UID have the given permission. This method **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ---------------------- | ---- | ------------------------------------- | -| permission | string | Yes| Name of the permission to verify.| -| callback | AsyncCallback\ | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| +| permission | string | Yes | Name of the permission to verify. | +| callback | AsyncCallback\ | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| **Example** @@ -126,17 +138,21 @@ verifyPermission(permission: string, options?: PermissionOptions): Promise\ | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| @@ -160,14 +176,18 @@ requestPermissionsFromUser(permissions: Array\, requestCode: number, res Requests certain permissions from the system. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | -| permissions | Array\ | Yes| Permissions to request. This parameter cannot be **null**.| -| requestCode | number | Yes| Request code to be passed to **PermissionRequestResult**.| -| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes| Permission request result.| +| permissions | Array\ | Yes | Permissions to request. This parameter cannot be **null**. | +| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**.| +| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes | Permission request result. | **Example** ```js @@ -194,11 +214,15 @@ getApplicationInfo(callback: AsyncCallback\) Obtains information about the current application. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ------------------------------- | ---- | ------------------------ | -| callback | AsyncCallback\ | Yes| Callback used to return the application information.| +| callback | AsyncCallback\ | Yes | Callback used to return the application information.| **Example** @@ -216,9 +240,13 @@ getApplicationInfo(): Promise\ Obtains information about the current application. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | ------------------------- | ------------------ | | Promise\ | Promise used to return the application information.| @@ -241,11 +269,15 @@ getBundleName(callback: AsyncCallback\): void Obtains the bundle name of the current ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ----------------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the bundle name.| +| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.| **Example** @@ -263,9 +295,13 @@ getBundleName(): Promise\ Obtains the bundle name of the current ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | ---------------- | ------------------------- | | Promise\ | Promise used to return the bundle name.| @@ -288,11 +324,15 @@ getProcessInfo(callback: AsyncCallback\) Obtains information about the current process, including the PID and process name. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the process information.| +| callback | AsyncCallback\ | Yes | Callback used to return the process information.| **Example** @@ -310,9 +350,13 @@ getProcessInfo(): Promise\ Obtains information about the current process, including the PID and process name. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | --------------------- | -------------- | | Promise\ | Promise used to return the process information.| @@ -337,11 +381,15 @@ Obtains the **ohos.bundle.ElementName** object of the current ability. This meth This method is available only to Page abilities. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ---------------------------------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the **ohos.bundle.ElementName** object.| +| callback | AsyncCallback\ | Yes | Callback used to return the **ohos.bundle.ElementName** object.| **Example** @@ -361,9 +409,13 @@ Obtains the **ohos.bundle.ElementName** object of the current ability. This meth This method is available only to Page abilities. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | --------------------- | ------------------------------------------ | | Promise\ | Promise used to return the **ohos.bundle.ElementName** object.| @@ -384,9 +436,13 @@ getProcessName(callback: AsyncCallback\): void Obtains the name of the current process. This method uses a callback to return the result. -| Name| Type| Mandatory| Description| +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the process name.| +| callback | AsyncCallback\ | Yes | Callback used to return the process name.| **Example** @@ -404,9 +460,13 @@ getProcessName(): Promise\ Obtains the name of the current process. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | ---------------- | -------------------- | | Promise\ | Promise used to return the process name.| @@ -429,11 +489,15 @@ getCallingBundle(callback: AsyncCallback\): void Obtains the bundle name of the calling ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the bundle name.| +| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.| **Example** @@ -451,9 +515,13 @@ getCallingBundle(): Promise\ Obtains the bundle name of the calling ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | --------------- | ------------------------- | | Promise\ | Promise used to return the bundle name.| @@ -470,15 +538,15 @@ context.getCallingBundle().then((data) => { ## PermissionOptions -| Name| Readable/Writable| Type| Mandatory| Description| +| Name| Readable/Writable| Type | Mandatory| Description | | ---- | -------- | ------ | ---- | ------ | -| pid | Read-only| number | No| PID.| -| uid | Read-only| number | No| UID.| +| pid | Read-only | number | No | PID.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| +| uid | Read-only | number | No | UID.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| ## PermissionRequestResult -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ----------- | -------- | -------------- | ---- | ------------------ | -| requestCode | Read-only| number | Yes| Request code passed.| -| permissions | Read-only| Array\ | Yes| Permissions passed.| -| authResults | Read-only| Array\ | Yes| Permission request result.| +| requestCode | Read-only | number | Yes | Request code passed.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| +| permissions | Read-only | Array\ | Yes | Permissions passed.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core | +| authResults | Read-only | Array\ | Yes | Permission request result.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core | diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md index 5d85731dc2ee337581c5fa38d7d52d60170675d4..7652774178a2357e7a8cb5928545f80348d1c2d2 100644 --- a/en/application-dev/reference/apis/js-apis-ability-context.md +++ b/en/application-dev/reference/apis/js-apis-ability-context.md @@ -1,12 +1,29 @@ # AbilityContext -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** -> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. Implements the ability context. This module is inherited from **Context**. +## Usage + + +Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**. + + + +``` +import Ability from '@ohos.application.Ability' +class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + let context = this.context; + } +} +``` + + ## Attributes | Name| Type| Readable| Writable| Description| @@ -21,6 +38,10 @@ startAbility(want: Want, callback: AsyncCallback<void>): void Starts an ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -42,14 +63,53 @@ Starts an ability. This method uses a callback to return the result. ## startAbility -startAbility(want: Want): Promise<void>; +startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void + +Starts an ability. This method uses a callback to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the **Want** used for starting an ability.| + | options | StartOptions | Yes| Parameters used for starting the ability.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + +- Example + + ``` + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "com.extreme.test.MainAbility" + }; + var options = { + windowMode: 0, + }; + this.context.startAbility(want, options, (error) => { + console.log("error.code = " + error.code) + }) + ``` + + +## startAbility + +startAbility(want: Want, options: StartOptions): Promise<void>; Starts an ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| + | options | StartOptions | Yes| Parameters used for starting the ability.| - Return value | Type| Description| @@ -63,7 +123,10 @@ Starts an ability. This method uses a promise to return the result. "bundleName": "com.extreme.test", "abilityName": "com.extreme.test.MainAbility" }; - this.context.startAbility(want) + var options = { + windowMode: 0, + }; + this.context.startAbility(want, options) .then((data) => { console.log('Operation successful.') }).catch((error) => { @@ -78,11 +141,15 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): Starts an ability. This method uses a callback to return the execution result when the ability is terminated. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | want |[Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| - | callback | Callback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| + | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| - Example @@ -96,17 +163,55 @@ Starts an ability. This method uses a callback to return the execution result wh ); ``` +## startAbilityForResult + +startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void; + +Starts an ability. This method uses a callback to return the execution result when the ability is terminated. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want |[Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| + | options | StartOptions | Yes| Parameters used for starting the ability.| + | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| + + +- Example + ``` + var options = { + windowMode: 0, + }; + this.context.startAbilityForResult( + {bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options, + (error, result) => { + console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code) + console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode) + } + ); + ``` + ## startAbilityForResult -startAbilityForResult(want: Want): Promise<AbilityResult>; +startAbilityForResult(want: Want, options: StartOptions): Promise<AbilityResult>; Starts an ability. This method uses a promise to return the execution result when the ability is terminated. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| + | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| + | options | StartOptions | Yes| Parameters used for starting the ability.| + - Return value | Type| Description| @@ -115,7 +220,10 @@ Starts an ability. This method uses a promise to return the execution result whe - Example ``` - this.context.startAbilityForResult({bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}).then((result) => { + var options = { + windowMode: 0, + }; + this.context.startAbilityForResult({bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options).then((result) => { console.log("startAbilityForResult Promise.resolve is called, result.resultCode = " + result.resultCode) }, (error) => { console.log("startAbilityForResult Promise.Reject is called, error.code = " + error.code) @@ -129,16 +237,20 @@ terminateSelf(callback: AsyncCallback<void>): void; Terminates this ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the method is successfully called.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the method is successfully called.| - Example ``` this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringfy(err); - } + console.log('terminateSelf result:' + JSON.stringfy(err)); + }); ``` @@ -148,6 +260,10 @@ terminateSelf(): Promise<void>; Terminates this ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Return value | Type| Description| | -------- | -------- | @@ -157,7 +273,7 @@ Terminates this ability. This method uses a promise to return the result. ``` this.context.terminateSelf(want).then((data) => { console.log('success:' + JSON.stringfy(data)); - )).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringfy(error)); }); ``` @@ -169,11 +285,15 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi Terminates this ability. This method uses a callback to return the information to the caller of **startAbilityForResult**. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.| - | callback | Callback<void> | No| Callback used to return the information.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| - Example ``` @@ -194,6 +314,10 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>; Terminates this ability. This method uses a promise to return information to the caller of **startAbilityForResult**. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -215,3 +339,157 @@ Terminates this ability. This method uses a promise to return information to the } ) ``` + + +## startAbilityByCall + +startAbilityByCall(want: Want): Promise<Caller>; + +Obtains the caller interface of the specified ability, and if the specified ability is not started, starts the ability in the background. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<> | Promise used to return the caller object to communicate with.| + +- Example + + ``` + import Ability from '@ohos.application.Ability'; + var caller; + export default class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + this.context.startAbilityByCall({ + bundleName: "com.example.myservice", + abilityName: "com.example.myservice.MainAbility", + deviceId: "" + }).then((obj) => { + caller = obj; + console.log('Caller GetCaller Get ' + call); + }).catch((e) => { + console.log('Caller GetCaller error ' + e); + }); + } + } + ``` + + +## requestPermissionsFromUser + +requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; + +Requests permissions from the user by displaying a pop-up window. This method uses a callback to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | permissions | Array<string> | Yes| Permissions to request.| + | callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result indicating whether the method is successfully called.| + +- Example + + ``` + this.context.requestPermissionsFromUser(permissions,(result) => { + console.log('requestPermissionsFromUserresult:' + JSON.stringfy(result)); + }); + ``` + + +## requestPermissionsFromUser + +requestPermissionsFromUser(permissions: Array<string>) : Promise<PermissionRequestResult>; + +Requests permissions from the user by displaying a pop-up window. This method uses a promise to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | permissions | Array<string> | Yes| Permissions to request.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result indicating whether the method is successfully called.| + +- Example + + ``` + this.context.requestPermissionsFromUser(permissions).then((data) => { + console.log('success:' + JSON.stringfy(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringfy(error)); + }); + ``` + + +## setMissionLabel + +setMissionLabel(label: string, callback:AsyncCallback<void>): void; + +Sets the label of the ability displayed in the task. This method uses a callback to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | label | string | Yes| Label of the ability to set.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the method is successfully called.| + +- Example + + ``` + this.context.setMissionLabel("test",(result) => { + console.log('requestPermissionsFromUserresult:' + JSON.stringfy(result)); + }); + ``` + + +## setMissionLabel + +setMissionLabel(label: string): Promise<void> + +Sets the label of the ability displayed in the task. This method uses a promise to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | label | string | Yes| Label of the ability to set.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return the result indicating whether the method is successfully called.| + +- Example + + ``` + this.context.setMissionLabel("test").then((data) => { + console.log('success:' + JSON.stringfy(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringfy(error)); + }); + ``` diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md new file mode 100644 index 0000000000000000000000000000000000000000..e3ba42ce0955682922d7d36766a8a4544d111b83 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-arraylist.md @@ -0,0 +1,576 @@ +# Linear Container ArrayList + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +``` +import ArrayList from '@ohos.util.ArrayList' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## ArrayList + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in an array list (called container later).| + + +### constructor + +constructor() + +A constructor used to create an **ArrayList** instance. + +**Example** + +``` +let arrayList = new ArrayList(); +``` + + +### add + +add(element: T): boolean + +Adds an entry at the end of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + + ``` + let arrayList = new ArrayList(); + let result = arrayList.add("a"); + let result1 = arrayList.add(1); + let b = [1, 2, 3]; + let result2 = arrayList.add(b); + let c = {name: "lala", age: "13"}; + let result3 = arrayList.add(false); + ``` + +### insert + +insert(element: T, index: number): void + +Inserts an entry at the specified position in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to insert.| +| index | number | Yes| Index of the position where the entry is to be inserted.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.insert("A", 0); +arrayList.insert(0, 1); +arrayList.insert(true, 2); +``` + +### has + +has(element: T): boolean + +Checks whether this container has the specified entry. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to check.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.| + +**Example** + +``` +let arrayList = new ArrayList(); +let result = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +arrayList.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result1 = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + +### getIndexOf + +getIndexOf(element: T): number + +Obtains the index of the first occurrence of the specified entry in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(2); +arrayList.add(1); +arrayList.add(2); +arrayList.add(4); +let result = arrayList.getIndexOf(2); +``` + +### getLastIndexOf + +getLastIndexOf(element: T): number + +Obtains the index of the last occurrence of the specified entry in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(2); +arrayList.add(1); +arrayList.add(2); +arrayList.add(4); +let result = arrayList.getLastIndexOf(2); +``` + +### removeByIndex + +removeByIndex(index: number): T + +Removes an entry with the specified position from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(2); +arrayList.add(4); +let result = arrayList.removeByIndex(2); +``` + +### remove + +remove(element: T): boolean + +Removes the first occurrence of the specified entry from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result = arrayList.remove(2); +``` + +### removeByRange + +removeByRange(fromIndex: number, toIndex: number): void + +Removes from this container all of the entries within a range, including the entry at the start position but not that at the end position. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fromIndex | number | Yes| Index of the start position.| +| toIndex | number | Yes| Index of the end position.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.removeByRange(2, 4); +arrayList.removeByRange(4, 3); +arrayList.removeByRange(2, 6); +``` + +### replaceAllElements +replaceAllElements(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => T, +thisArg?: Object): void + +Replaces all entries in this container with new entries, and returns the new ones. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked for the replacement.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| arrlist | ArrayList<T> | No| Instance that invokes the **replaceAllElements** method.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.replaceAllElements((value, index) => { + return value = 2 * value; +}); +arrayList.replaceAllElements((value, index) => { + return value = value - 2; +}); +``` + +### forEach +forEach(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => void, +thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| arrlist | ArrayList<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.forEach((value, index) => { + console.log(value, index); +}); +``` + +### sort +sort(comparator?: (firstValue: T, secondValue: T) => number): void + +Sorts entries in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| comparator | function | No| Callback invoked for sorting.| + +comparator + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| firstValue | T | Yes| Previous entry.| +| secondValue | T | Yes| Next entry.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.sort(a, (b => a - b)); +arrayList.sort(a, (b => b - a)); +arrayList.sort(); +``` + +### subArrayList +subArrayList(fromIndex: number, toIndex: number): ArrayList<T> + +Obtains entries within a range in this container, including the entry at the start position but not that at the end position, and returns these entries as a new **ArrayList** instance. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fromIndex | number | Yes| Index of the start position.| +| toIndex | number | Yes| Index of the end position.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| ArrayList<T> | New **ArrayList** instance obtained.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result1 = arrayList.subArrayList(2, 4); +let result2 = arrayList.subArrayList(4, 3); +let result3 = arrayList.subArrayList(2, 6); +``` + +### clear +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.clear(); +``` + +### clone +clone(): ArrayList<T> + +Clones this container and returns a copy. The modification to the copy does not affect the original instance. + + +**Return value** + +| Type| Description| +| -------- | -------- | +| ArrayList<T> | New **ArrayList** instance obtained.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result = arrayList.clone(); +``` + +### getCapacity +getCapacity(): number + +Obtains the capacity of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Capacity obtained.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result = arrayList.getCapacity(); +``` + +### convertToArray +convertToArray(): Array<T> + +Converts this container into an array. + +**Return value** + +| Type| Description| +| -------- | -------- | +| Array<T> | Array obtained.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result = arrayList.convertToArray(); +``` + +### isEmpty +isEmpty(): boolean + +Checks whether this container is empty (contains no entry). + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result = arrayList.isEmpty(); +``` + +### increaseCapacityTo +increaseCapacityTo(newCapacity: number): void + +Increases the capacity of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| newCapacity | number | Yes| New capacity.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.increaseCapacityTo(2); +arrayList.increaseCapacityTo(8); +``` + +### trimToCurrentLength +trimToCurrentLength(): void + +Trims the capacity of this container to its current length. + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.trimToCurrentLength(); +``` + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); + +// Method 1: +for (let item of arrayList) { + console.log(item); +} + +// Method 2: +let iter = arrayList[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index 80ac13c01931162680670633ac374864c8a24101..85d2dc6b01ebe7dc2dc97e3965985ae1a61efb52 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -1,6 +1,7 @@ # Audio -This module provides the following functions: audio management, audio rendering and system sound management. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -284,8 +285,18 @@ Enumerates audio device types. +## ActiveDeviceType -## AudioRingMode7+ +Enumerates the active device types. + +| Name | Default Value | Default Value | +| ------------- | ------ | ------------------------------------------------------------ | +| SPEAKER | 2 | Speaker.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | +| BLUETOOTH_SCO | 7 | Bluetooth device using the SCO link.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | + + + +## AudioRingMode Enumerates ringer modes. @@ -1028,7 +1039,7 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=> ## audioManager.mute -mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void7+ +mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void Mutes a stream. This method uses an asynchronous callback to return the result. @@ -1096,7 +1107,7 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { ## audioManager.mute -mute\(volumeType: AudioVolumeType, mute: boolean\): Promise7+ +mute\(volumeType: AudioVolumeType, mute: boolean\): Promise Mutes a stream. This method uses a promise to return the result. @@ -1164,7 +1175,7 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => ## audioManager.isMute -isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+ +isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. @@ -1223,7 +1234,7 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { ## audioManager.isMute -isMute\(volumeType: AudioVolumeType\): Promise7+ +isMute\(volumeType: AudioVolumeType\): Promise Checks whether a stream is muted. This method uses a promise to return the result. @@ -1282,7 +1293,7 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => ## audioManager.isActive -isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+ +isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\) Checks whether a stream is active. This method uses an asynchronous callback to return the query result. @@ -1341,7 +1352,7 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { ## audioManager.isActive -isActive\(volumeType: AudioVolumeType\): Promise7+ +isActive\(volumeType: AudioVolumeType\): Promise Checks whether a stream is active. This method uses a promise to return the query result. @@ -1400,7 +1411,7 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => ## audioManager.setRingerMode -setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void7+ +setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void Sets the ringer mode. This method uses an asynchronous callback to return the result. @@ -1459,7 +1470,7 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { ## audioManager.setRingerMode -setRingerMode\(mode: AudioRingMode\): Promise7+ +setRingerMode\(mode: AudioRingMode\): Promise Sets the ringer mode. This method uses a promise to return the result. @@ -1518,7 +1529,7 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => ## audioManager.getRingerMode -getRingerMode\(callback: AsyncCallback\): void7+ +getRingerMode\(callback: AsyncCallback\): void Obtains the ringer mode. This method uses an asynchronous callback to return the query result. @@ -1568,7 +1579,7 @@ audioManager.getRingerMode((err, value) => { ## audioManager.getRingerMode -getRingerMode\(\): Promise7+ +getRingerMode\(\): Promise Obtains the ringer mode. This method uses a promise to return the query result. @@ -1606,7 +1617,7 @@ audioManager.getRingerMode().then((value) => ## audioManager.setAudioParameter -setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void7+ +setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void Sets an audio parameter. This method uses an asynchronous callback to return the result. @@ -1674,7 +1685,7 @@ audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => { ## audioManager.setAudioParameter -setAudioParameter\(key: string, value: string\): Promise7+ +setAudioParameter\(key: string, value: string\): Promise Sets an audio parameter. This method uses a promise to return the result. @@ -1742,7 +1753,7 @@ audioManager.setAudioParameter('PBits per sample', '8 bit').then(() => ## audioManager.getAudioParameter -getAudioParameter\(key: string, callback: AsyncCallback\): void7+ +getAudioParameter\(key: string, callback: AsyncCallback\) Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result. @@ -1801,7 +1812,7 @@ audioManager.getAudioParameter('PBits per sample', (err, value) => { ## audioManager.getAudioParameter -getAudioParameter\(key: string\): Promise7+ +getAudioParameter\(key: string\): Promise Obtains the value of an audio parameter. This method uses a promise to return the query result. @@ -1979,7 +1990,7 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=> ## audioManager.setDeviceActive -setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback\): void7+ +setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback\): void Sets a device to the active state. This method uses an asynchronous callback to return the result. @@ -2048,7 +2059,7 @@ audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err)=> { ## audioManager.setDeviceActive -setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise7+ +setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise Sets a device to the active state. This method uses a promise to return the result. @@ -2116,7 +2127,7 @@ audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=> ## audioManager.isDeviceActive -isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void7+ +isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void Checks whether a device is active. This method uses an asynchronous callback to return the query result. @@ -2175,7 +2186,7 @@ audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => { ## audioManager.isDeviceActive -isDeviceActive\(deviceType: DeviceType\): Promise7+ +isDeviceActive\(deviceType: DeviceType\): Promise Checks whether a device is active. This method uses a promise to return the query result. @@ -2234,7 +2245,7 @@ audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => ## audioManager.setMicrophoneMute -setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void7+ +setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. @@ -2293,7 +2304,7 @@ audioManager.setMicrophoneMute(true, (err) => { ## audioManager.setMicrophoneMute -setMicrophoneMute\(mute: boolean\): Promise7+ +setMicrophoneMute\(mute: boolean\): Promise Mutes or unmutes the microphone. This method uses a promise to return the result. @@ -2352,7 +2363,7 @@ audioManager.setMicrophoneMute(true).then(() => ## audioManager.isMicrophoneMute -isMicrophoneMute\(callback: AsyncCallback\): void7+ +isMicrophoneMute\(callback: AsyncCallback\): void Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. @@ -2402,7 +2413,7 @@ audioManager.isMicrophoneMute((err, value) => { ## audioManager.isMicrophoneMute -isMicrophoneMute\(\): Promise7+ +isMicrophoneMute\(\): Promise Checks whether the microphone is muted. This method uses a promise to return the query result. @@ -4121,3 +4132,20 @@ None ``` await ringtonePlayer.release(); ``` + + +## AudioDeviceDescriptor + +Describes an audio device. + +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | +| deviceType | [DeviceType](#devicetype) | Yes | No | Device type.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | + + +## AudioDeviceDescriptors + +| Name | Description | +| -------- | -------- | +| AudioDeviceDescriptors | Array of **AudioDeviceDescriptor** objects. It is read-only.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index cb8927953871984a8f7784697f61071d96715b94..dc54b14b351dc85a09abd394681bd1dd2d182568 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -17,7 +17,9 @@ dial\(phoneNumber: string, callback: AsyncCallback\): void Initiates a call. This function uses an asynchronous callback to return the execution result. -Before using this API, you must declare the **ohos.permission.PLACE\_CALL** permission (a system permission). +**Required permission**: ohos.permission.PLACE\_CALL (a system permission) + +**System capability**: SystemCapability.Telephony.CallManager **Parameters** @@ -41,7 +43,9 @@ dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback Initiates a call. You can set call options as needed. This function uses a promise to return the execution result. -Before using this API, you must declare the **ohos.permission.PLACE\_CALL** permission (a system permission). +**Required permission**: ohos.permission.PLACE\_CALL (a system permission) + +**System capability**: SystemCapability.Telephony.CallManager **Parameters** @@ -102,6 +108,8 @@ hasCall\(callback: AsyncCallback\): void Checks whether a call is in progress. This function uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Telephony.CallManager + **Parameters** | Name| Type| Mandatory| Description| @@ -123,6 +131,8 @@ hasCall\(\): Promise Checks whether a call is in progress. This function uses a promise to return the result. +**System capability**: SystemCapability.Telephony.CallManager + **Return value** | Type| Description| @@ -147,6 +157,8 @@ getCallState\(callback: AsyncCallback\): void Obtains the call status. This function uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Telephony.CallManager + **Parameters** | Name| Type| Mandatory| Description| @@ -168,6 +180,8 @@ getCallState\(\): Promise Obtains the call status. This function uses a promise to return the result. +**System capability**: SystemCapability.Telephony.CallManager + **Return value** | Type| Description| @@ -191,6 +205,8 @@ isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback\) Checks whether the call number of the SIM card in the specified slot is an emergency number. This function uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Telephony.CallManager + **Parameters** | Name| Type| Mandatory| Description| @@ -213,6 +229,8 @@ isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, ca Checks whether the call number of the SIM card in the specified slot is an emergency number. This function uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Telephony.CallManager + **Parameters** | Name| Type| Mandatory| Description| @@ -236,6 +254,8 @@ isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Checks whether the call number of the SIM card in the specified slot is an emergency number. This function uses a promise to return the result. +**System capability**: SystemCapability.Telephony.CallManager + **Parameters** | Name| Type| Mandatory| Description| @@ -266,6 +286,8 @@ formatPhoneNumber\(phoneNumber: string, callback: AsyncCallback\): void Formats a phone number based on the specified ISO country code. This function uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Telephony.CallManager + **Parameters** | Name| Type| Mandatory| Description| @@ -288,6 +310,8 @@ formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: Formats a phone number based on specified formatting options. This function uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Telephony.CallManager + **Parameters** | Name| Type| Mandatory| Description| @@ -313,6 +337,8 @@ formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise Formats a phone number based on specified formatting options. This function uses a promise to return the result. +**System capability**: SystemCapability.Telephony.CallManager + **Parameters** | Name| Type| Mandatory| Description| @@ -349,6 +375,8 @@ The phone number must match the specified country code. For example, for a China All country codes are supported. +**System capability**: SystemCapability.Telephony.CallManager + **Parameters** | Name| Type| Mandatory| Description| @@ -378,6 +406,8 @@ The phone number must match the specified country code. For example, for a China All country codes are supported. +**System capability**: SystemCapability.Telephony.CallManager + **Parameters** | Name| Type| Mandatory| Description| @@ -407,30 +437,40 @@ promise.then(data => { ## DialOptions Provides an option for determining whether a call is a video call. -| Parameter| Type| Mandatory| Description| + +**System capability**: SystemCapability.Telephony.CallManager + +| Name| Type| Mandatory| Description| | ------ | ------- | ---- | ------------------------------------------------------------ | | extras | boolean | No| Indication of a video call. The options are as follows:
- **true**: video call
- **false**: voice call| ## CallState Enumerates call states. + | Variable| Value| Description| | ------------------ | ---- | ------------------------------------------------------------ | -| CALL_STATE_UNKNOWN | -1 | The call status fails to be obtained and is unknown.| -| CALL_STATE_IDLE | 0 | No call is in progress.| -| CALL_STATE_RINGING | 1 | The call is in the ringing or waiting state.| -| CALL_STATE_OFFHOOK | 2 | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.| +| CALL_STATE_UNKNOWN | -1 | The call status fails to be obtained and is unknown.
**System capability**: SystemCapability.Telephony.CallManager| +| CALL_STATE_IDLE | 0 | No call is in progress.
**System capability**: SystemCapability.Telephony.CallManager| +| CALL_STATE_RINGING | 1 | The call is in the ringing or waiting state.
**System capability**: SystemCapability.Telephony.CallManager| +| CALL_STATE_OFFHOOK | 2 | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.
**System capability**: SystemCapability.Telephony.CallManager| ## EmergencyNumberOptions7+ Provides an option for determining whether a number is an emergency number for the SIM card in the specified slot. -| Parameter| Type| Mandatory| Description| + +**System capability**: SystemCapability.Telephony.CallManager + +| Name| Type| Mandatory| Description| | ------ | ------ | ---- | ------------------------------------------ | | slotId | number | No| SIM card slot ID.
- **0**: slot 1
- **1**: slot 2| ## NumberFormatOptions7+ Provides an option for number formatting. -| Parameter| Type| Mandatory| Description| + +**System capability**: SystemCapability.Telephony.CallManager + +| Name| Type| Mandatory| Description| | ----------- | ------ | ---- | ---------------------------------------------------------- | | countryCode | string | No| Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.| diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index 92aef3bc743bc5a1e0466fecbbefa94a274f5af3..c076a882942d2145b641555efd8ac2bd5a504fd4 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -1,5 +1,8 @@ # Camera +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Modules to Import ``` diff --git a/en/application-dev/reference/apis/js-apis-commonEvent.md b/en/application-dev/reference/apis/js-apis-commonEvent.md index 655c8682e35e4fe583806a9c9d9c152b0b895abf..32045b0f0c9ed3b12b105e154611456ced48c46b 100644 --- a/en/application-dev/reference/apis/js-apis-commonEvent.md +++ b/en/application-dev/reference/apis/js-apis-commonEvent.md @@ -169,9 +169,9 @@ Publishes a common event with given attributes. This method uses a callback to r ```js // Attributes of a common event. var options = { - code: 0; // Result code of the common event - data: "initial data";// Result data of the common event - isOrdered: true; // The common event is an ordered one. + code: 0, // Result code of the common event + data: "initial data",// Result data of the common event + isOrdered: true // The common event is an ordered one. } // Callback for common event publication function PublishCallBack(err) { diff --git a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md index 75adfb3f60a650fce157a9fb56ac8c645e395480..49e61156a499d926620ecd0aa7bb6455c4aec9c7 100644 --- a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -16,13 +16,17 @@ openFile(uri: string, mode: string, callback: AsyncCallback\): void Opens a file with a specified URI. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ---------------------------------- | -| uri | string | Yes| URI of the file to open.| -| mode | string | Yes| Mode for opening the file. The value can be **rwt**.| -| callback | AsyncCallback\ | Yes| Callback used to return the file descriptor.| +| uri | string | Yes | URI of the file to open. | +| mode | string | Yes | Mode for opening the file. The value can be **rwt**. | +| callback | AsyncCallback\ | Yes | Callback used to return the file descriptor.| **Example** @@ -46,15 +50,19 @@ openFile(uri: string, mode: string): Promise\ Opens a file with a specified URI. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory| Description | | ---- | ------ | ---- | ------------------------ | -| uri | string | Yes| URI of the file to open.| -| mode | string | Yes| Mode for opening the file. The value can be **rwt**.| +| uri | string | Yes | URI of the file to open.| +| mode | string | Yes | Mode for opening the file. The value can be **rwt**. | **Return value** -| Type| Description| +| Type | Description | | ---------------- | ---------------- | | Promise\ | Promise used to return the file descriptor.| @@ -79,13 +87,17 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback\): void Registers an observer to observe data specified by a given URI. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------ | -| type | string | Yes| Type of the event to observe. The value is **dataChange**.| -| uri | string | Yes| URI of the data.| -| callback | AsyncCallback\ | Yes| Callback invoked when the data is changed.| +| type | string | Yes | Type of the event to observe. The value is **dataChange**. | +| uri | string | Yes | URI of the data.| +| callback | AsyncCallback\ | Yes | Callback invoked when the data is changed. | **Example** @@ -110,13 +122,17 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback\): void Unregisters the observer used to observe data specified by a given URI. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------ | -| type | string | Yes| Type of the event to observe. The value is **dataChange**.| -| uri | string | Yes| URI of the data.| -| callback | AsyncCallback\ | No| Callback used to return the result.| +| type | string | Yes | Type of the event to observe. The value is **dataChange**. | +| uri | string | Yes | URI of the data.| +| callback | AsyncCallback\ | No | Callback used to return the result. | **Example** @@ -145,12 +161,16 @@ getType(uri: string, callback: AsyncCallback\): void Obtains the MIME type of the data specified by a given URI. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | --------------------------------------------- | -| uri | string | Yes| URI of the data.| -| callback | AsyncCallback\ | Yes| Callback used to return the MIME type.| +| uri | string | Yes | URI of the data. | +| callback | AsyncCallback\ | Yes | Callback used to return the MIME type.| **Example** @@ -172,14 +192,18 @@ getType(uri: string): Promise\ Obtains the MIME type of the data specified by a given URI. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory| Description | | ---- | ------ | ---- | ------------------------ | -| uri | string | Yes| URI of the data.| +| uri | string | Yes | URI of the data.| **Return value** -| Type| Description| +| Type | Description | | ---------------- | ----------------------------------- | | Promise\ | Promise used to return the MIME type.| @@ -203,13 +227,17 @@ getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback> | Yes| Callback used to return the supported MIME types.| +| uri | string | Yes | URI of the file. | +| mimeTypeFilter | string | Yes | MIME type of the file. | +| callback | AsyncCallback\> | Yes | Callback used to return the supported MIME types.| **Example** @@ -234,15 +262,19 @@ getFileTypes(uri: string, mimeTypeFilter: string): Promise\> Obtains the supported MIME types of a specified file. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------------- | ------ | ---- | ---------------------------- | -| uri | string | Yes| URI of the file.| -| mimeTypeFilter | string | Yes| MIME type of the file.| +| uri | string | Yes | URI of the file. | +| mimeTypeFilter | string | Yes | MIME type of the file.| **Return value** -| Type| Description| +| Type | Description | | ------------------------ | ------------------------ | | Promise\> | Promise used to return the supported MIME types.| @@ -267,12 +299,16 @@ normalizeUri(uri: string, callback: AsyncCallback\): void Converts the URI that refers to a Data ability into a normalized URI. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| uri | string | Yes| URI object to normalize.| -| callback | AsyncCallback\ | Yes| Callback used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.| +| uri | string | Yes | URI object to normalize. | +| callback | AsyncCallback\ | Yes | Callback used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.| **Example** @@ -294,14 +330,18 @@ normalizeUri(uri: string): Promise\ Converts the URI that refers to a Data ability into a normalized URI. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory| Description | | ---- | ------ | ---- | ----------------------- | -| uri | string | Yes| URI object to normalize.| +| uri | string | Yes | URI object to normalize.| **Return value** -| Type| Description| +| Type | Description | | ---------------- | ------------------------------------------------------ | | Promise\ | Promise used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.| @@ -325,12 +365,16 @@ denormalizeUri(uri: string, callback: AsyncCallback\): void Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: string, callback: AsyncCallback\)** to a denormalized one. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | --------------------------------------------------- | -| uri | string | Yes| URI object to normalize.| -| callback | AsyncCallback\ | Yes| Callback used to return the denormalized URI object.| +| uri | string | Yes | URI object to normalize. | +| callback | AsyncCallback\ | Yes | Callback used to return the denormalized URI object.| **Example** @@ -354,14 +398,18 @@ denormalizeUri(uri: string): Promise\ Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: string)** to a denormalized one. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory| Description | | ---- | ------ | ---- | ----------------------- | -| uri | string | Yes| URI object to normalize.| +| uri | string | Yes | URI object to normalize.| **Return value** -| Type| Description| +| Type | Description | | ---------------- | ----------------------------------------- | | Promise\ | Promise used to return the denormalized URI object.| @@ -385,12 +433,16 @@ notifyChange(uri: string, callback: AsyncCallback\): void Notifies the registered observer of a change to the data specified by the URI. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------ | -| uri | string | Yes| URI of the data.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| uri | string | Yes | URI of the data.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -412,14 +464,18 @@ notifyChange(uri: string): Promise\ Notifies the registered observer of a change to the data specified by the URI. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory| Description | | ---- | ------ | ---- | ------------------------ | -| uri | string | Yes| URI of the data.| +| uri | string | Yes | URI of the data.| **Return value** -| Type| Description| +| Type | Description | | -------------- | --------------------- | | Promise\ | Promise used to return the result.| @@ -443,13 +499,17 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\ | Yes| Callback used to return the index of the inserted data record.| +| uri | string | Yes | URI of the data to insert. | +| valuesBucket | rdb.ValuesBucket | Yes | Data record to insert. If this parameter is **null**, a blank row will be inserted.| +| callback | AsyncCallback\ | Yes | Callback used to return the index of the inserted data record. | **Example** @@ -478,15 +538,19 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket): Promise\ Inserts a single data record into the database. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ------------ | ---------------- | ---- | ------------------------------------------------------ | -| uri | string | Yes| URI of the data to insert.| -| valuesBucket | rdb.ValuesBucket | Yes| Data record to insert. If this parameter is **null**, a blank row will be inserted.| +| uri | string | Yes | URI of the data to insert. | +| valuesBucket | rdb.ValuesBucket | Yes | Data record to insert. If this parameter is **null**, a blank row will be inserted.| **Return value** -| Type| Description| +| Type | Description | | ---------------- | ------------------------ | | Promise\ | Promise used to return the index of the inserted data record.| @@ -517,13 +581,17 @@ batchInsert(uri: string, valuesBuckets: Array, callback: Async Inserts multiple data records into the database. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ------------ | ----------------------- | ---- | -------------------------------- | -| uri | string | Yes| URI of the data to insert.| -| valuesBucket | Array | Yes| Data records to insert.| -| callback | AsyncCallback\ | Yes| Callback used to return the number of inserted data records.| +| uri | string | Yes | URI of the data to insert. | +| valuesBucket | Array | Yes | Data records to insert. | +| callback | AsyncCallback\ | Yes | Callback used to return the number of inserted data records.| **Example** @@ -549,15 +617,19 @@ batchInsert(uri: string, valuesBuckets: Array): Promise\ | Yes| Data record to insert.| +| uri | string | Yes | URI of the data to insert.| +| valuesBucket | Array | Yes | Data record to insert. | **Return value** -| Type| Description| +| Type | Description | | ---------------- | ---------------------- | | Promise\ | Promise used to return the number of inserted data records.| @@ -585,13 +657,17 @@ delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: Asy Deletes one or more data records from the database. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ------------ | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | Yes| URI of the data to delete.| -| valuesBucket | dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| -| callback | AsyncCallback\ | Yes| Callback used to return the number of deleted data records.| +| uri | string | Yes | URI of the data to delete. | +| valuesBucket | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| +| callback | AsyncCallback\ | Yes | Callback used to return the number of deleted data records. | **Example** @@ -616,15 +692,19 @@ delete(uri: string, predicates: dataAbility.DataAbilityPredicates): Promise\ | Promise used to return the number of deleted data records.| @@ -650,14 +730,18 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.Data Updates data records in the database. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ------------ | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | Yes| URI of the data to update.| -| valuesBucket | rdb.ValuesBucket | Yes| New values.| -| predicates | dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| -| callback | AsyncCallback\ | Yes| Callback used to return the number of updated data records.| +| uri | string | Yes | URI of the data to update. | +| valuesBucket | rdb.ValuesBucket | Yes | New values. | +| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| +| callback | AsyncCallback\ | Yes | Callback used to return the number of updated data records. | **Example** @@ -689,16 +773,20 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.Data Updates data records in the database. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ------------ | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | Yes| URI of the data to update.| -| valuesBucket | rdb.ValuesBucket | Yes| New values.| -| predicates | dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| +| uri | string | Yes | URI of the data to update. | +| valuesBucket | rdb.ValuesBucket | Yes | New values. | +| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| **Return value** -| Type| Description| +| Type | Description | | ---------------- | -------------------------------------------- | | Promise\ | Promise used to return the number of updated data records.| @@ -732,14 +820,18 @@ query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityP Queries data in the database. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | Yes| URI of the data to query.| -| columns | rdb.ValuesBucket | Yes| Columns to query. If this parameter is **null**, all columns will be queried.| -| predicates | dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| -| callback | AsyncCallback\ | Yes| Callback used to return the data queried.| +| uri | string | Yes | URI of the data to query. | +| columns | rdb.ValuesBucket | Yes | Columns to query. If this parameter is **null**, all columns will be queried. | +| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| +| callback | AsyncCallback\ | Yes | Callback used to return the data queried. | **Example** @@ -768,16 +860,20 @@ query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityP Queries data in the database. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | Yes| URI of the data to query.| -| columns | rdb.ValuesBucket | Yes| Columns to query. If this parameter is **null**, all columns will be queried.| -| predicates | dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| +| uri | string | Yes | URI of the data to query. | +| columns | rdb.ValuesBucket | Yes | Columns to query. If this parameter is **null**, all columns will be queried. | +| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| **Return value** -| Type| Description| +| Type | Description | | ------------------- | -------------- | | Promise\ | Promise used to return the data queried.| diff --git a/en/application-dev/reference/apis/js-apis-deque.md b/en/application-dev/reference/apis/js-apis-deque.md new file mode 100644 index 0000000000000000000000000000000000000000..1d94bd6b83d3707b566165ebfd1d0e2cb6f78afe --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-deque.md @@ -0,0 +1,274 @@ +# Linear Container Deque + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import Deque from '@ohos.util.Deque' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## Deque + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a double-ended queue (deque, called container later).| + +### constructor + +constructor() + +A constructor used to create a **Deque** instance. + +**Example** + +``` +let deque = new Deque(); +``` + +### insertFront + +insertFront(element: T): void + +Inserts an entry at the front of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to insert.| + +**Example** + +``` +let deque = new Deque; +deque.insertFront("a"); +deque.insertFront(1); +let b = [1, 2, 3]; +deque.insertFront(b); +let c = {name : "lala", age : "13"}; +deque.insertFront(false); +``` + +### insertEnd + +insertEnd(element: T): void + +Inserts an entry at the end of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to insert.| + +**Example** + +``` +let deque = new Deque; +deque.insertEnd("a"); +deque.insertEnd(1); +let b = [1, 2, 3]; +deque.insertEnd(b); +let c = {name : "lala", age : "13"}; +deque.insertEnd(false); +``` + +### has + +has(element: T): boolean + +Checks whether this container has the specified entry. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to check.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.| + +**Example** + +``` +let deque = new Deque(); +let result = deque.has("Ahfbrgrbgnutfodgorrogorg"); +deque.insertFront("Ahfbrgrbgnutfodgorrogorg"); +let result1 = deque.has("Ahfbrgrbgnutfodgorrogorg"); +``` + +### popFirst + +popFirst(): T + +Removes the first entry of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let deque = new Deque(); +deque.insertFront(2); +deque.insertFront(4); +deque.insertEnd(5); +deque.insertFront(2); +deque.insertFront(4); +let result = deque.popFirst(); +``` + +### popLast + +popLast(): T + +Removes the last entry of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let deque = new Deque(); +deque.insertFront(2); +deque.insertEnd(4); +deque.insertFront(5); +deque.insertFront(2); +deque.insertFront(4); +deque.popLast(); +let result = deque.popLast(); +``` + +### forEach +forEach(callbackfn: (value: T, index?: number, deque?: Deque<T>) => void, +thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the element that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| deque | Deque<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let deque = new Deque(); +deque.insertFront(2); +deque.insertEnd(4); +deque.insertFront(5); +deque.insertEnd(4); +deque.forEach((value, index) => { + console.log(value, index); +}); +``` + +### getFirst + +getFirst(): T; + +Obtains the first entry of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry obtained.| + +**Example** + +``` +let deque = new Deque(); +deque.insertEnd(2); +deque.insertEnd(4); +deque.insertFront(5); +deque.insertFront(4); +let result = deque.getFirst(); +``` + +### getLast + +getLast(): T + +Obtains the last entry of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry obtained.| + +**Example** + +``` +let deque = new Deque(); +deque.insertFront(2); +deque.insertFront(4); +deque.insertFront(5); +deque.insertFront(4); +let result = deque.getLast(); +``` + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** +``` +let deque = new Deque(); +deque.insertFront(2); +deque.insertFront(4); +deque.insertFront(5); +deque.insertFront(4); + +// Method 1: +for (let item of deque) { + console.log(item); +} + +// Method 2: +let iter = deque[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-distributed-data.md b/en/application-dev/reference/apis/js-apis-distributed-data.md index ed190a2e4e52c1bd771db9dc8448904d15f58031..eb9d6b4f5933cb441dbd7f91324927ade936013e 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-data.md +++ b/en/application-dev/reference/apis/js-apis-distributed-data.md @@ -591,7 +591,7 @@ Defines the KV store constants. ## Schema8+ ## -Defines a database schema. When creating or opening a KV store, you can create **Schema** objects and put them into **Options**. +Defines a database schema. When creating or opening a KV store, you can create a **Schema** object and put it into **Options**. ### toJsonString8+ ### @@ -1096,13 +1096,13 @@ Checks whether the data read position is after the last row. getEntry(): Entry; -Obtains KV pairs. +Obtains a KV pair. - Return value | Type| Description| | ------ | ------- | -| Entry |KV pairs obtained.| +| Entry |KV pair obtained.| - Example @@ -2387,7 +2387,7 @@ Deletes KV pairs in batches from this KV store. This method uses a promise to re startTransaction(callback: AsyncCallback<void>): void; -Starts transactions in this KV store. This method uses an asynchronous callback to return the result. +Starts the transaction in this KV store. This method uses an asynchronous callback to return the result. - Parameters @@ -2437,7 +2437,7 @@ Starts transactions in this KV store. This method uses an asynchronous callback startTransaction(): Promise<void>; -Starts transactions in this KV store. This method uses a promise to return the result. +Starts the transaction in this KV store. This method uses a promise to return the result. - Return value @@ -2470,7 +2470,7 @@ Starts transactions in this KV store. This method uses a promise to return the r commit(callback: AsyncCallback<void>): void; -Commits transactions in this KV store. This method uses an asynchronous callback to return the result. +Commits the transaction in this KV store. This method uses an asynchronous callback to return the result. - Parameters @@ -2500,7 +2500,7 @@ Commits transactions in this KV store. This method uses an asynchronous callback commit(): Promise<void>; -Commits transactions in this KV store. This method uses a promise to return the result. +Commits the transaction in this KV store. This method uses a promise to return the result. - Return value @@ -2528,7 +2528,7 @@ Commits transactions in this KV store. This method uses a promise to return the rollback(callback: AsyncCallback<void>): void; -Rolls back transactions in this KV store. This method uses an asynchronous callback to return the result. +Rolls back the transaction in this KV store. This method uses an asynchronous callback to return the result. - Parameters @@ -2558,7 +2558,7 @@ Rolls back transactions in this KV store. This method uses an asynchronous callb rollback(): Promise<void>; -Rolls back transactions in this KV store. This method uses a promise to return the result. +Rolls back the transaction in this KV store. This method uses a promise to return the result. - Return value diff --git a/en/application-dev/reference/apis/js-apis-extension-context.md b/en/application-dev/reference/apis/js-apis-extension-context.md index be430dce1a7275fd27d7c387199c0d353b8e8d02..08f53266f7a09ada42632df73fb0f58e6966a070 100644 --- a/en/application-dev/reference/apis/js-apis-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-extension-context.md @@ -11,4 +11,4 @@ Implements the extension context. This module is inherited from **Context**. | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.| +| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| diff --git a/en/application-dev/reference/apis/js-apis-featureAbility.md b/en/application-dev/reference/apis/js-apis-featureAbility.md index 49119078246995104a0e2d3fd5a401c7c93371d4..505e8cee17663326854d0e2c903a3bc682e9a2b1 100644 --- a/en/application-dev/reference/apis/js-apis-featureAbility.md +++ b/en/application-dev/reference/apis/js-apis-featureAbility.md @@ -16,12 +16,16 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\) Starts an ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | --------------------- | ---- | ------------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -53,11 +57,15 @@ startAbility(parameter: StartAbilityParameter): Promise\ Starts an ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | --------------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| **Example** @@ -89,15 +97,19 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper Obtains a **dataAbilityHelper** object. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory| Description | | ---- | ------ | ---- | ------------------------ | -| uri | string | Yes| URI of the file to open.| +| uri | string | Yes | URI of the file to open.| **Return value** -| Type| Description| +| Type | Description | | ----------------- | -------------------------------------------- | | DataAbilityHelper | A utility class used to help other abilities access the Data ability.| @@ -116,12 +128,16 @@ startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\ Starts an ability. This method uses a callback to return the execution result when the ability is destroyed. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | --------------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| -| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes| Callback used to return the result.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| +| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes | Callback used to return the result. | **Example** @@ -151,14 +167,18 @@ startAbilityForResult(parameter: StartAbilityParameter): Promise\ Starts an ability. This method uses a promise to return the execution result when the ability is destroyed. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | ------------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| **Return value** -| Type| Description| +| Type | Description | | ----------------------------------------- | -------------- | | Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.| @@ -204,12 +224,16 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\ Destroys this Page ability, with the result code and data sent to the caller. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ------------- | ---- | ------------------- | -| parameter | [AbilityResult](#abilityresult) | Yes| Ability to start.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -250,14 +274,18 @@ terminateSelfWithResult(parameter: AbilityResult): Promise\ Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ------------------------------- | ---- | ------------------- | -| parameter | [AbilityResult](#abilityresult) | Yes| Ability to start.| +| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.| **Return value** -| Type| Description| +| Type | Description | | -------------- | ----------------------- | | Promise\ | Promise used to return the result.| @@ -304,11 +332,15 @@ hasWindowFocus(callback: AsyncCallback\): void Checks whether the main window of this ability has the focus. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback\ | Yes| Callback used to return the result.
Returns **true** if the main window of this ability has the focus; returns **false** otherwise.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.
Returns **true** if the main window of this ability has the focus; returns **false** otherwise.| **Example** @@ -325,9 +357,13 @@ hasWindowFocus(): Promise\ Checks whether the main window of this ability has the focus. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Return value** -| Type| Description| +| Type | Description | | ----------------- | ---------------------------------------------------------- | | Promise\ | Returns **true** if the main window of this ability has the focus; returns **false** otherwise.| @@ -348,11 +384,15 @@ getWant(callback: AsyncCallback\): void Obtains the **Want** object sent from this ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ----------------------------- | ---- | ------------------ | -| callback | AsyncCallback\<[Want](#want)> | Yes| Callback used to return the result.| +| callback | AsyncCallback\<[Want](#want)> | Yes | Callback used to return the result.| **Example** @@ -369,8 +409,12 @@ getWant(): Promise\ Obtains the **Want** object sent from this ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Return value** -| Type| Description| +| Type | Description | | ----------------------- | ------------------------- | | Promise\<[Want](#want)> | Promise used to return the result.| @@ -389,8 +433,12 @@ getContext(): Context Obtains the application context. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Return value** -| Type| Description| +| Type | Description | | ------- | -------------------- | | Context | Application context returned.| @@ -410,11 +458,15 @@ terminateSelf(callback: AsyncCallback\): void Destroys this Page ability, with the result code and data sent to the caller. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ---------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -431,8 +483,12 @@ terminateSelf(): Promise\ Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Return value** -| Type| Description| +| Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| @@ -450,31 +506,35 @@ connectAbility(request: Want, options:ConnectOptions): number Connects this ability to a specific Service ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ------- | -------------- | ---- | ---------------------------- | -| request | [Want](#want) | Yes| Service ability to connect.| -| options | ConnectOptions | Yes| Callback used to return the result.| +| request | [Want](#want) | Yes | Service ability to connect.| +| options | ConnectOptions | Yes | Callback used to return the result. | Want -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable | Type | Mandatory| Description | | ------------ | -------- | -------- | ---- | ---------------------------------- | -| deviceId | Read-only| string | No| Device ID of the Service ability to connect. The default value is the local device ID.| -| bundleName | Read-only| string | Yes| Bundle name of the Service ability to connect.| -| abilityName | Read-only| string | Yes| Class name of the Service ability to connect.| +| deviceId | Read-only | string | No | Device ID of the Service ability to connect. The default value is the local device ID.
System capabilities: SystemCapability.Ability.AbilityBase| +| bundleName | Read-only | string | Yes | Bundle name of the Service ability to connect.
System capabilities: SystemCapability.Ability.AbilityBase | +| abilityName | Read-only | string | Yes | Class name of the Service ability to connect.
System capabilities: SystemCapability.Ability.AbilityBase | ConnectOptions -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ------------ | -------- | -------- | ---- | ---------------------------------- | -| onConnect | Read-only| function | Yes| Callback invoked when the connection is successful.| -| onDisconnect | Read-only| function | Yes| Callback invoked when the connection fails.| -| onFailed | Read-only| function | Yes| Callback invoked when **connectAbility** fails to be called.| +| onConnect | Read-only | function | Yes | Callback invoked when the connection is successful.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core | +| onDisconnect | Read-only | function | Yes | Callback invoked when the connection fails.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core | +| onFailed | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| **Return value** -| Type| Description| +| Type | Description | | ------ | ------------------------ | | number | Returns the ID of the Service ability connected.| @@ -512,12 +572,16 @@ disconnectAbility(connection: number, callback:AsyncCallback\): void Disconnects this ability from a specific Service ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ------------- | ---- | ------------------------------ | -| connection | number | Yes| ID of the Service ability to disconnect.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| connection | number | Yes | ID of the Service ability to disconnect.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -557,14 +621,18 @@ disconnectAbility(connection: number): Promise\ Disconnects this ability from a specific Service ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ------ | ---- | ------------------------------ | -| connection | number | Yes| ID of the Service ability to disconnect.| +| connection | number | Yes | ID of the Service ability to disconnect.| **Return value** -| Type| Description| +| Type | Description | | -------------- | ----------------------- | | Promise\ | Promise used to return the result.| @@ -596,226 +664,51 @@ var connId = featureAbility.connectAbility( var result = await featureAbility.disconnectAbility(connId); ``` -## featureAbility.continueAbility - -continueAbility(options: ContinueAbilityOptions, callback: AsyncCallback\): void - -Migrates an ability to another device. This method uses a callback to return the execution result. - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | ---------------------- | ---- | ------------------- | -| options | ContinueAbilityOptions | Yes| Ability to migrate.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| - -ContinueAbilityOptions - -| Name| Readable/Writable| Type| Mandatory| Description| -| ---------- | -------- | ------- | ---- | ------------------------------------------------------------ | -| deviceId | Read-only| string | Yes| Information about the ability to migrate.| -| reversible | Read-only| boolean | Yes| Whether migration back is supported. Currently, this feature is not supported. This parameter is reserved and can be set to **false**.| - -**Example** - -```javascript -import device from '@system.device' -import ability from '@ohos.ability.featureability' - -var DEVICE_LIST_LOCALHOST -export default { - data: { - title: "", - deviceId: '', - deviceList: [], - remoteDeviceModel : new RemoteDeviceModel() - }, - onInit() { - DEVICE_LIST_LOCALHOST = { - id: 'localhost', - }; - this.deviceList = [DEVICE_LIST_LOCALHOST]; - }, - onShow() { - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.init() - const configService = core.getDefaultService('config') - configService.setConfig(this) - core.execute() - }, - onReady() { - }, - GetNetWorkId(){ - let self = this; - this.remoteDeviceModel.registerDeviceListCallback(() => { - var list = []; - list[0] = DEVICE_LIST_LOCALHOST; - var deviceList = self.remoteDeviceModel.deviceList; - for (var i = 0; i < deviceList.length; i++) { - list[i] = { - id: deviceList[i].deviceId, - }; - } - self.deviceList = list; - }); - }, - ShowNetWorkId(){ - this.deviceId = this.deviceList[0].id; - }, - - async ContinueAbility(){ - function ContinueAbilityCallback(err) { - console.info("=============>ContinueAbilityCallback============>"); - } - var continueAbilityOptions = { - reversible: false, - deviceId: this.deviceId, - } - //continueAbility callback - await ability.continueAbility(continueAbilityOptions, ContinueAbilityCallback); - }, -} -``` - -## featureAbility.continueAbility - -continueAbility(options: ContinueAbilityOptions): Promise\; - -Migrates an ability to another device. This method uses a promise to return the execution result. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ------- | ---------------------- | ---- | ------------------- | -| options | ContinueAbilityOptions | Yes| Ability to migrate.| - -ContinueAbilityOptions - -| Name| Readable/Writable| Type| Mandatory| Description| -| ---------- | -------- | ------- | ---- | ------------------------------------------------------------ | -| deviceId | Read-only| string | Yes| Information about the ability to migrate.| -| reversible | Read-only| boolean | Yes| Whether migration back is supported. Currently, this feature is not supported. This parameter is reserved and can be set to **false**.| - -**Example** - -```javascript -import device from '@system.device' -import ability from '@ohos.ability.featureability' - -var DEVICE_LIST_LOCALHOST -export default { - data: { - title: "", - deviceId: '', - deviceList: [], - remoteDeviceModel : new RemoteDeviceModel() - }, - onInit() { - DEVICE_LIST_LOCALHOST = { - id: 'localhost', - }; - this.deviceList = [DEVICE_LIST_LOCALHOST]; - }, - onShow() { - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.init() - const configService = core.getDefaultService('config') - configService.setConfig(this) - core.execute() - }, - onReady() { - }, - GetNetWorkId(){ - let self = this; - this.remoteDeviceModel.registerDeviceListCallback(() => { - var list = []; - list[0] = DEVICE_LIST_LOCALHOST; - var deviceList = self.remoteDeviceModel.deviceList; - for (var i = 0; i < deviceList.length; i++) { - list[i] = { - id: deviceList[i].deviceId, - }; - } - self.deviceList = list; - }); - }, - ShowNetWorkId(){ - this.deviceId = this.deviceList[0].id; - }, - - async ContinueAbility(){ - function ContinueAbilityCallback(err) { - console.info("=============>ContinueAbilityCallback============>"); - } - var continueAbilityOptions = { - reversible: false, - deviceId: this.deviceId, - } - //continueAbility promise - await ability.continueAbility(continueAbilityOptions).then(() => { - console.info("=======>continueAbilityCallback=========>"); - }); - }, -} -``` - ## AbilityResult -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ---------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | -| resultCode | Read-only| number | Yes| Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.| -| want | Read-only| [Want](#want) | No| Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**.| +| resultCode | Read-only | number | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.
System capabilities: SystemCapability.Ability.AbilityBase| +| want | Read-only | [Want](#want) | No | Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**.
System capabilities: SystemCapability.Ability.AbilityBase | ## StartAbilityParameter -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| want | Read-only| [Want](#want) | Yes| Information about the ability to start.| -| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.| +| want | Read-only | [Want](#want) | Yes | Information about the ability to start.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| ## Want -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| deviceId | Read-only| string | No| ID of the device that runs the ability.| -| bundleName | Read-only| string | No| Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| -| abilityName | Read-only| string | No| Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| -| uri | Read-only| string | No| URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| -| type | Read-only| string | No| MIME type, for example, text/plain or image/*.| -| flags | Read-only| number | No| How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).| -| action | Read-only| string | No| Action option.| -| parameters | Read-only| {[key: string]: any} | No| List of parameters in a **Want** object.| -| entities | Read-only| Array\ | No| List of entities.| +| deviceId | Read-only | string | No | ID of the device that runs the ability.
System capabilities: SystemCapability.Ability.AbilityBase | +| bundleName | Read-only | string | No | Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.
System capabilities: SystemCapability.Ability.AbilityBase| +| abilityName | Read-only | string | No | Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.
System capabilities: SystemCapability.Ability.AbilityBase| +| uri | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.
System capabilities: SystemCapability.Ability.AbilityBase| +| type | Read-only | string | No | MIME type, for example, text/plain or image/*.
System capabilities: SystemCapability.Ability.AbilityBase | +| flags | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).
System capabilities: SystemCapability.Ability.AbilityBase| +| action | Read-only | string | No | Action option.
System capabilities: SystemCapability.Ability.AbilityBase | +| parameters | Read-only | {[key: string]: any} | No | List of parameters in a **Want** object.
System capabilities: SystemCapability.Ability.AbilityBase | +| entities | Read-only | Array\ | No | List of entities.
System capabilities: SystemCapability.Ability.AbilityBase | ## flags -| Name| Name| Description| +| Name | Name | Description | | ------------------------------------ | ---------- | ------------------------------------------------------------ | -| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.| -| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.| -| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.| -| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.| -| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.| -| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.| -| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.| -| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.| -| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.| -| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.| -| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.| -| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.| -| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.| -| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.| -| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.| -| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.| +| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.
System capabilities: SystemCapability.Ability.AbilityBase| +| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.
System capabilities: SystemCapability.Ability.AbilityBase| diff --git a/en/application-dev/reference/apis/js-apis-hashset.md b/en/application-dev/reference/apis/js-apis-hashset.md new file mode 100644 index 0000000000000000000000000000000000000000..7ba96f84539cccb36815d4b147853b9aacc269dc --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-hashset.md @@ -0,0 +1,275 @@ +# Nonlinear Container HashSet + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import HashSet from '@ohos.util.HashSet'; +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## HashSet + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a hash set (called container later).| + + +### constructor + +constructor() + +A constructor used to create a **HashSet** instance. + +**Example** + +``` +let hashSet = new HashSet(); +``` + + +### isEmpty + +isEmpty(): boolean + +Checks whether this container is empty (contains no entry). + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +const hashSet = new HashSet(); +hashSet.isEmpty(); +``` + + +### has + +has(value: T): boolean + +Checks whether this container contains the specified entry. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Entry to check.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.| + +**Example** + +``` +let hashSet = new HashSet(); +let result = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result1 = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + + +### add + +add(value: T): boolean + +Adds an entry to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + +``` +let hashSet = new HashSet(); +let result = hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + + +### remove + +remove(value: T): boolean + +Removes an entry from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sdfs"); +let result = hashSet.remove("sdfs"); +``` + + +### clear + +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sdfs"); +hashSet.clear(); +``` + + +### values + +values(): IterableIterator<T> + +Obtains an iterator that contains all the values in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sdfs"); +let iter = hashSet.values(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` + + +### forEach + +forEach(callbackfn: (value: T, key?: T, set?: HashSet<T>) => void, thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| key | T | No| Key of the entry that is currently traversed (same as **value**).| +| set | HashSet<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("sdfs"); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.forEach((value, key) => { + console.log(value, key); +}); +``` + + +### entries +entries(): IterableIterator<[T, T]> + +Obtains an iterator that contains all the entries in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<[T, T]> | Iterator obtained.| + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sdfs"); +let iter = hashSet.entries(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp[0]); + console.log(temp[1]); + temp = iter.next().value; +} +``` + + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sdfs"); + +// Method 1: +for (let item of hashSet) { + console.log("value: " + item); +} + +// Method 2: +let iter = hashSet[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-hidebug.md b/en/application-dev/reference/apis/js-apis-hidebug.md index 78b6282ce68b0b4776914472b9f0cc1ad9a0c6f0..7e2473e5f45acddec718e6d400c8eec88bcfd1e9 100644 --- a/en/application-dev/reference/apis/js-apis-hidebug.md +++ b/en/application-dev/reference/apis/js-apis-hidebug.md @@ -107,7 +107,7 @@ Obtains the size of the shared dirty memory of this process. - **Example** ``` - let sharedDirty = hidebug.getSharedDirty()); + let sharedDirty = hidebug.getSharedDirty(); ``` diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md index 27dc8eb464f9615f0b61462a5f7f81d71195d1f1..7a604fdd852e43c09c418312c6797ea96e7fc6e0 100644 --- a/en/application-dev/reference/apis/js-apis-i18n.md +++ b/en/application-dev/reference/apis/js-apis-i18n.md @@ -1,2665 +1,1252 @@ -# Internationalization \(i18n\) +# Internationalization – i18n ->![](public_sys-resources/icon-note.gif) **NOTE:** ->- The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ->- This module contains enhanced i18n APIs, which are not defined in ECMA 402. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> - This module contains enhanced i18n APIs, which are not defined in ECMA 402. -## Modules to Import + +## Modules to Import ``` import i18n from '@ohos.i18n'; ``` -## Required Permissions - -None -## i18n.getDisplayLanguage +## i18n.getDisplayLanguage -getDisplayLanguage\(language: string, locale: string, sentenceCase?: boolean\): string +getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string Obtains the localized script for the specified language. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

language

-

string

-

Yes

-

Specified language.

-

locale

-

string

-

Yes

-

Locale ID.

-

sentenceCase

-

boolean

-

No

-

Whether to use sentence case for the localized script.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Localized script for the specified language.

-
- -- Example - - ``` - I18n.getDisplayLanguage("zh", "en-GB", true); - I18n.getDisplayLanguage("zh", "en-GB"); - ``` - - -## i18n.getDisplayCountry - -getDisplayCountry\(country: string, locale: string, sentenceCase?: boolean\): string +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | language | string | Yes| Specified language.| + | locale | string | Yes| Locale ID.| + | sentenceCase | boolean | No| Whether to use sentence case for the localized script.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Localized script for the specified language.| + +- Example + ``` + i18n.getDisplayLanguage("zh", "en-GB", true); + i18n.getDisplayLanguage("zh", "en-GB"); + ``` + + +## i18n.getDisplayCountry + +getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string Obtains the localized script for the specified country. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

country

-

string

-

Yes

-

Specified country.

-

locale

-

string

-

Yes

-

Locale ID.

-

sentenceCase

-

boolean

-

No

-

Whether to use sentence case for the localized script.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Localized script for the specified country.

-
- -- Example - - ``` - I18n.getDisplayCountry("zh-CN", "en-GB", true); - I18n.getDisplayCountry("zh-CN", "en-GB"); - ``` - - -## i18n.isRTL8+ - -isRTL\(locale: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | country | string | Yes| Specified country.| + | locale | string | Yes| Locale ID.| + | sentenceCase | boolean | No| Whether to use sentence case for the localized script.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Localized script for the specified country.| + +- Example + ``` + i18n.getDisplayCountry("zh-CN", "en-GB", true); + i18n.getDisplayCountry("zh-CN", "en-GB"); + ``` + + +## i18n.isRTL8+ + +isRTL(locale: string): boolean Checks whether the localized script for the specified language is displayed from right to left. -- Parameters - - - - - - - - - - - - -

Name

-

Type

-

Description

-

locale

-

string

-

Locale ID.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the localized script is displayed from right to left, and value false indicates the opposite.

-
- -- Example - - ``` - i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned. - i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned. - ``` - - -## i18n.getSystemLanguage - -getSystemLanguage\(\): string +**System capability**: SystemCapability.Global.I18n -Obtains the system language. +- Parameters + | Name| Type| Description| + | -------- | -------- | -------- | + | locale | string | Locale ID.| -- Return values +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the localized script is displayed from right to left, and value **false** indicates the opposite.| - - - - - - - - - -

Type

-

Description

-

string

-

System language ID.

-
+- Example + ``` + i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned. + i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned. + ``` -- Example - ``` - I18n.getSystemLanguage(); - ``` +## i18n.getSystemLanguage +getSystemLanguage(): string -## i18n.getSystemRegion +Obtains the system language. -getSystemRegion\(\): string +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | string | System language ID.| + +- Example + ``` + i18n.getSystemLanguage(); + ``` -Obtains the system region. -- Return values +## i18n.getSystemRegion - - - - - - - - - -

Type

-

Description

-

string

-

System region ID.

-
+getSystemRegion(): string -- Example +Obtains the system region. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | string | System region ID.| - ``` - I18n.getSystemRegion(); - ``` +- Example + ``` + i18n.getSystemRegion(); + ``` -## i18n.getSystemLocale +## i18n.getSystemLocale -getSystemLocale\(\): string +getSystemLocale(): string Obtains the system locale. -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

System locale ID.

-
- -- Example - - ``` - I18n.getSystemLocale(); - ``` - - -## i18n.getCalendar8+ - -getCalendar\(locale: string, type? : string\): Calendar - -Obtains a **Calendar** object. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

Valid locale value, for example, zh-Hans-CN.

-

type

-

string

-

No

-

Valid calendar type. Currently, the valid types are as follows: buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, japanese, and persian. If this parameter is left unspecified, the default calendar type of the specified locale is used.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Calendar

-

Calendar object.

-
- -- Example - - ``` - I18n.getCalendar("zh-Hans", "gregory"); - ``` - - -## Calendar8+ - -### setTime8+ - -setTime\(date: Date\): void - -Sets the date for this **Calendar** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

date

-

Date

-

Yes

-

Date to be set for the Calendar object.

-
- - -- Example - - ``` - var calendar = I18n.getCalendar("en-US", "gregory"); - var date = new Date(2021, 10, 7, 8, 0, 0, 0); - calendar.setTime(date); - ``` - - -### setTime8+ - -setTime\(time: number\): void - -Sets the date and time for this **Calendar** object. The value is represented by the number of milliseconds that have elapsed since the Unix epoch \(00:00:00 UTC on January 1, 1970\). - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

time

-

number

-

Yes

-

Number of milliseconds that have elapsed since the Unix epoch.

-
- - -- Example - - ``` - var calendar = I18n.getCalendar("en-US", "gregory"); - calendar.setTime(10540800000); - ``` - - -### set8+ - -set\(year: number, month: number, date:number, hour?: number, minute?: number, second?: number\): void - -Sets the year, month, day, hour, minute, and second for this **Calendar** object. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

year

-

number

-

Yes

-

Year to set.

-

month

-

number

-

Yes

-

Month to set.

-

date

-

number

-

Yes

-

Day to set.

-

hour

-

number

-

No

-

Hour to set.

-

minute

-

number

-

No

-

Minute to set.

-

second

-

number

-

No

-

Second to set.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 - ``` - - -### setTimeZone8+ - -setTimeZone\(timezone: string\): void - -Sets the time zone of this **Calendar** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

timezone

-

string

-

Yes

-

Time zone, for example, Asia/Shanghai.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setTimeZone("Asia/Shanghai"); - ``` - - -### getTimeZone8+ - -getTimeZone\(\): string - -Obtains the time zone of this **Calendar** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Time zone of the Calendar object.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setTimeZone("Asia/Shanghai"); - calendar.getTimeZone(); // Asia/Shanghai" - ``` - - -### getFirstDayOfWeek8+ - -getFirstDayOfWeek\(\): number - -Obtains the start day of a week for this **Calendar** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Start day of a week. The value 1 indicates Sunday, and value 7 indicates Saturday.

-
+**System capability**: SystemCapability.Global.I18n +- Return value + | Type| Description| + | -------- | -------- | + | string | System locale ID.| -- Example - - ``` - var calendar = I18n.getCalendar("en-US", "gregory"); - calendar.getFirstDayOfWeek(); - ``` - - -### setFirstDayOfWeek8+ - -setFirstDayOfWeek\(value: number\): void - -Sets the start day of a week for this **Calendar** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

number

-

No

-

Start day of a week. The value 1 indicates Sunday, and value 7 indicates Saturday.

-
+- Example + ``` + i18n.getSystemLocale(); + ``` -- Example - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setFirstDayOfWeek(0); - ``` +## i18n.getCalendar8+ +getCalendar(locale: string, type? : string): Calendar -### getMinimalDaysInFirstWeek8+ +Obtains a **Calendar** object. -getMinimalDaysInFirstWeek\(\): number +**System capability**: SystemCapability.Global.I18n -Obtains the minimum number of days in the first week of a year. +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| Valid locale value, for example, **zh-Hans-CN**.| + | type | string | No| Valid calendar type. Currently, the valid types are as follows: buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic\_civil, islamic\_tbla, islamic\_umalqura, japanese, and persian. If this parameter is left unspecified, the default calendar type of the specified locale is used.| + +- Return value + | Type| Description| + | -------- | -------- | + | [Calendar](#calendar8) | **Calendar** object.| + +- Example + ``` + i18n.getCalendar("zh-Hans", "gregory"); + ``` + + +## Calendar8+ + + +### setTime8+ + +setTime(date: Date): void + +Sets the date for this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | date | Date | Yes| Date to be set for the **Calendar** object.| + +- Example + ``` + var calendar = I18n.getCalendar("en-US", "gregory"); + var date = new Date(2021, 10, 7, 8, 0, 0, 0); + calendar.setTime(date); + ``` + + +### setTime8+ + +setTime(time: number): void + +Sets the date and time for this **Calendar** object. The value is represented by the number of milliseconds that have elapsed since the Unix epoch (00:00:00 UTC on January 1, 1970). + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | time | number | Yes| Number of milliseconds that have elapsed since the Unix epoch.| + +- Example + ``` + var calendar = I18n.getCalendar("en-US", "gregory"); + calendar.setTime(10540800000); + ``` + + +### set8+ + +set(year: number, month: number, date:number, hour?: number, minute?: number, second?: number): void + +Sets the year, month, day, hour, minute, and second for this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | year | number | Yes| Year to set.| + | month | number | Yes| Month to set.| + | date | number | Yes| Day to set.| + | hour | number | No| Hour to set.| + | minute | number | No| Minute to set.| + | second | number | No| Second to set.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 + ``` + + +### setTimeZone8+ + +setTimeZone(timezone: string): void + +Sets the time zone of this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | timezone | string | Yes| Time zone, for example, **Asia/Shanghai**.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setTimeZone("Asia/Shanghai"); + ``` + + +### getTimeZone8+ + +getTimeZone(): string + +Obtains the time zone of this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | string | Time zone of the **Calendar** object.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setTimeZone("Asia/Shanghai"); + calendar.getTimeZone(); // Asia/Shanghai" + ``` + + +### getFirstDayOfWeek8+ + +getFirstDayOfWeek(): number + +Obtains the start day of a week for this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Start day of a week. The value **1** indicates Sunday, and value **7** indicates Saturday.| + +- Example + ``` + var calendar = I18n.getCalendar("en-US", "gregory"); + calendar.getFirstDayOfWeek(); + ``` + + +### setFirstDayOfWeek8+ + +setFirstDayOfWeek(value: number): void + +Sets the start day of a week for this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | value | number | No| Start day of a week. The value **1** indicates Sunday, and value **7** indicates Saturday.| -- Return values +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setFirstDayOfWeek(0); + ``` - - - - - - - - - -

Type

-

Description

-

number

-

Minimum number of days in the first week of a year.

-
-- Example +### getMinimalDaysInFirstWeek8+ - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.getMinimalDaysInFirstWeek(); - ``` +getMinimalDaysInFirstWeek(): number + +Obtains the minimum number of days in the first week of a year. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Minimum number of days in the first week of a year.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.getMinimalDaysInFirstWeek(); + ``` -### setMinimalDaysInFirstWeek8+ +### setMinimalDaysInFirstWeek8+ -setMinimalDaysInFirstWeek\(value: number\): void +setMinimalDaysInFirstWeek(value: number): void Sets the minimum number of days in the first week of a year. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

number

-

No

-

Minimum number of days in the first week of a year.

-
- -- Example - - ``` - var calendar = i18n.getCalendar("zh-Hans"); - calendar.setMinimalDaysInFirstWeek(3); - ``` - - -### get8+ - -get\(field: string\): number - -Obtains the value of the specified field in the **Calendar** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

field

-

string

-

Yes

-

Value of the specified field in the Calendar object. Currently, the valid fields are as follows: era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week, day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, dow_local, extended_year, julian_day, milliseconds_in_day, and is_leap_month.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Value of the specified field. For example, if the year in the internal date of this Calendar object is 1990, the get("year") function will return 1990.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 - calendar.get("hour_of_day"); // 8 - ``` - - -### getDisplayName8+ - -getDisplayName\(locale: string\): string - -Obtains the name of the **Calendar** object displayed for the specified locale. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

Locale for which the name of the Calendar object is displayed. For example, if locale is en-US, the name of the Buddhist calendar will be Buddhist Calendar.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Name of the Calendar object displayed for the specified locale.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("en-US", "buddhist"); - calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh. - ``` - - -### isWeekend8+ - -isWeekend\(date?: Date\): boolean - -Checks whether the specified date in this **Calendar** object is a weekend. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

date

-

Date

-

No

-

Specified date in this Calendar object. If this parameter is left unspecified, the system checks whether the current date in the Calendar object is a weekend.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the date is a weekend, and value false indicates a weekday.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setTime(2021, 11, 11, 8, 0, 0); // Set the time to 2021.11.11 08:00:00. - calendar.isWeekend(); // false - var date = new Date(2011, 11, 6, 9, 0, 0); - calendar.isWeekend(date); // true - ``` - - -## PhoneNumberFormat8+ - -### constructor8+ - -constructor\(country: string, options?: PhoneNumberFormatOptions\) - -Creates a **PhoneNumberFormat** object. +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | value | number | No| Minimum number of days in the first week of a year.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setMinimalDaysInFirstWeek(3); + ``` + + +### get8+ + +get(field: string): number + +Obtains the value of the specified field in the **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | field | string | Yes| Value of the specified field in the **Calendar** object. Currently, a valid field can be any of the following: era, year, month, week\_of\_year, week\_of\_month, date, day\_of\_year, day\_of\_week, day\_of\_week\_in\_month, hour, hour\_of\_day, minute, second, millisecond, zone\_offset, dst\_offset, year\_woy, dow\_local, extended\_year, julian\_day, milliseconds\_in\_day, is\_leap\_month.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Value of the specified field. For example, if the year in the internal date of this **Calendar** object is **1990**, the **get("year")** function will return **1990**.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 + calendar.get("hour_of_day"); // 8 + ``` + + +### getDisplayName8+ + +getDisplayName(locale: string): string + +Obtains the name of the **Calendar** object displayed for the specified locale. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| Locale for which the name of the **Calendar** object is displayed. For example, if **locale** is **en-US**, the name of the Buddhist calendar will be **Buddhist Calendar**.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Name of the **Calendar** object displayed for the specified locale.| + +- Example + ``` + var calendar = i18n.getCalendar("en-US", "buddhist"); + calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh. + ``` + + +### isWeekend8+ + +isWeekend(date?: Date): boolean + +Checks whether the specified date in this **Calendar** object is a weekend. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | date | Date | No| Specified date in this **Calendar** object. If this parameter is left unspecified, the system checks whether the current date in the **Calendar** object is a weekend.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the date is a weekend, and value **false** indicates a weekday.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setTime(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00 + calendar.isWeekend(); // false + var date = new Date(2011, 11, 6, 9, 0, 0); + calendar.isWeekend(date); // true + ``` + + +## PhoneNumberFormat8+ + + +### constructor8+ + +constructor(country: string, options?: PhoneNumberFormatOptions) + +Creates a **PhoneNumberFormat** object. + +**System capability**: SystemCapability.Global.I18n Parameters +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| country | string | Yes| Country or region to which the phone number to be formatted belongs.| +| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No| Options of the **PhoneNumberFormat** object.| - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

country

-

string

-

Yes

-

Country or region to which the phone number to be formatted belongs.

-

options

-

PhoneNumberFormatOptions

-

No

-

Options of the PhoneNumberFormat object.

-
- -- Example - - ``` - var phoneNumberFormat= new I18n.PhoneNumberFormat("CN", {"type": "E164"}); - ``` - - -### isValidNumber8+ - -isValidNumber\(number: string\): boolean +- Example + ``` + var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"}); + ``` + + +### isValidNumber8+ + +isValidNumber(number: string): boolean Checks whether the format of the specified phone number is valid. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

number

-

string

-

Yes

-

Phone number to be checked.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates the phone number format is valid, and value false indicates the opposite.

-
- - -- Example - - ``` - var phonenumberfmt = new I18n.PhoneNumberFormat("CN"); - phonenumberfmt.isValidNumber("15812312312"); - ``` - - -### format8+ - -format\(number: string\): string +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | number | string | Yes| Phone number to be checked.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates the phone number format is valid, and value **false** indicates the opposite.| + +- Example + ``` + var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); + phonenumberfmt.isValidNumber("15812312312"); + ``` + + +### format8+ + +format(number: string): string Formats a phone number. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

number

-

string

-

Yes

-

Phone number to be formatted.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Formatted phone number.

-
- - -- Example - - ``` - var phonenumberfmt = new I18n.PhoneNumberFormat("CN"); - phonenumberfmt.format("15812312312"); - ``` - - -## PhoneNumberFormatOptions8+ - -Defines the options for this **PhoneNumberFormat** object. - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

type

-

string

-

Yes

-

Yes

-

Format type of a phone number. The available options are as follows: E164, INTERNATIONAL, NATIONAL, and RFC3966.

-
- -## UnitInfo8+ +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | number | string | Yes| Phone number to be formatted.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Formatted phone number.| + +- Example + ``` + var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); + phonenumberfmt.format("15812312312"); + ``` + + +## PhoneNumberFormatOptions8+ + +Defines the options for this PhoneNumberFormat object. + + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| type | string | Yes| Yes| Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.
**System capability**: SystemCapability.Global.I18n| + + +## UnitInfo8+ Defines the measurement unit information. - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

unit

-

string

-

Yes

-

Yes

-

Name of the measurement unit, for example, meter, inch, or cup.

-

measureSystem

-

string

-

Yes

-

Yes

-

Measurement system. The value can be SI, US, or UK.

-
- -## Util8+ - -### unitConvert8+ - -unitConvert\(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string\): string + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| unit | string | Yes| Yes| Name of the measurement unit, for example, **meter**, **inch**, or **cup**.| +| measureSystem | string | Yes| Yes| Measurement system. The value can be **SI**, **US**, or **UK**.
**System capability**: SystemCapability.Global.I18n| + + +## Util8+ + + +### unitConvert8+ + +unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string Converts one measurement unit into another and formats the unit based on the specified locale and style. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

fromUnit

-

UnitInfo

-

Yes

-

Measurement unit to be converted.

-

toUnit

-

UnitInfo

-

Yes

-

Measurement unit to be converted to.

-

value

-

number

-

Yes

-

Value of the measurement unit to be converted.

-

locale

-

string

-

Yes

-

Locale used for formatting, for example, zh-Hans-CN.

-

style

-

string

-

No

-

Style used for formatting. The value can be long, short, or medium.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Character string obtained after formatting based on the measurement unit specified by toUnit.

-
- - -- Example - - ``` - I18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long"); - ``` - - -## i18n.getInstance8+ - -getInstance\(locale?: string\): IndexUtil - -Creates an **IndexUtil** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

No

-

A string containing locale information, including the language, optional script, and region.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

IndexUtil

-

IndexUtil object mapping to the specified locale.

-
- - -- Example - - ``` - var indexUtil= I18n.getInstance("zh-CN"); - ``` - - -## IndexUtil8+ - -### getIndexList8+ - -getIndexList\(\): Array - -Obtains the index list for this **locale** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

Array<string>

-

Index list for this locale.

-
- - -- Example - - ``` - var indexUtil = i18n.getInstance("zh-CN"); - var indexList = indexUtil.getIndexList(); - ``` - - -### addLocale8+ - -addLocale\(locale: string\) - -Adds the index of the new **locale** object to the index list. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

A string containing locale information, including the language, optional script, and region.

-
- - -- Example - - ``` - var indexUtil = i18n.getInstance("zh-CN"); - indexUtil.addLocale("en-US"); - ``` - - -### getIndex8+ - -getIndex\(text: string\): string - -Obtains the index of a **text** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

text

-

string

-

Yes

-

text object whose index is to be obtained.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Index of the text object.

-
- - -- Example - - ``` - var indexUtil= i18n.getInstance("zh-CN"); - indexUtil.getIndex("hi"); // Return h. - ``` - - -## Character8+ - -### isDigit8+ - -isDigit\(char: string\): boolean - -Checks whether the input character is a digit. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is a digit, and value false indicates the opposite.

-
- - -- Example - - ``` - var isdigit = Character.isDigit("1"); // Return true. - ``` - - -### isSpaceChar8+ - -isSpaceChar\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | fromUnit | [UnitInfo](#unitinfo8) | Yes| Measurement unit to be converted.| + | toUnit | [UnitInfo](#unitinfo8) | Yes| Measurement unit to be converted to.| + | value | number | Yes| Value of the measurement unit to be converted.| + | locale | string | Yes| Locale used for formatting, for example, **zh-Hans-CN**.| + | style | string | No| Style used for formatting. The value can be **long**, **short**, or **medium**.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.| + +- Example + ``` + I18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long"); + ``` + + +## IndexUtil8+ + + +### getInstance8+ + +getInstance(): IndexUtil + +Creates an **IndexUtil** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | No| A string containing locale information, including the language, optional script, and region.| + +- Return value + | Type| Description| + | -------- | -------- | + | [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.| + +- Example + ``` + var indexUtil= i18n.IndexUtil.getInstance("zh-CN"); + ``` + + +### getIndexList8+ + +getIndexList(): Array<string> + +Obtains the index list for this **locale** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | Array<string> | Index list for this **locale** object.| + +- Example + ``` + var indexUtil = i18n.getInstance("zh-CN"); + var indexList = indexUtil.getIndexList(); + ``` + + +### addLocale8+ + +addLocale(locale: string) + +Adds the index of the new **locale** object to the index list. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| A string containing locale information, including the language, optional script, and region.| + +- Example + ``` + var indexUtil = i18n.getInstance("zh-CN"); + indexUtil.addLocale("en-US"); + ``` + + +### getIndex8+ + +getIndex(text: string): string + +Obtains the index of a text object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | text | string | Yes| **text** object whose index is to be obtained.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Index of the **text** object.| + +- Example + ``` + var indexUtil= i18n.getInstance("zh-CN"); + indexUtil.getIndex("hi"); // Return h. + ``` + + +## Character8+ + + +### isDigit8+ + +isDigit(char: string): boolean + +Checks whether the input character string is composed of digits. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is a digit, and value **false** indicates the opposite.| + +- Example + ``` + var isdigit = Character.isDigit("1"); // Return true. + ``` + + +### isSpaceChar8+ + +isSpaceChar(char: string): boolean Checks whether the input character is a space. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is a space, and value false indicates the opposite.

-
- - -- Example - - ``` - var isspacechar = Character.isSpaceChar("a"); // Return false. - ``` - - -### isWhitespace8+ - -isWhitespace\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is a space, and value **false** indicates the opposite.| + +- Example + ``` + var isspacechar = Character.isSpaceChar("a"); // Return false. + ``` + + +### isWhitespace8+ + +isWhitespace(char: string): boolean Checks whether the input character is a white space. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is a white space, and value false indicates the opposite.

-
- - -- Example - - ``` - var iswhitespace = Character.isWhitespace("a"); // Return false. - ``` - - -### isRTL8+ - -isRTL\(char: string\): boolean - -Checks whether the input character is of the right to left \(RTL\) language. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is of the RTL language, and value false indicates the opposite.

-
- - -- Example - - ``` - var isrtl = Character.isRTL("a"); // Return false. - ``` - - -### isIdeograph8+ - -isIdeograph\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is a white space, and value **false** indicates the opposite.| + +- Example + ``` + var iswhitespace = Character.isWhitespace("a"); // Return false. + ``` + + +### isRTL8+ + +isRTL(char: string): boolean + +Checks whether the input character is of the right to left (RTL) language. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is of the RTL language, and value **false** indicates the opposite.| + +- Example + ``` + var isrtl = Character.isRTL("a"); // Return false. + ``` + + +### isIdeograph8+ + +isIdeograph(char: string): boolean Checks whether the input character is an ideographic character. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is an ideographic character, and value false indicates the opposite.

-
- - -- Example - - ``` - var isideograph = Character.isIdeograph("a"); // Return false. - ``` - - -### isLetter8+ - -isLetter\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is an ideographic character, and value **false** indicates the opposite.| + +- Example + ``` + var isideograph = Character.isIdeograph("a"); // Return false. + ``` + + +### isLetter8+ + +isLetter(char: string): boolean Checks whether the input character is a letter. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is a letter, and value false indicates the opposite.

-
- - -- Example - - ``` - var isletter = Character.isLetter("a"); // Return true. - ``` - - -### isLowerCase8+ - -isLowerCase\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is a letter, and value **false** indicates the opposite.| + +- Example + ``` + var isletter = Character.isLetter("a"); // Return true. + ``` + + +### isLowerCase8+ + +isLowerCase(char: string): boolean Checks whether the input character is a lowercase letter. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is a lowercase letter, and value false indicates the opposite.

-
- - -- Example - - ``` - var islowercase = Character.isLowerCase("a"); // Return true. - ``` - - -### isUpperCase8+ - -isUpperCase\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is a lowercase letter, and value **false** indicates the opposite.| + +- Example + ``` + var islowercase = Character.isLowerCase("a"); // Return true. + ``` + + +### isUpperCase8+ + +isUpperCase(char: string): boolean Checks whether the input character is an uppercase letter. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is an uppercase letter, and value false indicates the opposite.

-
- - -- Example - - ``` - var isuppercase = Character.isUpperCase("a"); // Return false. - ``` - - -### getType8+ - -getType\(char: string\): string +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value true indicates that the input character is an uppercase letter, and value false indicates the opposite.| + +- Example + ``` + var isuppercase = Character.isUpperCase("a"); // Return false. + ``` + + +### getType8+ + +getType(char: string): string Obtains the type of the input character string. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Type of the input character.

-
- - -- Example - - ``` - var type = Character.getType("a"); - ``` - - -## i18n.getLineInstance8+ - -getLineInstance\(locale: string\): BreakIterator - -Obtains a [BreakIterator](#section1312302611613) object for text segmentation. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

Valid locale value, for example, zh-Hans-CN. The BreakIterator object segments text according to the rules of the specified locale.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

BreakIterator

-

Break iterator used for text segmentation.

-
- -- Example - - ``` - I18n.getLineInstance("en"); - ``` - - -## BreakIterator8+ - -### setLineBreakText8+ - -setLineBreakText\(text: string\): void - -Sets the text to be processed by the [BreakIterator](#section1312302611613) object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

text

-

string

-

Yes

-

Text to be processed by the BreakIterator object.

-
- +**System capability**: SystemCapability.Global.I18n -- Example +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| - ``` - var iterator = I18n.getLineInstance("en"); - var iterator.setLineBreakText("Apple is my favorite fruit."); - ``` - - -### getLineBreakText8+ +- Return value + | Type| Description| + | -------- | -------- | + | string | Type of the input character.| -getLineBreakText\(\): string - -Obtains the text being processed by the [BreakIterator](#section1312302611613) object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Text being processed by the BreakIterator object.

-
- - -- Example +- Example + ``` + var type = Character.getType("a"); + ``` - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.getLineBreakText(); // Apple is my favorite fruit. - ``` +## i18n.getLineInstance8+ -### current8+ +getLineInstance(locale: string): BreakIterator -current\(\): number +Obtains a [BreakIterator](#breakiterator8) object for text segmentation. -Obtains the position of the [BreakIterator](#section1312302611613) object in the text being processed. +**System capability**: SystemCapability.Global.I18n -- Return values +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| Valid locale value, for example, **zh-Hans-CN**. The [BreakIterator](#breakiterator8) object segments text according to the rules of the specified locale.| - - - - - - - - - -

Type

-

Description

-

number

-

Position of the BreakIterator object in the text being processed.

-
+- Return value + | Type| Description| + | -------- | -------- | + | [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.| +- Example + ``` + i18n.getLineInstance("en"); + ``` -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - breakIter.current(); // 0 - ``` +## BreakIterator8+ -### first8+ - -first\(\): number - -Puts the [BreakIterator](#section1312302611613) object to the first text boundary, which is always at the beginning of the processed text. - -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Offset to the first text boundary of the processed text.

-
+### setLineBreakText8+ -- Example +setLineBreakText(text: string): void - ``` - iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - breakIter.first(); // 0 - ``` +Sets the text to be processed by the [BreakIterator](#breakiterator8) object. +**System capability**: SystemCapability.Global.I18n -### last8+ +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | text | string | Yes| Text to be processed by the **BreakIterator** object.| -last\(\): number +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + ``` -Puts the [BreakIterator](#section1312302611613) object to the last text boundary, which is always the next position after the end of the processed text. -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Offset of the last text boundary of the processed text.

-
+### getLineBreakText8+ +getLineBreakText(): string -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.last(); // 27 - ``` +Obtains the text being processed by the [BreakIterator](#breakiterator8) object. +**System capability**: SystemCapability.Global.I18n -### next8+ +- Return value + | Type| Description| + | -------- | -------- | + | string | Text being processed by the **BreakIterator** object.| -next\(index?: number\): number +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.getLineBreakText(); // Apple is my favorite fruit. + ``` -Moves the [BreakIterator](#section1312302611613) object backward by the specified number of text boundaries if the specified index is a positive number. If the index is a negative number, the [BreakIterator](#section1312302611613) object will be moved forward by the corresponding number of text boundaries. If no index is specified, the index will be treated as **1**. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

index

-

number

-

No

-

Number of text boundaries by which the BreakIterator object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as 1.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Position of the BreakIterator object in the text after it is moved by the specified number of text boundaries. The value -1 is returned if the position of the BreakIterator object is outside of the processed text after it is moved by the specified number of text boundaries.

-
- - -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.first(); // 0 - iterator.next(); // 6 - iterator.next(10); // -1 - ``` - - -### previous8+ - -previous\(\): number - -Moves the [BreakIterator](#section1312302611613) object to the previous text boundary. - -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Position of the BreakIterator object in the text after it is moved to the previous text boundary. The value -1 is returned if the position of the BreakIterator object is outside of the processed text after it is moved by the specified number of text boundaries.

-
- - -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.first(); // 0 - iterator.next(3); // 12 - iterator.previous(); // 9 - ``` - - -### following8+ - -following\(offset: number\): number - -Moves the [BreakIterator](#section1312302611613) object to the text boundary after the position specified by the offset. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

offset

-

number

-

Yes

-

Offset to the position before the text boundary to which the BreakIterator object is moved.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

The value -1 is returned if the text boundary to which the BreakIterator object is moved is outside of the processed text.

-
- - -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.following(0); // 6 - iterator.following(100); // -1 - iterator.current(); // 27 - ``` - - -### isBoundary8+ - -isBoundary\(offset: number\): boolean - -Checks whether the position specified by the offset is a text boundary. If **true** is returned, the [BreakIterator](#section1312302611613) object is moved to the position specified by the offset. If **false** is returned, the [BreakIterator](#section1312302611613) object is moved to the text boundary after the position specified by the offset, which is equivalent to calling [following\(offset\)](#section1743155314301). - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

offset

-

number

-

Yes

-

Position to check.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the position specified by the offset is a text boundary, and value false indicates the opposite.

-
- - -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.isBoundary(0); // true; - iterator.isBoundary(5); // false; - ``` - - -## i18n.is24HourClock8+ - -is24HourClock\(\): boolean +### current8+ -Checks whether the 24-hour clock is used. +current(): number + +Obtains the position of the [BreakIterator](#breakiterator8) object in the text being processed. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Position of the **BreakIterator** object in the text being processed.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + breakIter.current(); // 0 + ``` + + +### first8+ + +first(): number + +Puts the [BreakIterator](#breakiterator8) object to the first text boundary, which is always at the beginning of the processed text. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Offset to the first text boundary of the processed text.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + breakIter.first(); // 0 + ``` + + +### last8+ + +last(): number + +Puts the [BreakIterator](#breakiterator8) object to the last text boundary, which is always the next position after the end of the processed text. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Offset of the last text boundary of the processed text.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.last(); // 27 + ``` + + +### next8+ + +next(index?: number): number + +Moves the [BreakIterator](#breakiterator8) object backward by the specified number of text boundaries if the specified index is a positive number. If the index is a negative number, the [BreakIterator](#breakiterator8) object will be moved forward by the corresponding number of text boundaries. If no index is specified, the index will be treated as **1**. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | index | number | No| Number of text boundaries by which the [BreakIterator](#breakiterator8) object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as **1**.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.first(); // 0 + iterator.next(); // 6 + iterator.next(10); // -1 + ``` + + +### previous8+ + +previous(): number + +Moves the [BreakIterator](#breakiterator8) object to the previous text boundary. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.| -- Return values +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.first(); // 0 + iterator.next(3); // 12 + iterator.previous(); // 9 + ``` - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the 24-hour clock is used, and value false indicates the opposite.

-
+### following8+ -- Example +following(offset: number): number - ``` - var is24HourClock = i18n.is24HourClock(); - ``` +Moves the [BreakIterator](#breakiterator8) object to the text boundary after the position specified by the offset. Position of the [BreakIterator](#breakiterator8) object after it is moved to the text boundary after the position specified by the offset. +**System capability**: SystemCapability.Global.I18n -## i18n.set24HourClock8+ +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | offset | number | Yes| Offset to the position before the text boundary to which the [BreakIterator](#breakiterator8) object is moved.| -set24HourClock\(option: boolean\): boolean +- Return value + | Type| Description| + | -------- | -------- | + | number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.following(0); // 6 + iterator.following(100); // -1 + iterator.current(); // 27 + ``` + + +### isBoundary8+ + +isBoundary(offset: number): boolean + +Checks whether the position specified by the offset is a text boundary. If **true** is returned, the [BreakIterator](#breakiterator8) object is moved to the position specified by the offset. If **false** is returned, the [BreakIterator](#breakiterator8) object is moved to the text boundary after the position specified by the offset, which is equivalent to calling [following](#following8)(offset). + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | offset | number | Yes| Position to check.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the position specified by the offset is a text boundary, and value **false** indicates the opposite.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.isBoundary(0); // true; + iterator.isBoundary(5); // false; + ``` + + +## i18n.is24HourClock8+ + +is24HourClock(): boolean + +Checks whether the 24-hour clock is used. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the 24-hour clock is used, and value **false** indicates the opposite.| + +- Example + ``` + var is24HourClock = i18n.is24HourClock(); + ``` + + +## i18n.set24HourClock8+ + +set24HourClock(option: boolean): boolean Sets the 24-hour clock. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

option

-

boolean

-

Yes

-

Whether to enable the 24-hour clock. The value true means to enable the 24-hour clock, and value false means the opposite.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the 24-hour clock is enabled, and value false indicates the opposite.

-
- - -- Example - - ``` - // Set the system time to the 24-hour format. - var success = I18n.set24HourClock(true); - ``` - - -## i18n.addPreferredLanguage8+ - -addPreferredLanguage\(language: string, index?: number\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | option | boolean | Yes| Whether to enable the 24-hour clock. The value **true** means to enable the 24-hour clock, and value **false** means the opposite.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the 24-hour clock is enabled, and value **false** indicates the opposite.| + +- Example + ``` + // Set the system time to the 24-hour clock. + var success = I18n.set24HourClock(true); + ``` + + +## i18n.addPreferredLanguage8+ + +addPreferredLanguage(language: string, index?: number): boolean Adds a preferred language to the specified position on the preferred language list. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

language

-

string

-

Yes

-

Preferred language to add.

-

index

-

number

-

No

-

Position to which the preferred language is added.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the preferred language is added, and value false indicates the opposite.

-
- - -- Example - - ``` - // Add zh-CN to the preferred language list. - var language = 'zh-CN'; - var index = 0; - var success = i18n.addPreferredLanguage(langauge, index); - ``` - - -## i18n.removePreferredLanguage8+ - -removePreferredLanguage\(index: number\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | language | string | Yes| Preferred language to add.| + | index | number | No| Position to which the preferred language is added.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the preferred language is successfully added, and value **false** indicates the opposite.| + +- Example + ``` + // Add zh-CN to the preferred language list. + var language = 'zh-CN'; + var index = 0; + var success = i18n.addPreferredLanguage(language, index); + ``` + + +## i18n.removeDisplayLanguage8+ + +removeDisplayLanguage(index: number): boolean Deletes a preferred language from the specified position on the preferred language list. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

index

-

number

-

Yes

-

Position of the preferred language to delete.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the preferred language is deleted, and value false indicates the opposite.

-
- - -- Example - - ``` - // Delete the first preferred language from the preferred language list. - var index = 0; - var success = i18n.removePreferredLanguage(index); - ``` - - -## i18n.getPreferredLanguageList8+ - -getPreferredLanguageList\(\): Array +**System capability**: SystemCapability.Global.I18n -Obtains the preferred language list. +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | index | number | Yes| Position of the preferred language to delete.| -- Return values +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the preferred language is deleted, and value **false** indicates the opposite.| - - - - - - - - - -

Type

-

Description

-

Array<string>

-

Preferred language list.

-
+- Example + ``` + // Delete the first preferred language from the preferred language list. + var index = 0; + var success = i18n.removePreferredLanguage(index); + ``` -- Example +## i18n.getPreferredLanguageList8+ - ``` - var preferredLanguageList = i18n.getPreferredLanguageList(); - ``` +getPreferredLanguageList(): Array +Obtains the preferred language list. -## i18n.getFirstPreferredLanguage8+ +**System capability**: SystemCapability.Global.I18n -getFirstPreferredLanguage\(\): string +- Return value + | Type| Description| + | -------- | -------- | + | Array | Preferred language list.| -Obtains the preferred language that best matches the HAP resource. +- Example + ``` + var preferredLanguageList = i18n.getPreferredLanguageList(); + ``` -- Return values - - - - - - - - - -

Type

-

Description

-

string

-

Preferred language that best matches the HAP resource.

-
+## i18n.getFirstPreferredLanguage8+ +getFirstPreferredLanguage(): string + +Obtains the preferred language that best matches the HAP resource. -- Example +**System capability**: SystemCapability.Global.I18n - ``` - var firstPreferredLangauge = i18n.getFirstPreferredLangauge(); - ``` +- Return value + | Type| Description| + | -------- | -------- | + | string | Preferred language that best matches the HAP resource.| +- Example + ``` + var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); + ``` diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index f18b8b8bf316bb4b680d03cef06dbcd19e14bbfe..719154b9fcaf6c484cdf5b7c195be310d1c96c0e 100644 --- a/en/application-dev/reference/apis/js-apis-intl.md +++ b/en/application-dev/reference/apis/js-apis-intl.md @@ -1,1996 +1,681 @@ -# Internationalization (intl) +# Internationalization – intl ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ->- This module contains standard i18n APIs, which are defined in ECMA 402. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> - This module contains standard i18n APIs, which are defined in ECMA 402. -## Modules to Import + +## Modules to Import ``` import Intl from '@ohos.intl'; ``` -## Required Permissions - -None - -## Locale - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

language

-

string

-

Yes

-

No

-

Language associated with the locale, for example, zh.

-

script

-

string

-

Yes

-

No

-

Script type of the language, for example, Hans.

-

region

-

string

-

Yes

-

No

-

Region associated with the locale, for example, CN.

-

baseName

-

string

-

Yes

-

No

-

Basic key information about the locale, which consists of the language, script, and region, for example, zh-Hans-CN.

-

caseFirst

-

string

-

Yes

-

No

-

Whether case is taken into account for the locale's collation rules. The value can be upper, lower, or false.

-

calendar

-

string

-

Yes

-

No

-

Calendar for the locale. The value can be buddhist, chinese, coptic, dangi, ethioaa, ethiopic, gregory, hebrew, indian, islamic, islamic-umalqura, islamic-tbla, islamic-civil, islamic-rgsa, iso8601, japanese, persian, roc, or islamicc.

-

collation

-

string

-

Yes

-

No

-

Collation rules for the locale. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, and zhuyin.

-

hourCycle

-

string

-

Yes

-

No

-

Time system for the locale. The value can be h11, h12, h23, or h24.

-

numberingSystem

-

string

-

Yes

-

No

-

Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, and wcho.

-

numeric

-

boolean

-

Yes

-

No

-

Whether to apply special collation rules for numeric characters.

-
- -### constructor - -constructor\(locale: string, options?: options\) - -Creates a **Locale** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-
- - -- Example - - ``` - var locale = new Intl.Locale("zh-CN"); - ``` - - -### toString - -toString\(\): string + +## Locale + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| language | string | Yes| No| Language associated with the locale, for example, **zh**.
**System capability**: SystemCapability.Global.I18n| +| script | string | Yes| No| Script type of the language, for example, **Hans**.
**System capability**: SystemCapability.Global.I18n| +| region | string | Yes| No| Region associated with the locale, for example, **CN**.
**System capability**: SystemCapability.Global.I18n| +| baseName | string | Yes| No| Basic key information about the locale, which consists of the language, script, and region, for example, **zh-Hans-CN**.
**System capability**: SystemCapability.Global.I18n| +| caseFirst | string | Yes| No| Whether case is taken into account for the locale's collation rules. The value can be **upper**, **lower**, or **false**.
**System capability**: SystemCapability.Global.I18n| +| calendar | string | Yes| No| Calendar for the locale. The value can be any of the following: buddhist, chinese, coptic, dangi, ethioaa, ethiopic, gregory, hebrew, indian, islamic, islamic-umalqura, islamic-tbla, islamic-civil, islamic-rgsa, iso8601, japanese, persian, roc, islamicc.
**System capability**: SystemCapability.Global.I18n| +| collation | string | Yes| No| Rule for sorting regions. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, zhuyin.
**System capability**: SystemCapability.Global.I18n| +| hourCycle | string | Yes| No| Time system for the locale. The value can be any of the following: h12, h23, h11, and h24.
**System capability**: SystemCapability.Global.I18n| +| numberingSystem | string | Yes| No| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.
**System capability**: SystemCapability.Global.I18n| +| numeric | boolean | Yes| No| Whether to apply special collation rules for numeric characters.
**System capability**: SystemCapability.Global.I18n| + + +### constructor + +constructor(locale: string, options?: options) + +Creates a Locale object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| A string containing locale information, including the language, optional script, and region.| + | options | options | No| Options for creating the **Locale** object.| + +- Example + ``` + var locale = new Intl.Locale("zh-CN"); + ``` + + +### toString + +toString(): string Converts locale information to a string. -- Return values +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | string | String containing locale information.| + +- Example + ``` + var locale = new Intl.Locale("zh-CN"); + locale.toString(); + ``` + + +### maximize + +maximize(): Locale + +Maximizes information of the **Locale** object. If the script and locale information is missing, add the information. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | [Locale](#locale) | **Locale** object with the maximized information.| + +- Example + ``` + var locale = new Intl.Locale("zh-CN"); + locale.maximize(); + ``` + - - - - - - - - - -

Type

-

Description

-

string

-

String containing locale information.

-
+### minimize +minimize(): Locale -- Example +Minimizes information of the **Locale** object. If the script and locale information is present, delete the information. - ``` - var locale = new Intl.Locale("zh-CN"); - locale.toString(); - ``` - - -### maximize - -maximize\(\): Locale - -Maximizes information of the **Locale** object. If the script and locale information is missing, add the information. - -- Return values - - - - - - - - - - -

Type

-

Description

-

Locale

-

Locale object with the maximized information.

-
+**System capability**: SystemCapability.Global.I18n +- Return value + | Type| Description| + | -------- | -------- | + | [Locale](#locale) | **Locale** object with the minimized information.| -- Example +- Example + ``` + var locale = new Intl.Locale("zh-CN"); + locale.minimize(); + ``` - ``` - var locale = new Intl.Locale("zh-CN"); - locale.maximize(); - ``` +## DateTimeFormat -### minimize - -minimize\(\): Locale - -Minimizes information of the **Locale** object. If the script and locale information is present, delete the information. - -- Return values - - - - - - - - - - -

Type

-

Description

-

Locale

-

Locale object with the minimized information.

-
- - -- Example - - ``` - var locale = new Intl.Locale("zh-CN"); - locale.minimize(); - ``` - - -## DateTimeFormat - -### constructor - -constructor\(locale: string, options?: DateTimeOptions\) - -Creates a **DateTimeOptions** object for the specified locale. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

options

-

DateTimeOptions

-

No

-

Options for creating a DateTimeFormat object.

-
- - -- Example - - ``` - var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' }); - ``` - - -### constructor - -constructor\(locales: Array, options?: DateTimeOptions\) - -Creates a **DateTimeOptions** object for the specified array of locales. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locales

-

Array<string>

-

Yes

-

An array of strings containing locale information.

-

options

-

DateTimeOptions

-

No

-

Options for creating a DateTimeFormat object.

-
- - -- Example - - ``` - var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); - ``` - - -### format - -format\(date: Date\): string + +### constructor + +constructor(locale: string, options?: DateTimeOptions) + +Creates a **DateTimeOptions** object for the specified locale. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| A string containing locale information, including the language, optional script, and region.| + | options | [DateTimeOptions](#datetimeoptions) | No| Options for creating a **DateTimeFormat** object.| + +- Example + ``` + var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' }); + ``` + + +### constructor + +constructor(locales: Array<string>, options?: DateTimeOptions) + +Creates a **DateTimeOptions** object for the specified locale. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locales | Array<string> | Yes| An array of strings containing locale information.| + | options | [DateTimeOptions](#datetimeoptions) | No| Options for creating a **DateTimeFormat** object.| + +- Example + ``` + var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); + ``` + + +### format + +format(date: Date): string Formats the specified date and time. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

date

-

Date

-

Yes

-

Date and time to be formatted.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

A string containing the formatted date and time.

-
- - -- Example - - ``` - var date = new Date(2021, 11, 17, 3, 24, 0); - var datefmt = new Intl.DateTimeFormat("en-GB"); - datefmt.format(date); - ``` - - -### formatRange - -formatRange\(fromDate: Date, toDate: Date\): string +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | date | Date | Yes| Date and time to be formatted.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | A string containing the formatted date and time.| + +- Example + ``` + var date = new Date(2021, 11, 17, 3, 24, 0); + var datefmt = new Intl.DateTimeFormat("en-GB"); + datefmt.format(date); + ``` + + +### formatRange + +formatRange(fromDate: Date, toDate: Date): string Formats the specified date range. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

startDate

-

Date

-

Yes

-

Start date and time to be formatted.

-

endDate

-

Date

-

Yes

-

End date and time to be formatted.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

A string containing the formatted date and time range.

-
- - -- Example - - ``` - var startDate = new Date(2021, 11, 17, 3, 24, 0); - var endDate = new Date(2021, 11, 18, 3, 24, 0); - var datefmt = new Intl.DateTimeFormat("en-GB"); - datefmt.formatRange(startDate, endDate); - ``` - - -### resolvedOptions - -resolvedOptions\(\): DateTimeOptions - -Obtains the formatting options for **DateTimeFormat** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

DateTimeOptions

-

Formatting options for DateTimeFormat objects.

-
- - -- Example - - ``` - var datefmt = new Intl.DateTimeFormat("en-GB"); - datefmt.resolvedOptions(); - ``` - - -## DateTimeOptions - -Provides the options for the **DateTimeFormat** object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

locale

-

string

-

Yes

-

No

-

Locale, for example, zh-Hans-CN.

-

dateStyle

-

string

-

Yes

-

Yes

-

Date display format. The value can be long, short, medium, or full.

-

timeStyle

-

string

-

Yes

-

Yes

-

Time display format. The value can be long, short, medium, or full.

-

hourCycle

-

string

-

Yes

-

Yes

-

Time system for the locale. The value can be h11, h12, h23, or h24.

-

timeZone

-

string

-

Yes

-

Yes

-

Time zone represented by a valid IANA time zone ID.

-

numberingSystem

-

string

-

Yes

-

Yes

-

Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, and wcho.

-

hour12

-

boolean

-

Yes

-

Yes

-

Whether to use the 12-hour clock.

-

weekday

-

string

-

Yes

-

Yes

-

Workday display format. The value can be long, short, or narrow.

-

era

-

string

-

Yes

-

Yes

-

Era display format. The value can be long, short, or narrow.

-

year

-

string

-

Yes

-

Yes

-

Year display format. The value can be numeric or 2-digit.

-

month

-

string

-

Yes

-

Yes

-

Month display format. The value can be numeric, 2-digit, long, short, or narrow.

-

day

-

string

-

Yes

-

Yes

-

Day display format. The value can be numeric or 2-digit.

-

hour

-

string

-

Yes

-

Yes

-

Hour display format. The value can be numeric or 2-digit.

-

minute

-

string

-

Yes

-

Yes

-

Minute display format. The value can be numeric or 2-digit.

-

second

-

string

-

Yes

-

Yes

-

Second display format. The value can be numeric or 2-digit.

-

timeZoneName

-

string

-

Yes

-

Yes

-

Localized representation of a time zone name.

-

dayPeriod

-

string

-

Yes

-

Yes

-

Time period display format. The value can be long, short, or narrow.

-

localeMatcher

-

string

-

Yes

-

Yes

-

Locale matching algorithm. The value can be lookup or best fit.

-

formatMatcher

-

string

-

Yes

-

Yes

-

Format matching algorithm. The value can be basic or best fit.

-
- -## NumberFormat - -### constructor - -constructor\(locale: string, options?: NumberOptions\) - -Creates a **NumberFormat** object for the specified locale. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

options

-

NumberOptions

-

No

-

Options for creating a NumberFormat object.

-
- -- Example - - ``` - var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"}); - ``` - - -### constructor - -constructor\(locales: Array, options?: NumberOptions\) - -Creates a **NumberFormat** object for the specified array of locales. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locales

-

Array<string>

-

Yes

-

An array of strings containing locale information.

-

options

-

NumberOptions

-

No

-

Options for creating a NumberFormat object.

-
- - -- Example - - ``` - var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); - ``` - - -### format - -format\(number: number\): string; +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | startDate | Date | Yes| Start date and time to be formatted.| + | endDate | Date | Yes| End date and time to be formatted.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | A string containing the formatted date and time range.| + +- Example + ``` + var startDate = new Date(2021, 11, 17, 3, 24, 0); + var endDate = new Date(2021, 11, 18, 3, 24, 0); + var datefmt = new Intl.DateTimeFormat("en-GB"); + datefmt.formatRange(startDate, endDate); + ``` + + +### resolvedOptions + +resolvedOptions(): DateTimeOptions + +Obtains the formatting options for **DateTimeFormat** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | [DateTimeOptions](#datetimeoptions) | Formatting options for **DateTimeFormat** objects.| + +- Example + ``` + var datefmt = new Intl.DateTimeFormat("en-GB"); + datefmt.resolvedOptions(); + ``` + + +## DateTimeOptions + +Provides the options for the **DateTimeFormat** object. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.
**System capability**: SystemCapability.Global.I18n| +| dateStyle | string | Yes| Yes| Date display format. The value can be **long**, **short**, **medium**, or **full**.
**System capability**: SystemCapability.Global.I18n| +| timeStyle | string | Yes| Yes| Time display format. The value can be **long**, **short**, **medium**, or **full**.
**System capability**: SystemCapability.Global.I18n| +| hourCycle | string | Yes| Yes| Time system for the locale. The value can be any of the following: h11, h12, h23, h24.
**System capability**: SystemCapability.Global.I18n| +| timeZone | string | Yes| Yes| Time zone represented by a valid IANA time zone ID.
**System capability**: SystemCapability.Global.I18n| +| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.
**System capability**: SystemCapability.Global.I18n| +| hour12 | boolean | Yes| Yes| Whether to use the 12-hour clock.
**System capability**: SystemCapability.Global.I18n| +| weekday | string | Yes| Yes| Workday display format. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| +| era | string | Yes| Yes| Era display format. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| +| year | string | Yes| Yes| Year display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| +| month | string | Yes| Yes| Month display format. The value can be any of the following: numeric, 2-digit, long, short, narrow.
**System capability**: SystemCapability.Global.I18n| +| day | string | Yes| Yes| Day display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| +| hour | string | Yes| Yes| Hour display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| +| minute | string | Yes| Yes| Minute display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| +| second | string | Yes| Yes| Seconds display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| +| timeZoneName | string | Yes| Yes| Localized representation of a time zone name.
**System capability**: SystemCapability.Global.I18n| +| dayPeriod | string | Yes| Yes| Time period display format. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| formatMatcher | string | Yes| Yes| Format matching algorithm. The value can be **basic** or **best fit**.
**System capability**: SystemCapability.Global.I18n| + + +## NumberFormat + + +### constructor + +constructor(locale: string, options?: NumberOptions) + +Creates a **NumberFormat** object for the specified locale. + +**System capability**: SystemCapability.Global.I18n + +Parameters +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| locale | string | Yes| A string containing locale information, including the language, optional script, and region.| +| options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.| + +- Example + ``` + var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"}); + ``` + + +### constructor + +constructor(locales: Array<string>, options?: NumberOptions) + +Creates a **NumberFormat** object for the specified locale. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locales | Array<string> | Yes| An array of strings containing locale information.| + | options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.| + +- Example + ``` + var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); + ``` + + +### format + +format(number: number): string; Formats a number. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

number

-

number

-

Yes

-

Number to be formatted.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Formatted number.

-
- - -- Example - - ``` - var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); - numfmt.format(1223); - ``` - - -### resolvedOptions - -resolvedOptions\(\): NumberOptions - -Obtains the options of the **NumberFormat** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

NumberOptions

-

Options of the NumberFormat object.

-
- - -- Example - - ``` - var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); - numfmt.resolvedOptions(); - ``` - - -## NumberOptions +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | number | number | Yes| Number to be formatted.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Formatted number.| + + +- Example + ``` + var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); + numfmt.format(1223); + ``` + + +### resolvedOptions + +resolvedOptions(): NumberOptions + +Obtains the options of the **NumberFormat** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | [NumberOptions](#numberoptions) | Formatting options for **NumberFormat** objects.| + + +- Example + ``` + var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); + numfmt.resolvedOptions(); + ``` + + +## NumberOptions Provides the device capability. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

locale

-

string

-

Yes

-

No

-

Locale, for example, zh-Hans-CN.

-

currency

-

string

-

Yes

-

Yes

-

Currency unit, for example, EUR, CNY, or USD.

-

currencySign

-

string

-

Yes

-

Yes

-

Currency unit symbol. The value can be symbol, narrowSymbol, code, or name.

-

currencyDisplay

-

string

-

Yes

-

Yes

-

Currency display mode. The value can be symbol, narrowSymbol, code, or name.

-

unit

-

string

-

Yes

-

Yes

-

Unit name, for example, meter, inch, or hectare.

-

unitDisplay

-

string

-

Yes

-

Yes

-

Unit display format. The value can be long, short, or medium.

-

unitUsage

-

string

-

Yes

-

Yes

-

Unit use case. The value can be any of the following: default, area-land-agricult, area-land-commercl, area-land-residntl, length-person, length-person-small, length-rainfall, length-road, length-road-small, length-snowfall, length-vehicle, length-visiblty, length-visiblty-small, length-person-informal, length-person-small-informal, length-road-informal, speed-road-travel, speed-wind, temperature-person, temperature-weather, and volume-vehicle-fuel.

-

signDisplay

-

string

-

Yes

-

Yes

-

Number sign display format. The value can be auto, never, always, or expectZero.

-

compactDisplay

-

string

-

Yes

-

Yes

-

Compact display format. The value can be long or short.

-

notation

-

string

-

Yes

-

Yes

-

Number notation. The value can be standard, scientific, engineering, or compact.

-

localeMatcher

-

string

-

Yes

-

Yes

-

Locale matching algorithm. The value can be lookup or best fit.

-

style

-

string

-

Yes

-

Yes

-

Number display format. The value can be decimal, currency, percent, or unit.

-

numberingSystem

-

string

-

Yes

-

Yes

-

Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, and wcho.

-

useGrouping

-

boolean

-

Yes

-

Yes

-

Whether to use grouping for display.

-

miniumumIntegerDigits

-

number

-

Yes

-

Yes

-

Minimum number of digits allowed in the integer part of a number. The value ranges from 1 to 21.

-

miniumumFractionDigits

-

number

-

Yes

-

Yes

-

Minimum number of digits in the fraction part of a number. The value ranges from 0 to 20.

-

maxiumumFractionDigits

-

number

-

Yes

-

Yes

-

Maximum number of digits in the fraction part of a number. The value ranges from 1 to 21.

-

miniumumSignificantDigits

-

number

-

Yes

-

Yes

-

Minimum number of the least significant digits. The value ranges from 1 to 21.

-

maxiumumSignificantDigits

-

number

-

Yes

-

Yes

-

Maximum number of the least significant digits. The value ranges from 1 to 21.

-
- -## Collator8+ - -### constructor8+ - -constructor\(\) - -Creates a **Collator** object. - -- Example - - ``` - var collator = new Intl.Collator(); - ``` - - -### constructor8+ - -constructor\(locale: string | Array, options?: CollatorOptions\) - -Creates a **Collator** object based on the specified locale and options. +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.
**System capability**: SystemCapability.Global.I18n| +| currency | string | Yes| Yes| Currency unit, for example, **EUR**, **CNY**, or **USD**.
**System capability**: SystemCapability.Global.I18n| +| currencySign | string | Yes| Yes| Currency unit symbol. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.
**System capability**: SystemCapability.Global.I18n| +| currencyDisplay | string | Yes| Yes| Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.
**System capability**: SystemCapability.Global.I18n| +| unit | string | Yes| Yes| Unit name, for example, **meter**, **inch**, or **hectare**.
**System capability**: SystemCapability.Global.I18n| +| unitDisplay | string | Yes| Yes| Unit display format. The value can be **long**, **short**, or **medium**.
**System capability**: SystemCapability.Global.I18n| +| unitUsage | string | Yes| Yes| Unit usage scenario. The value can be any of the following: default, area-land-agricult, area-land-commercl, area-land-residntl, length-person, length-person-small, length-rainfall, length-road, length-road-small, length-snowfall, length-vehicle, length-visiblty, length-visiblty-small, length-person-informal, length-person-small-informal, length-road-informal, speed-road-travel, speed-wind, temperature-person, temperature-weather, volume-vehicle-fuel.
**System capability**: SystemCapability.Global.I18n| +| signDisplay | string | Yes| Yes| Number sign display format. The value can be **auto**, **never**, always**, or **expectZero**.
**System capability**: SystemCapability.Global.I18n| +| compactDisplay | string | Yes| Yes| Compact display format. The value can be **long** or **short**.
**System capability**: SystemCapability.Global.I18n| +| notation | string | Yes| Yes| Number formatting specification. The value can be **standard**, **scientific**, engineering**, or **compact**.
**System capability**: SystemCapability.Global.I18n| +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| style | string | Yes| Yes| Number display format. The value can be **decimal**, **currency**, **percent**, or **unit**.
**System capability**: SystemCapability.Global.I18n| +| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.
**System capability**: SystemCapability.Global.I18n| +| useGrouping | boolean | Yes| Yes| Whether to use grouping for display.
**System capability**: SystemCapability.Global.I18n| +| miniumumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| miniumumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **1** to **20**.
**System capability**: SystemCapability.Global.I18n| +| maxiumumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| miniumumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| maxiumumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| -Parameters - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string|Array<string>

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

options

-

CollatorOptions

-

No

-

Options for creating a Collator object.

-
- -- Example - - ``` - var collator = new Intl.Collator("zh-CN", {"localeMatcher": "lookup", "usage": "sort"}); - ``` - - -### compare8+ - -compare\(first: string, second: string\): number - -Compares two strings based on the sorting policy of the **Collator**. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

first

-

string

-

Yes

-

First string to compare.

-

second

-

string

-

Yes

-

Second string to compare.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Comparison result. If the value is a negative number, the first string is before the second string. If the value of number is 0, the first string is equal to the second string. If the value of number is a positive number, the first string is after the second string.

-
- - -- Example - - ``` - var collator = new intl.Collator("zh-Hans"); - collator.compare("first", "second"); - ``` - - -### resolvedOptions8+ - -resolvedOptions\(\): CollatorOptions - -Returns properties reflecting the locale and collation options of a **Collator** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

CollatorOptions

-

Properties of the Collator object.

-
- - -- Example - - ``` - var collator = new intl.Collator("zh-Hans"); - var options = collator.resolvedOptions(); - ``` - - -## CollatorOptions8+ - -Represents the properties of a **Collator** object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

localeMatcher

-

string

-

Yes

-

Yes

-

Locale matching algorithm. The value can be lookup or best fit.

-

usage

-

string

-

Yes

-

Yes

-

Whether the comparison is for sorting or for searching. The value can be sort or search.

-

sensitivity

-

string

-

Yes

-

Yes

-

Differences in the strings that lead to non-zero return values. The value can be base, accent, case, or variant.

-

ignorePunctuation

-

boolean

-

Yes

-

Yes

-

Whether punctuation is ignored. The value can be true or false.

-

collation

-

string

-

Yes

-

Yes

-

Sorting policy. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, and zhuyin.

-

numeric

-

boolean

-

Yes

-

Yes

-

Whether numeric collation is used. The value can be true or false.

-

caseFirst

-

string

-

Yes

-

Yes

-

Whether upper case or lower case is sorted first. The value can be upper, lower, or false.

-
- -## PluralRules8+ - -### constructor8+ - -constructor\(\) - -Create a **PluralRules** object. - -- Example - - ``` - var pluralRules = new Intl.PluralRules(); - ``` - - -### constructor8+ - -constructor\(locale: string | Array, options?: PluralRulesOptions\) - -Creates a **PluralRules** object based on the specified locale and options. +## Collator8+ + + +### constructor8+ + +constructor() + +Creates a Collator object. + +**System capability**: SystemCapability.Global.I18n + +- Example + ``` + var collator = new Intl.Collator(); + ``` + + +### constructor8+ + +constructor(locale: string | Array<string>, options?: CollatorOptions) + +Creates a Collator object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string\|Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| + | options | [CollatorOptions](#collatoroptions) | No| Options for creating a **Collator** object.| + +- Example + ``` + var collator = new Intl.Collator("zh-CN", {"localeMatcher": "lookup", "usage": "sort"}); + ``` + + +### compare8+ + +compare(first: string, second: string): number + +Compares two strings based on the sorting policy of the **Collator** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | first | string | Yes| First string to compare.| + | second | string | Yes| Second string to compare.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Comparison result. If the value is a negative number, the first string is before the second string. If the value of number is **0**, the first string is equal to the second string. If the value of number is a positive number, the first string is after the second string.| + +- Example + ``` + var collator = new Intl.Collator("zh-Hans"); + collator.compare("first", "second"); + ``` + + +### resolvedOptions8+ + +resolvedOptions(): CollatorOptions + +Returns properties reflecting the locale and collation options of a **Collator** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | [CollatorOptions](#collatoroptions) | Properties of the **Collator** object.| + +- Example + ``` + var collator = new Intl.Collator("zh-Hans"); + var options = collator.resolvedOptions(); + ``` + + +## CollatorOptions8+ + +Represents the properties of a **Collator** object. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| usage | string | Yes| Yes| Whether the comparison is for sorting or for searching. The value can be **sort** or **search**.
**System capability**: SystemCapability.Global.I18n| +| sensitivity | string | Yes| Yes| Differences in the strings that lead to non-zero return values. The value can be **base**, **accent**, **case**, or **variant**.
**System capability**: SystemCapability.Global.I18n| +| ignorePunctuation | boolean | Yes| Yes| Whether punctuation is ignored. The value can be **true** or **false**.
**System capability**: SystemCapability.Global.I18n| +| collation | string | Yes| Yes| Rule for sorting regions. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, zhuyin.
**System capability**: SystemCapability.Global.I18n| +| numeric | boolean | Yes| Yes| Whether numeric collation is used. The value can be **true** or **false**.
**System capability**: SystemCapability.Global.I18n| +| caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.
**System capability**: SystemCapability.Global.I18n| + + +## PluralRules8+ + + +### constructor8+ + +constructor() + +Create a **PluralRules** object. + +**System capability**: SystemCapability.Global.I18n + +- Example + ``` + var pluralRules = new Intl.PluralRules(); + ``` + + +### constructor8+ + +constructor(locale: string | Array<string>, options?: PluralRulesOptions) + +Create a **PluralRules** object. + +**System capability**: SystemCapability.Global.I18n Parameters +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| locale | string\|Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| +| options | [PluralRulesOptions](#pluralrulesoptions) | No| Options for creating a **PluralRules** object.| + +- Example + ``` + var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); + ``` - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string|Array<string>

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

options

-

PluralRulesOptions

-

No

-

Options for creating a PluralRules object.

-
- -- Example - - ``` - var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); - ``` - - -### select8+ - -select\(n: number\): string + +### select8+ + +select(n: number): string Obtains a string that represents the singular-plural type of the specified number. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

n

-

number

-

Yes

-

Number for which the singular-plural type is to be obtained.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Singular-plural type. The options are as follows: zero, one, two, few, many, and others.

-
- - -- Example - - ``` - var pluralRules = new intl.PluralRules("zh-Hans"); - pluralRules.select(1); - ``` - - -## PluralRulesOptions8+ - -Represents the properties of a **PluralRules** object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

localeMatcher

-

string

-

Yes

-

Yes

-

Locale matching algorithm. The value can be lookup or best fit.

-

type

-

string

-

Yes

-

Yes

-

Sorting type. The value can be cardinal or ordinal.

-

minimumIntegerDigits

-

number

-

Yes

-

Yes

-

Minimum number of digits allowed in the integer part of a number. The value ranges from 1 to 21.

-

minimumFractionDigits

-

number

-

Yes

-

Yes

-

Minimum number of digits in the fraction part of a number. The value ranges from 0 to 20.

-

maximumFractionDigits

-

number

-

Yes

-

Yes

-

Maximum number of digits in the fraction part of a number. The value ranges from 1 to 21.

-

minimumSignificantDigits

-

number

-

Yes

-

Yes

-

Minimum number of the least significant digits. The value ranges from 1 to 21.

-

maximumSignificantDigits

-

number

-

Yes

-

Yes

-

Maximum number of the least significant digits. The value ranges from 1 to 21.

-
- -## RelativeTimeFormat8+ - -### constructor8+ - -constructor\(\) - -Creates a **RelativeTimeFormat** object. - -- Example - - ``` - var relativetimefmt = new Intl.RelativeTimeFormat(); - ``` - - -### constructor8+ - -constructor\(locale: string | Array, options?: RelativeTimeFormatInputOptions\) - -Creates a **RelativeTimeFormat** object based on the specified locale and options. +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | n | number | Yes| Number for which the singular-plural type is to be obtained.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Singular-plural type. The value can be any of the following: one, two, few, many, others.| + +- Example + ``` + var pluralRules = new Intl.PluralRules("zh-Hans"); + pluralRules.select(1); + ``` + + +## PluralRulesOptions8+ + +Represents the properties of a **PluralRules** object. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| type | string | Yes| Yes| Sorting type. The value can be **cardinal** or **ordinal**.
**System capability**: SystemCapability.Global.I18n| +| minimumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| minimumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**.
**System capability**: SystemCapability.Global.I18n| +| maximumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| minimumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| + + +## RelativeTimeFormat8+ + + +### constructor8+ + +constructor() + +Creates a **RelativeTimeFormat** object. + +**System capability**: SystemCapability.Global.I18n + +- Example + ``` + var relativetimefmt = new Intl.RelativeTimeFormat(); + ``` + + +### constructor8+ + +constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions) + +Creates a **RelativeTimeFormat** object. + +**System capability**: SystemCapability.Global.I18n Parameters +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| locale | string\|Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| +| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | No| Options for creating a **RelativeTimeFormat** object.| + +- Example + ``` + var relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {"localeMatcher": "lookup", "numeric": "always", "style": "long"}); + ``` + - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string|Array<string>

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

options

-

RelativeTimeFormatInputOptions

-

No

-

Options for creating a RelativeTimeFormat object.

-
- -- Example - - ``` - var relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {"localeMatcher": "lookup", "numeric": "always", "style": "long"}); - ``` - - -### format8+ - -format\(value: numeric, unit: string\): string +### format8+ + +format(value: numeric, unit: string): string Formats the value and unit based on the specified locale and formatting options. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

numeric

-

Yes

-

Value to format.

-

unit

-

string

-

Yes

-

Unit to format. The value can be year, quarter, month, week, day, hour, minute, or second.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Relative time after formatting.

-
- - -- Example - - ``` - var relativetimefmt = new Intl.RelativeTimeFormat("zh-CN"); - relativetimefmt.format(3, "quarter") - ``` - - -### formatToParts8+ - -formatToParts\(value: numeric, unit: string\): Array - -Returns an array of **RelativeTimeFormat** objects in parts for locale-aware formatting. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

numeric

-

Yes

-

Value to format.

-

unit

-

string

-

Yes

-

Unit to format. The value can be year, quarter, month, week, day, hour, minute, or second.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Array<Object>

-

An array of RelativeTimeFormat objects in parts.

-
- - -- Example - - ``` - var relativetimefmt = new Intl.RelativeTimeFormat("en", {"numeric": "auto"}); - var parts = relativetimefmt.format(10, "seconds"); - ``` - - -### resolvedOptions8+ - -resolvedOptions\(\): RelativeTimeFormatResolvedOptions - -Obtains the formatting options for **RelativeTimeFormat** objects. - -- Return values - - - - - - - - - - -

Type

-

Description

-

RelativeTimeFormatResolvedOptions

-

Formatting options for RelativeTimeFormat objects.

-
- - -- Example - - ``` - var relativetimefmt= new Intl.RelativeTimeFormat("en-GB"); - relativetimefmt.resolvedOptions(); - ``` - - -## RelativeTimeFormatInputOptions8+ - -Represents the properties of a **RelativeTimeFormat** object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

localeMatcher

-

string

-

Yes

-

Yes

-

Locale matching algorithm. The value can be lookup or best fit.

-

numeric

-

string

-

Yes

-

Yes

-

Format of the output message. The value can be always or auto.

-

style

-

string

-

Yes

-

Yes

-

Length of the internationalized message. The value can be long, short, or narrow.

-
- -## RelativeTimeFormatResolvedOptions8+ - -Represents the properties of a **RelativeTimeFormat** object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

locale

-

string

-

Yes

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

numeric

-

string

-

Yes

-

Yes

-

Format of the output message. The value can be always or auto.

-

style

-

string

-

Yes

-

Yes

-

Length of the internationalized message. The value can be long, short, or narrow.

-

numberingSystem

-

string

-

Yes

-

Yes

-

Numbering system.

-
+**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | value | numeric | Yes| Value to format.| + | unit | string | Yes| Unit to format. The value can be any of the following: year, quarter, month, week, day, hour, minute, second.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Relative time after formatting.| + +- Example + ``` + var relativetimefmt = new Intl.RelativeTimeFormat("zh-CN"); + relativetimefmt.format(3, "quarter") + ``` + + +### formatToParts8+ + +formatToParts(value: numeric, unit: string): Array<Object> + +Returns an array of RelativeTimeFormat objects in parts for locale-aware formatting. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | value | numeric | Yes| Value to format.| + | unit | string | Yes| Unit to format. The value can be any of the following: year, quarter, month, week, day, hour, minute, second.| + +- Return value + | Type| Description| + | -------- | -------- | + | Array<Object> | An array of **RelativeTimeFormat** objects in parts.| + +- Example + ``` + var relativetimefmt = new Intl.RelativeTimeFormat("en", {"numeric": "auto"}); + var parts = relativetimefmt.format(10, "seconds"); + ``` + + +### resolvedOptions8+ + +resolvedOptions(): RelativeTimeFormatResolvedOptions + +Obtains the formatting options for **RelativeTimeFormat** objects. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions) | Formatting options for **RelativeTimeFormat** objects.| + +- Example + ``` + var relativetimefmt= new Intl.RelativeTimeFormat("en-GB"); + relativetimefmt.resolvedOptions(); + ``` + + +## RelativeTimeFormatInputOptions8+ + +Represents the properties of a **RelativeTimeFormat** object. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.
**System capability**: SystemCapability.Global.I18n| +| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| + + +## RelativeTimeFormatResolvedOptions8+ + +Represents the properties of a **RelativeTimeFormat** object. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| locale | string | Yes| Yes| A string containing locale information, including the language, optional script, and region.
**System capability**: SystemCapability.Global.I18n| +| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.
**System capability**: SystemCapability.Global.I18n| +| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| +| numberingSystem | string | Yes| Yes| Numbering system.
**System capability**: SystemCapability.Global.I18n| diff --git a/en/application-dev/reference/apis/js-apis-lightweightset.md b/en/application-dev/reference/apis/js-apis-lightweightset.md new file mode 100644 index 0000000000000000000000000000000000000000..cf32ebe8d594116443ca52474d2721674214388a --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-lightweightset.md @@ -0,0 +1,505 @@ +# Nonlinear Container LightWeightSet + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import LightWeightSet from '@ohos.util.LightWeightSet' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## LightWeightSet + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a lightweight set (called container later).| + + +### constructor + +constructor() + +A constructor used to create a **LightWeightSet** instance. + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +``` + + +### isEmpty + +isEmpty(): boolean + +Checks whether this container is empty. + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +const lightWeightSet = new LightWeightSet(); +let result = lightWeightSet.isEmpty(); +``` + +### add + +add(obj: T): boolean + +Adds an entry to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| obj | T | Yes| Entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +let result = lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + + +### addAll + +addAll(set: LightWeightSet<T>): boolean + +Adds all entries in a **LightWeightSet** instance to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| set | LightWeightSet<T> | Yes| **LightWeightSet** instance whose entries are to be added to the current container.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let set = new LightWeightSet(); +set.add("sfage"); +let result = lightWeightSet.addAll(set); +``` + + +### hasAll + +hasAll(set: LightWeightSet<T>): boolean + +Checks whether this container contains all entries of the specified **LightWeightSet** instance. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| set | LightWeightSet<T> | Yes| **LightWeightSet** instance to be used for comparison.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if all the entries in the specified **LightWeightSet** instance are contained; returns **false** otherwise.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let set = new LightWeightSet(); +set.add("sdfs"); +let result = lightWeightSet.hasAll(set); +``` + + +### has + +has(key: T): boolean + +Checks whether this container has the specified key. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key| T | Yes| Key to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified key is contained; returns **false** otherwise.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +let result = lightWeightSet.has(123); +lightWeightSet.add(123); +let result = lightWeightSet.has(123); +``` + + +### equal + +equal(obj: Object): boolean + +Checks whether this container contains objects of the same type as the specified **obj**. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| obj | Object | Yes| Object to be used for comparison.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container contains objects of the same type as the specified **obj**; returns **false** otherwise.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let obj = {"Ahfbrgrbgnutfodgorrogorgrogofdfdf", "sdfs"}; +let result = lightWeightSet.equal(obj); +``` + + +### increaseCapacityTo + +increaseCapacityTo(minimumCapacity: number): void + +Increases the capacity of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| minimumCapacity | number | Yes| Minimum number of entries to accommodate in the container.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.increaseCapacityTo(10); +``` + + +### getIndexOf + +getIndexOf(key: T): number + +Obtains the position index of the entry with the specified key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | T | Yes| Key of the entry to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Position index of the entry.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.getIndexOf("sdfs"); +``` + + +### remove + +remove(key: T): T + +Removes an entry of the specified key from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | T | Yes| Key of the entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value of the entry removed.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.remove("sdfs"); +``` + + +### removeAt + +removeAt(index: number): boolean + +Removes the entry at the specified position from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.removeAt(1); +``` + + +### getValueAt + +getValueAt(index: number): T + +Obtains the value of the entry at the specified position in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value obtained.| + +**Parameters** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.getValueAt(1); +``` + + +### clear + +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +lightWeightSet.clear(); +``` + + +### toString + +toString(): String + +Obtains a string that contains all entries in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| String | String obtained.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.toString(); +``` + + +### toArray + +toArray(): Array<T> + +Obtains an array that contains all objects in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| Array<T> | Array obtained.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.toArray(); +``` + + +### values + +values(): IterableIterator<T> + +Obtains an iterator that contains all the values in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let iter = lightWeightSet.values(); +let index = 0; +while(index < lightWeightSet.length) { + console.log(JSON.stringify(iter.next().value)); + index++; +} +``` + + +### forEach + +forEach(callbackfn: (value: T, key?: T, set?: LightWeightSet<T>) => void, thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| key | T | No| Key of the entry that is currently traversed (same as **value**).| +| set | LightWeightSet<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("sdfs"); +lightWeightSet.add("dfsghsf"); +lightWeightSet.forEach((value, key) => { + console.log(value, key); +}); +``` + + +### entries + +entries(): IterableIterator<[T, T]> + +Obtains an iterator that contains all the entries in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<[T, T]> | Iterator obtained.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let iter = lightWeightSet.entries(); +let index = 0; +while(index < lightWeightSet.length) { + console.log(JSON.stringify(iter.next().value)); + index++; +} +``` + + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); + +// Method 1: +for (let item of lightWeightSet) { + console.log("value: " + item); +} + +// Method 2: +let iter = lightWeightSet[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-list.md b/en/application-dev/reference/apis/js-apis-list.md new file mode 100644 index 0000000000000000000000000000000000000000..fc7e38d2a1ae33b561f3902ea3906b5b1cadab16 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-list.md @@ -0,0 +1,619 @@ +# Linear Container List + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import List from '@ohos.util.List' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + + +## List + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a list (called container later).| + + +### constructor + +constructor(head?: NodeObj<T>) + +A constructor used to create a **List** instance. + +**Parameters** + +| Name| Value Type | Readable| Description| +| -------- | -------- | -------- | -------- | +| head | NodeObj<T> | Yes| Node object, including **element** and **next**.| + +**Example** + +``` +let list = new List(); +``` + + +### add + +add(element: T): boolean + +Adds an entry at the end of this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Element to add.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + +``` +let list = new List; +let result = list.add("a"); +let result1 = list.add(1); +let b = [1, 2, 3]; +list.add(b); +let c = {name : "lala", age : "13"}; +let result3 = list.add(false); +``` + +### insert + +insert(element: T, index: number): void + +Inserts an entry at the specified position in this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Element to insert.| +| index | number | Yes| Index of the position where the entry is to be inserted.| + +**Example** + +``` +let list = new List(); +list.insert("A", 0); +list.insert(0, 1); +list.insert(true, 2); +``` + +### has + +has(element: T): boolean + +Checks whether this container has the specified entry. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.| + +**Example** + +``` +let list = new List(); +let result = list.has("Ahfbrgrbgnutfodgorrogorg"); +list.add("Ahfbrgrbgnutfodgorrogorg"); +let result1 = list.has("Ahfbrgrbgnutfodgorrogorg"); +``` + +### get + +get(index: number): T + +Obtains the entry at the specified position in this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry to obtain.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| T | Entry obtained.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(2); +list.add(1); +list.add(2); +list.add(4); +let result = list.get(2); +``` + +### getLastIndexOf + +getLastIndexOf(element: T): number + +Obtains the index of the last occurrence of the specified entry in this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(2); +list.add(1); +list.add(2); +list.add(4); +let result = list.getLastIndexOf(2); +``` + +### getIndexOf + +getIndexOf(element: T): number + +Obtains the index of the first occurrence of the specified entry in this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(2); +list.add(1); +list.add(2); +list.add(4); +list.getIndexOf(2); +let result = list.getIndexOf(2); +``` + +### equal + +equal(obj: Object): boolean + +Compares whether a specified object is equal to this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| obj | Object | Yes| Object used for comparison.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| boolean | Returns **true** if the two are equal; returns **false** otherwise.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(2); +let obj1 = new List(); +obj1.add(2); +obj1.add(4); +obj1.add(5); +list.equal(obj1); +let obj2 = {name : "lala", age : "13"}; +let result = list.equal(obj2); +``` + +### removeByIndex + +removeByIndex(index: number): T + +Removes an entry at the specified position from this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry to remove.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(2); +list.add(4); +let result = list.removeByIndex(2); +``` + +### remove + +remove(element: T): boolean + +Removes the first occurrence of the specified entry from this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to remove.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.remove(2); +``` + +### replaceAllElements +replaceAllElements(callbackfn: (value: T, index?: number, list?: List<T>) => T, +thisArg?: Object): void + +Replaces all entries in this container with new entries, and returns the new ones. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked for the replacement.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| list | List<T> | No| Instance that invokes the **replaceAllElements** method.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +list.replaceAllElements((value, index) => { + return value = 2 * value; +}); +list.replaceAllElements((value, index) => { + return value = value - 2; +}); +``` + +### forEach +forEach(callbackfn: (value: T, index?: number, List?: List<T>) => void, +thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| List | List<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +list.forEach((value, index) => { + console.log(value, index); +}); + +``` + +### sort +sort(comparator: (firstValue: T, secondValue: T) => number): void + +Sorts entries in this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| comparator | function | Yes| Callback invoked for sorting.| + +comparator + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| firstValue | T | Yes| Previous entry.| +| secondValue | T | Yes| Next entry.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +list.sort(a, (b => a - b)); +list.sort(a, (b => b - a)); +``` + +### getSubList +getSubList(fromIndex: number, toIndex: number): List<T> + +Obtains entries within a range in this container, including the entry at the start position but not that at the end position, and returns these entries as a new **List** instance. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fromIndex | number | Yes| Index of the start position.| +| toIndex | number | Yes| Index of the end position.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| List<T> | New **List** instance obtained.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.subList(2, 4); +let result1 = list.subList(4, 3); +let result2 = list.subList(2, 6); +``` + +### clear +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +list.clear(); +``` + +### set +set(index: number, element: T): T +Replaces an entry at the specified position in this container with a given entry. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry to replace.| +| element | T | Yes| Entry to be used for replacement.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| T | New entry.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +list.set(2, "b"); + +``` + +### convertToArray +convertToArray(): Array<T> + +Converts this container into an array. + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| Array<T> | Array obtained.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.convertToArray(); +``` + +### isEmpty +isEmpty(): boolean + +Checks whether this container is empty (contains no entry). + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.isEmpty(); +``` + +### getFirst + +getFirst(): T + +Obtains the first entry in this container. + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| T | The first entry obtained.| + +**Example** + +``` +let list = new Vector(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.getFirst(); +``` + +### getLast + +getLast(): T + +Obtains the last entry in this container. + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| T | The last entry obtained.| + +**Example** + +``` +let list = new Vector(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.getLast(); +``` + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T>; + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); + +// Method 1: +for (let item of list) { + console.log(item); +} + +// Method 2: +let iter = list[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-observer.md b/en/application-dev/reference/apis/js-apis-observer.md new file mode 100644 index 0000000000000000000000000000000000000000..bb658c1fbd35dcf714092ef915d9c6792a432dcc --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-observer.md @@ -0,0 +1,265 @@ +# Observer + +>**NOTE** +> +>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import observer from '@ohos.telephony.observer' +``` + +## observer.on('networkStateChange') + +on\(type: \'networkStateChange\', callback: Callback\): void; + +Registers an observer for network status change events. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ----------------------------------------- | ---- | --------------------------------- | +| type | string | Yes| Network status change event.| +| callback | Callback\<[NetworkState](js-apis-radio.md#NetworkState)\> | Yes| Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#NetworkState).| + +**Example** + +``` +observer.on('networkStateChange', data =>{ + console.log("on networkStateChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.on('networkStateChange') + +on\(type: \'networkStateChange\', options: { slotId: number }, callback: Callback\): void; + +Registers an observer for network status change events of the SIM card in the specified slot. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| type | string | Yes| Network status change event.| +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | Callback\<[NetworkState](js-apis-radio.md#NetworkState)\> | Yes| Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#NetworkState).| + +**Example** + +``` +observer.on('networkStateChange', {slotId: 0}, data =>{ + console.log("on networkStateChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.off('networkStateChange') + +off\(type: \'networkStateChange\', callback?: Callback\): void; + +Unregisters the observer for network status change events. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +>**NOTE** +> +>You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------ | ---- | --------------------------------- | +| type | string | Yes| Network status change event.| +| callback | Callback\<[NetworkState](js-apis-radio.md#NetworkState)\> | No| Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#NetworkState).| + +**Example** + +``` +let callback = data => { + console.log("on networkStateChange, data:" + JSON.stringify(data)); +} +observer.on('networkStateChange', callback); +// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +observer.off('networkStateChange', callback); +observer.off('networkStateChange'); +``` + +## observer.on('signalInfoChange') + +on\(type: \'signalInfoChange\', callback: Callback\>): void; + +Registers an observer for signal status change events. This function uses an asynchronous callback to return the execution result. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes| Signal status change event.| +| callback | Callback\> | Yes| Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#SignalInformation).| + +**Example** + +``` +observer.on('signalInfoChange', data =>{ + console.log("on signalInfoChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.on('signalInfoChange') + +on\(type: \'signalInfoChange\', options: { slotId: number }, callback: Callback\>): void; + +Registers an observer for signal status change events of the SIM card in the specified slot. This function uses an asynchronous callback to return the execution result. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| type | string | Yes| Signal status change event.| +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | Callback\> | Yes| Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#SignalInformation).| + +**Example** + +``` +observer.on('signalInfoChange', {slotId: 0}, data =>{ + console.log("on signalInfoChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.off('signalInfoChange') + +off\(type: \'signalInfoChange\', callback?: Callback\>): void; + +Unregisters the observer for signal status change events. This function uses an asynchronous callback to return the execution result. + +>**NOTE** +> +>You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes| Signal status change event.| +| callback | Callback\> | No| Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#SignalInformation).| + +**Example** + +``` +let callback = data => { + console.log("on signalInfoChange, data:" + JSON.stringify(data)); +} +observer.on('signalInfoChange', callback); +// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +observer.off('signalInfoChange', callback); +observer.off('signalInfoChange'); +``` + + +## observer.on('callStateChange') + +on(type: 'callStateChange', callback: Callback\<{ state: [CallState](js-apis-call.md#CallState), number: string }\>): void; + +Registers an observer for call status change events. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.READ_CALL_LOG + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes| Call status change event.| +| callback | Callback\<{ state: [CallState](js-apis-call.md#CallState), number: string }\> | Yes| Callback used to return the result. For details, see [CallState](js-apis-call.md#CallState)
**number**: phone number.| + +**Example** + +``` +observer.on('callStateChange', value =>{ + console.log("on callStateChange, state:" + value.state + ", number:" + value.number); +}); +``` + + +## observer.on('callStateChange') + +on(type: 'callStateChange', options: { slotId: number }, callback: Callback<{ state: [CallState](js-apis-call.md#CallState), number: string }>): void; + +Registers an observer for call status change events. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.READ_CALL_LOG + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes| Call status change event.| +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | Callback\<{ state: [CallState](js-apis-call.md#CallState), number: string }\> | Yes| Callback used to return the result. For details, see [CallState](js-apis-call.md#CallState)
**number**: phone number.| + +**Example** + +``` +observer.on('callStateChange', {slotId: 0}, value =>{ + console.log("on callStateChange, state:" + value.state + ", number:" + value.number); +}); +``` + + +## observer.off('callStateChange') + +off(type: 'callStateChange', callback?: Callback<{ state: [CallState](js-apis-call.md#CallState), number: string }>): void; + +Unregisters the observer for call status change events. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.READ_CALL_LOG + +>**NOTE** +> +>You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes| Call status change event.| +| callback | Callback\<{ state: [CallState](js-apis-call.md#CallState), number: string }\> | No| Callback used to return the result. For details, see [CallState](js-apis-call.md#CallState)
**number**: phone number.| + +**Example** + +``` +let callback = value => { + console.log("on callStateChange, state:" + value.state + ", number:" + value.number); +} +observer.on('callStateChange', callback); +// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +observer.off('callStateChange', callback); +observer.off('callStateChange'); +``` diff --git a/en/application-dev/reference/apis/js-apis-particleAbility.md b/en/application-dev/reference/apis/js-apis-particleAbility.md index fa68ababf9d5b4af6108f5b835a5249ad2fe59ec..84d4281dd8e8c1faa843cd92856f75c54d5d5d50 100644 --- a/en/application-dev/reference/apis/js-apis-particleAbility.md +++ b/en/application-dev/reference/apis/js-apis-particleAbility.md @@ -16,13 +16,17 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\: v Starts a particle ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | ----------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -53,17 +57,25 @@ particleAbility.startAbility( ## particleAbility.startAbility +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + startAbility(parameter: StartAbilityParameter): Promise\ Starts a particle ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | ----------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| **Return value** -| Type| Description| +| Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| @@ -99,11 +111,15 @@ terminateSelf(callback: AsyncCallback\): void Terminates this particle ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -124,8 +140,12 @@ terminateSelf(): Promise\ Terminates this particle ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Return value** -| Type| Description| +| Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| @@ -146,15 +166,19 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper Obtains a **dataAbilityHelper** object. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory| Description | | :--- | ------ | ---- | ------------------------ | -| uri | string | Yes| URI of the file to open.| +| uri | string | Yes | URI of the file to open.| **Return value** -| Type| Description| +| Type | Description | | ----------------- | -------------------------------------------- | | DataAbilityHelper | A utility class used to help other abilities access a Data ability.| @@ -168,45 +192,45 @@ particleAbility.acquireDataAbilityHelper(uri) ## StartAbilityParameter -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ------------------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | -| want | Read-only| [Want](#want) | Yes| Information about the ability to start.| -| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.| +| want | Read-only | [Want](#want) | Yes | Information about the ability to start.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| ## Want -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| deviceId | Read-only| string | No| ID of the device running the ability to start.| -| bundleName | Read-only| string | No| Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| -| abilityName | Read-only| string | No| Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| -| uri | Read-only| string | No| URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| -| type | Read-only| string | No| MIME type, for example, **text/plain** or **image/***.| -| flags | Read-only| number | No| How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](#flags).| -| action | Read-only| string | No| Action option.| -| parameters | Read-only| {[key: string]: any} | No| List of parameters in the **Want** object.| -| entities | Read-only| Array\ | No| List of entities.| +| deviceId | Read-only | string | No | ID of the device running the ability to start.
System capabilities: SystemCapability.Ability.AbilityBase | +| bundleName | Read-only | string | No | Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.
System capabilities: SystemCapability.Ability.AbilityBase| +| abilityName | Read-only | string | No | Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.
System capabilities: SystemCapability.Ability.AbilityBase| +| uri | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.
System capabilities: SystemCapability.Ability.AbilityBase| +| type | Read-only | string | No | MIME type, for example, **text/plain** or **image/***.
System capabilities: SystemCapability.Ability.AbilityBase | +| flags | Read-only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](#flags).
System capabilities: SystemCapability.Ability.AbilityBase| +| action | Read-only | string | No | Action option.
System capabilities: SystemCapability.Ability.AbilityBase | +| parameters | Read-only | {[key: string]: any} | No | List of parameters in the **Want** object.
System capabilities: SystemCapability.Ability.AbilityBase | +| entities | Read-only | Array\ | No | List of entities.
System capabilities: SystemCapability.Ability.AbilityBase | ## flags -| Name| Value| Description| +| Name | Value | Description | | ------------------------------------ | ---------- | ------------------------------------------------------------ | -| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.| -| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.| -| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.| -| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.| -| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.| -| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.| -| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.| -| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.| -| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.| -| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.| -| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.| -| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.| -| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.| -| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.| -| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.| -| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.| +| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.
System capabilities: SystemCapability.Ability.AbilityBase| +| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.
System capabilities: SystemCapability.Ability.AbilityBase| ## AbilityStartSetting @@ -214,23 +238,23 @@ The **AbilityStartSetting** attribute is an object defined as [key: string]: any Defines special attributes of an ability, for example, **featureAbility.AbilityStartSetting.BOUNDS_KEY**. -| Name| Value| Description| +| Name | Value | Description | | --------------- | --------------- | -------------------------- | -| BOUNDS_KEY | "abilityBounds" | Ability window size.| -| WINDOW_MODE_KEY | "windowMode" | Ability window display mode.| -| DISPLAY_ID_KEY | "displayId" | Display device ID.| +| BOUNDS_KEY | "abilityBounds" | Ability window size.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_KEY | "windowMode" | Ability window display mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| DISPLAY_ID_KEY | "displayId" | Display device ID.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| ## AbilityWindowConfiguration Defines the window display modes of a Page ability, for example, **featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED**. -| Name| Value| Description| +| Name | Value| Description | | --------------------------- | ---- | ---------- | -| WINDOW_MODE_UNDEFINED | 0 | The Page ability is in an undefined window display mode.| -| WINDOW_MODE_FULLSCREEN | 1 | The Page ability is in full screen mode.| -| WINDOW_MODE_SPLIT_PRIMARY | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.| -| WINDOW_MODE_SPLIT_SECONDARY | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.| -| WINDOW_MODE_FLOATING | 102 | The Page ability is displayed in floating window mode.| +| WINDOW_MODE_UNDEFINED | 0 | The Page ability is in an undefined window display mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_FULLSCREEN | 1 | The Page ability is in full screen mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_SPLIT_PRIMARY | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| +| WINDOW_MODE_SPLIT_SECONDARY | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| +| WINDOW_MODE_FLOATING | 102 | The Page ability is displayed in floating window mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | ## particleAbility.startBackgroundRunning @@ -239,6 +263,10 @@ startBackgroundRunning(id: number, request: NotificationRequest, callback: Async Requests a continuous task from the system. This method uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) +**System capabilities** + +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -295,6 +323,10 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { startBackgroundRunning(id: number, request: NotificationRequest): Promise<void> +**System capabilities** + +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + Requests a continuous task from the system. This method uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) **Parameters** @@ -304,7 +336,7 @@ Requests a continuous task from the system. This method uses a promise to return | request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.| **Return value** -| Type| Description| +| Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| @@ -355,6 +387,10 @@ cancelBackgroundRunning(callback: AsyncCallback<void>): void; Requests to cancel a continuous task from the system. This method uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) +**System capabilities** + +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -382,8 +418,12 @@ cancelBackgroundRunning(): Promise<void>; Requests to cancel a continuous task from the system. This method uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) +**System capabilities** + +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + **Return value** -| Type| Description| +| Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| diff --git a/en/application-dev/reference/apis/js-apis-queue.md b/en/application-dev/reference/apis/js-apis-queue.md new file mode 100644 index 0000000000000000000000000000000000000000..543dcf5ea8664993511256b4f41a4e859bba0327 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-queue.md @@ -0,0 +1,187 @@ +# Linear Container Queue + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import Queue from '@ohos.util.Queue' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + + +## Queue + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a queue (called container later).| + + +### constructor + +constructor() + +A constructor used to create a **Queue** instance. + +**Example** + +``` +let queue = new Queue(); +``` + + +### add + +add(element: T): boolean + +Adds an entry at the end of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + +``` +let queue = new Queue(); +let result = queue.add("a"); +let result1 = queue.add(1); +queue.add(1); +let b = [1, 2, 3]; +queue.add(b); +let c = {name : "lala", age : "13"}; +let result3 = queue.add(c); +``` + +### pop + +pop(): T + +Removes the first entry from this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let queue = new Queue(); +queue.add(2); +queue.add(4); +queue.add(5); +queue.add(2); +queue.add(4); +let result = queue.pop(); +``` + +### getFirst + +getFirst(): T + +Obtains the first entry of this container. + +**Parameters** + +| Type| Description| +| -------- | -------- | +| T | The first entry obtained.| + +**Example** + +``` +let queue = new Queue(); +queue.add(2); +queue.add(4); +queue.add(5); +queue.add(2); +let result = queue.getFirst(); +``` + +### forEach +forEach(callbackfn: (value: T, index?: number, Queue?: Queue<T>) => void, +thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| Queue | Queue<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let queue = new Queue(); +queue.add(2); +queue.add(4); +queue.add(5); +queue.add(4); +queue.forEach((value, index) => { + console.log(value, index); +}); + +``` + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** +``` +let queue = new Queue(); +queue.add(2); +queue.add(4); +queue.add(5); +queue.add(4); + +// Method 1: +for (let item of queue) { + console.log(item); +} + +// Method 2: +let iter = queue[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index a59cb7b53462b657bc1f57f091b35e087f55b40f..2ced67717197ec4576aa69c5424deca6c734c312 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -15,9 +15,11 @@ import radio from '@ohos.telephony.radio' getRadioTech\(slotId: number, callback: AsyncCallback<\{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology\}\>\): void -Obtains the radio access technologies (RATs) used by the CS and PS domains. This function uses an asynchronous callback to return the result. +Obtains the radio access technology (RAT) used by the CS and PS domains. This function uses an asynchronous callback to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService **Parameters** @@ -42,7 +44,9 @@ getRadioTech\(slotId: number\): Promise<\{psRadioTech: RadioTechnology, csRadioT Obtains the RAT used by the CS and PS domains. This function uses a promise to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService **Parameters** @@ -73,15 +77,17 @@ promise.then(data => { getNetworkState\(callback: AsyncCallback\): void -Obtains the network status of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. +Obtains the network status. This function uses an asynchronous callback to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService **Parameters** | Name| Type| Mandatory| Description| | -------- | ---------------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\<[NetworkState](#NetworkState)\> | Yes| Callback invoked to traverse the entries in the container.| +| callback | AsyncCallback\<[NetworkState](#NetworkState)\> | Yes| Callback used to return the result.| **Example** @@ -98,7 +104,9 @@ getNetworkState\(slotId: number, callback: AsyncCallback\): void Obtains the network status of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService **Parameters** @@ -123,7 +131,9 @@ getNetworkState\(slotId?: number\): Promise Obtains the network status of the SIM card in the specified slot. This function uses a promise to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService **Parameters** @@ -156,6 +166,8 @@ getNetworkSelectionMode\(slotId: number, callback: AsyncCallback Obtains the network selection mode of the SIM card in the specified slot. This function uses a promise to return the result. +**System capability**: SystemCapability.Telephony.CoreService + **Parameters** | Name| Type| Mandatory| Description| @@ -210,12 +224,14 @@ getISOCountryCodeForNetwork\(slotId: number, callback: AsyncCallback\): Obtains the ISO country code of the network with which the SIM card in the specified slot is registered. This function uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Telephony.CoreService + **Parameters** | Name| Type| Mandatory| Description| | -------- | ----------------------- | ---- | ---------------------------------------- | | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| -| callback | AsyncCallback\ | Yes| Callback used to return the result, which is a country code, for example, **CN** (China).| +| callback | AsyncCallback\ | Yes| Callback used to return the result. which is a country code, for example, **CN** (China).| **Example** @@ -233,6 +249,8 @@ getISOCountryCodeForNetwork\(slotId: number\): Promise Obtains the ISO country code of the network with which the SIM card in the specified slot is registered. This function uses a promise to return the result. +**System capability**: SystemCapability.Telephony.CoreService + **Parameters** | Name| Type| Mandatory| Description| @@ -264,6 +282,8 @@ getSignalInformation\(slotId: number, callback: AsyncCallback\> Obtains a list of signal strengths of the network with which the SIM card in the specified slot is registered. This function uses a promise to return the result. +**System capability**: SystemCapability.Telephony.CoreService + **Parameters** | Name| Type| Mandatory| Description| @@ -316,9 +338,11 @@ promise.then(data => { isRadioOn\(callback: AsyncCallback\): void -Checks whether the radio service is enabled. This function uses an asynchronous callback to return the result. +Checks whether the radio service is enabled on the primary SIM card. This function uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**System capability**: SystemCapability.Telephony.CoreService **Parameters** @@ -335,13 +359,48 @@ radio.isRadioOn((err, data) => { ``` -## radio.isRadioOn7+ +## radio.isRadioOn7+ + +isRadioOn\(slotId: number, callback: AsyncCallback\): void + +Checks whether the radio service is enabled on the SIM card in the specified slot. This function uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------ | ---- | ------------------------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result.
- **true**: The radio service is enabled.
- **false**: The radio service is disabled.| + +**Example** + +``` +let slotId = 0; +radio.isRadioOn(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.isRadioOn7+ -isRadioOn\(\): Promise +isRadioOn\(slotId?: number\): Promise Checks whether the radio service is enabled. This function uses a promise to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | No| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2
If the slot ID is not specified, this function is defaulted to check whether the radio service is enabled on the primary SIM card.| **Return value** @@ -352,7 +411,8 @@ Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO **Example** ``` -let promise = radio.isRadioOn(); +let slotId = 0; +let promise = radio.isRadioOn(slotId); promise.then(data => { console.log(`isRadioOn success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -361,25 +421,83 @@ promise.then(data => { ``` +## radio.getOperatorName7+ + +getOperatorName\(slotId: number, callback: AsyncCallback\): void + +Obtains the carrier name. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ----------------------- | ---- | ------------------------------------------ | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result, which is the carrier name, for example, China Mobile.| + +**Example** + +``` +let slotId = 0; +radio.getOperatorName(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.getOperatorName7+ + +getOperatorName\(slotId: number\): Promise + +Obtains the carrier name. This function uses a promise to return the result. + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| + +**Return value** + +| Type| Description| +| ----------------- | ------------------------------------------------------------ | +| Promise\ | Promise used t return the result, which is the carrier name, for example, China Mobile.| + +**Example** + +``` +let slotId = 0; +let promise = radio.getOperatorName(slotId); +promise.then(data => { + console.log(`getOperatorName success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getOperatorName fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + ## RadioTechnology Enumerates the RATs. | Variable| Value| Description| | ------------------------- | ---- | ------------------------------------------------------------ | -| RADIO_TECHNOLOGY_UNKNOWN | 0 | Unknown| -| RADIO_TECHNOLOGY_GSM | 1 | Global System for Mobile Communication (GSM)| -| RADIO_TECHNOLOGY_1XRTT | 2 | Single-Carrier Radio Transmission Technology (1XRTT)| -| RADIO_TECHNOLOGY_WCDMA | 3 | Wideband Code Division Multiple Access (WCDMA)| -| RADIO_TECHNOLOGY_HSPA | 4 | High Speed Packet Access (HSPA)| -| RADIO_TECHNOLOGY_HSPAP | 5 | Evolved High Speed Packet Access (HSPA+)| -| RADIO_TECHNOLOGY_TD_SCDMA | 6 | Time Division Synchronous Code Division Multiple Access (TD-SCDMA)| -| RADIO_TECHNOLOGY_EVDO | 7 | Evolution-Data Optimized (EVDO)| -| RADIO_TECHNOLOGY_EHRPD | 8 | Evolved High Rate Package Data (EHRPD)| -| RADIO_TECHNOLOGY_LTE | 9 | Long Term Evolution (LTE)| -| RADIO_TECHNOLOGY_LTE_CA | 10 | Long Term Evolution_Carrier Aggregation (LTE_CA)| -| RADIO_TECHNOLOGY_IWLAN | 11 | Industrial Wireless LAN (IWLAN)| -| RADIO_TECHNOLOGY_NR | 12 | New Radio (NR)| +| RADIO_TECHNOLOGY_UNKNOWN | 0 | Unknown RAT
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_GSM | 1 | Global System for Mobile Communication (GSM)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_1XRTT | 2 | Single-Carrier Radio Transmission Technology (1XRTT)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_WCDMA | 3 | Wideband Code Division Multiple Access (WCDMA)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_HSPA | 4 | High Speed Packet Access (HSPA)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_HSPAP | 5 | Evolved High Speed Packet Access (HSPA+)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_TD_SCDMA | 6 | Time Division Synchronous Code Division Multiple Access (TD-SCDMA)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_EVDO | 7 | Evolution-Data Optimized (EVDO)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_EHRPD | 8 | Evolved High Rate Package Data (EHRPD)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_LTE | 9 | Long Term Evolution (LTE)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_LTE_CA | 10 | Long Term Evolution_Carrier Aggregation (LTE_CA)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_IWLAN | 11 | Industrial Wireless LAN (IWLAN)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_NR | 12 | New Radio (NR)
**System capability**: SystemCapability.Telephony.CoreService| ## SignalInformation @@ -387,39 +505,40 @@ Enumerates the RATs. Defines the signal strength. | Attribute| Type| Description| -| ----------- | --------------------------- | ------------------ | -| signalType | [NetworkType](#NetworkType) | Signal strength type.| -| signalLevel | number | Signal strength level.| +| ----------- | --------------------------- | ------------------------------------------------------------ | +| signalType | [NetworkType](#NetworkType) | Signal strength type.
**System capability**: SystemCapability.Telephony.CoreService| +| signalLevel | number | Signal strength level.
**System capability**: SystemCapability.Telephony.CoreService| ## NetworkType -Network type. +Defines the network type. | Variable| Value| Description| | -------------------- | ---- | ------------------------------------------------------------ | -| NETWORK_TYPE_UNKNOWN | 0 | Unknown| -| NETWORK_TYPE_GSM | 1 | GSM network| -| NETWORK_TYPE_CDMA | 2 | CDMA network| -| NETWORK_TYPE_WCDMA | 3 | WCDMA network| -| NETWORK_TYPE_TDSCDMA | 4 | TD-SCDMA network| -| NETWORK_TYPE_LTE | 5 | LTE network| -| NETWORK_TYPE_NR | 6 | 5G NR network| +| NETWORK_TYPE_UNKNOWN | 0 | Unknown network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_GSM | 1 | GSM network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_CDMA | 2 | CDMA network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_WCDMA | 3 | WCDMA network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_TDSCDMA | 4 | TD-SCDMA network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_LTE | 5 | LTE network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_NR | 6 | 5G NR network
**System capability**: SystemCapability.Telephony.CoreService| ## NetworkState Defines the network registration status. | Variable| Type| Description| -| ----------------- | --------------------- | ------------------------------ | -| longOperatorName | string | Long carrier name of the registered network.| -| shortOperatorName | string | Short carrier name of the registered network.| -| plmnNumeric | string | PLMN code of the registered network.| -| isRoaming | boolean | Whether the user is roaming.| -| regState | [RegState](#RegState) | Network registration status of the device.| -| nsaState | [NsaState](#NsaState) | NSA network registration status of the device.| -| isCaActive | boolean | Whether carrier aggregation (CA) is supported.| -| isEmergency | boolean | Whether only emergency calls are allowed.| +| ----------------- | --------------------- | ------------------------------------------------------------ | +| longOperatorName | string | Long carrier name of the registered network.
**System capability**: SystemCapability.Telephony.CoreService| +| shortOperatorName | string | Short carrier name of the registered network.
**System capability**: SystemCapability.Telephony.CoreService| +| plmnNumeric | string | PLMN code of the registered network.
**System capability**: SystemCapability.Telephony.CoreService| +| isRoaming | boolean | Whether the user is roaming.
**System capability**: SystemCapability.Telephony.CoreService| +| regState | [RegState](#RegState) | Network registration status of the device.
**System capability**: SystemCapability.Telephony.CoreService| +| cfgTech8+ | [RadioTechnology](#RadioTechnology) | RAT of the device.
**System capability**: SystemCapability.Telephony.CoreService| +| nsaState | [NsaState](#NsaState) | NSA network registration status of the device.
**System capability**: SystemCapability.Telephony.CoreService| +| isCaActive | boolean | CA status.
**System capability**: SystemCapability.Telephony.CoreService| +| isEmergency | boolean | Whether only emergency calls are allowed.
**System capability**: SystemCapability.Telephony.CoreService| ## RegState @@ -427,11 +546,11 @@ Defines the network registration status. Defines the network registration status. | Variable| Value| Description| -| ----------------------------- | ---- | -------------------------- | -| REG_STATE_NO_SERVICE | 0 | The device cannot use any service.| -| REG_STATE_IN_SERVICE | 1 | The device can use services normally. | -| REG_STATE_EMERGENCY_CALL_ONLY | 2 | The device can use only the emergency call service.| -| REG_STATE_POWER_OFF | 3 | The cellular radio service is disabled.| +| ----------------------------- | ---- | ------------------------------------------------------------ | +| REG_STATE_NO_SERVICE | 0 | The device cannot use any service.
**System capability**: SystemCapability.Telephony.CoreService| +| REG_STATE_IN_SERVICE | 1 | The device can use services normally.
**System capability**: SystemCapability.Telephony.CoreService| +| REG_STATE_EMERGENCY_CALL_ONLY | 2 | The device can use only the emergency call service.
**System capability**: SystemCapability.Telephony.CoreService| +| REG_STATE_POWER_OFF | 3 | The cellular radio service is disabled.
**System capability**: SystemCapability.Telephony.CoreService| ## NsaState @@ -439,13 +558,13 @@ Defines the network registration status. Enumerates NSA network states. | Variable| Value| Description| -| -------------------------- | ---- | ---------------------------------------------------------- | -| NSA_STATE_NOT_SUPPORT | 1 | The device is in idle or connected state in an LTE cell that does not support NSA.| -| NSA_STATE_NO_DETECT | 2 | The device is in the idle state in an LTE cell that supports NSA but does not support NR coverage detection.| -| NSA_STATE_CONNECTED_DETECT | 3 | The device is connected to the LTE network in an LTE cell that supports NSA and NR coverage detection.| -| NSA_STATE_IDLE_DETECT | 4 | The device is in the idle state in an LTE cell that supports NSA and NR coverage detection.| -| NSA_STATE_DUAL_CONNECTED | 5 | The device is connected to the LTE/NR network in an LTE cell that supports NSA.| -| NSA_STATE_SA_ATTACHED | 6 | The device is idle or connected to the NG-RAN cell when being attached to the 5G Core.| +| -------------------------- | ---- | ------------------------------------------------------------ | +| NSA_STATE_NOT_SUPPORT | 1 | The device is in idle or connected state in an LTE cell that does not support NSA.
**System capability**: SystemCapability.Telephony.CoreService| +| NSA_STATE_NO_DETECT | 2 | The device is in the idle state in an LTE cell that supports NSA but does not support NR coverage detection.
**System capability**: SystemCapability.Telephony.CoreService| +| NSA_STATE_CONNECTED_DETECT | 3 | The device is connected to the LTE network in an LTE cell that supports NSA and NR coverage detection.
**System capability**: SystemCapability.Telephony.CoreService| +| NSA_STATE_IDLE_DETECT | 4 | The device is in the idle state in an LTE cell that supports NSA and NR coverage detection.
**System capability**: SystemCapability.Telephony.CoreService| +| NSA_STATE_DUAL_CONNECTED | 5 | The device is connected to the LTE/NR network in an LTE cell that supports NSA.
**System capability**: SystemCapability.Telephony.CoreService| +| NSA_STATE_SA_ATTACHED | 6 | The device is idle or connected to the NG-RAN cell when being attached to the 5G Core.
**System capability**: SystemCapability.Telephony.CoreService| ## NetworkSelectionMode @@ -453,7 +572,7 @@ Enumerates NSA network states. Enumerates network selection modes. | Variable| Value| Description| -| --------------------------- | ---- | -------------- | -| NETWORK_SELECTION_UNKNOWN | 0 | Unknown network selection mode.| -| NETWORK_SELECTION_AUTOMATIC | 1 | Automatic network selection mode.| -| NETWORK_SELECTION_MANUAL | 2 | Manual network selection mode.| +| --------------------------- | ---- | ------------------------------------------------------------ | +| NETWORK_SELECTION_UNKNOWN | 0 | Unknown network selection mode.
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_SELECTION_AUTOMATIC | 1 | Automatic network selection mode.
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_SELECTION_MANUAL | 2 | Manual network selection mode.
**System capability**: SystemCapability.Telephony.CoreService| diff --git a/en/application-dev/reference/apis/js-apis-sensor.md b/en/application-dev/reference/apis/js-apis-sensor.md index 440a79eab1934eba07f7ca2c90cdc20c96fafe62..8b9cf97f184547b9f5ce59da96bf85a6021bee55 100644 --- a/en/application-dev/reference/apis/js-apis-sensor.md +++ b/en/application-dev/reference/apis/js-apis-sensor.md @@ -1,6 +1,6 @@ # Sensor -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -1172,9 +1172,72 @@ Unsubscribes from sensor data changes. console.info("Succeeded in unsubscribing from acceleration sensor data."); } ); - ``` +## sensor.transformCoordinateSystem + +transformCoordinateSystem(inRotationVector: Array<number>, coordinates: CoordinatesOptions, callback: AsyncCallback<Array<number>>): void + +Rotates a rotation vector so that it can represent the coordinate system in different ways. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------------- | ----------------------------------------- | ---- | ---------------------- | + | inRotationVector | Array<number> | Yes| Rotation vector to rotate.| + | coordinates | [CoordinatesOptions](#coordinatesoptions) | Yes| Direction of the coordinate system.| + | callback | AsyncCallback<Array<number>> | Yes| Callback used to return the rotation vector after being rotated.| + +- Example + + ``` + sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) { + if (err) { + console.error("Operation failed. Error code: " + err.code + ", message: " + err.message); + return; + } + console.info("Operation successed. Data obtained: " + data.x); + for (var i=0; i < data.length; i++) { + console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); + } + }) + ``` + +## sensor.transformCoordinateSystem + +transformCoordinateSystem(inRotationVector: Array<number>, coordinates: CoordinatesOptions): Promise<Array<number>> + +Rotates a rotation vector so that it can represent the coordinate system in different ways. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------------- | ----------------------------------------- | ---- | ---------------- | + | inRotationVector | Array<number> | Yes| Rotation vector to rotate.| + | coordinates | [CoordinatesOptions](#coordinatesoptions) | Yes| Direction of the coordinate system.| + +- Return value + + | Type| Description| + | ---------------------------------- | ---------------------- | + | Promise<Array<number>> | Promise used to return the rotation vector after being converted.| + +- Example + + ``` + const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}); + promise.then((data) => { + console.info("Operation successed."); + for (var i=0; i < data.length; i++) { + console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); + } + }).catch((err) => { + console.info("Operation failed"); + }) + ``` + + + ## sensor.getGeomagneticField @@ -1207,7 +1270,7 @@ Obtains the geomagnetic field of a geographic location. This method uses a callb getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise<GeomagneticResponse> -Obtains the geomagnetic field of a geographic location. This method uses a callback to return the result. +Obtains the geomagnetic field of a geographic location. This method uses a promise to return the result. - Parameters | Name| Type| Mandatory| Description| @@ -1218,7 +1281,7 @@ Obtains the geomagnetic field of a geographic location. This method uses a callb - Return value | Type| Description| | -------- | -------- | - | Promise<[GeomagneticResponse](#geomagneticresponse)> | Callback used to return the geomagnetic field.| + | Promise<[GeomagneticResponse](#geomagneticresponse)> | Promise used to return the geomagnetic field.| - Example ``` @@ -1232,6 +1295,437 @@ Obtains the geomagnetic field of a geographic location. This method uses a callb }) ``` +## sensor.getAltitude + +getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback<number>): void + +Obtains the altitude at which the device is located based on the sea-level atmospheric pressure and the current atmospheric pressure. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | --------------- | --------------------------- | ---- | ------------------------------------- | + | seaPressure | number | Yes| Sea-level atmospheric pressure, in hPa.| + | currentPressure | number | Yes| Current atmospheric pressure at the altitude where the device is located, in hPa.| + | callback | AsyncCallback<number> | Yes| Callback used to return the altitude, in meters.| + +- Example + + ``` + sensor.getAltitude(0, 200, function(err, data) { + if (err) { + console.error( + "Operation failed. Error code: " + err.code + ", message: " + err.message); + return; + } + console.info("Successed to get getAltitude interface get data: " + data); + }); + ``` + +## sensor.getAltitude + +getAltitude(seaPressure: number, currentPressure: number): Promise<number> + +Obtains the altitude at which the device is located based on the sea-level atmospheric pressure and the current atmospheric pressure. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | --------------- | ------ | ---- | ------------------------------------- | + | seaPressure | number | Yes| Sea-level atmospheric pressure, in hPa.| + | currentPressure | number | Yes| Atmospheric pressure at the altitude where the device is located, in hPa.| + +- Return value + + | Type| Description| + | --------------------- | ------------------------------------ | + | Promise<number> | Promise used to return the altitude, in meters.| + +- Example + + ``` + const promise = sensor.getAltitude(0, 200); + promise.then((data) => { + console.info(' sensor_getAltitude_Promise success', data); + }).catch((err) => { + console.error("Operation failed"); + }) + ``` + + +## sensor.getGeomagneticDip + +getGeomagneticDip(inclinationMatrix: Array<number>, callback: AsyncCallback<number>): void + +Obtains the magnetic dip based on the inclination matrix. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----------------- | --------------------------- | ---- | ---------------------------- | + | inclinationMatrix | Array<number> | Yes| Inclination matrix.| + | callback | AsyncCallback<number> | Yes| Callback used to return the magnetic dip, in radians.| + +- Example + + ``` + sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { + if (err) { + console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info(Successed to get getGeomagneticDip interface get data: " + data); + }) + ``` + +## sensor.getGeomagneticDip + +getGeomagneticDip(inclinationMatrix: Array<number>): Promise<number> + +Obtains the magnetic dip based on the inclination matrix. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----------------- | ------------------- | ---- | -------------- | + | inclinationMatrix | Array<number> | Yes| Inclination matrix.| + +- Return value + + | Type| Description| + | --------------------- | ---------------------------- | + | Promise<number> | Promise used to return the magnetic dip, in radians.| + +- Example + + ``` + const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]); + promise.then((data) => { + console.info(' getGeomagneticDip_promise successed', data); + }).catch((err) => { + console.error("Operation failed"); + }) + ``` + +## sensor. getAngleModify + +getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>, callback: AsyncCallback<Array<number>>): void + +Obtains the angle change between two rotation matrices. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | --------------------- | ---------------------------------------- | ---- | --------------------------------- | + | currentRotationMatrix | Array<number> | Yes| Current rotation matrix.| + | preRotationMatrix | Array<number> | Yes| The other rotation matrix.| + | callback | AsyncCallback<Array<number>> | Yes| Callback used to return the angle change around the z, x, and y axes.| + +- Example + + ``` + sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) { + if (err) { + console.error(LABEL + 'Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info("SensorJsAPI--->Successed to get getAngleModifiy interface get data: " + data.x); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }) + ``` + + +## sensor. getAngleModify + +getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>): Promise<Array<number>> + +Obtains the angle change between two rotation matrices. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | --------------------- | ------------------- | ---- | ------------------ | + | currentRotationMatrix | Array<number> | Yes| Current rotation matrix.| + | preRotationMatrix | Array<number> | Yes| The other rotation matrix.| + +- Return value + + | Type| Description| + | ---------------------------------- | --------------------------------- | + | Promise<Array<number>> | Promise used to return the angle change around the z, x, and y axes.| + +- Example + + ``` + const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]); + promise.then((data) => { + console.info(LABEL + 'getAngleModifiy_promise success'); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }).catch((reason) => { + console.info(LABEL + "promise::catch", reason); + }) + ``` + + +## sensor.createRotationMatrix + +createRotationMatrix(rotationVector: Array<number>, callback: AsyncCallback<Array<number>>): void + +Converts a rotation vector into a rotation matrix. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ---------------------------------------- | ---- | -------------- | + | rotationVector | Array<number> | Yes| Rotation vector to convert.| + | callback | AsyncCallback<Array<number>> | Yes| Callback used to return the rotation matrix.| + +- Example + + ``` + sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { + if (err) { + console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }) + ``` + + +## sensor.createRotationMatrix + +createRotationMatrix(rotationVector: Array<number>): Promise<Array<number>> + +Converts a rotation vector into a rotation matrix. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ------------------- | ---- | -------------- | + | rotationVector | Array<number> | Yes| Rotation vector to convert.| + +- Return value + + | Type| Description| + | ---------------------------------- | -------------- | + | Promise<Array<number>> | Promise used to return the rotation matrix.| + +- Example + + ``` + const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); + promise.then((data) => { + console.info(LABEL + 'createRotationMatrix_promise success'); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }).catch((reason) => { + console.info(LABEL + "promise::catch", reason); + }) + ``` + + +## sensor.createQuaternion + +createQuaternion(rotationVector: Array<number>, callback: AsyncCallback<Array<number>>): void + +Converts a rotation vector into a quaternion. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ---------------------------------------- | ---- | -------------- | + | rotationVector | Array<number> | Yes| Rotation vector to convert.| + | callback | AsyncCallback<Array<number>> | Yes| Callback used to return the quaternion.| + +- Example + + ``` + sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { + if (err) { + console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info("SensorJsAPI--->Successed to get createQuaternion interface get data: " + data.x); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }) + ``` + + +## sensor.createQuaternion + +createQuaternion(rotationVector: Array<number>): Promise<Array<number>> + +Converts a rotation vector into a quaternion. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ------------------- | ---- | -------------- | + | rotationVector | Array<number> | Yes| Rotation vector to convert.| + +- Return value + + | Type| Description| + | ---------------------------------- | ------------ | + | Promise<Array<number>> | Promise used to return the quaternion.| + +- Example + + ``` + const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]); + promise.then((data) => { + console.info('createQuaternion_promise successed'); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }).catch((err) => { + console.info('promise failed'); + }) + ``` + + +## sensor.getDirection + +getDirection(rotationMatrix: Array<number>, callback: AsyncCallback<Array<number>>): void + +Obtains the device direction based on the rotation matrix. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ---------------------------------------- | ---- | --------------------------------- | + | rotationMatrix | Array<number> | Yes| Rotation matrix.| + | callback | AsyncCallback<Array<number>> | Yes| Callback used to return the rotation angle around the z, x, and y axes.| + +- Example + + ``` + sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { + if (err) { + console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info(LABEL + "SensorJsAPI--->Successed to get getDirection interface get data: " + data.x); + for (var i = 1; i < data.length; i++) { + console.info(TAG +"sensor_getDirection_callback" + data[i]); + } + }) + ``` + + +## sensor.getDirection + +getDirection(rotationMatrix: Array<number>): Promise<Array<number>> + +Obtains the device direction based on the rotation matrix. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ------------------- | ---- | -------------- | + | rotationMatrix | Array<number> | Yes| Rotation matrix.| + +- Return value + + | Type| Description| + | ---------------------------------- | --------------------------------- | + | Promise<Array<number>> | Promise used to return the rotation angle around the z, x, and y axes.| + +- Example + + ``` + const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]); + promise.then((data) => { + console.info(' sensor_getAltitude_Promise success', data.x); + for (var i = 1; i < data.length; i++) { + console.info(TAG +"sensor_getDirection_promise" + data[i]); + } + }).catch((err) => { + console.info('promise failed'); + }) + ``` + + +## sensor.createRotationMatrix + +createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>, callback: AsyncCallback<RotationMatrixResponse>): void + +Creates a rotation matrix based on the gravity vector and geomagnetic vector. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----------- | ------------------------------------------------------------ | ---- | -------------- | + | gravity | Array<number> | Yes| Gravity vector.| + | geomagnetic | Array<number> | Yes| Geomagnetic vector.| + | callback | AsyncCallback<[RotationMatrixResponse](#rotationmatrixresponse)> | Yes| Callback used to return the rotation matrix.| + +- Example + + ``` + sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) { + if (err) { + console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]) + } + }) + ``` + + +## sensor.createRotationMatrix + +createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>,): Promise<RotationMatrixResponse> + +Creates a rotation matrix based on the gravity vector and geomagnetic vector. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----------- | ------------------- | ---- | -------------- | + | gravity | Array<number> | Yes| Gravity vector.| + | geomagnetic | Array<number> | Yes| Geomagnetic vector.| + +- Return value + + | Type| Description| + | ------------------------------------------------------------ | -------------- | + | Promise<[RotationMatrixResponse](#rotationmatrixresponse)> | Promise used to return the rotation matrix.| + +- Example + + ``` + const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); + promise.then((data) => { + console.info(LABEL + 'createRotationMatrix_promise successed'); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }).catch((err) => { + console.info(LABEL + 'promise failed'); + }) + ``` + ## SensorType @@ -1519,6 +2013,25 @@ Describes the sensor data reporting frequency. | -------- | -------- | -------- | | interval | number | Frequency at which a sensor reports data. The default value is 200,000,000 ns.| +## RotationMatrixResponse + +Describes the response for setting the rotation matrix. + +| Name| Type| Readable| Writable| Description| +| ----------- | ------------------- | ---- | ---- | ---------- | +| rotation | Array<number> | Yes| Yes| Rotation matrix.| +| inclination | Array<number> | Yes| Yes| Inclination matrix.| + + +## CoordinatesOptions + +Describes the coordinate options. + +| Name| Type| Readable| Writable| Description| +| ---- | -------- | ---- | ---- | ----------- | +| x | number | Yes| Yes| X coordinate direction.| +| y | number | Yes| Yes| Y coordinate direction.| + ## GeomagneticResponse diff --git a/en/application-dev/reference/apis/js-apis-service-extension-context.md b/en/application-dev/reference/apis/js-apis-service-extension-context.md index de067acf57d05f2a2c121fc7423877759e5efe82..1c1d2b615a5b9344fab4247aa3b3e84b963c3a0b 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-service-extension-context.md @@ -16,10 +16,14 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; Starts an ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to start, such as the ability name and bundle name.| + | want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to start, such as the ability name and bundle name.| | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the method is successfully called.| - Example @@ -40,10 +44,14 @@ startAbility(want: Want): Promise<void>; Starts an ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to start, such as the ability name and bundle name.| + | want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to start, such as the ability name and bundle name.| - Return value | Type| Description| @@ -70,6 +78,10 @@ terminateSelf(callback: AsyncCallback<void>): void; Terminates this ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -89,6 +101,10 @@ terminateSelf(): Promise<void>; Terminates this ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Return value | Type| Description| | -------- | -------- | @@ -110,10 +126,14 @@ connectAbility(want: Want, options: ConnectOptions): number; Connects this ability to a Service ability. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to connect to, such as the ability name and bundle name.| + | want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to connect to, such as the ability name and bundle name.| | options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.| - Return value @@ -142,6 +162,10 @@ disconnectAbility(connection: number, callback:AsyncCallback<void>): void; Disconnects this ability from the Service ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -162,6 +186,10 @@ disconnectAbility(connection: number): Promise<void>; Disconnects this ability from the Service ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -171,7 +199,7 @@ Disconnects this ability from the Service ability. This method uses a promise to | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result indicating whether the method is successfully called.| - + - Example ``` this.context.disconnectAbility(connection).then((data) => { // connection is the return value of connectAbility. @@ -188,6 +216,6 @@ Defines the **ConnectOptions** data structure. | Name| Description| | -------- | -------- | -| onConnect(elementName:ElementName, remote:IRemoteObject) | Called when this ability is connected to a Service ability.| -| onDisconnect(elementName:ElementName) | Called when the peer service is abnormal or killed.| -| onFailed(code: number) | Called when the connection fails.| +| onConnect(elementName:ElementName, remote:IRemoteObject) | Called when this ability is connected to a Service ability.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| +| onDisconnect(elementName:ElementName) | Called when the peer service is abnormal or killed.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| +| onFailed(code: number) | Called when the connection fails.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| diff --git a/en/application-dev/reference/apis/js-apis-service-extension.md b/en/application-dev/reference/apis/js-apis-service-extension.md index 3696ec05ec8d97e5f0bb4a7b600b1df4d8b75bd7..0a6b357e97fad6ee1474e6925067361d78e0c6a1 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension.md +++ b/en/application-dev/reference/apis/js-apis-service-extension.md @@ -32,6 +32,10 @@ onCreate(want: Want): void; Called when an extension is created to initialize the service logic. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -53,6 +57,10 @@ onDestroy(): void; Called when this extension is destroyed to clear resources. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Example ``` class ServiceExt extends ServiceExtension { @@ -69,6 +77,10 @@ onRequest(want: Want, startId: number): void; Called after **onCreate** is invoked when an ability is started by calling **startAbility**. The value of **startId** is incremented for each ability that is started. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -91,6 +103,10 @@ onConnect(want: Want): rpc.RemoteObject; Called after **onCreate** is invoked when an ability is started by calling **connectAbility**. A **RemoteObject** object is returned for communication with the client. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -126,6 +142,10 @@ onDisconnect(want: Want): void; Called when the ability is disconnected. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index 65fcef6b4fb590a5ead28ede1f2f502f7bd2b513..b3cca70e284d04d0c3f4ad09dae27a42de549252 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -16,6 +16,8 @@ createMessage\(pdu: Array, specification: string, callback: AsyncCallba Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. This function uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Telephony.SmsMms + **Parameters** | Name| Type| Mandatory| Description| @@ -42,6 +44,8 @@ createMessage\(pdu: Array, specification: string\): Promise\): void Obtains the default slot of the SIM card used to send SMS messages. This function uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Telephony.SmsMms + **Parameters** | Name| Type| Mandatory| Description| | -------- | --------------------------- | ---- | ---------------------------------------- | -| callback | AsyncCallback<number> | Yes| Callback used to return the result,
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback<number> | Yes| Callback used to return the result.
- **0**: slot 1
- **1**: slot 2| **Example** @@ -129,6 +137,8 @@ getDefaultSmsSlotId\(\): Promise Obtains the default slot of the SIM card used to send SMS messages. This function uses a promise to return the result. +**System capability**: SystemCapability.Telephony.SmsMms + **Return value** | Type| Description| @@ -153,7 +163,9 @@ setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback\): Sets the short message service center (SMSC) address. This function uses an asynchronous callback to return the result. -Before using this API, you must declare the **ohos.permission.SET\_TELEPHONY\_STATE** permission. +**Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission) + +**System capability**: SystemCapability.Telephony.SmsMms **Parameters** @@ -180,7 +192,9 @@ setSmscAddr\(slotId: number, smscAddr: string\): Promise Sets the SMSC address. This function uses a promise to return the result. -Before using this API, you must declare the **ohos.permission.SET\_TELEPHONY\_STATE** permission. +**Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission) + +**System capability**: SystemCapability.Telephony.SmsMms **Parameters** @@ -215,7 +229,9 @@ getSmscAddr\(slotId: number, callback: AsyncCallback\): void Obtains the SMSC address. This function uses an asynchronous callback to return the result. -Before using this API, you must declare the **ohos.permission.GET\_TELEPHONY\_STATE** permission. +**Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission) + +**System capability**: SystemCapability.Telephony.SmsMms **Parameters** @@ -240,7 +256,9 @@ getSmscAddr\(slotId: number\): Promise Obtains the SMSC address. This function uses a promise to return the result. -Before using this API, you must declare the **ohos.permission.GET\_TELEPHONY\_STATE** permission. +**Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission) + +**System capability**: SystemCapability.Telephony.SmsMms **Parameters** @@ -271,6 +289,8 @@ promise.then(data => { Defines an SMS message instance. +**System capability**: SystemCapability.Telephony.SmsMms + | Variable| Type| Description| | ------------------------ | --------------------------------------- | ------------------------------------------------------------ | | emailAddress | string | Email address.| @@ -295,12 +315,12 @@ Defines an SMS message instance. Enumerates SMS message types. | Variable| Value| Description| -| ---------------- | ---- | ---------------------------------------- | -| UNKNOWN | 0 | Unknown type.| -| INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received.| -| OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card.| -| SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card.| -| FORWARD_MESSAGE | 4 | Message to be forwarded to another device.| +| ---------------- | ---- | ------------------------------------------------------------ | +| UNKNOWN | 0 | Unknown type.
**System capability**: SystemCapability.Telephony.SmsMms| +| INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received.
**System capability**: SystemCapability.Telephony.SmsMms| +| OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card.
**System capability**: SystemCapability.Telephony.SmsMms| +| SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card.
**System capability**: SystemCapability.Telephony.SmsMms| +| FORWARD_MESSAGE | 4 | Message to be forwarded to another device.
**System capability**: SystemCapability.Telephony.SmsMms| ## SendMessageOptions @@ -309,11 +329,13 @@ Provides the options (including callbacks) for sending an SMS message. For example, you can specify the SMS message type by the optional parameter **content**. +**System capability**: SystemCapability.Telephony.SmsMms + | Name| Type| Mandatory| Description| | ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | slotId | number | Yes| Slot ID of the SIM card used for sending SMS messages:
- **0**: slot 1
- **1**: slot 2| | destinationHost | string | Yes| Destination address of the SMS message.| -| content | string \| Array<number> | Yes| SMS message type. If the content is comprised of character strings, the SMS message is a text message. If the content is comprised of byte arrays, the SMS message is a data message.| +| content | string \| Array<number> | Yes| SMS message type. If the content is composed of character strings, the SMS message is a text message. If the content is composed of byte arrays, the SMS message is a data message.| | serviceCenter | string | No| SMSC address. By default, the SMSC address in the SIM card is used.| | destinationPort | number | No| Destination port of the SMS message. This parameter is mandatory only for a data message. Otherwise, it is optional.| | sendCallback | AsyncCallback<[ISendShortMessageCallback](#ISendShortMessageCallback)> | No| Callback used to return the SMS message sending result. For details, see [ISendShortMessageCallback](#ISendShortMessageCallback).| @@ -322,7 +344,9 @@ For example, you can specify the SMS message type by the optional parameter **co ## ISendShortMessageCallback -Provides the callback for the SMS message delivery report. It consists of three parts: SMS message sending result, URI for storing the sent SMS message, and whether the SMS message is the last part of a long SMS message. +Provides the callback for the SMS message sending result. It consists of three parts: SMS message sending result, URI for storing the sent SMS message, and whether the SMS message is the last part of a long SMS message. + +**System capability**: SystemCapability.Telephony.SmsMms | Name| Type| Mandatory| Description| | ---------- | ------------------------------- | ---- | ------------------------------------------------------------ | @@ -333,7 +357,9 @@ Provides the callback for the SMS message delivery report. It consists of three ## IDeliveryShortMessageCallback -Provides the callback for the SMS message delivery report. Return the SMS delivery report. +Provides the callback for the SMS message sending result. Return the SMS delivery report. + +**System capability**: SystemCapability.Telephony.SmsMms | Name| Type| Mandatory| Description| | ------ | ------------------- | ---- | -------------- | @@ -344,6 +370,8 @@ Provides the callback for the SMS message delivery report. Return the SMS delive Enumerates SMS message sending results. +**System capability**: SystemCapability.Telephony.SmsMms + | Name| Value| Description| | ------------------------------------ | ---- | ------------------------------------------------------ | | SEND_SMS_SUCCESS | 0 | SMS message sent successfully.| diff --git a/en/application-dev/reference/apis/js-apis-stack.md b/en/application-dev/reference/apis/js-apis-stack.md new file mode 100644 index 0000000000000000000000000000000000000000..2cec7c7cc3489abc2cd0316c837e1a3403844d83 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-stack.md @@ -0,0 +1,236 @@ +# Linear Container Stack + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import Stack from '@ohos.util.Stack' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + + +## Stack + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a stack (called container later).| + + +### constructor + +constructor() + +A constructor used to create a **Stack** instance. + +**Example** + +``` +let stack = new Stack(); +``` + + +### push + +push(item: T): T + +Adds an entry at the top of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| item | T | Yes| Element to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Element added.| + +**Example** + +``` +let stack = new Stack(); +let result = stack.push("a"); +let result1 = stack.push(1); +let b = [1, 2, 3]; +stack.push(b); +let c = {name : "lala", age : "13"}; +let result3 = stack.push(c); +``` + +### pop + +pop(): T + +Removes the top entry from this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(2); +stack.push(4); +let result = stack.pop(); +``` + +### peek + +peek(): T + +Obtains the top entry of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry obtained.| + +**Example** + +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(2); +let result = stack.peek(); +``` + +### locate + +locate(element: T): number + +Obtains the index of the first occurrence of the specified entry in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + +**Example** + +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(2); +let result = stack.locate(2); +``` + +### forEach +forEach(callbackfn: (value: T, index?: number, stack?: Stack<T>) => void, +thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| stack | Stack<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(4); +stack.forEach((value, index) => { + console.log(value, index); +}); +``` + +### isEmpty +isEmpty(): boolean + +Checks whether this container is empty (contains no entries). + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(4); +let result = stack.isEmpty(); +``` + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(4); + +// Method 1: +for (let item of stack) { + console.log(item); +} + +// Method 2: +let iter = stack[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-telephony-data.md b/en/application-dev/reference/apis/js-apis-telephony-data.md new file mode 100644 index 0000000000000000000000000000000000000000..8cb2951bda1838891021ab653db926958859786c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-telephony-data.md @@ -0,0 +1,289 @@ +# Cellular Data + +>**NOTE** +> +>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +``` +import data from '@ohos.telephony.data'; +``` + +## data.getDefaultCellularDataSlotId + +getDefaultCellularDataSlotId(callback: AsyncCallback\): void + +Obtains the default SIM card used for mobile data. This function uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ----------------------- | ---- | ------------------------------------------ | +| callback | AsyncCallback\ | Yes| Callback used to return the result.
**0**: slot 1
**1**: slot 2| + +**Example** + +``` +data.getDefaultCellularDataSlotId((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.getDefaultCellularDataSlotId + +getDefaultCellularDataSlotId(): Promise\ + +Obtains the default SIM card used for mobile data. This function uses a promise to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Return value** + +| Type| Description| +| ----------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result, wherein:
**0**: slot 1
**1**: slot 2| + +**Example** + +``` +let promise = data.getDefaultCellularDataSlotId(); +promise.then((data) => { + console.log(`test success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`test fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.getCellularDataFlowType + +getCellularDataFlowType(callback: AsyncCallback\): void + +Obtains the cellular data flow type, which can be uplink or downlink. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ---------------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\<[DataFlowType](#DataFlowType)\> | Yes| Callback used to return the result.| + +**Example** + +``` +data.getCellularDataFlowType((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.getCellularDataFlowType + +getCellularDataFlowType(): Promise\ + +Obtains the cellular data flow type, which can be uplink or downlink. This function uses a promise to return the result. + +**System capability**: SystemCapability.Telephony.CellularData + +**Return value** + +| Type| Description| +| ---------------------------------------- | ----------------------------------------------- | +| Promise\<[DataFlowType](#DataFlowType)\> | Promise used to return the result. | + +**Example** + +``` +let promise = data.getCellularDataFlowType(); +promise.then((data) => { + console.log(`test success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`test fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.getCellularDataState + +getCellularDataState(callback: AsyncCallback\): void + +Obtains the connection status of the packet switched (PS) domain. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------ | ---- | ---------- | +| callback | AsyncCallback\<[DataConnectState](#DataConnectState)\> | Yes| Callback used to return the result.| + +**Example** + +``` +data.getCellularDataState((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.getCellularDataState + +getCellularDataState(): Promise\ + +Obtains the connection status of the PS domain. This function uses a promise to return the result. + +**System capability**: SystemCapability.Telephony.CellularData + +**Return value** + +| Type| Description| +| ------------------------------------------------ | ------------------------------------- | +| Promise\<[DataConnectState](#DataConnectState)\> | Promise used to return the result.| + +**Example** + +``` +let promise = data.getCellularDataState(); +promise.then((data) => { + console.log(`test success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`test fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.isCellularDataEnabled + +isCellularDataEnabled(callback: AsyncCallback\): void + +Checks whether the cellular data service is enabled. This function uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\ | Yes| Callback used to return the result.
**true**: The cellular data service is enabled.
**false**: The cellular data service is disabled.| + +**Example** + +``` +data.isCellularDataEnabled((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.isCellularDataEnabled + +isCellularDataEnabled(): Promise\ + +Checks whether the cellular data service is enabled. This function uses a promise to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Return value** + +| Type| Description| +| ------------------ | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result, wherein:
**true**: The cellular data service is enabled.
**false**: The cellular data service is disabled.| + +**Example** + +``` +let promise = data.isCellularDataEnabled(); +promise.then((data) => { + console.log(`test success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`test fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.isCellularDataRoamingEnabled + +isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\): void + +Checks whether roaming is enabled for the cellular data service. This function uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------ | ---- | ------------------------------------------------------------ | +| slotId | number | Yes| Card slot ID. The options are as follows:
**0**: slot 1
**1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result.
**true**: Roaming is enabled for the cellular data service.
**false**: Roaming is disabled for the cellular data service.| + +**Example** + +``` +data.isCellularDataRoamingEnabled(0,(err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.isCellularDataRoamingEnabled + +isCellularDataRoamingEnabled(slotId: number): Promise\ + +Checks whether roaming is enabled for the cellular data service. This method uses a promise to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | ---------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
**0**: slot 1
**1**: slot 2| + +**Return value** + +| Type| Description| +| ------------------ | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result, wherein:
**true**: Roaming is enabled for the cellular data service.
**false**: Roaming is disabled for the cellular data service.| + +**Example** + +``` +let promise = data.isCellularDataRoamingEnabled(0); +promise.then((data) => { + console.log(`test success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`test fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## DataFlowType + + Defines the cellular data flow type. + +| Name| Value| Description| +| ------ | ---------------------- | ------------------------------------------------------------ | +| 0 | DATA_FLOW_TYPE_NONE | No uplink or downlink data is available.
**System capability**: SystemCapability.Telephony.CellularData| +| 1 | DATA_FLOW_TYPE_DOWN | Only the downlink data is available.
**System capability**: SystemCapability.Telephony.CellularData| +| 2 | DATA_FLOW_TYPE_UP | Only the uplink data is available.
**System capability**: SystemCapability.Telephony.CellularData| +| 3 | DATA_FLOW_TYPE_UP_DOWN | Both uplink data and downlink data are available.
**System capability**: SystemCapability.Telephony.CellularData| +| 4 | DATA_FLOW_TYPE_DORMANT | No uplink or downlink data is available because the lower-layer link is in the dormant state.
**System capability**: SystemCapability.Telephony.CellularData| + +## DataConnectState + + Describes the connection status of a cellular data link. + +| Name| Value| Description| +| ------ | ----------------------- | ------------------------------------------------------------ | +| -1 | DATA_STATE_UNKNOWN| The status of the cellular data link is unknown.
**System capability**: SystemCapability.Telephony.CellularData| +| 0 | DATA_STATE_DISCONNECTED | The cellular data link is disconnected.
**System capability**: SystemCapability.Telephony.CellularData| +| 1 | DATA_STATE_CONNECTING | The cellular data link is being connected.
**System capability**: SystemCapability.Telephony.CellularData| +| 2 | DATA_STATE_CONNECTED | The cellular data link is connected.
**System capability**: SystemCapability.Telephony.CellularData| +| 3 | DATA_STATE_SUSPENDED | The cellular data link is suspended.
**System capability**: SystemCapability.Telephony.CellularData| diff --git a/en/application-dev/reference/apis/js-apis-thermal.md b/en/application-dev/reference/apis/js-apis-thermal.md new file mode 100644 index 0000000000000000000000000000000000000000..9c534aae3b5dee1be7890153cd9eba768d770a64 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-thermal.md @@ -0,0 +1,98 @@ +# Thermal Management + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import thermal from '@ohos.thermal'; +``` + + +## ThermalLevel + +Represents the thermal level. + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| COOL | 0 | The device is cool, and services are not restricted.| +| NORMAL | 1 | The device is operational but is not cool. You need to pay attention to its heating.| +| WARM | 2 | The device is warm. You need to stop or delay some imperceptible services.| +| HOT | 3 | The device is heating up. You need to stop all imperceptible services and downgrade or reduce the load of other services.| +| OVERHEATED | 4 | The device is overheated. You need to stop all imperceptible services and downgrade or reduce the load of major services.| +| WARNING | 5 | The device is overheated and is about to enter the emergency state. You need to stop all imperceptible services and downgrade major services to the maximum extent.| +| EMERGENCY | 6 | The device has entered the emergency state. You need to stop all services except those for the emergency help purposes.| + + +## thermal.subscribeThermalLevel + +subscribeThermalLevel(callback: AsyncCallback<ThermalLevel>): void + +Subscribes to thermal level changes. + +**System Capabilities** + +SystemCapability.PowerManager.ThermalManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<ThermalLevel> | Yes| Callback used to obtain the return value.
Return value: thermal level| + +**Example** + +``` +thermal.subscribeThermalLevel((lev) => { + console.info("Thermal level is: " + lev); +}) +``` + +## thermal.unsubscribeThermalLevel + +unsubscribeThermalLevel(callback?: AsyncCallback): void + +Unsubscribes from thermal level changes. + +**System Capabilities** + +SystemCapability.PowerManager.ThermalManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | No| Callback without a return value.| + +**Example** + +``` +thermal.unsubscribeThermalLevel(() => { + console.info("Unsubscribe completed."); +}); +``` + +## thermal.getThermalLevel + +getThermalLevel(): ThermalLevel + +Obtains the current thermal level. + +**System Capabilities** + +SystemCapability.PowerManager.ThermalManager + +**Return value** + +| Type| Description| +| -------- | -------- | +| ThermalLevel | Thermal level obtained.| + +**Example** + +``` +var lev = thermal.getThermalLevel(); +console.info("Thermal level is: " + lev); +``` diff --git a/en/application-dev/reference/apis/js-apis-treemap.md b/en/application-dev/reference/apis/js-apis-treemap.md new file mode 100644 index 0000000000000000000000000000000000000000..047a66fbf44e97d3c45ac04d04ba5be64b629fd1 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-treemap.md @@ -0,0 +1,518 @@ +# Nonlinear Container TreeMap + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import TreeMap from '@ohos.util.TreeMap' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## TreeMap + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a tree map (called container later).| + + +### constructor + +constructor(comparator?:(firstValue: K, secondValue: K) => boolean) + +A constructor used to create a **TreeMap** instance. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| comparator | function | No| Custom comparator.| + +**Example** + +``` +let treeMap = new TreeMap(); +``` + + +### isEmpty + +isEmpty(): boolean; + +Checks whether this container is empty (contains no entry). + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +const treeMap = new TreeMap(); +let result = treeMap.isEmpty(); +``` + + +### hasKey + +hasKey(key: K): boolean; + +Checks whether this container has the specified key. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified key is contained; returns **false** otherwise.| + +**Example** + +``` +let treeMap = new TreeMap(); +let result = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +let result1 = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + + +### hasValue + +hasValue(value: V): boolean + +Checks whether this container has the specified value. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | V | Yes| Value to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified value is contained; returns **false** otherwise.| + +**Example** + +``` +let treeMap = new TreeMap(); +let result = treeMap.hasValue(123); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +let result1 = treeMap.hasValue(123); +``` + + +### get + +get(key: K): V + +Obtains the value of the specified key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| V | Value of the key.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let result = treeMap.get("sdfs"); +``` + + +### getFirstKey + +getFirstKey(): K; + +Obtains the first key in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| K | Key obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let result = treeMap.getFirstKey(); +``` + + +### getLastKey + +getLastKey(): K; + +Obtains the last key in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| K | Key obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let result = treeMap.getLastKey(); +``` + + +### setAll + +setAll(map: TreeMap): void + +Adds all entries in a **TreeMap** instance to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| map | TreeMap | Yes| **TreeMap** instance whose entries are to be added to the current container.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let map = new TreeMap(); +treeMap.setAll(map); +``` + + +### set +set(key: K, value: V): Object + +Adds an entry to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of the entry to add.| +| value | V | Yes| Value of the entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Object | Container that contains the new entry.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +``` + + +### remove + +remove(key: K): V; + +Removes the entry with the specified key from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of the entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| V | Value of the entry removed.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +treeMap.remove("sdfs"); +``` + + +### getLowerKey + +getLowerKey(key: K): K + +Obtains the key that is placed in front of the input key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Input key.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| K | Key obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +treeMap.set("zdfgsd", 356); +let result = treeMap.getLowerKey("sdfs"); +``` + + +### getHigherKey + +getHigherKey(key: K): K + +Obtains the key that is placed next to the input key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Input key.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| K | Key obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +treeMap.set("zdfgsd", 356); +let result = treeMap.getHigherKey("sdfs"); +``` + +### replace +replace(key: K, newValue: V): boolean + +Replaces an entry in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of the entry to replace.| +| newValue | V | Yes| New value of the entry.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is replaced successfully; returns **false** otherwise.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("sdfs", 123); +let result = treeMap.replace("sdfs", 357); +``` + + +### clear + +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +treeMap.clear(); +``` + + +### keys + +keys(): IterableIterator<K> + +Obtains an iterator that contains all the keys in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<K> | Iterator obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let iter = treeMap.keys(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` + + +### values + +values(): IterableIterator<V> + +Obtains an iterator that contains all the values in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<V> | Iterator obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let iter = treeMap.values(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` + + +### forEach + +forEach(callbackfn: (value: V, key?: K, map?: TreeMap) => void, thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | V | Yes| Value of the entry that is currently traversed.| +| key | K | Yes| Key of the entry that is currently traversed.| +| map | TreeMap | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("sdfs", 123); +treeMap.set("dfsghsf", 357); +treeMap.forEach((value, key) => { + console.log(value, key); +}); +``` + + +### entries + +entries(): IterableIterator<[K, V]> + +Obtains an iterator that contains all the entries in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<[K, V]> | Iterator obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let iter = treeMap.entries(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp[0]); + console.log(temp[1]); + temp = iter.next().value; +} +``` + + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<[K, V]>; + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** +| Type| Description| +| -------- | -------- | +| IterableIterator<[K, V]> | Iterator obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); + +// Method 1: +for (let item of treeMap) { + console.log("key: " + item[0]); + console.log("value: " + item[1]); +} + +// Method 2: +let iter = treeMap[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp[0]); + console.log(temp[1]); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-treeset.md b/en/application-dev/reference/apis/js-apis-treeset.md new file mode 100644 index 0000000000000000000000000000000000000000..bc937047ab2edb71d6c27322ba93f785632e9079 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-treeset.md @@ -0,0 +1,428 @@ +# Nonlinear Container TreeSet + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import TreeSet from '@ohos.util.TreeSet' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## TreeSet + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a tree set (called container later).| + + +### constructor + +constructor(comparator?:(firstValue: T, secondValue: T) => boolean) + +A constructor used to create a **TreeSet** instance. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| comparator | function | No| Custom comparator.| + +**Example** + +``` +let treeSet = new TreeSet(); +``` + + +### isEmpty + +isEmpty(): boolean + +Checks whether this container is empty (contains no entry). + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +const treeSet = new TreeSet(); +let result = treeSet.isEmpty(); +``` + + +### has + +has(value: T): boolean + +Checks whether this container has the specified value. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified value is contained; returns **false** otherwise.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.has(123); +treeSet.add(123); +let result1 = treeSet.has(123); +``` + + +### getFirstValue + +getFirstValue(): T + +Obtains the value of the first entry in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let result = treeSet.getFirstValue(); +``` + + +### getLastValue + +getLastValue(): T + +Obtains the value of the last entry in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let result = treeSet.getLastValue(); +``` + + +### add +add(value: T): boolean + +Adds an entry to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + +``` +let treeSet = new TreeSet(); +let result = treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + + +### remove + +remove(value: T): boolean; + +Removes the entry with the specified key from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Key of the entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let result = treeSet.remove("sdfs"); +``` + + +### getLowerValue + +getLowerValue(key: T): T + +Obtains the value that is placed in front of the input key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | T | Yes| Input key.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +treeSet.add("zdfgsd"); +let result = treeSet.getLowerValue("sdfs"); +``` + + +### getHigherValue + +getHigherValue(key: T): T + +Obtains the value that is placed next to the input key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | T | Yes| Input key.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +treeSet.add("zdfgsd"); +let result = treeSet.getHigherValue("sdfs"); +``` + + +### popFirst + +popFirst(): T + +Removes the first entry in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Return value** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let result = treeSet.popFirst(); +``` + + +### popLast + +popLast(): T + +Removes the last entry in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Return value** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let result = treeSet.popLast(); +``` + + +### clear + +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +treeSet.clear(); +``` + + +### values + +values(): IterableIterator<T> + +Obtains an iterator that contains all the values in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let iter = treeSet.values(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` + + +### forEach + +forEach(callbackfn: (value: T, key?: T, set?: TreeSet<T>) => void, thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| key | T | No| Key of the entry that is currently traversed (same as **value**).| +| set | TreeSet<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("sdfs"); +treeSet.add("dfsghsf"); +treeSet.forEach((value, key) => { + console.log(value, key) +}); +``` + + +### entries + +entries(): IterableIterator<[T, T]> + +Obtains an iterator that contains all the entries in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<[T, T]> | Iterator obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let iter = treeSet.entries(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp[0]); + console.log(temp[1]); + temp = iter.next().value; +} +``` + + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); + +// Method 1: +for (let item of treeSet) { + console.log("value: " + item); +} + +// Method 2: +let iter = treeSet[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-image.md b/en/application-dev/reference/arkui-js/js-components-canvas-image.md index 8ad046dea4f04309fca88e860adf17f3a561d6ad..32bd1bb59a4e3fe52150b32240a18c1b3ac049ea 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-image.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-image.md @@ -89,7 +89,7 @@ export default { onShow(){ const el =this.$refs.canvas - var ctx = this.$element('drawImage').getContext('2d'); + var ctx =el.getContext('2d'); var img = new Image(); img.src = 'common/images/example.jpg'; img.onload = function() { diff --git a/en/application-dev/reference/arkui-ts/Readme-EN.md b/en/application-dev/reference/arkui-ts/Readme-EN.md index 7924866850f603116b7a82f8f6fda1eadc56fa99..775bd3d067c466e6415a565eaefb15964956c61e 100644 --- a/en/application-dev/reference/arkui-ts/Readme-EN.md +++ b/en/application-dev/reference/arkui-ts/Readme-EN.md @@ -52,17 +52,20 @@ - [Gauge](ts-basic-components-gauge.md) - [Image](ts-basic-components-image.md) - [ImageAnimator](ts-basic-components-imageanimator.md) + - [LoadingProgress](ts-basic-components-loadingprogress.md) - [Marquee](ts-basic-components-marquee.md) - [Progress](ts-basic-components-progress.md) - [QRCode](ts-basic-components-qrcode.md) - [Rating](ts-basic-components-rating.md) - - [Span](ts-basic-components-span.md) + - [Select](ts-basic-components-select.md) - [Slider](ts-basic-components-slider.md) + - [Span](ts-basic-components-span.md) - [Text](ts-basic-components-text.md) - [TextArea](ts-basic-components-textarea.md) - [TextInput](ts-basic-components-textinput.md) - [Toggle](ts-basic-components-toggle.md) - + - [TextClock](ts-basic-components-textclock.md) + - [Container Components](ts-components-container.md) - [AlphabetIndexer](ts-container-alphabet-indexer.md) - [Badge](ts-container-badge.md) @@ -86,29 +89,28 @@ - [Swiper](ts-container-swiper.md) - [Tabs](ts-container-tabs.md) - [TabContent](ts-container-tabcontent.md) - - [Stepper](ts-container-stepper.md) - - [StepperItem](ts-container-stepperitem.md) - + + - [Refresh](ts-container-refresh.md) - [Drawing Components](ts-drawing-components.md) + - [Circle](ts-drawing-components-circle.md) - [Ellipse](ts-drawing-components-ellipse.md) - [Line](ts-drawing-components-line.md) - [Polyline](ts-drawing-components-polyline.md) - [Polygon](ts-drawing-components-polygon.md) - - [Path](ts-drawing-components-path.md) + - [Path](ts-drawing-components-path.md) - [Rect](ts-drawing-components-rect.md) - [Shape](ts-drawing-components-shape.md) - + - [Canvas Components](ts-components-canvas.md) - [Canvas](ts-components-canvas-canvas.md) - [CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md) - [OffscreenCanvasRenderingConxt2D](ts-offscreencanvasrenderingcontext2d.md) - [Lottie](ts-components-canvas-lottie.md) - [Path2D](ts-components-canvas-path2d.md) - - [CanvasGradient](ts-components-canvas-canvasgradient.md) + - [CanvasGradient](ts-components-canvas-canvasgradient.md) - [ImageBitmap](ts-components-canvas-imagebitmap.md) - [ImageData](ts-components-canvas-imagedata.md) - - [Animation](ts-animation.md) - [Attribute Animation](ts-animatorproperty.md) - [Explicit Animation](ts-explicit-animation.md) @@ -129,5 +131,6 @@ - [List Selection Dialog Box](ts-methods-action-sheet.md) - [Appendix](ts-appendix.md) + - [Built-in Enums](ts-appendix-enums.md) diff --git a/en/application-dev/reference/arkui-ts/figures/refresh.gif b/en/application-dev/reference/arkui-ts/figures/refresh.gif new file mode 100644 index 0000000000000000000000000000000000000000..f7796bdc1286c55b3853d52cf0f81d84cec6e8d4 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/refresh.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/row.png b/en/application-dev/reference/arkui-ts/figures/row.png index 3b44b9a41cb0fa78afcde81f82e0ad63c90de58d..6bf426a5f019e76b7b3a0953643988690eb67b1e 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/row.png and b/en/application-dev/reference/arkui-ts/figures/row.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/select.png b/en/application-dev/reference/arkui-ts/figures/select.png new file mode 100644 index 0000000000000000000000000000000000000000..2672d45f3ed5685aa6f350c2cade469c065a13af Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/select.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/text_clock.png b/en/application-dev/reference/arkui-ts/figures/text_clock.png new file mode 100644 index 0000000000000000000000000000000000000000..85b17585ac7fbb72297c5757f1b1118c27e7d8c9 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/text_clock.png differ diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-select.md b/en/application-dev/reference/arkui-ts/ts-basic-components-select.md new file mode 100644 index 0000000000000000000000000000000000000000..25d73234a372a9e13f9a693e2e834e45d6bf9cda --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-select.md @@ -0,0 +1,72 @@ +# Select + +> ![](public_sys-resources/icon-note.gif) **NOTE** This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component provides a drop-down list box that allows users to select among multiple options. + +## Required Permissions + +None + +## Child Components + +None + +## APIs + +Select(options: Array) + +- `SelectOption` parameters + + | Name| Type| Mandatory| Default Value| Description| + | ------ | ----------------------------------------------- | ---- | ------ | -------------- | + | value | [ResourceStr](../../ui/ts-types.md#ResourceStr) | Yes| - | Value of an option in the drop-down list box.| + | icon | [ResourceStr](../../ui/ts-types.md#ResourceStr) | No| - | Icon of an option in the drop-down list box.| + +## Attributes + +| Name| Type| Default Value| Description| +| ----------------------- | --------------------------------------------------- | ------ | ----------------------------------------------- | +| selected | number | - | Index of the initial selected option in the drop-down list box. The index of the first option is **0**.| +| value | string | - | Text of the drop-down button.| +| font | [Font](../../ui/ts-types.md) | - | Text font of the drop-down button.| +| fontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of the drop-down button.| +| selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Background color of the selected option in the drop-down list box.| +| selectedOptionFont | [Font](../../ui/ts-types.md) | - | Text font of the selected option in the drop-down list box.| +| selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of the selected option in the drop-down list box.| +| optionBgColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Background color of an option in the drop-down list box.| +| optionFont | [Font](../../ui/ts-types.md) | - | Text font of an option in the drop-down list box.| +| optionFontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of an option in the drop-down list box.| + +## Events + +| Name| Description| +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| onSelected(callback: (index: number, value?:string) => void)| Invoked when an option in the drop-down list box is selected. **index** indicates the index of the selected option. **value** indicates the value of the selected option.| + +## Example + +``` +@Entry +@Component +struct SliderExample { + build() { + Column() { + Select([{value:'aaa',icon: "/common/1.png"}, + {value:'bbb',icon: "/common/2.png"}, + {value:'ccc',icon: "/common/3.png"}, + {value:'ddd',icon: "/common/4.png"}]) + .selected(2) + .value('TTT') + .font({size: 30, weight:400, family: 'serif', style: FontStyle.Normal }) + .selectedOptionFont({size: 40, weight: 500, family: 'serif', style: FontStyle.Normal }) + .optionFont({size: 30, weight: 400, family: 'serif', style: FontStyle.Normal }) + .onSelected((index:number)=>{ + console.info("Select:" + index) + }) + } + } +} +``` + +![](figures/select.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textclock.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textclock.md new file mode 100644 index 0000000000000000000000000000000000000000..6f23dd45ae12120f7dcec85d26d16383e2b464ab --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textclock.md @@ -0,0 +1,83 @@ +# TextClock + +> ![](public_sys-resources/icon-note.gif) **NOTE** This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component displays the current system time in text format for different time zones. The time is accurate to seconds. + +## Required Permissions + +None + +## Child Components + +None + +## APIs + +TextClock(options?: {timeZoneOffset?: number, contorller?: TextClockController}) + +- Parameters + + | Name| Type| Mandatory| Default Value| Description| + | -------- | -------- | ---- | ------------------ | ------------------------------------------------------------ | + | timeZoneOffset | number | No| Time zone offset| Sets the time zone offset. The value range is [-14, 12], indicating UTC+12 to UTC-12. A negative value indicates Eastern Standard Time, and a positive value indicates Western Standard Time. For example, **-8** indicates UTC+8. For countries or regions crossing the International Date Line, use -13 (UTC+13) and -14 (UTC+14) to ensure consistent time within the entire country or region.| + | contorller | [TextClockContorller](#TextClockController) | No| null | Binds a controller to control the status of the **** component.| + +## Attributes + +| Name| Type| Default Value| Description| +| ------ | -------- | -------- | ------------------------------------------------------------ | +| format | string | 'hhmmss' | Time format, for example, **yyyy/mm/dd** or **yyyy-mm-dd**. Supported time format strings:
  • yyyy (year)
  • mm (two-letter abbreviated month name)
  • mmm (three-letter abbreviated month name)
  • mmmm (full month name)
  • dd (two-letter abbreviated day of the week)
  • ddd (three-letter abbreviated day of the week)
  • dddd (full day of the week)
  • HH (24-hour format)
  • hh (12-hour format)
  • MM/mm (minute)
  • SS/ss (second)
| + +## TextClockController + +Controller of the **** component, which can be bound to the component for status control. + +| API| Description| +| -------------------------------------------- | ------------------------------------------------------------ | +| start() | Starts the **** component.| +| stop() | Stops the **** component.| + + +## Events + +| Name| Description| +| -------------------------------------------- | ------------------------------------------------------------ | +| onDateChange(event: (value: number) => void) | Triggered when the time changes in seconds at minimum.
value: Unix time stamp, which is the number of milliseconds that have elapsed since the Unix epoch.| + +## Example + +``` +@Entry +@Component +struct Second { + @State accumulateTime: number = 0 + controller: TextClockController = new TextClockController() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center}) { + Text('current milliseconds is' + this.accumulateTime) + .fontSize(20) + TextClock({timeZoneOffset: -8, controller: this.controller}) + .format('hhmmss') + .onDateChange((value: number) => { + this.accumulateTime = value + }) + .margin(20) + .fontSize(30) + Button("start TextClock") + .margin({ bottom: 10 }) + .onClick(()=>{ + this.controller.start() + }) + Button("stop TextClock") + .onClick(()=>{ + this.controller.stop() + }) + } + .width('100%') + .height('100%') + } +} +``` +![](figures/text_clock.png) diff --git a/en/application-dev/reference/arkui-ts/ts-container-refresh.md b/en/application-dev/reference/arkui-ts/ts-container-refresh.md new file mode 100644 index 0000000000000000000000000000000000000000..fefd46e33b5f0f43fe4565882e288b10fa7952f9 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-container-refresh.md @@ -0,0 +1,80 @@ +# Refresh + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component is used to refresh a page through a pull-down gesture. + +## Required Permissions + +None + +## Child Components + +This component supports only one child component. + +## APIs + +Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number\}\) + +- Parameters + + | Name| Value Type| Mandatory| Default Value| Description| + | -------- | -------- | -------- | -------- | -------- | + | refreshing | boolean | Yes| - | Whether the current component is being refreshed.| + | offset | Length | No| 16 | Distance to the top of the parent component from the **** component that comes to rest after a successful pull-down gesture.| + | friction | number | No| 62 | Coefficient of friction, which indicates the **** component's sensitivity to the pull-down gesture. The value ranges from 0 to 100.
- **0** indicates that the **** component is not sensitive to the pull-down gesture.
- **100** indicates that the **** component is highly sensitive to the pull-down gesture.
- A larger value indicates a more sensitive response of the **** component to the pull-down gesture.| + + + +## Events + + +| Name| Description| +| -------- | -------- | +| onStateChange(callback: (state: RefreshStatus) => void)| Triggered when the refresh status changes.
**state** indicates the refresh status.| +| onRefreshing(callback: () => void)| Triggered when the component enters the refresh state.| + +- RefreshStatus enums + + | Name| Description| + | -------- | -------- | + | Inactive | The component is not pulled down. This is the default value.| + | Drag | The component is being pulled down, but the pulled distance is shorter than the minimum length required to trigger the refresh.| + | OverDrag | The component is being pulled down, and the pulled distance exceeds the minimum length required to trigger the refresh.| + | Refresh | The pull-down ends, and the component rebounds to the minimum length required to trigger the refresh and enters the refresh state.| + | Done | The refresh is complete, and the component returns to the initial state (top).| + + +## Example + +``` +@Entry +@Component +struct RefreshExample { + @State isRefreshing: boolean = false + @State counter: number = 0 + + build() { + Column() { + Refresh({refreshing: this.isRefreshing, offset: 120, friction: 100}) { + Text('Pull Down and refresh: ' + this.counter) + .fontSize(30) + .margin(10) + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.counter++ + this.isRefreshing = false + }, 1000) + console.log('onRefreshing test') + }) + } + } +} +``` + +![](figures/refresh.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-row.md b/en/application-dev/reference/arkui-ts/ts-container-row.md index e25ea9b861af2897ea301d7e6eb2d6cb5055a639..628b9672084d28207535f29c32745d3f4eb23a06 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-row.md +++ b/en/application-dev/reference/arkui-ts/ts-container-row.md @@ -1,106 +1,48 @@ -# Row +# Row ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component lays out child components horizontally. -## Required Permissions +The **** component lays out child components horizontally. + + +## Required Permissions None -## Child Components - -This component can contain child components. - -## APIs - -Row\(value:\{space?: Length\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

space

-

Length

-

No

-

0

-

Space between any two adjacent child components in the horizontal layout.

-
- - -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

alignItems

-

VerticalAlign

-

Center

-

Alignment mode of the child components in the vertical direction.

-
- -- VerticalAlign enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Top

-

Top aligned.

-

Center

-

Center alignment. This is the default alignment mode.

-

Bottom

-

Bottom aligned.

-
- - -## Example + +## Child Components + +Supported + + +## APIs + +Row(value:{space?: Length}) + +- Parameters + | Name| Type| Mandatory| Default Value| Description| + | -------- | -------- | -------- | -------- | -------- | + | space | Length | No| 0 | Space between two adjacent child components in the horizontal layout.| + + +## Attributes + +| Name| Type| Default Value| Description| +| -------- | -------- | -------- | -------- | +| alignItems | VerticalAlign | VerticalAlign.Center | Alignment mode of the child components in the vertical direction.| +| justifyContent8+ | [FlexAlign](ts-container-flex.md) | FlexAlign.Start | Alignment mode of the child components in the horizontal direction.| + +- VerticalAlign enums + | Name| Description| + | -------- | -------- | + | Top | Top aligned.| + | Center | Center aligned. This is the default alignment mode.| + | Bottom | Bottom aligned.| + + +## Example ``` @Entry @@ -109,26 +51,37 @@ struct RowExample { build() { Column({ space: 5 }) { Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row({ space: 20 }) { - Row().width(150).height(50).backgroundColor(0xAFEEEE) - Row().width(150).height(50).backgroundColor(0x00FFFF) - }.width(321).height(52).border({ width: 1 }) - - Text('alignItems(Bottom)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row() { - Row().width('50%').height(50).backgroundColor(0xAFEEEE) - Row().width('50%').height(50).backgroundColor(0x00FFFF) - }.alignItems(VerticalAlign.Bottom).width('90%').height(100).border({ width: 1 }) - - Text('alignItems(Top)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row() { - Row().width('50%').height(50).backgroundColor(0xAFEEEE) - Row().width('50%').height(50).backgroundColor(0x00FFFF) - }.alignItems(VerticalAlign.Top).width('90%').height(100).border({ width: 1 }) + Row({ space: 5 }) { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').height(107).border({ width: 1 }) + + Text('alignItems(Top)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.alignItems(VerticalAlign.Top).height('15%').border({ width: 1 }) + + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.alignItems(VerticalAlign.Center).height('15%').border({ width: 1 }) + + Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.End) + + Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.Center) }.width('100%') } } ``` -![](figures/row.png) - +![en_image_0000001174422908](figures/row.png) diff --git a/en/application-dev/security/userauth-guidelines.md b/en/application-dev/security/userauth-guidelines.md index ede673ad7acadde4015c618b567f20ec0d4ddc12..38dc702198546d90925a3b02d2d2d330bdfd1de7 100644 --- a/en/application-dev/security/userauth-guidelines.md +++ b/en/application-dev/security/userauth-guidelines.md @@ -1,65 +1,27 @@ -# User Authentication Development +# User Authentication Development ->**NOTE:** ->This document applies to JS. +## When to Use -## When to Use +OpenHarmony supports 2D and 3D facial recognition that can be used for identity authentication during device unlocking, application login, and payment. -HarmonyOS supports 2D and 3D facial recognition that can be used for identity authentication during device unlocking, application login, and payment. - -## Available APIs +## Available APIs The **userIAM\_userAuth** module provides methods for checking the support for biometric authentication, and performing and canceling authentication. You can perform authentication based on biometric features such as facial characteristics. Before performing biometric authentication, check whether your device supports this capability, including the authentication type, security level, and whether local authentication is used. If biometric authentication is not supported, consider using another authentication type. The following table lists methods in the APIs available for biometric authentication. **Table 1** Methods available for biometric authentication - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Method

-

Description

-

getAuthenticator(): Authenticator

-

Obtains an Authenticator object for user authentication. 6+

-

Obtains an Authenticator object to check the device's capability of user authentication, perform or cancel user authentication, and obtain the tips generated in the authentication process. 7+

-

checkAvailability(type: AuthType, level: SecureLevel): number

-

Checks whether the device supports the specified authentication type and security level.

-

execute(type: AuthType, level: SecureLevel, callback: AsyncCallback<number>): void

-

Performs user authentication and returns the authentication result using an asynchronous callback.

-

execute(type: AuthType, level: SecureLevel): Promise<number>

-

Performs user authentication and returns the authentication result using a promise.

-

cancel(): void

-

Cancels the current authentication.

-

on(type: "tip", callback: Callback<Tip>): void

-

Subscribes to the events of the specified type.

-

off(type: "tip", callback?: Callback<Tip>): void

-

Unsubscribes from the events of the specified type.

-
- -## How to Develop +| Method | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| getAuthenticator(): Authenticator | Obtains an **Authenticator** object for user authentication. 6+
Obtains an **Authenticator** object to check the device's capability of user authentication, perform or cancel user authentication, and obtain the tips generated in the authentication process. 7+ | +| checkAvailability(type: AuthType, level: SecureLevel): number | Checks whether the device supports the specified authentication type and security level. | +| execute(type: AuthType, level: SecureLevel, callback: AsyncCallback\): void | Performs user authentication and returns the authentication result using an asynchronous callback. | +| execute(type: AuthType, level: SecureLevel): Promise\ | Performs user authentication and returns the authentication result using a promise. | +| cancel(): void | Cancels the current authentication. | +| on(type: "tip", callback: Callback\): void | Subscribes to the events of the specified type. | +| off(type: "tip", callback?: Callback\): void | Unsubscribes from the events of the specified type. | + + +## How to Develop Before starting the development, make the following preparations: @@ -88,7 +50,7 @@ The development procedure is as follows: } ``` -3. \(Optional\) Subscribe to tip information. The sample code is as follows: +3. \(Optional\) Subscribe to tip information. The sample code is as follows: ``` let authenticator = userIAM_userAuth.getAuthenticator(); @@ -112,7 +74,7 @@ The development procedure is as follows: }); ``` -5. \(Optional\) Unsubscribe from tip information if [you have subscribed to tip information](#li109311114115111)you have subscribed to tip information. +5. \(Optional\) Unsubscribe from tip information if you have subscribed to tip information you have subscribed to tip information. ``` let authenticator = userIAM_userAuth.getAuthenticator(); @@ -138,4 +100,3 @@ The development procedure is as follows: } ``` - diff --git a/en/application-dev/security/userauth-overview.md b/en/application-dev/security/userauth-overview.md index 5bd678a630115cdb26686ce75945e45f90cdca39..f3e6a9a9042ad36f0111f3679f0084be4c6fc352 100644 --- a/en/application-dev/security/userauth-overview.md +++ b/en/application-dev/security/userauth-overview.md @@ -1,22 +1,22 @@ -# User Authentication Overview +# User Authentication Overview OpenHarmony provides biometric recognition that can be used for identity authentication in device unlocking, application login, and payment. OpenHarmony provides both 2D and 3D facial recognition. You can provide either or both of them on your device based on the hardware and technology applied on the device. 3D facial recognition is superior to 2D facial recognition in terms of recognition rate and anti-counterfeiting capability. However, you can use 3D facial recognition only if your device supports capabilities such as 3D structured light and 3D Time of Flight \(TOF\). -## Basic Concepts +## Basic Concepts Biometric recognition \(also known as biometric authentication\) uses optical, acoustical, and biological sensors, as well as the biological statistics mechanism to identify individuals. Facial recognition is a biometric recognition technology that identifies individuals based on facial characteristics. A camera is used to collect images or video streams that contain human faces, and automatically detect, track, and recognize the human faces. -## Working Principles +## Working Principles Facial recognition establishes a secure channel between a camera and a trusted execution environment \(TEE\). Through this channel, face image data is transmitted to the TEE. This protects against any attack from the rich execution environment \(REE\) as the face image data cannot be obtained from the REE. The face image collection, characteristic extraction, alive human body detection, and characteristic comparison are all completed in the TEE. The TEE implements security isolation based on the trust zone. The external face framework only initiates face authentication and processes authentication results. It does not process the human face data. Facial characteristics are stored in the TEE, which uses strong cryptographic algorithms to encrypt and protect the integrity of facial characteristics. The collected and stored facial characteristics will not be transferred out of the TEE without user authorization. This ensures that system or third-party applications cannot obtain facial characteristics, or send or back them up to any external storage medium. -## Limitations and Constraints +## Limitations and Constraints - OpenHarmony only supports facial recognition and local authentication, and does not support an authentication UI. - To use biometric recognition, a device must have a camera with a face image pixel greater than 100x100. diff --git a/en/application-dev/ui/Readme-EN.md b/en/application-dev/ui/Readme-EN.md index 8f16c2a59a777fe617d85df75fca4900a263b630..2a353af88ae135779578dc78e4f79e77a1518114 100755 --- a/en/application-dev/ui/Readme-EN.md +++ b/en/application-dev/ui/Readme-EN.md @@ -1,142 +1,111 @@ # UI -- [ ArkUI](ui-arkui.md) - - [JavaScript-based Web-Like Development Paradigm](ui-arkui-js.md) - - [Overview](ui-js-overview.md) - - [Framework](js-framework.md) - - [File Organization](js-framework-file.md) - - ["js" Tag](js-framework-js-tag.md) - - [app.js](js-framework-js-file.md) - - [Syntax](js-framework-syntax.md) - - [HML](js-framework-syntax-hml.md) - - [CSS](js-framework-syntax-css.md) - - [JavaScript](js-framework-syntax-js.md) - - - [Lifecycle](js-framework-lifecycle.md) - - [Resource Limitations and Access](js-framework-resource-restriction.md) - - [Multi-Language Capability](js-framework-multiple-languages.md) - - - [Building the UI](ui-js-building-ui.md) - - [Component Overview](ui-js-building-ui-component.md) - - [Building the Layout](ui-js-building-ui-layout.md) - - [Layout Description](ui-js-building-ui-layout-intro.md) - - [Adding Title and Paragraph Text](ui-js-building-ui-layout-text.md) - - [Adding an Image](ui-js-building-ui-layout-image.md) - - [Adding a Comment](ui-js-building-ui-layout-comment.md) - - [Adding a Container](ui-js-building-ui-layout-external-container.md) - - - [Adding Interactions](ui-js-building-ui-interactions.md) - - [Developing Animations](ui-js-building-ui-animation.md) - - [Defining Events](ui-js-building-ui-event.md) - - [Defining Page Routes](ui-js-building-ui-routes.md) - - - [Common Component Development Guidelines](ui-js-common-components.md) - - [Text](ui-js-components-text.md) - - [Input](ui-js-components-input.md) - - [Button](ui-js-components-button.md) - - [List](ui-js-components-list.md) - - [Picker](ui-js-components-picker.md) - - [Dialog](ui-js-components-dialog.md) - - [Form](ui-js-components-form.md) - - [Stepper](ui-js-components-stepper.md) - - [Tabs](ui-js-component-tabs.md) - - [Image](ui-js-components-images.md) - - - [Animation Development Guidelines](ui-js-animate.md) - - [CSS Animation](ui-js-animate-css.md) - - [Defining Attribute Style Animations](ui-js-animate-attribute-style.md) - - [Defining Animations with the transform Attribute](ui-js-animate-transform.md) - - [Defining Animations with the background-position Attribute](ui-js-animate-background-position-style.md) - - - [JS Animation](ui-js-animate-javascript.md) - - [Component Animation](ui-js-animate-component.md) - - [Interpolator Animation](ui-js-animate-interpolator.md) - - [Animation Effect](ui-js-animate-dynamic-effects.md) - - [Animation Frame](ui-js-animate-frame.md) - - - [Custom Components](ui-js-custom-components.md) - - - [TypeScript-based Declarative Development Paradigm](ui-arkui-ts.md) - - [Overview](ui-ts-overview.md) - - [Framework Overview](ts-framework.md) - - [File Organization](ts-framework-file.md) - - [Directory Structure](ts-framework-directory.md) - - [Rules for Accessing Application Code Files](ts-framework-file-access-rules.md) - - - ["js" Tag](ts-framework-js-tag.md) - - [Resource Access](ts-resource-access.md) - - [Accessing Application Resources](ts-application-resource-access.md) +- JavaScript-based Web-Like Development Paradigm + - [Overview](ui-js-overview.md) + - Framework + - [File Organization](js-framework-file.md) + - ["js" Tag](js-framework-js-tag.md) + - [app.js](js-framework-js-file.md) + - Syntax + - [HML](js-framework-syntax-hml.md) + - [CSS](js-framework-syntax-css.md) + - [JavaScript](js-framework-syntax-js.md) + - [Lifecycle](js-framework-lifecycle.md) + - [Resource Limitations and Access](js-framework-resource-restriction.md) + - [Multi-Language Capability](js-framework-multiple-languages.md) + - Building the UI + - [Component Overview](ui-js-building-ui-component.md) + - Building the Layout + - [Layout Description](ui-js-building-ui-layout-intro.md) + - [Adding Title and Paragraph Text](ui-js-building-ui-layout-text.md) + - [Adding an Image](ui-js-building-ui-layout-image.md) + - [Adding a Comment](ui-js-building-ui-layout-comment.md) + - [Adding a Container](ui-js-building-ui-layout-external-container.md) + - [Adding Interactions](ui-js-building-ui-interactions.md) + - [Developing Animations](ui-js-building-ui-animation.md) + - [Defining Events](ui-js-building-ui-event.md) + - [Defining Page Routes](ui-js-building-ui-routes.md) + - Common Component Development Guidelines + - [Text](ui-js-components-text.md) + - [Input](ui-js-components-input.md) + - [Button](ui-js-components-button.md) + - [List](ui-js-components-list.md) + - [Picker](ui-js-components-picker.md) + - [Dialog](ui-js-components-dialog.md) + - [Form](ui-js-components-form.md) + - [Stepper](ui-js-components-stepper.md) + - [Tabs](ui-js-component-tabs.md) + - [Image](ui-js-components-images.md) + - Animation Development Guidelines + - CSS Animation + - [Defining Attribute Style Animations](ui-js-animate-attribute-style.md) + - [Defining Animations with the transform Attribute](ui-js-animate-transform.md) + - [Defining Animations with the background-position Attribute](ui-js-animate-background-position-style.md) + - JS Animation + - [Component Animation](ui-js-animate-component.md) + - Interpolator Animation + - [Animation Effect](ui-js-animate-dynamic-effects.md) + - [Animation Frame](ui-js-animate-frame.md) + - [Custom Components](ui-js-custom-components.md) +- TypeScript-based Declarative Development Paradigm + - [Overview](ui-ts-overview.md) + - Framework Overview + - File Organization + - [Directory Structure](ts-framework-directory.md) + - [Rules for Accessing Application Code Files](ts-framework-file-access-rules.md) + - ["js" Tag](ts-framework-js-tag.md) + - Resource Access - [Media Resource Types](ts-media-resource-type.md) - - - [Pixel Units](ts-pixel-units.md) - - [Types](ts-types.md) - - - [Declarative Syntax](ts-declarative-syntax.md) - - [Overview](ts-syntax-intro.md) - - [General UI Description Specifications](ts-general-ui-description-specifications.md) - - [Basic Concepts](ts-general-ui-concepts.md) - - [Declarative UI Description Specifications](ts-declarative-ui-description-specifications.md) - - [Parameterless Configuration](ts-parameterless-configuration.md) - - [Configuration with Mandatory Parameters](ts-configuration-with-mandatory-parameters.md) - - [Attribution Configuration](ts-attribution-configuration.md) - - [Event Configuration](ts-event-configuration.md) - - [Child Component Configuration](ts-child-component-configuration.md) - - - [Componentization](ts-component-based.md) - - [@Component](ts-component-based-component.md) - - [@Entry](ts-component-based-entry.md) - - [@Preview](ts-component-based-preview.md) - - [@Builder](ts-component-based-builder.md) - - [@Extend](ts-component-based-extend.md) - - [@CustomDialog](ts-component-based-customdialog.md) - - - [About UI State Management](ts-ui-state-management.md) - - [Basic Concepts](ts-ui-state-mgmt-concepts.md) - - [Managing Component States](ts-managing-component-states.md) - - [@State](ts-component-states-state.md) - - [@Prop](ts-component-states-prop.md) - - [@Link](ts-component-states-link.md) - - - [Managing Application States](ts-managing-application-states.md) - - [APIs](ts-managing-application-states-apis.md) - - [AppStorage](ts-application-states-appstorage.md) - - [PersistentStorage](ts-application-states-apis-persistentstorage.md) - - [Environment](ts-application-states-apis-environment.md) - - - [Synchronization Between AppStorage and Components](ts-application-states-storagelink-storageprop.md) - - - [Managing Other States](ts-managing-other-states.md) - - [@observed and @objectLink](ts-other-states-observed-objectlink.md) - - [@Consume and @Provide](ts-other-states-consume-provide.md) - - [@Watch](ts-other-states-watch.md) - - - [About Rendering Control Syntax](ts-rending-control-syntax.md) - - [if/else](ts-rending-control-syntax-if-else.md) - - [ForEach](ts-rending-control-syntax-foreach.md) - - [LazyForEach](ts-rending-control-syntax-lazyforeach.md) - - - [About @Component](ts-a-deep-dive-into-component.md) - - [build Function](ts-function-build.md) - - [Custom Component Initialization](ts-custom-component-initialization.md) - - [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md) - - [Example: Component Creation and Re-Initialization](ts-component-creation-re-initialization.md) - - - [About Syntactic Sugar](ts-syntactic-sugar.md) - - [@Decorator](ts-syntactic-sugar-decorator.md) - - [Chain Call](ts-syntactic-sugar-chaining.md) - - [struct](ts-syntactic-sugar-struct.md) - - [Instantiating a struct Without the new Keyword](ts-instantiating-a-struct-without-new-keyword.md) - - [Using a Separate Line for New Component](ts-using-a-separate-line-for-new-component.md) - - [Restrictions on Using TypeScript for Generators](ts-restrictions-for-generators.md) - - - [Experiencing the Declarative UI](ui-ts-experiencing-declarative-ui.md) - - [Creating a Declarative UI Project](ui-ts-creating-project.md) - - [Getting to Know Components](ui-ts-components.md) - - [Creating a Simple Page](ui-ts-creating-simple-page.md) - - - [Defining Page Layout and Connection](ui-ts-page-layout-connections.md) - - [Building a Food Data Model](ui-ts-building-data-model.md) - - [Building a Food Category List Layout](ui-ts-building-category-list-layout.md) - - [Building a Food Category Grid Layout](ui-ts-building-category-grid-layout.md) - - [Implementing Page Redirection and Data Transmission](ui-ts-page-redirection-data-transmission.md) + - [Pixel Units](ts-pixel-units.md) + - [Types](ts-types.md) + - Declarative Syntax + - [Overview](ts-syntax-intro.md) + - General UI Description Specifications + - [Basic Concepts](ts-general-ui-concepts.md) + - Declarative UI Description Specifications + - [Parameterless Configuration](ts-parameterless-configuration.md) + - [Configuration with Mandatory Parameters](ts-configuration-with-mandatory-parameters.md) + - [Attribution Configuration](ts-attribution-configuration.md) + - [Event Configuration](ts-event-configuration.md) + - [Child Component Configuration](ts-child-component-configuration.md) + - Componentization + - [@Component](ts-component-based-component.md) + - [@Entry](ts-component-based-entry.md) + - [@Preview](ts-component-based-preview.md) + - [@Builder](ts-component-based-builder.md) + - [@Extend](ts-component-based-extend.md) + - [@CustomDialog](ts-component-based-customdialog.md) + - About UI State Management + - [Basic Concepts](ts-ui-state-mgmt-concepts.md) + - Managing Component States + - [@State](ts-component-states-state.md) + - [@Prop](ts-component-states-prop.md) + - [@Link](ts-component-states-link.md) + - Managing Application States + - [AppStorage](ts-application-states-appstorage.md) + - [PersistentStorage](ts-application-states-apis-persistentstorage.md) + - [Environment](ts-application-states-apis-environment.md) + - Managing Other States + - [@observed and @objectLink](ts-other-states-observed-objectlink.md) + - [@Consume and @Provide](ts-other-states-consume-provide.md) + - [@Watch](ts-other-states-watch.md) + - About Rendering Control Syntax + - [if/else](ts-rending-control-syntax-if-else.md) + - [ForEach](ts-rending-control-syntax-foreach.md) + - [LazyForEach](ts-rending-control-syntax-lazyforeach.md) + - About @Component + - [build Function](ts-function-build.md) + - [Custom Component Initialization](ts-custom-component-initialization.md) + - [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md) + - [Example: Component Creation and Re-Initialization](ts-component-creation-re-initialization.md) + - [Syntactic Sugar](ts-syntactic-sugar.md) + - Experiencing the Declarative UI + - [Creating a Declarative UI Project](ui-ts-creating-project.md) + - [Getting to Know Components](ui-ts-components.md) + - [Creating a Simple Page](ui-ts-creating-simple-page.md) + - Defining Page Layout and Connection + - [Building a Food Data Model](ui-ts-building-data-model.md) + - [Building a Food Category List Layout](ui-ts-building-category-list-layout.md) + - [Building a Food Category Grid Layout](ui-ts-building-category-grid-layout.md) + - [Implementing Page Redirection and Data Transmission](ui-ts-page-redirection-data-transmission.md) diff --git a/en/device-dev/bundles/bundles-standard-rules.md b/en/device-dev/bundles/bundles-standard-rules.md index 559ff09b2190c8c98b705ec6ceea1f478d6597ad..edd766e0bde314cd32406c1ea32c47b133f835a4 100644 --- a/en/device-dev/bundles/bundles-standard-rules.md +++ b/en/device-dev/bundles/bundles-standard-rules.md @@ -161,7 +161,7 @@ Bundle dependencies are then stored in the **ohos\_bundles** folder in the roo username@server MINGW64 /f/showcase/demo/demo $ hpm list +--demo@1.0.0 -| +--@huawei/media@1.0.2 +| +--@example/media@1.0.2 | +--@demo/sport_hi3518ev300_liteos_a@1.0.0 | | +--@demo/app@4.0.1 | | | +--@demo/build@4.0.1 diff --git a/en/device-dev/faqs/faqs-system-applications.md b/en/device-dev/faqs/faqs-system-applications.md index 8be8a965d7090a42f3f475d9d7dfdac838343c87..10f999d9f36131330be4a92153bd68480c25adab 100644 --- a/en/device-dev/faqs/faqs-system-applications.md +++ b/en/device-dev/faqs/faqs-system-applications.md @@ -17,7 +17,7 @@ The compiled executable program is run directly without being converted to an ap Call the **UtilsSetEnv** function of the KV store to set the data storage path. ``` -UtilsSetEnv("/storage/com.huawei.kv"); +UtilsSetEnv("/storage/com.example.kv"); ``` ## Visual Applications diff --git a/en/device-dev/get-code/gettools-acquire.md b/en/device-dev/get-code/gettools-acquire.md index 21e5bccc54e32782a1d0b39b2cd2b4101d6d67e1..6c06f41669bfdb21965dcfe7d4095613a676861b 100644 --- a/en/device-dev/get-code/gettools-acquire.md +++ b/en/device-dev/get-code/gettools-acquire.md @@ -30,16 +30,16 @@ OpenHarmony provides the following two types of Docker environments for you to q

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker

-

0.0.7

+

1.0.0

Standard system

Ubuntu

-

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard

+

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker

-

0.0.8

+

1.0.0

HPM-based Docker environment

@@ -62,6 +62,7 @@ OpenHarmony provides the following two types of Docker environments for you to q + ## Preparations Before using the Docker environment, perform the following operations: @@ -82,7 +83,7 @@ The Docker image of OpenHarmony is hosted on [HUAWEI CLOUD SWR](https://console 1. Obtain the Docker image. ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment: @@ -90,13 +91,13 @@ The Docker image of OpenHarmony is hosted on [HUAWEI CLOUD SWR](https://console Run the following command in Ubuntu: ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\): ``` - docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` @@ -108,7 +109,6 @@ Set the build path to the current path. ``` hb set - . ``` **Figure 1** Setting page @@ -116,6 +116,7 @@ hb set >![](../public_sys-resources/icon-note.gif) **NOTE:** >The mapping between the development board and the building GUI: +> >- Hi3861: wifiiot\_hispark\_pegasus@hisilicon >- Hi3516: ipcamera\_hispark\_taurus@hisilicon >- Hi3518: ipcamera\_hispark\_aries@hisilicon @@ -137,13 +138,13 @@ hb set 1. Obtain the Docker image. ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:1.0.0 ``` 2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment: ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/en/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md b/en/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md index a6752e9588f164f0e728b4e4ab49b9f23f597e42..0dd40f285677989a859a6b49b132aa74cf4cfa06 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md @@ -90,7 +90,6 @@ kill \[-l \[_signo_\] | _-s signo_ | _-signo_\] _pid..._ 6 1 6 0 Pending 0x688000 0x137000 0x11bca0 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa1cdf 0.88 wms_server 8 1 8 2 Pending 0x1f5000 0x48000 0x47dc2 0.2 mksh - 10 5 5 101 Pending 0x11ec000 0x2f9000 0x206047 0.93 com.huawei.launcher 12 1 12 0 Pending 0x4d4000 0x112000 0xe0882 0.0 deviceauth_service 13 1 13 0 Pending 0x34f000 0xbd000 0x51799 0.0 sensor_service 14 1 14 2 Pending 0x34e000 0xb3000 0x52184 0.0 ai_server @@ -116,7 +115,6 @@ kill \[-l \[_signo_\] | _-s signo_ | _-signo_\] _pid..._ 6 1 6 0 Pending 0x688000 0x137000 0x11c1ba 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa21f9 0.89 wms_server 8 1 8 2 Pending 0x1f5000 0x48000 0x482dc 0.2 mksh - 10 5 5 101 Pending 0x11ec000 0x2f9000 0x206561 0.93 com.huawei.launcher 12 1 12 0 Pending 0x4d4000 0x112000 0xe0d9c 0.0 deviceauth_service 13 1 13 0 Pending 0x34f000 0xbd000 0x51cb3 0.0 sensor_service 14 1 14 2 Pending 0x34e000 0xb3000 0x5269e 0.0 ai_server diff --git a/en/device-dev/kernel/kernel-small-debug-shell-cmd-task.md b/en/device-dev/kernel/kernel-small-debug-shell-cmd-task.md index 702530ad0a5439df2a4a3c1cc8c44f7640277b73..3eceba9af02fe37ab24ee34fe8282092a8e5a199 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-cmd-task.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-cmd-task.md @@ -62,7 +62,6 @@ OHOS # task 6 1 6 0 Pending 0x688000 0x137000 0x11c518 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa1ddf 0.89 wms_server 8 1 1 1000 Running 0x2bf000 0x8f000 0x2a8c6 0.0 shell - 9 5 5 101 Pending 0x11ea000 0x2f9000 0x20429d 0.97 com.huawei.launcher 11 1 11 0 Pending 0x4d4000 0x112000 0xe0ad7 0.0 deviceauth_service 12 1 12 0 Pending 0x34f000 0xbd000 0x519ee 0.0 sensor_service 13 1 13 2 Pending 0x34e000 0xb3000 0x523d9 0.0 ai_server diff --git a/en/device-dev/kernel/kernel-small-debug-shell-cmd-top.md b/en/device-dev/kernel/kernel-small-debug-shell-cmd-top.md index 9826e59c8eb87a6307db706289c4a55f275ce012..3f605a6d21a6e44ccaa8a3ab8d567313e381f2b7 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-cmd-top.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-cmd-top.md @@ -73,7 +73,6 @@ OHOS:/$ top 6 1 6 0 Pending 0x688000 0x137000 0x11c1ba 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa21f9 0.87 wms_server 8 1 8 2 Pending 0x1f5000 0x48000 0x462dc 0.0 mksh - 9 5 5 101 Pending 0x11ea000 0x2f9000 0x204561 0.94 com.huawei.launcher 11 1 11 0 Pending 0x4d4000 0x112000 0xe0d9c 0.0 deviceauth_service 12 1 12 0 Pending 0x34f000 0xbd000 0x51cb3 0.0 sensor_service 13 1 13 2 Pending 0x34e000 0xb3000 0x5269e 0.0 ai_server diff --git a/en/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md b/en/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md index 78cb1416ad05af2d3474c360a398fbbb9d3b2e3b..781a427e634db8e478120f7ab6cb2ca1fde324e2 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md @@ -84,7 +84,7 @@ Example 1: all information of the operating system ``` OHOS:/$ uname -a -Huawei LiteOS hisilicon 2.0.0.37 Huawei LiteOS 2.0.0.37 Oct 21 2021 17:39:32 Cortex-A7 +LiteOS hisilicon 2.0.0.37 Huawei LiteOS 2.0.0.37 Oct 21 2021 17:39:32 Cortex-A7 OHOS:/$ ``` @@ -92,7 +92,7 @@ Example 2: operating system name and architecture ``` OHOS:/$ uname -ms -Huawei LiteOS Cortex-A7 +LiteOS Cortex-A7 OHOS:/$ ``` diff --git a/en/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md b/en/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md index 65d163661af9a504cd2f63016c5558b7b9844203..df743e04bb4b8628338bedf864b9616374a11a96 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md @@ -105,7 +105,6 @@ OHOS # 6 1 6 0 Pending 0x688000 0x137000 0x11c518 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa1ddf 0.95 wms_server 8 1 1 1000 Running 0x2bf000 0x8f000 0x2a8c6 0.0 shell - 9 5 5 101 Pending 0x11ea000 0x2f9000 0x20429d 1.2 com.huawei.launcher 11 1 11 0 Pending 0x4d4000 0x112000 0xe0ad7 0.0 deviceauth_service 12 1 12 0 Pending 0x34f000 0xbd000 0x519ee 0.0 sensor_service 13 1 13 2 Pending 0x34e000 0xb3000 0x523d9 0.0 ai_server diff --git a/en/device-dev/quick-start/quickstart-standard-docker-environment.md b/en/device-dev/quick-start/quickstart-standard-docker-environment.md index 4f61ac051f71146760d4c23e29f6a0a540de3432..ab1534cdd01ad90681fd2f1d5cbc0f274d170147 100644 --- a/en/device-dev/quick-start/quickstart-standard-docker-environment.md +++ b/en/device-dev/quick-start/quickstart-standard-docker-environment.md @@ -64,13 +64,13 @@ By default, the downloaded prebuilts binary file is stored in **OpenHarmony\_2. 1. Obtain the Docker image. ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. Go to the root directory of source code and run the following command to access the Docker build environment: ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md index b7106bf6f4ea8d0b0dab99470c598d42edfd9970..5df286d2676a52bb60d097feb926e00b2f2525b2 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md @@ -21,34 +21,34 @@ Before subscribing to system events, you need to configure HiSysEvent logging. F ### Available APIs -**Table 1** EventListener APIs +**Table 1** Description of EventListener APIs -| API| Description| +| Name| Description | | -------- | --------- | -|bool HiSysEventManager::AddEventListener(std::shared_ptr<HiSysEventSubscribeCallBackBase> listener, std::vector<ListenerRule>& rules)|Registers a listener for system events. You can listen for certain events by specifying rules.

Input arguments:
  • **listener**: callback object for system events.
  • **rules**: rules for event listening.
Return value:
  • **0**: Repeated registration is successful.
  • **1**: Initial registration is successful.
  • Other values: Registration has failed.
| -|bool HiSysEventManager::RemoveListener(std::shared_ptr<HiSysEventSubscribeCallBackBase> listener)|Removes the listener for system events.

Input argument:
  • **listener**: callback object for system events.
Return value:
  None.| +|bool HiSysEventManager::AddEventListener(std::shared_ptr<HiSysEventSubscribeCallBack> listener, std::vector<ListenerRule>& rules)|Registers a listener for system events. You can listen for certain events by specifying rules.

Input arguments:
  • **listener**: callback object for system events.
  • **rules**: rules for event listening.
Return value:
  • **0**: Repeated registration is successful.
  • **1**: Initial registration is successful.
  • Other values: Registration has failed.
| +|bool HiSysEventManager::RemoveListener(std::shared_ptr<HiSysEventSubscribeCallBack> listener)|Removes the listener for system events.

Input arguments:
  • **listener**: callback object for system events.
Return value:
None.| **Table 2** Description of ListenerRule -| API| Description| +| API| Description | | -------- | --------- | -|ListenerRule(const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event tag.

Input arguments:
  • **tag**: indicates the event tag for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, lowercase letters, and digits.
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| -|ListenerRule(const std::string& domain, const std::string& eventName, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain and event name.

Input arguments:
  • **domain**: indicates the event domain for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, digits, and underscores (_).
  • **eventName**: indicates the event name for the **ListenerRule** object. The value is a string of 1 to 32 characters, including uppercase letters, digits, and underscores (_).
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| -|ListenerRule(const std::string& domain, const std::string& eventName, const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain, event name, and event tag.

Input arguments:
  • **tag**: indicates the event tag for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, lowercase letters, and digits.
  • **domain**: indicates the event domain for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, digits, and underscores (_).
  • **eventName**: indicates the event name for the **ListenerRule** object. The value is a string of 1 to 32 characters, including uppercase letters, digits, and underscores (_).
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| +|ListenerRule(const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event tag.

Input arguments:
  • **tag**: indicates the event tag for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, lowercase letters, and digits.
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| +|ListenerRule(const std::string& domain, const std::string& eventName, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain and event name.

Input arguments:
  • **domain**: indicates the event domain for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, digits, and underscores (_).
  • **eventName**: indicates the event name for the **ListenerRule** object. The value is a string of 1 to 32 characters, including uppercase letters, digits, and underscores (_).
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| +|ListenerRule(const std::string& domain, const std::string& eventName, const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain, event name, and event tag.

Input arguments:
  • **tag**: indicates the event tag for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, lowercase letters, and digits.
  • **domain**: indicates the event domain for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, digits, and underscores (_).
  • **eventName**: indicates the event name for the **ListenerRule** object. The value is a string of 1 to 32 characters, including uppercase letters, digits, and underscores (_).
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| **Table 3** Description of RuleType -| Enum| Description| +| Value | Description | | ------------ | ------------- | -| WHOLE_WORD | Whole word matching| -| PREFIX | Prefix matching| -| REGULAR | Regular expression matching| +| WHOLE_WORD | Whole word matching | +| PREFIX | Prefix matching | +| REGULAR | Regular expression matching | -**Table 4** Description of HiSysEventSubscribeCallBackBase +**Table 4** Description of HiSysEventSubscribeCallBack -| API| Description| +| API| Description | | -------- | --------- | -|void HiSysEventSubscribeCallBackBase::OnHandle(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail)|Provides the callback of system events.

Input arguments:
  • **domain**: indicates the domain to which the event belongs.
  • **eventName**: indicates the event name.
  • **eventType**: indicates the event type.
  • **eventDetail**: indicates the event information, in JSON format.
Return value:
  None.| +|void HiSysEventSubscribeCallBack::OnHandle(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail)|Provides the callback of system events.

Input arguments:
  • **domain**: indicates the domain to which the event belongs.
  • **eventName**: indicates the event name.
  • **eventType**: indicates the event type.
  • **eventDetail**: indicates the event information, in JSON format.
Return value:
None.| ### Development Example @@ -66,16 +66,16 @@ C++ #include - class DemoListener : public OHOS::HiviewDFX::HiSysEventSubscribeCallBackNative { + class DemoListener : public OHOS::HiviewDFX::HiSysEventSubscribeCallBack { public: - explicit DemoListener() : HiSysEventSubscribeCallBackNative() {} + explicit DemoListener() : HiSysEventSubscribeCallBack() {} void OnHandle(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail); virtual ~DemoListener() {} void OnServiceDied(); }; - #endif DEMO_LISTENER_H + #endif // DEMO_LISTENER_H ``` Create the **DemoListener.cpp** file, and add the implementation logic of the custom event callback API in the **DemoListener** class. diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md index 03660c682780e822f41b93dd8394d480ddfa3994..8401862dae6b3bcdf4824334889bb9f6d28a37b6 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md @@ -13,16 +13,16 @@ HiSysEvent provides an API for you to query system events. You can query concern ### Available APIs -**Table 1** HiSysEvent query API +**Table 1** Description of the HiSysEvent query API -| API| Description| +| Name| Description | | -------- | --------- | -| bool HiSysEventManager::QueryHiSysEvent(struct QueryArg& queryArg, std::vector<QueryRule>& queryRules, std::shared_ptr<HiSysEventQueryCallBackBase> queryCallBack) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.

Input arguments:
  • **queryArg**: event query parameter.
  • **queryRules**: event filtering rules.
  • **queryCallBack**: callback object for query results.
Return value:
  • **true**: The query is successful.
  • **false**: The query has failed.
| +| bool HiSysEventManager::QueryHiSysEvent(struct QueryArg& queryArg, std::vector<QueryRule>& queryRules, std::shared_ptr<HiSysEventQueryCallBack> queryCallBack) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.

Input arguments:
  • **queryArg**: event query parameter.
  • **queryRules**: event filtering rules.
  • **queryRules**: callback object for query results.
Return value:
  • **true**: The query is successful.
  • **false**: The query has failed.
| **Table 2** Description of QueryArg -| Attribute| Description| +| Attribute| Description | | -------- | --------- | | beginTime | Start time, in the **long long int** format.| | endTime | End time, in the **long long int** format.| @@ -30,16 +30,16 @@ HiSysEvent provides an API for you to query system events. You can query concern **Table 3** Description of QueryRule -| API| Description| +| API| Description | | -------- | --------- | -| QueryRule(const std::string& domain, const std::vector<std::string>& eventList) | Constructor used to create a **QueryRule** object based on domain and event name list.

Input arguments:
  • **domain**:domain to which the event belongs, in the **string** format. By default, an empty string indicates that the domain is successfully matched.
  • **eventList**:event name list, in the std::vector<std::string> format. By default, an empty string indicates that the event names on the list are successfully matched.
| +| QueryRule(const std::string& domain, const std::vector<std::string>& eventList) | Constructor used to create a **QueryRule** object.

Input arguments:
  • **domain: domain to which the event of the **QueryRule** object belongs, in the **string** format. By default, an empty string indicates that the domain is successfully matched.
  • **eventList**: event name list, in the **std::vector<std::string>** format. By default, an empty string indicates that the event names on the list are successfully matched.
| -**Table 4** Description of HiSysEventQueryCallBackBase +**Table 4** Description of HiSysEventQueryCallBack -| API| Description| +| API| Description | | -------- | --------- | -| void HiSysEventQueryCallBackBase::OnQuery(const ::std::vector<std::string>& sysEvent, const ::std::vector<int64_t>& seq) | Callback object for event query.

Input arguments:
  • **sysEvent**: event set.
  • **seq**: event sequence set.
Return value:
  None.| -| void HiSysEventQueryCallBackBase::OnComplete(int32_t reason, int32_t total) | Callback object for completion of event query.

Input arguments:
  • **reason**: reason for completion of event query. The default value is **0**.
  • **total**: total number of events returned in this query.
Return value:
  None.| +| void HiSysEventQueryCallBack::OnQuery(const ::std::vector<std::string>& sysEvent, const ::std::vector<int64_t>& seq) | Callback object for event query.

Input arguments:
  • **sysEvent**: event set.
  • **seq**: event sequence set.
Return value:
None.| +| void HiSysEventQueryCallBack::OnComplete(int32_t reason, int32_t total) | Callback object for completion of event query.

Input arguments:
  • **reason**: reason for completion of event query. The default value is **0**.
  • **total**: total number of events returned in this query.
Return value:
None.| ### Development Example @@ -53,13 +53,13 @@ C++ - Implement the callback API. - void HiSysEventQueryCallBackBase::OnQuery\(const ::std::vector& sysEvent, const ::std::vector& seq\) + void HiSysEventQueryCallBack::OnQuery\(const ::std::vector<std::string>& sysEvent, const ::std::vector& seq\) - void HiSysEventQueryCallBackBase::OnComplete\(int32\_t reason, int32\_t total\) + void HiSysEventQueryCallBack::OnComplete\(int32\_t reason, int32\_t total\) - Invoke the query API in the corresponding service logic. - HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector& queryRules, std::shared\_ptr queryCallBack\) + HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector& queryRules, std::shared\_ptr queryCallBack\) ``` diff --git a/en/device-dev/subsystems/subsys-utils-guide.md b/en/device-dev/subsystems/subsys-utils-guide.md index 1988c6b9c43fb96ab6cd04a24fb5148dc8a3648e..6a6a786790f00aed60848586b64bb4861eb1738f 100644 --- a/en/device-dev/subsystems/subsys-utils-guide.md +++ b/en/device-dev/subsystems/subsys-utils-guide.md @@ -165,8 +165,8 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); ``` { "app": { - "bundleName": "com.huawei.launcher", - "vendor": "huawei", + "bundleName": "com.example.launcher", + "vendor": "example, "version": { "code": 1, "name": "1.0" @@ -189,7 +189,7 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); } }, "module": { - "package": "com.huawei.launcher", + "package": "com.example.launcher", "name": ".MyHarmonyAbilityPackage", "deviceType": [ "phone", "tv","tablet", "pc","car","smartWatch","sportsWatch","smartCamera" @@ -242,7 +242,7 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); 3. Send the command for running the native KV store application to the board through the serial port. ``` - ./nfs/dev_tools/bin/aa start -p com.huawei.launcher -n ServiceAbility + ./nfs/dev_tools/bin/aa start -p com.example.launcher -n ServiceAbility ``` diff --git a/en/readme/globalization.md b/en/readme/globalization.md index 8879c928bbf1fe37d567799e8d6b5ed50ea15af1..6fc2c3fa69e1d42d94290ad6b8103cad00842328 100755 --- a/en/readme/globalization.md +++ b/en/readme/globalization.md @@ -45,13 +45,6 @@ The directory structure of the Globalization subsystem for the mini and small sy │ │ │ └── src # Implementation code │ ├── interfaces # APIs │ │ └── innerkits # APIs for internal subsystems -├── cust_lite # Code repository for the Cust framework -│ ├── frameworks # Core code of the Cust framework -│ │ ├── cust_lite # Cust framework -│ │ │ ├── src # Implementation code -│ │ │ └── test # Test code -│ ├── interfaces # APIs -│ │ └── innerkits # APIs for internal subsystems ``` The directory structure of the Globalization subsystem for the standard system is as follows: @@ -78,8 +71,6 @@ The directory structure of the Globalization subsystem for the standard system i **Globalization subsystem** -global\_cust\_lite - global\_i18n\_lite global\_i18n\_standard diff --git a/en/release-notes/OpenHarmony-2-0-Canary.md b/en/release-notes/OpenHarmony-2-0-Canary.md index 4b366d447874c9623d2a9c9251df4ea5fdc2070d..b8b23c579d2136cf61b3c4ec15c60f2af303ce5a 100644 --- a/en/release-notes/OpenHarmony-2-0-Canary.md +++ b/en/release-notes/OpenHarmony-2-0-Canary.md @@ -1,4 +1,4 @@ -# OpenHarmony 2.0 Canary \(2021-06-02\) +# OpenHarmony 2.0 Canary \(2021-06-01\) ## Version Description @@ -78,7 +78,7 @@ repo forall -c'git lfs pull' | Source Code | Version | Mirror | SHA-256 Checksum | | -------- | -------- | -------- | -------- | | Full code base | 2.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.0/code-2.0-canary_20210601.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.0/code-2.0-canary_20210601.tar.gz.sha256) | -| Release Notes | 2.0 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-2-0-canary.md) | - | +| Release Notes | 2.0 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-2-0-Canary.md) | - | ## What's New diff --git a/en/release-notes/Readme.md b/en/release-notes/Readme.md index 3d7db33edefe2a101b45ed1c50ce4ee37ac5b872..38c48debb7aa5779a46baa4d62170d8f12d7296c 100644 --- a/en/release-notes/Readme.md +++ b/en/release-notes/Readme.md @@ -6,7 +6,7 @@ ## OpenHarmony 2.x Releases - [OpenHarmony v2.2 beta2 (2021-08-04)](OpenHarmony-v2.2-beta2.md) -- [OpenHarmony 2.0 Canary (2021-06-02)](OpenHarmony-2-0-Canary.md) +- [OpenHarmony 2.0 Canary (2021-06-01)](OpenHarmony-2-0-Canary.md) ## OpenHarmony 1.x Releases - [OpenHarmony v1.1.4 LTS (2022-02-11)](OpenHarmony-v1-1-4-LTS.md) - [OpenHarmony v1.1.3 LTS (2021-09-30)](OpenHarmony-v1-1-3-LTS.md) diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index 562b3b8779e67a26e251526f88fe6e0cfdf03900..59d832ea6745d2aec8bc216883437981b8d3a84c 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -1,20 +1,34 @@ # 应用开发 - [应用开发导读](application-dev-guide.md) -- [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) -- [包结构说明](quick-start/package-structure.md) -- [Ability框架](ability/Readme-CN.md) -- 方舟开发框架(ArkUI) - - [基于JS扩展的类Web开发范式](ui/ui-arkui-js.md) - - [基于TS扩展的声明式开发范式](ui/ui-arkui-ts.md) -- [后台代理提醒](background-agent-scheduled-reminder/Readme-CN.md) -- [后台任务管理](background-task-management/Readme-CN.md) -- [媒体](media/Readme-CN.md) -- [安全](security/Readme-CN.md) -- [网络与连接](connectivity/Readme-CN.md) -- [数据管理](database/Readme-CN.md) -- [USB服务](usb/Readme-CN.md) -- [DFX](dfx/Readme-CN.md) -- [WebGL](webgl/Readme-CN.md) -- [开发参考](reference/Readme-CN.md) - +- 了解OpenHarmony + - [了解OpenHarmony开源项目](../OpenHarmony-Overview_zh.md) + - [了解OpenHarmony系统](../readme) + - [术语](../device-dev/glossary/glossary.md) + - [版本说明](../release-notes/Readme.md) +- 快速开始 + - [应用开发快速入门](quick-start/Readme-CN.md) + - [应用开发包结构说明](quick-start/package-structure.md) +- 开发 + - [Ability开发](ability/Readme-CN.md) + - [UI开发](ui/Readme-CN.md) + - 基础功能开发 + - [后台代理提醒](background-agent-scheduled-reminder/Readme-CN.md) + - [后台任务管理](background-task-management/Readme-CN.md) + - [媒体](media/Readme-CN.md) + - [安全](security/Readme-CN.md) + - [网络与连接](connectivity/Readme-CN.md) + - [数据管理](database/Readme-CN.md) + - [USB服务](usb/Readme-CN.md) + - [DFX](dfx/Readme-CN.md) +- 工具 + - [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) +- 示例教程 + - [示例代码](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md) + - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) +- API参考 + - [组件参考(基于JS扩展的类Web开发范式)](reference/arkui-js/Readme-CN.md) + - [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/Readme-CN.md) + - [接口参考](reference/apis/Readme-CN.md) +- 贡献 + - [参与贡献](../contribute/贡献文档.md) \ No newline at end of file diff --git a/zh-cn/application-dev/ability/service-ability.md b/zh-cn/application-dev/ability/service-ability.md index 16ee1070629281cdd0dae21c54a7c85c489cd088..1cb7bc9a74ce85f501a1af09fc01c3201bcb380d 100644 --- a/zh-cn/application-dev/ability/service-ability.md +++ b/zh-cn/application-dev/ability/service-ability.md @@ -29,19 +29,19 @@ ```javascript export default { onStart(want) { - console.log('SerivceAbility onStart'); + console.log('ServiceAbility onStart'); }, onCommand(want, restart, startId) { - console.log('SerivceAbility onCommand'); + console.log('ServiceAbility onCommand'); }, onConnect(want) { - console.log('SerivceAbility OnConnect'); + console.log('ServiceAbility OnConnect'); }, onDisconnect() { - console.log('SerivceAbility OnDisConnect'); + console.log('ServiceAbility OnDisConnect'); }, onStop() { - console.log('SerivceAbility onStop'); + console.log('ServiceAbility onStop'); }, } ``` @@ -168,17 +168,17 @@ export default { mMyStub = new MyStub("ServiceAbility-test"); }, onCommand(want, restart, startId) { - console.log('SerivceAbility onCommand'); + console.log('ServiceAbility onCommand'); }, onConnect(want) { - console.log('SerivceAbility OnConnect'); + console.log('ServiceAbility OnConnect'); return mMyStub; }, onDisconnect() { - console.log('SerivceAbility OnDisConnect'); + console.log('ServiceAbility OnDisConnect'); }, onStop() { - console.log('SerivceAbility onStop'); + console.log('ServiceAbility onStop'); }, } ``` @@ -250,17 +250,17 @@ export default { mMyStub = new MyStub("ServiceAbility-test"); }, onCommand(want, restart, startId) { - console.log('SerivceAbility onCommand'); + console.log('ServiceAbility onCommand'); }, onConnect(want) { - console.log('SerivceAbility OnConnect'); + console.log('ServiceAbility OnConnect'); return mMyStub; }, onDisconnect() { - console.log('SerivceAbility OnDisConnect'); + console.log('ServiceAbility OnDisConnect'); }, onStop() { - console.log('SerivceAbility onStop'); + console.log('ServiceAbility onStop'); }, } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md b/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md index e1b2b4c62a663e7e916e67baf3245ca4240f48a8..bb77011ba0b4182153bf0bf1fdcace9e7d7f3d10 100644 --- a/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md +++ b/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md @@ -87,15 +87,15 @@ interface ReminderRequest: 需要发布的提醒实例的信息 interface ReminderRequestCalendar extends ReminderRequest: 日历类提醒实例。 -第一次指定的目标时间必须大于当前时间。 +如果没有指定重复的月或天,那么第一次指定的目标时间必须大于当前时间,否则应用将异常退出。 **表8** ReminderRequestCalendar | 参数名 | 类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| dateTime | LocalDataTime | 是 | 设置目标时间 | -| repeatMonths | Array<number> | 否 | 设置重复提醒的月份 | -| repeatDays | Array<number> | 否 | 设置重复提醒的日期 | +| dateTime | LocalDateTime | 是 | 设置目标时间(精确到分钟级别) | +| repeatMonths | Array<number> | 否 | 设置重复提醒的月份,范围从 1 到 12 | +| repeatDays | Array<number> | 否 | 设置重复提醒的日期,范围从 1 到 31 | interface ReminderRequestAlarm extends ReminderRequest: 闹钟类提醒实例。 @@ -103,9 +103,9 @@ interface ReminderRequestAlarm extends ReminderRequest: 闹钟类提醒实例。 | 参数名 | 类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| hour | number | 是 | 设置目标时间(小时) | -| minute | number | 是 | 设置目标时间(分钟) | -| daysOfWeek | Array<number> | 否 | 设置每个星期哪一天重复提醒 | +| hour | number | 是 | 设置目标时间(小时),范围从 0 到 23 | +| minute | number | 是 | 设置目标时间(分钟),范围从 0 到 59 | +| daysOfWeek | Array<number> | 否 | 设置每个星期哪一天重复提醒,范围从 1 到 7 | interface ReminderRequestTimer extends ReminderRequest:倒计时提醒实例 @@ -196,8 +196,8 @@ calendar: { minute: 14, second: 30 }, - repeatMonths: [0], - repeatDays: [0], + repeatMonths: [1], + repeatDays: [1], actionButton: [ { title: "close", diff --git a/zh-cn/application-dev/background-task-management/background-task-dev-guide.md b/zh-cn/application-dev/background-task-management/background-task-dev-guide.md index 2047780916748df3d73dabb48f13df84c9960e32..526670f34b77c05b51f9d146fe08330c51b3b48b 100644 --- a/zh-cn/application-dev/background-task-management/background-task-dev-guide.md +++ b/zh-cn/application-dev/background-task-management/background-task-dev-guide.md @@ -13,7 +13,7 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager'; ## 短时任务 -**表1** backgroundTaskManager主要接口 +**表1** 短时任务主要接口 | 接口名 | 描述 | | -------- | -------- | @@ -106,7 +106,7 @@ ohos.permission.KEEP_BACKGROUND_RUNNING | function stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void;
function stopBackgroundRunning(context: Context): Promise<void>; | 停止后台长时任务的运行 | -其中,wantAgent的信息详见([WantAgent](#zh-cn/application-dev/reference/apis/js-apis-notification.md#WantAgent接口)) +其中,wantAgent的信息详见([WantAgent](../reference/apis/js-apis-notification.md#WantAgent接口) **表4** 后台模式类型 diff --git a/zh-cn/application-dev/background-task-management/background-task-overview.md b/zh-cn/application-dev/background-task-management/background-task-overview.md index fa4c7330628333de635df896851dbb1c04b5cf6f..403126992ae84827af546d4d6acc32f70d1fd020 100644 --- a/zh-cn/application-dev/background-task-management/background-task-overview.md +++ b/zh-cn/application-dev/background-task-management/background-task-overview.md @@ -57,6 +57,6 @@ OpenHarmony提供了九种后台模式,供需要在后台做长时任务的业 ### 长时任务使用约束 - 如果用户选择可感知业务(如播音、导航、上传下载等),触发对应后台模式,在任务启动时,系统会强制弹出通知提醒用户。 - 如果任务结束,应用应主动退出后台模式。若在后台运行期间,系统检测到应用并未使用对应后台模式的资源,则会被挂起(Suspend)。 -- 避免不合理地申请后台长时任务,长时任务类型要与应用的业务类型匹配。如表1所示。如果执行的任务和申请的类型不匹配,也会被系统检测到并被挂起(Suspend)。 +- 避免不合理地申请后台长时任务,长时任务类型要与应用的业务类型匹配。如果执行的任务和申请的类型不匹配,也会被系统检测到并被挂起(Suspend)。 - 长时任务是为了真正在后台长时间执行某个任务,如果一个应用申请了长时任务,但在实际运行过程中,并未真正运行或执行此类任务时,也会被系统检测到并被挂起(Suspend)。 -- 每个Ability同一时刻只能申请运行一个长时任务。 \ No newline at end of file +- 一个Ability同一时刻只能申请运行一个长时任务。 \ No newline at end of file diff --git a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md index 3afd163afdff4f9780ae87250586ac40d637dd4e..5cc72d56f4fe05ca70ba36492e5e61c696dac9f4 100644 --- a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md +++ b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md @@ -8,7 +8,7 @@ ## 接口说明 注册相关接口包导入: ```js -import stats from '@ohos.usagestatskit'; +import stats from '@ohos.bundleState'; ``` **表1** 设备使用信息统计主要接口 @@ -38,188 +38,170 @@ import stats from '@ohos.usagestatskit'; } ``` -2. 通过指定起始和结束时间查询所有应用的事件集合。 +2. 通过指定起始和结束时间查询所有应用的事件集合,config.json中需要配置权限:ohos.permission.BUNDLE_ACTIVE_INFO。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.queryBundleActiveStates(0, 20000000000000).then( res => { - console.log('queryBundleActiveStates promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleActiveStates, promise bundleName = " + res[i].bundleName) - console.log("queryBundleActiveStates, promise stateType = " + res[i].stateType) - console.log("queryBundleActiveStates, promise stateOccurredTime = " + res[i].stateOccurredTime) + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryBundleActiveStates promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.queryBundleActiveStates(0, 20000000000000, (err, res) => { - console.log('queryBundleActiveStates callback succeeded, data number: ' + res.length); - if(err.data == 0) { - for (let i = 0; i < res.length; i++) { - console.log("queryBundleActiveStates, callback bundleName = " + res[i].bundleName) - console.log("queryBundleActiveStates, callback stateType = " + res[i].stateType) - console.log("queryBundleActiveStates, callback stateOccurredTime = " + res[i].stateOccurredTime) - } - } else { - console.log('queryBundleActiveStates callback failed, because: ' + err.data); + stats.queryBundleActiveStates(0, 20000000000000, (err, res) => { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i])); } - }) - }, 500); + } else { + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code); + } + }); ``` -3. 通过指定起始和结束时间查询应用使用时长统计信息。 +3. 通过指定起始和结束时间查询应用使用时长统计信息,config.json中需要配置权限:ohos.permission.BUNDLE_ACTIVE_INFO。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.queryBundleStateInfos(0, 20000000000000).then( res => { - console.log('queryBundleStateInfos promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.'); + let i = 1; for(let key in res){ - console.log("queryBundleStateInfos promise key = " + key) - console.log("queryBundleStateInfos promise bundleName = " + res[key].bundleName) - console.log("queryBundleStateInfos promise abilityPrevAccessTime = " + res[key].abilityPrevAccessTime) - console.log("queryBundleStateInfos promise abilityInFgTotalTime = " + res[key].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise number : ' + i); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key])); + i++; } }).catch( err => { - console.log('queryBundleStateInfos promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.queryBundleStateInfos(0, 20000000000000,(err, res) => { - console.log('queryBundleStateInfos callback succeeded, data number: ' + res.length); - if(err.data == 0) { - for(let key in res){ - console.log("queryBundleStateInfos callback key = " + key) - console.log("queryBundleStateInfos callback bundleName = " + res[key].bundleName) - console.log("queryBundleStateInfos callback abilityPrevAccessTime = " + res[key].abilityPrevAccessTime) - console.log("queryBundleStateInfos callback abilityInFgTotalTime = " + res[key].abilityInFgTotalTime) - } - } else { - console.log('queryBundleStateInfos callback failed, because: ' + err.data); + stats.queryBundleStateInfos(0, 20000000000000, (err, res) => { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.'); + let i = 1; + for(let key in res){ + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback number : ' + i); + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key])); + i++; } - }) - }, 500); + } else { + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code); + } + }); ``` -4. 通过指定起始和结束时间查询当前应用的事件集合。 +4. 通过指定起始和结束时间查询当前应用的事件集合,config.json中不需要配置权限。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.queryCurrentBundleActiveStates(0, 20000000000000).then( res => { - console.log('queryCurrentBundleActiveStates promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryCurrentBundleActiveStates, promise bundleName = " + res[i].bundleName) - console.log("queryCurrentBundleActiveStates, promise stateType = " + res[i].stateType) - console.log("queryCurrentBundleActiveStates, promise stateOccurredTime = " + res[i].stateOccurredTime) + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryCurrentBundleActiveStates promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.queryCurrentBundleActiveStates(0, 20000000000000,(err, res) => { - console.log('queryCurrentBundleActiveStates callback succeeded, data number: ' + res.length); - if(err.data == 0) { - for (let i = 0; i < res.length; i++) { - console.log("queryCurrentBundleActiveStates, callback bundleName = " + res[i].bundleName) - console.log("queryCurrentBundleActiveStates, callback stateType = " + res[i].stateType) - console.log("queryCurrentBundleActiveStates, callback stateOccurredTime = " + res[i].stateOccurredTime) - } - } else { - console.log('queryCurrentBundleActiveStates callback failed, because: ' + err.data); - } - }) - }, 500); + stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i])); + } + } else { + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code); + } + }); ``` -5. 通过指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。 +5. 通过指定时间段间隔(天、周、月、年)查询应用使用时长统计信息,config.json中需要配置权限:ohos.permission.BUNDLE_ACTIVE_INFO。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => { - console.log('queryBundleStateInfoByInterval promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleStateInfoByInterval, promise bundleName = " + res[i].bundleName) - console.log("queryBundleStateInfoByInterval, promise abilityPrevAccessTime = " + res[i].abilityPrevAccessTime) - console.log("queryBundleStateInfoByInterval, promise abilityInFgTotalTime = " + res[i].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryBundleStateInfoByiInterval promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.queryBundleStateInfoByInterval(0, 0, 20000000000000,(err, res) => { - console.log('queryBundleStateInfoByInterval callback succeeded, data number: ' + res.length); - if(err.data == 0) { - for (let i = 0; i < res.length; i++) { - console.log("queryBundleStateInfoByInterval, callback bundleName = " + res[i].bundleName) - console.log("queryBundleStateInfoByInterval, callback abilityPrevAccessTime = " + res[i].abilityPrevAccessTime) - console.log("queryBundleStateInfoByInterval, callback abilityInFgTotalTime = " + res[i].abilityInFgTotalTime) - } - } else { - console.log('queryBundleStateInfoByInterval callback failed, because: ' + err.data); + stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i])); } - }) - }, 500); + } else { + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code); + } + }); ``` -6. 查询(返回)当前调用者应用的使用优先级群组。 +6. 查询(返回)当前调用者应用的使用优先级群组,config.json中不需要配置权限。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.queryAppUsagePriorityGroup().then( res => { - console.log('queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); }).catch( err => { - console.log('queryAppUsagePriorityGroup promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.queryAppUsagePriorityGroup((err, res) => { - if(err.data === 0) { - console.log('queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); - } else { - console.log('queryAppUsagePriorityGroup callback failed, because: ' + err.data); - } - }) - }, 500); + stats.queryAppUsagePriorityGroup((err, res) => { + if(err.code === 0) { + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); + } else { + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code); + } + }); ``` -7. 判断指定Bundle Name的应用当前是否是空闲状态。 +7. 判断指定Bundle Name的应用当前是否是空闲状态,config.json中不需要配置权限。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.isIdleState("com.ohos.camera").then( res => { - console.log('isIdleState promise succeeded. result: ' + JSON.stringify(res)); + console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res)); }).catch( err => { - console.log('isIdleState promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.isIdleState("com.ohos.camera", (err, res) => { - if(err.data === 0) { - console.log('isIdleState callback succeeded. result: ' + JSON.stringify(res)); - } else { - console.log('isIdleState callback failed, because: ' + err.data); - } - }) - }, 500); + stats.isIdleState("com.ohos.camera", (err, res) => { + if(err.code === 0) { + console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res)); + } else { + console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code); + } + }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-overview.md b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-overview.md index 2044ec8683c6b9c2b7c9e5b81daa9ce3248aa285..66c2ea874ae4a1a8edf2403db20f81d53045835f 100644 --- a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-overview.md +++ b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-overview.md @@ -20,5 +20,5 @@ >6. 判断指定应用当前是否是空闲状态; ### 设备使用信息统计使用权限 -- 设备使用信息统计接口只对系统应用开放,三方应用不可调用。 -- 系统应用调用设备使用信息统计接口前,必须申请ohos.permission.BUNDLE_ACTIVE_INFO权限。 \ No newline at end of file +- 设备使用信息统计的queryBundleActiveStates、queryBundleStateInfos、queryBundleStateInfoByInterval接口为系统api,调用前需要申请ohos.permission.BUNDLE_ACTIVE_INFO权限。 +- 设备使用信息统计的queryCurrentBundleActiveStates、queryAppUsagePriorityGroup、isIdleState接口为三方api,调用时不需要申请权限。 \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/package-structure.md b/zh-cn/application-dev/quick-start/package-structure.md index 43a78f2056ea1384f1774aa853937b671a428078..599bd61b6d33b2da7e112710c570a9278a96be8a 100644 --- a/zh-cn/application-dev/quick-start/package-structure.md +++ b/zh-cn/application-dev/quick-start/package-structure.md @@ -88,7 +88,7 @@ app对象包含应用全局配置信息,内部结构说明参见表2。 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------- | ------------------------------------------------------------ | -------- | ------------------ | -| bundleName | 表示应用的包名,用于标识应用的唯一性。包名是由字母、数字、下划线(_)和点号(.)组成的字符串,必须以字母开头。支持的字符串长度为7~127字节。包名通常采用反域名形式表示(例如,"com.example.myapplication")。建议第一级为域名后缀"com",第二级为厂商/个人名,也可以采用多级。 | 字符串 | 否 | +| bundleName | 表示应用的包名,用于标识应用的唯一性。包名是由字母、数字、下划线(_)和点号(.)组成的字符串,必须以字母开头。支持的字符串长度为7~127字节。包名通常采用反向域名形式表示(例如,"com.example.myapplication")。建议第一级为域名后缀"com",第二级为厂商/个人名,也可以采用多级。 | 字符串 | 否 | | vendor | 表示对应用开发厂商的描述。字符串长度不超过255字节。 | 字符串 | 可缺省,缺省值为空 | | version | 表示应用的版本信息。参考表3。 | 对象 | 否 | | apiVersion | 标识应用程序所依赖的OpenHarmony API版本。参考表4。 | 对象 | 可缺省,缺省值为空 | @@ -97,8 +97,8 @@ app对象包含应用全局配置信息,内部结构说明参见表2。 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------------------ | ------------------------------------------------------------ | -------- | -------------------------- | -| name | 表示应用的版本号,用于向应用的终端用户呈现。取值可以自定义,长度不超过127字节。自定义规则如下:
API5及更早的版本:推荐使用三段数字版本号(也兼容两段式版本号),如A.B.C(也兼容A.B),其中A、B、C取值为0-999范围内的整数。初次之外不支持其他格式。
A段,一般表示主版本号(Major)。
B段,一般表示次版本号(Minor)。
C段,一般表示修订版本号(Patch)。
API6版本起:推荐采用四段式数字版本号,如A.B.C.D,其中A、B、C取值为0-99范围内的整数,D的取值为0-999范围内的整数。
A段,一般表示主版本号(Major)。
B段,一般表示次版本号(Minor)。
C段,一般表示特性版本号(Feature)。
D段,一般表示修订版本号(Patch)。 | 数值 | 不可缺省 | -| code | 表示应用的版本号,仅用于OpenHarmony管理该应用,不对应用的终端用户呈现。取值规则如下:
API5及更早版本:二进制32位以内的非负整数,需要从version.name的值转换得到。转换规则为:
code值=A * 1,000,000 + B * 1,000 + C 例如,version.name字段取值为2.2.1,则code值为2002001。
API6版本起:code的取值不与version.name字段的取值关联,开发者可自定义code取值,取值范围为2^31的非负整数,但是每次应用版本的更新,均需要更新code字段的值,新版本code取值必须大于旧版本code的值。 | 数值 | 不可缺省 | +| name | 表示应用的版本号,用于向应用的终端用户呈现。取值可以自定义,长度不超过127字节。自定义规则如下:
API5及更早的版本:推荐使用三段数字版本号(也兼容两段式版本号),如A.B.C(也兼容A.B),其中A、B、C取值为0-999范围内的整数。除此之外不支持其他格式。
A段,一般表示主版本号(Major)。
B段,一般表示次版本号(Minor)。
C段,一般表示修订版本号(Patch)。
API6版本起:推荐采用四段式数字版本号,如A.B.C.D,其中A、B、C取值为0-99范围内的整数,D的取值为0-999范围内的整数。
A段,一般表示主版本号(Major)。
B段,一般表示次版本号(Minor)。
C段,一般表示特性版本号(Feature)。
D段,一般表示修订版本号(Patch)。 | 数值 | 不可缺省 | +| code | 表示应用的版本号,仅用于OpenHarmony管理该应用,不对应用的终端用户呈现。取值规则如下:
API5及更早版本:二进制32位以内的非负整数,需要从version.name的值转换得到。转换规则为:
code值=A * 1,000,000 + B * 1,000 + C 例如,version.name字段取值为2.2.1,则code值为2002001。
API6版本起:code的取值不与version.name字段的取值关联,开发者可自定义code取值,取值范围为2^31以内的非负整数,但是每次应用版本的更新,均需要更新code字段的值,新版本code取值必须大于旧版本code的值。 | 数值 | 不可缺省 | | minCompatibleVersionCode | 表示应用可兼容的最低版本号,用于跨设备场景下,判断其他设备上该应用的版本是否兼容。
格式与version.code字段的格式要求相同。 | 数值 | 可缺省,缺省值为code标签值 | 表4 apiVersion内部结构 @@ -107,7 +107,7 @@ app对象包含应用全局配置信息,内部结构说明参见表2。 | ----------- | ----------------------------------------------------------- | -------- | ---------- | | compatible | 运行应用所需要的最低API版本,取值范围为0~2147483647。 | 整数 | 可缺省 | | target | 用于标识应用运行所需的目标API版本,取值范围为0~2147483647。 | 整数 | 可缺省 | -| releaseType | 用于标识应用运行所需的目标API版本。 | 字符串 | 可缺省 | +| releaseType | 用于标识应用运行所需的目标API版本的类型。 | 字符串 | 可缺省 | app实例: @@ -149,7 +149,7 @@ default、phone、tablet、tv、car、wearable、liteWearble等对象的内部 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------------ | ------------------------------------------------------------ | -------- | ----------------------- | -| process | 表示应用或者Ability的进程名。如果在deviceConfig标签下配置了process标签,则该应用的所有Ability都运行在这个进程中。如果在abilities标签下也为某个Ability配置了process标签,则该Ability就运行在这个进程中。该标签仅适用于手机、平板、智慧屏、车机、智慧穿戴。 | 字符串 | 是 | +| process | 表示应用或者Ability的进程名。如果在deviceConfig标签下配置了process标签,则该应用的所有Ability都运行在这个进程中。如果在abilities标签下也为某个Ability配置了process标签,则该Ability就运行在这个进程中。该标签仅适用于手机、平板、智慧屏、车机、智慧穿戴。该标签最大长度为31。 | 字符串 | 是 | | supportBackup | 表示应用是否支持备份和恢复。如果配置为"false",则不支持为该应用执行备份或恢复操作。
该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为"false" | | compressNativeLibs | 表示libs库是否以压缩存储的方式打包到HAP包。如果配置为"false",则libs库以不压缩的方式存储,HAP包在安装时无需解压libs,运行时会直接从HAP内加载libs库。
该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为"true" | | directLaunch | 指定设备被锁定时是否可以启动应用程序。如果要在不解锁设备的情况下启动应用程序,请将此设备设置为"true"。运行OHOS的设备不支持此属性。 | 布尔值 | 可缺省,缺省值为"false" | @@ -165,10 +165,10 @@ default、phone、tablet、tv、car、wearable、liteWearble等对象的内部 表8 reqVersion对象内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ---------- | ------------------------------- | -------- | ---------- | -| compatible | 表示支持应用程序的最低maple版本 | 整数 | 不可缺省 | -| target | 指定maple应用程序的类型 | 整数 | 不可缺省 | +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ---------- | -------------------------------------------------------- | -------- | ---------- | +| compatible | 表示支持应用程序的最低maple版本,采用32位无符号整形表示。 | 整数 | 不可缺省 | +| target | 指定maple应用程序的类型,采用32位无符号整形表示。 | 整数 | 不可缺省 | 表9 network对象的内部结构说明 @@ -181,7 +181,7 @@ default、phone、tablet、tv、car、wearable、liteWearble等对象的内部 | 属性名称 | 子属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------------- | ------------------ | ------------------------------------------------------------ | -------- | ---------------- | -| domainSettings | - | 表示自定义的网域范围的安全配置,支持多层嵌套,即一个domainSettings对象中允许嵌套更小网域范围的domainSettings对象。 | 布尔类型 | 可缺省,缺省为空 | +| domainSettings | - | 表示自定义的网域范围的安全配置,支持多层嵌套,即一个domainSettings对象中允许嵌套更小网域范围的domainSettings对象。 | 对象类型 | 可缺省,缺省为空 | | | cleartextPermitted | 表示自定义的网域范围内是否允许明文流量传输。当cleartextTraffic和security同时存在时,自定义网域是否允许明文流量传输以cleartextPermitted的取值为准。
true:允许明文流量传输。
false:拒绝明文流量传输 | 布尔类型 | 否 | | | domains | 表示域名配置信息,包含两个参数:subdomains和name。
subdomains(布尔类型):表示是否包含子域名。如果为"true",此网域规则将与相应网域及所有子网域(包括子网域的子网域)匹配。否则,该规则仅适用于精确匹配项。
name(字符串):表示域名名称 | 对象数组 | 否 | @@ -231,11 +231,11 @@ module对象包含HAP包的配置信息,内部结构说明参见表11。 | shortcuts | 表示应用的快捷方式信息。采用对象数组格式,其中的每个元素表示一个快捷方式对象。参考表25。 | 对象数组 | 可缺省,缺省值为空 | | reqPermissions | 表示应用运行时向系统申请的权限。参考表21。 | 对象数组 | 可缺省,缺省值为空 | | colorMode | 表示应用自身的颜色模式。
dark:表示按照深色模式选取资源。
light:表示按照浅色模式选取资源。
auto:表示跟随系统的颜色模式值选取资源。
该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"auto" | -| distroFilter | 表示应用的分发规则。
该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括API Verion、屏幕形状、屏幕分辨率。在进行分发时,通过deviceType与这三个属性的匹配关系,唯一确定一个用于分发到设备的HAP。参考表29。 | 对象数组 | 可缺省,缺省值为空。但当应用中包含多个entry模块时,必须配置该标签。 | +| distroFilter | 表示应用的分发规则。
该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括API Verion、屏幕形状、屏幕分辨率。在进行分发时,通过deviceType与这三个属性的匹配关系,唯一确定一个用于分发到设备的HAP。参考表29。 | 对象 | 可缺省,缺省值为空。但当应用中包含多个entry模块时,必须配置该标签。 | | reqCapabilities | 表示运行应用程序所需的设备能力 | 字符串数组 | 可缺省,缺省为空 | -| commonEvents | 静态广播,参考表33。 | 对象数组 | 可缺省,缺省为空 | +| commonEvents | 静态广播,参考表35。 | 对象数组 | 可缺省,缺省为空 | | allowClassMap | HAP的元信息。标记值为true或false。如果标记值为true,则hap使用OpenHarmony框架提供的Java对象代理机制。默认值为false。 | 布尔值 | 不可缺省,缺省值为false | -| entryTheme | 此标签表示OpenHarmony内部主题的关键字。将标记值设置为名称的资源索引 | 字符串 | 可缺省,缺省值为 | +| entryTheme | 此标签表示OpenHarmony内部主题的关键字。将标记值设置为名称的资源索引 | 字符串 | 可缺省,缺省值为空 | module示例: @@ -275,7 +275,7 @@ module示例: | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------------- | ------------------------------------------------------------ | -------- | ---------- | -| moduleName | 表示当前HAP的名称。 | 字符串 | 不可缺省 | +| moduleName | 表示当前HAP的名称,最大长度为31。 | 字符串 | 不可缺省 | | moduleType | 表示当前HAP的类型,包括两种类型:entry和feature。另外,如果表示HAR类型,请设置为har。 | 字符串 | 不可缺省 | | installationFree | 表示当前HAP是否支持免安装特性。
true:表示支持免安装特性,且符合免安装约束。
false:表示不支持免安装特性。
另外还需注意:
当entry.hap该字段配置为true时,与该entry.hap相关的所有feature.hap该字段也需要配置为true。
当entry.hap该字段配置为false时,与该entry.hap相关的各feature.hap该字段可按业务 需求配置true或false。 | 布尔值 | 否 | @@ -291,25 +291,26 @@ distro示例: 表13 metaData对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ---------- | ------------------------------------------------------------ | -------- | -------------------- | -| parameters | 表示调用Ability时所有调用参数的元信息。每个调用参数参数的元信息由一下三个标签组成:description、name、type。参考表14。 | 对象 | 可缺省,缺省值为空 | -| results | 表示Ability返回值的元信息。每个返回值的元信息由以下三个标签组成:description、name、type。参考表15。 | 对象 | 可缺省,缺省值为空。 | +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ------------- | ------------------------------------------------------------ | -------- | -------------------- | +| parameters | 表示调用Ability时所有调用参数的元信息。每个调用参数的元信息由以下三个标签组成:description、name、type。参考表14。 | 对象数组 | 可缺省,缺省值为空 | +| results | 表示Ability返回值的元信息。每个返回值的元信息由以下三个标签组成:description、name、type。参考表15。 | 对象数组 | 可缺省,缺省值为空。 | +| customizeData | 该标签标识父级组件的自定义元信息,Parameters和results在application不可配。参考表16 | 对象数组 | 可缺省,缺省值为空。 | 表14 parameters对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ----------- | ------------------------------------------------------------ | -------- | ------------------ | -| description | 表示对调用参数的描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。 | 字符串 | 可缺省,缺省值为空 | -| name | 表示调用参数的名称。 | 字符串 | 可缺省,缺省值为空 | +| description | 表示对调用参数的描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空 | +| name | 表示调用参数的名称。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空 | | type | 表示调用参数的类型,如Integer。 | 字符串 | 不可缺省 | 表15 results对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ----------- | ------------------------------------------------------------ | -------- | -------------------- | -| description | 表示对返回值的描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。 | 字符串 | 可缺省,缺省值为空。 | -| name | 表示返回值的名字。 | 字符串 | 可缺省,缺省值为空。 | +| description | 表示对返回值的描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | +| name | 表示返回值的名字。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | | type | 表示返回值的类型,如Integer。 | 字符串 | 否 | 表16 customizeData对象的内部结构说明 @@ -317,7 +318,7 @@ distro示例: | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ---------------------------------------------------------- | -------- | -------------------- | | name | 表示数据项的键名称,字符串类型(最大长度255字节)。 | 字符串 | 可缺省,缺省值为空。 | -| value | 表示数据项的键名称,字符串类型(最大长度255字节)。 | 字符串 | 可缺省,缺省值为空。 | +| value | 表示数据项的值名称,字符串类型(最大长度255字节)。 | 字符串 | 可缺省,缺省值为空。 | | extra | 表示用户自定义数据格式,标签值为标识该数据的资源的索引值。 | 字符串 | 可缺省,缺省值为空。 | metaData示例: @@ -347,11 +348,11 @@ metaData示例: | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------------- | ------------------------------------------------------------ | ---------- | -------------------------------------------------------- | | process | 运行应用程序或Ability的进程名称。如果在deviceConfig标记中配置了进程,则应用程序的所有能力都在此进程中运行。您还可以为特定能力设置流程属性,以便该能力可以在此流程中运行。如果此属性设置为与其他应用程序相同的进程名称,则所有这些应用程序可以在同一进程中运行,前提是他们具有相同的联合用户ID和相同的签名。运行OHOS的设备不支持此属性。 | 字符串 | 可缺省,缺省值为空。 | -| name | 表示Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如“com.example.myapplication.MainAbility”;也可采用“.”开头的类名方式表示,如“.MainAbility”。
Ability的名称,需在一个应用的范围内保证唯一。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。
说明:在使用DevEco Studio新建项目时,默认生成首个Ability的配置,包括生成“MainAbility.java”文件,及“config.json”中“MainAbility”的配置。如使用其他IDE工具,可自定义名称。 | 字符串 | 否 | -| description | 表示对Ability的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。 | 字符串 | 可缺省,缺省值为空。 | +| name | 表示Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如“com.example.myapplication.MainAbility”;也可采用“.”开头的类名方式表示,如“.MainAbility”。
Ability的名称,需在一个应用的范围内保证唯一。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。
说明:在使用DevEco Studio新建项目时,默认生成首个Ability的配置,包括生成“MainAbility.java”文件,及“config.json”中“MainAbility”的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127。 | 字符串 | 否 | +| description | 表示对Ability的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | | icon | 表示Ability图标资源文件的索引。取值示例:$media:ability_icon。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的icon将同时作为应用的icon。如果存在多个符合条件的Ability,则取位置靠前的Ability的icon作为应用的icon。
说明:应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。 | 字符串 | 可缺省,缺省值为空。 | -| label | 表示Ability对用户显示的名称。取值可以是Ability名称,也可以是对该名称的资源索引,以支持多语言。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。
说明: 应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。 | 字符串 | 可缺省,缺省值为空。 | -| uri | 表示Ability的统一资源标识符。 | 字符串 | 可缺省,对于data类型的Ability不可缺省。 | +| label | 表示Ability对用户显示的名称。取值可以是Ability名称,也可以是对该名称的资源索引,以支持多语言。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。
说明: 应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | +| uri | 表示Ability的统一资源标识符。该标签最大长度为255。 | 字符串 | 可缺省,对于data类型的Ability不可缺省。 | | launchType | 表示Ability的启动模式,支持“standard”、“singleMission”和“singleton”三种模式:
standard:表示该Ability可以有多实例。
“standard”模式适用于大多数应用场景。
singleMission:表示此Ability在每个任务栈中只能有一个实例。
singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用“singleton”模式。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为“standard”。 | | visible | 表示Ability是否可以被其他应用调用。
true:可以被其他应用调用。
false:不能被其他应用调用。 | 布尔类型 | 可缺省,缺省值为“false”。 | | permissions | 表示其他应用的Ability调用此Ability时需要申请的权限。通常采用反向域名格式,取值可以是系统预定义的权限,也可以是开发者自定义的权限。 | 字符串数组 | 可缺省,缺省值为空。 | @@ -373,14 +374,14 @@ metaData示例: | forms | 表示服务卡片的属性。该标签仅当formsEnabled为“true”时,才能生效。参考表27。 | 对象数组 | 可缺省,缺省值为空。 | | srcLanguage | Ability开发语言的类型。 | 字符串 | 取值为java、js或ets | | srcPath | 该标签表示Ability对应的JS组件代码路径 | 字符串 | 可缺省,缺省值为空。 | -| uriPermission | 表示该Ability有权访问的应用程序数据。此属性由模式和路径子属性组成。此属性仅对类型提供的能力有效。运行OHOS的设备不支持此属性。参考表18。 | 对象 | 可缺省,缺省值为空。 | +| uriPermission | 表示该Ability有权访问的应用程序数据。此属性由模式和路径子属性组成。此属性仅对类型提供者的能力有效。运行OHOS的设备不支持此属性。参考表18。 | 对象 | 可缺省,缺省值为空。 | 表18 uriPermission对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ----------------------- | -------- | ----------------------- | -| path | uriPermission标识的路径 | 字符串 | 不可缺省 | -| mode | uriPeimission的匹配模式 | 字符串 | 可缺省,缺省值为false。 | +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ----------------------- | -------- | ------------------------- | +| path | uriPermission标识的路径 | 字符串 | 不可缺省 | +| mode | uriPeimission的匹配模式 | 字符串 | 可缺省,缺省值为default。 | abilities示例: @@ -457,13 +458,15 @@ abilities示例: 表20 uris对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------- | -------- | -------------------- | -| scheme | 表示uri的scheme值。 | 字符串 | 不可缺省。 | -| host | 表示uri的host值。 | 字符串 | 可缺省,缺省值为空。 | -| port | 表示uri的port值。 | 字符串 | 可缺省,缺省值为空。 | -| path | 表示uri的path值。 | 字符串 | 可缺省,缺省值为空。 | -| type | 表示uri的type值。 | 字符串 | 可缺省,缺省值为空。 | +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ------------- | -------------------------- | -------- | -------------------- | +| scheme | 表示uri的scheme值。 | 字符串 | 不可缺省。 | +| host | 表示uri的host值。 | 字符串 | 可缺省,缺省值为空。 | +| port | 表示uri的port值。 | 字符串 | 可缺省,缺省值为空。 | +| pathStartWith | 表示uri的pathStartWith值。 | 字符串 | 字符串 | +| path | 表示uri的path值。 | 字符串 | 可缺省,缺省值为空。 | +| pathRegx | 表示uri的pathRegx值。 | 字符串 | 可缺省,缺省值为空。 | +| type | 表示uri的type值。 | 字符串 | 可缺省,缺省值为空。 | skills示例: @@ -491,11 +494,11 @@ skills示例: 表21 reqPermissions权限申请字段说明 -| 属性名称 | 含义 | **类型** | **取值范围** | **默认值** | **规则约束** | -| --------- | ------------------------------------------------------------ | ------------------------------- | ----------------------------------------------------------- | ---------------------- | ------------------------------------------------------------ | -| name | 必须,填写需要使用的权限名称。 | 字符串 | 自定义 | 无 | 未填写时,解析失败。 | -| reason | 可选,当申请的权限为user_grant权限时此字段必填。描述申请权限的原因。 | 字符串 | 显示文字长度不能超过256个字节。 | 空 | user_grant权限必填,否则不允许在应用市场上架。需做多语种适配。 | -| usedScene | 可选,当申请的权限为user_grant权限时此字段必填。描述权限使用的场景和时机。场景类型有:ability、when(调用时机)。可配置多个ability。 | ability:字符串数组when:字符串 | ability:ability的名称when:inuse(使用时)、always(始终) | ability:空when:inuse | user_grant权限必填ability,可选填when。 | +| 属性名称 | 含义 | **类型** | **取值范围** | **默认值** | **规则约束** | +| --------- | ------------------------------------------------------------ | -------- | ----------------------------------------------------------- | ---------------------- | ------------------------------------------------------------ | +| name | 必须,填写需要使用的权限名称。 | 字符串 | 自定义 | 无 | 未填写时,解析失败。 | +| reason | 可选,当申请的权限为user_grant权限时此字段必填。描述申请权限的原因。 | 字符串 | 显示文字长度不能超过256个字节。 | 空 | user_grant权限必填,否则不允许在应用市场上架。需做多语种适配。 | +| usedScene | 可选,当申请的权限为user_grant权限时此字段必填。描述权限使用的场景和时机。场景类型有:ability、when(调用时机)。可配置多个ability。 | 对象 | ability:ability的名称when:inuse(使用时)、always(始终) | ability:空when:inuse | user_grant权限必填ability,可选填when。 | 表22 js对象的内部结构说明 @@ -516,10 +519,10 @@ skills示例: 表24 mode对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | -------------------- | ----------------------------------- | -------------------------- | -| type | 定义JS组件的功能类型 | 字符串,取值为"pageAbility"、"form" | 可缺省,缺省值为pageAbilit | -| syntax | 定义JS组件的语法类型 | 字符串,取值为"hml","ets" | 是,默认值为"hml" | +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | -------------------- | ----------------------------------- | --------------------------- | +| type | 定义JS组件的功能类型 | 字符串,取值为"pageAbility"、"form" | 可缺省,缺省值为pageAbility | +| syntax | 定义JS组件的语法类型 | 字符串,取值为"hml","ets" | 是,默认值为"hml" | js示例: @@ -546,6 +549,7 @@ js示例: | ---------- | ------------------------------------------------------------ | -------- | ------------------ | | shortcutId | 表示快捷方式的ID。字符串的最大长度为63字节。 | 字符串 | 否 | | label | 表示快捷方式的标签信息,即快捷方式对外显示的文字描述信息。取值可以是描述性内容,也可以是标识label的资源索引。字符串最大长度为63字节。 | 字符串 | 可缺省,缺省为空。 | +| icon | 表示快捷方式的图标信息。取值为表示icon的资源索引。 | 字符串 | 可缺省,缺省为空。 | | intents | 表示快捷方式内定义的目标intent信息集合,每个intent可配置两个子标签,targetClass, targetBundle。参考表26。 | 对象数组 | 可缺省,缺省为空。 | 表26 intents对象的内部结构说明 @@ -588,7 +592,7 @@ shortcuts示例: | updateEnabled | 表示卡片是否支持周期性刷新,取值范围:
true:表示支持周期性刷新,可以在定时刷新(updateDuration)和定点刷新(scheduledUpdateTime)两种方式任选其一,优先选择定时刷新。
false:表示不支持周期性刷新。 | 布尔类型 | 否 | | scheduledUpdateTime | 表示卡片的定点刷新的时刻,采用24小时制,精确到分钟。 | 字符串 | 可缺省,缺省值为“0:0”。 | | updateDuration | 表示卡片定时刷新的更新周期,单位为30分钟,取值为自然数。
当取值为0时,表示该参数不生效。
当取值为正整数N时,表示刷新周期为30*N分钟。 | 数值 | 可缺省,缺省值为“0”。 | -| formConfigAbility | 表示卡片的配置跳转链接,采用URI格式。 | 字符串 | 可缺省,缺省值为空。 | +| formConfigAbility | 表示用于调整卡片的设施或活动的名称。 | 字符串 | 可缺省,缺省值为空。 | | formVisibleNotify | 标识是否允许卡片使用卡片可见性通知 | 字符串 | 可缺省,缺省值为空。 | | jsComponentName | 表示JS卡片的Component名称。字符串最大长度为127字节。仅当卡片类型为JS卡片时,需要配置该标签。 | 字符串 | 否 | | metaData | 表示卡片的自定义信息,包含customizeData数组标签。参考表13。 | 对象 | 可缺省,缺省值为空。 | @@ -596,10 +600,11 @@ shortcuts示例: 表28 customizeData对象内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | --------------------------------------------- | -------- | -------------------- | -| name | 表示数据项的键名称。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省值为空。 | -| value | 表示数据项的值。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省值为空。 | +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | --------------------------------------------------- | -------- | -------------------- | +| name | 表示数据项的键名称。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省值为空。 | +| value | 表示数据项的值。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省值为空。 | +| extra | 表示当前custom数据的格式,取值为表示extra的资源值。 | 字符串 | 可缺省,缺省值为空。 | forms示例: @@ -656,11 +661,13 @@ forms示例: 表29 distroFilter对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------------ | ------------------------------------------------------------ | -------- | ---------- | -| apiVersion | 表示支持的apiVersion范围。参考表30。 | 对象数组 | 可选 | -| screenShape | 表示屏幕形状的支持策略。参考表31。 | 对象数组 | 可选 | -| screenWindow | 表示应用运行时窗口的分辨率支持策略。该字段仅支持对轻量级智能穿戴设备进行配置。参考表32。 | 对象数组 | 可选 | +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ------------- | ------------------------------------------------------------ | -------- | ---------- | +| apiVersion | 表示支持的apiVersion范围。参考表30。 | 对象 | 可选 | +| screenShape | 表示屏幕形状的支持策略。参考表31。 | 对象数组 | 可选 | +| screenWindow | 表示应用运行时窗口的分辨率支持策略。该字段仅支持对轻量级智能穿戴设备进行配置。参考表32。 | 对象数组 | 可选 | +| screenDensity | 表示屏幕的像素密度(dpi:Dots Per Inch)。参考表33。 | 对象数组 | 可选 | +| countryCode | 表示分发应用时的国家码。具体值参考ISO-3166-1的标准,支持多个国家和地区的枚举定义。参考表34。 | 对象数组 | 可选 | 表30 apiVersion对象的内部结构说明 @@ -683,28 +690,48 @@ forms示例: | policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | | value | 单个字符串的取值格式为:“宽 * 高”,取值为整数像素值,例如“454 * 454”。 | 数组 | 可缺省,缺省值为空。 | +表33 screenDensity对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 取值范围如下:
sdpi:表示小规模的屏幕密度(Small-scale Dots Per Inch),适用于dpi取值为(0,120]的设备。
mdpi:表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120,160]的设备。
ldpi:表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160,240]的设备。
xldpi:表示特大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240,320]的设备。
xxldpi:表示超大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320,480]的设备。
xxxldpi:表示超特大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480,640]的设备。 | 数组 | 可缺省,缺省值为空。 | + +表34 countryCode对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | ---------- | -------------------- | +| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 该标签表示应用需要分发的国家码,标签为字符串数组,子串表示支持的国家或地区,由两个大写字母表示。 | 字符串数组 | 可缺省,缺省值为空。 | + distroFilter示例: ```json -"distroFilter": [ - { - "apiVersion": { - "policy": "include", - "value": [4,5] - }, - "screenShape": { - "policy": "include", - "value": ["circle","rect"] - }, - "screenWindow": { - "policy": "include", - "value": ["454*454","466*466"] - } +"distroFilter": { + "apiVersion": { + "policy": "include", + "value": [4,5] + }, + "screenShape": { + "policy": "include", + "value": ["circle","rect"] + }, + "screenWindow": { + "policy": "include", + "value": ["454*454","466*466"] + }, + “screenDensity”:{ + "policy": "exclude", + "value": ["ldpi","xldpi"] + }, + "countryCode": { + "policy":"include", + "value":["CN", "HK"] } -] +} ``` -表33 commonEvents对象的内部结构说明 +表35 commonEvents对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------- | ------------------------------------------------------------ | ---------- | ------------------ | diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 532f240e1d032aaeb5198a5baf1eae1c7870a87a..e612643dbce7170b96970b50732e06aa0e48aa8e 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -83,6 +83,7 @@ - [屏幕截图](js-apis-screenshot.md) - [输入法框架](js-apis-inputmethod.md) - [输入法服务](js-apis-inputmethodengine.md) + - [辅助功能](js-apis-accessibility.md) - DFX - [应用打点](js-apis-hiappevent.md) - [性能打点](js-apis-hitracemeter.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md index dd04004618e463d69d8d185210418fa3c0d748ee..c8841f24348e99e23dbc3f282f220948adf7ccdf 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -28,6 +28,10 @@ getApplicationInfo(bundleName: string, bundleFlags: number, userId: number): Pro ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -68,13 +72,17 @@ getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, call ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + **参数:** | 名称 | 类型 | 必填 | 描述 | | ----------- | ------------------------------- | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 要查询的应用程序包名称。 | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。 | -| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | +| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | | callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数,返回应用程序信息。 | **示例:** @@ -104,6 +112,10 @@ getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise>): void -获取指定用户下所有已安装的应用信息,通过回调函数获取返回值。 +获取指定用户下所有已安装的应用信息,使用callback形式返回结果。 **需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + **参数:** | 名称 | 类型 | 必填 | 描述 | | ----------- | -------------------------------------- | ---- | ------------------------------------------------------ | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。| -| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | +| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | | callback | AsyncCallback> | 是 | 程序启动作为入参的回调函数,返回应用信息列表。 | **示例:** @@ -393,6 +433,10 @@ queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise ohos.permission.INSTALL_BUNDLE +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + **返回值:** | 类型 | 说明 | @@ -539,6 +587,10 @@ getBundleInstaller(callback: AsyncCallback): void; ohos.permission.INSTALL_BUNDLE +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -579,6 +631,10 @@ getLaunchWantForBundle(bundleName: string): Promise\ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -612,6 +668,10 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void; ohos.permission.GET_BUNDLE_INFO_PRIVILEGED +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -731,7 +791,6 @@ bundle.getNameForUid(uid, (err, data) => { | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ------ | ------ | ------ | | userId | number | 是 | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| networkId | string | 是 | 是 | 网络Id,默认值:null。 | ## BundleInfo @@ -746,7 +805,7 @@ bundle.getNameForUid(uid, (err, data) => { | installTime | number | 是 | 否 | HAP包安装时间 | | updateTime | number | 是 | 否 | HAP包更新时间 | | appInfo | ApplicationInfo | 是 | 否 | 应用程序的配置信息 | -| abilityInfo | Array | 是 | 否 | Ability的配置信息 | +| abilityInfos | Array | 是 | 否 | Ability的配置信息 | | reqPermissions | Array | 是 | 否 | 应用运行时需向系统申请的权限集合 | | reqPermissionDetails | Array | 是 | 否 | 应用运行时需向系统申请的权限集合的详细信息 | | vendor | string | 是 | 否 | 应用包的供应商 | @@ -755,7 +814,7 @@ bundle.getNameForUid(uid, (err, data) => { | compatibleVersion | number | 是 | 否 | 运行应用包所需要最低的SDK版本号 | | targetVersion | number | 是 | 否 | 运行应用包所需要最高SDK版本号 | | isCompressNativeLibs | boolean | 是 | 否 | 是否压缩应用包的本地库,默认为true | -| hapModuleInfo | Array | 是 | 否 | 模块的配置信息 | +| hapModuleInfos | Array | 是 | 否 | 模块的配置信息 | | entryModuleName | string | 是 | 否 | Entry的模块名称 | | cpuAbi | string | 是 | 否 | 应用包的cpuAbi信息 | | isSilentInstallation | string | 是 | 否 | 是否通过静默安装 | @@ -882,13 +941,7 @@ Ability信息 | readPermission | string | 是 | 否 | 读取Ability数据所需的权限 | | writePermission | string | 是 | 否 | 向Ability写数据所需的权限 | | applicationInfo | ApplicationInfo | 是 | 否 | 应用程序的配置信息 | -| formEntity | number | 是 | 否 | 显示表单的位置 | -| minFormHeight | number | 是 | 否 | Ability的最小高度 | -| defaultFormHeight | number | 是 | 否 | Ability的默认高度 | -| minFormWidth | number | 是 | 否 | Ability的最小宽度 | -| defaultFormWidth | number | 是 | 否 | Ability的默认宽度 | | uri | string | 是 | 否 | 获取Ability的统一资源标识符(URI) | -| customizeData | Map> | 是 | 是 | Ability的自定义数据 | | labelId | number | 是 | 否 | Ability的标签id | | subType | AbilitySubType | 是 | 否 | Ability中枚举使用的模板的子类型 | | metaData | Array | 是 | 否 | ability的自定义元信息 | @@ -922,7 +975,7 @@ Ability类型 | 名称 | 类型 | 说明 | | ----------- | ---- | ------------------- | -| UNSPECIFIED | 0 | Ability只有一个示例 | +| SINGLETON | 0 | Ability只有一个示例 | | STANDARD | 1 | Ability有多个示例 | ## AbilitySubType diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md index c821a665b202b19129b6410b09042cf14c069887..e1ab57aed3064d616732a18fc49d5e6b22670e8a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md @@ -1,24 +1,5 @@ # AbilityContext -- [使用说明](#使用说明) -- [属性](#属性) -- [startAbility](#startAbility) -- [startAbility](#startAbility) -- [startAbility](#startAbility) -- [startAbilityForResult](#startAbilityForResult) -- [startAbilityForResult](#startAbilityForResult) -- [startAbilityForResult](#startAbilityForResult) -- [terminateSelf](#terminateSelf) -- [terminateSelf](#terminateSelf) -- [terminateSelfWithResult](#terminateSelfWithResult) -- [terminateSelfWithResult](#terminateSelfWithResult) -- [startAbilityByCall](#startAbilityByCall) -- [requestPermissionsFromUser](#requestPermissionsFromUser) -- [requestPermissionsFromUser](#requestPermissionsFromUser) -- [setMissionLabel](#setMissionLabel) -- [setMissionLabel](#setMissionLabel) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -485,7 +466,7 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void; ## AbilityContext.setMissionLabel -setMissionLabel(label: string): Promise; +setMissionLabel(label: string): Promise<void> 设置ability在任务中显示的名称。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index f7a50c58358c8e0c3753be5e231dc47e33f53dd9..d5351e156e3b78d23ea5e5a333ff08566f183198 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -9,15 +9,15 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl' ``` -## 系统能力 -SystemCapability.Security.AccessToken - ## abilityAccessCtrl.createAtManager createAtManager(): AtManager 访问控制管理:获取访问控制模块对象。 +**系统能力:** SystemCapability.Security.AccessToken + + **返回值:** | 类型 | 说明 | @@ -40,6 +40,8 @@ verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStat 校验应用是否授予权限,使用Promise方式异步返回结果。 +**系统能力:** SystemCapability.Security.AccessToken + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -56,7 +58,7 @@ verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStat **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let promise = AtManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); promise.then(data => { @@ -70,7 +72,9 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl 授予应用user grant权限,使用Promise方式异步返回结果。 -需要权限:ohos.permission.GRANT_SENSITIVE_PERMISSIONS。 +**需要权限:** ohos.permission.GRANT_SENSITIVE_PERMISSIONS + +**系统能力:** SystemCapability.Security.AccessToken **参数:** @@ -89,7 +93,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); promise.then(data => { @@ -105,7 +109,9 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl 授予应用user grant权限,使用callback回调异步返回结果。 -需要权限:ohos.permission.GRANT_SENSITIVE_PERMISSIONS。 +**需要权限:** ohos.permission.GRANT_SENSITIVE_PERMISSIONS + +**系统能力:** SystemCapability.Security.AccessToken **参数:** @@ -119,7 +125,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let permissionFlag = 1; AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => { @@ -133,7 +139,9 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF 撤销应用user grant权限,使用Promise方式异步返回结果。 -需要权限:ohos.permission.REVOKE_SENSITIVE_PERMISSIONS。 +**需要权限:** ohos.permission.REVOKE_SENSITIVE_PERMISSIONS + +**系统能力:** SystemCapability.Security.AccessToken **参数:** @@ -152,7 +160,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let permissionFlag = 1; let promise = AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag); @@ -167,7 +175,9 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF 撤销应用user grant权限,使用callback回调异步返回结果。 -需要权限:ohos.permission.REVOKE_SENSITIVE_PERMISSIONS。 +**需要权限:** ohos.permission.REVOKE_SENSITIVE_PERMISSIONS + +**系统能力:** SystemCapability.Security.AccessToken **参数:** @@ -181,7 +191,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => { console.log(`callback: data->${JSON.stringify(data)}`); @@ -194,6 +204,8 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise<number&g 获取指定应用的指定权限的flag,使用Promise方式异步返回结果。 +**系统能力:** SystemCapability.Security.AccessToken + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -210,7 +222,7 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise<number&g **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let promise = AtManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); promise.then(data => { @@ -222,6 +234,8 @@ promise.then(data => { 表示授权状态的枚举。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken + | 名称 | 默认值 | 描述 | | ----------------------------- | ---------------------- | ----------------------- | | PERMISSION_DENIED | -1 | 表示未授权。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md index a24ef4bf9d42471d79f8dc0c937026dd74d74d97..28f6239ce3523477d8aead6c6df7fdc64dc05733 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md @@ -1,12 +1,7 @@ # AbilityRunningInfo -- [使用说明](#使用说明) -- [属性](#属性) -- [abilityManager.AbilityState](#abilityManagerAbilityState) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 8开始支持。 +> 本模块首批接口从API 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 Ability运行相关信息。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md b/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md index 9b390bc098682925713c33f831b998fc5efdf666..07b30f570340377cd12e3abd029a8c7cef5357bb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md @@ -1,11 +1,7 @@ # AbilityStageContext -- [使用说明](#使用说明) -- [属性](#属性) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。 +> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 AbilityStage的上下文环境,继承自[Context](js-apis-application-context.md)。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility.md new file mode 100644 index 0000000000000000000000000000000000000000..7d3076a1c53ab8f84d5aac56cf6677ba774a155f --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility.md @@ -0,0 +1,629 @@ +# 辅助功能 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从 API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```typescript +import accessibility from '@ohos.accessibility'; +``` + +## AbilityState + +辅助应用状态类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| enable | 辅助应用已启用。 | +| disable | 辅助应用已禁用。 | +| install | 辅助应用已安装。 | + +## AbilityType + +无障碍辅助应用类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| audible | 表示具有听觉反馈。 | +| generic | 表示具有通用反馈。 | +| haptic | 表示具有触觉反馈。 | +| spoken | 表示具有语音反馈。 | +| visual | 表示具有视觉反馈。 | + +## AccessibilityAbilityInfo + +辅助应用信息。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +### 属性 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| id | number | 是 | 否 | ability id。 | +| name | string | 是 | 否 | ability 名。 | +| bundleName | string | 是 | 否 | 包名。 | +| abilityTypes | Array<[AbilityType](#abilitytype)> | 是 | 否 | 辅助应用类型。 | +| capabilities | Array<[Capability](#capability)> | 是 | 否 | 辅助应用能力列表。 | +| description | string | 是 | 否 | 辅助应用描述。 | +| eventTypes | Array<[EventType](#eventtype)> | 是 | 否 | 辅助应用关注的无障碍事件列表。 | + +## Action + +应用所支持的目标动作。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| click | 表示点击操作。 | +| longClick | 表示长按操作。 | +| scrollForward | 表示向前滚动操作。 | +| scrollBackward | 表示向后滚动操作。 | +| focus | 表示获得焦点操作。 | +| clearFocus | 表示清除焦点操作。 | +| clearSelection | 表示清除选择操作。 | +| accessibilityFocus | 表示获得无障碍焦点操作。 | +| clearAccessibilityFocus | 表示清除无障碍焦点操作。 | +| cut | 表示剪切操作。 | +| copy | 表示复制操作。 | +| paste | 表示粘贴操作。 | +| select | 表示选择操作。 | +| setText | 表示设置文本操作。 | +| delete | 表示删除操作。 | +| setSelection | 表示选择操作。 | + +## Capability + +辅助应用能力类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| retrieve | 具有检索窗口内容的能力。 | +| touchGuide | 具有触摸探索模式的能力。 | +| keyEventObserver | 具有过滤按键事件的能力。 | +| zoom | 具有控制显示放大的能力。 | +| gesture | 具有执行手势动作的能力。 | + +## CaptionsFontEdgeType8+ + +字幕字体边缘类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Hearing + +| 名称 | 描述 | +| -------- | -------- | +| none | 无效果。 | +| raised | 凸起效果。 | +| depressed | 凹陷效果。 | +| uniform | 轮廓效果。 | +| dropShadow | 阴影效果。 | + +## CaptionsFontFamily8+ + +字幕字体。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Hearing + +| 名称 | 描述 | +| -------- | -------- | +| default | 默认字体。 | +| monospacedSerif | 等宽 Serif 字体。 | +| serif | Serif 字体。 | +| monospacedSansSerif | 等宽 Sans Serif 字体。 | +| sansSerif | Sans Serif 字体。 | +| casual | 非正式字体。 | +| cursive | 手写字体。 | +| smallCapitals | 小型大写字母字体。 | + +## CaptionsStyle8+ + +字幕风格。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Hearing + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | 是 | 否 | 描述字幕字体。 | +| fontScale | number | 是 | 否 | 描述字幕字体缩放系数。 | +| fontColor | number \| string | 是 | 否 | 描述字幕字体颜色。 | +| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | 是 | 否 | 描述字幕字体边缘。 | +| backgroundColor | number \| string | 是 | 否 | 描述字幕背景颜色。 | +| windowColor | number \| string | 是 | 否 | 描述字幕窗口颜色。 | + +## CaptionsManager8+ + +字幕配置。 + +### 属性 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| enabled | boolean | 是 | 否 | 表示是否启用字幕配置。 | +| style | [CaptionsStyle](#captionsstyle8) | 是 | 否 | 表示字幕风格。 | + +### 方法 + +下列 API 示例中都需要使用 [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) 获取 captionsManager 实例,再通过此实例调用对应的方法。 + +#### on('enableChange') + +on(type: 'enableChange', callback: Callback<boolean>): void; + +注册字幕配置启用的监听函数。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 监听字幕配置启用状态。 | + | callback | Callback<boolean> | 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 | + +- 示例 + + ```typescript + captionsManager.on('enableChange',(data) => { + console.info('success data:subscribeStateObserver : ' + JSON.stringify(data)) + }) + ``` + +#### on('styleChange') + +on(type: 'styleChange', callback: Callback<CaptionsStyle>): void; + +注册字幕风格变化的监听函数。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 监听字幕风格变化。 | + | callback | Callback<[CaptionsStyle](#captionsstyle8)> | 是 | 回调函数,在字幕风格变化时通过此函数进行通知。 | + +- 示例 + + ```typescript + captionsManager.on('styleChange',(data) => { + console.info('success data:subscribeStateObserver : ' + JSON.stringify(data)) + }) + ``` + +#### off('enableChange') + +off(type: 'enableChange', callback?: Callback<boolean>): void; + +移除字幕配置启用的监听函数。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 监听字幕配置启用状态。 | + | callback | Callback<boolean> | 否 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 | + +- 示例 + + ```typescript + captionsManager.off('enableChange') + ``` + +#### off('styleChange') + +off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; + +移除字幕风格变化的监听函数。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 字幕风格变化。 | + | callback | Callback<[CaptionsStyle](#captionsstyle8)> | 否 | 回调函数,在字幕风格变化时通过此函数进行通知。 | + +- 示例 + + ```typescript + captionsManager.off('styleChange') + ``` + +## EventInfo + +界面变更事件。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +### 属性 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| type | [EventType](#eventtype) | 是 | 是 | 无障碍事件类型。 | +| windowUpdateType | [WindowUpdateType](#windowupdatetype) | 是 | 是 | 窗口变化类型。 | +| bundleName | string | 是 | 是 | 目标应用名。 | +| componentType | string | 是 | 是 | 事件源组件类型,如按钮、图表。 | +| pageId | number | 是 | 是 | 事件源的页面 ID。 | +| description | string | 是 | 是 | 事件描述。 | +| triggerAction | [Action](#action) | 是 | 是 | 触发事件的 Action。 | +| textMoveUnit | [TextMoveUnit](#textmoveunit) | 是 | 是 | 文本移动粒度。 | +| contents | Array<string> | 是 | 是 | 内容列表。 | +| lastContent | string | 是 | 是 | 最新内容。 | +| beginIndex | number | 是 | 是 | 画面显示条目的开始序号。 | +| currentIndex | number | 是 | 是 | 当前条目序号。 | +| endIndex | number | 是 | 是 | 画面显示条目的结束序号。 | +| itemCount | number | 是 | 是 | 条目总数。 | + +## EventType + +无障碍事件类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| click | 描述点击组件的事件。 | +| longClick | 描述长按组件的事件。 | +| select | 描述选择组件的事件。 | +| focus | 描述组件获得焦点的事件。 | +| textUpdate | 描述组件文本已更改的事件。 | +| hoverEnter | 描述悬停进入组件的事件。 | +| hoverExit | 描述悬停离开组件的事件。 | +| scroll | 描述滚动视图的事件。 | +| textSelectionUpdate | 描述选定文本已更改的事件。 | +| accessibilityFocus | 描述获得无障碍焦点的事件。 | +| accessibilityFocusClear | 描述清除无障碍焦点的事件。 | + +## TextMoveUnit + +文本无障碍导航移动粒度。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| char | 以字符为移动粒度遍历节点文本。 | +| word | 以词为移动粒度遍历节点文本。 | +| line | 以行为移动粒度遍历节点文本。 | +| page | 以页为移动粒度遍历节点文本。 | +| paragraph | 以段落为移动粒度遍历节点文本。 | + +## WindowUpdateType + +窗口变化类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| add | 添加窗口的窗口变化事件。 | +| remove | 一个窗口被删除的窗口变化事件。 | +| title | 窗口标题已更改的窗口变化事件。 | +| bounds | 窗口边界已更改的窗口变化事件。 | +| layer | 窗口层级发生变化的窗口变化事件。 | +| active | 窗口变为活动或不活动的窗口变化事件。 | +| focus | 窗口焦点发生变化的窗口变化事件。 | +| accessibilityFocus | 窗口无障碍焦点发生变化的窗口更改事件。 | +| parent | 父窗口已更改的窗口变化事件。 | +| children | 子窗口已更改的窗口变化事件。 | +| pip | 窗口进入或退出画中画(PIP)模式的窗口变化事件。 | + +## accessibility.getAbilityLists + +getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<Array<AccessibilityAbilityInfo>> + +查询辅助应用列表。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | + | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | + +- 返回值: + + | 类型 | 说明 | + | -------- | -------- | + | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | 返回辅助应用信息列表。 | + +- 示例 + + ```typescript + accessibility.getAbilityLists("spoken", "enable") + .then((data) => { + console.info('success data:getAbilityList1 : ' + JSON.stringify(data)); + for (let item of data) { + console.info(item.id); + console.info(item.name); + console.info(item.description); + console.info(item.abilityTypes); + console.info(item.eventTypes); + console.info(item.capabilities); + console.info(item.packageName); + console.info(item.filterBundleNames); + console.info(item.bundleName); + } + }).catch((error) => { + console.error('failed to getAbilityList1 because ' + JSON.stringify(error)); + }) + ``` + +## accessibility.getAbilityLists + +getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void + +查询辅助应用列表。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | + | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | + | callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | 是 | 回调函数,返回辅助应用信息列表。 | + +- 示例 + + ```typescript + accessibility.getAbilityLists("visual", "enable", (err, data) => { + if (err) { + console.error('failed to getAbilityList2 because ' + JSON.stringify(err)); + return; + } + console.info('success data:getAbilityList2 : ' + JSON.stringify(data)); + for (let item of data) { + console.info(item.id); + console.info(item.name); + console.info(item.description); + console.info(item.abilityTypes); + console.info(item.eventTypes); + console.info(item.capabilities); + console.info(item.packageName); + console.info(item.filterBundleNames); + console.info(item.bundleName); + } + }) + ``` + +## accessibility.getCaptionsManager8+ + +getCaptionsManager(): CaptionsManager + +获取无障碍字幕配置。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing + +- 返回值: + + | 类型 | 说明 | + | -------- | -------- | + | [CaptionsManager](#captionsmanager8) | 无障碍字幕配置管理。 | + +- 示例 + + ```typescript + captionsManager = accessibility.getCaptionsManager() + ``` + +## accessibility.on('accessibilityStateChange' | 'touchGuideStateChange') + +on(type: 'accessibilityStateChange' | 'touchGuideStateChange', callback: Callback<boolean>): void + +启用辅助应用和触摸浏览功能的状态变化监听。 + +**系统能力**:以下各项对应的系统能力有所不同,详见下表。 + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 监听的事件类型。
- type 为'accessibilityStateChange'时表示监听类型为辅助功能启用状态变化监听;
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core
- type 为'touchGuideStateChange'时表示监听类型为触摸浏览启用状态变化监听。
**系统能力**:SystemCapability.Barrierfree.Accessibility.Vision | + | callback | Callback<boolean> | 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 | + +- 示例 + + ```typescript + accessibility.on('accessibilityStateChange',(data) => { + console.info('success data:subscribeStateObserver : ' + JSON.stringify(data)) + }) + ``` + +## accessibility.off('accessibilityStateChange' | 'touchGuideStateChange') + +off(type: ‘accessibilityStateChange ’ | ‘touchGuideStateChange’, callback?: Callback<boolean>): void + +关闭辅助应用和触摸浏览功能的状态变化监听。 + +**系统能力**:以下各项对应的系统能力有所不同,详见下表。 + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 否 | 监听的事件类型。
- type 为'accessibilityStateChange'时表示监听类型为辅助功能启用状态变化监听;
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core
- type 为'touchGuideStateChange'时表示监听类型为触摸浏览启用状态变化监听。
**系统能力**:SystemCapability.Barrierfree.Accessibility.Vision | + | callback | Callback<boolean> | 否 | 要取消的监听回调函数。 | + +- 示例 + + ```typescript + accessibility.off('accessibilityStateChange',(data) => { + console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data)) + }) + ``` + +## accessibility.isOpenAccessibility + +isOpenAccessibility(): Promise<boolean> + +判断是否启用了辅助功能。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 返回值: + + | 类型 | 说明 | + | -------- | -------- | + | Promise<boolean> | 如果辅助功能已启用,则返回 true;否则返回 false。 | + +- 示例 + + ```typescript + accessibility.isOpenAccessibility() + .then((data) => { + console.info('success data:isOpenAccessibility : ' + JSON.stringify(data)) + }).catch((error) => { + console.error('failed to isOpenAccessibility because ' + JSON.stringify(error)); + }) + ``` + +## accessibility.isOpenAccessibility + +isOpenAccessibility(callback: AsyncCallback<boolean>): void + +判断是否启用了辅助功能。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数 + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | 是 | 回调函数,如果辅助功能已启用,则返回 true;否则返回 false。 | + +- 示例 + + ```typescript + accessibility.isOpenAccessibility((err, data) => { + if (err) { + console.error('failed to isOpenAccessibility because ' + JSON.stringify(err)); + return; + } + console.info('success data:isOpenAccessibility : ' + JSON.stringify(data)) + }) + ``` + +## accessibility.isOpenTouchGuide + +isOpenTouchGuide(): Promise<boolean> + +判断触摸浏览模式是否开启。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 返回值: + + | 类型 | 说明 | + | -------- | -------- | + | Promise<boolean> | 如果触摸浏览模式已开启,则返回 true;否则返回 false。 | + +- 示例 + + ```typescript + accessibility.isOpenTouchGuide() + .then((data) => { + console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data)) + }).catch((error) => { + console.error('failed to isOpenTouchGuide because ' + JSON.stringify(error)); + }) + ``` + +## accessibility.isOpenTouchGuide + +isOpenTouchGuide(callback: AsyncCallback<boolean>): void + +判断触摸浏览模式是否开启。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数 + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | 是 | 回调函数,如果触摸浏览模式已开启,则返回 true;否则返回 false。 | + +- 示例 + + ```typescript + accessibility.isOpenTouchGuide((err, data) => { + if (err) { + console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err)); + return; + } + console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data)) + }) + ``` + +## accessibility.sendEvent + +sendEvent(event: EventInfo): Promise<void> + +发送无障碍事件。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 | + +- 返回值: + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 以 Promise 形式返回结果,如果发送无障碍事件成功,则 data 有数据返回;如果发送无障碍事件失败,则 err 有数据返回。 | + +- 示例 + + ```typescript + accessibility.sendEvent(this.eventInfo) + .then((data) => { + console.info('success data:sendEvent : ' + JSON.stringify(data)) + }).catch((error) => { + console.error('failed to sendEvent because ' + JSON.stringify(error)); + }) + ``` + +## accessibility.sendEvent + +sendEvent(event: EventInfo, callback: AsyncCallback<void>): void + +发送无障碍事件。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 | + | callback | AsyncCallback<void> | 是 | 回调函数,如果发送无障碍事件成功,则 AsyncCallback 中 data 有数据返回;如果发送无障碍事件失败,则 AsyncCallback 中 err 有数据返回。 | + +- 示例 + + ```typescript + accessibility.sendEvent(this.eventInfo,(err, data) => { + if (err) { + console.error('failed to sendEvent because ' + JSON.stringify(err)); + return; + } + console.info('success data:sendEvent : ' + JSON.stringify(data)) + }) + ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index 38e22506315711bdc156e56523ad76a3998d0ac8..a571496b551cfe0aae82c69336dd92d8afaf9abe 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -1366,15 +1366,17 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<Authentic ``` const appAccountManager = account_appAccount.createAppAccountManager(); featureAbility.getWant((err, want) => { - var sessionId = want.parameters[Constants.KEY_SESSION_ID]; + var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => { - if (err.code != ResultCode.SUCCESS) { + if (err.code != account_appAccount.ResultCode.SUCCESS) { console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); return; } - var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", - Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; - callback.OnResult(ResultCode.SUCCESS, result); + var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", + [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", + [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge", + [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); }); }); ``` @@ -1402,11 +1404,13 @@ getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> ``` const appAccountManager = account_appAccount.createAppAccountManager(); featureAbility.getWant().then((want) => { - var sessionId = want.parameters[Constants.KEY_SESSION_ID]; + var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { - var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", - Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; - callback.OnResult(ResultCode.SUCCESS, result); + var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", + [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", + [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge", + [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); }).catch((err) => { console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); }); @@ -1561,9 +1565,11 @@ onResult: (code: number, result: {[key: string]: any}) => void; const appAccountManager = account_appAccount.createAppAccountManager(); var sessionId = "1234"; appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { - var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", - Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; - callback.OnResult(ResultCode.SUCCESS, result); + var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", + [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", + [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge", + [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); }).catch((err) => { console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); }); @@ -1592,8 +1598,10 @@ onRequestRedirected: (request: Want) => void; } authenticate(name, authType, callerBundleName, options, callback) { - var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"}; - callback.onResult(ResultCode.SUCCESS, result); + var result = {[account_appAccount.Constants.KEY_NAME]: name, + [account_appAccount.Constants.KEY_AUTH_TYPE]: authType, + [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + callback.onResult(account_appAccount.ResultCode.SUCCESS, result); } } ``` @@ -1643,8 +1651,10 @@ authenticate(name: string, authType: string, callerBundleName: string, options: } authenticate(name, authType, callerBundleName, options, callback) { - var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"}; - callback.onResult(ResultCode.SUCCESS, result); + var result = {[account_appAccount.Constants.KEY_NAME]: name, + [account_appAccount.Constants.KEY_AUTH_TYPE]: authType, + [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + callback.onResult(account_appAccount.ResultCode.SUCCESS, result); } } diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md index 1f167652228ce59efc2b4f04f54269043c2b360d..3821f213bd48fada542902b46a6a94af6726fddf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md @@ -1,29 +1,7 @@ # Ability -- [导入模块](#导入模块) -- [属性](#属性) -- [onCreate](#onCreate) -- [onWindowStageCreate](#onWindowStageCreate) -- [onWindowStageDestroy](#onWindowStageDestroy) -- [onWindowStageRestore](#onWindowStageRestore) -- [onDestroy](#onDestroy) -- [onForeground](#onForeground) -- [onBackground](#onBackground) -- [onContinue](#onContinue) -- [onNewWant](#onNewWant) -- [onConfigurationUpdated](#onConfigurationUpdated) -- [Caller](#Caller) - - [call](#call) - - [callWithResult](#callWithResult) - - [release](#release) - - [onRelease](#onRelease) -- [Callee](#Callee) - - [on](#on) - - [off](#off) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 从API Version 8 开始支持。 +> 从API Version 8 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 Ability模块,提供对Ability生命周期、上下文环境等调用管理。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md index 71748cefcf1d94354c10d7880d66c15d69622b94..e46a4451919cb05149a306c0a1e134a87a321a80 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md @@ -1,13 +1,7 @@ # AbilityStage -- [导入模块](#导入模块) -- [onCreate](#onCreate) -- [onAcceptWant](#onAcceptWant) -- [onConfigurationUpdated](#onConfigurationUpdated) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。 +> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 AbilityStage是HAP包的运行时类。在HAP加载的时候,通知开发者,开发者可以在此进行该HAP的初始化(如资源预加载,线程创建等)。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-application-context.md index cf68c54f976b4b2861210bead621c5f7f9bacd53..967d22b7e92450cea4b3d9e8ed9b86ac095a9c0b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-context.md @@ -1,13 +1,7 @@ # Context -- [使用说明](#使用说明) -- [属性](#属性) -- [createBundleContext](#createBundleContext) -- [getApplicationContext](#getApplicationContext) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。 +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 提供开发者运行代码的上下文环境,包括应用信息、ResourceManager等信息。 @@ -16,7 +10,7 @@ ## 使用说明 -通过AbilityContext等集成实现。 +通过AbilityContext等继承实现。 ## 属性 diff --git a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md index 0906012f1a43d7df81c4e08fcbb6b7d1d211930a..89a655ece0fbfdff9cfe6cc791dcaf5be257fc10 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md @@ -1,15 +1,10 @@ # appManager -- [导入模块](#导入模块) -- [isRunningInStabilityTest](#isRunningInStabilityTest) -- [isRunningInStabilityTest](#isRunningInStabilityTest) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 8开始支持。 +> 本模块首批接口从API 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -App运行相关信息。 +App管理。 ## 导入模块 @@ -24,7 +19,7 @@ import app from '@ohos.application.appManager'; static isRunningInStabilityTest(callback: AsyncCallback<boolean>): void -查询当前用户是否是一个稳定性测试。 +查询当前是否处于稳定性测试场景。 **系统能力**:SystemCapability.Ability.AbilityRuntime.Core diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index 607758131ea1a1cf097668faf3f64b466abba8f8..e7e1b3a06ea3d9895f2aafae031f2e15c499a78f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -1,7 +1,12 @@ # 音频管理 > **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +该模块提供以下音频相关的常用功能: + +- [AudioManager](#audiomanager):音频管理。 +- [AudioRenderer](#audiorenderer8):音频播放,用于播放PCM(Pulse Code Modulation)音频数据。 ## 导入模块 @@ -10,7 +15,7 @@ import audio from '@ohos.multimedia.audio'; ``` -## getAudioManager +## audio.getAudioManager getAudioManager(): AudioManager @@ -19,8 +24,8 @@ getAudioManager(): AudioManager **系统能力:** SystemCapability.Multimedia.Audio.Core **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ----------------------------- | ------------ | | [AudioManager](#audiomanager) | 音频管理类。 | **示例:** @@ -28,91 +33,356 @@ getAudioManager(): AudioManager var audioManager = audio.getAudioManager(); ``` +## audio.createAudioRenderer8+ + +createAudioRenderer(options: AudioRendererOptions): AudioRenderer + +获取音频播放器。 + +**系统能力:** SystemCapability.Multimedia.Audio.Renderer + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------------- | ---- | ----------- | +| options | [AudioRendererOptions](#audiorendereroptions8) | 是 | 配置播放器. | + +**返回值**: + +| 类型 | 说明 | +| -------------------------------- | ---------------- | +| [AudioRenderer](#audiorenderer8) | 音频播放器对象。 | + +**示例:** + +``` +var audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 +} + +var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo +} + +let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); +``` ## AudioVolumeType 枚举,音频流类型。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| RINGTONE | 2 | 表示铃声。
**系统能力:** SystemCapability.Multimedia.Audio.Volume | -| MEDIA | 3 | 表示媒体。
**系统能力:** SystemCapability.Multimedia.Audio.Volume | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume + +| 名称 | 默认值 | 描述 | +| ---------------------------- | ------ | ---------- | +| VOICE_CALL8+ | 0 | 语音电话。 | +| RINGTONE | 2 | 铃声。 | +| MEDIA | 3 | 媒体。 | +| VOICE_ASSISTANT8+ | 9 | 语音助手。 | ## DeviceFlag 枚举,可获取的设备种类。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| OUTPUT_DEVICES_FLAG | 1 | 表示输出设备种类。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| INPUT_DEVICES_FLAG | 2 | 表示输入设备种类。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| ALL_DEVICES_FLAG | 3 | 表示所有设备种类。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device + +| 名称 | 默认值 | 描述 | +| ------------------- | ------ | ---------- | +| OUTPUT_DEVICES_FLAG | 1 | 输出设备。 | +| INPUT_DEVICES_FLAG | 2 | 输入设备。 | +| ALL_DEVICES_FLAG | 3 | 所有设备。 | ## DeviceRole 枚举,设备角色。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| INPUT_DEVICE | 1 | 输入设备角色。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| OUTPUT_DEVICE | 2 | 输出设备角色。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device + +| 名称 | 默认值 | 描述 | +| ------------- | ------ | -------------- | +| INPUT_DEVICE | 1 | 输入设备角色。 | +| OUTPUT_DEVICE | 2 | 输出设备角色。 | ## DeviceType 枚举,设备类型。 -| 名称 | 默认值 | 描述 | -| -------------- | ------ | ------------------------------------------------------------ | -| INVALID | 0 | 无效设备。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| EARPIECE | 1 | 听筒。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| SPEAKER | 2 | 扬声器。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| WIRED_HEADSET | 3 | 有线耳机。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| BLUETOOTH_SCO | 7 | 蓝牙设备SCO连接(Synchronous Connection Oriented)。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| BLUETOOTH_A2DP | 8 | 蓝牙设备A2DP连接(Advanced Audio Distribution Profile)。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| MIC | 15 | 麦克风。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device + +| 名称 | 默认值 | 描述 | +| -------------- | ------ | --------------------------------------------------------- | +| INVALID | 0 | 无效设备。 | +| EARPIECE | 1 | 听筒。 | +| SPEAKER | 2 | 扬声器。 | +| WIRED_HEADSET | 3 | 有线耳机。 | +| BLUETOOTH_SCO | 7 | 蓝牙设备SCO(Synchronous Connection Oriented)连接。 | +| BLUETOOTH_A2DP | 8 | 蓝牙设备A2DP(Advanced Audio Distribution Profile)连接。 | +| MIC | 15 | 麦克风。 | ## ActiveDeviceType 枚举,活跃设备类型。 -| 名称 | 默认值 | 描述 | -| ------------- | ------ | ------------------------------------------------------------ | -| SPEAKER | 2 | 扬声器。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| BLUETOOTH_SCO | 7 | 蓝牙设备SCO连接(Synchronous Connection Oriented)。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device + +| 名称 | 默认值 | 描述 | +| ------------- | ------ | ---------------------------------------------------- | +| SPEAKER | 2 | 扬声器。 | +| BLUETOOTH_SCO | 7 | 蓝牙设备SCO(Synchronous Connection Oriented)连接。 | -## AudioRingMode +## AudioRingMode 枚举,铃声模式。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| RINGER_MODE_SILENT | 0 | 静音模式。
**系统能力:** SystemCapability.Multimedia.Audio.Communication | -| RINGER_MODE_VIBRATE | 1 | 震动模式。
**系统能力:** SystemCapability.Multimedia.Audio.Communication | -| RINGER_MODE_NORMAL | 2 | 响铃模式。
**系统能力:** SystemCapability.Multimedia.Audio.Communication | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Communication + +| 名称 | 默认值 | 描述 | +| ------------------- | ------ | ---------- | +| RINGER_MODE_SILENT | 0 | 静音模式。 | +| RINGER_MODE_VIBRATE | 1 | 震动模式。 | +| RINGER_MODE_NORMAL | 2 | 响铃模式。 | + +## AudioSampleFormat8+ + +枚举,音频采样格式。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| --------------------- | ------ | -------------------------- | +| SAMPLE_FORMAT_INVALID | -1 | 无效格式。 | +| SAMPLE_FORMAT_U8 | 0 | 无符号8位整数。 | +| SAMPLE_FORMAT_S16LE | 1 | 带符号的16位整数,小尾数。 | +| SAMPLE_FORMAT_S24LE | 2 | 带符号的24位整数,小尾数。 | +| SAMPLE_FORMAT_S32LE | 3 | 带符号的32位整数,小尾数。 | + +## AudioChannel8+ + +枚举, 音频声道。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| --------- | -------- | -------- | +| CHANNEL_1 | 0x1 << 0 | 单声道。 | +| CHANNEL_2 | 0x1 << 1 | 双声道。 | + +## AudioSamplingRate8+ + +枚举,音频采样率。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| ----------------- | ------ | --------------- | +| SAMPLE_RATE_8000 | 8000 | 采样率为8000。 | +| SAMPLE_RATE_11025 | 11025 | 采样率为11025。 | +| SAMPLE_RATE_12000 | 12000 | 采样率为12000。 | +| SAMPLE_RATE_16000 | 16000 | 采样率为16000。 | +| SAMPLE_RATE_22050 | 22050 | 采样率为22050。 | +| SAMPLE_RATE_24000 | 24000 | 采样率为24000。 | +| SAMPLE_RATE_32000 | 32000 | 采样率为32000。 | +| SAMPLE_RATE_44100 | 44100 | 采样率为44100。 | +| SAMPLE_RATE_48000 | 48000 | 采样率为48000。 | +| SAMPLE_RATE_64000 | 64000 | 采样率为64000。 | +| SAMPLE_RATE_96000 | 96000 | 采样率为96000。 | + +## AudioEncodingType8+ + +枚举,音频编码类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| --------------------- | ------ | --------- | +| ENCODING_TYPE_INVALID | -1 | 无效。 | +| ENCODING_TYPE_RAW | 0 | PCM编码。 | + +## ContentType8+ + +枚举,音频内容类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| ------------------------- | ------ | ---------- | +| CONTENT_TYPE_UNKNOWN | 0 | 未知类型。 | +| CONTENT_TYPE_SPEECH | 1 | 语音。 | +| CONTENT_TYPE_MUSIC | 2 | 音乐。 | +| CONTENT_TYPE_MOVIE | 3 | 电影。 | +| CONTENT_TYPE_SONIFICATION | 4 | 加密类型。 | +| CONTENT_TYPE_RINGTONE | 5 | 铃声。 | + +## StreamUsage8+ + +枚举,音频流使用类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| ---------------------------------- | ------ | ---------- | +| STREAM_USAGE_UNKNOWN | 0 | 未知类型。 | +| STREAM_USAGE_MEDIA | 1 | 音频。 | +| STREAM_USAGE_VOICE_COMMUNICATION | 2 | 语音通信。 | +| STREAM_USAGE_NOTIFICATION_RINGTONE | 3 | 通知铃声。 | + +## AudioState8+ + +枚举,音频状态。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| -------------- | ------ | ---------------- | +| STATE_INVALID | -1 | 无效状态。 | +| STATE_NEW | 0 | 创建新实例状态。 | +| STATE_PREPARED | 1 | 准备状态。 | +| STATE_RUNNING | 2 | 可运行状态。 | +| STATE_STOPPED | 3 | 停止状态。 | +| STATE_RELEASED | 4 | 释放状态。 | +| STATE_PAUSED | 5 | 暂停状态。 | + +## AudioRendererRate8+ + +枚举,播放速度。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 默认值 | 描述 | +| ------------------ | ------ | ---------- | +| RENDER_RATE_NORMAL | 0 | 正常速度。 | +| RENDER_RATE_DOUBLE | 1 | 2倍速。 | +| RENDER_RATE_HALF | 2 | 0.5倍数。 | + +## InterruptType8+ + +枚举,中断类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer +| 名称 | 默认值 | 描述 | +| -------------------- | ------ | ---------------------- | +| INTERRUPT_TYPE_BEGIN | 1 | 音频播放中断事件开始。 | +| INTERRUPT_TYPE_END | 2 | 音频播放中断事件结束。 | + +## InterruptForceType8+ + +枚举,强制打断类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 默认值 | 描述 | +| --------------- | ------ | ------------------------------------ | +| INTERRUPT_FORCE | 0 | 由系统进行操作,强制打断音频播放。 | +| INTERRUPT_SHARE | 1 | 由应用进行操作,可以选择打断或忽略。 | + +## InterruptHint8+ + +枚举,中断提示。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 默认值 | 描述 | +| --------------------- | ------ | -------------------------------------------- | +| INTERRUPT_HINT_NONE | 0 | 无提示。 | +| INTERRUPT_HINT_RESUME | 1 | 提示音频恢复。 | +| INTERRUPT_HINT_PAUSE | 2 | 提示音频暂停。 | +| INTERRUPT_HINT_STOP | 3 | 提示音频停止。 | +| INTERRUPT_HINT_DUCK | 4 | 提示音频躲避。(躲避:音量减弱,而不会停止) | +| INTERRUPT_HINT_UNDUCK | 5 | 提示音量恢复。 | + +## AudioStreamInfo8+ + +音频流信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ---------------------------------------- | ---- | ------------------ | +| samplingRate | [AudioSamplingRate](#audiosamplingrate8) | 是 | 音频文件的采样率。 | +| channels | [AudioChannel](#audiochannel8) | 是 | 音频文件的通道数。 | +| sampleFormat | [AudioSampleFormat](#audiosampleformat8) | 是 | 音频采样格式。 | +| encodingType | [AudioEncodingType](#audioencodingtype8) | 是 | 音频编码格式。 | + +## AudioRendererInfo8+ + +音频播放器信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ---------------------------- | ---- | ---------------- | +| contentType | [ContentType](#contenttype8) | 是 | 媒体类型。 | +| usage | [StreamUsage](#streamusage8) | 是 | 音频流使用类型。 | +| rendererFlags | number | 是 | 音频播放器标志。 | + +## AudioRendererOptions8+ + +音频播放器选项信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ---------------------------------------- | ---- | ---------------- | +| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | 是 | 表示音频流信息。 | +| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | 表示播放器信息。 | + +## InterruptEvent8+ + +播放中断时,应用接收的中断事件。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ------------------------------------------ | ---- | ------------------------------------ | +| eventType | [InterruptType](#interrupttype8) | 是 | 中断事件类型,开始或是结束。 | +| forceType | [InterruptForceType](#interruptforcetype8) | 是 | 操作是由系统执行或是由应用程序执行。 | +| hintType | [InterruptHint](#interrupthint8) | 是 | 中断提示。 | + +## VolumeEvent8+ + +音量改变时,应用接收的事件。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume + +| 名称 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | +| updateUi | boolean | 是 | 在UI中显示音量变化。 | ## AudioManager -管理音频音量和音频设备。 +管理音频音量和音频设备。在调用AudioManager的接口前,需要先通过[getAudioManager](#audiogetaudiomanager)创建实例。 ### setVolume setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void -设置指定流的音量,使用callback方式返回异步结果。 +设置指定流的音量,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | -| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | +| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败。 | **示例:** @@ -131,21 +401,21 @@ audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err)=>{ setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> -设置指定流的音量,使用promise方式返回异步结果。 +设置指定流的音量,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ----------------------------- | | Promise<void> | Promise回调表示成功还是失败。 | **示例:** @@ -161,16 +431,16 @@ audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(()=> getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -获取指定流的音量,使用callback方式返回异步结果。 +获取指定流的音量,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| callback | AsyncCallback<number> | 是 | 回调返回音量大小。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<number> | 是 | 回调返回音量大小。 | **示例:** @@ -189,20 +459,20 @@ audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { getVolume(volumeType: AudioVolumeType): Promise<number> -获取指定流的音量,使用promise方式返回异步结果。 +获取指定流的音量,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| --------------------- | ------------------------- | | Promise<number> | Promise回调返回音量大小。 | **示例:** @@ -218,16 +488,16 @@ audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -获取指定流的最小音量,使用callback方式返回异步结果。 +获取指定流的最小音量,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| callback | AsyncCallback<number> | 是 | 回调返回最小音量。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<number> | 是 | 回调返回最小音量。 | **示例:** @@ -246,20 +516,20 @@ audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { getMinVolume(volumeType: AudioVolumeType): Promise<number> -获取指定流的最小音量,使用promise方式返回异步结果。 +获取指定流的最小音量,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| --------------------- | ------------------------- | | Promise<number> | Promise回调返回最小音量。 | **示例:** @@ -275,16 +545,16 @@ audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -获取指定流的最大音量,使用callback方式返回异步结果。 +获取指定流的最大音量,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| callback | AsyncCallback<number> | 是 | 回调返回最大音量大小。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ---------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<number> | 是 | 回调返回最大音量大小。 | **示例:** @@ -303,20 +573,20 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { getMaxVolume(volumeType: AudioVolumeType): Promise<number> -获取指定流的最大音量,使用promise方式返回异步结果。 +获取指定流的最大音量,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| --------------------- | ----------------------------- | | Promise<number> | Promise回调返回最大音量大小。 | **示例:** @@ -332,17 +602,17 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=> mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void -设置指定音量流静音,使用callback方式返回异步结果。 +设置指定音量流静音,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| mute | boolean | 是 | 静音状态,true为静音,false为非静音。 | -| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| mute | boolean | 是 | 静音状态,true为静音,false为非静音。 | +| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败。 | **示例:** @@ -361,21 +631,21 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> -设置指定音量流静音,使用promise方式返回异步结果。 +设置指定音量流静音,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| mute | boolean | 是 | 静音状态,true为静音,false为非静音。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| mute | boolean | 是 | 静音状态,true为静音,false为非静音。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ----------------------------- | | Promise<void> | Promise回调表示成功还是失败。 | **示例:** @@ -393,16 +663,16 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -获取指定音量流是否被静音,使用callback方式返回异步结果。 +获取指定音量流是否被静音,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| callback | AsyncCallback<boolean> | 是 | 回调返回流静音状态,true为静音,false为非静音。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ----------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<boolean> | 是 | 回调返回流静音状态,true为静音,false为非静音。 | **示例:** @@ -422,20 +692,20 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { isMute(volumeType: AudioVolumeType): Promise<boolean> -获取指定音量流是否被静音,使用promise方式返回异步结果。 +获取指定音量流是否被静音,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------ | | Promise<boolean> | Promise回调返回流静音状态,true为静音,false为非静音。 | **示例:** @@ -451,16 +721,16 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -获取指定音量流是否为活跃状态,使用callback方式返回异步结果。 +获取指定音量流是否为活跃状态,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| callback | AsyncCallback<boolean> | 是 | 回调返回流的活跃状态,true为活跃,false为不活跃。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<boolean> | 是 | 回调返回流的活跃状态,true为活跃,false为不活跃。 | **示例:** @@ -479,20 +749,20 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { isActive(volumeType: AudioVolumeType): Promise<boolean> -获取指定音量流是否为活跃状态,使用promise方式返回异步结果。 +获取指定音量流是否为活跃状态,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------- | -------------------------------------------------------- | | Promise<boolean> | Promise回调返回流的活跃状态,true为活跃,false为不活跃。 | **示例:** @@ -508,16 +778,16 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void -设置铃声模式,使用callback方式返回异步结果。 +设置铃声模式,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Communication **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| mode | [AudioRingMode](#audioringmode) | 是 | 音频铃声模式。 | -| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------- | ---- | ------------------------ | +| mode | [AudioRingMode](#audioringmode) | 是 | 音频铃声模式。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | **示例:** @@ -525,7 +795,7 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void var audioManager = audio.getAudioManager(); audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { if (err) { - console.error('Failed to set the ringer mode.​ ${err.message}'); + console.error('Failed to set the ringer mode. ${err.message}'); return; } console.log('Callback invoked to indicate a successful setting of the ringer mode.'); @@ -536,20 +806,20 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { setRingerMode(mode: AudioRingMode): Promise<void> -设置铃声模式,使用promise方式返回异步结果。 +设置铃声模式,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Communication **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| mode | [AudioRingMode](#audioringmode) | 是 | 音频铃声模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------------- | ---- | -------------- | +| mode | [AudioRingMode](#audioringmode) | 是 | 音频铃声模式。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ------------------------------- | | Promise<void> | Promise回调返回设置成功或失败。 | **示例:** @@ -566,15 +836,15 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => getRingerMode(callback: AsyncCallback<AudioRingMode>): void -获取铃声模式,使用callback方式返回异步结果。 +获取铃声模式,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Communication **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<[AudioRingMode](#audioringmode)> | 是 | 回调返回系统的铃声模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ------------------------ | +| callback | AsyncCallback<[AudioRingMode](#audioringmode)> | 是 | 回调返回系统的铃声模式。 | **示例:** @@ -582,7 +852,7 @@ getRingerMode(callback: AsyncCallback<AudioRingMode>): void var audioManager = audio.getAudioManager(); audioManager.getRingerMode((err, value) => { if (err) { - console.error('Failed to obtain the ringer mode.​ ${err.message}'); + console.error('Failed to obtain the ringer mode. ${err.message}'); return; } console.log('Callback invoked to indicate that the ringer mode is obtained.' + value); @@ -594,14 +864,14 @@ audioManager.getRingerMode((err, value) => { getRingerMode(): Promise<AudioRingMode> -获取铃声模式,使用promise方式返回异步结果。 +获取铃声模式,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Communication **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------------------------------- | ------------------------------- | | Promise<[AudioRingMode](#audioringmode)> | Promise回调返回系统的铃声模式。 | **示例:** @@ -617,17 +887,17 @@ audioManager.getRingerMode().then((value) => setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void -音频参数设置,使用callback方式返回异步结果。 +音频参数设置,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| key | string | 是 | 被设置的音频参数的键。 | -| value | string | 是 | 被设置的音频参数的值。 | -| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------ | +| key | string | 是 | 被设置的音频参数的键。 | +| value | string | 是 | 被设置的音频参数的值。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | **示例:** @@ -646,21 +916,21 @@ audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => { setAudioParameter(key: string, value: string): Promise<void> -音频参数设置,使用promise方式返回异步结果。 +音频参数设置,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| key | string | 是 | 被设置的音频参数的键。 | -| value | string | 是 | 被设置的音频参数的值。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| key | string | 是 | 被设置的音频参数的键。 | +| value | string | 是 | 被设置的音频参数的值。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ------------------------------- | | Promise<void> | Promise回调返回设置成功或失败。 | **示例:** @@ -676,16 +946,16 @@ audioManager.setAudioParameter('PBits per sample', '8 bit').then(() => getAudioParameter(key: string, callback: AsyncCallback<string>): void -获取指定音频参数值,使用callback方式返回异步结果。 +获取指定音频参数值,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| key | string | 是 | 待获取的音频参数的键。 | -| callback | AsyncCallback<string> | 是 | 回调返回获取的音频参数的值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ---------------------------- | +| key | string | 是 | 待获取的音频参数的键。 | +| callback | AsyncCallback<string> | 是 | 回调返回获取的音频参数的值。 | **示例:** @@ -704,20 +974,20 @@ audioManager.getAudioParameter('PBits per sample', (err, value) => { getAudioParameter(key: string): Promise<string> -获取指定音频参数值,使用promise方式返回异步结果。 +获取指定音频参数值,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| key | string | 是 | 待获取的音频参数的键。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| key | string | 是 | 待获取的音频参数的键。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| --------------------- | ----------------------------------- | | Promise<string> | Promise回调返回获取的音频参数的值。 | **示例:** @@ -733,16 +1003,16 @@ audioManager.getAudioParameter('PBits per sample').then((value) => getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void -获取音频设备列表,使用callback方式返回异步结果。 +获取音频设备列表,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceFlag | [DeviceFlag](#deviceflag) | 是 | 设备类型的flag。 | -| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | 是 | 回调,返回设备列表。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------------------------------------------ | ---- | -------------------- | +| deviceFlag | [DeviceFlag](#deviceflag) | 是 | 设备类型的flag。 | +| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | 是 | 回调,返回设备列表。 | **示例:** ``` @@ -760,20 +1030,20 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{ (deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors> -获取音频设备列表,使用promise方式返回异步结果。 +获取音频设备列表,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceFlag | [DeviceFlag](#deviceflag) | 是 | 设备类型的flag。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ---------------- | +| deviceFlag | [DeviceFlag](#deviceflag) | 是 | 设备类型的flag。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------------------------------------------------ | ------------------------- | | Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise回调返回设备列表。 | **示例:** @@ -789,17 +1059,17 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=> setDeviceActive(deviceType: DeviceType, active: boolean, callback: AsyncCallback<void>): void -设置设备激活状态,使用callback方式返回异步结果。 +设置设备激活状态,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | -| active | boolean | 是 | 设备激活状态。 | -| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------ | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| active | boolean | 是 | 设备激活状态。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | **示例:** @@ -818,21 +1088,21 @@ audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err)=> { setDeviceActive(deviceType: DeviceType, active: boolean): Promise<void> -设置设备激活状态,使用promise方式返回异步结果。 +设置设备激活状态,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | -| active | boolean | 是 | 设备激活状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | -------------- | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| active | boolean | 是 | 设备激活状态。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ------------------------------- | | Promise<void> | Promise回调返回设置成功或失败。 | **示例:** @@ -849,16 +1119,16 @@ audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=> isDeviceActive(deviceType: DeviceType, callback: AsyncCallback<boolean>): void -获取指定设备的激活状态,使用callback方式返回异步结果。 +获取指定设备的激活状态,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | -| callback | AsyncCallback<boolean> | 是 | 回调返回设备的激活状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ---------------------------- | ---- | ------------------------ | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| callback | AsyncCallback<boolean> | 是 | 回调返回设备的激活状态。 | **示例:** @@ -878,20 +1148,20 @@ audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => { isDeviceActive(deviceType: DeviceType): Promise<boolean> -获取指定设备的激活状态,使用promise方式返回异步结果。 +获取指定设备的激活状态,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | -------------- | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | **返回值:** -| Type | Description | -| -------- | -------- | +| Type | Description | +| ---------------------- | ------------------------------- | | Promise<boolean> | Promise回调返回设备的激活状态。 | **示例:** @@ -907,16 +1177,16 @@ audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void -设置麦克风静音状态,使用callback方式返回异步结果。 +设置麦克风静音状态,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| mute | boolean | 是 | 待设置的静音状态,true为静音,false为非静音。 | -| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | --------------------------------------------- | +| mute | boolean | 是 | 待设置的静音状态,true为静音,false为非静音。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | **示例:** @@ -935,20 +1205,20 @@ audioManager.setMicrophoneMute(true, (err) => { setMicrophoneMute(mute: boolean): Promise<void> -设置麦克风静音状态,使用promise方式返回异步结果。 +设置麦克风静音状态,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| mute | boolean | 是 | 待设置的静音状态,true为静音,false为非静音。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | --------------------------------------------- | +| mute | boolean | 是 | 待设置的静音状态,true为静音,false为非静音。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ------------------------------- | | Promise<void> | Promise回调返回设置成功或失败。 | **示例:** @@ -964,15 +1234,15 @@ audioManager.setMicrophoneMute(true).then(() => isMicrophoneMute(callback: AsyncCallback<boolean>): void -获取麦克风静音状态,使用callback方式返回异步结果。 +获取麦克风静音状态,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | 是 | 回调返回系统麦克风静音状态,true为静音,false为非静音。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调返回系统麦克风静音状态,true为静音,false为非静音。 | **示例:** @@ -991,14 +1261,14 @@ audioManager.isMicrophoneMute((err, value) => { isMicrophoneMute(): Promise<boolean> -获取麦克风静音状态,使用promise方式返回异步结果。 +获取麦克风静音状态,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Device **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------ | | Promise<boolean> | Promise回调返回系统麦克风静音状态,true为静音,false为非静音。 | **示例:** @@ -1011,19 +1281,729 @@ audioManager.isMicrophoneMute().then((value) => ) ``` +### on('volumeChange') + +on(type: 'volumeChange', callback: Callback\): void + +监听系统音量变化事件。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 事件回调类型,支持的事件为:'volumeChange'(系统音量变化事件,检测到系统音量改变时,触发该事件)。 | +| callback | Callback<[VolumeEvent](#volumeevent8)> | 是 | 回调方法。 | + +**示例:** + +``` +audioManager.on('volumeChange', (volumeEvent) => { + console.log('VolumeType of stream: ' + volumeEvent.volumeType); + console.log('Volume level: ' + volumeEvent.volume); + console.log('Whether to updateUI: ' + volumeEvent.updateUi); +}) +``` + +### on('ringerModeChange') + +on(type: 'ringerModeChange', callback: Callback\): void + +监听铃声模式变化事件。 + +**系统能力:** SystemCapability.Multimedia.Audio.Communication + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 事件回调类型,支持的事件为:'ringerModeChange'(铃声模式变化事件,检测到铃声模式改变时,触发该事件)。 | +| callback | Callback<[AudioRingMode](#audioringmode)> | 是 | 回调方法。 | ## AudioDeviceDescriptor 描述音频设备。 -| 名称 | 参数型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| deviceRole | [DeviceRole](#devicerole) | 是 | 否 | 设备角色。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| deviceType | [DeviceType](#devicetype) | 是 | 否 | 设备类型。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device +| 名称 | 参数型 | 可读 | 可写 | 说明 | +| ---------- | ------------------------- | ---- | ---- | ---------- | +| deviceRole | [DeviceRole](#devicerole) | 是 | 否 | 设备角色。 | +| deviceType | [DeviceType](#devicetype) | 是 | 否 | 设备类型。 | ## AudioDeviceDescriptors -| 名称 | 描述 | -| -------- | -------- | -| 设备属性数组 | AudioDeviceDescriptor的数组,只读。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device + +| 名称 | 描述 | +| ------------ | ----------------------------------- | +| 设备属性数组 | AudioDeviceDescriptor的数组,只读。 | + +**示例:** + +``` +function deviceProp(audioDeviceDescriptor, index, array) { + deviceRoleValue = audioDeviceDescriptor.deviceRole; + deviceTypeValue = audioDeviceDescriptor.deviceType; +} + +deviceRoleValue = null; +deviceTypeValue = null; +const promise = audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG); +promise.then(async function (audioDeviceDescriptors) { + console.info('getDevices OUTPUT_DEVICES_FLAG'); + audioDeviceDescriptors.forEach(deviceProp); + if (deviceTypeValue != null && deviceRoleValue != null){ + console.info('OUTPUT_DEVICES_FLAG : Pass'); + expect(true).assertTrue(); + } + else{ + console.error('OUTPUT_DEVICES_FLAG : fail'); + expect(false).assertTrue(); + } + }); + await promise; + done(); +}) +``` + +## AudioRenderer8+ + +提供音频播放的相关接口。在调用AudioRenderer的接口前,需要先通过[createAudioRenderer](#audiocreateaudiorenderer8)创建实例。 + +### 属性 + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | -------------------------- | ---- | ---- | ------------------ | +| state | [AudioState](#audiostate8) | 是 | 否 | 当前播放器的状态。 | + +**示例:** + +``` +var state = audioRenderer.state; +``` + +### getRendererInfo8+ + +getRendererInfo(callback: AsyncCallback): void + +获取当前被创建的音频播放器的信息,使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :------- | :------------------------------------------------------- | :--- | :------------------------- | +| callback | AsyncCallback<[AudioRendererInfo](#audiorendererinfo8)\> | 是 | 回调返回音频播放器的信息。 | + +**示例:** + +``` +audioRenderer.getRendererInfo((err, rendererInfo)=>{ + console.log('Renderer GetRendererInfo:'); + console.log('Renderer content:' + rendererInfo.content); + console.log('Renderer usage:' + rendererInfo.usage); + console.log('Renderer flags:' + rendererInfo.rendererFlags); +}) +``` + +### getRendererInfo8+ + +getRendererInfo(): Promise + +获取当前被创建的音频播放器的信息,使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------------------------------------------- | ------------------------------- | +| Promise<[AudioRendererInfo](#audiorendererinfo8)\> | Promise用于返回音频播放器信息。 | + +**示例:** + +``` +let streamInfo = await audioRenderer.getStreamInfo(); +console.log('Renderer GetStreamInfo:'); +console.log('Renderer sampling rate:' + streamInfo.samplingRate); +console.log('Renderer channel:' + streamInfo.AudioChannel); +console.log('Renderer format:' + streamInfo.AudioSampleFormat); +console.log('Renderer encoding type:' + streamInfo.AudioEncodingType); +``` + +### getStreamInfo8+ + +getStreamInfo(callback: AsyncCallback): void + +获取音频流信息,使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :------- | :--------------------------------------------------- | :--- | :------------------- | +| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | 是 | 回调返回音频流信息。 | + +**示例:** + +``` +audioRenderer.getStreamInfo((err, streamInfo)=>{ + console.log('Renderer GetStreamInfo:'); + console.log('Renderer sampling rate:' + streamInfo.samplingRate); + console.log('Renderer channel:' + streamInfo.AudioChannel); + console.log('Renderer format:' + streamInfo.AudioSampleFormat); + console.log('Renderer encoding type:' + streamInfo.AudioEncodingType); +}) +``` + +### getStreamInfo8+ + +getStreamInfo(): Promise + +获取音频流信息,使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| :--------------------------------------------- | :--------------------- | +| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise返回音频流信息. | + +**示例:** + +``` +let streamInfo = await audioRenderer.getStreamInfo(); +console.log('Renderer GetStreamInfo:'); +console.log('Renderer sampling rate:' + streamInfo.samplingRate); +console.log('Renderer channel:' + streamInfo.AudioChannel); +console.log('Renderer format:' + streamInfo.AudioSampleFormat); +console.log('Renderer encoding type:' + streamInfo.AudioEncodingType); +``` + +### start8+ + +start(callback: AsyncCallback): void + +启动音频播放器。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------- | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +audioRenderer.start((err)=>{ + if (err) { + console.error('Renderer start failed.'); + } else { + console.info('Renderer start success.'); + } +}) +``` + +### start8+ + +start(): Promise + +启动音频播放器。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise方式异步返回结果。 | + +**示例:** + +``` +await audioRenderer.start(); +``` + +### pause8+ + +pause(callback: AsyncCallback\): void + +暂停音频播放器。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | 是 | 返回回调的结果。 | + +**示例:** + +``` +audioRenderer.pause((err)=>{ + if (err) { + console.error('Renderer pause failed'); + } else { + console.log('Renderer paused.'); + } +}) +``` + +### pause8+ + +pause(): Promise\ + +暂停音频播放器。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise方式异步返回结果。 | + +**示例:** + +``` +await audioRenderer.pause(); +``` + +### drain8+ + +drain(callback: AsyncCallback\): void + +检查播放缓冲区是否已被耗尽。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | 是 | 返回回调的结果。 | + +**示例:** + +``` +audioRenderer.drain((err)=>{ + if (err) { + console.error('Renderer drain failed'); + } else { + console.log('Renderer drained.'); + } +}) +``` + +### drain8+ + +drain(): Promise\ + +检查播放缓冲区是否已被耗尽。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise方式异步返回结果。 | + +**示例:** + +``` +await audioRenderer.drain(); +``` + +### stop8+ + +stop(callback: AsyncCallback\): void + +停止播放。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | 是 | 返回回调的结果。 | + +**示例:** + +``` +audioRenderer.stop((err)=>{ + if (err) { + console.error('Renderer stop failed'); + } else { + console.log('Renderer stopped.'); + } +}) +``` + +### stop8+ + +stop(): Promise\ + +停止播放。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise方式异步返回结果。 | + +**示例:** + +``` +await audioRenderer.stop(); +``` + +### release8+ + +release(callback: AsyncCallback\): void + +释放音频播放器。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | 是 | 返回回调的结果。 | + +**示例:** + +``` +audioRenderer.release((err)=>{ + if (err) { + console.error('Renderer release failed'); + } else { + console.log('Renderer released.'); + } +}) +``` + +### release8+ + +release(): Promise\ + +释放渲染器。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise方式异步返回结果。 | + +**示例:** + +``` +await audioRenderer.release(); +``` + +### write8+ + +write(buffer: ArrayBuffer, callback: AsyncCallback\): void + +写入缓冲区。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | --------------------------------------------------- | +| buffer | ArrayBuffer | 是 | 要写入缓冲区的数据。 | +| callback | AsyncCallback\ | 是 | 回调如果成功,返回写入的字节数,否则返回errorcode。 | + +**示例:** + +``` +let ss = fileio.createStreamSync(filePath, 'r'); +let buf = new ArrayBuffer(bufferSize); +ss.readSync(buf); +audioRenderer.write(buf, (err, writtenbytes)=>{ + if (writtenbytes < 0) { + console.error('write failed.'); + } else { + console.log('Actual written bytes: ' + writtenbytes); + } +}) +``` + +### write8+ + +write(buffer: ArrayBuffer): Promise\ + +写入缓冲区。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------------------------------------ | +| Promise\ | Promise返回结果,如果成功,返回写入的字节数,否则返回errorcode。 | + +**示例:** + +``` +let ss = fileio.createStreamSync(filePath, 'r'); +let buf = new ArrayBuffer(bufferSize); +ss.readSync(buf); +let writtenbytes = await audioRenderer.write(buf); +if (writtenbytes < 0) { + console.error('write failed.'); +} else { + console.log('Actual written bytes: ' + writtenbytes); +} +``` + +### getAudioTime8+ + +getAudioTime(callback: AsyncCallback\): void + +获取时间戳。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | 是 | 回调返回时间戳。 | + +**示例:** + +``` +audioRenderer.getAudioTime((err, timestamp)=>{ + console.log('Current timestamp: ' + timestamp); +}) +``` + +### getAudioTime8+ + +getAudioTime(): Promise\ + +获取时间戳。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 描述 | +| ---------------- | ----------------------- | +| Promise\ | Promise回调返回时间戳。 | + +**示例:** + +``` +let timestamp = await audioRenderer.getAudioTime(); +console.log('Current timestamp: ' + timestamp); +``` + +### getBufferSize8+ + +getBufferSize(callback: AsyncCallback\): void + +获取音频播放器的最小缓冲区大小。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | -------------------- | +| callback | AsyncCallback\ | 是 | 回调返回缓冲区大小。 | + +**示例:** + +``` +audioRenderer.getBufferSize((err, bufferSize)=>{ + if (err) { + console.error('getBufferSize error'); + } +}) +let buf = new ArrayBuffer(bufferSize); +ss.readSync(buf); +``` + +### getBufferSize8+ + +getBufferSize(): Promise\ + +获取音频播放器的最小缓冲区大小。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| ---------------- | --------------------------- | +| Promise\ | promise回调返回缓冲区大小。 | + +**示例:** + +``` +var bufferSize = await audioRenderer.getBufferSize(); +let buf = new ArrayBuffer(bufferSize); +ss.readSync(buf); +``` + +### setRenderRate8+ + +setRenderRate(rate: AudioRendererRate, callback: AsyncCallback\): void + +设置音频播放速率。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------ | +| rate | [AudioRendererRate](#audiorendererrate8) | 是 | 播放的速率。 | +| callback | AsyncCallback\ | 是 | 用于返回执行结果的回调。 | + +**示例:** + +``` +audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err)=> { + if (err) { + console.error('Failed to set params'); + } else { + console.log('Callback invoked to indicate a successful render rate setting.'); + } +}) +``` + +### setRenderRate8+ + +setRenderRate(rate: AudioRendererRate): Promise\ + +设置音频播放速率。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------------------------------- | ---- | ------------ | +| rate | [AudioRendererRate](#audiorendererrate8) | 是 | 播放的速率。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise用于返回执行结果。 | + +**示例:** + +``` +await audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL); +``` + +### getRenderRate8+ + +getRenderRate(callback: AsyncCallback\): void + +获取当前播放速率。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------ | +| callback | AsyncCallback<[AudioRendererRate](#audiorendererrate8)> | 是 | 回调返回播放速率。 | + +**示例:** + +``` +audioRenderer.getRenderRate((err, renderrate)=>{ + console.log('getRenderRate: ' + renderrate); +}) +``` + +### getRenderRate8+ + +getRenderRate(): Promise\ + +获取当前播放速率。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------- | ------------------------- | +| Promise<[AudioRendererRate](#audiorendererrate8)> | Promise回调返回播放速率。 | + +**示例:** + +``` +let renderRate = await audioRenderer.getRenderRate(); +console.log('getRenderRate: ' + renderrate); +``` + +### on('interrupt')8+ + +on(type: 'interrupt', callback: Callback\): void + +监听音频中断事件。使用callback获取中断事件。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 事件回调类型,支持的事件为:'interrupt'(中断事件被触发,音频播放被中断。) | +| callback | Callback<[InterruptEvent](#interruptevent8)> | 是 | 被监听的中断事件的回调。 | + +**示例:** + +``` +audioRenderer.on('interrupt', (interruptEvent) => { + if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { + switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.log('Force paused. Stop writing'); + isPlay = false; + break; + case audio.InterruptHint.INTERRUPT_HINT_STOP: + console.log('Force stopped. Stop writing'); + isPlay = false; + break; + } + } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { + switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_RESUME: + console.log('Resume force paused renderer or ignore'); + startRenderer(); + break; + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.log('Choose to pause or ignore'); + pauseRenderer(); + break; + } + } +}) +``` + + + diff --git a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md index fb4a41f4bbd0ba63a5088ad0a75c2c6677a1ee81..7e0470b09ba94fb61061c1b60851664db87c5f2f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -10,10 +10,6 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager'; ``` -## 系统能力 -SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask - ## 权限列表 长时任务需要申请如下权限: @@ -29,6 +25,8 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen 延迟挂起时间一般情况下默认值为180000,低电量(依据系统低电量广播)时默认值为60000。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -55,6 +53,8 @@ getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): 获取应用程序进入挂起状态前的剩余时间,使用callback形式返回。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -80,6 +80,8 @@ getRemainingDelayTime(requestId: number): Promise<number> 获取应用程序进入挂起状态前的剩余时间,使用Promise形式返回。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -107,6 +109,8 @@ cancelSuspendDelay(requestId: number): void 取消延迟挂起。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -122,6 +126,8 @@ cancelSuspendDelay(requestId: number): void 延迟挂起信息。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | requestId | number | 是 | 延迟挂起的请求ID。 | @@ -129,16 +135,18 @@ cancelSuspendDelay(requestId: number): void ## backgroundTaskManager.startBackgroundRunning -[8] startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void; +startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void; 8+ 向系统申请长时任务,使用callback形式返回结果。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | context | Context | 是 | 应用运行的上下文 | | bgMode | BackgroundMode | 是 | 向系统申请的后台模式 | - | wantAgent | WantAgent | 是 | 通知参数,用于指定长时任务通知点击跳转的界面。使用方式参考:[8] | + | wantAgent | [WantAgent](js-apis-notification.md#WantAgent接口) | 是 | 通知参数,用于指定长时任务通知点击后跳转的界面。 | | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果 | - **示例**: @@ -176,16 +184,18 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { ## backgroundTaskManager.startBackgroundRunning -[8] startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void> +startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void>; 8+ 向系统申请长时任务,使用promise形式返回结果。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | context | Context | 是 | 应用运行的上下文 | | bgMode | BackgroundMode | 是 | 向系统申请的后台模式 | - | wantAgent | WantAgent | 是 | 通知参数,用于指定长时任务通知点击跳转的界面 | + | wantAgent | [WantAgent](js-apis-notification.md#WantAgent接口) | 是 | 通知参数,用于指定长时任务通知点击跳转的界面 | - **返回值** | 类型 | 说明 | @@ -223,10 +233,12 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { ## backgroundTaskManager.stopBackgroundRunning -[8] stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void; +stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void; 8+ 向系统申请取消长时任务,使用callback形式返回结果。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -252,10 +264,12 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext(), callbac ## backgroundTaskManager.stopBackgroundRunning -[8] stopBackgroundRunning(context: Context): Promise<void>; +stopBackgroundRunning(context: Context): Promise<void>; 8+ 向系统申请取消长时任务,使用promise形式返回结果。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -279,16 +293,16 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() ``` -## [8] BackgroundMode +## BackgroundMode 8+ -| 参数名 | 参数 | 描述 | +| 参数名 | 参数值 | 描述 | | ----------------------- | -------- | -------- | -| DATA_TRANSFER | 1 | 数据传输 | -| AUDIO_PLAYBACK | 2 | 音频播放 | -| AUDIO_RECORDING | 3 | 录音 | -| LOCATION | 4 | 定位导航 | -| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 | -| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 | -| WIFI_INTERACTION | 7 | WLAN相关(系统保留) | -| VOIP | 8 | 音视频通话(系统保留) | -| TASK_KEEPING | 9 | 计算任务(仅供PC使用) | \ No newline at end of file +| DATA_TRANSFER | 1 | 数据传输
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| AUDIO_PLAYBACK | 2 | 音频播放
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| AUDIO_RECORDING | 3 | 录音
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| LOCATION | 4 | 定位导航
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| BLUETOOTH_INTERACTION | 5 | 蓝牙相关
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| MULTI_DEVICE_CONNECTION | 6 | 多设备互联
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| WIFI_INTERACTION | 7 | WLAN相关(系统保留)
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| VOIP | 8 | 音视频通话(系统保留)
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| TASK_KEEPING | 9 | 计算任务(仅供PC使用)
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-brightness.md b/zh-cn/application-dev/reference/apis/js-apis-brightness.md index 07ed408bb13416cb724b48b12bc01c47038a34e9..2398385699fc110af31de75c474e1d4a370b8977 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-brightness.md +++ b/zh-cn/application-dev/reference/apis/js-apis-brightness.md @@ -12,17 +12,15 @@ import brightness from '@ohos.brightness'; ``` -## 系统能力 - -SystemCapability.PowerManager.DisplayPowerManager - ## brightness.setValue setValue(value: number) 设置系统的屏幕亮度。 -**补充说明:**该接口为system api,仅供系统应用使用。 +**系统能力:** SystemCapability.PowerManager.DisplayPowerManager + +**补充说明:** 该接口为system api,仅供系统应用使用。 **参数:** @@ -33,6 +31,5 @@ setValue(value: number) **示例:** ``` -import brightness from '@ohos.brightness.d.ts'; brightness.setValue(128); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md index a1d5811928270b8cd10be1d09e53d878006d3343..09fa471f41b6d6e78803364275a2ccbbb3fa2d09 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @@ -116,18 +116,14 @@ import CommonEvent from '@ohos.commonEvent'; ``` -## 系统能力 - -```js -SystemCapability.Notification.CommonEvent -``` - ## CommonEvent.publish publish(event: string, callback: AsyncCallback\): void 发布公共事件(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -140,11 +136,15 @@ publish(event: string, callback: AsyncCallback\): void ```js //发布公共事件回调 function PublishCallBack(err) { - console.info("==========================>PublishCallBack=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("publish failed " + JSON.stringify(err)); + } else { + console.info("publish"); + } } + //发布公共事件 -CommonEvent.publish("publish_event", PublishCallBack); +CommonEvent.publish("event", PublishCallBack); ``` @@ -155,6 +155,8 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ 发布公共事件指定发布信息(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -173,12 +175,18 @@ var options = { data: "initial data",//公共事件的初始数据 isOrdered: true //有序公共事件 } + //发布公共事件回调 function PublishCallBack(err) { - console.info("==========================>PublishCallBack=======================>"); + if (err.code) { + console.error("publish failed " + JSON.stringify(err)); + } else { + console.info("publish"); + } } + //发布公共事件 -CommonEvent.publish("publish_event", options, PublishCallBack); +CommonEvent.publish("event", options, PublishCallBack); ``` @@ -189,6 +197,8 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\): vo 向指定用户发布公共事件(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -203,15 +213,17 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\): vo //发布公共事件回调 function PublishAsUserCallBack(err) { if (err.code) { - console.info("publishAsUser failed " + JSON.stringify(err)); + console.error("publishAsUser failed " + JSON.stringify(err)); } else { console.info("publishAsUser"); } } + //指定发送的用户 var userId = 100; + //发布公共事件 -CommonEvent.publish("publish_event", userId, PublishAsUserCallBack); +CommonEvent.publishAsUser("event", userId, PublishAsUserCallBack); ``` @@ -222,6 +234,8 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca 向指定用户发布公共事件并指定发布信息(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -240,18 +254,21 @@ var options = { code: 0; //公共事件的初始代码 data: "initial data";//公共事件的初始数据 } + //发布公共事件回调 function PublishAsUserCallBack(err) { if (err.code) { - console.info("publishAsUser failed " + JSON.stringify(err)); + console.error("publishAsUser failed " + JSON.stringify(err)); } else { console.info("publishAsUser"); } } + //指定发送的用户 var userId = 100; + //发布公共事件 -CommonEvent.publish("publish_event", userId, options, PublishAsUserCallBack); +CommonEvent.publishAsUser("event", userId, options, PublishAsUserCallBack); ``` @@ -262,6 +279,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac 创建订阅者(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -274,15 +293,22 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac ```js var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 + //订阅者信息 var subscribeInfo = { events: ["event"] }; + //创建订阅者回调 -function CreateSubscriberCallBack(err, data) { - console.info("==========================>CreateSubscriberCallBack=======================>"); - subscriber = data; +function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.error("createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; + } } + //创建订阅者 CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ``` @@ -295,6 +321,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\ { - console.info("==========================>createSubscriberPromise=======================>"); - subscriber = data; +CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; +}).catch((err) => { + console.error("createSubscriber failed " + JSON.stringify(err)); }); ``` @@ -329,6 +361,8 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\SubscribeCallBack=======================>"); + if (err.code) { + console.error("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribe " + JSON.stringify(data)); + } } + //创建订阅者回调 -function CreateSubscriberCallBack(err, data) { - console.info("==========================>CreateSubscriberCallBack=======================>"); - subscriber = data; - //订阅公共事件 - CommonEvent.subscribe(subscriber, SubscribeCallBack); +function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.error("createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; + //订阅公共事件 + CommonEvent.subscribe(subscriber, SubscribeCallBack); + } } + //创建订阅者 CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ``` @@ -365,6 +411,7 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ```js var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 + //订阅者信息 var subscribeInfo = { events: ["event"] @@ -372,40 +419,63 @@ var subscribeInfo = { //设置有序公共事件的结果代码回调 function SetCodeCallBack(err) { - console.info("==========================>SetCodeCallBack=======================>"); + if (err.code) { + console.error("setCode failed " + JSON.stringify(err)); + } else { + console.info("setCode"); + } } + //设置有序公共事件的结果数据回调 function SetDataCallBack(err) { - console.info("==========================>SetDataCallBack=======================>"); + if (err.code) { + console.error("setData failed " + JSON.stringify(err)); + } else { + console.info("setData"); + } } + //完成本次有序公共事件处理回调 function FinishCommonEventCallBack(err) { - console.info("==========================>FinishCommonEventCallBack=======================>"); + if (err.code) { + console.error("finishCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("finishCommonEvent"); + } } + //订阅公共事件回调 function SubscribeCallBack(err, data) { - console.info("==========================>SubscribeCallBack=======================>"); - //设置有序公共事件的结果代码 - subscriber.setCode(0, SetCodeCallBack); - //设置有序公共事件的结果数据 - subscriber.setData("publish_data_changed", SetDataCallBack); - //完成本次有序公共事件处理 - subscriber.finishCommonEvent(FinishCommonEventCallBack) + if (err.code) { + console.error("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribe " + JSON.stringify(data)); + //设置有序公共事件的结果代码 + subscriber.setCode(0, SetCodeCallBack); + //设置有序公共事件的结果数据 + subscriber.setData("publish_data_changed", SetDataCallBack); + //完成本次有序公共事件处理 + subscriber.finishCommonEvent(FinishCommonEventCallBack) + } } //创建订阅者回调 -function CreateSubscriberCallBack(err, data) { - console.info("==========================>CreateSubscriberCallBack=======================>"); - subscriber = data; - //订阅公共事件 - CommonEvent.subscribe(subscriber, SubscribeCallBack); +function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.error("createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; + //订阅公共事件 + CommonEvent.subscribe(subscriber, SubscribeCallBack); + } } //创建订阅者 CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ``` - + ## CommonEvent.unsubscribe @@ -413,6 +483,8 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): 取消订阅公共事件(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -424,61 +496,79 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): ```js var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 + //订阅者信息 var subscribeInfo = { events: ["event"] }; + //订阅公共事件回调 function SubscribeCallBack(err, data) { - console.info("==========================>SubscribeCallBack=======================>"); + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribe " + JSON.stringify(data)); + } } + //创建订阅者回调 -function CreateSubscriberCallBack(err, data) { - console.info("==========================>CreateSubscriberCallBack=======================>"); - subscriber = data; - //订阅公共事件 - CommonEvent.subscribe(subscriber, SubscribeCallBack); +function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.info("createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; + //订阅公共事件 + CommonEvent.subscribe(subscriber, SubscribeCallBack); + } } + //取消订阅公共事件回调 function UnsubscribeCallBack(err) { - console.info("==========================>UnsubscribeCallBack=======================>"); + if (err.code) { + console.info("unsubscribe failed " + JSON.stringify(err)); + } else { + console.info("unsubscribe"); + } } + //创建订阅者 CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); + //取消订阅公共事件 CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); ``` ## CommonEventPublishData -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| --------------------- | -------- | -------------------- | ---- | ---------------------------- | -| bundleName | 只读 | string | 否 | 表示包名称 | -| code | 只读 | number | 否 | 表示公共事件的结果代码 | -| data | 只读 | string | 否 | 表示公共事件的自定义结果数据 | -| subscriberPermissions | 只读 | Array\ | 否 | 表示订阅者的权限 | -| isOrdered | 只读 | boolean | 否 | 表示是否是有序事件 | -| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息 | +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| --------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| bundleName | 只读 | string | 否 | 表示包名称
**系统能力**:SystemCapability.Notification.CommonEvent | +| code | 只读 | number | 否 | 表示公共事件的结果代码
**系统能力**:SystemCapability.Notification.CommonEvent | +| data | 只读 | string | 否 | 表示公共事件的自定义结果数据
**系统能力**:SystemCapability.Notification.CommonEvent | +| subscriberPermissions | 只读 | Array\ | 否 | 表示订阅者的权限
**系统能力**:SystemCapability.Notification.CommonEvent | +| isOrdered | 只读 | boolean | 否 | 表示是否是有序事件
**系统能力**:SystemCapability.Notification.CommonEvent | +| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息
**系统能力**:SystemCapability.Notification.CommonEvent | ## CommonEventSubscribeInfo | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ | -| events | 只读 | Array\ | 是 | 表示要发送的公共事件 | -| publisherPermission | 只读 | string | 否 | 表示发布者的权限 | -| publisherDeviceId | 只读 | string | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID | -| userId | 只读 | number | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 | -| priority | 只读 | number | 否 | 表示订阅者的优先级。值的范围是-100到1000 | +| events | 只读 | Array\ | 是 | 表示要发送的公共事件
**系统能力**:SystemCapability.Notification.CommonEvent | +| publisherPermission | 只读 | string | 否 | 表示发布者的权限
**系统能力**:SystemCapability.Notification.CommonEvent | +| publisherDeviceId | 只读 | string | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID
**系统能力**:SystemCapability.Notification.CommonEvent | +| userId | 只读 | number | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。
**系统能力**:SystemCapability.Notification.CommonEvent | +| priority | 只读 | number | 否 | 表示订阅者的优先级。值的范围是-100到1000
**系统能力**:SystemCapability.Notification.CommonEvent | ## CommonEventData -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------ | -| event | 只读 | string | 是 | 表示当前接收的公共事件名称 | -| bundleName | 只读 | string | 否 | 表示包名称 | -| code | 只读 | number | 否 | 表示公共事件的结果代码,用于传递int类型的数据 | -| data | 只读 | string | 否 | 表示公共事件的自定义结果数据,用于传递string类型的数据 | -| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息 | +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| event | 只读 | string | 是 | 表示当前接收的公共事件名称
**系统能力**:SystemCapability.Notification.CommonEvent | +| bundleName | 只读 | string | 否 | 表示包名称
**系统能力**:SystemCapability.Notification.CommonEvent | +| code | 只读 | number | 否 | 表示公共事件的结果代码,用于传递int类型的数据
**系统能力**:SystemCapability.Notification.CommonEvent | +| data | 只读 | string | 否 | 表示公共事件的自定义结果数据,用于传递string类型的数据
**系统能力**:SystemCapability.Notification.CommonEvent | +| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息
**系统能力**:SystemCapability.Notification.CommonEvent | ## CommonEventSubscriber @@ -488,6 +578,8 @@ getCode(callback: AsyncCallback\): void 获取公共事件的结果代码(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -497,12 +589,16 @@ getCode(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 -function getCodeCallback(err, data) { - console.info("==========================>getCodeCallback=======================>"); - console.info("==========================>err:=======================>", err.code); - console.info("==========================>code:=======================>", data); +getCode() { +function getCodeCallback(err, Code) { + if (err.code) { + console.error("getCode failed " + JSON.stringify(err)); + } else { + console.info("getCode " + JSON.stringify(Code)); + } } subscriber.getCode(getCodeCallback); ``` @@ -513,6 +609,8 @@ getCode(): Promise\ 获取公共事件的结果代码(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **返回值:** | 类型 | 说明 | @@ -522,10 +620,12 @@ getCode(): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -subscriber.getCode().then((data) => { - console.info("==========================>getCodePromise=======================>"); - console.info("==========================>code:=======================>", data); +var subscriber; //创建成功的订阅者对象 + +subscriber.getCode().then((Code) => { + console.info("getCode " + JSON.stringify(Code)); +}).catch((err) => { + console.error("getCode failed " + JSON.stringify(err)); }); ``` @@ -535,6 +635,8 @@ setCode(code: number, callback: AsyncCallback\): void 设置公共事件的结果代码(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -545,11 +647,15 @@ setCode(code: number, callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 function setCodeCallback(err) { - console.info("==========================>setCodeCallback=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("setCode failed " + JSON.stringify(err)); + } else { + console.info("setCode"); + } } subscriber.setCode(1, setCodeCallback); ``` @@ -560,6 +666,8 @@ setCode(code: number): Promise\ 设置公共事件的结果代码(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -569,9 +677,12 @@ setCode(code: number): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + subscriber.setCode(1).then(() => { - console.info("==========================>setCodePromise=======================>"); + console.info("setCode"); +}).catch((err) => { + console.error("setCode failed " + JSON.stringify(err)); }); ``` @@ -581,6 +692,8 @@ getData(callback: AsyncCallback\): void 获取公共事件的结果数据(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -590,12 +703,15 @@ getData(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 -function getDataCallback(err, data) { - console.info("==========================>getDataCallback=======================>"); - console.info("==========================>err:=======================>", err.code); - console.info("==========================>data:=======================>", data); +function getDataCallback(err, Data) { + if (err.code) { + console.error("getData failed " + JSON.stringify(err)); + } else { + console.info("getData " + JSON.stringify(Data)); + } } subscriber.getData(getDataCallback); ``` @@ -606,6 +722,8 @@ getData(): Promise\ 获取公共事件的结果数据(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **返回值:** | 类型 | 说明 | @@ -615,10 +733,12 @@ getData(): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -subscriber.getData().then((data) => { - console.info("==========================>getDataPromise=======================>"); - console.info("==========================>data:=======================>", data); +var subscriber; //创建成功的订阅者对象 + +subscriber.getData().then((Data) => { + console.info("getData " + JSON.stringify(Data)); +}).catch((err) => { + console.error("getData failed " + JSON.stringify(err)); }); ``` @@ -628,6 +748,8 @@ setData(data: string, callback: AsyncCallback\): void 设置公共事件的结果数据(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -638,11 +760,15 @@ setData(data: string, callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 function setDataCallback(err) { - console.info("==========================>setDataCallback=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("setData failed " + JSON.stringify(err)); + } else { + console.info("setData"); + } } subscriber.setData("publish_data_changed", setDataCallback); ``` @@ -653,6 +779,8 @@ setData(data: string): Promise\ 设置公共事件的结果数据(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -662,9 +790,12 @@ setData(data: string): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + subscriber.setData("publish_data_changed").then(() => { - console.info("==========================>setDataPromise=======================>"); + console.info("setData"); +}).catch((err) => { + console.error("setData failed " + JSON.stringify(err)); }); ``` @@ -674,6 +805,8 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\): void 设置公共事件的结果代码和结果数据(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -685,11 +818,15 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 function setCodeDataCallback(err) { - console.info("==========================>setCodeDataCallback=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("setCodeAndData failed " + JSON.stringify(err)); + } else { + console.info("setCodeDataCallback"); + } } subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback); ``` @@ -700,6 +837,8 @@ setCodeAndData(code: number, data: string): Promise\ 设置公共事件的结果代码和结果数据(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -710,9 +849,12 @@ setCodeAndData(code: number, data: string): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + subscriber.setCodeAndData(1, "publish_data_changed").then(() => { - console.info("==========================>setCodeAndData=======================>"); + console.info("setCodeAndData"); +}).catch((err) => { + console.info("setCodeAndData failed " + JSON.stringify(err)); }); ``` @@ -724,6 +866,8 @@ isOrderedCommonEvent(callback: AsyncCallback\): void 返回true代表是有序公共事件,false代表不是有序公共事件。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -733,12 +877,15 @@ isOrderedCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 -function isOrderedCallback(err, data) { - console.info("==========================>isOrderedCallback=======================>"); - console.info("==========================>err:=======================>", err.code); - console.info("==========================>isOrdered:=======================>", data); +function isOrderedCallback(err, isOrdered) { + if (err.code) { + console.error("isOrderedCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("isOrdered " + JSON.stringify(isOrdered)); + } } subscriber.isOrderedCommonEvent(isOrderedCallback); ``` @@ -751,6 +898,8 @@ isOrderedCommonEvent(): Promise\ 返回true代表是有序公共事件,false代表不是有序公共事件。 +**系统能力**:SystemCapability.Notification.CommonEvent + **返回值:** | 类型 | 说明 | @@ -760,9 +909,12 @@ isOrderedCommonEvent(): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -subscriber.isOrderedCommonEvent().then((data) => { - console.info("==========================>isOrdered:=======================>", data); +var subscriber; //创建成功的订阅者对象 + +subscriber.isOrderedCommonEvent().then((isOrdered) => { + console.info("isOrdered " + JSON.stringify(isOrdered)); +}).catch((err) => { + console.error("isOrdered failed " + JSON.stringify(err)); }); ``` @@ -772,6 +924,8 @@ abortCommonEvent(callback: AsyncCallback\): void 取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -781,11 +935,15 @@ abortCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 function abortCallback(err) { - console.info("==========================>abortCallback=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("abortCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("abortCommonEvent"); + } } subscriber.abortCommonEvent(abortCallback); ``` @@ -796,12 +954,17 @@ abortCommonEvent(): Promise\ 取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + subscriber.abortCommonEvent().then(() => { - console.info("==========================>abortCommonEvent:=======================>"); + console.info("abortCommonEvent"); +}).catch((err) => { + console.error("abortCommonEvent failed " + JSON.stringify(err)); }); ``` @@ -811,6 +974,8 @@ clearAbortCommonEvent(callback: AsyncCallback\): void 清除当前公共事件的取消状态,仅对有序公共事件有效(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -820,11 +985,15 @@ clearAbortCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 function clearAbortCallback(err) { - console.info("==========================>clearAbortCallback=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("clearAbortCommonEvent"); + } } subscriber.clearAbortCommonEvent(clearAbortCallback); ``` @@ -835,12 +1004,17 @@ clearAbortCommonEvent(): Promise\ 清除当前公共事件的取消状态,仅对有序公共事件有效(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + subscriber.clearAbortCommonEvent().then(() => { - console.info("==========================>clearAbortCommonEvent:=======================>"); + console.info("clearAbortCommonEvent"); +}).catch((err) => { + console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); }); ``` @@ -850,6 +1024,8 @@ getAbortCommonEvent(callback: AsyncCallback\): void 获取当前有序公共事件是否取消的状态(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -859,12 +1035,15 @@ getAbortCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 -function getAbortCallback(err, data) { - console.info("==========================>getAbortCallback=======================>"); - console.info("==========================>err:=======================>", err.code); - console.info("==========================>abort:=======================>", data); +function getAbortCallback(err, AbortCommonEvent) { + if (err.code) { + console.error("getAbortCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("AbortCommonEvent " + AbortCommonEvent) + } } subscriber.getAbortCommonEvent(getAbortCallback); ``` @@ -875,6 +1054,8 @@ getAbortCommonEvent(): Promise\ 获取当前有序公共事件是否取消的状态(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **返回值:** | 类型 | 说明 | @@ -884,10 +1065,12 @@ getAbortCommonEvent(): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -subscriber.getAbortCommonEvent().then((data) => { - console.info("==========================>getAbortCommonEvent:=======================>"); - console.info("==========================>abort:=======================>", data); +var subscriber; //创建成功的订阅者对象 + +subscriber.getAbortCommonEvent().then((AbortCommonEvent) => { + console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent)); +}).catch((err) => { + console.error("getAbortCommonEvent failed " + JSON.stringify(err)); }); ``` @@ -897,6 +1080,8 @@ getSubscribeInfo(callback: AsyncCallback\): void 获取订阅者的订阅信息(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -906,12 +1091,15 @@ getSubscribeInfo(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 -function getSubscribeInfoCallback(err, data) { - console.info("==========================>getSubscribeInfoCallback=======================>"); - console.info("==========================>err:=======================>", err.code); - console.info("==========================>priority:=======================>", data.priority); +function getSubscribeInfoCallback(err, SubscribeInfo) { + if (err.code) { + console.error("getSubscribeInfo failed " + JSON.stringify(err)); + } else { + console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); + } } subscriber.getSubscribeInfo(getSubscribeInfoCallback); ``` @@ -922,6 +1110,8 @@ getSubscribeInfo(): Promise\ 获取订阅者的订阅信息(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **返回值:** | 类型 | 说明 | @@ -931,9 +1121,12 @@ getSubscribeInfo(): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -subscriber.getSubscribeInfo().then((data) => { - console.info("==========================>getSubscribeInfo:=======================>"); - console.info("==========================>priority:=======================>", data.priority); +var subscriber; //创建成功的订阅者对象 + +subscriber.getSubscribeInfo().then((SubscribeInfo) => { + console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); +}).catch((err) => { + console.error("getSubscribeInfo failed " + JSON.stringify(err)); }); -``` \ No newline at end of file +``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-configuration.md b/zh-cn/application-dev/reference/apis/js-apis-configuration.md index de828384dd5ebf5ade4327d6812dbba3dd6db80c..776ae3d6d414c46f6579f3854f458b48bbbf23d2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-configuration.md +++ b/zh-cn/application-dev/reference/apis/js-apis-configuration.md @@ -1,11 +1,7 @@ # Configuration -- [导入模块](#导入模块) -- [属性](#属性) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 8开始支持。 +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 环境变化信息。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md b/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md index 741cbe9dd02e20e4b5fd9dc072c971acb5981934..3f17f1419ae03ec75c30d58332c3928664d3c63f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md +++ b/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md @@ -1,13 +1,7 @@ # ConfigurationConstant -- [导入模块](#导入模块) -- [ColorMode](#ColorMode) -- [Direction](#Direction) -- [ScreenDensity](#ScreenDensity) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 8开始支持。 +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 配置信息枚举值定义。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md index 02cb52e20528506dac53438ffcd04264506b7f2b..ff10035a59a11d7d11204cbef82a5ff961a3455c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -752,7 +752,7 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.Data | 类型 | 说明 | | ---------------- | -------------------------------------------- | -| Promise\ | 返回值为Promise对象,Promise中包含应用信息。 | +| Promise\ | Promise中包含更新的数据记录数。 。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md b/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md index 0ff74ddd4019ca2b8bf558c5da2034ec35682199..8a8634363b7ed99e777444ce9c95a747951cd49b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @@ -7,10 +7,10 @@ ## 导入模块 ``` -import stats from '@ohos.usagestatskit' +import stats from '@ohos.bundleState' ``` -## usagestatskit.isIdleState +## bundleState.isIdleState isIdleState(bundleName: string, callback: AsyncCallback): void - **系统能力**: @@ -26,20 +26,22 @@ SystemCapability.ResourceSchedule.UsageStatistics.AppGroup | bundleName | string | 是 | 应用的bundleName。| | callback | AsyncCallback | 是 | 指定的callback回调方法。如果指定的bundleName有效,则返回指定bundleName的应用当前是否是空闲状态;否则返回null。 | +- **权限**: +无权限 - **示例**: ``` stats.isIdleState("com.ohos.camera", (err, res) => { - if(err.data === 0) { - console.log('isIdleState callback succeeded, result: ' + JSON.stringify(res)); + if(err.code === 0) { + console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res)); } else { - console.log('isIdleState callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code); } }); ``` -## usagestatskit.isIdleState +## bundleState.isIdleState isIdleState(bundleName: string): Promise; - **系统能力**: @@ -60,17 +62,20 @@ SystemCapability.ResourceSchedule.UsageStatistics.AppGroup | -------- | -------- | | Promise | 指定的Promise回调方法。如果指定的bundleName有效,则返回指定bundleName的应用当前是否是空闲状态;否则返回null。 | +- **权限**: +无权限 + - **示例**: ``` stats.isIdleState("com.ohos.camera").then( res => { - console.log('isIdleState callback succeeded, result: ' + JSON.stringify(res)); + console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res)); }).catch( err => { - console.log('isIdleState callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code); }); ``` -## usagestatskit.queryAppUsagePriorityGroup +## bundleState.queryAppUsagePriorityGroup queryAppUsagePriorityGroup(callback: AsyncCallback): void - **系统能力**: @@ -85,19 +90,22 @@ SystemCapability.ResourceSchedule.UsageStatistics.AppGroup | -------- | -------- | -------- | -------- | | callback | AsyncCallback | 是 | 指定的callback回调方法。返回当前调用者应用的使用优先级群组。| +- **权限**: +无权限 + - **示例**: ``` stats.queryAppUsagePriorityGroup((err, res) => { - if(err.data === 0) { - console.log('queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); + if(err.code === 0) { + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); } else { - console.log('queryAppUsagePriorityGroup callback failed. because: ' + err.data); + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code); } }); ``` -## usagestatskit.queryAppUsagePriorityGroup +## bundleState.queryAppUsagePriorityGroup queryAppUsagePriorityGroup(): Promise - **系统能力**: @@ -112,17 +120,20 @@ SystemCapability.ResourceSchedule.UsageStatistics.AppGroup | -------- | -------- | | Promise | 指定的Promise回调方法。查询(返回)当前调用者应用的使用优先级群组。| +- **权限**: +无权限 + - **示例**: ``` stats.queryAppUsagePriorityGroup().then( res => { - console.log('queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); }).catch( err => { - console.log('queryAppUsagePriorityGroup promise failed. because: ' + err.data); + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code); }); ``` -## usagestatskit.queryBundleStateInfos +## bundleState.queryBundleStateInfos queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback): void - **系统能力**: @@ -139,25 +150,28 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | end | number | 是 | 结束时间。| | callback | AsyncCallback | 是 | 指定的callback回调方法。返回指定起始和结束时间内应用使用时长统计信息。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleStateInfos(0, 20000000000000, (err, res) => { - console.log('queryBundleStateInfos callback succeeded, data number: ' + res.length); - if(err.data == 0) { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.'); + let i = 1; for(let key in res){ - console.log("queryBundleStateInfos callback key = " + key) - console.log("queryBundleStateInfos callback bundleName = " + res[key].bundleName) - console.log("queryBundleStateInfos callback abilityPrevAccessTime = " + res[key].abilityPrevAccessTime) - console.log("queryBundleStateInfos callback abilityInFgTotalTime = " + res[key].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback number : ' + i); + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key])); + i++; } } else { - console.log('queryBundleStateInfos callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code); } }); ``` -## usagestatskit.queryBundleStateInfos +## bundleState.queryBundleStateInfos queryBundleStateInfos(begin: number, end: number): Promise - **系统能力**: @@ -179,23 +193,26 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | -------- | -------- | | Promise | 指定的Promise回调方法。返回指定起始和结束时间内应用使用时长统计信息。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleStateInfos(0, 20000000000000).then( res => { - console.log('queryBundleStateInfos promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.'); + let i = 1; for(let key in res){ - console.log("queryBundleStateInfos promise key = " + key) - console.log("queryBundleStateInfos promise bundleName = " + res[key].bundleName) - console.log("queryBundleStateInfos promise abilityPrevAccessTime = " + res[key].abilityPrevAccessTime) - console.log("queryBundleStateInfos promise abilityInFgTotalTime = " + res[key].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise number : ' + i); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key])); + i++; } }).catch( err => { - console.log('queryBundleStateInfos promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code); }); ``` -## usagestatskit.queryBundleStateInfoByInterval +## bundleState.queryBundleStateInfoByInterval queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback>): void - **系统能力**: @@ -213,24 +230,26 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | end | number | 是 | 结束时间。| | callback | AsyncCallback> | 是 | 指定的callback回调方法。返回指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => { - console.log('queryBundleStateInfoByInterval callback succeeded, data number: ' + res.length); - if(err.data == 0) { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleStateInfoByInterval, callback bundleName = " + res[i].bundleName) - console.log("queryBundleStateInfoByInterval, callback abilityPrevAccessTime = " + res[i].abilityPrevAccessTime) - console.log("queryBundleStateInfoByInterval, callback abilityInFgTotalTime = " + res[i].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i])); } } else { - console.log('queryBundleStateInfoByInterval callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code); } }); ``` -## usagestatskit.queryBundleStateInfoByInterval +## bundleState.queryBundleStateInfoByInterval queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise> - **系统能力**: @@ -253,22 +272,24 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | -------- | -------- | | Promise> | 指定的Promise回调方法。返回指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => { - console.log('queryBundleStateInfoByInterval promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleStateInfoByInterval, promise bundleName = " + res[i].bundleName) - console.log("queryBundleStateInfoByInterval, promise abilityPrevAccessTime = " + res[i].abilityPrevAccessTime) - console.log("queryBundleStateInfoByInterval, promise abilityInFgTotalTime = " + res[i].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryBundleStateInfoByiInterval promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code); }); ``` -## usagestatskit.queryBundleActiveStates +## bundleState.queryBundleActiveStates queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void - **系统能力**: @@ -285,24 +306,26 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | end | number | 是 | 结束时间。| | callback | AsyncCallback> | 是 | 指定的callback回调方法。返回指定起始和结束时间查询所有应用的事件集合。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleActiveStates(0, 20000000000000, (err, res) => { - console.log('queryBundleActiveStates callback succeeded, data number: ' + res.length); - if(err.data == 0) { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleActiveStates, callback bundleName = " + res[i].bundleName) - console.log("queryBundleActiveStates, callback stateType = " + res[i].stateType) - console.log("queryBundleActiveStates, callback stateOccurredTime = " + res[i].stateOccurredTime) + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i])); } } else { - console.log('queryBundleActiveStates callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code); } }); ``` -## usagestatskit.queryBundleActiveStates +## bundleState.queryBundleActiveStates queryBundleActiveStates(begin: number, end: number): Promise> - **系统能力**: @@ -324,22 +347,24 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | -------- | -------- | | Promise> | 指定的Promise回调方法。返回指定起始和结束时间查询所有应用的事件集合。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleActiveStates(0, 20000000000000).then( res => { - console.log('queryBundleActiveStates promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleActiveStates, promise bundleName = " + res[i].bundleName) - console.log("queryBundleActiveStates, promise stateType = " + res[i].stateType) - console.log("queryBundleActiveStates, promise stateOccurredTime = " + res[i].stateOccurredTime) + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryBundleActiveStates promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code); }); ``` -## usagestatskit.queryCurrentBundleActiveStates +## bundleState.queryCurrentBundleActiveStates queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void - **系统能力**: @@ -356,24 +381,26 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | end | number | 是 | 结束时间。| | callback | AsyncCallback> | 是 | 指定的callback回调方法。返回指定起始和结束时间查询当前应用的事件集合。| +- **权限**: +无权限 + - **示例**: ``` - stats.queryCurrentBundleActiveStates(0, 20000000000000,(err, res) => { - console.log('queryCurrentBundleActiveStates callback succeeded, data number: ' + res.length); - if(err.data == 0) { + stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.'); for (let i = 0; i < res.length; i++) { - console.log("queryCurrentBundleActiveStates, callback bundleName = " + res[i].bundleName) - console.log("queryCurrentBundleActiveStates, callback stateType = " + res[i].stateType) - console.log("queryCurrentBundleActiveStates, callback stateOccurredTime = " + res[i].stateOccurredTime) - } + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i])); + } } else { - console.log('queryCurrentBundleActiveStates callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code); } }); ``` -## usagestatskit.queryCurrentBundleActiveStates +## bundleState.queryCurrentBundleActiveStates queryCurrentBundleActiveStates(begin: number, end: number): Promise> - **系统能力**: @@ -395,26 +422,30 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | -------- | -------- | | Promise> | 指定的Promise回调方法。返回指定起始和结束时间查询当前应用的事件集合。| +- **权限**: +无权限 + - **示例**: ``` stats.queryCurrentBundleActiveStates(0, 20000000000000).then( res => { - console.log('queryCurrentBundleActiveStates promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryCurrentBundleActiveStates, promise bundleName = " + res[i].bundleName) - console.log("queryCurrentBundleActiveStates, promise stateType = " + res[i].stateType) - console.log("queryCurrentBundleActiveStates, promise stateOccurredTime = " + res[i].stateOccurredTime) + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryCurrentBundleActiveStates promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code); }); ``` -## usagestatskit.BundleStateInfo +## bundleState.BundleStateInfo - **系统能力**: SystemCapability.ResourceSchedule.UsageStatistics.App -提供应用使用时长的具体信息。 +- **参数**: + + 提供应用使用时长的具体信息。 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -422,11 +453,13 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | abilityPrevAccessTime | number | 是 | 应用最后一次使用的时间。| | abilityInFgTotalTime | number | 是 | 应用在前台使用的总时间。| -## usagestatskit.BundleActiveState +## bundleState.BundleActiveState - **系统能力**: SystemCapability.ResourceSchedule.UsageStatistics.App -提供应用事件的具体信息。 +- **参数**: + + 提供应用事件的具体信息。 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -434,21 +467,25 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | stateType | number | 是 | 应用事件类型。| | stateOccurredTime | number | 是 | 应用事件发生的时间戳。| -## usagestatskit.BundleActiveInfoResponse +## bundleState.BundleActiveInfoResponse - **系统能力**: SystemCapability.ResourceSchedule.UsageStatistics.App -提供应用使用时长的具体信息。 +- **参数**: + + 提供应用使用时长的具体信息。 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | [key: string]: BundleStateInfo | BundleStateInfo | 是 | 不同应用的使用时长统计信息。| -## usagestatskit.IntervalType +## bundleState.IntervalType - **系统能力**: SystemCapability.ResourceSchedule.UsageStatistics.App -触发工作的网络类型。 +- **参数**: + + 提供查询的类型 |名称 |默认值 |说明| | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md index 84e8d00c2bac1720679ac16694d5857f95651d83..cdce9e3617ce117b221abcd8b86d6bb3564cdc8a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md +++ b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md @@ -1,16 +1,10 @@ # EventHub -- [使用说明](#使用说明) -- [on](#on) -- [off](#off) -- [emit](#emit) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。 +> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -事件中心。提供订阅、取消订阅、触发事件能力。 +事件中心,提供订阅、取消订阅、触发事件能力。 ## 使用说明 diff --git a/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md index 36b807c84b12e60d9a89f6cd83cccf3b8888d058..19ed0e0bc21061498f088df2ad6eb659bd16a948 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md @@ -1,12 +1,7 @@ # ExtensionRunningInfo -- [使用说明](#使用说明) - - [属性](#属性) -- [bundle.ExtensionAbilityType](#bundleExtensionAbilityType) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 8开始支持。 +> 本模块首批接口从API 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 Extension运行相关信息。 @@ -36,7 +31,7 @@ abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => { | uid | number | 是 | 否 | 用户ID。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | | processName | string | 是 | 否 | 进程名称。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | | startTime | number | 是 | 否 | Extension启动时间。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | -| clientPackage | Array<String> | 是 | 否 | 连接客户端包名。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| clientPackage | Array<String> | 是 | 否 | 表示当期进程下的所有包名。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | | type | [bundle.ExtensionAbilityType](#bundle-extensionabilitytype) | 是 | 否 | Extension类型。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | @@ -47,7 +42,7 @@ Extension类型。 | 名称 | 值 | 说明 | | -------- | -------- | -------- | | FORM | 0 | 表示带有form类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | -| WORK_SCHEDULER | 1 | 表示带有work schedule类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | +| WORK_SCHEDULER | 1 | 表示带有work scheduler类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | | INPUT_METHOD | 2 | 表示用输入法类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | | SERVICE | 3 | 表示带有service类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | | ACCESSIBILITY | 4 | 表示具有可访问性类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | diff --git a/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md b/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md index f27debab52af246072586d603dc599801b065e03..9ea0cbac0f5e00ae9f4dffacabb88256580d59fc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md +++ b/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md @@ -73,7 +73,7 @@ function queryFaultLogCallback(error, value) { } } } -faultLogger.querySelfFaultLog(faultlogger.FaultType.JS_CRASH, queryFaultLogCallback); +faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback); ``` ## faultLogger.querySelfFaultLog @@ -97,20 +97,22 @@ querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>&g **示例:** ``` -let value = await faultLogger.querySelfFaultLog(faultlogger.FaultType.JS_CRASH); -if (value) { - console.info("value length is " + value.length); - let len = value.length; - for (let i = 0; i < len; i++) { - console.info("log: " + i); - console.info("Log pid: " + value[i].pid); - console.info("Log uid: " + value[i].uid); - console.info("Log type: " + value[i].type); - console.info("Log ts: " + value[i].ts); - console.info("Log reason: " + value[i].reason); - console.info("Log module: " + value[i].module); - console.info("Log summary: " + value[i].summary); - console.info("Log text: " + value[i].fullLog); +async function getLog() { + let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH); + if (value) { + console.info("value length is " + value.length); + let len = value.length; + for (let i = 0; i < len; i++) { + console.info("log: " + i); + console.info("Log pid: " + value[i].pid); + console.info("Log uid: " + value[i].uid); + console.info("Log type: " + value[i].type); + console.info("Log ts: " + value[i].ts); + console.info("Log reason: " + value[i].reason); + console.info("Log module: " + value[i].module); + console.info("Log summary: " + value[i].summary); + console.info("Log text: " + value[i].fullLog); + } } } -``` \ No newline at end of file +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md index 5c520aef02ef740eb995f5deaaf250815dd969c6..28aacbace59ca9b96e5eb76d9cbdef16c839be89 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md @@ -4,7 +4,7 @@ ## 导入模块 ```js -import filemanager from 'ohos.filemanager'; +import filemanager from '@ohos.fileManager'; ``` ## 系统能力 @@ -71,7 +71,7 @@ filemanager.getRoot((err, fileInfo) => { listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}) : Promise<FileInfo[]> -以异步方法获取获取第二层相册,文件信息。使用promise形式返回结果。 +以异步方法获取第二层相册,文件信息。使用promise形式返回结果。 - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -106,8 +106,7 @@ filemanager.listFile(media_path, "file") console.log(JSON.Stringify(fileInfo)) } } -}) -.catch((err) => { +}).catch((err) => { console.log(err) }) ``` @@ -115,7 +114,7 @@ filemanager.listFile(media_path, "file") listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback<FileInfo[]>) : void -以异步方法获取获取第二层相册,文件信息。使用callback形式返回结果。 +以异步方法获取第二层相册,文件信息。使用callback形式返回结果。 - 参数 diff --git a/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md b/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md index 78d3e21d8b0170012c399610cca5c05fd1c394d7..aab3ba2e587c9ef80c41fb6282cd3c7b42828f51 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md @@ -19,14 +19,14 @@ SystemCapability.HiviewDFX.HiTrace | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | -| DEFAULT | 0 | 缺省标志 | -| INCLUDE_ASYNC | 1 | 异步调用标志 | -| DONOT_CREATE_SPAN | 1 << 1 | 无分支标志 | -| TP_INFO | 1 << 2 | 埋点标志 | -| NO_BE_INFO | 1 << 3 | 无起始结束标志 | -| DISABLE_LOG | 1 << 4 | 日志关联标志 | -| FAILURE_TRIGGER | 1 << 5 | 故障触发标志 | -| D2D_TP_INFO | 1 << 6 | 设备间埋点标志 | +| DEFAULT | 0 | 缺省标志。 | +| INCLUDE_ASYNC | 1 | 异步调用标志。启动跟踪时,缺省只跟踪同步调用。设置该标志,同时跟踪同步、异步调用。 | +| DONOT_CREATE_SPAN | 1 << 1 | 无分支标志。启动跟踪时,在同步、异步调用时缺省自动创建分支信息。设置该标志,指示不创建分支。 | +| TP_INFO | 1 << 2 | 埋点标志。启动跟踪式时,缺省不进行埋点。调试场景下设置该标志,在同步、异步调用的收发侧自动埋点,输出埋点信息和时间戳。收发埋点按照client、server分为[client send(CS)、server receive(SR)、server send(SS)、client receive(CR)](#hitracetracepointtype)四类信息。一次同步调用输出CS/SR/SS/CR,一次异步调用输出CS/SR/SS三个埋点信息。 | +| NO_BE_INFO | 1 << 3 | 无起始结束标志。启动跟踪时,缺省打印启动及结束跟踪信息。设置该标志,指示不打印启动及结束跟踪信息。 | +| DISABLE_LOG | 1 << 4 | 日志关联标志。设置该标志,指示隐藏日志中的跟踪信息。 | +| FAILURE_TRIGGER | 1 << 5 | 故障触发标志。预置标志,暂时没有作用。 | +| D2D_TP_INFO | 1 << 6 | 设备间埋点标志。TP_INFO的一个子集,设置该标志,只进行设备间的调用埋点。 | ## HiTraceTracepointType @@ -34,11 +34,11 @@ SystemCapability.HiviewDFX.HiTrace | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | -| CS | 0 | 客户端发送类型 | -| CR | 1 | 客户端接收类型 | -| SS | 2 | 服务端发送类型 | -| SR | 3 | 服务端接收类型 | -| GENERAL | 4 | 常规类型 | +| CS | 0 | 客户端发送类型,标识client侧的发送埋点。 | +| CR | 1 | 客户端接收类型,标识client侧的接收埋点。 | +| SS | 2 | 服务端发送类型,标识server侧的发送埋点。 | +| SR | 3 | 服务端接收类型,标识server侧的接收埋点。 | +| GENERAL | 4 | 一般类型,标识CS、CR、SS、SR四种场景之外的埋点。| ## HiTraceCommunicationMode @@ -46,7 +46,7 @@ SystemCapability.HiviewDFX.HiTrace | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | -| DEFAULT | 0 | 缺省方式 | +| DEFAULT | 0 | 缺省通信类型 | | THREAD | 1 | 线程间通信类型 | | PROCESS | 2 | 进程间通信类型 | | DEVICE | 3 | 设备间通信类型 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-i18n.md b/zh-cn/application-dev/reference/apis/js-apis-i18n.md index 5dfcf16cf0b3f359ec2afb89c244c1cca9b8e14f..e7d49645e542163fb2aa87724abd6d100fdb0d0b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-i18n.md +++ b/zh-cn/application-dev/reference/apis/js-apis-i18n.md @@ -111,6 +111,63 @@ getSystemLanguage(): string ``` +## i18n.setSystemLanguage + +setSystemLanguage(): boolean + +设置系统语言。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回true,表示系统语言设置成功;返回false,表示系统语言设置失败。 | + +- 示例: + ``` + i18n.setSystemLanguage(); + ``` + + +## i18n.getSystemLanguages + +getSystemLanguages(): Array + +获取系统支持的语言列表。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Array | 系统支持的语言ID列表。 | + +- 示例: + ``` + i18n.getSystemLanguages(); + ``` + + +## i18n.getSystemCountries + +getSystemCountries(): Array + +获取系统支持的区域列表。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Array | 系统支持的区域ID列表。 | + +- 示例: + ``` + i18n.getSystemCountries(); + ``` + + ## i18n.getSystemRegion getSystemRegion(): string @@ -130,6 +187,25 @@ getSystemRegion(): string ``` +## i18n.setSystemRegion + +setSystemRegion(): boolean + +设置系统区域。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回true,表示系统区域设置成功;返回false,表示系统区域设置失败。 | + +- 示例: + ``` + i18n.setSystemRegion(); + ``` + + ## i18n.getSystemLocale getSystemLocale(): string @@ -149,6 +225,55 @@ getSystemLocale(): string ``` +## i18n.setSystemLocale + +setSystemLocale(locale: string): boolean + +设置系统Locale。 + +**系统能力**:SystemCapability.Global.I18n + +- 参数: + | 参数名 | 类型 | 说明 | + | -------- | -------- | -------- | + | locale | string | 指定区域ID,例如zh-CN。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回true,表示系统Locale设置成功;返回false,表示系统Locale设置失败。 | + +- 示例: + ``` + i18n.setSystemLocale('zh-CN'); + ``` + + +## i18n.isSuggested + +isSuggested(language: string, region?: string): boolean + +判断当前语言和区域是否匹配。 + +**系统能力**:SystemCapability.Global.I18n + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | language | string | 是 | 合法的语言ID,例如zh。 | + | region | string | 否 | 合法的地区ID,例如CN | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回true,表示当前语言和地区匹配;返回false,表示当前语言和地区不匹配。 | + +- 示例: + ``` + i18n.isSuggested('zh', 'CN'); + ``` + + ## i18n.getCalendar8+ getCalendar(locale: string, type? : string): Calendar diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index 9dbb932ac72f046b8c5ebe056bb2b74b17534007..74446dfbb9f826742c440d847080c80c9545be43 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -8,28 +8,28 @@ --------- ``` -import image from './@ohos.multimedia.image'; +import image from '@ohos.multimedia.image'; ``` -## image.createPixelMap +## image.createPixelMap8+ createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions): Promise\ -通过colors和opts创建pixelmap。 +通过属性创建Pixelmap,通过Promise返回结果。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------ | ----------------------------------------------- | ---- | ------------------------------------------------------------ | -| colors | ArrayBuffer | 是 | 颜色数组。 | -| opts | [InitializetionOptions](#InitializationOptions) | 是 | 创建像素的属性,包括透明度,尺寸,缩略值,像素格式和是否可编辑。 | +| 名称 | 类型 | 必填 | 说明 | +| ------ | ------------------------------------------------ | ---- | ------------------------------------------------------------ | +| colors | ArrayBuffer | 是 | 颜色数组。 | +| opts | [InitializetionOptions](#InitializationOptions8) | 是 | 创建像素的属性,包括透明度,尺寸,缩略值,像素格式和是否可编辑。 | **返回值:** -| 类型 | 说明 | -| ------------------ | -------------- | -| Promise\ | 返回pixelmap。 | +| 类型 | 说明 | +| -------------------------------- | -------------- | +| Promise\<[PixelMap](#pixelmap7)> | 返回pixelmap。 | **示例:** @@ -41,21 +41,21 @@ image.createPixelMap(Color, opts) }) ``` -## image.createPixelMap +## image.createPixelMap8+ createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions) callback: AsyncCallback\): void -通过属性创建pixelmap。 +通过属性创建Pixelmap,通过回调函数返回结果。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------- | ---- | -------------------- | -| colors | ArrayBuffer | 是 | 颜色数组。 | -| opts | [InitializetionOptions](#InitializationOptions) | 是 | 属性。 | -| callback | AsyncCallback\ | 是 | 回调表示成功或失败。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | -------------------- | +| colors | ArrayBuffer | 是 | 颜色数组。 | +| opts | [InitializetionOptions](#InitializationOptions8) | 是 | 属性。 | +| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | 是 | 回调表示成功或失败。 | **示例:** @@ -66,21 +66,19 @@ image.createPixelMap(Color, opts, (pixelmap) => { }) ``` -## PixelMap +## PixelMap7+ 图像像素类,用于读取或写入图像数据以及获取图像信息。在调用PixelMap的方法前,需要先通过createPixelMap创建一个PixelMap实例。 ### 属性 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ---------- | ------- | ---- | ---- | ------------------------------------------------------------ | -| isEditable | boolean | 是 | 否 | 设定是否图像像素可被编辑。
**系统能力:** SystemCapability.Multimedia.Image | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----------------------- | ------- | ---- | ---- | ------------------------------------------------------------ | +| isEditable7+ | boolean | 是 | 否 | 设定是否图像像素可被编辑。
**系统能力:** SystemCapability.Multimedia.Image | -### readPixelsToBuffer +### readPixelsToBuffer7+ -``` -readPixelsToBuffer(dst: ArrayBuffer): Promise -``` +readPixelsToBuffer(dst: ArrayBuffer): Promise\ 读取图像像素数据,结果写入ArrayBuffer里,使用Promise形式返回。 @@ -123,11 +121,11 @@ pixelmap.readPixelsToBuffer(readBuffer).then(() => { }) ``` -### readPixelsToBuffer +### readPixelsToBuffer7+ readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\): void -读取图像像素数据,结果写入ArrayBuffer里,使用callback形式返回。 +读取图像像素数据,结果写入ArrayBuffer里,使用callback形式返回。 **系统能力:** SystemCapability.Multimedia.Image @@ -163,7 +161,7 @@ pixelmap.readPixelsToBuffer(readBuffer, () => { }) ``` -### readPixels +### readPixels7+ readPixels(area: PositionArea): Promise\ @@ -173,9 +171,9 @@ readPixels(area: PositionArea): Promise\ **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------------------------- | ---- | ------------------------ | -| area | [PositionArea](#PositionArea) | 是 | 区域大小,根据区域读取。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------------ | ---- | ------------------------ | +| area | [PositionArea](#positionarea7) | 是 | 区域大小,根据区域读取。 | **返回值:** @@ -211,20 +209,20 @@ pixelmap.readPixels(area).then((data) => { }) ``` -### readPixels +### readPixels7+ readPixels(area: PositionArea, callback: AsyncCallback\): void -读区域的像素。 +读取区域内的图片数据,使用callback形式返回读取结果。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------- | ---- | ------------------------------ | -| area | [PositionArea](#PositionArea) | 是 | 区域大小,根据区域读取。 | -| callback | AsyncCallback\ | 是 | 获取回调,失败时返回错误信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------ | ---- | ------------------------------ | +| area | [PositionArea](#positionarea7) | 是 | 区域大小,根据区域读取。 | +| callback | AsyncCallback\ | 是 | 获取回调,失败时返回错误信息。 | **示例:** @@ -247,19 +245,19 @@ pixelmap.readPixels(area,(data) => { } ``` -### writePixels +### writePixels7+ writePixels(area: PositionArea): Promise\ -先创建pixelmap,将pixelmap写入指定区域内,使用Promise形式返回写入结果。 +将Pixelmap写入指定区域内,使用Promise形式返回写入结果。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------------------------- | ---- | -------------------- | -| area | [PositionArea](#PositionArea) | 是 | 区域,根据区域写入。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------------ | ---- | -------------------- | +| area | [PositionArea](#PositionArea7) | 是 | 区域,根据区域写入。 | **返回值:** @@ -277,20 +275,20 @@ pixelMap.writePixels(area).then(() => { }); ``` -### writePixels +### writePixels7+ writePixels(area: PositionArea, callback: AsyncCallback\): void -将指定的像素信息写入指定区域内。 +将Pixelmap写入指定区域内,使用callback形式返回写入结果。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | ----------------------------- | ---- | ------------------------------ | -| area | [PositionArea](#PositionArea) | 是 | 区域,根据区域写入。 | -| callback: | AsyncCallback\ | 是 | 获取回调,失败时返回错误信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------------ | ---- | ------------------------------ | +| area | [PositionArea](#PositionArea7) | 是 | 区域,根据区域写入。 | +| callback: | AsyncCallback\ | 是 | 获取回调,失败时返回错误信息。 | **示例:** @@ -305,19 +303,19 @@ pixelmap.writePixels(area, () => { }) ``` -### writeBufferToPixels +### writeBufferToPixels7+ writeBufferToPixels(src: ArrayBuffer): Promise\ -将缓冲区的内容写入像素。 +读取缓冲区中的图片数据,结果写入Pixelmap中,使用Promise形式返回。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------- | ---- | -------- | -| src | ArrayBuffer | 是 | 缓冲区。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------- | ---- | -------------- | +| src | ArrayBuffer | 是 | 图像像素数据。 | **返回值:** @@ -335,11 +333,11 @@ pixelMap.writeBufferToPixels(colorBuffer).then(() => { }); ``` -### writeBufferToPixels +### writeBufferToPixels7+ writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\): void -将缓冲区的内容写入像素。 +读取缓冲区中的图片数据,结果写入Pixelmap中,使用Promise形式返回。 **系统能力:** SystemCapability.Multimedia.Image @@ -362,7 +360,7 @@ pixelMap.writeBufferToPixels(colorBuffer, function(err) { }); ``` -### getImageInfo +### getImageInfo7+ getImageInfo(): Promise\ @@ -372,9 +370,9 @@ getImageInfo(): Promise\ **返回值:** -| 类型 | 说明 | -| ------------------- | ----------------------------------------------------------- | -| Promise\ | Promise实例,用于异步获取图像像素信息,失败时返回错误信息。 | +| 类型 | 说明 | +| --------------------------------- | ----------------------------------------------------------- | +| Promise\<[ImageInfo](#imageinfo)> | Promise实例,用于异步获取图像像素信息,失败时返回错误信息。 | **示例:** @@ -386,7 +384,7 @@ pixelMap.getImageInfo().then(function(info) { }); ``` -### getImageInfo +### getImageInfo7+ getImageInfo(callback: AsyncCallback\): void @@ -396,9 +394,9 @@ getImageInfo(callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback\ | 是 | 获取图像像素信息回调,异步返回图像像素信息,失败时返回错误信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\<[ImageInfo](#imageinfo)> | 是 | 获取图像像素信息回调,异步返回图像像素信息,失败时返回错误信息。 | **示例:** @@ -418,9 +416,9 @@ pixelmap.getImageInfo((imageInfo) => { }) ``` -### getBytesNumberPerRow +### getBytesNumberPerRow7+ -getBytesNumberPerRow(): Promise\ +getBytesNumberPerRow(): number 获取图像像素每行字节数。 @@ -428,9 +426,9 @@ getBytesNumberPerRow(): Promise\ **返回值:** -| 类型 | 说明 | -| ---------------- | --------------------------------------------- | -| Promise\ | Promise实例,用于异步获取图像像素的行字节数。 | +| 类型 | 说明 | +| ------ | -------------------- | +| number | 图像像素的行字节数。 | **示例:** @@ -442,33 +440,9 @@ pixelmap.getBytesNumberPerRow().then((num) => { }) ``` -### getBytesNumberPerRow - -getBytesNumberPerRow(callback: AsyncCallback\): void - -获取图像像素每行字节数。 +### getPixelBytesNumber7+ -**系统能力:** SystemCapability.Multimedia.Image - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------ | -| callback | AsyncCallback\ | 是 | 通过回调返回结果。 | - -**示例:** - -```js -pixelmap.getBytesNumberPerRow( num => { - console.info('TC_025-1 num is ' + num); - expect(num == expectNum).assertTrue(); - done(); - }) -``` - -### getPixelBytesNumber - -getPixelBytesNumber(): Promise\ +getPixelBytesNumber(): number 获取图像像素的总字节数。 @@ -476,9 +450,9 @@ getPixelBytesNumber(): Promise\ **返回值:** -| 类型 | 说明 | -| ---------------- | --------------------------------------------- | -| Promise\ | Promise实例,用于异步获取图像像素的总字节数。 | +| 类型 | 说明 | +| ------ | -------------------- | +| number | 图像像素的总字节数。 | **示例:** @@ -490,37 +464,19 @@ pixelmap.getPixelBytesNumber().then((num) => { }) ``` -### getPixelBytesNumber +### release7+ -getPixelBytesNumber(callback: AsyncCallback\): void +release():Promise\ -获取图像像素的总字节数。 +释放Pixelmap对象,使用Promise形式返回释放结果。 **系统能力:** SystemCapability.Multimedia.Image -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------ | -| callback | AsyncCallback\ | 是 | 通过回调返回结果。 | - -**示例:** - -```js -pixelmap.getPixelBytesNumber((num) => { - console.info('TC_026-1 num is ' + num) - expect(num == expectNum).assertTrue() - done() - }) -``` - -### release - -release(): void - -释放pixelmap对象,使用Promise形式返回释放结果。 +**返回值:** -**系统能力:** SystemCapability.Multimedia.Image +| 类型 | 说明 | +| -------------- | ------------------ | +| Promise\ | 异步返回释放结果。 | **示例:** @@ -530,110 +486,80 @@ pixelmap.release() done() ``` -## image.createImageSource - -createImageSource(uri: string): ImageSource - -创建图片源。 - -**系统能力:** SystemCapability.Multimedia.Image - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ---------- | -| uri | string | 是 | 图片路径。 | - -**返回值:** - -| 类型 | 说明 | -| ----------- | ------------ | -| ImageSource | 返回图片源。 | - -**示例:** +### release7+ -```js -const imageSourceApi = image.createImageSource('/data/local/tmp/test.jpg') -``` - -## image.createImageSource - -createImageSource(fd: number): ImageSource +release(callback: AsyncCallback\): void -创建图片源。 +释放Pixelmap对象,使用callback形式返回释放结果。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------ | -| fd | number | 是 | 基于fd创建图片源。 | - -**返回值:** - -| 类型 | 说明 | -| ----------- | ------------ | -| ImageSource | 返回图片源。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------ | +| callback | AsyncCallback\ | 是 | 异步返回释放结果。 | **示例:** ```js -const imageSourceApi = image.createImageSource(0) +pixelmap.release(()=>{ + expect(true).assertTrue(); + console.log('TC_027-1 success'); + done(); + }) ``` ## image.createImageSource -createImageSource(data: ArrayBuffer): ImageSource +createImageSource(uri: string): ImageSource -创建图片源。 +通过传入的uri创建图片源实例。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------- | ---- | ------ | -| data | ArrayBuffer | 是 | 数组。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------- | +| uri | string | 是 | 图片路径,当前仅支持本地绝对路径。 | **返回值:** -| 类型 | 说明 | -| ----------- | ------------ | -| ImageSource | 返回图片源。 | +| 类型 | 说明 | +| --------------------------- | --------------------------------------- | +| [ImageSource](#imagesource) | 返回ImageSource类实例,失败时返回null。 | **示例:** ```js -const data = new ArrayBuffer(96); -const imageSourceApi = image.createImageSource(data); +const imageSourceApi = image.createImageSource('/data/local/tmp/test.jpg') ``` -## image.createIncrementalSource +## image.createImageSource7+ -createIncrementalSource(data: ArrayBuffer): ImageSource +createImageSource(fd: number): ImageSource -创建增量图片源。 +通过传入文件描述符来创建图片源实例。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------- | ---- | ---- | -| data | ArrayBuffer | 是 | 数组 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------- | +| fd | number | 是 | 文件描述符fd。 | **返回值:** -| 类型 | 说明 | -| ----------- | ------------ | -| ImageSource | 返回图片源。 | +| 类型 | 说明 | +| --------------------------- | --------------------------------------- | +| [ImageSource](#imagesource) | 返回ImageSource类实例,失败时返回null。 | **示例:** ```js -const data = new ArrayBuffer(96); -const imageSourceApi = image.createIncrementalSource(data); +const imageSourceApi = image.createImageSource(0) ``` ## ImageSource @@ -656,10 +582,10 @@ getImageInfo(index: number, callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | ---- | ----------------------------------------------- | -| index | number | 是 | 图片序号,创建图片源时的序号,不选择时默认为0。 | -| callback | AsyncCallback<[ImageInfo](#ImageInfo)> | 是 | 获取图片信息回调,异步返回图片信息对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ---------------------------------------- | +| index | number | 是 | 创建图片源时的序号。 | +| callback | AsyncCallback<[ImageInfo](#imageinfo)> | 是 | 获取图片信息回调,异步返回图片信息对象。 | **示例:** @@ -684,7 +610,7 @@ it('TC_046', 0, async function (done) { getImageInfo(callback: AsyncCallback\): void -获取指定序号的图片信息,使用callback形式返回图片信息。 +获取图片信息,使用callback形式返回图片信息。 **系统能力:** SystemCapability.Multimedia.Image @@ -692,7 +618,7 @@ getImageInfo(callback: AsyncCallback\): void | 名称 | 类型 | 必填 | 说明 | | -------- | -------------------------------------- | ---- | ---------------------------------------- | -| callback | AsyncCallback<[ImageInfo](#ImageInfo)> | 是 | 获取图片信息回调,异步返回图片信息对象。 | +| callback | AsyncCallback<[ImageInfo](#imageinfo)> | 是 | 获取图片信息回调,异步返回图片信息对象。 | **示例:** @@ -714,15 +640,15 @@ getImageInfo(index?: number): Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----- | ------ | ---- | ----------------------------------------------- | -| index | number | 否 | 图片序号,创建图片源时的序号,不选择时默认为0。 | +| 名称 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ------------------------------------- | +| index | number | 否 | 创建图片源时的序号,不选择时默认为0。 | **返回值:** -| 类型 | 说明 | -| --------------------------------- | ---------------------- | -| Promise\<[ImageInfo](#ImageInfo)> | 返回获取到的图片信息。 | +| 类型 | 说明 | +| -------------------------------- | ---------------------- | +| Promise<[ImageInfo](#imageinfo)> | 返回获取到的图片信息。 | **示例:** @@ -735,20 +661,20 @@ imageSourceApi.getImageInfo(0) }) ``` -### getImageProperty +### getImageProperty7+ getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\ -获取图片中给定索引处图像的指定属性键的值。 +获取图片中给定索引处图像的指定属性键的值,用Promise形式返回结果。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------- | --------------------------------------------------- | ---- | ------------------------------------ | -| key | string | 是 | 图片属性名。 | -| options | [GetImagePropertyOptions](#GetImagePropertyOptions) | 否 | 图片属性,包括图片序号与默认属性值。 | +| 名称 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------------------- | ---- | ------------------------------------ | +| key | string | 是 | 图片属性名。 | +| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | 否 | 图片属性,包括图片序号与默认属性值。 | **返回值:** @@ -762,11 +688,11 @@ getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\7+ getImageProperty(key:string, callback: AsyncCallback\): void -获取图片中给定索引处图像的指定属性键的值,使用callback形式返回结果。 +获取图片中给定索引处图像的指定属性键的值,用callback形式返回结果。 **系统能力:** SystemCapability.Multimedia.Image @@ -783,7 +709,7 @@ getImageProperty(key:string, callback: AsyncCallback\): void const w = imageSourceApi.getImageProperty("ImageWidth",w=>{}) ``` -### getImageProperty +### getImageProperty7+ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCallback\): void @@ -793,11 +719,11 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | -| key | string | 是 | 图片属性名。 | -| options | [GetImagePropertyOptions](#GetImagePropertyOptions) | 是 | 图片属性,包括图片序号与默认属性值。 | -| callback | AsyncCallback\ | 是 | 获取图片属性回调,返回图片属性值,如获取失败则返回属性默认值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | +| key | string | 是 | 图片属性名。 | +| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | 是 | 图片属性,包括图片序号与默认属性值。 | +| callback | AsyncCallback\ | 是 | 获取图片属性回调,返回图片属性值,如获取失败则返回属性默认值。 | **示例:** @@ -805,107 +731,21 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa imageSourceApi.getImageProperty("ImageWidth",PropertyOptions,(w)=>{}) ``` -### modifyImageProperty - -modifyImageProperty(key:string, value:string, options?: GetImagePropertyOptions): Promise\ - -修改属性的值。 - -**系统能力:** SystemCapability.Multimedia.Image - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------- | --------------------------------------------------- | ---- | ------------------------------------ | -| key | string | 是 | 图片属性名。 | -| value | string | 是 | 属性值。 | -| options | [GetImagePropertyOptions](#GetImagePropertyOptions) | 是 | 图片属性,包括图片序号与默认属性值。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise\ | Promise实例,异步返回结果。 | - -**示例:** - -**示例:** - -```js -imageSourceApi.modifyImageProperty("ImageWidth", "abc") - .then(() => { - const w = imageSourceApi.getImageProperty("ImageWidth") - console.info('w', w); - expect(w == 'abc').assertTrue(); - done(); - }) -``` - -### modifyImageProperty - -modifyImageProperty(key:string, value:string, callback: AsyncCallback\): void - -修改属性的值,callback返回结果。 - -**系统能力:** SystemCapability.Multimedia.Image - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------------ | -| key | string | 是 | 图片属性名。 | -| value | string | 是 | 属性值。 | -| callback | AsyncCallback\ | 是 | 修改属性值,callback返回结果。 | - -**示例:** - -```js -imageSourceApi.modifyImageProperty("ImageWidth", "abc",() => {}) -``` - -### modifyImageProperty - -modifyImageProperty(key:string, value:string, options: GetImagePropertyOptions,callback: AsyncCallback\): void - -修改属性的值,callback返回结果。 - -**系统能力:** SystemCapability.Multimedia.Image - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------------- | ---- | ------------------------------------ | -| key | string | 是 | 图片属性名。 | -| value | string | 是 | 属性值。 | -| options | [GetImagePropertyOptions](#GetImagePropertyOptions) | 是 | 图片属性,包括图片序号与默认属性值。 | -| callback | AsyncCallback\ | 是 | 修改属性值,callback返回结果。 | - -**示例:** - -```js -let PropertyOptions = { - index:0, - defaultValue:'a' -imageSourceApi.modifyImageProperty("ImageWidth", "abc",PropertyOptions,() => { - - }; -``` - -### createPixelMap +### createPixelMap7+ createPixelMap(index: number, options: DecodingOptions, callback: AsyncCallback\): void -通过图片解码参数创建pixelmap对象,使用callback形式返回结果。 +通过图片解码参数创建Pixelmap对象,使用callback形式返回结果。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------------- | ------------------------------------ | ---- | -------------------- | -| options | [DecodingOptions](#DecodingOptions) | 是 | 解码参数。 | -| index | number | 是 | 图片索引。 | -| AsyncCallback | AsyncCallback<[PixelMap](#PixelMap)> | 是 | 回调表示成功或失败。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ------------------------------------- | ---- | -------------------- | +| options | [DecodingOptions](#decodingoptions7) | 是 | 解码参数。 | +| index | number | 是 | 图片索引。 | +| AsyncCallback | AsyncCallback<[PixelMap](#pixelmap7)> | 是 | 回调表示成功或失败。 | **示例:** @@ -917,7 +757,7 @@ imageSourceApi.createPixelMap().then(pixelmap => { }) ``` -### createPixelMap +### createPixelMap7+ createPixelMap(options: DecodingOptions, callback: AsyncCallback\): void @@ -927,10 +767,10 @@ createPixelMap(options: DecodingOptions, callback: AsyncCallback\): vo **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------ | ---- | -------------------- | -| options | [DecodingOptions](#DecodingOptions) | 是 | 解码参数。 | -| callback | AsyncCallback<[PixelMap](#PixelMap)> | 是 | 回调表示成功或失败。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | -------------------- | +| options | [DecodingOptions](#decodingoptions7) | 是 | 解码参数。 | +| callback | AsyncCallback<[PixelMap](#pixelmap7)> | 是 | 回调表示成功或失败。 | **示例:** @@ -950,7 +790,7 @@ let decodingOptions = { }) ``` -### createPixelMap +### createPixelMap7+ createPixelMap(opts: DecodingOptions, callback: AsyncCallback\): void @@ -960,10 +800,10 @@ createPixelMap(opts: DecodingOptions, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------ | ---- | -------------------- | -| opts | [DecodingOptions](#DecodingOptions) | 是 | 解码参数。 | -| callback | AsyncCallback<[PixelMap](#PixelMap)> | 是 | 回调表示成功或失败。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | -------------------- | +| opts | [DecodingOptions](#decodingoptions7) | 是 | 解码参数。 | +| callback | AsyncCallback<[PixelMap](#pixelmap7)> | 是 | 回调表示成功或失败。 | **示例:** @@ -981,103 +821,14 @@ let decodingOptions = { console.info('TC_050-1 createPixelMap '); expect(pixelmap !== null ).assertTrue(); done(); - }) -``` - -### updateData - -updateData(data: Array\, isFinal: boolean, offset: number, length: number, callback: AsyncCallback\): void - -更新增量数据。 - -**系统能力:** SystemCapability.Multimedia.Image - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------- | -| data | Array\ | 是 | 增量数据。 | -| isFinal | boolean | 是 | 是否更新完。 | -| offset | number | 是 | 偏移量。 | -| length | number | 是 | 数组长。 | -| callback | AsyncCallback\ | 是 | 回调表示成功或失败。 | - -**示例:** - -```js -imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> { - if(data !== undefined){ - expect(data).assertTrue(); - console.info('TC_053-1 success'); - done(); - } -``` - -### updateData - -updateData(data: Array\, isFinal: boolean, offset?: number, length?: number): Promise\ - -更新增量数据。 - -**系统能力:** SystemCapability.Multimedia.Image - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------- | -------------- | ---- | ------------ | -| data | Array\ | 是 | 增量数据。 | -| isFinal | boolean | 是 | 是否更新完。 | -| offset | boolean | 否 | 偏移量。 | -| length | number | 否 | 数组长。 | - -**返回值:** - -| 类型 | 说明 | -| ----------------- | --------------------------------- | -| Promise\ | Promise实例,异步返回成功或失败。 | - -**示例:** - -```js - imageSourceIncrementalSApi.updateData(array, false, 0, 10).then(data => { - expect(data).assertTrue(); - console.info('TC_053 success'); - done(); - }) -``` - -### updateData - -updateData(data: Array\, isFinal: boolean, callback: AsyncCallback\): void - -更新增量数据。 - -**系统能力:** SystemCapability.Multimedia.Image - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------- | -| data | Array\ | 是 | 增量数据。 | -| isFinal | boolean | 是 | 是否更新完。 | -| callback | AsyncCallback\ | 是 | 回调表示成功或失败。 | - -**示例:** - -```js -imageSourceIncrementalSApi.updateData(array, false,(error,data) => { - if(data !== undefined){ - expect(data).assertTrue(); - console.info('TC_053-2 success'); - done(); - } + }) ``` ### release release(callback: AsyncCallback\): void -释放图片源。 +释放图片源实例,使用callback形式返回结果。 **系统能力:** SystemCapability.Multimedia.Image @@ -1102,7 +853,7 @@ imageSourceApi.release(() => { release(): Promise\ -释放图片源。 +释放图片源实例,使用Promise形式返回结果。 **系统能力:** SystemCapability.Multimedia.Image @@ -1126,15 +877,15 @@ release(): Promise\ createImagePacker(): ImagePacker -创建imagepacker实例。 +创建ImagePacker实例。 **系统能力:** SystemCapability.Multimedia.Image **返回值:** -| 类型 | 说明 | -| ----------- | ----------------- | -| ImagePacker | 返回ImagePacker。 | +| 类型 | 说明 | +| ----------- | ---------------------- | +| ImagePacker | 返回ImagePackers实例。 | **示例:** @@ -1150,7 +901,7 @@ const imagePackerApi = image.createImagePacker(); | 名称 | 类型 | 可读 | 可写 | 说明 | | ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | -| supportedFormats | Array\ | 是 | 否 | 图片打包支持的格式,jpg。
**系统能力:** SystemCapability.Multimedia.Image | +| supportedFormats | Array\ | 是 | 否 | 图片打包支持的格式,jpeg。
**系统能力:** SystemCapability.Multimedia.Image | ### packing @@ -1164,8 +915,8 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback> | 是 | 获取图片打包回调,返回打包后数据。 | **示例:** @@ -1183,7 +934,7 @@ let packOpts = { format:["image/jpeg"], quality:98 } packing(source: ImageSource, option: PackingOption): Promise> -图片压缩或重新打包,使用promise形式返回结果。 +图片压缩或重新打包,使用Promise形式返回结果。 **系统能力:** SystemCapability.Multimedia.Image @@ -1191,8 +942,8 @@ packing(source: ImageSource, option: PackingOption): Promise> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------------------------- | ---- | -------------- | -| source | [ImageSource](#ImageSource) | 是 | 打包的图片源。 | -| option | [PackingOption](#PackingOption) | 是 | 设置打包参数。 | +| source | [ImageSource](#imagesource) | 是 | 打包的图片源。 | +| option | [PackingOption](#packingoption) | 是 | 设置打包参数。 | **返回值:** @@ -1216,15 +967,15 @@ let packOpts = { format:["image/jpeg"], quality:98 } release(callback: AsyncCallback\): void -释放packer对象。 +释放图片打包实例,使用callback形式返回结果。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------- | -| callback | AsyncCallback\ | 是 | 回调表示成功还是失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------------------ | +| callback | AsyncCallback\ | 是 | 释放回调,失败时返回错误信息。 | **示例:** @@ -1239,15 +990,15 @@ imagePackerApi.release(()=>{ release(): Promise\ -释放packer对象。 +释放图片打包实例,使用Promise形式返回释放结果。 **系统能力:** SystemCapability.Multimedia.Image **返回值:** -| 类型 | 说明 | -| :------------- | :------------------------------ | -| Promise\ | Promise实例,用于异步返回结果。 | +| 类型 | 说明 | +| :------------- | :------------------------------------------------------ | +| Promise\ | Promise实例,用于异步获取释放结果,失败时返回错误信息。 | **示例:** @@ -1258,128 +1009,150 @@ imagePackerApi.release(); done(); ``` -## PositionArea +## PositionArea7+ + +表示图片指定区域内的数据。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------------------ | ---- | ---- | -------------------- | +| pixels | ArrayBuffer | 是 | 否 | 像素。 | +| offset | number | 是 | 否 | 偏移量。 | +| stride | number | 是 | 否 | 像素间距。 | +| region | [Region](#region8) | 是 | 否 | 区域,按照区域读写。 | -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------ | ----------------- | ---- | ---- | ------------------------------------------------------------ | -| pixels | ArrayBuffer | 是 | 否 | 像素。
**系统能力:** SystemCapability.Multimedia.Image | -| offset | number | 是 | 否 | 偏移量。
**系统能力:** SystemCapability.Multimedia.Image | -| stride | number | 是 | 否 | 像素间距。
**系统能力:** SystemCapability.Multimedia.Image | -| region | [Region](#Region) | 是 | 否 | 区域,按照区域读写。
**系统能力:** SystemCapability.Multimedia.Image | +## **ImageInfo** -## **ImageInfo** +表示图片信息。 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----------- | --------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| size | [Size](#Size) | 是 | 是 | 图片大小。
**系统能力:** SystemCapability.Multimedia.Image | -| pixelFormat | [PixelMapFormat](#PixelMapFormat) | 是 | 是 | 图片格式。
**系统能力:** SystemCapability.Multimedia.Image | -| colorSpace | [ColorSpace](#ColorSpace) | 是 | 是 | 色域。
**系统能力:** SystemCapability.Multimedia.Image | -| alphaType | [AlphaType](#AlphaType) | 是 | 是 | 透明度。
**系统能力:** SystemCapability.Multimedia.Image | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image -## Size +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---- | ------------- | ---- | ---- | ---------- | +| size | [Size](#size) | 是 | 是 | 图片大小。 | -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------ | ------ | ---- | ---- | ------------------------------------------------------------ | -| height | number | 是 | 是 | 输出图片的高。
**系统能力:** SystemCapability.Multimedia.Image | -| width | number | 是 | 是 | 输出图片的宽。
**系统能力:** SystemCapability.Multimedia.Image | +## Size -## PixelMapFormat +表示图片尺寸。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | -------------- | +| height | number | 是 | 是 | 输出图片的高。 | +| width | number | 是 | 是 | 输出图片的宽。 | + +## PixelMapFormat7+ 枚举,像素格式。 -| 名称 | 默认值 | 描述 | -| --------- | ------ | ------------------------------------------------------------ | -| UNKNOWN | 0 | 未知格式。
**系统能力:** SystemCapability.Multimedia.Image | -| ARGB_8888 | 1 | 格式为ARGB_8888。
**系统能力:** SystemCapability.Multimedia.Image | -| RGB_565 | 2 | 格式为RGB_565。
**系统能力:** SystemCapability.Multimedia.Image | - -## ColorSpace - -枚举,色块。 - -| 名称 | 默认值 | 描述 | -| -------------------- | ------ | ------------------------------------------------------------ | -| UNKNOWN | 0 | 色块基于unknown color space。
**系统能力:** SystemCapability.Multimedia.Image | -| DISPLAY_P3 | 1 | 色块基于 SMPTE RP 431-2-2007 and IEC 61966-2.1:199。
**系统能力:** SystemCapability.Multimedia.Image | -| SRGB | 2 | 色块基于IEC 61966-2.1:1999。
**系统能力:** SystemCapability.Multimedia.Image | -| LINEAR_SRGB | 3 | 色块基于the IEC 61966-2.1:1999。
**系统能力:** SystemCapability.Multimedia.Image | -| EXTENDED_SRGB | 4 | 色块基于IEC 61966-2-2:2003。
**系统能力:** SystemCapability.Multimedia.Image | -| LINEAR_EXTENDED_SRGB | 5 | 色块基于IEC 61966-2-2:2003。
**系统能力:** SystemCapability.Multimedia.Image | -| GENERIC_XYZ | 6 | 色块基于D50。
**系统能力:** SystemCapability.Multimedia.Image | -| GENERIC_LAB | 7 | 色块基于 CIE XYZ D50。
**系统能力:** SystemCapability.Multimedia.Image | -| ACES | 8 | 色块基于SMPTE ST 2065-1:2012。
**系统能力:** SystemCapability.Multimedia.Image | -| ACES_CG | 9 | 色块基于Academy S-2014-004。
**系统能力:** SystemCapability.Multimedia.Image | -| ADOBE_RGB_1998 | 10 | 色块基于 Adobe RGB。
**系统能力:** SystemCapability.Multimedia.Image | -| DCI_P3 | 11 | 色块基于SMPTE RP 431-2-2007。
**系统能力:** SystemCapability.Multimedia.Image | -| ITU_709 | 12 | 色块基于Rec.ITU-R BT.709-5。
**系统能力:** SystemCapability.Multimedia.Image | -| ITU_2020 | 13 | 色块基于Rec.ITU-R BT.2020-1。
**系统能力:** SystemCapability.Multimedia.Image | -| ROMM_RGB | 14 | 色块基于ISO 22028-2:2013。
**系统能力:** SystemCapability.Multimedia.Image | -| NTSC_1953 | 15 | 色块基于NTSC 1953 standard。
**系统能力:** SystemCapability.Multimedia.Image | -| SMPTE_C | 16 | 色块基于 SMPTE C。
**系统能力:** SystemCapability.Multimedia.Image | - -## AlphaType +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image + +| 名称 | 默认值 | 描述 | +| --------- | ------ | ----------------- | +| UNKNOWN | 0 | 未知格式。 | +| RGBA_8888 | 3 | 格式为RGBA_8888。 | +| RGB_565 | 2 | 格式为RGB_565。 | + +## AlphaType8+ 枚举,透明度。 -| 名称 | 默认值 | 描述 | -| -------- | ------ | ------------------------------------------------------------ | -| UNKNOWN | 0 | 未知透明度。
**系统能力:** SystemCapability.Multimedia.Image | -| OPAQUE | 1 | 没有alpha或图片全透明。
**系统能力:** SystemCapability.Multimedia.Image | -| PREMUL | 2 | RGB前乘alpha。
**系统能力:** SystemCapability.Multimedia.Image | -| UNPREMUL | 3 | RGB不前乘alpha。
**系统能力:** SystemCapability.Multimedia.Image | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image + +| 名称 | 默认值 | 描述 | +| -------- | ------ | ----------------------- | +| UNKNOWN | 0 | 未知透明度。 | +| OPAQUE | 1 | 没有alpha或图片全透明。 | +| PREMUL | 2 | RGB前乘alpha。 | +| UNPREMUL | 3 | RGB不前乘alpha。 | -## ScaleMode +## ScaleMode8+ 枚举,缩略值。 -| 名称 | 默认值 | 描述 | -| --------------- | ------ | ------------------------------------------------------------ | -| CENTER_CROP | 1 | 缩放图像以填充目标图像区域并居中裁剪区域外的效果。
**系统能力:** SystemCapability.Multimedia.Image | -| FIT_TARGET_SIZE | 2 | 图像适合目标尺寸的效果。
**系统能力:** SystemCapability.Multimedia.Image | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image -## InitializationOptions +| 名称 | 默认值 | 描述 | +| --------------- | ------ | -------------------------------------------------- | +| CENTER_CROP | 1 | 缩放图像以填充目标图像区域并居中裁剪区域外的效果。 | +| FIT_TARGET_SIZE | 2 | 图像适合目标尺寸的效果。 | -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----------- | --------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| alphaType | [AlphaType](#AlphaType) | 是 | 是 | 透明度。
**系统能力:** SystemCapability.Multimedia.Image | -| editable | boolean | 是 | 是 | 是否可编辑。
**系统能力:** SystemCapability.Multimedia.Image | -| pixelFormat | [PixelMapFormat](#PixelMapFormat) | 是 | 是 | 像素格式。
**系统能力:** SystemCapability.Multimedia.Image | -| scalemode | [ScaleMode](#ScaleMode) | 是 | 是 | 缩略值。
**系统能力:** SystemCapability.Multimedia.Image | -| size | [Size](#Size) | 是 | 是 | 创建图片大小。
**系统能力:** SystemCapability.Multimedia.Image | +## InitializationOptions8+ -## DecodingOptions +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----------- | ---------------------------------- | ---- | ---- | -------------- | +| alphaType | [AlphaType](#alphatype8) | 是 | 是 | 透明度。 | +| editable | boolean | 是 | 是 | 是否可编辑。 | +| pixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | 像素格式。 | +| scaleMode | [ScaleMode](#scalemode8) | 是 | 是 | 缩略值。 | +| size | [Size](#size) | 是 | 是 | 创建图片大小。 | + +## DecodingOptions7+ 解码设置选项。 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------------------ | --------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| sampleSize | number | 是 | 是 | 缩略图采样大小。
**系统能力:** SystemCapability.Multimedia.Image | -| rotateDegrees | number | 是 | 是 | 旋转角度。
**系统能力:** SystemCapability.Multimedia.Image | -| editable | boolean | 是 | 是 | 是否可编辑。
**系统能力:** SystemCapability.Multimedia.Image | -| desiredSize | [Size](#Size) | 是 | 是 | 期望输出大小。
**系统能力:** SystemCapability.Multimedia.Image | -| desiredRegion | [Region](#Region) | 是 | 是 | 解码区域。
**系统能力:** SystemCapability.Multimedia.Image | -| desiredPixelFormat | [PixelMapFormat](#PixelMapFormat) | 是 | 是 | 解码的像素格式。
**系统能力:** SystemCapability.Multimedia.Image | -| reusedPixelMap | [PixelMap](#PixelMap) | 是 | 是 | 将当前buffer地址给新创建的pixelmap。
**系统能力:** SystemCapability.Multimedia.Image | - -## Region - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ---- | ------------- | ---- | ---- | ------------------------------------------------------------ | -| size | [Size](#Size) | 是 | 是 | 区域大小。
**系统能力:** SystemCapability.Multimedia.Image | -| x | number | 是 | 是 | 区域坐标。
**系统能力:** SystemCapability.Multimedia.Image | -| y | number | 是 | 是 | 区域坐标。
**系统能力:** SystemCapability.Multimedia.Image | - -## PackingOption - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------- | ------ | ---- | ---- | ------------------------------------------------------------ | -| format | string | 是 | 是 | 目标格式。
**系统能力:** SystemCapability.Multimedia.Image | -| quality | number | 是 | 是 | 目标图片质量。
**系统能力:** SystemCapability.Multimedia.Image | - -## GetImagePropertyOptions - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------------ | ------ | ---- | ---- | ---------- | -| index | number | 是 | 是 | 图片序号。
**系统能力:** SystemCapability.Multimedia.Image | -| defaultValue | string | 是 | 是 | 默认属性值
**系统能力:** SystemCapability.Multimedia.Image | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------ | ---------------------------------- | ---- | ---- | ---------------- | +| sampleSize | number | 是 | 是 | 缩略图采样大小。 | +| rotateDegrees | number | 是 | 是 | 旋转角度。 | +| editable | boolean | 是 | 是 | 是否可编辑。 | +| desiredSize | [Size](#size) | 是 | 是 | 期望输出大小。 | +| desiredRegion | [Region](#region8) | 是 | 是 | 解码区域。 | +| desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | 解码的像素格式。 | +| index | numer | 是 | 是 | 解码图片序号 | + +## Region8+ + +表示区域信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---- | ------------- | ---- | ---- | ---------- | +| size | [Size](#size) | 是 | 是 | 区域大小。 | +| x | number | 是 | 是 | 区域坐标。 | +| y | number | 是 | 是 | 区域坐标。 | + +## PackingOption + +表示图片打包选项。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------- | ------ | ---- | ---- | -------------- | +| format | string | 是 | 是 | 目标格式。 | +| quality | number | 是 | 是 | 目标图片质量。 | + +## GetImagePropertyOptions7+ + +表示查询图片属性的索引。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------ | ------ | ---- | ---- | ------------ | +| index | number | 是 | 是 | 图片序号。 | +| defaultValue | string | 是 | 是 | 默认属性值。 | + +## PropertyKey7+ + +枚举,Exif(Exchangeable image file format)图片信息。 + +| 名称 | 默认值 | 说明 | +| ----------------- | ----------------- | -------------------- | +| BITS_PER_SAMPLE | "BitsPerSample" | 每个像素字节数。 | +| ORIENTATION | "Orientation" | 图片方向。 | +| IMAGE_LENGTH | "ImageLength" | 图片长度。 | +| IMAGE_WIDTH | "ImageWidth" | 图片宽度。 | +| GPS_LATITUDE | "GPSLatitude" | 图片纬度。 | +| GPS_LONGITUDE | "GPSLongitude" | 图片经度。 | +| GPS_LATITUDE_REF | "GPSLatitudeRef" | 纬度引用,例如N或S。 | +| GPS_LONGITUDE_REF | "GPSLongitudeRef" | 经度引用,例如W或E。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-intl.md b/zh-cn/application-dev/reference/apis/js-apis-intl.md index eb6a9804cff291c5d5f7bcee22b1caccbab7e7de..9d847a9f13111ef1b14e128f185eb1519f268831 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-intl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-intl.md @@ -32,6 +32,20 @@ import Intl from '@ohos.intl'; | numeric | boolean | 是 | 否 | 是否对数字字符具有特殊的排序规则处理。
**系统能力**:SystemCapability.Global.I18n | +### constructor + +constructor() + +创建区域对象 + +**系统能力**:SystemCapability.Global.I18n + +- 示例: + ``` + var locale = new Intl.Locale(); + ``` + + ### constructor constructor(locale: string, options?: options) @@ -115,6 +129,20 @@ minimize(): Locale ## DateTimeFormat +### constructor + +constructor() + +创建时间日期格式化对象。 + +**系统能力**:SystemCapability.Global.I18n + +- 示例: + ``` + var datefmt= new Intl.DateTimeFormat(); + ``` + + ### constructor constructor(locale: string, options?: DateTimeOptions) @@ -259,6 +287,20 @@ resolvedOptions(): DateTimeOptions ## NumberFormat +### constructor + +constructor() + +创建数字格式化对象。 + +**系统能力**:SystemCapability.Global.I18n + +- 示例: + ``` + var numfmt = new Intl.NumberFormat(); + ``` + + ### constructor constructor(locale: string, options?: NumberOptions) diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md index 1ff86fc1903ddf9d9c92a779fcf3814df084ca62..66b3a24981a800cb85100c792df746b70b0e9f93 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md @@ -146,7 +146,7 @@ has(key: T): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 指定key | +| key | T | 是 | 指定key | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md index 93785e13e76db9a1493236935188edeba4083d76..8339647ac38b5e6fcdf0370b56580781da664e23 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md @@ -68,7 +68,7 @@ add(element: T): boolean ``` let linkedList = new LinkedList(); let result = linkedList.add("a"); -let result = linkedList.add(1); +let result1 = linkedList.add(1); let b = [1, 2, 3]; linkedList.add(b); let c = {name : "lala", age : "13"}; diff --git a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md index 95c20f3b362c5801182deb043a5fecba20e6ee89..a47a4fb0647d085027f123eb3d6e6551aa3f439f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -387,7 +387,7 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void var createIocalId; osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ createIocalId = osAccountInfo.localId; - )}; + }); accountManager.removeOsAccount(createIocalId, (err)=>{ console.log("removeOsAccount err:" + JSON.stringify(err)); }); @@ -418,7 +418,7 @@ removeOsAccount(localId: number): Promise<void> var createIocalId; osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ createIocalId = osAccountInfo.localId; - )}; + }); createIocalId = osAccount.localId; accountManager.removeOsAccount(createIocalId).then(() => { console.log('removeOsAccount Success'); diff --git a/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md b/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md index 364981f6b4f2afc65382ac6123dcd15871f7ec2a..333decf39e627acfe5a90736981b62263d05e381 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md +++ b/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @@ -1,10 +1,7 @@ # PermissionRequestResult -- [属性](#属性) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。 +> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 权限请求结果。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md index 0ff829fa745d6d71780cffdcd85b7e89026dba03..44ce21f9db6b77f0fab9179db7c21be38a40e7da 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md +++ b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md @@ -117,7 +117,7 @@ let result = plainArray.get(1); getIndexOfKey(key: number): number; -查找指定key第一次出现的下标值,如果没有找到该元素返回-1。 +查找指定key第一次出现的下标值,如果没有找到该key返回-1。 **参数:** @@ -145,19 +145,19 @@ let result = plainArray.getIndexOfKey("sdfs"); getIndexOfValue(value: T): number; -查找指定元素第一次出现的下标值,如果没有找到该元素返回-1。 +查找指定value元素第一次出现的下标值,如果没有找到该value元素返回-1。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 指定元素。 | +| value | T | 是 | 指定value元素。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 | +| number | 返回指定value元素第一次出现时的下标值,查找失败返回-1。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md index c8fd0792d1eb33d3e67a5cb78a0b6f12c6db0a10..9c8bad9a20f6559f5507892857456d281898cc5f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md @@ -1,11 +1,7 @@ # ProcessRunningInfo -- [使用说明](#使用说明) -- [属性](#属性) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 8开始支持。 +> 本模块首批接口从API 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 进程运行信息。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-runninglock.md b/zh-cn/application-dev/reference/apis/js-apis-runninglock.md index f26db121c4b48c58ef520d88fc25a3eae726c123..df65e342c82b8c2d8a31229a7f92ce88134b207d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-runninglock.md +++ b/zh-cn/application-dev/reference/apis/js-apis-runninglock.md @@ -9,19 +9,16 @@ ## 导入模块 ``` -import runninglock from '@ohos.runningLock'; +import runningLock from '@ohos.runningLock'; ``` -## 系统能力 - -SystemCapability.PowerManager.PowerManager.Core - - ## RunningLockType RunningLock锁的类型。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.PowerManager.PowerManager.Core + | 名称 | 默认值 | 描述 | | ------------------------ | ---- | ------------------- | | BACKGROUND | 1 | 阻止系统休眠的锁。 | @@ -34,6 +31,8 @@ isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback<boo 查询系统是否支持该类型的锁。 +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -60,6 +59,8 @@ isRunningLockTypeSupported(type: RunningLockType): Promise<boolean> 查询系统是否支持该类型的锁。 +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -91,7 +92,9 @@ createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&l 创建RunningLock锁。 -**需要权限:**ohos.permission.RUNNING_LOCK +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + +**需要权限:** ohos.permission.RUNNING_LOCK **参数:** @@ -124,7 +127,9 @@ createRunningLock(name: string, type: RunningLockType): Promise<RunningLock&g 创建Runninglock锁。 -**需要权限:**ohos.permission.RUNNING_LOCK +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + +**需要权限:** ohos.permission.RUNNING_LOCK **参数:** @@ -163,6 +168,8 @@ lock(timeout: number): void 锁定和持有RunningLock。 +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -189,6 +196,8 @@ unlock(): void 释放Runninglock锁。 +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + **示例:** ``` @@ -209,6 +218,8 @@ isUsed(): boolean 查询当前Runninglock是持有状态还是释放状态。 +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + **返回值:** | 类型 | 说明 | | ------- | ------------------------------------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-sensor.md index 660c64edcd258e76548e2299655ad61f6f7ac9b5..19dfe99430b6bc73adb62be86be62fb5828905b5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md @@ -10,28 +10,17 @@ import sensor from '@ohos.sensor'; ``` -## 系统能力 - -SystemCapability.Sensors.Sensor - -## 权限列表 - -计步器:ohos.permission.ACTIVITY_MOTION - -心率:ohos.permission.READ_HEALTH_DATA - -加速度:ohos.permission.ACCELEROMETER - -陀螺仪:ohos.permission.GYROSCOPE - ## sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER) on(type: sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback<AccelerometerResponse>,options?: Options): void - 监听加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | @@ -62,6 +51,10 @@ on(type:sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:AsyncCallb 监听线性加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -91,6 +84,10 @@ on(type:sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback:Asy 监听未校准加速度计传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -123,6 +120,8 @@ on(type: sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback<Gr 监听重力传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -152,6 +151,10 @@ on(type: sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback< 监听陀螺仪传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**需要权限**:ohos.permission.GYROSCOPE ,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -181,6 +184,10 @@ on(type:sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:AsyncCa 监听未校准陀螺仪传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**需要权限**:ohos.permission.GYROSCOPE ,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -213,6 +220,8 @@ on(type: sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: AsyncCal 监听大幅动作传感器数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -236,15 +245,19 @@ on(type: sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: AsyncCal ## sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION) -on(type: sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: AsyncCallback<PedometerDetectResponse>, options?: Options): void +on(type: sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: AsyncCallback<PedometerDetectionResponse>, options?: Options): void 监听计步检测传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**需要权限**:ohos.permission.ACTIVITY_MOTION + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | [SensorType](#sensortype) | 是 | 要订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | - | callback | AsyncCallback<[PedometerDetectResponse](#pedometerdetectresponse)> | 是 | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectResponse。 | + | callback | AsyncCallback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | - 示例: @@ -267,6 +280,10 @@ on(type: sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback< 监听计步传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**需要权限**:ohos.permission.ACTIVITY_MOTION + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -294,6 +311,8 @@ on(type:sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:AsyncCallb 监听环境温度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -321,6 +340,8 @@ on(type: sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallbac 监听磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -350,6 +371,8 @@ on(type:sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback:As 监听未校准磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -382,6 +405,8 @@ on(type:sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback<P 监听接近光传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -409,6 +434,8 @@ on(type: sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback<H 监听湿度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -436,6 +463,8 @@ on(type:sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback<B 监听气压计传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -463,6 +492,8 @@ on(type: sensor.SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback<HallR 监听霍尔传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -490,6 +521,8 @@ on(type:sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: AsyncCallback& 监听环境光传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -517,6 +550,8 @@ on(type: sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback&l 监听方向传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -546,6 +581,8 @@ on(type:sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback:AsyncCallback& 监听旋转矢量传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -575,6 +612,8 @@ on(type: sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: AsyncCallbac 监听佩戴检测传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -602,6 +641,10 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallba 监听加速度传感器的数据变化一次。 +**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -629,6 +672,10 @@ once(type:sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:AsyncCal 监听线性加速度传感器数据变化一次。 +**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -656,6 +703,10 @@ once(type:sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback:A 监听未校准加速度传感器的数据变化一次。 +**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -686,6 +737,8 @@ once(type:sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback<G 监听重力传感器的数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -713,6 +766,10 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback&l 监听陀螺仪传感器的数据变化一次。 +**需要权限**:ohos.permission.GYROSCOPE ,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -740,6 +797,10 @@ once(type:sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Async 监听未校准陀螺仪传感器的数据变化一次。 +**需要权限**:ohos.permission.GYROSCOPE ,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -770,6 +831,8 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback:AsyncCal 监听有效运动传感器的数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -791,15 +854,19 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback:AsyncCal ## sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION) -once(type:sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback:AsyncCallback<PedometerDetectResponse>): void +once(type:sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback:AsyncCallback<PedometerDetectionResponse>): void 监听计步检测传感器数据变化一次。 +**需要权限**:ohos.permission.ACTIVITY_MOTION + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | [SensorType](#sensortype) | 是 | 计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | - | callback | AsyncCallback<[PedometerDetectResponse](#pedometerdetectresponse)> | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectResponse。 | + | callback | AsyncCallback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | - 示例: ``` @@ -820,6 +887,10 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback&l 监听计步器传感器数据变化一次。 +**需要权限**:ohos.permission.ACTIVITY_MOTION + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -845,6 +916,8 @@ once(type:sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:AsyncCal 监听环境温度传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -870,6 +943,8 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallb 监听磁场传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -897,6 +972,8 @@ once(type:sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: 监听未校准磁场传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -927,6 +1004,8 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback&l 监听接近光传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -952,6 +1031,8 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback< 监听湿度传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -977,6 +1058,8 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback&l 监听气压计传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1002,6 +1085,8 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback<H 监听霍尔传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1027,6 +1112,8 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: AsyncCallba 监听环境光传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1052,6 +1139,8 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback 监听方向传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1079,6 +1168,8 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: AsyncCall 监听旋转矢量传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1106,6 +1197,10 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: AsyncCallback& 监听心率传感器数据变化一次。 +**需要权限**:ohos.permission.READ_HEALTH_DATA + +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1131,6 +1226,8 @@ once(type: sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: AsyncCallb 监听佩戴检测传感器数据变化一次。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1156,6 +1253,8 @@ off(type: SensorType, callback?: AsyncCallback<void>): void 取消订阅传感器数据。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1180,6 +1279,8 @@ transformCoordinateSystem(inRotationVector: Array<number>, coordinates: Co 旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1209,6 +1310,8 @@ transformCoordinateSystem(inRotationVector: Array<number>, coordinates: Co 旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1245,6 +1348,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callba 获取地球上特定位置的地磁场。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1272,6 +1377,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promi 获取地球上特定位置的地磁场。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1301,6 +1408,8 @@ getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallbac 根据气压值获取设备所在的海拔高度。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1328,6 +1437,8 @@ getAltitude(seaPressure: number, currentPressure: number): Promise<number> 根据气压值获取设备所在的海拔高度。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1359,6 +1470,8 @@ getGeomagneticDip(inclinationMatrix: Array<number>, callback: AsyncCallbac 根据倾斜矩阵计算地磁倾斜角。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1385,6 +1498,8 @@ getGeomagneticDip(inclinationMatrix: Array<number>): Promise<number> 根据倾斜矩阵计算地磁倾斜角。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1414,6 +1529,8 @@ getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Ar 获取两个旋转矩阵之间的角度变化。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1445,12 +1562,14 @@ getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Ar 获取两个旋转矩阵之间的角度变化。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | | --------------------- | ------------------- | ---- | ------------------ | | currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | - | preRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | + | preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | - 返回值 @@ -1479,6 +1598,8 @@ createRotationMatrix(rotationVector: Array<number>, callback: AsyncCallbac 将旋转矢量转换为旋转矩阵。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1509,6 +1630,8 @@ createRotationMatrix(rotationVector: Array<number>): Promise<Array<n 将旋转矢量转换为旋转矩阵。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1542,6 +1665,8 @@ createQuaternion(rotationVector: Array<number>, callback: AsyncCallback< 将旋转矢量转换为四元数。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1572,6 +1697,8 @@ createQuaternion(rotationVector: Array<number>): Promise<Array<numbe 将旋转矢量转换为四元数。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1605,6 +1732,8 @@ getDirection(rotationMatrix: Array<number>, callback: AsyncCallback<Arr 根据旋转矩阵计算设备的方向。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1635,6 +1764,8 @@ getDirection(rotationMatrix: Array<number>): Promise<Array<number> 根据旋转矩阵计算设备的方向。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1668,6 +1799,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 根据重力矢量和地磁矢量计算旋转矩阵。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1699,6 +1832,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 根据重力矢量和地磁矢量计算旋转矩阵。 +**系统能力**:SystemCapability.Sensors.Sensor + - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -1731,6 +1866,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 表示要订阅或取消订阅的传感器类型。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | @@ -1761,6 +1898,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 传感器数据的时间戳。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | timestamp | number | 是 | 是 | 传感器数据上报的时间戳。 | @@ -1770,6 +1909,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 加速度传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1782,6 +1923,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 线性加速度传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1794,6 +1937,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 未校准加速度计传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1809,6 +1954,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 重力传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1821,6 +1968,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 方向传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1833,6 +1982,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 旋转矢量传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1845,6 +1996,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 陀螺仪传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1857,6 +2010,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 未校准陀螺仪传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1872,6 +2027,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 有效运动传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1882,6 +2039,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 接近光传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1892,6 +2051,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 环境光传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1902,6 +2063,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 霍尔传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1912,6 +2075,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 磁场传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1924,6 +2089,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 未校准磁场传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1939,6 +2106,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 计步传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1949,16 +2118,20 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 湿度传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | humidity | number | 是 | 是 | 湿度值。测量环境的相对湿度,以百分比 (%) 表示。 | -## PedometerDetectResponse +## PedometerDetectionResponse 计步检测传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1969,6 +2142,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 温度传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1979,6 +2154,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 气压计传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1989,6 +2166,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 心率传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -1999,6 +2178,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 佩戴检测传感器数据,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -2009,13 +2190,17 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 设置传感器上报频率。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 说明 | | -------- | -------- | -------- | | interval | number | 表示传感器的上报频率,默认值为200000000ns。 | ## RotationMatrixResponse -设置旋转矩阵响应对象 +设置旋转矩阵响应对象。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ----------- | ------------------- | ---- | ---- | ---------- | @@ -2025,7 +2210,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& ## CoordinatesOptions -设置坐标选项对象 +设置坐标选项对象。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ---- | -------- | ---- | ---- | ----------- | @@ -2037,6 +2224,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& 设置地磁响应对象,继承于[Response](#response)。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | x | number | 是 | 是 | 地磁场的北分量。 | @@ -2047,9 +2236,12 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& | levelIntensity | number | 是 | 是 | 地磁场的水平强度。 | | totalIntensity | number | 是 | 是 | 地磁场的总强度。 | - ## LocationOptions +指示地理位置。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | latitude | number | 是 | 是 | 纬度。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md index 1f6fd7240d544c637071afe99294fc1e46af5ae1..423630408b85eba49db29a0c27c1d6438cf9e511 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @@ -6,7 +6,7 @@ ## 导入模块 ```js -import storagestatistics from "@ohos.storagestatistics"; +import storagestatistics from "@ohos.storageStatistics"; ``` ## 系统能力 @@ -61,9 +61,10 @@ getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):v let uuid = ""; storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){ // do something + console.info("getTotalSizeOfVolume successfully:"+ number); }); ``` - + ## storagestatistics.getFreeSizeOfVolume @@ -115,22 +116,22 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):vo let uuid = ""; storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){ // do something + console.info("getFreeSizeOfVolume successfully:"+ number); }); ``` -## storagestatistics.getBundleStats +## storagestatistics.getBundleStats9+ -getBundleStats(volumeUuid: string, packageName:String, ): Promise<BundleStats> +getBundleStats(packageName:String, ): Promise<BundleStats> -异步获取指定卷上的应用存储状态,以promise方式返回。 +异步获取应用存储状态,以promise方式返回。 - 参数 | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | -------- | - | volumeUuid | string | 是 | 卷id | | packageName | string | 是 | 应用包名 | - + - 返回值 | 类型 | 说明 | @@ -140,35 +141,33 @@ getBundleStats(volumeUuid: string, packageName:String, ): Promise<BundleStat - 示例 ```js - let uuid = ""; let packageName = ""; - storagestatistics.getBundleStats(uuid, packageName).then(function(BundleStats){ + storagestatistics.getBundleStats(packageName).then(function(BundleStats){ console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); }).catch(function(err){ console.info("getBundleStats failed with error:"+ err); }); ``` -## storagestatistics.getBundleStats +## storagestatistics.getBundleStats9+ -getBundleStats(volumeUuid: string, callback:AsyncCallback<BundleStats>):void +getBundleStats(callback:AsyncCallback<BundleStats>):void -异步获取指定卷上的应用存储状态,以callback方式返回。 +异步获取应用存储状态,以callback方式返回。 - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | --------------------------------------------------------- | ---- | ------------------------------------ | - | volumeUuid | string | 是 | 卷id | - | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 | - + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | + | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 | + - 示例 ```js - let uuid = ""; let packageName = ""; - storagestatistics.getBundleStats(uuid, packageName, function(error, BundleStats){ + storagestatistics.getBundleStats(packageName, function(error, BundleStats){ // do something + console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-treemap.md b/zh-cn/application-dev/reference/apis/js-apis-treemap.md index e31c6540de600ef673dccf0d3a491efdbb6f1dcd..796112066e342dd7fe36577480a0481f3962d2b1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treemap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treemap.md @@ -95,13 +95,13 @@ let result1 = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hasValue(value: V): boolean -判断此容器中是否含有该指定元素。 +判断此容器中是否含有该指定value。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | V | 是 | 指定元素。 | +| value | V | 是 | 指定value。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-update.md b/zh-cn/application-dev/reference/apis/js-apis-update.md index b0f789003d71af0d28cf5a4669c05b3be7b1d724..ea84b0d18e42292353a90ff55f8c9f70b6fcec1b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-update.md +++ b/zh-cn/application-dev/reference/apis/js-apis-update.md @@ -1,5 +1,8 @@ # 升级 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + 升级范围:升级整个系统,包括内置的资源、预置应用;第三方的应用不在升级的范围。 升级依赖:升级分为SD卡升级和在线升级两种。 @@ -17,15 +20,13 @@ import update from '@ohos.update' 无 -## 获取升级对象Updater - -### update.getUpdater +## update.getUpdater getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater 获取本地升级Updater。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -50,13 +51,13 @@ try { } ``` -### update.getUpdaterForOther +## update.getUpdaterForOther getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater 获取升级对象给待升级设备。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -82,13 +83,13 @@ try { } ``` -### update.getUpdaterFromOther +## update.getUpdaterFromOther getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater 获取其它设备为本设备升级的Updater。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -122,7 +123,7 @@ getNewVersionInfo(callback: AsyncCallback\): void 获取新版本信息,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -147,7 +148,7 @@ getNewVersionInfo(): Promise\ 获取新版本信息,使用promise方式作为异步方法。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **返回值:** @@ -173,7 +174,7 @@ checkNewVersion(callback: AsyncCallback\): void 检查新版本,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -198,7 +199,7 @@ checkNewVersion(): Promise\ 检查新版本,使用promise方式作为异步方法。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **返回值:** @@ -224,7 +225,7 @@ verifyUpdatePackage(upgradeFile: string, certsFile: string): void 升级前检查升级包是否有效。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -248,7 +249,7 @@ rebootAndCleanUserData(): Promise\ 重启设备并清除用户分区数据。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **返回值:** @@ -272,7 +273,7 @@ rebootAndCleanUserData(callback: AsyncCallback\): void 重启设备并清除用户分区数据。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -294,7 +295,7 @@ applyNewVersion(): Promise\ 重启设备后安装升级包。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **返回值:** @@ -318,7 +319,7 @@ applyNewVersion(callback: AsyncCallback\): void 重启设备后安装升级包。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -340,7 +341,7 @@ download(): void 下载新版本,并监听下载进程。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **示例:** @@ -359,7 +360,7 @@ updater.upgrade():void 启动升级。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **示例:** @@ -378,7 +379,7 @@ setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\): void 设置升级策略,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -409,7 +410,7 @@ setUpdatePolicy(policy: UpdatePolicy): Promise\ 设置升级策略,使用promise方式作为异步方法。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -446,7 +447,7 @@ getUpdatePolicy(callback: AsyncCallback\): void 获取升级策略信息,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **参数:** @@ -471,7 +472,7 @@ getUpdatePolicy(): Promise\ 获取升级策略,通过promise方式作为异步方法。 -**系统能力**:SystemCapability.Updater.update_service +**系统能力**:SystemCapability.Update.UpdateService **返回值:** @@ -495,85 +496,101 @@ update.getUpdatePolicy().then(value => { 升级类型。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 参数名 | 说明 | | ------ | -------- | -| OTA | OTA升级
**系统能力**:SystemCapability.Updater.update_service| -| patch | 补丁升级
**系统能力**:SystemCapability.Updater.update_service| +| OTA | OTA升级 | +| patch | 补丁升级 | ## PackageTypes 升级包类型。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 参数名 | 默认值 | 说明 | | -------------------- | ------ | -------------- | -| PACKAGE_TYPE_NORMAL | 1 | 通用升级包
**系统能力**:SystemCapability.Updater.update_service| -| PACKAGE_TYPE_BASE | 2 | 基础升级包
**系统能力**:SystemCapability.Updater.update_service| -| PACKAGE_TYPE_CUST | 3 | 定制升级包
**系统能力**:SystemCapability.Updater.update_service| -| PACKAGE_TYPE_PRELOAD | 4 | 预装升级包
**系统能力**:SystemCapability.Updater.update_service| -| PACKAGE_TYPE_COTA | 5 | 参数配置升级包
**系统能力**:SystemCapability.Updater.update_service| -| PACKAGE_TYPE_VERSION | 6 | 版本升级包
**系统能力**:SystemCapability.Updater.update_service| -| PACKAGE_TYPE_PATCH | 7 | 补丁包
**系统能力**:SystemCapability.Updater.update_service| +| PACKAGE_TYPE_NORMAL | 1 | 通用升级包 | +| PACKAGE_TYPE_BASE | 2 | 基础升级包 | +| PACKAGE_TYPE_CUST | 3 | 定制升级包 | +| PACKAGE_TYPE_PRELOAD | 4 | 预装升级包 | +| PACKAGE_TYPE_COTA | 5 | 参数配置升级包 | +| PACKAGE_TYPE_VERSION | 6 | 版本升级包 | +| PACKAGE_TYPE_PATCH | 7 | 补丁包 | ## InstallMode 安装模式。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 参数名 | 默认值 | 说明 | | ------------------- | ------ | -------- | -| INSTALL_MODE_NORMAL | 0 | 正常升级
**系统能力**:SystemCapability.Updater.update_service| -| INSTALL_MODE_NIGHT | 1 | 夜间升级
**系统能力**:SystemCapability.Updater.update_service| -| INSTALL_MODE_AUTO | 2 | 自动升级
**系统能力**:SystemCapability.Updater.update_service| +| INSTALL_MODE_NORMAL | 0 | 正常升级 | +| INSTALL_MODE_NIGHT | 1 | 夜间升级 | +| INSTALL_MODE_AUTO | 2 | 自动升级 | ## NewVersionStatus 新版本检测状态。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 参数名 | 默认值 | 说明 | | ------------------- | ------ | ---------------- | -| VERSION_STATUS_ERR | -1 | 检测版本时出错
**系统能力**:SystemCapability.Updater.update_service| -| VERSION_STATUS_NEW | 0 | 检测到新版本
**系统能力**:SystemCapability.Updater.update_service| -| VERSION_STATUS_NONE | 1 | 没有检测到新版本
**系统能力**:SystemCapability.Updater.update_service| -| VERSION_STATUS_BUSY | 2 | 检测版本时忙
**系统能力**:SystemCapability.Updater.update_service| +| VERSION_STATUS_ERR | -1 | 检测版本时出错 | +| VERSION_STATUS_NEW | 0 | 检测到新版本 | +| VERSION_STATUS_NONE | 1 | 没有检测到新版本 | +| VERSION_STATUS_BUSY | 2 | 检测版本时忙 | ## UpdatePolicy 升级策略。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 名称 | 参数类型 | 必填 | 说明 | | ------------------- | --------------------------- | ---- | -------------- | -| autoDownload | bool | 是 | 自动升级开关
**系统能力**:SystemCapability.Updater.update_service| -| installMode | [InstallMode](#installmode) | 是 | 安装模式
**系统能力**:SystemCapability.Updater.update_service| -| autoUpgradeInterval | Array\ | 是 | 自动升级时间段
**系统能力**:SystemCapability.Updater.update_service| +| autoDownload | bool | 是 | 自动升级开关 | +| installMode | [InstallMode](#installmode) | 是 | 安装模式 | +| autoUpgradeInterval | Array\ | 是 | 自动升级时间段 | ## NewVersionInfo 新版本信息。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 名称 | 参数类型 | 必填 | 说明 | | --------------- | ------------------------------------------- | ---- | -------- | -| status | [NewVersionStatus](#newversionstatus) | 是 | 升级状态
**系统能力**:SystemCapability.Updater.update_service| -| errMsg | string | 是 | 错误信息
**系统能力**:SystemCapability.Updater.update_service| -| checkResults | Array<[CheckResult](#checkresult)> | 是 | 检测结果
**系统能力**:SystemCapability.Updater.update_service| -| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | 是 | 描述信息
**系统能力**:SystemCapability.Updater.update_service| +| status | [NewVersionStatus](#newversionstatus) | 是 | 升级状态 | +| errMsg | string | 是 | 错误信息 | +| checkResults | Array<[CheckResult](#checkresult)> | 是 | 检测结果 | +| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | 是 | 描述信息 | ## CheckResult 检测结果。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 名称 | 参数类型 | 必填 | 说明 | | ------------- | ----------------------------- | ---- | ------------ | -| versionName | string | 是 | 版本名称
**系统能力**:SystemCapability.Updater.update_service| -| versionCode | number | 是 | 版本编码
**系统能力**:SystemCapability.Updater.update_service| -| size | number | 是 | 版本大小
**系统能力**:SystemCapability.Updater.update_service| -| verifyInfo | string | 是 | 版本校验信息
**系统能力**:SystemCapability.Updater.update_service| -| packageType | [PackageTypes](#packagetypes) | 是 | 版本类型
**系统能力**:SystemCapability.Updater.update_service| -| descriptionId | string | 是 | 版本描述信息
**系统能力**:SystemCapability.Updater.update_service| +| versionName | string | 是 | 版本名称 | +| versionCode | number | 是 | 版本编码 | +| size | number | 是 | 版本大小 | +| verifyInfo | string | 是 | 版本校验信息 | +| packageType | [PackageTypes](#packagetypes) | 是 | 版本类型 | +| descriptionId | string | 是 | 版本描述信息 | ## DescriptionInfo 版本描述信息。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 名称 | 参数类型 | 必填 | 说明 | | ------------- | -------- | ---- | ----------------- | -| descriptionId | string | 是 | 版本versionId信息
**系统能力**:SystemCapability.Updater.update_service| -| content | string | 是 | 版本changelog信息
**系统能力**:SystemCapability.Updater.update_service| \ No newline at end of file +| descriptionId | string | 是 | 版本versionId信息 | +| content | string | 是 | 版本changelog信息 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md b/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md index 14a3814de074e2cdcdbed759f59fa4151ca8411c..f09e2458dfda147edba473e448e7d6ead422e85e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md @@ -1,12 +1,7 @@ # UriPermissionManager -- [导入模块](#导入模块) -- [verifyUriPermission](#verifyUriPermission) -- [verifyUriPermission](#verifyUriPermission) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。 +> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 Uri权限管理。 @@ -36,7 +31,7 @@ SystemCapability.Ability.AbilityRuntime.Core | uri | string | 是 | 指向文件的uri,例如fileshare:///com.samples.filesharetest.FileShare/person/10。 | | flag | wantConstant.Flags | 是 | uri的读权限或写权限。 | | accessTokenId | number | 是 | 每个应用的唯一标识ID,开发者通过包管理接口自行获取。 | - | callback | AsyncCallback<number> | 是 | callback形式返回启动结果,返回0表示有权限,返回-1表示无权限。 | + | callback | AsyncCallback<number> | 是 | callback形式返回检验结果,返回0表示有权限,返回-1表示无权限。 | - 示例: diff --git a/zh-cn/application-dev/reference/apis/js-apis-url.md b/zh-cn/application-dev/reference/apis/js-apis-url.md index f9fc0379bbb57eff50d727381e10b4267a1c8d61..2208093cd8c569b43645479e6840acf41e5f4ef4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-url.md +++ b/zh-cn/application-dev/reference/apis/js-apis-url.md @@ -36,7 +36,7 @@ var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'] var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2}); var objectParams2 = new URLSearchParams('?fod=1&bard=2'); var urlObject = new URL('https://developer.mozilla.org/?fod=1&bard=2'); -var params = new URLSearchParams(urlObject .search); +var params = new URLSearchParams(urlObject.search); ``` @@ -79,7 +79,7 @@ delete(name: string): void ``` let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsobject = new URLSearchParams(urlObject.search.slice(1)); -paramsobject.delete('foo'); +paramsobject.delete('fod'); ``` @@ -106,7 +106,7 @@ getAll(name: string): string[] ``` let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); -paramsObject.append('fod', 3); // Add a second value for the foo parameter. +paramsObject.append('fod', 3); // Add a second value for the fod parameter. console.log(params.getAll('fod')) // Output ["1","3"]. ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-vector.md b/zh-cn/application-dev/reference/apis/js-apis-vector.md index 3e9285e735f00541bdee712b0f1488123d8a65a9..6b1644a678ca0f1ab2ddf9191d34c73f112edf2e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vector.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vector.md @@ -114,8 +114,8 @@ has(element: T): boolean let vector = new Vector(); let result = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); vector.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -let result = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -``` +let result1 = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` ### getIndexOf diff --git a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md index 7e4d658d1a434da4af2e0b54d058bc7da917300d..f0880ee46acee9980596247992a75f4b37cc739c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md @@ -10,22 +10,17 @@ import vibrator from '@ohos.vibrator'; ``` -## 系统能力 - -SystemCapability.Sensors.MiscDevice - -## 权限列表 - -ohos.permission.VIBRATE - ## vibrator.vibrate vibrate(duration: number): Promise<void> - 按照指定持续时间触发马达振动。 +**权限列表**:ohos.permission.VIBRATE,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.MiscDevice + - 参数: | 参数名 | 类型 | 必填 | 说明 | @@ -54,13 +49,17 @@ vibrate(duration: number, callback?: AsyncCallback<void>): void 按照指定持续时间触发马达振动。 +**权限列表**:ohos.permission.VIBRATE,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.MiscDevice + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | duration | number | 是 | 指示马达振动的持续时间。 | | callback | AsyncCallback<void> | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 | -- 示例**:** +- 示例: ``` vibrator.vibrate(1000,function(error){ if(error){ @@ -78,6 +77,10 @@ vibrate(effectId: EffectId): Promise<void> 按照指定振动效果触发马达振动。 +**权限列表**:ohos.permission.VIBRATE,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.MiscDevice + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -104,6 +107,10 @@ vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void 按照指定振动效果触发马达振动。 +**权限列表**:ohos.permission.VIBRATE,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.MiscDevice + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -128,6 +135,10 @@ stop(stopMode: VibratorStopMode): Promise<void> 按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。 +**权限列表**:ohos.permission.VIBRATE,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.MiscDevice + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -154,6 +165,10 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void; 按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。 +**权限列表**:ohos.permission.VIBRATE,该权限为系统权限 + +**系统能力**:SystemCapability.Sensors.MiscDevice + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -176,6 +191,8 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void; 表示马达振动效果的字符串。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice + | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | | EFFECT_CLOCK_TIMER | "haptic.clock.timer" | 调整定时器时振动器的振动效果。 | @@ -185,6 +202,8 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void; 表示马达要停止指定的振动模式。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice + | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | | VIBRATOR_STOP_MODE_TIME | "time" | 停止模式为duration模式的振动。即触发振动时参数类型为number,参数本身为指示振动持续时间的触发方式。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index faac688921ed5bdcb7b9714fd1743674e5faf49b..975ce49cb9e17efb19f024ea0afaeed95936ce51 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -13,118 +13,152 @@ import window from '@ohos.window'; 窗口类型。 -| 名称 | 默认值 | 说明 | -| ----------------- | ------ | ------------------------------------------------------------ | -| TYPE_APP | 0 | 表示应用子窗口。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| TYPE_SYSTEM_ALERT | 1 | 表示系统告警窗口。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 默认值 | 说明 | +| ----------------- | ------ | ------------------ | +| TYPE_APP | 0 | 表示应用子窗口。 | +| TYPE_SYSTEM_ALERT | 1 | 表示系统告警窗口。 | ## AvoidAreaType7+ 窗口内容需要规避区域的类型。 -| 名称 | 默认值 | 说明 | -| ----------- | ------ | ------------------------------------------------------------ | -| TYPE_SYSTEM | 0 | 表示系统默认区域。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| TYPE_CUTOUT | 1 | 表示刘海屏区域。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 默认值 | 说明 | +| ----------- | ------ | ------------------ | +| TYPE_SYSTEM | 0 | 表示系统默认区域。 | +| TYPE_CUTOUT | 1 | 表示刘海屏区域。 | ## WindowMode7+ 窗口模式。 -| 名称 | 默认值 | 说明 | -| ---------- | ------ | ------------------------------------------------------------ | -| UNDEFINED | 1 | 表示APP未定义窗口模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| FULLSCREEN | 2 | 表示APP全屏模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| PRIMARY | 3 | 表示APP分屏多窗口主要模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| SECONDARY | 4 | 表示APP分屏多窗口次要模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| FLOATING | 5 | 表示APP自由悬浮形式窗口模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +此接口为系统接口,三方应用不支持调用。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 默认值 | 说明 | +| ---------- | ------ | ----------------------------- | +| UNDEFINED | 1 | 表示APP未定义窗口模式。 | +| FULLSCREEN | 2 | 表示APP全屏模式。 | +| PRIMARY | 3 | 表示APP分屏多窗口主要模式。 | +| SECONDARY | 4 | 表示APP分屏多窗口次要模式。 | +| FLOATING | 5 | 表示APP自由悬浮形式窗口模式。 | ## SystemBarProperties 状态栏导航栏的属性。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | -| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| statusBarContentColor8+ | string | 否 | 是 | 状态栏文字颜色。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| isNavigationBarLightIcon7+ | boolean | 否 | 否 | 导航栏图标是否为高亮状态。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| navigationBarContentColor8+ | string | 否 | 是 | 导航栏文字颜色。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。 | +| isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。 | +| statusBarContentColor8+ | string | 否 | 是 | 状态栏文字颜色。 | +| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。 | +| isNavigationBarLightIcon7+ | boolean | 否 | 否 | 导航栏图标是否为高亮状态。 | +| navigationBarContentColor8+ | string | 否 | 是 | 导航栏文字颜色。 | ## SystemBarRegionTint 8+ 单个导航栏或状态栏回调信息。 +此接口为系统接口,三方应用不支持调用。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| type | [WindowType](#windowtype) | 是 | 是 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| isEnable | boolean | 是 | 是 | 当前系统栏是否显示。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| region | [Rect](#rect) | 是 | 是 | 当前系统栏的位置及大小。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| contentColor | string | 是 | 是 | 系统栏文字颜色。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| type | [WindowType](#windowtype) | 是 | 是 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | +| isEnable | boolean | 是 | 是 | 当前系统栏是否显示。 | +| region | [Rect](#rect) | 是 | 是 | 当前系统栏的位置及大小。 | +| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。 | +| contentColor | string | 是 | 是 | 系统栏文字颜色。 | ## SystemBarTintState 8+ 当前系统栏回调信息集合。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---------- | -------------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| displayId | number | 是 | 否 | 当前物理屏幕id。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| regionTint | Array<[SystemBarRegionTint](#systembartegiontint)> | 是 | 是 | 当前改变所有的系统栏信息。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +此接口为系统接口,三方应用不支持调用。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---------- | -------------------------------------------------- | ---- | ---- | -------------------------- | +| displayId | number | 是 | 否 | 当前物理屏幕id。 | +| regionTint | Array<[SystemBarRegionTint](#systembartegiontint)> | 是 | 是 | 当前改变所有的系统栏信息。 | ## Rect7+ 矩形。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | -| left | number | 是 | 是 | 矩形区域的左边界。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| top | number | 是 | 是 | 矩形区域的上边界。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| width | number | 是 | 是 | 矩形区域的宽度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| height | number | 是 | 是 | 矩形区域的高度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | -------- | ---- | ---- | ------------------ | +| left | number | 是 | 是 | 矩形区域的左边界。 | +| top | number | 是 | 是 | 矩形区域的上边界。 | +| width | number | 是 | 是 | 矩形区域的宽度。 | +| height | number | 是 | 是 | 矩形区域的高度。 | ## AvoidArea7+ 表示窗口内容规避区域。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---------- | ------------- | ---- | ---- | ------------------------------------------------------------ | -| leftRect | [Rect](#rect) | 是 | 是 | 屏幕左侧的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| topRect | [Rect](#rect) | 是 | 是 | 屏幕顶部的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| rightRect | [Rect](#rect) | 是 | 是 | 屏幕右侧的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| bottomRect | [Rect](#rect) | 是 | 是 | 屏幕底部的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---------- | ------------- | ---- | ---- | ------------------ | +| leftRect | [Rect](#rect) | 是 | 是 | 屏幕左侧的矩形区。 | +| topRect | [Rect](#rect) | 是 | 是 | 屏幕顶部的矩形区。 | +| rightRect | [Rect](#rect) | 是 | 是 | 屏幕右侧的矩形区。 | +| bottomRect | [Rect](#rect) | 是 | 是 | 屏幕底部的矩形区。 | ## Size7+ 窗口大小。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | -| width | number | 是 | 是 | 窗口宽度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| height | number | 是 | 是 | 窗口高度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | -------- | ---- | ---- | ---------- | +| width | number | 是 | 是 | 窗口宽度。 | +| height | number | 是 | 是 | 窗口高度。 | ## WindowProperties 窗口属性。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| windowRect7+ | [Rect](#rect) | 是 | 是 | 窗口尺寸。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| type7+ | [WindowType](#windowtype) | 是 | 是 | 窗口类型。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| focusable7+ | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| touchable7+ | boolean | 是 | 否 | 窗口是否可触摸,默认为true。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| windowRect7+ | [Rect](#rect) | 是 | 是 | 窗口尺寸。 | +| type7+ | [WindowType](#windowtype) | 是 | 是 | 窗口类型。 | +| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。 | +| isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。 | +| focusable7+ | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。 | +| touchable7+ | boolean | 是 | 否 | 窗口是否可触摸,默认为true。 | +| brightness | number | 是 | 是 | 屏幕亮度, 取值范围为0~1,1表示最大亮度值。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| dimBehindValue7+ | number | 是 | 是 | 靠后窗口的暗度值,取值范围为0~1,1表示最暗。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| isKeepScreenOn | boolean | 是 | 是 | 屏幕是否常亮,默认为false。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| isPrivacyMode7+ | boolean | 是 | 是 | 隐私模式,默认为false。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| isRoundCorner7+ | boolean | 是 | 是 | 窗口是否为圆角。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| isTransparent7+ | boolean | 是 | 是 | 窗口是否透明。默认为false。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | ## ColorSpace8+ 色域模式。 -| 名称 | 默认值 | 说明 | -| ---------- | ------ | ------------------------------------------------------------ | -| DEFAULT | 0 | 默认色域模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| WIDE_GAMUT | 1 | 广色域模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 默认值 | 说明 | +| ---------- | ------ | -------------- | +| DEFAULT | 0 | 默认色域模式。 | +| WIDE_GAMUT | 1 | 广色域模式。 | ## window.create7 @@ -145,12 +179,13 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi - 示例 ``` + var windowClass = null; window.create("first", window.WindowType.TYPE_APP, (err, data) => { - windowClass = data; if (err.code) { console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); return; } + windowClass = data; console.info('SubWindow created. Data: ' + JSON.stringify(data)) windowClass.resetSize(500, 1000); }); @@ -180,8 +215,10 @@ create(id: string, type: WindowType): Promise<Window> - 示例 ``` + var windowClass = null; let promise = window.create("first", window.WindowType.TYPE_APP); promise.then((data)=> { + windowClass = data; console.info('SubWindow created. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); @@ -208,12 +245,13 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi - 示例 ``` + var windowClass = null; window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { - windowClass = data; if (err.code) { console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); return; } + windowClass = data; console.info('Window created. Data: ' + JSON.stringify(data)) windowClass.resetSize(500, 1000); }); @@ -244,8 +282,10 @@ create(ctx: Context, id: string, type: WindowType): Promise<Window> - 示例 ``` + var windowClass = null; let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT); promise.then((data)=> { + windowClass = data; console.info('Window created. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); @@ -270,13 +310,14 @@ find(id: string, callback: AsyncCallback<Window>): void - 示例 ``` - window.find("first", (err, data) => { + var windowClass = null; + window.find("alertWindow", (err, data) => { if (err.code) { console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); return; } - console.info('window found. Data: ' + JSON.stringify(data)) - windowClass = data; + windowClass = data; + console.info('window found. Data: ' + JSON.stringify(data)) }); ``` @@ -303,8 +344,10 @@ find(id: string): Promise<Window> - 示例 ``` - let promise = window.find("first"); + var windowClass = null; + let promise = window.find("alertWindow"); promise.then((data)=> { + windowClass = data; console.info('window found. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); @@ -328,13 +371,14 @@ getTopWindow(callback: AsyncCallback<Window>): void - 示例 ``` + var windowClass = null; window.getTopWindow((err, data) => { if (err.code) { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }); ``` @@ -355,8 +399,10 @@ getTopWindow(): Promise<Window> - 示例 ``` + var windowClass = null; let promise = window.getTopWindow(); promise.then((data)=> { + windowClass = data; console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); @@ -381,13 +427,14 @@ getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void - 示例 ``` + var windowClass = null; window.getTopWindow(this.context, (err, data) => { if (err.code) { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }); ``` @@ -414,8 +461,10 @@ getTopWindow(ctx: Context): Promise<Window> - 示例 ``` + var windowClass = null; let promise = window.getTopWindow(this.context); promise.then((data)=> { + windowClass = data; console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); @@ -428,6 +477,8 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v 注册状态栏、导航栏的监听函数。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 @@ -452,6 +503,8 @@ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >) 关闭监听。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 @@ -478,6 +531,8 @@ hide (callback: AsyncCallback<void>): void 隐藏当前窗口,使用callback方式作为异步方法。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 @@ -489,12 +544,12 @@ hide (callback: AsyncCallback<void>): void - 示例 ``` - windowClass.hide((err) => { + windowClass.hide((err, data) => { if (err.code) { console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); return; } - console.info('window hidden.') + console.info('window hidden. data: ' + JSON.stringify(data)) }) ``` @@ -504,6 +559,8 @@ hide(): Promise<void> 隐藏当前窗口,使用Promise方式作为异步方法。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 返回值 @@ -516,8 +573,8 @@ hide(): Promise<void> ``` let promise = windowClass.hide(); - promise.then(()=> { - console.info('window hidden.') + promise.then((data)=> { + console.info('window hidden. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); }) @@ -540,12 +597,12 @@ show(callback: AsyncCallback<void>): void - 示例 ``` - windowClass.show((err) => { + windowClass.show((err, data) => { if (err.code) { console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in showing the window.') + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) }) ``` @@ -567,8 +624,8 @@ show(): Promise<void> ``` let promise = windowClass.show(); - promise.then(()=> { - console.info('Succeeded in showing the window.') + promise.then((data)=> { + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); }) @@ -591,12 +648,12 @@ destroy(callback: AsyncCallback<void>): void - 示例 ``` - windowClass.destroy((err) => { + windowClass.destroy((err, data) => { if (err.code) { console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in destroying the window.') + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) }) ``` @@ -618,8 +675,8 @@ destroy(): Promise<void> ``` let promise = windowClass.destroy(); - promise.then(()=> { - console.info('Succeeded in destroying the window.') + promise.then((data)=> { + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); }) @@ -644,12 +701,12 @@ moveTo(x: number, y: number, callback: AsyncCallback<void>): void - 示例 ``` - windowClass.moveTo(300, 300, (err)=>{ + windowClass.moveTo(300, 300, (err, data)=>{ if (err.code) { console.error('Failed to move the window. Cause:' + JSON.stringify(err)); return; } - console.info('Window moved.'); + console.info('Window moved. Data: ' + JSON.stringify(data)) }); ``` @@ -679,8 +736,8 @@ moveTo(x: number, y: number): Promise<void> ``` let promise = windowClass.moveTo(300, 300); - promise.then(()=> { - console.info('Window moved.') + promise.then((data)=> { + console.info('Window moved. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); }) @@ -705,12 +762,12 @@ resetSize(width: number, height: number, callback: AsyncCallback<void>): v - 示例 ``` - windowClass.resetSize(500, 1000, (err) => { + windowClass.resetSize(500, 1000, (err, data) => { if (err.code) { console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); return; } - console.info('Window size changed.'); + console.info('Window size changed. Data: ' + JSON.stringify(data)) }); ``` @@ -739,8 +796,8 @@ resetSize(width: number, height: number): Promise<void> ``` let promise = windowClass.resetSize(500, 1000); - promise.then(()=> { - console.info('Window size changed.') + promise.then((data)=> { + console.info('Window size changed. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); }); @@ -752,6 +809,8 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void 设置窗口类型,使用callback方式作为异步方法。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 @@ -765,12 +824,12 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void ``` var type = window.TYPE_APP; - windowClass.setWindowType(type, (err) => { + windowClass.setWindowType(type, (err, data) => { if (err.code) { console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window type.') + console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) }); ``` @@ -780,6 +839,8 @@ setWindowType(type: WindowType): Promise<void> 设置窗口类型,使用Promise方式作为异步方法。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 @@ -799,8 +860,8 @@ setWindowType(type: WindowType): Promise<void> ``` var type = window.TYPE_APP; let promise = windowClass.setWindowType(type); - promise.then(()=> { - console.info('Succeeded in setting the window type.') + promise.then((data)=> { + console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); }); @@ -935,12 +996,12 @@ setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void ``` var isFullScreen = true; - windowClass.setFullScreen(isFullScreen, (err) => { + windowClass.setFullScreen(isFullScreen, (err, data) => { if (err.code) { console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in enabling the full-screen mode.'); + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)) }); ``` @@ -969,8 +1030,8 @@ setFullScreen(isFullScreen: boolean): Promise<void> ``` var isFullScreen = true; let promise = windowClass.setFullScreen(isFullScreen); - promise.then(()=> { - console.info('Succeeded in enabling the full-screen mode.')) + promise.then((data)=> { + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); }); @@ -995,12 +1056,12 @@ setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void ``` var isLayoutFullScreen= true; - windowClass.setLayoutFullScreen(isLayoutFullScreen, (err) => { + windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { if (err.code) { console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window layout to full-screen mode.'); + console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)) }); ``` @@ -1029,8 +1090,8 @@ setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> ``` var isLayoutFullScreen = true; let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); - promise.then(()=> { - console.info('Succeeded in setting the window layout to full-screen mode.')) + promise.then((data)=> { + console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); }); @@ -1055,12 +1116,12 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallbac ``` var names = ["status", "navigation"]; - windowClass.setSystemBarEnable(names, (err) => { + windowClass.setSystemBarEnable(names, (err, data) => { if (err.code) { console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the system bar to be visible.'); + console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)) }); ``` @@ -1089,8 +1150,8 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> ``` var names = ["status", "navigation"]; let promise = windowClass.setSystemBarEnable(names); - promise.then(()=> { - console.info('Succeeded in setting the system bar to be visible.')) + promise.then((data)=> { + console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); }); @@ -1121,15 +1182,15 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: Async isStatusBarLightIcon: true, isNavigationBarLightIcon:false, //以下两个属性从API Version8开始支持 - statusBarContentColor:'#ffffff' + statusBarContentColor:'#ffffff', navigationBarContentColor:'#00ffff' }; - windowClass.setSystemBarProperties(SystemBarProperties, (err) => { + windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { if (err.code) { console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the system bar properties.'); + console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)) }); ``` @@ -1163,20 +1224,20 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<voi isStatusBarLightIcon: true, isNavigationBarLightIcon:false, //以下两个属性从API Version8开始支持 - statusBarContentColor:'#ffffff' + statusBarContentColor:'#ffffff', navigationBarContentColor:'#00ffff' }; let promise = windowClass.setSystemBarProperties(SystemBarProperties); - promise.then(()=> { - console.info('Succeeded in setting the system bar properties.')) + promise.then((data)=> { + console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); }); ``` -### loadContent8+ +### loadContent7+ -loadContent(path: string, storage: ContentStorage, callback: AsyncCallback<void>): void +loadContent(path: string, callback: AsyncCallback<void>): void 当前窗口加载具体页面内容,使用callback方式作为异步方法。 @@ -1187,24 +1248,23 @@ loadContent(path: string, storage: ContentStorage, callback: AsyncCallback<vo | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | -------------------- | | path | string | 是 | 设置加载页面的路径。 | - | storage | ContentStorage | 否 | 当前应用内的数据。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | - + - 示例 ``` - windowClass.loadContent("pages/page2/page2", (err) => { + windowClass.loadContent("pages/page2/page2", (err, data) => { if (err.code) { console.error('Failed to load the content. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in loading the content.'); + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) }); ``` -### loadContent8+ +### loadContent7+ -loadContent(path: string, storage?: ContentStorage): Promise<void> +loadContent(path: string): Promise<void> 当前窗口加载具体页面内容,使用Promise方式作为异步方法。 @@ -1212,11 +1272,10 @@ loadContent(path: string, storage?: ContentStorage): Promise<void> - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | ------- | -------------- | ---- | -------------------- | - | path | string | 是 | 设置加载页面的路径。 | - | storage | ContentStorage | 否 | 当前应用内的数据。 | - + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------------------- | + | path | string | 是 | 设置加载页面的路径。 | + - 返回值 | 类型 | 说明 | @@ -1227,8 +1286,8 @@ loadContent(path: string, storage?: ContentStorage): Promise<void> ``` let promise = windowClass.loadContent("pages/page2/page2"); - promise.then(()=> { - console.info('Succeeded in loading the content.')) + promise.then((data)=> { + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); }); @@ -1251,12 +1310,12 @@ isShowing(callback: AsyncCallback<boolean>): void - 示例 ``` - windowClass.isShowing((err) => { + windowClass.isShowing((err, data) => { if (err.code) { console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in checking whether the window is showing. Cause:') + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)) }); ``` @@ -1278,8 +1337,8 @@ isShowing(): Promise<boolean> ``` let promise = windowClass.isShowing(); - promise.then(()=> { - console.info('Succeeded in checking whether the window is showing.') + promise.then((data)=> { + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); }); @@ -1377,6 +1436,56 @@ off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void windowClass.off(type); ``` +### on('keyboardHeightChange')7+ + +on(type: 'keyboardHeightChange', callback: Callback<number>): void + +开启键盘高度变化的监听。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'keyboardHeightChange'时表示监听类型为键盘高度变化监听。 | + | callback | Callback<[AvoidArea](#avoidarea)> | 是 | 回调返回监听到的信息。 | + +- 示例 + + ``` + var type = 'keyboardHeightChange'; + windowClass.on(type, (data) => { + console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); + }); + ``` + +### off('keyboardHeightChange')7+ + +off(type: 'keyboardHeightChange', callback?: Callback<number>): void + +关闭键盘高度变化的监听。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'keyboardHeightChange'时表示监听类型为键盘高度变化监听。 | + | callback | Callback<number> | 否 | 回调返回监听到的信息。 | + +- 示例 + + ``` + var type = 'keyboardHeightChange'; + windowClass.off(type); + ``` + ### isSupportWideGamut8+ isSupportWideGamut(callback: AsyncCallback<boolean>): void @@ -1394,12 +1503,12 @@ isSupportWideGamut(callback: AsyncCallback<boolean>): void - 示例 ``` - windowClass.isSupportWideGamut((err) => { + windowClass.isSupportWideGamut((err, data) => { if (err.code) { console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in checking whether the window support WideGamut.') + console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)) }) ``` @@ -1421,8 +1530,8 @@ isSupportWideGamut(): Promise<boolean> ``` let promise = windowClass.isSupportWideGamut(); - promise.then(()=> { - console.info('Succeeded in checking whether the window support WideGamut.') + promise.then((data)=> { + console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); }); @@ -1446,12 +1555,12 @@ setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void - 示例 ``` - windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => { + windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { if (err.code) { console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting window colorspace.') + console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) }) ``` @@ -1479,8 +1588,8 @@ setColorSpace(colorSpace:ColorSpace): Promise<void> ``` let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT); - promise.then(()=> { - console.info('Succeeded in setting window colorspace.') + promise.then((data)=> { + console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to set window colorspacet. Cause: ' + JSON.stringify(err)); }); @@ -1537,3 +1646,514 @@ getColorSpace(): Promise<ColorSpace> }); ``` +### setBackgroundColor + +setBackgroundColor(color: string, callback: AsyncCallback<void>): void + +设置窗口的背景色,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ------------------------------------------------------------ | + | color | string | 是 | 需要设置的背景色,为16进制颜色,例如"#00FF00"或"#FF00FF00"。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var color = '#00ff33'; + windowClass.setBackgroundColor(color, (err, data) => { + if (err.code) { + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); + }); + ``` + +### setBackgroundColor + +setBackgroundColor(color: string): Promise<void> + +设置窗口的背景色,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------------------------------------------ | + | color | string | 是 | 需要设置的背景色,为16进制颜色,例如"#00FF00"或"#FF00FF00"。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var color = '#00ff33'; + let promise = windowClass.setBackgroundColor(color); + promise.then((data)=> { + console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setBrightness + +setBrightness(brightness: number, callback: AsyncCallback<void>): void + +设置屏幕亮度值,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------------------------- | ---- | ------------------------------------ | + | brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var brightness = 1; + windowClass.setBrightness(brightness, (err, data) => { + if (err.code) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); + }); + ``` + +### setBrightness + +setBrightness(brightness: number): Promise<void> + +设置屏幕亮度值,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------ | ---- | ------------------------------------ | + | brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var brightness = 1; + let promise = windowClass.setBrightness(brightness); + promise.then((data)=> { + console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setDimBehind7+ + +setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void + +窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------------------------- | ---- | -------------------------------------------------- | + | dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + windowClass.setDimBehind(0.5, (err, data) => { + if (err.code) { + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); + }); + ``` + +### setDimBehind7+ + +setDimBehind(dimBehindValue: number): Promise<void> + +窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------ | ---- | -------------------------------------------------- | + | dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + let promise = windowClass.setDimBehind(0.5); + promise.then((data)=> { + console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setFocusable7+ + +setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void + +设置点击时是否支持切换焦点窗口,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | ------------------------- | ---- | ---------------------------- | + | isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var isFocusable= true; + windowClass.setFocusable(isFocusable, (err, data) => { + if (err.code) { + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); + }); + ``` + +### setFocusable7+ + +setFocusable(isFocusable: boolean): Promise<void> + +设置点击时是否支持切换焦点窗口,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | ------- | ---- | ---------------------------- | + | isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var isFocusable= true; + let promise = windowClass.setFocusable(isFocusable); + promise.then((data)=> { + console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setKeepScreenOn + +setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void + +设置屏幕是否为常亮状态,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------------------------- | ---- | ------------------------ | + | isKeepScreenOn | boolean | 是 | 是否设置为屏幕常亮状态。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var isKeepScreenOn = true; + windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { + if (err.code) { + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); + }); + ``` + +### setKeepScreenOn + +setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> + +设置屏幕是否为常亮状态,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------- | ---- | ------------------------ | + | isKeepScreenOn | boolean | 是 | 是否设置为屏幕常亮状态。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var isKeepScreenOn= true; + let promise = windowClass.setKeepScreenOn(isKeepScreenOn); + promise.then((data)=> { + console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setOutsideTouchable7+ + +setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void + +设置是否允许可点击子窗口以外的区域,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------------------------- | ---- | ---------------- | + | touchable | boolean | 是 | 设置是否可点击。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + windowClass.setOutsideTouchable(true, (err, data) => { + if (err.code) { + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) + }) + ``` + +### setOutsideTouchable7+ + +setOutsideTouchable(touchable: boolean): Promise<void> + +设置是否允许可点击子窗口以外的区域,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------- | ---- | ---------------- | + | touchable | boolean | 是 | 设置是否可点击。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + let promise = windowClass.setOutsideTouchable(true); + promise.then((data)=> { + console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setPrivacyMode7+ + +setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void + +设置窗口是否为隐私模式,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ------------- | ------------------------- | ---- | -------------------- | + | isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var isPrivacyMode = true; + windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { + if (err.code) { + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data)); + + }); + ``` + +### setPrivacyMode7+ + +setPrivacyMode(isPrivacyMode: boolean): Promise<void> + +设置窗口是否为隐私模式,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ------------- | ------- | ---- | -------------------- | + | isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var isPrivacyMode = true; + let promise = windowClass.setPrivacyMode(isPrivacyMode); + promise.then((data)=> { + console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setTouchable7+ + +setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void + +设置窗口是否为可触状态,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | ------------------------- | ---- | -------------------- | + | isTouchable | boolean | 是 | 窗口是否为可触状态。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var isTouchable = true; + windowClass.setTouchable(isTouchable, (err, data) => { + if (err.code) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); + + }); + ``` + +### setTouchable7+ + +setTouchable(isTouchable: boolean): Promise<void> + +设置窗口是否为可触状态,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | ------- | ---- | -------------------- | + | isTouchable | boolean | 是 | 窗口是否为可触状态。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var isTouchable = true; + let promise = windowClass.setTouchable(isTouchable); + promise.then((data)=> { + console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); + }); + ``` + +### \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-zlib.md b/zh-cn/application-dev/reference/apis/js-apis-zlib.md new file mode 100644 index 0000000000000000000000000000000000000000..c23db3897b773977947ff00036821b625845cd0a --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-zlib.md @@ -0,0 +1,161 @@ +# Zip模块(JS端SDK接口) + +## 使用限制 +无。 +## 导入模块 +import zlib from '@ohos.zlib' +## zlib.zipFile +zipFile(inFile:string, outFile:string, options: Options): Promise; +压缩接口(Promise形式)。 + +**系统能力:** SystemCapability.BundleManager.Zlib + +**参数:** + +| 名称 | 类型 | 必填 | 描述 | +| ------- | ----------------------------------- | ---- | ------------------------------------------- | +| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径 | +| outFile | string | 是 | 指定的压缩结果的文件路径(文件的扩展名zip) | +| options | [Options](#options对象可选参数说明) | 否 | 压缩的可选参数 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ---------------------------------------------------- | +| Promise\ | ERROR_CODE_OK:压缩成功 ERROR_CODE_ERRNO:压缩失败 | + +**示例1:** + +```javascript + +//【压缩文件 例子1】 +import zlib from '@ohos.zlib' +var inFile = "/xxx/filename.xxx"; +var outFile = "/xxx/xxx.zip"; +var options = {}; +options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; +options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; +options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; + +zlib.zipFile(inFile, outFile, options).then((data) => { + if (data == zlib.ErrorCode.ERROR_CODE_OK) { + console.log("zipFile OK"); + } else { + console.log("zipFile NG"); + } +}).catch((err)=>{ + console.log("catch((err)=>" + err); +}); + +``` + +**示例2:** + +``` +// 【压缩文件夹 例子2】 +import zlib from '@ohos.zlib' +var inFile = "/xxx/xxx"; +var outFile = "/xxx/xxx.zip"; +var options = {}; +options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; +options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; +options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; + +zlib.zipFile(inFile , unzipDir, options).then((data) => { + if (data == zlib.ErrorCode.ERROR_CODE_OK) { + console.log("zipFile OK"); + } else { + console.log("zipFile NG"); + } +}).catch((err)=>{ + console.log("catch((err)=>" + err); +}); +``` + +## zlib.unzipFile + +unzipFile(inFile:string, outFile:string, options: Options): Promise; + +解压文件,解压完成返回执行结果(Promise形式)。 + +**系统能力:** SystemCapability.BundleManager.Zlib + +**参数:** + +| 名称 | 类型 | 必填 | 描述 | +| ------- | ----------------------------------- | ---- | ----------------------------------- | +| inFile | string | 是 | 指定解压的文件路径(文件扩展名zip) | +| outFile | string | 是 | 指定的解压文件路径 | +| options | [Options](#options对象可选参数说明) | 否 | 解压的可选参数 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------------------------------------------ | +| Promise\ | ERROR_CODE_OK:解压成功 ERROR_CODE_ERRNO:解压失败返回执行结果。 | + +**示例:** + +```javascript +// 【解压例子1】 +import zlib from '@ohos.zlib' +var inFile = "/xx/xxx.zip"; +var outFile = "/xxx"; + +var options = {}; +options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; +options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; +options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; + +zlib.unzipFile(inFile, outFile, options).then((data) => { + if (data == zlib.ErrorCode.ERROR_CODE_OK) { + console.log("unzipFile OK"); + } else { + console.log("unzipFile NG"); + } +}).catch((err)=>{ + console.log("catch((err)=>" + err); +}) + +``` + +## Options对象可选参数说明 + +| 参数 | | +| --------------------------- | ------------------------------------------------------------ | +| level?: CompressLeve | [参考zip.CompressLevel枚举定义](#zip.CompressLevel压缩等级可选参数说明) | +| memLevel?: MemLevel | [参考zip.MemLevel枚举定义](#zip.MemLevel可选参数说明) | +| strategy?: CompressStrategy | [参考zip.CompressStrategy枚举定义](#zip.CompressStrategy压缩策略可选参数说明) | + +## zip.MemLevel可选参数说明 + +| MEM_LEVEL_MIN | zip 接口在压缩过程中最小使用内存 | +| ----------------- | -------------------------------- | +| MEM_LEVEL_MAX | zip 接口在压缩过程中最大使用内存 | +| MEM_LEVEL_DEFAULT | zip 接口在压缩过程中默认使用内存 | + +## zip.CompressLevel压缩等级可选参数说明 + +| 参数 | 描述 | +| --------------------------------------- | ----------------- | +| COMPRESS_LEVEL_NO_COMPRESSION : 0 | 压缩率为0压缩等级 | +| COMPRESS_LEVEL_BEST_SPEED : 1 | 最佳速度压缩等级 | +| COMPRESS_LEVEL_BEST_COMPRESSION :9 | 最佳压缩等级 | +| COMPRESS_LEVEL_DEFAULT_COMPRESSION :-1 | 默认压缩等级 | + +## zip.CompressStrategy压缩策略可选参数说明 + +| 参数 | 描述 | +| -------------------------------------- | ------------------------ | +| COMPRESS_STRATEGY_DEFAULT_STRATEGY : 0 | 常规数据策略 | +| COMPRESS_STRATEGY_FILTERED : 1 | 过滤器产生的数据压缩策略 | +| COMPRESS_STRATEGY_HUFFMAN_ONLY : 2 | 霍夫曼编码格式压缩策略 | +| OMPRESS_STRATEGY_RLE : 3 | 游标编码压缩策略 | +| COMPRESS_STRATEGY_FIXED : 4 | 固定的压缩策略 | + +## zip.ErrorCode接口返回值参数说明 + +| 参数 | 描述 | +| -------------------- | ------------ | +| ERROR_CODE_OK: 0 | 函数调用成功 | +| ERROR_CODE_ERRNO:- 1 | 函数调用失败 | diff --git a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md index 8380ca334b2b5c5925486f1215ea1a3447335480..5053eff042adcc7395f1025b845e834cdec232e9 100644 --- a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md @@ -58,6 +58,7 @@ - [toolbar](js-components-basic-toolbar.md) - [toolbar-item](js-components-basic-toolbar-item.md) - [toggle](js-components-basic-toggle.md) + - [web](js-components-basic-web.md) - 媒体组件 - [video](js-components-media-video.md) - 画布组件 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-web.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-web.md index 83fb9c4f41ad13b7d05341b8016c4426fba481fa..c7f4bd776a2011ab8cdec8bc3bb5805e2423bad1 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-web.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-web.md @@ -21,7 +21,7 @@ web组件不跟随转场动画。一个页面仅支持一个web组件。 ## 样式 -仅支持通用样式中的width8+、height8+、padding8+、margin8+、border8+。 +不支持通用样式设置。 ## 事件 仅支持如下事件: diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md index 15900d8ce4f02e1bb4d93b39c51a75e52efc6749..bbf7ca807f64b5a8206a8f865dd8dcdda7bf6b06 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md @@ -48,8 +48,10 @@ PageA跳转到PageB,跳转的共享元素为image, shareid为“shareImage
- - Click on picture to Jump to ths details +
+ + Click on picture to Jump to ths details +
diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index 2c6b3e436ee4cde424ae5fbc36928d9b14d8c87f..40ec43688ceed4f1a2271e6f40b97bba6085eaca 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -48,7 +48,6 @@ - [SwipeGesture](ts-basic-gestures-swipegesture.md) - [组合手势](ts-combined-gestures.md) - 基础组件 - - [Web](ts-basic-components-web.md) - [Blank](ts-basic-components-blank.md) - [Button](ts-basic-components-button.md) - [Checkbox](ts-basic-components-checkbox.md) @@ -58,21 +57,22 @@ - [Divider](ts-basic-components-divider.md) - [Image](ts-basic-components-image.md) - [ImageAnimator](ts-basic-components-imageanimator.md) + - [LoadingProgress](ts-basic-components-loadingprogress.md) - [Progress](ts-basic-components-progress.md) - [QRCode](ts-basic-components-qrcode.md) - [Radio](ts-basic-components-radio.md) - [Rating](ts-basic-components-rating.md) - - [Span](ts-basic-components-span.md) + - [Select](ts-basic-components-select.md) - [Slider](ts-basic-components-slider.md) + - [Span](ts-basic-components-span.md) - [Text](ts-basic-components-text.md) - [TextArea](ts-basic-components-textarea.md) - [TextInput](ts-basic-components-textinput.md) - [TextPicker](ts-basic-components-textpicker.md) - [TextTimer](ts-basic-components-texttimer.md) - [Toggle](ts-basic-components-toggle.md) - - [Select](ts-basic-components-select.md) - [TextClock](ts-basic-components-textclock.md) - - [LoadingProgress](ts-basic-components-loadingprogress.md) + - [Web](ts-basic-components-web.md) - 容器组件 - [AlphabetIndexer](ts-container-alphabet-indexer.md) - [Badge](ts-container-badge.md) @@ -97,7 +97,6 @@ - [Swiper](ts-container-swiper.md) - [Tabs](ts-container-tabs.md) - [TabContent](ts-container-tabcontent.md) - - [SideBarContainer](ts-container-sidebarcontainer.md) - [Refresh](ts-container-refresh.md) - 媒体组件 - [Video](ts-media-components-video.md) @@ -138,5 +137,6 @@ - [自定义弹窗](ts-methods-custom-dialog-box.md) - [日期时间选择弹窗](ts-methods-datepicker-dialog.md) - [文本选择弹窗](ts-methods-textpicker-dialog.md) + - [菜单](ts-methods-menu.md) - 附录 - [文档中涉及到的内置枚举值](ts-appendix-enums.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md index 9f6fce6df8d37c59fb188599df1ad915917a0b06..b11da741ede1d037d42efc989116c3e6140ade49 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md @@ -42,7 +42,7 @@ Checkbox( name?: string, group?: string ) ## 示例 ``` -@Entry‘ +@Entry @Component struct CheckboxExample { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md index c56463a8002aa53b14ff7837a2dc319ee9a27e69..da2780cc42bfe57694efc5b9e9679f5fdda58edf 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md @@ -53,17 +53,16 @@ RichText\(content:string\) @Entry @Component struct RichTextExample { - @State data: string = '

h1标题

-

h1斜体

-

h1下划线

-

h2标题

-

h3标题

-

p常规


-
-

字体大小35px,行高45px

-

- 这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字 - 这是一段文字

' + @State data: string = "

h1标题

" + + "

h1斜体

" + + "

h1下划线

" + + "

h2标题

" + + "

h3标题

" + + "

p常规


" + + "
" + + "

字体大小35px,行高45px

" + + "

" + + "

这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字

" build() { Flex({direction: FlexDirection.Column,alignItems: ItemAlign.Center, diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md index fc850b8b669cfdc6316f811b838465d6df2b6efb..ca29204c7a19c79ff353057ed7a45b3a7bbef05e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md @@ -33,7 +33,7 @@ Span(content: string) | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype枚举说明),
color?: Color
} | {
type: TextDecorationType.None
} | 设置文本装饰线样式及其颜色。 | +| decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype枚举说明),
color?: Color
} | {
type: TextDecorationType.None
color:Color.Black
} | 设置文本装饰线样式及其颜色。 | | textCase | [TextCase](ts-appendix-enums.md#textcase枚举说明) | Normal | 设置文本大小写。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md index 566d3b60124edd5c1f2dcf691892250d320746ca..3373cce20b1a2db2f17e43da873de94587523b68 100755 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -61,15 +61,32 @@ ohos.permission.READ_USER_STORAGE 通用事件仅支持onFocus。 -| 名称 | 功能描述 | -| ---------------------------------------- | ---------------------------------------- | +| 名称 | 功能描述 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | | onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisposition: string, mimetype: string, contentLength: number }) => void) |

下载开始时触发该回调。
url:Web引擎返回的下载URL。
userAgent:Web引擎返回的用户代理名称。
contentDisposition:Web引擎返回的响应头。
mimetype:Web引擎返回的mimetype信息。
contentLength:Web引擎返回的内容长度。

| -| onGeolocationHide(callback: () => void) |

调用onGeolocationShow时发出的地理位置权限请求被取消后触发该回调。

| +| onGeolocationHide(callback: () => void) |

调用onGeolocationShow时发出的地理位置权限请求被取消后触发该回调。

| | onGeolocationShow(callback: (event?: { origin: string, geolocation: JsGeolocation }) => void) |

应用尝试使用地理位置时触发该回调,并向用户请求权限。
origin:尝试获取地理位置的Web内容的来源。
geolocation:用于请求地理位置权限。

| -| onPageBegin(callback: (event?: { url: string }) => void) |

网页加载时触发该回调。
url:Web引擎返回的URL。

| -| onPageEnd(callback: (event?: { url: string }) => void) |

网页加载结束时触发该回调。
url:Web引擎返回的URL。

| +| onPageBegin(callback: (event?: { url: string }) => void) |

网页加载时触发该回调。
url:Web引擎返回的URL。

| +| onPageEnd(callback: (event?: { url: string }) => void) |

网页加载结束时触发该回调。
url:Web引擎返回的URL。

| | onProgressChange(callback: (event?: { newProgress: number }) => void) |

网页加载进度变化时触发该回调。
newProgress:加载进度,取值范围为0到100的整数。

| -| onTitleReceive(callback: (event?: { title: string }) => void) |

网页主页面标题更改时触发该回调。
title:标题内容。

| +| onTitleReceive(callback: (event?: { title: string }) => void) |

网页主页面标题更改时触发该回调。
title:标题内容。

| +| onErrorReceive(callback: (event?: { request: WebResourceRequest, error: WebResourceError }) => void) |

网页加载错误时触发该回调。
request:网页的请求信息。
error:网页的错误信息 。

| +| onHttpErrorReceive(callback: (event?: { request: WebResourceRequest, response: WebResourceResponse }) => void) |

网页加载出现网络错误时触发该回调。
request:网页的请求信息。
response:网页的响应信息

| +| onConsole(callback: (event?: { message: ConsoleMessage }) => boolean) |

向主应用报告JavaScript控制台消息时触发该回调。
message:触发的控制台信息。

| +| onAlert(callback: (event?: { url: string; message: string; result: JsResult }) => boolean) |

网页触发alert()告警弹窗时触发。
url:Web引擎返回的下载URL。
message:Web引擎返回的信息。
JsResult:Web引擎返回的弹窗确认或弹窗取消功能对象。

| +| onBeforeUnload(callback: (event?: { url: string; message: string; result: JsResult }) => boolean) |

网页重新加载或关闭时触发。
url:Web引擎返回的下载URL。
message:Web引擎返回的信息。
JsResult:Web引擎返回的弹窗确认或弹窗取消功能对象。

| +| onConfirm(callback: (event?: { url: string; message: string; result: JsResult }) => boolean) |

即将离开当前页面(刷新或关闭)时触发。
url:Web引擎返回的下载URL。
message:Web引擎返回的信息。
JsResult:Web引擎返回的弹窗确认或弹窗取消功能对象。

| + +### JsResult 对象说明 + +Web引擎返回的弹窗确认或弹窗取消功能对象。 + +- 接口 + + | 接口名称 | 功能描述 | + | --------------------- | ----------------- | + | handleCancel(): void |

取消弹窗。

| + | handleConfirm(): void |

确认弹窗。

| ### JsGeolocation 对象说明 @@ -77,10 +94,65 @@ ohos.permission.READ_USER_STORAGE - 接口 - | 接口名称 | 功能描述 | - | ---------------------------------------- | ---------------------------------------- | + | 接口名称 | 功能描述 | + | ------------------------------------------------------------ | ------------------------------------------------------------ | | invoke(origin: string, allow: boolean, retain: boolean): void |

通知系统用户是否批准该应用使用地理位置权限。
origin:尝试获取地理位置的Web内容的来源。
allow:用户是否批准该应用使用地理位置权限。true: 允许访问,false: 不允许访问。
retain:是否允许将地理位置权限状态保存到系统中。true: 允许,false: 不允许。

| +### WebResourceRequest对象说明 + +- 接口 + + | 接口名称 | 功能描述 | + | --------------------------------- | ------------------------------------ | + | getRequestUrl(): string | 获取请求的url信息。 | + | isRequestGesture(): boolean | 获取请求是否与手势关联。 | + | isMainFrame(): boolean | 获取请求是否时为了获取主窗口的信息。 | + | isRedirect(): boolean | 获取请求是否重定向。 | + | getRequestHeader(): Array
| 获取请求头信息。 | + +### WebResourceError对象说明 + +- 接口 + + | 接口名称 | 功能描述 | + | ---------------------- | ------------------------ | + | getErrorInfo(): string | 获取加载资源的错误信息。 | + | getErrorCode(): number | 获取加载资源的错误码。 | + +### WebResourceResponse对象说明 + +- 接口 + + | 接口名称 | 功能描述 | + | ---------------------------------- | ---------------------- | + | getResponseData(): string | 获取响应数据。 | + | getResponseEncoding(): string | 获取响应的编码。 | + | getResponseMimeType(): string | 获取响应的MIME类型。 | + | getResponseCode(): number | 获取响应的状态码。 | + | getReasonMessage(): string | 获取响应的状态码描述。 | + | getResponseHeader(): Array
| 获取响应头信息。 | + +### ConsoleMessage对象说明 + +- 接口 + + | 接口名称 | 功能描述 | + | ------------------------------- | ------------------------------ | + | getMessage(): string | 获取ConsoleMessage的日志信息。 | + | getSourceId(): string | 获取ConsoleMessage的源的Id。 | + | getLineNumber(): number | 获取ConsoleMessage的行数。 | + | getMessageLevel(): MessageLevel | 获取ConsoleMessage的信息级别。 | + +- MessageLevel枚举说明 + + | 名称 | 描述 | + | ----- | :--------- | + | Debug | 调试级别。 | + | Error | 错误级别。 | + | Info | 消息级别。 | + | Log | 日志级别。 | + | Warn | 警告级别。 | + ## WebController Web 组件的控制器。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md index 89205a74d14de964f9cbd475dfef7163e63b91fd..ebe9c8c1293e0b0f76fa8ce8077beba41df38597 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md @@ -29,7 +29,7 @@ LongPressGesture(options?: { fingers?: number, repeat?: boolean, duration?: numb | onActionEnd((event?: LongPressGestureEvent) => void) | LongPress手势识别成功,手指抬起后触发回调。 | | onActionCancel(event: () => void) | LongPress手势识别成功,接收到触摸取消事件触发回调。 | -- LongPressGestureEvent对象说明8+ +- LongPressGestureEvent8+对象说明 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | repeat | boolean | 事件是否为重复触发事件。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md index b2a9218cb63bcd350efc30d993ad0e2755d344bc..d6ef7f4010f2e86e385c86b05b66564ccd50b828 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md @@ -59,7 +59,7 @@ PanGestureOption(options?: { fingers?: number, direction?: PanDirection, distanc | onActionEnd(callback: (event?: PanGestureEvent) => void) | Pan手势识别成功,手指抬起后触发回调。 | | onActionCancel(callback: () => void) | Pan手势识别成功,接收到触摸取消事件触发回调。 | -- PanGestureEvent对象说明8+ +- PanGestureEvent8+对象说明 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | offsetX | number | 手势事件偏移量,单位为vp。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md index 95279db007e7b3ca92c62a04771ae1ee39978d9e..4d87009b040266175c255110a0e36dff25199492 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md @@ -29,7 +29,7 @@ PinchGesture(options?: { fingers?: number, distance?: number }) | onActionEnd((event?: PinchGestureEvent) => void) | Pinch手势识别成功,手指抬起后触发回调。 | | onActionCancel(event: () => void) | Pinch手势识别成功,接收到触摸取消事件触发回调。 | -- PinchGestureEvent对象说明8+ +- PinchGestureEvent8+对象说明 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | scale | number | 缩放比例,用于PinchGesture手势触发场景。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md index f9d55455044fa873cb1042ad6f32cecc75fc2dfb..5c2a2d1d7615ab495b6fe380530464f8496f4860 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md @@ -29,7 +29,7 @@ RotationGesture(options?: { fingers?: number, angle?: number }) | onActionEnd((event?: RotationGestureEvent) => void) | Rotation手势识别成功,手指抬起后触发回调。 | | onActionCancel(event: () => void) | Rotation手势识别成功,接收到触摸取消事件触发回调。 | -- RotationGestureEvent对象说明8+ +- RotationGestureEvent8+对象说明 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | angle | number | 旋转角度。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index 83b31626aa2cd63a86b4dbc2c71a8d1322b19c1c..c945aa1bf7e4d614c321eeeb0d996db9a57dd6c2 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -1577,7 +1577,7 @@ transform方法对应一个变换矩阵,想对一个图形进行变化的时 @Component struct Transform { private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: RenderingContext = new RenderingContext(this.settings) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -1926,9 +1926,9 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void .backgroundColor('#ffff00') .onReady(() =>{ var grad = this.context.createLinearGradient(50,0, 300,100) - this.grad.addColorStop(0.0, 'red') - this.grad.addColorStop(0.5, 'white') - this.grad.addColorStop(1.0, 'green') + grad.addColorStop(0.0, 'red') + grad.addColorStop(0.5, 'white') + grad.addColorStop(1.0, 'green') this.context.fillStyle = grad this.context.fillRect(0, 0, 500, 500) }) @@ -1974,9 +1974,9 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, .backgroundColor('#ffff00') .onReady(() =>{ var grad = this.context.createRadialGradient(200,200,50, 200,200,200) - this.grad.addColorStop(0.0, 'red') - this.grad.addColorStop(0.5, 'white') - this.grad.addColorStop(1.0, 'green') + grad.addColorStop(0.0, 'red') + grad.addColorStop(0.5, 'white') + grad.addColorStop(1.0, 'green') this.context.fillStyle = grad this.context.fillRect(0, 0, 500, 500) }) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md index 02fcaf26213ed0cd8a11549e95bd2b0a281e0634..d2568f09ba7fefe59c27753e4702f084b72b45c6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -38,6 +38,13 @@ Scroll(scroller?: Scroller) | Vertical | 仅支持竖直方向滚动。 | | None | 不可滚动。 | +## 事件 + +| 名称 | 功能描述 | +| -------- | -------- | +| onScroll(xOffset: number, yOffset: number) => void | 滚动事件回调, 返回滚动时水平、竖直方向偏移量。 | +| onScrollEdge(side: Edge) => void | 滚动到边缘事件回调。 | +| onScrollEnd() => void | 滚动停止事件回调。 | ## Scroller @@ -51,7 +58,7 @@ scroller: Scroller = new Scroller() ``` -### scroller.scrollTo +### scrollTo scrollTo(value: { xOffset: number | string, yOffset: number | string, animation?: { duration: number, curve: Curve } }): void @@ -67,7 +74,7 @@ scrollTo(value: { xOffset: number | string, yOffset: number | string, animation? | animation | {
duration: number,
curve: [Curve](ts-animatorproperty.md) \|
CubicBezier \|
SpringCurve
} | 否 | | 动画配置:
- duration: 滚动时长设置。
- curve: 滚动曲线设置。 | -### scroller.scrollEdge +### scrollEdge scrollEdge(value: Edge): void @@ -81,7 +88,7 @@ scrollEdge(value: Edge): void | value | Edge | 是 | - | 滚动到的边缘位置。 | -### scroller.scrollPage +### scrollPage scrollPage(value: { next: boolean, direction?: Axis }): void @@ -93,7 +100,7 @@ scrollPage(value: { next: boolean, direction?: Axis }): void | next | boolean | 是 | - | 是否向下翻页。true表示向下翻页,false表示向上翻页。 | -### scroller.currentOffset +### currentOffset scroller.currentOffset(): Object @@ -107,7 +114,7 @@ scroller.currentOffset(): Object | {
xOffset: number,
yOffset: number
} | xOffset: 水平滑动偏移;
yOffset: 竖直滑动偏移。 | -### scroller.scrollToIndex +### scrollToIndex scroller.scrollToIndex(value: number): void @@ -125,15 +132,6 @@ scroller.scrollToIndex(value: number): void | value | number | 是 | - | 要滑动到的列表项在列表中的索引值。 | -## 事件 - -| 名称 | 功能描述 | -| -------- | -------- | -| onScroll(xOffset: number, yOffset: number) => void | 滚动事件回调, 返回滚动时水平、竖直方向偏移量。 | -| onScrollEdge(side: Edge) => void | 滚动到边缘事件回调。 | -| onScrollEnd() => void | 滚动停止事件回调。 | - - ## 示例 ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md b/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md index ea36bb58f044a95072acd1d68d8a2c2ed769111f..fe0e8e92dbbcb024fe7400043d7385fa6b7c2fb7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md @@ -25,7 +25,7 @@ Video(value: VideoOption) | controller | [VideoController](#videocontroller) | 否 | - | 控制器。 | -- PlaybackSpeed类型接口说明8+ +- PlaybackSpeed8+类型接口说明 | 名称 | 描述 | | -------- | -------- | | Speed_Forward_0_75_X | 0.75倍速播放。 | @@ -73,7 +73,7 @@ Video(value: VideoOption) | setCurrentTime(value: number) | 指定视频播放的进度位置。 | | setCurrentTime(value: number, seekMode: SeekMode | 指定视频播放的进度位置,并指定跳转模式。 | -- SeekMode类型接口说明8+ +- SeekMode8+类型接口说明 | 名称 | 描述 | | -------- | -------- | | PreviousKeyframe | 跳转到前一个最近的关键帧。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index 0978b45c9e6211d7417c109d4c3b27865e3d3053..494d326a3bc512c27531570b5d8ce02ab716ded5 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -37,21 +37,23 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, aut | BottomEnd8+ | 右下对齐。 | -### CustomDialogController +## CustomDialogController -创建对象 +### 导入对象 ``` dialogController : CustomDialogController = new CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, autoCancel?: boolean}) ``` -open() +### open() +open(): void 显示自定义弹窗内容,若已显示,则不生效。 -close() +### close +close(): void 关闭显示的自定义弹窗,若已关闭,则不生效。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md new file mode 100644 index 0000000000000000000000000000000000000000..df97249f6d38576b79f604df4aab7d277c7118f9 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md @@ -0,0 +1,39 @@ +# 菜单 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从 API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +## ContextMenu.close + +close(): void + +可以通过该方法在页面范围内关闭通过[bindContextMenu](./ts-universal-attributes-menu.md#属性)给组件绑定的菜单。 + +- 示例 + ``` + @Entry + @Component + struct Index { + @Builder MenuBuilder(){ + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('close') + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + ContextMenu.close(); + }) + }.height(400) + .backgroundColor(Color.Pink) + + } + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) { + Column(){ + Text("Text") + }.bindContextMenu(this.MenuBuilder, ResponseType.LongPress) + } + .width('100%') + .height('100%') + } + } + ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index 95d3ab05e222f3675b0412969ccab5be988b5352..7a2decde903a27a4cea908c2a7a75c5d5c6b1239 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -2037,9 +2037,9 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void .backgroundColor('#ffff00') .onReady(() =>{ var grad = this.offContext.createLinearGradient(50,0, 300,100) - this.grad.addColorStop(0.0, 'red') - this.grad.addColorStop(0.5, 'white') - this.grad.addColorStop(1.0, 'green') + grad.addColorStop(0.0, 'red') + grad.addColorStop(0.5, 'white') + grad.addColorStop(1.0, 'green') this.offContext.fillStyle = grad this.offContext.fillRect(0, 0, 500, 500) var image = this.offContext.transferToImageBitmap() @@ -2088,9 +2088,9 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, .backgroundColor('#ffff00') .onReady(() =>{ var grad = this.offContext.createRadialGradient(200,200,50, 200,200,200) - this.grad.addColorStop(0.0, 'red') - this.grad.addColorStop(0.5, 'white') - this.grad.addColorStop(1.0, 'green') + grad.addColorStop(0.0, 'red') + grad.addColorStop(0.5, 'white') + grad.addColorStop(1.0, 'green') this.offContext.fillStyle = grad this.offContext.fillRect(0, 0, 500, 500) var image = this.offContext.transferToImageBitmap() diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md index 334636f603d2bd67f3b0f7a4e9488b85e4798232..8dfcbfc08201b7f2a9550f457d7754f9004db715 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md @@ -14,12 +14,12 @@ | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| linearGradient | {
angle?: [Angle](../../ui/ts-types.md#角度类型),
direction?: GradientDirection,
colors: Array<[ColorStop](../../ui/ts-types.md#角度类型/ts-types.md#colorstop类型)>
repeating?: boolean
} | - | 线性渐变。
angle: 线性渐变的角度。
direction: 线性渐变的方向。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | -| sweepGradient | {
center: Point,
start?: angle,
end?: angle,
colors: Array<[ColorStop](../../ui/ts-types.md#colorstop类型)>
repeating?: boolean
} | - | 角度渐变。
center:为角度渐变的中心点。
start:角度渐变的起点。
end:角度渐变的终点。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | -| radialGradient | {
center: Point,
radius: Length,
colors: Array<[ColorStop](../../ui//ts-types.md#colorstop类型)>
repeating: boolean
} | - | 径向渐变。
center:径向渐变的中心点。
radius:径向渐变的半径。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | +| linearGradient | {
angle?: [Angle](../../ui/ts-types.md),
direction?: GradientDirection,
colors: Array<[ColorStop](../../ui/ts-types.md)>
repeating?: boolean
} | - | 线性渐变。
angle: 线性渐变的角度。
direction: 线性渐变的方向。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | +| sweepGradient | {
center: Point,
start?: angle,
end?: angle,
colors: Array<[ColorStop](../../ui/ts-types.md)>
repeating?: boolean
} | - | 角度渐变。
center:为角度渐变的中心点。
start:角度渐变的起点。
end:角度渐变的终点。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | +| radialGradient | {
center: Point,
radius: Length,
colors: Array<[ColorStop](../../ui/ts-types.md)>
repeating: boolean
} | - | 径向渐变。
center:径向渐变的中心点。
radius:径向渐变的半径。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | -- GradientDirection枚举说明 +- GradientDirection枚举说明
GradientDirection用于描述渐变方向。 | 名称 | 描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md index 49015456c8dd875aa1409dd3476878543a24c0fa..0d065df39fc5115b89a7a13d99844540251f7b29 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md @@ -34,7 +34,7 @@ @Component struct ImageEffectsExample { build() { - Column({space:10}) { + Column({space: 10}) { // 对字体进行模糊 Text('font blur').fontSize(15).fontColor(0xCCCCCC).width('90%') Text('text').blur(3).width('90%').height(40) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index ac768804a52d97e332ec964f02b190425ac5e609..71c1273bb276dca02d9708a0bbd85601c98f1a31 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -14,18 +14,26 @@ | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| bindMenu | Array8+ | - | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 | +| bindMenu | Array8+ | - | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 | +| bindContextMenu8+ | content: [CustomBuilder](../../ui/ts-types.md)
responseType: ResponseType | - | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 | - MenuItem - | 名称 | 类型 | 描述 | + | 名称 | 类型 | 描述 | | -------- | -------- | -------- | - | value | string | 菜单项文本。 | - | action | () => void | 点击菜单项的事件回调。 | + | value | string | 菜单项文本。 | + | action | () => void | 点击菜单项的事件回调。 | +- ResponseType8+ + | 参数值 | 描述 | + | -------- | -------- | + | LongPress | 通过长按触发菜单弹出。 | + | RightClick | 通过鼠标右键触发菜单弹出。 | ## 示例 +#### 普通菜单 + ``` @Entry @Component @@ -56,6 +64,8 @@ struct MenuExample { ![zh-cn_image_0000001174582862](figures/zh-cn_image_0000001174582862.gif) +#### 自定义内容菜单 + ``` import router from '@system.router'; @@ -103,3 +113,36 @@ struct MenuExample { ``` ![zh-cn_image_0000001186807708](figures/zh-cn_image_0000001186807708.gif) + +#### 菜单(右键触发显示) + +``` +@Entry +@Component +struct ContextMenuExample { + @Builder MenuBuilder() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text('Test menu item 1') + .fontSize(20) + .width(100) + .height(50) + .textAlign(TextAlign.Center) + Divider().height(10) + Text('Test menu item 2') + .fontSize(20) + .width(100) + .height(50) + .textAlign(TextAlign.Center) + }.width(100) + } + + build() { + Column() { + Text('rightclick for menu') + } + .width('100%') + .margin({ top: 5 }) + .bindContextMenu(this.MenuBuilder, ResponseType.RightClick) + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index 1f10a1a0a9ea896ce8e727159f47343430682981..ad1873ea00073974a129ca8d303813ba42b46c90 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -26,7 +26,7 @@ | secondaryButton | {
value: string,
action: () => void
} | 否 | - | 第二个按钮。
value: 弹窗里辅助按钮的文本。
action: 点击辅助按钮的回调函数。 | | onStateChange | (isVisible: boolean) => void | 否 | - | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 | -- CustomPopupOption类型接口说明8+ +- CustomPopupOption8+类型接口说明 | 名称 | 类型 | 必填 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -------- | | builder | () => any | 是 | - | 提示气泡内容的构造器。 | @@ -37,7 +37,7 @@ | autoCancel | boolean | 否 | true | 页面有操作时,是否自动关闭气泡 | | onStateChange | (isVisible: boolean) => void | 否 | - | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 | -- Placement枚举说明8+ +- Placement8+枚举说明 | 名称 | 描述 | | -------- | -------- | | Left | 气泡提示位于组件左侧。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md index 0e09e523c0a5ca7d64bfe788774b747e1fc5291d..cb6e258fb771a93e1ea13c04f5f70c55ae477ac7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md @@ -19,7 +19,7 @@ | size | {
width?: Length,
height?: Length
} | - | 设置高宽尺寸。 | | padding | {
top?: Length,
right?: Length,
bottom?: Length,
left?: Length
} \| Length | 0 | 设置内边距属性。
参数为Length类型时,四个方向内边距同时生效。 | | margin | {
top?: Length,
right?: Length,
bottom?: Length,
left?: Length
}
\| Length | 0 | 设置外边距属性。
参数为Length类型时,四个方向外边距同时生效。 | -| constraintSize | {
minWidth?: Length,
maxWidth?: Length,
minHeight?: Length,
maxHeight?: Lenght
} | {
minWidth: 0,
maxWidth: Infinity,
minHeight: 0,
maxHeight: Infinity
} | 设置约束尺寸,组件布局时,进行尺寸范围限制。 | +| constraintSize | {
minWidth?: Length,
maxWidth?: Length,
minHeight?: Length,
maxHeight?: Length
} | {
minWidth: 0,
maxWidth: Infinity,
minHeight: 0,
maxHeight: Infinity
} | 设置约束尺寸,组件布局时,进行尺寸范围限制。 | | layoutWeight | number | 0 | 容器尺寸确定时,元素与兄弟节点主轴布局尺寸按照权重进行分配,忽略本身尺寸设置。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅在Row/Column/Flex布局中生效。 | @@ -29,7 +29,6 @@ @Entry @Component struct SizeExample { - @StateitemWidth : number = 0 @StateitemHeight : number = 0 build() { Column({ space: 10 }) { Text('margin and padding:').fontSize(12).fontColor(0xCCCCCC).width('90%') @@ -55,10 +54,8 @@ struct SizeExample { Text('no layoutWeight') .size({ width: '30%', height: 110 }).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) }.size({ width: '90%', height: 140 }).backgroundColor(0xAFEEEE) - List() { ListItem() { Image('/resources/rawfile/seaman.png') .alt('/resources/rawfile/seaman2.png') .objectFit(ImageFit.Fill) .padding('100vp') .margin('40vp') .opacity(0.5) .measure('image_1') // 获取id=image_1的Image组件尺寸信息 } .onMeasure((Array ruler) => { // 在布局之前回调,返回已测量的子组件尺寸信息 console.log(ruler[0].id, ruler[0].screenX, ruler[0].screenY, ruler[0].offsetX, ruler[0].offsetY, ruler[0].width, ruler[0].height) this.itemWidth = ruler[0].width this.itemHeight = ruler[0].height }) .width(this.itemWidth) .height(this.itemHeight) } }.width('100%').margin({ top: 5 }) - } -} + }} ``` ![zh-cn_image_0000001174264384](figures/zh-cn_image_0000001174264384.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md index a8259660569efac407d788477dbf4f8cfd5fcd3b..2af9b5be1fb516d1c58c40c7f4e949a6f9b0a6a7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md @@ -20,7 +20,7 @@ | responseRegion | Array<Rectangle> \| Rectangle | {
x:0,
y:0,
width:'100%',
height:'100%'
} | 设置一个或多个触摸热区,包括位置和大小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> -百分比是相对于组件本身来度量的。
> -x和y可以设置正负值百分比。当x设置为'100%'时表示热区往右偏移组件本身宽度大小,当x设置为'-100%'时表示热区往左偏移组件本身宽度大小。当y设置为'100%'时表示热区往下偏移组件本身高度大小,当y设置为'-100%'时表示热区往上偏移组件本身高度大小。
> -width和height只能设置正值百分比。width:'100%'表示热区宽度设置为该组件本身的宽度。比如组件本身宽度是100vp,那么'100%'表示热区宽度也为100vp。height:'100%'表示热区高度设置为该组件本身的高度。 | -- Rectangle对象说明 +### Rectangle对象说明 | 名称 | 类型 | 必填 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -------- | | x | Length | 否 | 0vp | 触摸点相对于组件本身左边沿的X坐标。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md index 25770999ace02b3124ce54b48045cfc416fca41c..c6a3fc890b0c27895a6d1e66cc9766df3124455e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -15,7 +15,7 @@ | -------- | -------- | -------- | | onClick(callback: (event?: ClickEvent) => void) | 否 | 点击动作触发该方法调用,event参数见ClickEvent介绍。 | -- ClickEvent对象说明 +### ClickEvent对象说明 | 属性名称 | 类型 | 描述 | | -------- | -------- | -------- | | screenX | number | 点击点相对于设备屏幕左边沿的X坐标。 | @@ -25,12 +25,12 @@ | target8+ | EventTarget | 被点击元素对象。 | | timestamp | number | 事件时间戳。 | -- EventTarget对象说明8+ +- EventTarget8+对象说明 | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | area | Area | 目标元素的区域信息。 | -- Area对象说明8+ +- Area8+对象说明 | 属性名称 | 类型 | 描述 | | -------- | -------- | -------- | | width | number | 目标元素的宽度,单位为vp。 | @@ -38,7 +38,7 @@ | pos | Position | 目标元素左上角相对父元素左上角的位置。 | | globalPos | Position | 目标元素左上角相对页面左上角的位置。 | -- Position对象说明8+ +- Position8+对象说明 | 属性名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | x | number | x轴坐标,单位为vp。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md index b8f35086cf464d11191a8604497f9f3bba51fd33..988437562c8fc9ac11f0fcfd3edc61a0fa5d5954 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md @@ -3,31 +3,31 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +## 事件 | 名称 | 支持冒泡 | 功能描述 | | -------- | -------- | -------- | -| onDragStart(callback: (event: DragEvent, extraParams?: string) =>  [CustomBuilder](../../ui/ts-types.md#custombuilder类型8+)) | 否 | 第一次拖拽此事件绑定的组件时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。
返回值:当前跟手效果所拖拽的对象,用于显示拖拽时的提示组件。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 长按150毫秒(ms)可触发拖拽事件。
> - 优先级:长按手势配置时间小于等于150毫秒(ms)时,长按手势优先触发,否则拖拽事件优先触发。 | +| onDragStart(callback: (event: DragEvent, extraParams?: string) =>  [CustomBuilder](../../ui/ts-types.md)) | 否 | 第一次拖拽此事件绑定的组件时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。
返回值:当前跟手效果所拖拽的对象,用于显示拖拽时的提示组件。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 长按150毫秒(ms)可触发拖拽事件。
> - 优先级:长按手势配置时间小于等于150毫秒(ms)时,长按手势优先触发,否则拖拽事件优先触发。 | | onDragEnter(callback: (event: DragEvent, extraParams?: string) => void) | 否 | 拖拽进入组件范围内时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 当监听了onDrop事件时,此事件才有效。 | | onDragMove(callback: (event: DragEvent, extraParams?: string) => void) | 否 | 拖拽在组件范围内移动时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 当监听了onDrop事件时,此事件才有效。 | | onDragLeave(callback: (event: DragEvent, extraParams?: string) => void) | 否 | 拖拽离开组件范围内时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 当监听了onDrop事件时,此事件才有效。 | | onDrop(callback: (event: DragEvent, extraParams?: string) => void) | 否 | 绑定此事件的组件可作为拖拽释放目标,当在本组件范围内停止拖拽行为时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。 | - -- DragEvent对象说明 - | 名称 | 返回值类型 | 功能描述 | - | -------- | -------- | -------- | - | getX() | number | 当前拖拽点x轴坐标,单位为vp。 | - | getY() | number | 当前拖拽点y轴坐标,单位为vp。 | - -- extraParam说明 +- extraParam说明
用于返回组件在拖拽中需要用到的额外信息。 - extraParam是Json对象转换的string字符串,可以通过Json.parse转换的Json对象获取如下属性。 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | selectedIndex | number | 当拖拽事件设在父容器的子元素时,selectedIndex表示当前被拖拽子元素是父容器第selectedIndex个子元素,selectedIndex从0开始。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅在ListItem组件中生效。 | | insertIndex | number | 当前拖拽元素在List组件中放下时,insertIndex表示被拖拽元素插入该组件的第insertIndex个位置,insertIndex从0开始。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅在List组件的拖拽事件中生效。 | +### DragEvent对象说明 +- 接口 + | 名称 | 返回值类型 | 功能描述 | + | -------- | -------- | -------- | + | getX() | number | 当前拖拽点x轴坐标,单位为vp。 | + | getY() | number | 当前拖拽点y轴坐标,单位为vp。 | + ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md index 63f31446e6c55b67754e7a0de693abc22ad15ae3..6c310bc063b24a73dc1d8fae1f6d596b2a1ae049 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md @@ -16,7 +16,7 @@ | onKeyEvent(event: (event?: KeyEvent) => void) | 是 | 按键动作触发该方法调用,event参数见[KeyEvent](#keyevent对象说明)介绍。 | -## KeyEvent对象说明 +### KeyEvent对象说明 - 属性 | 属性名称 | 类型 | 描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md index 2dd02c00eac219a07c2fa369635d6bac8731005a..ca49bfc099d772425df32ccf6d9eb05c77a99e0f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md @@ -16,7 +16,7 @@ | onTouch(callback: (event?: TouchEvent) => void) | 是 | 触摸动作触发该方法调用,event参数见[TouchEvent](#touchevent对象说明)介绍。 -## TouchEvent对象说明 +### TouchEvent对象说明 - 属性 | 属性名称 | 类型 | 描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md index 26d34ecc321f5e3b63371a5fea75efeb21416a5a..61fd6b4dd9ea40f60dd470fd4387f019fe943f2b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md @@ -17,7 +17,7 @@ | onMouse(callback: (event?: MouseEvent) => void) | 是 | 当前组件被鼠标按键点击时或者鼠标在组件上移动时,触发该回调,event参数包含触发事件时的时间戳、鼠标按键、动作、点击触点在整个屏幕上的坐标和点击触点相对于当前组件的坐标。 | -- MouseEvent对象说明 +### MouseEvent对象说明 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | timestamp | number | 触发事件时的时间戳。 | diff --git a/zh-cn/application-dev/reference/native-lib/third_party_libc/musl-peculiar-symbol.md b/zh-cn/application-dev/reference/native-lib/third_party_libc/musl-peculiar-symbol.md new file mode 100644 index 0000000000000000000000000000000000000000..87162b3ea96e169a9d031e8b4d6f9edf6dd94f8b --- /dev/null +++ b/zh-cn/application-dev/reference/native-lib/third_party_libc/musl-peculiar-symbol.md @@ -0,0 +1,309 @@ +**NDK中没有导出的符号列表** + +|符号类型|符号名|备注| +| --- | --- | --- | +|OBJECT|___environ|| +|OBJECT|__daylight|| +|OBJECT|__environ|| +|OBJECT|__hook_enable_hook_flag|| +|OBJECT|__libc_malloc_default_dispatch|| +|OBJECT|__musl_libc_globals|| +|OBJECT|__optpos|| +|OBJECT|__optreset|| +|OBJECT|__progname_full|| +|OBJECT|__signgam|| +|OBJECT|__timezone|| +|OBJECT|__tzname|| +|OBJECT|_dl_debug_addr|| +|OBJECT|_environ|| +|OBJECT|function_of_shared_lib|| +|OBJECT|h_errno|| +|OBJECT|ohos_malloc_hook_shared_liibrary|| +|OBJECT|program_invocation_name|| +|OBJECT|program_invocation_short_name|| +|FUNC|__adjtime64|| +|FUNC|__aio_suspend_time64|| +|FUNC|__clock_gettime64|| +|FUNC|__ctype_b_loc|| +|FUNC|__ctype_tolower_loc|| +|FUNC|__ctype_toupper_loc|| +|FUNC|__dls2b|| +|FUNC|__dls3|| +|FUNC|__fgetwc_unlocked|| +|FUNC|__flt_rounds|| +|FUNC|__fputwc_unlocked|| +|FUNC|__freadahead|| +|FUNC|__freadptr|| +|FUNC|__freadptrinc|| +|FUNC|__freelocale|| +|FUNC|__fstat_time64|| +|FUNC|__ftime64|| +|FUNC|__fxstat64|| +|FUNC|__fxstatat64|| +|FUNC|__getdelim|| +|FUNC|__isalnum_l|| +|FUNC|__isalpha_l|| +|FUNC|__isblank_l|| +|FUNC|__iscntrl_l|| +|FUNC|__isdigit_l|| +|FUNC|__isgraph_l|| +|FUNC|__islower_l|| +|FUNC|__isoc99_fscanf|| +|FUNC|__isoc99_fwscanf|| +|FUNC|__isoc99_scanf|| +|FUNC|__isoc99_sscanf|| +|FUNC|__isoc99_swscanf|| +|FUNC|__isoc99_vfscanf|| +|FUNC|__isoc99_vfwscanf|| +|FUNC|__isoc99_vscanf|| +|FUNC|__isoc99_vsscanf|| +|FUNC|__isoc99_vswscanf|| +|FUNC|__isoc99_vwscanf|| +|FUNC|__isoc99_wscanf|| +|FUNC|__isprint_l|| +|FUNC|__ispunct_l|| +|FUNC|__isspace_l|| +|FUNC|__isupper_l|| +|FUNC|__iswalnum_l|| +|FUNC|__iswalpha_l|| +|FUNC|__iswblank_l|| +|FUNC|__iswcntrl_l|| +|FUNC|__iswctype_l|| +|FUNC|__iswdigit_l|| +|FUNC|__iswgraph_l|| +|FUNC|__iswlower_l|| +|FUNC|__iswprint_l|| +|FUNC|__iswpunct_l|| +|FUNC|__iswspace_l|| +|FUNC|__iswupper_l|| +|FUNC|__iswxdigit_l|| +|FUNC|__isxdigit_l|| +|FUNC|__lgammal_r|| +|FUNC|__libc_free|| +|FUNC|__libc_malloc|| +|FUNC|__libc_start_main|| +|FUNC|__lstat_time64|| +|FUNC|__lxstat64|| +|FUNC|__mq_timedreceive_time64|| +|FUNC|__mq_timedsend_time64|| +|FUNC|__nanosleep_time64|| +|FUNC|__newlocale|| +|FUNC|__nl_langinfo|| +|FUNC|__nl_langinfo_l|| +|FUNC|__overflow|| +|FUNC|__posix_getopt|| +|FUNC|__pthread_cond_timedwait_time64|| +|FUNC|__pthread_gettid_np|| +|FUNC|__pthread_timedjoin_np_time64|| +|FUNC|__res_state|| +|FUNC|__setjmp|| +|FUNC|__sigsetjmp|| +|FUNC|__stat_time64|| +|FUNC|__stime64|| +|FUNC|__strcasecmp_l|| +|FUNC|__strcoll_l|| +|FUNC|__strerror_l|| +|FUNC|__strncasecmp_l|| +|FUNC|__strtod_l|| +|FUNC|__strtof_l|| +|FUNC|__strtoimax_internal|| +|FUNC|__strtol_internal|| +|FUNC|__strtold_l|| +|FUNC|__strtoll_internal|| +|FUNC|__strtoul_internal|| +|FUNC|__strtoull_internal|| +|FUNC|__strtoumax_internal|| +|FUNC|__strxfrm_l|| +|FUNC|__sysv_signal|| +|FUNC|__tolower_l|| +|FUNC|__toupper_l|| +|FUNC|__towctrans_l|| +|FUNC|__towlower_l|| +|FUNC|__towupper_l|| +|FUNC|__uflow|| +|FUNC|__uselocale|| +|FUNC|__utimensat_time64|| +|FUNC|__wait3_time64|| +|FUNC|__wcscoll_l|| +|FUNC|__wcsftime_l|| +|FUNC|__wcsxfrm_l|| +|FUNC|__wctrans_l|| +|FUNC|__wctype_l|| +|FUNC|__xmknod|| +|FUNC|__xmknodat|| +|FUNC|__xpg_basename|| +|FUNC|__xpg_strerror_r|| +|FUNC|__xstat64|| +|FUNC|_dl_debug_state|| +|FUNC|_dlstart|| +|FUNC|_fini|| +|FUNC|_init|| +|FUNC|_IO_feof_unlocked|| +|FUNC|_IO_ferror_unlocked|| +|FUNC|_IO_getc|| +|FUNC|_IO_getc_unlocked|| +|FUNC|_IO_putc|| +|FUNC|_IO_putc_unlocked|| +|FUNC|a64l|| +|FUNC|addmntent|| +|FUNC|adjtime|| +|FUNC|aio_cancel|| +|FUNC|aio_cancel64|| +|FUNC|aio_error|| +|FUNC|aio_error64|| +|FUNC|aio_fsync|| +|FUNC|aio_fsync64|| +|FUNC|aio_read|| +|FUNC|aio_read64|| +|FUNC|aio_return|| +|FUNC|aio_return64|| +|FUNC|aio_suspend|| +|FUNC|aio_suspend64|| +|FUNC|aio_write|| +|FUNC|aio_write64|| +|FUNC|bcmp|| +|FUNC|bind_textdomain_codeset|| +|FUNC|bindtextdomain|| +|FUNC|confstr|| +|FUNC|copy_file_range|| +|FUNC|crypt|| +|FUNC|crypt_r|| +|FUNC|cuserid|| +|FUNC|dcgettext|| +|FUNC|dcngettext|| +|FUNC|dgettext|| +|FUNC|dlinfo|| +|FUNC|dngettext|| +|FUNC|eaccess|| +|FUNC|ecvt|| +|FUNC|encrypt|| +|FUNC|endspent|| +|FUNC|endusershell|| +|FUNC|endutxent|| +|FUNC|ether_hostton|| +|FUNC|ether_line|| +|FUNC|ether_ntohost|| +|FUNC|euidaccess|| +|FUNC|exp10|| +|FUNC|exp10f|| +|FUNC|exp10l|| +|FUNC|explicit_bzero|| +|FUNC|fanotify_init|| +|FUNC|fanotify_mark|| +|FUNC|fcvt|| +|FUNC|fgetgrent|| +|FUNC|fgetpwent|| +|FUNC|fgetspent|| +|FUNC|fgetwc_unlocked|| +|FUNC|fgetws_unlocked|| +|FUNC|finish_install_ohos_malloc_hooks|| +|FUNC|fmtmsg|| +|FUNC|fopencookie|| +|FUNC|fputwc_unlocked|| +|FUNC|fputws_unlocked|| +|FUNC|gcvt|| +|FUNC|get_current_dir_name|| +|FUNC|getdate|| +|FUNC|getdents64|| +|FUNC|gethostid|| +|FUNC|getpass|| +|FUNC|getservbyname_r|| +|FUNC|getservbyport_r|| +|FUNC|getspent|| +|FUNC|getspnam|| +|FUNC|getspnam_r|| +|FUNC|gettext|| +|FUNC|getusershell|| +|FUNC|getutid|| +|FUNC|getutline|| +|FUNC|getutxent|| +|FUNC|getutxid|| +|FUNC|getutxline|| +|FUNC|getw|| +|FUNC|getwc_unlocked|| +|FUNC|getwchar_unlocked|| +|FUNC|glob64|| +|FUNC|globfree64|| +|FUNC|init_malloc_hook_shared_library|| +|FUNC|isastream|| +|FUNC|l64a|| +|FUNC|lchmod|| +|FUNC|lckpwdf|| +|FUNC|lio_listio|| +|FUNC|lio_listio64|| +|FUNC|load_malloc_hook_shared_library|| +|FUNC|log_print|| +|FUNC|membarrier|| +|FUNC|mq_close|| +|FUNC|mq_getattr|| +|FUNC|mq_notify|| +|FUNC|mq_open|| +|FUNC|mq_receive|| +|FUNC|mq_send|| +|FUNC|mq_setattr|| +|FUNC|mq_timedreceive|| +|FUNC|mq_timedsend|| +|FUNC|mq_unlink|| +|FUNC|name_to_handle_at|| +|FUNC|ngettext|| +|FUNC|ohos_malloc_hook_init_function|| +|FUNC|open_by_handle_at|| +|FUNC|pivot_root|| +|FUNC|posix_close|| +|FUNC|posix_spawn_file_actions_addchdir_np|| +|FUNC|posix_spawn_file_actions_addfchdir_np|| +|FUNC|pow10|| +|FUNC|pow10f|| +|FUNC|pow10l|| +|FUNC|pthread_cancel|| +|FUNC|pthread_getaffinity_np|| +|FUNC|pthread_getattr_default_np|| +|FUNC|pthread_getconcurrency|| +|FUNC|pthread_mutex_consistent|| +|FUNC|pthread_mutex_getprioceiling|| +|FUNC|pthread_mutex_setprioceiling|| +|FUNC|pthread_mutexattr_getrobust|| +|FUNC|pthread_mutexattr_setrobust|| +|FUNC|pthread_setaffinity_np|| +|FUNC|pthread_setattr_default_np|| +|FUNC|pthread_setcancelstate|| +|FUNC|pthread_setcanceltype|| +|FUNC|pthread_setconcurrency|| +|FUNC|pthread_testcancel|| +|FUNC|pthread_timedjoin_np|| +|FUNC|pthread_tryjoin_np|| +|FUNC|putgrent|| +|FUNC|putpwent|| +|FUNC|putspent|| +|FUNC|pututxline|| +|FUNC|putwc_unlocked|| +|FUNC|putwchar_unlocked|| +|FUNC|remap_file_pages|| +|FUNC|rindex|| +|FUNC|secure_getenv|| +|FUNC|setkey|| +|FUNC|setspent|| +|FUNC|setusershell|| +|FUNC|setutxent|| +|FUNC|shm_open|| +|FUNC|shm_unlink|| +|FUNC|sigandset|| +|FUNC|sigisemptyset|| +|FUNC|sigorset|| +|FUNC|sockatmark|| +|FUNC|stime|| +|FUNC|strfmon|| +|FUNC|strfmon_l|| +|FUNC|strverscmp|| +|FUNC|textdomain|| +|FUNC|ualarm|| +|FUNC|ulckpwdf|| +|FUNC|ulimit|| +|FUNC|updwtmp|| +|FUNC|updwtmpx|| +|FUNC|utmpxname|| +|FUNC|versionsort|| +|FUNC|versionsort64|| +|FUNC|vhangup|| +|FUNC|wordexp|| +|FUNC|wordfree|| \ No newline at end of file diff --git a/zh-cn/application-dev/reference/native-lib/third_party_libc/musl.md b/zh-cn/application-dev/reference/native-lib/third_party_libc/musl.md new file mode 100644 index 0000000000000000000000000000000000000000..be554fac5b2dd2b9c387c88cf8802bfd555b50dc --- /dev/null +++ b/zh-cn/application-dev/reference/native-lib/third_party_libc/musl.md @@ -0,0 +1,74 @@ +# Native API中支持的标准库 + + + +## 简介 + + + +**表1** HarmonyOS支持的标准库 + +| 名称 | 简介 | +| :-------- | :----------------------------------------------------------- | +| 标准C库 | [libc、libm、libdl](https://zh.cppreference.com/w/c/header)组合实现C11标准C库。 | +| 标准C++库 | [libc++](https://libcxx.llvm.org/) 是C++标准库的一种实现。 | +| OpenSL ES | [OpenSL ES](https://www.khronos.org/registry/OpenSL-ES/)是一个嵌入式跨平台的音频处理库。 | +| zlib | [Zlib](https://zlib.net/)是基于C/C++语言实现的一个通用的数据压缩库。 | + +## 标准C库 + + + +[libc、libm、libdl](https://zh.cppreference.com/w/c/header)组合实现C11标准C库。 + +libc:包含线程相关接口,以及大部分标准接口。 + +libm:数学库函数接口。 + +libdl:dlopen等动态链接器接口。 + +**版本** + +1.2.0 + +**支持的能力** + +C标准函数库是在C语言程序设计中,所有符合标准的头文件的集合,以及常用的函数库实现程序(如I/O输入输出和字符串控制)。 + +**musl** + +[NDK中没有导出的符号列表](musl-peculiar-symbol.md) + +## 标准C++库 + + + +[libc++](https://libcxx.llvm.org/)是C++标准库的一种实现。 + +**版本** + +10.0.1 + +**支持的能力** + +C++11、C++14标准已完全支持,C++17和C++20标准正在完善。 + +## OpenSL ES + + + +[OpenSL ES](https://www.khronos.org/registry/OpenSL-ES/)是一个嵌入式跨平台的音频处理库。 + + + +## zlib + + + +[Zlib](https://zlib.net/)是基于C/C++语言实现的一个通用的数据压缩库。 + + + + + + diff --git a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md index 48308666b73d34cef7f83c3438da881b89edadb2..52fdd30c2330f6e9787db6d3cd7aefa26e4bcbba 100644 --- a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md +++ b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md @@ -17,6 +17,7 @@ ## 示例 ``` +@Entry @Component struct CountDownTimerComponent { @State countDownFrom: number = 10 diff --git a/zh-cn/application-dev/windowmanager/Readme-CN.md b/zh-cn/application-dev/windowmanager/Readme-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..3fd9703535131da3414947cd088cc75418cf9f02 --- /dev/null +++ b/zh-cn/application-dev/windowmanager/Readme-CN.md @@ -0,0 +1,12 @@ +# 窗口管理 + +* 窗口 + * 窗口开发概述 + * 窗口开发指导 +* 显示设备 + * [屏幕属性开发概述](display-overview.md) + * [屏幕属性开发指导](display-guidelines.md) +* 屏幕截图 + * [屏幕截图开发概述](screenshot-overview.md) + * [屏幕截图开发指导](screenshot-guidelines.md) + diff --git a/zh-cn/application-dev/windowmanager/display-guidelines.md b/zh-cn/application-dev/windowmanager/display-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..5133771581ab75d1906bedc5fed4e8cbfba9ef4a --- /dev/null +++ b/zh-cn/application-dev/windowmanager/display-guidelines.md @@ -0,0 +1,25 @@ +# 屏幕属性开发指导 + +## 场景介绍 + +应用通过调用屏幕接口获取默认Display或者所有Display的属性。 + +## 接口说明 + +完整版的接口定义请参考API接口说明文件:[屏幕属性](../reference/apis/js-apis-display.md)。 + +### 开发步骤 + +通过`getDefaultDisplay(): Promise`来获取当前默认的`Display`对象,具体代码示例可参考: + +```js +import display from '@ohos.display' // 导入模块 + +let disp; // disp用来保存默认Display +display.getDefaultDisplay().then((disp) => { + console.log('display.getDefaultDisplay success, display :' + JSON.stringify(disp)); +}, (err) => { + console.log('display.getDefaultDisplay failed, error : ' + JSON.stringify(err)); +}) +``` + diff --git a/zh-cn/application-dev/windowmanager/display-overview.md b/zh-cn/application-dev/windowmanager/display-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..8c80828fc20c4e694ca92a6922e2afa906f7ec36 --- /dev/null +++ b/zh-cn/application-dev/windowmanager/display-overview.md @@ -0,0 +1,7 @@ +# 屏幕属性开发概述 + +屏幕具有显示应用窗口布局的能力,屏幕属性包括:屏幕id号、屏幕名称、屏幕启用标识、屏幕状态、屏幕刷新率、屏幕旋转角度、屏幕宽度、屏幕高度、屏幕像素密度、屏幕字体缩放因子和每英寸屏幕的确切物理像素值。 + +## 基本概念 + +`Display`:Display指的是对应用可见的屏幕,这是一种抽象的屏幕概念,与真实的物理屏幕不同,可作为窗口容器。 diff --git a/zh-cn/application-dev/windowmanager/screenshot-guidelines.md b/zh-cn/application-dev/windowmanager/screenshot-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..0ed1eb14ff3a0ba00e8b64d40f3f6645d9f5a15f --- /dev/null +++ b/zh-cn/application-dev/windowmanager/screenshot-guidelines.md @@ -0,0 +1,38 @@ +# 屏幕截图开发概述 + +## 场景介绍 + +指定显示设备进行特定参数的屏幕截图。 + +## 接口说明 + +完整版的接口定义请参考API接口说明文件:[屏幕截图](../reference/apis/js-apis-screenshot.md)。 + +## 开发步骤 + +通过接口`save(options?: ScreenshotOptions): Promise`进行屏幕截图。其中`options`为预定义的截屏参数,如果没有输入`options`,则使用默认截取整屏,具体代码示例可参考: + +```js +import screenshot from '@ohos.screenshot' // 导入模块 + +// 设置屏幕截图参数 +var ScreenshotOptions = { + "screenRect": { + "left": 200, + "top": 100, + "width": 200, + "height": 200}, + "imageSize": { + "width": 300, + "height": 300}, + "rotation": 0 +}; + +let image; // image用来保存屏幕截图 +screenshot.save(ScreenshotOptions).then((image) => { + console.log('screenshot.save success, screenshot image :' + JSON.stringify(image)); +}, (err) => { + console.log('screenshot.save failed, error : ' + JSON.stringify(err)); +}) +``` + diff --git a/zh-cn/application-dev/windowmanager/screenshot-overview.md b/zh-cn/application-dev/windowmanager/screenshot-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..f2faeb9256efa801a66f618b4c03acc3c568beab --- /dev/null +++ b/zh-cn/application-dev/windowmanager/screenshot-overview.md @@ -0,0 +1,7 @@ +# 屏幕截图开发指导 + +提供指定显示设备下特定参数的屏幕截图能力。 + +## 基本概念 + +`screenshot`:提供屏幕截图能力。 diff --git a/zh-cn/contribute/template/guide-template.md b/zh-cn/contribute/template/guide-template.md index 8305f34c38fb741f6202736171d7563d8d80f022..e01c26119b390ec888e910b55dbd9bbbf5475141 100644 --- a/zh-cn/contribute/template/guide-template.md +++ b/zh-cn/contribute/template/guide-template.md @@ -123,4 +123,13 @@ | 仅进行最后的业务调测,每个小任务的操作结果,在开发步骤执行完成后,及时验证操作结果。 | | | 明确开发成功标准。 | | +## 开发实例 +** *【写作要求】*** + +*提供完整的sample示例,同时简要描述示例原理和实现,并链接到源码仓。* + +针对xxx开发,有以下示例工程可供参考: + +- xxx(此处请提供源码超链接) +本示例xxxx。 diff --git a/zh-cn/contribute/template/js-template.md b/zh-cn/contribute/template/js-template.md index e4609e7873b633ec26bd033fb9e41ef45772f068..9fba9061f60e3d1cf7d1680307f7bad6c49a3db5 100644 --- a/zh-cn/contribute/template/js-template.md +++ b/zh-cn/contribute/template/js-template.md @@ -16,6 +16,8 @@ > > 0.6 - 文档标题为一级标题;namespace下的属性字段、function、class、interface、enum、type为二级标题;class下的属性、function为三级标题。 > +> **版本说明** +> > 0.7 - **对已有模块的新增接口标记起始版本:使用\标签,标记对应的版本号。** > 示例:API 6已有的模块,在API 7新增了一个属性字段,则在属性后加标记,即newAttribute7+。 > 如果新增了一个方法,则在方法标题后增加标记,即 sim.getSimIccId7+,interface、class、枚举等同理。 @@ -25,7 +27,24 @@ > > > 从API Version 7 开始废弃,建议使用[newMethod](#newMethod)替代。 > -> 0.9 - **权限和syscap**:与代码保持一致,下沉到各个方法、枚举、属性字段中。 +> 0.9 - **MR版本才能实现的空接口**,在接口的描述说明中,添加: +> 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 +> +> **权限、syscap、系统API** +> +> 0.10 - **权限**:与代码保持一致,下沉到各个方法、枚举、属性字段中。采用格式: +> (所有应用可申请)**需要权限:** ohos.permission.xxxx +> (仅系统应用可申请)**需要权限:** ohos.permission.xxxx,仅系统应用可用。 +> +> 0.11 - **syscap**: +> 每个function需要进行描述:**系统能力**:SystemCapability.xxx.xxx +> 每个表格(属性、枚举、常量、变量)可统一进行说明,分两种情况: +> 每个表格下系统能力无差异的: +> 以下各项对应的系统能力均为SystemCapability.xxx.xxx。 +> 有差异的: +> 以下各项对应的系统能力有所不同,详见下表。 +> +> 0.12 - **系统API**:系统API需要增加描述:此接口为系统接口,三方应用不支持调用。 > 下面进入具体每个API的写作。 *** @@ -78,11 +97,15 @@ import call from '@ohos.telephony.call'; > 4.3 - 对于可读属性:如果取值为有特殊含义的有限值,需要进行枚举。 > > 4.4 - 对于可写属性:如果仅支持固定字段,需要进行说明。 +> +> 4.5 - 如果各项系统能力有差异,描述改为:以下各项对应的系统能力有所不同,详见下表。然后在各项里进行描述。参考[枚举的说明](#枚举) + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.xxx.xxx。(必选) -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ---------------- | ----------------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| pluggedType | [BatteryPluggedType](#BatteryPluggedType) | 是 | 否 | 表示当前设备连接的充电器类型。
**系统能力**:SystemCapability.xxx.xxx(必选) | -| isBatteryPresent | boolean | 是 | 否 | 表示当前设备是否支持电池或者电池是否在位。
**系统能力**:SystemCapability.xxx.xxx(必选) | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------------- | ----------------------------------------- | ---- | ---- | ------------------------------------------ | +| pluggedType | [BatteryPluggedType](#BatteryPluggedType) | 是 | 否 | 表示当前设备连接的充电器类型。 | +| isBatteryPresent | boolean | 是 | 否 | 表示当前设备是否支持电池或者电池是否在位。 | ## 枚举 @@ -94,6 +117,8 @@ import call from '@ohos.telephony.call'; 在此处给出该枚举类型的简要描述。如:表示连接的充电器类型的枚举。 +**系统能力:** 以下各项对应的系统能力有所不同,详见下表。(必选) + | 名称 | 值 | 说明 | | ---- | ---- | ------------------------------------------------------------ | | NONE | 1 | 表示连接的充电器类型未知。
**系统能力**:SystemCapability.xxx.xxx(必选) | @@ -105,15 +130,11 @@ import call from '@ohos.telephony.call'; > 6.1 - 可选,如果没有可删除。如果有多个方法,请分多个二级内容描述,并使用“##”自行新建二级标题。 > > 6.2 - 二级标题名为方法名,采用导入类.方法名,如果是订阅方法,需要在方法名加上对应的订阅事件。 -> > 示例: sim.getSimIccId -> > 订阅方法:sim.on('exampleEvent') > > 6.3 - **方法具体调用形式**:和d.ts保持一致,需要包括参数类型、参数名、返回值类型。 -> > 示例:getNetworkState(slotId: number, callback: AsyncCallback\): void -> > 注意:尖括号<>可能会被识别为标签,导致界面显示失效,可增加一个\,以保证界面正常显示,如“\\<>”或使用转义字符\< \> 。 > > 6.4.1 - **方法描述**:对方法实现的功能进行描述,包括其使用的前提条件(*如:在xx方法调用后才能调用、需要确保网络已连接……*)、使用之后的影响(*如:调用该接口后再进行xx将不起效*)、**权限限制**、**系统能力**等。 @@ -165,7 +186,6 @@ import call from '@ohos.telephony.call'; > 7.2 - 二级标题名为class、interface的名称。 > > 7.3 - 如果该API中,既有属性,又有方法,需要先进行属性的写作,并使用“###”三级标题。 -> > 如果该API中,只有属性,那么不需要新建三级标题,直接使用表格陈列属性,具体示例参考[CustomType](#CustomType)。 类描述/interface描述。如果有使用限制,需要在这个地方说明。比方说,是否有前提条件,是否需要通过什么方法先构造一个实例。 @@ -181,11 +201,8 @@ import call from '@ohos.telephony.call'; > *写作说明* > > 7.4 - 标题名为方法名,使用三级标题,**没有前缀**。如果是订阅方法,需要在方法名加上对应的订阅事件。 -> > 示例: getSimIccId -> > 订阅方法:on('exampleEvent') -> > 其余要求请参考[方法](#方法)中的说明。 在此处给出方法的具体调用形式。说明请参考6.3。 @@ -225,8 +242,9 @@ import call from '@ohos.telephony.call'; ## CustomType 仅有k-v键值对的自定义类型示例。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.xxx.xxx。(必选) | 名称 | 类型 | 可读 | 可写 | 说明 | | ------------ | ------------------- | ---- | ---- | ------------------------------------------------------------ | -| parameterUrl | string | 是 | 是 | 媒体输出URI。支持:
1. 协议类型为“internal”的相对路径,示例如下:
临时目录:internal://cache/test.mp4

2. 文件的绝对路径,示例如下:
file:///data/data/ohos.xxx.xxx/files/test.mp4
**系统能力**:SystemCapability.xxx.xxx(必选) | -| parameterOne | [CustomEnum](#枚举) | 是 | 是 | 属性描述,要求与参数说明类似。
**系统能力**:SystemCapability.xxx.xxx(必选) | \ No newline at end of file +| parameterUrl | string | 是 | 是 | 媒体输出URI。支持:
1. 协议类型为“internal”的相对路径,示例如下:
临时目录:internal://cache/test.mp4

2. 文件的绝对路径,示例如下:
file:///data/data/ohos.xxx.xxx/files/test.mp4
| +| parameterOne | [CustomEnum](#枚举) | 是 | 是 | 属性描述,要求与参数说明类似。 | \ No newline at end of file diff --git a/zh-cn/device-dev/faqs/faqs-system-applications.md b/zh-cn/device-dev/faqs/faqs-system-applications.md index a78ff419666cd091e4c647a091f205d8ca65f41c..b8f34e907fbd1735e40ab63333e71bf4ad21c5e6 100644 --- a/zh-cn/device-dev/faqs/faqs-system-applications.md +++ b/zh-cn/device-dev/faqs/faqs-system-applications.md @@ -43,7 +43,7 @@ LiteOS-A内核\(Hi3516、Hi3518平台\)直接调用KV存储提供的接口,各 显示调用KV存储的UtilsSetEnv接口,设置数据存储路径。 ``` -UtilsSetEnv("/storage/com.huawei.kv"); +UtilsSetEnv("/storage/com.example.kv"); ``` ## 视觉应用常见问题 diff --git a/zh-cn/device-dev/get-code/gettools-acquire.md b/zh-cn/device-dev/get-code/gettools-acquire.md index 830c6001e9482c4a04bdc64629f5dbfbc95c2452..a20b03121461491c3b3418809273b93f7e25ff63 100644 --- a/zh-cn/device-dev/get-code/gettools-acquire.md +++ b/zh-cn/device-dev/get-code/gettools-acquire.md @@ -43,7 +43,7 @@ OpenHarmony为开发者提供了两种Docker环境,以帮助开发者快速完

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker

-

0.0.7

+

1.0.0

标准系统

@@ -52,7 +52,7 @@ OpenHarmony为开发者提供了两种Docker环境,以帮助开发者快速完

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard

-

0.0.8

+

1.0.0

HPM Docker环境

@@ -75,6 +75,7 @@ OpenHarmony为开发者提供了两种Docker环境,以帮助开发者快速完 + ## 环境准备 在使用docker环境前需要先完成以下操作: @@ -95,7 +96,7 @@ OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud 1. 获取Docker镜像。 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 @@ -103,13 +104,13 @@ OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud ubuntu下执行: ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` windows下执行(假设源码目录为D:\\OpenHarmony): ``` - docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` @@ -121,7 +122,6 @@ OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud ``` hb set - . ``` **图 1** 设置编译界面 @@ -150,13 +150,13 @@ hb set 1. 获取Docker镜像。 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/zh-cn/device-dev/kernel/Readme-CN.md b/zh-cn/device-dev/kernel/Readme-CN.md index 69a2a9ca7c64c75bcff96f63590bc4662480bd38..66f6c859f7d474fa1b393f9019ab0d6c75dde107 100755 --- a/zh-cn/device-dev/kernel/Readme-CN.md +++ b/zh-cn/device-dev/kernel/Readme-CN.md @@ -178,3 +178,6 @@ - [Linux内核概述](kernel-standard-overview.md) - [开发板Patch使用指导](kernel-standard-patch.md) - [Linux内核编译与构建指导](kernel-standard-build.md) + - [内核增强特性](kernel-standard-enhanced-features.md) + - [内存管理](kernel-standard-mm.md) + - [Enhanced SWAP特性介绍](kernel-standard-mm-eswap.md) diff --git a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md index 0d9f9fe060ec3149a2fa5f8e5776bfcd3db29c68..0279282d1f36122a41222ab1973cf424594bddd6 100644 --- a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md +++ b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md @@ -52,7 +52,7 @@ uname [_-a | -s | -r | -m | -n | -v | --help_] ``` OHOS:/$ uname -a -Huawei LiteOS hisilicon 2.0.0.37 Huawei LiteOS 2.0.0.37 Oct 21 2021 17:39:32 Cortex-A7 +LiteOS hisilicon 2.0.0.37 Huawei LiteOS 2.0.0.37 Oct 21 2021 17:39:32 Cortex-A7 OHOS:/$ ``` @@ -60,6 +60,6 @@ OHOS:/$ ``` OHOS:/$ uname -ms -Huawei LiteOS Cortex-A7 +LiteOS Cortex-A7 OHOS:/$ ``` diff --git a/zh-cn/device-dev/kernel/kernel-standard-enhanced-features.md b/zh-cn/device-dev/kernel/kernel-standard-enhanced-features.md new file mode 100644 index 0000000000000000000000000000000000000000..348cf8bd68185bea940b47160c780db8c0ac03d3 --- /dev/null +++ b/zh-cn/device-dev/kernel/kernel-standard-enhanced-features.md @@ -0,0 +1,3 @@ +# 内核增强特性 + +- **[内存管理](kernel-standard-mm.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/kernel/kernel-standard-mm-eswap.md b/zh-cn/device-dev/kernel/kernel-standard-mm-eswap.md new file mode 100644 index 0000000000000000000000000000000000000000..ef358a73ff013109d626c7f739e2a2b84698f027 --- /dev/null +++ b/zh-cn/device-dev/kernel/kernel-standard-mm-eswap.md @@ -0,0 +1,234 @@ +# Enhanced SWAP特性介绍 + + +## 基本概念 + +ESwap(Enhanced Swap)提供了自定义新增存储分区作为内存交换分区的能力,并创建了一个常驻进程zswapd将压缩后的匿名页加密换出到ESwap存储分区,从而能完全的空出一块可用内存,以此来达到维持Memavailable水线的目标。同时,配合这个回收机制,在整个内存框架上进行改进,优化匿名页和文件页的回收效率,并且使两者的回收比例更加合理以避免过度回收导致的refault问题造成卡顿现象。 + + +## ZRAM与ESwap配置指导 + +### 使能ESwap +1. 打开相关配置项及依赖 + + 启用ESwap,需要通过编译内核时打开相应的配置项及依赖,ESwap相关CONFIG如下: + + ``` + CONFIG_HYPERHOLD=y + CONFIG_HYPERHOLD_DEBUG=y + CONFIG_HYPERHOLD_ZSWAPD=y + CONFIG_HYPERHOLD_FILE_LRU=y + CONFIG_HYPERHOLD_MEMCG=y + CONFIG_ZRAM_GROUP=y + CONFIG_ZRAM_GROUP_DEBUG=y + CONFIG_ZLIST_DEBUG=y + CONFIG_ZRAM_GROUP_WRITEBACK=y + ``` + + 另有部分CONFIG被依赖: + + ``` + CONFIG_MEMCG=y + CONFIG_SWAP=y + CONFIG_ZSMALLOC=y + CONFIG_ZRAM=y + ``` + +2. 创建ESwap设备 + + 可以使用任意block设备作为ESwap交换设备,这里创建一个文件hpdisk挂载为loop6设备: + + ```Bash + // 通过dd命令创建一个文件hpdisk用于ESwap换出,具体大小需根据产品及需求调整,此处设置为512MB。 + dd if=/dev/random of=/data/hpdisk bs=4096 count=131072 + // 将上一步创建的hpdisk与ESwap device进行绑定。 + losetup /dev/block/loop6 hpdisk + ``` + +3. 配置ESwap + + 将2中创建的设备绑定为ESwap换出设备: + + ```Bash + echo /dev/block/loop6 > /proc/sys/kernel/hyperhold/device + ``` + + ESwap默认对换出数据使用软件加密,如果2中创建的ESwap设备支持inline加密,可以关闭ESwap的软件加密功能: + + ```Bash + // 需确认是否支持并开启硬加密,否则不要执行该操作。 + echo 0 > /proc/sys/kernel/hyperhold/soft_crypt + ``` + + > ![icon-caution.gif](public_sys-resources/icon-caution.gif) **注意:** + > 出于安全考虑,所有换出内容均需加密。因此若当前配置ESwap的设备不支持inline加密,或编译时未打开inline加密宏,则在关闭软加密时,ESwap无法enable。 + +4. 使能ESwap + + 使能ESwap,使能后无法更改上述配置: + + ```Bash + echo enable > /proc/sys/kernel/hyperhold/enable + ``` + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 使能ESwap需要在使能ZRAM之前,不需要使用ESwap时, 也可以仅使能ZRAM。如部分设备不包括用于换出的存储设备,也没有新建相应的存储分区,那么可以仅使能ZRAM来通过zswapd进行内存回收。 + +### 使能ZRAM + +1. 初始化ZRAM + + ```Bash + // 打开ZRAM到eswap的换入换出功能,该步骤必须要在配置ZRAM大小之前。 + echo readwrite > /sys/block/zram0/group + // 配置ZRAM的大小,具体大小需根据产品及需求调整,此处设置为512MB。 + echo 512M > /sys/block/zram0/disksize + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > /sys/block/zram0/group可接受参数及作用为: + > + > - none:表示disable; + > - readonly:表示只记录数据的cgroup信息,并不换出; + > - readwrite:表示打开ZRAM到eswap的换入换出功能。 + +2. 使能ZRAM + + ```Bash + mkswap /dev/block/zram0 + swapon /dev/block/zram0 + ``` + + +### 关闭ESwap与ZRAM + +1. 关闭ESwap + + ```Bash + echo disable > /proc/sys/kernel/hyperhold/enable + 或 + echo force_disable > /proc/sys/kernel/hyperhold/enable + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 两者的区别在于: + > + > - disable:表示如果ESwap中没有数据,则完全关闭,否则变为只读模式; + > - force_disable:表示如果没有数据,完全关闭,否则变为只读模式,并同步等待ESwap中数据完全读出,然后完全关闭。 + +2. 关闭ZRAM及ZRAM group + + ```Bash + echo 1 > /sys/block/zram0/reset + ``` + + +## ESwap相关接口 + +ESwap提供了一些接口用于控制换入换出策略以及记录当前状态,这些接口位于memcg所挂载的目录当中,如`/dev/memcg/`。 + +| 功能分类 | 接口名 | 描述 | +| -------- | -------- | -------- | +| 控制接口 | [avail_buffers](#avail_buffers) | 设置buffer区间 | +| | [zswapd_single_memcg_param](#zswapd_single_memcg_param) | 设置当前memcg相关配置 | +| | [zswapd_wm_ratio](#zswapd_wm_ratio) | 设置zram换出水线 | +| 状态接口 | [zswapd_pressure_show](#zswapd_pressure_show) | 记录当前buffer以及refault | +| | [stat](#stat) | 检测ESwap实时情况 | +| | [zswapd_vmstat_show](#zswapd_vmstat_show) | 记录zswapd运行过程中各种事件 | + +> ![icon-caution.gif](public_sys-resources/icon-caution.gif) **注意:** +> 除avail_buffers会因为调整了buffer水线而会主动去唤醒zswapd外,其余控制接口并不会主动唤醒zswapd,只是其配置需在zswapd所被唤醒后方可生效。 + +各接口的具体描述如下: + +### avail_buffers + +avail_buffers接口用于设置buffer区间[min_avail_buffers, high_avail_buffers],当检测到当前的buffer低于min_avail_buffers时则会唤醒zswapd进行匿名页回收,期望的回收量为high_avail_buffers与当前系统buffer值的差值,实际可能会因为无法回收等原因而未回收那么多内存。avail_buffers为期望的内存正常状态buffer值,free_swap_threshold则是设置交换分区空闲容量的阈值,当zswapd唤醒并进行内存回收之后,会根据当前系统情况以及两者的设置记录当前内存压力事件,如medium press,critical press等。可主动调整来触发zswapd回收,如`echo 1000 950 1050 0 > /dev/memcg/memory.avail_buffers`。 + +默认值: + +``` + avail_buffers: 0 + min_avail_buffers: 0 + high_avail_buffers: 0 + free_swap_threshold: 0 +``` + +限制: + +0<=min_avail_buffers<=avail_buffers<=high_avail_buffers + +0<=free_swap_threashold + +取值均为整型。 + +### zswapd_single_memcg_param + +设置当前memcg的相关配置。score为当前memcg回收优先级,ub_mem2zram_ratio为内存压缩到ZRAM的比率,ub_zram2ufs_ratio为ZRAM换出到ESwap的比率,refault_threshold为refault的阈值,可通过调整比率来控制ZRAM压缩以及ESwap换出情况,如`echo 60 10 50 > memory.zswapd_single_memcg_param`。 + +默认值: + +``` + memcg score: 300 + memcg ub_mem2zram_ratio: 60 + memcg ub_zram2ufs_ratio: 10 + memcg refault_threshold: 50 +``` + +限制: + +0<=ub_mem2zram_ratio<=100 + +0<=ub_zram2ufs_ratio<=100 + +0<=refault_threshold<=100 + +取值均为整型。 + +### zram_wm_ratio + +设置ZRAM换出水线,即当当前ZRAM中压缩的匿名页大于ZRAM总大小*zram_wm_ratio时,会开始向ESwap进行换出,但是具体换出时间为zswapd因buffer水线而唤醒之后。设置为0时系统默认为37,可进行调整,如`echo 30 > /dev/memcg/memory.zram_wm_ratio`。 + +默认值: + +``` + zram_wm_ratio: 0 +``` + +限制: + +0<=zram_wm_ratio<=100 + +取值为整型。 + +### zswapd_pressure_show + +记录当前zswapd所需相关状态,buffer_size为当前系统的buffer值,recent_refault为最近产生的refault次数。 + + +### stat + +在原有memcg.stat的基础上新增了Anon,File,zram,Eswap等项,用以监测ESwap的实时情况。 + + +### zswapd_vmstat_show + +记录zswapd运行过程中的各种事件。 + + +## 触发zswapd回收 + +可先通过`cat /dev/memcg/memory.zswapd_pressure_show`查看当前buffer值,比如当前为1200,那么便可通过主动调整buffer区间,来主动唤醒zswapd。 + +```Bash +echo 1300 1250 1350 0 > /dev/memcg/memory.avail_buffers +``` + + +## ESwap配置大小示例 + +ZRAM与ESwap的大小配置需根据实际使用场景以及产品硬件特点进行适配。目前在rk3568板子上使用时,其ram为2G,因此设置的ZRAM与ESwap大小均为512MB。 + + + diff --git a/zh-cn/device-dev/kernel/kernel-standard-mm.md b/zh-cn/device-dev/kernel/kernel-standard-mm.md new file mode 100644 index 0000000000000000000000000000000000000000..2c54cc79301396553a1573f6ffd75e2c9f2b65ea --- /dev/null +++ b/zh-cn/device-dev/kernel/kernel-standard-mm.md @@ -0,0 +1,3 @@ +# 内存管理 + +- **[Enhanced SWAP特性介绍](kernel-standard-mm-eswap.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/kernel/kernel-standard.md b/zh-cn/device-dev/kernel/kernel-standard.md index d642451274aac47aef7519c49b60bab328525730..73034025e7f08827766813caf81e604ae4cacf70 100644 --- a/zh-cn/device-dev/kernel/kernel-standard.md +++ b/zh-cn/device-dev/kernel/kernel-standard.md @@ -7,3 +7,5 @@ - **[Linux内核编译与构建指导](kernel-standard-build.md)** +- **[内核增强特性](kernel-standard-enhanced-features.md)** + diff --git a/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md b/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md index f2725ccc22379214adc7003b25463a1850aacc5d..b65533df179d3078518e6d089a5f662f5e93c75a 100644 --- a/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md +++ b/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md @@ -410,7 +410,6 @@ static int32_t FsDriverInit(struct HdfDeviceObject *object) fs[i].lfs_cfg.lookahead_size = 16; fs[i].lfs_cfg.block_cycles = 1000; - SetDefaultMountPath(i, fs[i].mount_point); int ret = mount(NULL, fs[i].mount_point, "littlefs", 0, &fs[i].lfs_cfg); HDF_LOGI("%s: mount fs on '%s' %s\n", __func__, fs[i].mount_point, (ret == 0) ? "succeed" : "failed"); } diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md b/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md index a81005a338f33cbf35f011222b3f78d7f5b70f6c..0618477f49c778435cc98ff6624cb93700ab74ae 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md @@ -24,11 +24,11 @@ OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud 1. 获取Docker镜像。 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md index 5bb3128a4361d1b41e3d5f2ed999f0514dcb5534..47f745e8c9cd4ae5ebeff637099c46d9e3914408 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md @@ -41,13 +41,13 @@ bash build/prebuilts_download.sh 1. 获取Docker镜像。 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. 进入源码根目录执行如下命令,从而进入Docker构建环境。 ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md index 781ce3a9e2b69b7928816c71108f37a46f37fae7..2b414676249d306a6f1717ca220822836f7f0d13 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md @@ -41,13 +41,13 @@ bash build/prebuilts_download.sh 1. 获取Docker镜像。 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:1.0.0 ``` 2. 进入源码根目录执行如下命令,从而进入Docker构建环境。 ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/zh-cn/device-dev/subsystems/subsys-utils-faqs.md b/zh-cn/device-dev/subsystems/subsys-utils-faqs.md index c991e43c15fe5dd550c7d42c9707d738c4b44673..c3f3e2da63e5426589b7ddafcb5d88921af19ade 100755 --- a/zh-cn/device-dev/subsystems/subsys-utils-faqs.md +++ b/zh-cn/device-dev/subsystems/subsys-utils-faqs.md @@ -17,6 +17,6 @@ LiteOS-A内核\(Hi3516、Hi3518平台\)直接调用KV存储提供的接口,各 显示调用KV存储的UtilsSetEnv接口,设置数据存储路径。 ``` -UtilsSetEnv("/storage/com.huawei.kv"); +UtilsSetEnv("/storage/com.example.kv"); ``` diff --git a/zh-cn/device-dev/subsystems/subsys-utils-guide.md b/zh-cn/device-dev/subsystems/subsys-utils-guide.md index 98866eec08eed9f7693172402a20e0ae81e6e557..0986cbb6a11294806309e5143b68013f5369949e 100644 --- a/zh-cn/device-dev/subsystems/subsys-utils-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-utils-guide.md @@ -177,8 +177,8 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); ``` { "app": { - "bundleName": "com.huawei.launcher", - "vendor": "huawei", + "bundleName": "com.example.launcher", + "vendor": "example", "version": { "code": 1, "name": "1.0" @@ -201,7 +201,7 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); } }, "module": { - "package": "com.huawei.launcher", + "package": "com.example.launcher", "name": ".MyHarmonyAbilityPackage", "deviceType": [ "phone", "tv","tablet", "pc","car","smartWatch","sportsWatch","smartCamera" @@ -254,7 +254,7 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); 3. 通过串口向单板发送运行KV存储native应用的命令。 ``` - ./nfs/dev_tools/bin/aa start -p com.huawei.launcher -n ServiceAbility + ./nfs/dev_tools/bin/aa start -p com.example.launcher -n ServiceAbility ``` diff --git "a/zh-cn/readme/\345\205\250\347\220\203\345\214\226\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\345\205\250\347\220\203\345\214\226\345\255\220\347\263\273\347\273\237.md" index 19c3e0812df2b200c59dc8b656fb941a7bd20214..539168f4a3c7fe8180617c541aa98e76ea8f097e 100755 --- "a/zh-cn/readme/\345\205\250\347\220\203\345\214\226\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\345\205\250\347\220\203\345\214\226\345\255\220\347\263\273\347\273\237.md" @@ -50,13 +50,6 @@ │ │ │ └── src # 实现代码 │ ├── interfaces # 资源管理框架接口 │ │ └── innerkits # 资源管理框架对子系统间接口 -├── cust_lite # 定制框架代码仓 -│ ├── frameworks # 定制框架核心代码 -│ │ ├── cust_lite # 定制框架模块 -│ │ │ ├── src # 实现代码 -│ │ │ └── test # 测试代码 -│ ├── interfaces # 定制框架接口 -│ │ └── innerkits # 定制框架子系统间接口 ``` 标准系统的目录结构如下所示: @@ -83,8 +76,6 @@ **全球化子系统** -global\_cust\_lite - global\_i18n\_lite global\_i18n\_standard diff --git "a/zh-cn/readme/\347\252\227\345\217\243\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\347\252\227\345\217\243\345\255\220\347\263\273\347\273\237.md" index 77182df54102070b645f388d8e247732f8fb169a..7813ab5c8c166a9fa7523cca05815b2b8bc89d52 100644 --- "a/zh-cn/readme/\347\252\227\345\217\243\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\347\252\227\345\217\243\345\255\220\347\263\273\347\273\237.md" @@ -1,4 +1,4 @@ -# windowmanager +# 窗口子系统 - [简介](#简介) - [目录](#目录) @@ -8,15 +8,14 @@ ## 简介 -**窗口子系统** 提供窗口管理和Display管理的基础能力,是系统图形界面显示所需的基础子系统 - -其主要的结构如下图所示: +**窗口子系统** 提供窗口管理和Display管理的基础能力,是系统图形界面显示所需的基础子系统。其主要的结构如图1所示。 +**图 1** 窗口子系统架构图 ![窗口子系统架构图](./figures/WindowManager.png) - **Window Manager Client** - 应用进程窗口管理接口层,提供窗口对对象抽象和窗口管理接口,对接原能力和UI框架。 + 应用进程窗口管理接口层,提供窗口对象抽象和窗口管理接口,对接元能力和UI框架。 - **Display Manager Client** @@ -24,17 +23,17 @@ - **Window Manager Server** - 窗口管理服务,提供窗口布局、Z序控制、窗口树结构、窗口拖拽、窗口快照等能力,并提供窗口布局和焦点窗口给多模输入 + 窗口管理服务,提供窗口布局、Z序控制、窗口树结构、窗口拖拽、窗口快照等能力,并提供窗口布局和焦点窗口给多模输入。 - **Display Manager Server** - Display管理服务,提供Display信息、屏幕截图、屏幕亮灭和亮度处理控制,并处理Display与Screen映射关系 + Display管理服务,提供Display信息、屏幕截图、屏幕亮灭和亮度处理控制,并处理Display与Screen映射关系。 ## 目录 ``` foundation/windowmanager/ ├── dm # Dislplay Manager Client实现代码 -├── dmserver # Dislplay Manager Service实现代码 +├── dmserver # Dislplay Manager Server实现代码 ├── interfaces # 对外接口存放目录 │   ├── innerkits # native接口存放目录 │   └── kits # js/napi接口存放目录 @@ -43,7 +42,7 @@ foundation/windowmanager/ ├── snapshot # 截屏命令行工具实现代码 ├── utils # 工具类存放目录 ├── wm # Window Manager Client实现代码 -├── wmserver # Window Manager Service实现代码 +├── wmserver # Window Manager Server实现代码 ``` ## 约束 diff --git a/zh-cn/release-notes/Readme.md b/zh-cn/release-notes/Readme.md index aa3297ec73218f6add3f87b8e905cc39c8c60d70..b4f5de9c3a291d9a08d943cff32e30969e5d8343 100644 --- a/zh-cn/release-notes/Readme.md +++ b/zh-cn/release-notes/Readme.md @@ -7,7 +7,7 @@ ## OpenHarmony 2.x Releases - [OpenHarmony v2.2 beta2 (2021-08-04)](OpenHarmony-v2.2-beta2.md) -- [OpenHarmony 2.0 Canary (2021-06-02)](OpenHarmony-2-0-Canary.md) +- [OpenHarmony 2.0 Canary (2021-06-01)](OpenHarmony-2-0-Canary.md) ## OpenHarmony 1.x Releases - [OpenHarmony v1.1.4 LTS (2022-02-11)](OpenHarmony-v1-1-4-LTS.md) - [OpenHarmony v1.1.3 LTS (2021-09-30)](OpenHarmony-v1-1-3-LTS.md)