diff --git a/CODEOWNERS b/CODEOWNERS index 200832f4e488b910697dbb875624c74e173c1bc5..e39947e90a7e572b6f323f9f1d18da24d8f1b3ba 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -15,7 +15,302 @@ zh-cn/device-dev/kernel/ @Austin23 zh-cn/device-dev/website.md @Austin23 -README.md @Austin23 -zh-cn/device-dev/porting/ @duangavin123_admin +zh-cn/device-dev/faqs/ @Austin23 +zh-cn/device-dev/porting/ @Austin23 +zh-cn/device-dev/security/ @Austin23 zh-cn/device-dev/guide/ @duangavin123_admin -zh-cn/device-dev/subsystems/ @li-yan339 \ No newline at end of file +zh-cn/device-dev/quick-start/ @li-yan339 +zh-cn/device-dev/driver/ @li-yan339 +zh-cn/device-dev/get-code/ @li-yan339 +zh-cn/device-dev/hpm-part/ @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-build-mini-lite.md @Austin23 +zh-cn/device-dev/subsystems/subsys-build-standard-large.md @Austin23 +zh-cn/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md @Austin23 +zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guid.md @Austin23 +zh-cn/device-dev/subsystems/subsys-remote-start.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-graphics-overview.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-graphics-container-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-graphics-layout-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-graphics-common-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-graphics-animation-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-multimedia-camera-overview.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-multimedia-camera-photo-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-multimedia-camera-record-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-multimedia-camera-preview-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-multimedia-video-overview.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-multimedia-video-play-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-multimedia-video-record-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-utils-overview.md @Austin23 +zh-cn/device-dev/subsystems/subsys-utils-guide.md @Austin23 +zh-cn/device-dev/subsystems/subsys-utils-faqs.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-guide.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-envbuild.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-tech-name.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-tech-interface.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-devguide-sdk.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-devguide-plugin.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-devguide-conf.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-demo-sdk.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-demo-plugin.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-demo-conf.md @Austin23 +zh-cn/device-dev/subsystems/subsys-data-relational-database.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-data-relational-database-overview.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-data-relational-database-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-data-storage.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-data-storage-overview.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-data-storage-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-sensor-overview.md @Austin23 +zh-cn/device-dev/subsystems/subsys-sensor-guide.md @Austin23 +zh-cn/device-dev/subsystems/subsys-sensor-demo.md @Austin23 +zh-cn/device-dev/subsystems/subsys-usbservice-overview.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-usbservice-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-usbservice-demo.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-application-framework-overview.md @Austin23 +zh-cn/device-dev/subsystems/subsys-application-framework-envbuild.md @Austin23 +zh-cn/device-dev/subsystems/subsys-application-framework-guide.md @Austin23 +zh-cn/device-dev/subsystems/subsys-application-framework-demo.md @Austin23 +zh-cn/device-dev/subsystems/subsys-ota-guide.md @Austin23 +zh-cn/device-dev/subsystems/subsys-tel-overview.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-tel-guide.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-security-overview.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-security-sigverify.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-security-communicationverify.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-security-devicesecuritylevel.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-boot-overview.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-init.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-appspawn.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-appspawn-standard.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-bootstrap.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-syspara.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-faqs.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-ref.md @Austin23 +zh-cn/device-dev/subsystems/subsys-testguide-test.md @Austin23 +zh-cn/device-dev/subsystems/subsys-dfx-overview.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hilog-rich.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hilog-lite.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hitrace.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hicollie.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-tool.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-dfx-faultlogger.md @duangavin123_admin +zh-cn/device-dev/subsystems/subsys-toolchain-bytrace-guide.md @Austin23 +zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md @Austin23 +zh-cn/device-dev/subsystems/subsys-toolchain-hiperf.md @Austin23 +zh-cn/device-dev/subsystems/subsys-xts-guide.md @Austin23 + +zh-cn/application-dev/ability/ @RayShih +zh-cn/application-dev/ui/ @HelloCrease +zh-cn/application-dev/notification/ @RayShih +zh-cn/application-dev/windowmanager/ @ge-yafang +zh-cn/application-dev/webgl/ @ge-yafang +zh-cn/application-dev/media/ @zengyawen +zh-cn/application-dev/security/ @zengyawen +zh-cn/application-dev/connectivity/ @zengyawen +zh-cn/application-dev/connectivity/ipc-rpc-overview.md @qinxiaowang +zh-cn/application-dev/connectivity/ipc-rpc-development-guideline.md @qinxiaowang +zh-cn/application-dev/connectivity/subscribe-remote-state.md @qinxiaowang +zh-cn/application-dev/telephony/ @zengyawen +zh-cn/application-dev/dfx/ @zengyawen +zh-cn/application-dev/database/ @ge-yafang +zh-cn/application-dev/napi/drawing_guidelines.md @ge-yafang +zh-cn/application-dev/napi/rawfile_guidelines.md @HelloCrease +zh-cn/application-dev/background-agent-scheduled-reminder/ @RayShih +zh-cn/application-dev/background-task-management/ @RayShih +zh-cn/application-dev/work-scheduler/ @HelloCrease +zh-cn/application-dev/device/usb-overview.md @ge-yafang +zh-cn/application-dev/device/usb-guidelines.md @ge-yafang +zh-cn/application-dev/device/device-location-overview.md @sun-yue14 +zh-cn/application-dev/device/device-location-info.md @sun-yue14 +zh-cn/application-dev/device/device-location-geocoding.md @sun-yue14 +zh-cn/application-dev/device/sensor-overview.md @HelloCrease +zh-cn/application-dev/device/sensor-guidelines.md @HelloCrease +zh-cn/application-dev/device/vibrator-overview.md @HelloCrease +zh-cn/application-dev/device/vibrator-guidelines.md @HelloCrease +zh-cn/application-dev/device/sample-server-overview.md @HelloCrease +zh-cn/application-dev/device/sample-server-guidelines.md @HelloCrease +zh-cn/application-dev/reference/arkui-js/ @HelloCrease +zh-cn/application-dev/reference/arkui-ts/ @HelloCrease +zh-cn/application-dev/reference/native-apis @RayShih +zh-cn/application-dev/reference/native-lib @RayShih +zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-ability-errorCode.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-ability-wantConstant.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-ability.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-abilityConstant.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-appmanager.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-configuration.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-featureAbility.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-formbindingdata.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-formextension.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-formerror.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-formhost.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-formInfo.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-missionManager.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-formprovider.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-Want.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-wantAgent.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-Context.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-ability-context.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-abilityMonitor.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-context.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-extension-context.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-MissionSnapshot.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-emitter.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-notification.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-eventhub.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-Bundle.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-zlib.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-animator.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-mediaquery.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-prompt.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-router.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-display.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-screenshot.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-window.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-webgl.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-webgl2.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-audio.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-camera.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-image.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-media.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-i18n.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-intl.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-config-policy.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-huks.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-system-cipher.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-data-ability.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-data-storage.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-system-storage.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-data-rdb.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-settings.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-data-resultset.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-document.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-environment.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-fileio.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-filemanager.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-statfs.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-contact.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-call.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-observer.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-radio.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-sim.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-sms.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-telephony-data.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-net-connection.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-http.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-request.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-socket.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-webSocket.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-rpc.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-wifi.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-wifiext.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-accessibility.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-faultLogger.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-hiappevent.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-hichecker.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-hidebug.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-hilog.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-hitracechain.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-hitracemeter.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-system-time.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-timer.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-battery-info.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-brightness.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-device-info.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-device-manager.md +zh-cn/application-dev/reference/apis/js-apis-geolocation.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-power.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-runninglock.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-sensor.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-thermal.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-update.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-usb.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-vibrator.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-appAccount.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-osAccount.md @sun-yue14 +zh-cn/application-dev/reference/apis/js-apis-convertxml.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-process.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-uri.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-url.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-util.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-arraylist.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-deque.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-hashmap.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-hashset.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-lightweightset.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-linkedlist.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-list.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-plainarray.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-queue.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-stack.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-treemap.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-treeset.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-vector.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-worker.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-xml.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-testRunner.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-uitest.md @HelloCrease +zh-cn/application-dev/quick-start/start-overview.md @ge-yafang +zh-cn/application-dev/quick-start/start-with-ets.md @ge-yafang +zh-cn/application-dev/quick-start/start-with-ets-low-code.md @ge-yafang +zh-cn/application-dev/quick-start/start-with-js.md @ge-yafang +zh-cn/application-dev/quick-start/start-with-js-low-code.md @ge-yafang +zh-cn/application-dev/quick-start/package-structure.md @RayShih +zh-cn/application-dev/quick-start/basic-resource-file-categories.md @RayShih +zh-cn/application-dev/quick-start/syscap.md @RayShih diff --git a/OAT.xml b/OAT.xml index c84e1b4df3bdb1005b4c8912e0cc70055b57bd6d..414d2024d4d92853fb4a174aea6f19d54c3c770d 100644 --- a/OAT.xml +++ b/OAT.xml @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + diff --git a/en/OpenHarmony-Overview.md b/en/OpenHarmony-Overview.md index 78abcbd9df183779c9e930e8904019921970a145..7f61ce7dd8eefb4617c5baeaed025a6fc3ca1fe3 100644 --- a/en/OpenHarmony-Overview.md +++ b/en/OpenHarmony-Overview.md @@ -90,11 +90,11 @@ OpenHarmony supports the following types: - Small system - A small system runs on the devices whose memory is greater than or equal to 1 MiB and that are equipped with application processors such as Arm Cortex-A. This system provides higher security capabilities, standard graphics frameworks, and video encoding and decoding capabilities. Typical products include smart home IP cameras, electronic cat eyes, and routers, and event data recorders \(EDRs\) for smart travel. + A small system runs on the devices whose memory is greater than or equal to 1 MiB and that are equipped with application processors such as Arm Cortex-A. This system provides higher security capabilities, standard graphics frameworks, and video encoding and decoding capabilities. Typical products include smart home IP cameras, electronic cat eyes, routers, and event data recorders \(EDRs\) for smart travel. - Standard system - A standard system runs on the devices whose memory is greater than or equal to 128 MiB and that are equipped with application processors such as ARM Cortex-A. This system provides a complete application framework supporting the enhanced interaction, 3D GPU, hardware composer, diverse components, and rich animations. This system applies to high-end refrigerator displays. + A standard system runs on the devices whose memory is greater than or equal to 128 MiB and that are equipped with application processors such as Arm Cortex-A. This system provides a complete application framework supporting the enhanced interaction, 3D GPU, hardware composer, diverse components, and rich animations. This system applies to high-end refrigerator displays. ## Subsystems @@ -125,7 +125,7 @@ The following table describes the subsystems of OpenHarmony. For details about t | Account | Provides interconnection with vendors' cloud account apps on the device side, and query and update of the cloud account login status. | Standard system | | Compilation and Building | Provides a compilation and building framework based on Generate Ninja (GN) and Ninja. | All systems | | Test | The test-driven development mode is used during the development process. You can develop new cases or modify existing cases to test new or enhanced system features. The test helps you develop high-quality code in the development phase. | All systems | -| Data Management | Provides local data management and distributed data management:<\br> - Local app data management for lightweight preference databases and relational databases<\br> - Distributed data service to provide apps with the capability to store data in the databases of different devices | Standard system | +| Data Management | Provides local data management and distributed data management:
- Local app data management for lightweight preference databases and relational databases
- Distributed data service to provide apps with the capability to store data in the databases of different devices | Standard system | | Programming Language Runtime | Provides the compilation and execution environment for programs developed with JavaScript or C/C++, basic libraries that support the runtime, and the runtime-associated APIs, compilers, and auxiliary tools. | All systems | | Distributed Scheduler | Starts, registers, queries, and manages system services. | All systems | | JS UI framework | OpenHarmony UI development framework that supports web-development-like paradigm. | All systems | @@ -153,7 +153,7 @@ Currently, OpenHarmony supports the development boards listed in the following t | Standard system| Runhe HH-SCDAYU200| RK3568 | Bolstered by the Rockchip RK3568, the HH-SCDAYU200 development board integrates a dual-core GPU and high-efficiency NPU. Its quad-core 64-bit Cortex-A55 processor uses the advanced 22 nm fabrication process and is clocked at up to 2.0 GHz. The board is packed with Bluetooth, WiFi, audio, video, and camera features, with a wide range of expansion ports as well as video input and output ports. It comes with dual GE auto-sensing RJ45 ports, so it can be used in multi-connectivity products, such as network video recorders (NVRs) and industrial gateways.| Video and audio entertainment, smart travel, and smart home, such as kitchen hoods, ovens, and treadmills.| Code repositories:
[device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)
[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)
[vendor_hihope](https://gitee.com/openharmony/vendor_hihope)
Daily build:
http://ci.openharmony.cn/dailys/dailybuilds | | Lightweight| Goodix GR5515-STARTER-KIT| GR5515 | The GR5515-STARTER-KIT development board is a Bluetooth 5.1-capable single-mode Bluetooth low energy (BLE) SoC and comes with multifunctional keys and LED indicators.| Smart hardware, such as watches, wristbands, and price tags.| Code repositories:
[device_soc_goodix](https://gitee.com/openharmony/device_soc_goodix)
[device_board_goodix](https://gitee.com/openharmony/device_board_goodix)
Daily build:
http://ci.openharmony.cn/dailys/dailybuilds | | Lightweight| Langguo LANGO200| ASR582X | The LANGO200 IoT development board integrates the high-performance WiFi-BLE dual-mode chip ASR5822, external storage chip, voice playing chip, and analog-to-digital converter. It supports common peripheral interfaces like SPI, and can be connected to an external OLED display and infrared remote control.| Connection modules for smart home products.| Code repositories:
[device_soc_asrmicro](https://gitee.com/openharmony/device_soc_asrmicro)
[device_board_lango](https://gitee.com/openharmony/device_board_lango)
[vendor_asrmicro](https://gitee.com/openharmony/vendor_asrmicro)
Daily build:
http://ci.openharmony.cn/dailys/dailybuilds | -| Lightweight| Fn-Link multi-modal V200ZR| BES2600 | The multi-modal V200Z-R development board is a high-performance, multi-functional, and cost-effective AIoT SoC powered by the BES2600WM chip of Bestechnic. It integrates a quad-core ARM processor with a frequency of up to 1 GHz as well as dual-mode WiFi and dual-mode Bluetooth. The board supports the 802.11 a/b/g/n/ and BT/BLE 5.2 standards. It is able to accommodate RAM of up to 42 MB and flash memory of up to 32 MB, and supports the MIPI display serial interface (DSI) and camera serial interface (CSI). It is applicable to various AIoT multi-modal VUI and GUI interaction scenarios.| Smart hardware with screens, such as speakers and watches.| Code repositories:
[device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)
[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)
[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic)
Daily build:
http://ci.openharmony.cn/dailys/dailybuilds | +| Lightweight| Fn-Link multi-modal V200ZR| BES2600 | The multi-modal V200Z-R development board is a high-performance, multi-functional, and cost-effective AIoT SoC powered by the BES2600WM chip of Bestechnic. It integrates a quad-core Arm processor with a frequency of up to 1 GHz as well as dual-mode WiFi and dual-mode Bluetooth. The board supports the 802.11 a/b/g/n/ and BT/BLE 5.2 standards. It is able to accommodate RAM of up to 42 MB and flash memory of up to 32 MB, and supports the MIPI display serial interface (DSI) and camera serial interface (CSI). It is applicable to various AIoT multi-modal VUI and GUI interaction scenarios.| Smart hardware with screens, such as speakers and watches.| Code repositories:
[device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)
[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)
[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic)
Daily build:
http://ci.openharmony.cn/dailys/dailybuilds | | Lightweight| BearPi-HM_Nano| Hi3861 | The BearPi-HM_Nano development board is specially designed for OpenHarmony. It is equipped with the highly integrated 2.4 GHz WiFi SoC chip Hi3861, near field communication (NFC) circuits, and standard E53 interfaces, which can be used to connect to smart humidifiers, smart desk lamps, smart security facilities, and intelligent smoke detectors.| Connection devices like smart street lamps, smart logistics sensors, and human body infrared sensors.| Code repositories:
[device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)
[device_board_bearpi](https://gitee.com/openharmony/device_board_bearpi)
[vendor_bearpi](https://gitee.com/openharmony/vendor_bearpi)
Daily build:
http://ci.openharmony.cn/dailys/dailybuilds | ## Getting Started diff --git a/en/application-dev/IDL/figures/IDL-interface-description.png b/en/application-dev/IDL/figures/IDL-interface-description.png new file mode 100644 index 0000000000000000000000000000000000000000..c7acc5c490e1aef26ceeafaffd0f63675cc2d488 Binary files /dev/null and b/en/application-dev/IDL/figures/IDL-interface-description.png differ diff --git a/en/application-dev/IDL/figures/IPC-RPC-communication-model.png b/en/application-dev/IDL/figures/IPC-RPC-communication-model.png new file mode 100644 index 0000000000000000000000000000000000000000..0af6b9fef057703ab2b00ef9153e73df87d4176b Binary files /dev/null and b/en/application-dev/IDL/figures/IPC-RPC-communication-model.png differ diff --git a/en/application-dev/IDL/idl-guidelines.md b/en/application-dev/IDL/idl-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..66b45bd4c04860e882c9104aaf3c58164f5ec29b --- /dev/null +++ b/en/application-dev/IDL/idl-guidelines.md @@ -0,0 +1,661 @@ +# OpenHarmony IDL Specifications and User Guide + +## IDL Overview +To ensure successful communications between the client and server, interfaces recognized by both parties must be defined. The OpenHarmony Interface Definition Language (IDL) is a tool for defining such interfaces. OpenHarmony IDL decomposes objects to be transferred into primitives that can be understood by the operating system and encapsulates cross-boundary objects based on developers' requirements. + +**Figure 1** IDL interface description + +![IDL-interface-description](./figures/IDL-interface-description.png) + +IDL provides the following functions: + +- Declares interfaces provided by system services for external systems, and based on the interface declaration, generates C, C++, JS, or TS code for inter-process communication (IPC) or remote procedure call (RPC) proxies and stubs during compilation. + +- Declares interfaces provided by abilities for external systems, and based on the interface declaration, generates C, C++, JS, or TS code for IPC or RPC proxies and stubs during compilation. + +**Figure 2** IPC/RPC communication model + +![IPC-RPC-communication-model](./figures/IPC-RPC-communication-model.png) + +IDL has the following advantages: + +- Services are defined in the form of interfaces in IDL. Therefore, you do not need to focus on implementation details. + +- Interfaces defined by IDL can be used in IPC or RPC scenarios. The information or code generated based on the definitions in IDL simplifies IPC or RPC implementation. + +## IDL File Structure + +### Data Types + +#### Primitive Type +| IDL Primitive Type| C++ Primitive Type| TS Primitive Type| +| -------- | -------- | -------- | +|void | void | void | +|boolean | bool | boolean | +|byte | int8_t | number | +|short | int16_t | number | +|int | int32_t | number | +|long | int64_t | number | +|float | float | number | +|double | double | number | +|String | std::string | string | + +The preceding table lists the primitive types supported by IDL and the mappings to the C++ and TS primitive types. + +#### sequenceable Type +The sequenceable type is declared using the keyword **sequenceable**. This type can be passed during IPC or RPC through **Parcel** objects. The declaration mode of the sequenceable type in C++ is different from that in TS. + +In C++, the declaration is placed in the file header in the format of **sequenceable includedir..namespace.typename**. It can be in any of the following forms: + +``` +sequenceable includedir..namespace.typename +sequenceable includedir...typename +sequenceable namespace.typename +``` +In the preceding information, **includedir** indicates the directory where the header file of the type is located, and the dot (.) is used as the separator. **namespace** indicates the namespace where the type is located, and the dot (.) is used as the separator. **typename** indicates the data type, which can contain only English characters. **includedir** and **namespace** are separated by two dots (..). If the declaration statement does not contain two dots, all characters except the last typename will be parsed as a namespace. Example: +``` +sequenceable a.b..C.D +``` +The preceding statement is parsed into the following code in the C++ header file: +``` +#include "a/b/d.h" +using C::D; +``` +In TS, the declaration is placed in the file header in the format of **sequenceable namespace.typename;**. It can be in the following form: + +``` +sequenceable idl.MySequenceable +``` + +In the preceding information, **namespace** indicates the namespace to which the data type belongs, **typename** indicates the data type name, and **MySequenceable** indicates that data can be passed during IPC using **Parcel** objects. The sequenceable type is not defined in the IDL file, but in the .ts file. Therefore, IDL adds the following statement to the generated .ts file based on the declaration: + +``` +import MySequenceable from "./my_sequenceable" +``` + +Note that IDL does not implement code for this type. It only imports the header file in the specified format or imports the specified module and uses the type. Therefore, you must ensure that the imported directory, namespace, and type are correct. + +#### Interface Type +The interface type refers to interfaces defined in IDL files. The interfaces defined in an IDL file can be directly used as the parameter type or return value type of a method declared in the file. If an IDL file attempts to use interfaces defined in other IDL files, forward declaration must be contained in the header of that IDL file. + +The declaration form in C++ is similar to that of the sequenceable type. The declaration form is as follows: + +``` +interface includedir..namespace.typename +``` + +In TS, the declaration form is as follows: + +``` +interface namespace.interfacename +``` + +In the preceding information, **namespace** indicates the namespace to which the interface belongs, and **interfacename** indicates the name of the interface. For example, **interface OHOS.IIdlTestObserver;** declares the **IIdlTestObserver** interface defined in another IDL file. This interface can be used as the parameter type or return value type of a method in the current file. IDL adds the following statement to the generated .ts file based on the statement: + +``` +import IIdlTestObserver from "./i_idl_test_observer" +``` + +#### Array Type +The array type is represented by T[], where **T** can be the primitive, sequenceable, interface, or array type. In C++, this type is generated as **std::vector<T>**. +The table below lists the mappings between the IDL array type and TS and C++ data types. + +|IDL Data Type | C++ Data Type | TS Data Type | +| -------- | -------- | -------- | +|T[] | std::vector<T> | T[] | + +#### Container Type +IDL supports two container types: List and Map. The List container is represented in the format of **List<T>**. The Map container is represented in the format of **Map**, where **T**, **KT**, and **VT** can be of the primitive, sequenceable, interface, array, or container type. + +In C++, the List container type is generated as **std::list**, and the Map container type is generated as **std::map**. + +In TS, the List container type is not supported, and the Map container type is generated as **Map**. + +The table below lists the mappings between the IDL container type and TS and C++ data types. + +|IDL Data Type | C++ Data Type | TS Data Type | +| -------- | -------- | -------- | +|List<T> | std::list | Not supported| +|Map | std::map | Map | + + +### Specifications for Compiling IDL Files +Only one interface type can be defined in an IDL file, and the interface name must be the same as the file name. The interface definition of the IDL file is described in Backus-Naur form (BNF). The basic definition format is as follows: +``` +[<*interface_attr_declaration*>]interface<*interface_name_with_namespace*>{<*method_declaration*>} +``` +In the preceding information, <*interface_attr_declaration*> declares interface attributes. Currently, only the **oneway** attribute is supported, indicating that all methods in the interface are unidirectional. Such a method returns value without waiting for the execution to complete. This attribute is optional. If this attribute is not set, synchronous call is used. The interface name must contain the complete interface header file directory, namespace, and method declaration. Empty interfaces are not allowed. +The method declaration format in the interface is as follows: +``` +[<*method_attr_declaration*>]<*result_type*><*method_declaration*> +``` +In the preceding information, <*method_attr_declaration*> describes the interface attributes. Currently, only the **oneway** attribute is supported, indicating that the method is unidirectional. Such a method returns value without waiting for the execution to complete. This attribute is optional. If this attribute is not set, synchronous call is used. <*result_type*> indicates the type of the return value, and <*method_declaration*> indicates the method name and parameter declaration. +The parameter declaration format is as follows: +``` +[<*formal_param_attr*>]<*type*><*identifier*> +``` +The value of <*formal_param_attr*> can be **in**, **out**, or **inout**, indicating that the parameter is an input parameter, an output parameter, or both an input and an output parameter, respectively. A **oneway** method does not allow **output** or **inout** parameters or return values. + +## How to Develop + +### Development Using C++ + +#### Creating an IDL File + + You can use C++ to create IDL files. An example IDL file is as follows: + +``` + interface OHOS.IIdlTestService { + int TestIntTransaction([in] int data); + void TestStringTransaction([in] String data); + } +``` + +You can run the **./idl -gen-cpp -d dir -c dir/iTest.idl** command (**-d** indicates the output directory) to generate the interface file, stub file, and proxy file in the **dir** directory in the execution environment. The names of the generated interface class files are the same as that of the IDL file, except that the file name extensions are **.h** and **.cpp**. For example, for **IIdlTestService.idl**, the generated files are **i_idl_test_service.h**, **idl_test_service_proxy.h**, **idl_test_service_stub.h**, **idl_test_service_proxy.cpp**, and **idl_test_service_stub.cpp**. + +#### Exposing Interfaces on the Server + +The stub class generated by IDL is an abstract implementation of the interface class and declares all methods in the IDL file. + +``` +#ifndef OHOS_IDLTESTSERVICESTUB_H +#define OHOS_IDLTESTSERVICESTUB_H +#include +#include "iidl_test_service.h" + +namespace OHOS { +class IdlTestServiceStub : public IRemoteStub { +public: + int OnRemoteRequest( + /* [in] */ uint32_t code, + /* [in] */ MessageParcel& data, + /* [out] */ MessageParcel& reply, + /* [in] */ MessageOption& option) override; + +private: + static constexpr int COMMAND_TEST_INT_TRANSACTION = MIN_TRANSACTION_ID + 0; + static constexpr int COMMAND_TEST_STRING_TRANSACTION = MIN_TRANSACTION_ID + 1; +}; +} // namespace OHOS +#endif // OHOS_IDLTESTSERVICESTUB_H +``` + +You need to inherit the interface class defined in the IDL file and implement the methods in the class. In addition, you need to register the defined services with SAMGR during service initialization. In the following code snippet, **TestService** inherits the **IdlTestServiceStub** interface class and implements the **TestIntTransaction** and **TestStringTransaction** methods. + +``` +#ifndef OHOS_IPC_TEST_SERVICE_H +#define OHOS_IPC_TEST_SERVICE_H + +#include "hilog/log.h" +#include "log_tags.h" +#include "idl_test_service_stub.h" + +namespace OHOS { +class TestService : public IdlTestServiceStub { +public: + TestService(); + ~TestService(); + static int Instantiate(); + ErrCode TestIntTransaction(int data, int &rep) override; + ErrCode TestStringTransaction(const std::string& data) override; +private: + static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "TestService" }; +}; +} // namespace OHOS +#endif // OHOS_IPC_TEST_SERVICE_H +``` + +The sample code for registering a service is as follows: + +``` +#include "test_service.h" + +#include + +#include "if_system_ability_manager.h" +#include "ipc_debug.h" +#include "ipc_skeleton.h" +#include "iservice_registry.h" +#include "system_ability_definition.h" + +namespace OHOS { +using namespace OHOS::HiviewDFX; + +int TestService::Instantiate() +{ + ZLOGI(LABEL, "%{public}s call in", __func__); + auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (saMgr == nullptr) { + ZLOGE(LABEL, "%{public}s:fail to get Registry", __func__); + return -ENODEV; + } + + sptr newInstance = new TestService(); + int result = saMgr->AddSystemAbility(IPC_TEST_SERVICE, newInstance); + ZLOGI(LABEL, "%{public}s: IPC_TEST_SERVICE result = %{public}d", __func__, result); + return result; +} + +TestService::TestService() +{ +} + +TestService::~TestService() +{ +} + +ErrCode TestService::TestIntTransaction(int data, int &rep) +{ + ZLOGE(LABEL, " TestService:read from client data = %{public}d", data); + rep = data + data; + return ERR_NONE; +} + +ErrCode TestService::TestStringTransaction(const std::string &data) +{ + ZLOGE(LABEL, "TestService:read string from client data = %{public}s", data.c_str()); + return data.size(); +} +} // namespace OHOS +``` + + +#### Calling Methods from the Client for IPC + +The C++ client obtains the service proxy defined in the system through SAMGR and then invokes the interface provided by the proxy. The sample code is as follows: + +``` +#include "test_client.h" + +#include "if_system_ability_manager.h" +#include "ipc_debug.h" +#include "ipc_skeleton.h" +#include "iservice_registry.h" +#include "system_ability_definition.h" + +namespace OHOS { +int TestClient::ConnectService() +{ + auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (saMgr == nullptr) { + ZLOGE(LABEL, "get registry fail"); + return -1; + } + + sptr object = saMgr->GetSystemAbility(IPC_TEST_SERVICE); + if (object != nullptr) { + ZLOGE(LABEL, "Got test Service object"); + testService_ = (new (std::nothrow) IdlTestServiceProxy(object)); + } + + if (testService_ == nullptr) { + ZLOGE(LABEL, "Could not find Test Service!"); + return -1; + } + + return 0; +} + +void TestClient::StartIntTransaction() +{ + if (testService_ != nullptr) { + ZLOGE(LABEL, "StartIntTransaction"); + [[maybe_unused]] int result = 0; + testService_->TestIntTransaction(1234, result); // 1234 : test number + ZLOGE(LABEL, "Rec result from server %{public}d.", result); + } +} + +void TestClient::StartStringTransaction() +{ + if (testService_ != nullptr) { + ZLOGI(LABEL, "StartIntTransaction"); + testService_->TestStringTransaction("IDL Test"); + } +} +} // namespace OHOS +``` + + + + +### Development Using TS + +#### Creating an IDL File + + You can use TS to create IDL files. An example IDL file is as follows: + +``` + interface OHOS.IIdlTestService { + int TestIntTransaction([in] int data); + void TestStringTransaction([in] String data); + } +``` + +Run the **./idl -c IIdlTestService.idl -gen-ts -d /data/ts/** command (**-d** indicates the output directory) to generate the interface file, stub file, and proxy file in the **/data/ts** directory in the execution environment. The names of the generated interface class files are the same as that of the IDL file, except that the file name extension is **.ts**. For example, the files generated for the **IIdlTestService.idl** file are **i_idl_test_service.ts**, **idl_test_service_proxy.ts**, and **idl_test_service_stub.ts**. + +#### Exposing Interfaces on the Server + +The stub class generated by IDL is an abstract implementation of the interface class and declares all methods in the IDL file. + +``` +import {testIntTransactionCallback} from "./i_idl_test_service"; +import {testStringTransactionCallback} from "./i_idl_test_service"; +import IIdlTestService from "./i_idl_test_service"; +import rpc from "@ohos.rpc"; + +export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdlTestService { + constructor(des: string) { + super(des); + } + + onRemoteRequest(code: number, data, reply, option): boolean { + console.log("onRemoteRequest called, code = " + code); + switch(code) { + case IdlTestServiceStub.COMMAND_TEST_INT_TRANSACTION: { + let _data = data.readInt(); + this.testIntTransaction(_data, (errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue); + } + }); + return true; + } + case IdlTestServiceStub.COMMAND_TEST_STRING_TRANSACTION: { + let _data = data.readString(); + this.testStringTransaction(_data, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + default: { + console.log("invalid request code" + code); + break; + } + } + return false; + } + + testIntTransaction(data: number, callback: testIntTransactionCallback): void{} + testStringTransaction(data: string, callback: testStringTransactionCallback): void{} + + static readonly COMMAND_TEST_INT_TRANSACTION = 1; + static readonly COMMAND_TEST_STRING_TRANSACTION = 2; +} +``` + +You need to inherit the interface class defined in the IDL file and implement the methods in the class. The following code snippet shows how to inherit the **IdlTestServiceStub** interface class and implement the **testIntTransaction** and **testStringTransaction** methods. + +``` +import {testIntTransactionCallback} from "./i_idl_test_service" +import {testStringTransactionCallback} from "./i_idl_test_service" +import IdlTestServiceStub from "./idl_test_service_stub" + + +class IdlTestImp extends IdlTestServiceStub { + + testIntTransaction(data: number, callback: testIntTransactionCallback): void + { + callback(0, data + 1); + } + testStringTransaction(data: string, callback: testStringTransactionCallback): void + { + callback(0); + } +} +``` + +After the service implements the interface, the interface needs to be exposed to the client for connection. If your service needs to expose this interface, extend **Ability** and implement **onConnect()** to return **IRemoteObject** so that the client can interact with the service process. The following code snippet shows how to expose the **IRemoteAbility** interface to the client: + +``` +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility onConnect'); + try { + console.log('ServiceAbility want:' + typeof(want)); + console.log('ServiceAbility want:' + JSON.stringify(want)); + console.log('ServiceAbility want name:' + want.bundleName) + } catch(err) { + console.log("ServiceAbility error:" + err) + } + console.info('ServiceAbility onConnect end'); + return new IdlTestImp('connect'); + }, + onDisconnect(want) { + console.info('ServiceAbility onDisconnect'); + console.info('ServiceAbility want:' + JSON.stringify(want)); + } +}; +``` + +#### Calling Methods from the Client for IPC + +When the client calls **connectAbility()** to connect to a Service ability, the **onConnect** callback in **onAbilityConnectDone** of the client receives the **IRemoteObject** instance returned by the **onConnect()** method of the Service ability. The client and Service ability are in different applications. Therefore, the directory of the client application must contain a copy of the .idl file (the SDK automatically generates the proxy class). The **onConnect** callback then uses the **IRemoteObject** instance to create the **testProxy** instance of the **IdlTestServiceProxy** class and calls the related IPC method. The sample code is as follows: + +``` +import IdlTestServiceProxy from './idl_test_service_proxy' +import featureAbility from '@ohos.ability.featureAbility'; + +function callbackTestIntTransaction(result: number, ret: number): void { + if (result == 0 && ret == 124) { + console.log("case 1 success "); + } +} + +function callbackTestStringTransaction(result: number): void { + if (result == 0) { + console.log("case 2 success "); + } +} + +var onAbilityConnectDone = { + onConnect:function (elementName, proxy) { + let testProxy = new IdlTestServiceProxy(proxy); + testProxy.testIntTransaction(123, callbackTestIntTransaction); + testProxy.testStringTransaction('hello', callbackTestStringTransaction); + }, + onDisconnect:function (elementName) { + console.log("onDisconnectService onDisconnect"); + }, + onFailed:function (code) { + console.log("onDisconnectService onFailed"); + } +}; + +function connectAbility: void { + let want = { + "bundleName":"com.example.myapplicationidl", + "abilityName": "com.example.myapplicationidl.ServiceAbility" + }; + let connectionId = -1; + connectionId = featureAbility.connectAbility(want, onAbilityConnectDone); +} + + +``` + +#### Transferring a sequenceable Object During IPC + +You can send a class from one process to another through IPC interfaces. However, you must ensure that the peer can use the code of this class and this class supports the **marshalling** and **unmarshalling** methods. OpenHarmony uses **marshalling** and **unmarshalling** to serialize and deserialize objects into objects that can be identified by each process. + +To create a class that supports the sequenceable type, perform the following operations: + +1. Implement the **marshalling** method, which obtains the current state of the object and serializes the object into a **Parcel** object. +2. Implement the **unmarshalling** method, which deserializes the object from a **Parcel** object. + +The following is an example of the **MySequenceable** class code: + +``` +import rpc from '@ohos.rpc'; +export default class MySequenceable { + constructor(num: number, str: string) { + this.num = num; + this.str = str; + } + getNum() : number { + return this.num; + } + getString() : string { + return this.str; + } + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } + private num; + private str; +} +``` + + + +## How to Develop for Interworking Between C++ and TS + +### TS Proxy and C++ Stub Development + +#### C++ Service Object + +1. Use C++ to construct an IDL file and run commands to generate interfaces, stub files, and proxy files. + +2. Create a service object, inherit the interface class defined in the C++ stub file, and implement the methods in the class. An example is as follows: + + ``` + class IdlTestServiceImpl : public IdlTestServiceStub { + public: + IdlTestServiceImpl() = default; + virtual ~IdlTestServiceImpl() = default; + + ErrCode TestIntTransaction(int _data, int& result) override + { + result = 256; + return ERR_OK; + } + + ErrCode TestStringTransaction(const std::string& _data) override + { + return ERR_OK; + } + }; + ``` + +#### Native APIs in C++ + +C++ provides C++ service objects to TS in the format of native APIs. For example, C++ provides a **GetNativeObject** method, which is used to create an **IdlTestServiceImpl** instance. Using the **NAPI_ohos_rpc_CreateJsRemoteObject** method, you can create a JS remote object for the TS application. + +``` +NativeValue* GetNativeObject(NativeEngine& engine, NativeCallbackInfo& info) +{ + sptr impl = new IdlTestServiceImpl(); + napi_value napiRemoteObject = NAPI_ohos_rpc_CreateJsRemoteObject(reinterpret_cast(&engine), impl); + NativeValue* nativeRemoteObject = reinterpret_cast(napiRemoteObject); + return nativeRemoteObject; +} +``` + +#### TS Proxy Object + +Use TS to construct an IDL file and run commands to generate interfaces, stub files, and proxy files. An example proxy file is as follows: + +``` + +import {testIntTransactionCallback} from "./i_idl_test_service"; +import {testStringTransactionCallback} from "./i_idl_test_service"; +import IIdlTestService from "./i_idl_test_service"; +import rpc from "@ohos.rpc"; + +export default class IdlTestServiceProxy implements IIdlTestService { + constructor(proxy) { + this.proxy = proxy; + } + + testIntTransaction(data: number, callback: testIntTransactionCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(data); + this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_INT_TRANSACTION, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readInt(); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + testStringTransaction(data: string, callback: testStringTransactionCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeString(data); + this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_STRING_TRANSACTION, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + static readonly COMMAND_TEST_INT_TRANSACTION = 1; + static readonly COMMAND_TEST_STRING_TRANSACTION = 2; + private proxy +} +``` + +#### Interworking Between TS and C++ Applications + +1. The TS application invokes the native API to obtain the remote C++ service object. +2. Construct a TS proxy and transfers the remote C++ service object to it. +3. Use the TS proxy to call the method declared in the IDL file to implement the interworking between the TS proxy and C++ stub. The following is an example: + +``` +import IdlTestServiceProxy from './idl_test_service_proxy' +import nativeMgr from 'nativeManager'; + +function testIntTransactionCallback(errCode: number, returnValue: number) +{ + console.log("errCode: " + errCode + " returnValue: " + returnValue); +} + +function testStringTransactionCallback(errCode: number) +{ + console.log("errCode: " + errCode); +} + +function jsProxyTriggerCppStub() +{ + let nativeObj = nativeMgr.GetNativeObject(); + let tsProxy = new IdlTestServiceProxy(nativeObj); + // Call testIntTransaction. + tsProxy.testIntTransaction(10, testIntTransactionCallback); + + // Call testStringTransaction. + tsProxy.testStringTransaction("test", testIntTransactionCallback); +} +``` diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md index 8ef60fba9b498e0e1578d8f12641840d88933677..36d653078e36493e3927053cb636ba48062213d9 100644 --- a/en/application-dev/Readme-EN.md +++ b/en/application-dev/Readme-EN.md @@ -7,14 +7,14 @@ - [OpenHarmony Release Notes](../release-notes/Readme.md) - Quick Start - Getting Started - - [Preparations](start-overview.md) + - [Preparations](quick-start/start-overview.md) - [Getting Started with eTS in the Traditional Coding Approach](quick-start/start-with-ets.md) - [Getting Started with eTS in the Low-Code Approach](quick-start/start-with-ets-low-code.md) - [Getting Started with JavaScript in the Traditional Coding Approach](quick-start/start-with-js.md) - [Getting Started with JavaScript in the Low-Code Approach](quick-start/start-with-js-low-code.md) - Development Fundamentals - - [Application Development Package Structure (FA Model)](quick-start/package-structure.md) - - [Application Development Package Structure (Stage Model)](quick-start/module-structure.md) + - [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md) + - [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md) - [Resource File Categories](quick-start/basic-resource-file-categories.md) - [SysCap](quick-start/syscap.md) - Development @@ -36,8 +36,8 @@ - [Device Usage Statistics](device-usage-statistics/Readme-EN.md) - [DFX](dfx/Readme-EN.md) - [Internationalization](internationalization/Readme-EN.md) - - - - [Using Native APIs in Application Projects](napi/napi-guidelines.md) + - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md) + - [Using Native APIs in Application Projects](napi/Readme-EN.md) - Tools - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - Hands-On Tutorials diff --git a/en/application-dev/ability/ability-delegator.md b/en/application-dev/ability/ability-delegator.md index cbf823bacad7b9781d90c8a86224893740444f35..4e27041093bc2b9d1e3a2966f7a5f20b0f51b94c 100644 --- a/en/application-dev/ability/ability-delegator.md +++ b/en/application-dev/ability/ability-delegator.md @@ -1,60 +1,71 @@ # Test Framework Usage ## Overview -The delegator test framework provides a self-test framework (environment) for OpenHarmony applications. Using this framework, you can start an ability, schedule its lifecycle, listen for its state changes, run a shell command, and print the test result. +The delegator test framework provides a self-test environment for OpenHarmony applications. Using this framework, you can start an ability, schedule its lifecycle, listen for its state changes, run a shell command, and print the test result. ## Constraints -The APIs provided by the test framework can be used only in the test HAP. They take effect only after the test framework is started by running the **aa test** command or using the Integrated Development Environment (IDE). +The APIs provided by the test framework can be used only in the test HAP. They take effect only after the test framework is started. ## Starting the Test Framework -The test framework can be started using either of the following methods: +The test framework can be started in either of the following ways: -- Method 1: Run the **aa test** command. +- Method 1: Run the aa test command. - Method 2: Use the IDE. ### Running aa test -You can run the **aa test** command to start the test framework. You can specify the **TestRunner** to be used and the package name or module name of the HAP where the **TestRunner** is located. +To start the test framework, specify the **TestRunner** and the package name or module name of the HAP where the **TestRunner** is located. An example command in the FA model is as follows: ```javascript -aa test -p com.example.myapplicationfaets -s unittest OpenHarmonyTestRunner -s class ActsAbilityTest -w 20 +aa test -b BundleName -p com.example.myapplicationfaets -s unittest OpenHarmonyTestRunner -s class ActsAbilityTest -w 20 ``` An example command in the stage model is as follows: ```javascript -aa test -m com.example.myapplicationfaets -s unittest OpenHarmonyTestRunner -s class ActsAbilityTest -w 20 +aa test -b BundleName -m com.example.myapplicationfaets -s unittest OpenHarmonyTestRunner -s class ActsAbilityTest -w 20 ``` | Parameter | Mandatory| Description | | --------------- | -------- | ------------------------------------------------------------ | +| -b | Yes | Bundle name of the HAP where the **TestRunner** is located. | | -p | Yes | Package name of the HAP where the **TestRunner** is located. This parameter is used by the FA model. | | -m | Yes | Module name of the HAP where the **TestRunner** is located. This parameter is used by the stage model. | | -s unittest | Yes | Name of the **TestRunner** to be used. The TestRunner name must be the same as the file name. | -| -w | No | Timeout interval of a test case, in seconds. If this parameter is not specified, the test framework exits only after **finishTest** is invoked.| -| -s | No | It can be any parameter in the key-value format. The entered parameters can be obtained in key-value mode through **AbilityDelegatorArgs.parameters**. For example, in **-s classname myTest**, **classname** is the key and **myTest** is the value.| +| -w | No | Timeout interval of a test case, in seconds. If this parameter is not specified or is set to a value less than or equal to **0**, the test framework exits only after **finishTest** is invoked.| +| -s \\ | No | **-s** can be followed by any key-value pair obtained through **AbilityDelegatorArgs.parameters**. For example, in **-s classname myTest**, **-s classname** is the key and **myTest** is the value.| +| -D | No | Debug mode for starting the tested application. | +| -h | No | Help information. | ### Using the IDE -For details about how to start the IDE, see [IDE Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-openharmony-test-framework-0000001263160453#section1034420367508). +For details about how to use the IDE to start the test framework, see [IDE Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-openharmony-test-framework-0000001263160453#section1034420367508). ## Introduction to TestRunner **TestRunner** is the entry class of the test framework test process. When the test process is started, the system calls related APIs in **TestRunner**. You need to inherit this class and override the **onPrepare** and **onRun** APIs. When creating an application template, the IDE initializes the default **TestRunner** and starts the default **TestAbility** in the **onRun** API. You can modify the test code of **TestAbility** or override **onPrepare** and **onRun** in **TestRunner** to implement your own test code. For details, see [TestRunner](../reference/apis/js-apis-testRunner.md). +## Introduction to AbilityDelegatorRegistry + +**AbilityDelegatorRegistry** is the **AbilityDelegator** repository class provided by the test framework. You can use **AbilityDelegatorRegistry** to obtain an **AbilityDelegator** instance and the input and generated parameters **AbilityDelegatorArgs** during the test. You can use **AbilityDelegator** to invoke the function set provided by the test framework for testing and verification. For details, see [AbilityDelegatorRegistry](../reference/apis/js-apis-abilityDelegatorRegistry.md). + +## Introduction to AbilityDelegatorArgs + +**AbilityDelegatorArgs** is a test parameter class provided by the test framework. You can use **AbilityDelegatorArgs** to obtain the parameters passed and generated during the test. For details, see [AbilityDelegatorArgs](../reference/apis/js-apis-application-abilityDelegatorArgs.md). + ## Introduction to AbilityMonitor -**AbilityMonitor** is provided by the test framework for binding to and listening for abilities. You can use **AbilityMonitor** to bind to an **Ability** instance and add **AbilityMonitor** to the listening list. After an ability is bound, the creation and lifecycle changes of the ability will trigger the related callback in **AbilityMonitor**. You can test and verify the ability in these callbacks. For details, see [AbilityMonitor](../reference/apis/js-apis-application-abilityMonitor.md). +**AbilityMonitor** is provided by the test framework for binding to and listening for abilities. You can use **AbilityMonitor** to bind to an **Ability** instance and add **AbilityMonitor** to the listening list. When **AbilityMonitor** is bound to an ability, the creation and lifecycle changes of the ability will trigger the related callback in **AbilityMonitor**. You can test and verify the ability in these callbacks. For details, see [AbilityMonitor](../reference/apis/js-apis-application-abilityMonitor.md). **Example** ```javascript import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -function onAbilityCreateCallback() { +function onAbilityCreateCallback(data) { console.info("onAbilityCreateCallback"); } @@ -64,7 +75,7 @@ var monitor = { } var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); -abilityDelegator.addAbilityMonitor(monitor).then((void) => { +abilityDelegator.addAbilityMonitor(monitor).then(() => { console.info("addAbilityMonitor promise"); }); ``` @@ -94,7 +105,7 @@ var abilityDelegator; var ability; var timeout = 100; -function onAbilityCreateCallback() { +function onAbilityCreateCallback(data) { console.info("onAbilityCreateCallback"); } @@ -113,8 +124,6 @@ var want = { bundleName: "bundleName", abilityName: "abilityName" }; - -abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.startAbility(want, (err, data) => { console.info("startAbility callback"); }); @@ -126,14 +135,44 @@ abilityDelegator.startAbility(want, (err, data) => { ### Running a Shell Command -**AbilityDelegator** provides APIs to run shell commands. You can run a shell command in the test code. This feature takes effect only in the test environment. +**AbilityDelegator** provides APIs to run shell commands in the test environment. **Example** ```javascript - var abilityDelegator; - var cmd = "cmd"; - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - abilityDelegator.executeShellCommand(cmd, (err,data) => { +var abilityDelegator; +var cmd = "cmd"; +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.executeShellCommand(cmd, (err, data) => { console.info("executeShellCommand callback"); - }); +}); +``` + +### Printing Log Information + +**AbilityDelegator** provides APIs for printing log information. You can call any API in the test code to print process logs to the unit test console. +**Example** + +```javascript +var abilityDelegator; +var msg = "msg"; + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.print(msg, (err) => { + console.info("print callback"); +}); +``` + +### Finishing the Test and Printing Log Information + +**AbilityDelegator** provides the APIs for actively finishing the test. You can call any API in test code to finish the test and print logs to the unit test console. +**Example** + +```javascript +var abilityDelegator; +var msg = "msg"; + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.finishTest(msg, 0, (err) => { + console.info("finishTest callback"); +}); ``` diff --git a/en/application-dev/ability/fa-pageability.md b/en/application-dev/ability/fa-pageability.md index e6c097d55d25d1717c342c847452b0a84baf0d83..d4f6a193ff4b25859f6545b9bfd8eb2adf921229 100644 --- a/en/application-dev/ability/fa-pageability.md +++ b/en/application-dev/ability/fa-pageability.md @@ -2,13 +2,13 @@ ## Overview ### Concepts -The Page ability implements the ArkUI and provides the capability of interacting with developers. When you create an ability in the integrated development environment (IDE), the IDE automatically creates template code. The capabilities related to the Page ability are implemented through the **featureAbility**, and the lifecycle callbacks are implemented through the callbacks in **app.js/app.ets**. +The Page ability implements the ArkUI and provides the capability of interacting with developers. When you create an ability in DevEco Studio, DevEco Studio automatically creates template code. The capabilities related to the Page ability are implemented through the **featureAbility**, and the lifecycle callbacks are implemented through the callbacks in **app.js** or **app.ets**. ### Page Ability Lifecycle **Ability lifecycle** -The Page ability lifecycle is a general term for all states of a Page ability, such as **INACTIVE**, **ACTIVE**, and **BACKGROUND**. +The Page ability lifecycle defines all states of a Page ability, such as **INACTIVE**, **ACTIVE**, and **BACKGROUND**. The following figure shows the lifecycle state transition of the Page ability. @@ -17,25 +17,25 @@ The following figure shows the lifecycle state transition of the Page ability. Description of ability lifecycle states: - - **UNINITIALIZED**: The Page ability is not initialized. This is a temporary state. A Page ability changes directly to the **INITIAL** state upon its creation. + - **UNINITIALIZED**: The Page ability is not initialized. This is a temporary state, from which a Page ability changes directly to the **INITIAL** state upon its creation. - - **INITIAL**: This state refers to the initial or stopped state. The Page ability in this state is not running. The Page ability enters the **INACTIVE** state after it is started. + - **INITIAL**: The Page ability is initialized but not running. The Page ability enters the **INACTIVE** state after it is started. - - **INACTIVE**: The ability is visible but does not gain focus. + - **INACTIVE**: The Page ability is visible but does not gain focus. - - **ACTIVE**: The ability runs in the foreground and gains focus. + - **ACTIVE**: The Page ability runs in the foreground and has focus. - - **BACKGROUND**: The Page ability returns to the background. After being re-activated, the Page ability enters the **ACTIVE** state. After being destroyed, the Page ability enters the **INITIAL** state. + - **BACKGROUND**: The Page ability runs in the background. After being re-activated, the Page ability enters the **ACTIVE** state. After being destroyed, the Page ability enters the **INITIAL** state. **The following figure shows the relationship between lifecycle callbacks and lifecycle states of the Page ability.** ![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) -You can override the lifecycle callbacks provided by the Page ability in the **app.js/app.ets** file. Currently, the **app.js** file provides only the **onCreate** and **onDestroy** callbacks, and the **app.ets** file provides the full lifecycle callbacks. +You can override the lifecycle callbacks provided by the Page ability in the **app.js** or **app.ets** file. Currently, the **app.js** file provides only the **onCreate** and **onDestroy** callbacks, and the **app.ets** file provides the full lifecycle callbacks. ### Launch Type The ability supports two launch types: singleton and multi-instance. -The **launchType** item in the **config.json** file is used to specify the launch type. +You can specify the launch type by setting **launchType** in the **config.json** file. | Launch Type | Description |Description | | ----------- | ------- |---------------- | @@ -55,7 +55,7 @@ By default, **singleton** is used. | void startAbility(parameter: StartAbilityParameter) | Starts an ability. | | Context getContext(): | Obtains the application context.| | void terminateSelf() | Terminates the ability. | -| bool hasWindowFocus() | Checks whether the ability gains focus. | +| bool hasWindowFocus() | Checks whether the ability has focus. | ### Starting a Local Page Ability @@ -76,37 +76,10 @@ By default, **singleton** is used. action: "", entities: [""], type: "", - options: { - // Grant the permission to perform read operations on the URI. - authReadUriPermission: true, - // Grant the permission to perform write operations on the URI. - authWriteUriPermission: true, - // Support forwarding the Want result to the ability. - abilityForwardResult: true, - // Enable abiligy continuation. - abilityContinuation: true, - // Specify that a component does not belong to ohos. - notOhosComponent: true, - // Specify that an ability is started. - abilityFormEnabled: true, - // Grant the permission for possible persisting on the URI. - authPersistableUriPermission: true, - // Grant the permission for possible persisting on the prefix URI. - authPrefixUriPermission: true, - // Support distributed scheduling system startup on multiple devices. - abilitySliceMultiDevice: true, - // A service ability is started regardless of whether the host application has been started. - startForegroundAbility: true, - // Install the specified ability if it is not installed. - installOnDemand: true, - // Return the result to the ability slice. - abilitySliceForwardResult: true, - // Install the specified ability with background mode if it is not installed. - installWithBackgroundMode: true - }, deviceId: "", - bundleName: "com.example.startability", - abilityName: "com.example.startability.MainAbility", + bundleName: "com.example.myapplication", + /* In the FA model, abilityName consists of package and ability name. */ + abilityName: "com.example.entry.secondAbility", uri: "" }, }, @@ -122,10 +95,10 @@ You can also include **parameters** in the **want** parameter and set its value featureAbility.startAbility({ want: { - bundleName: "com.example.startability", + bundleName: "com.example.myapplication", uri: "", parameters: { - abilityName: "com.example.startability.MainAbility" + abilityName: "com.example.entry.secondAbility" } }, }, @@ -227,15 +200,15 @@ In the cross-device scenario, the application must also apply for the data synch | API | Description | | ------------ | ------------------------------------------------------------ | | onShow() | Called when the ability is switched from the background to the foreground. In this case, the ability is visible to users.| -| onHide() | Called when the ability is switched from the foreground to the background. In this case, the ability is invisible.| -| onDestroy() | Called when the ability is destroyed. In this callback, you can make preparations for app exit, such as recycling resources and clearing the cache.| +| onHide() | Called when the ability is switched from the foreground to the background. In this case, the ability is invisible to users.| +| onDestroy() | Called when the ability is destroyed. In this callback, you can make preparations for application exit, such as recycling resources and clearing the cache.| | onCreate() | Called when the ability is created for the first time. You can initialize the application in this callback.| -| onInactive() | Called when the ability loses focus. An ability loses focus before entering the background state.| +| onInactive() | Called when the ability loses focus. An ability loses focus when it is about to enter the background state.| | onActive() | Called when the ability is switched to the foreground and gains focus. | **Example** -You need to override the lifecycle callbacks in **app.js/app.ets**. The IDE template generates **onCreate()** and **onDestroy()** by default. You need to override the other callbacks. +You need to override the lifecycle callbacks except **onCreate()** and **onDestroy()** in **app.js** or **app.ets**. The **onCreate()** and **onDestroy()** callbacks are automatically generated in the template code provided by DevEco Studio. ```javascript export default { @@ -261,4 +234,5 @@ export default { ``` ## Samples The following sample is provided to help you better understand how to develop a Page ability: -- [`DMS`: Distributed Demo (eTS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS) + +- [`DMS`: Distributed Demo (eTS, API version 7)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS) diff --git a/en/application-dev/ability/stage-call.md b/en/application-dev/ability/stage-call.md index 6b1ab0c3cae210aca41488cc4750382128635a1e..9f7216de316df0e4d786e8e25b770dea45be7f6d 100644 --- a/en/application-dev/ability/stage-call.md +++ b/en/application-dev/ability/stage-call.md @@ -8,13 +8,17 @@ The following figure shows the ability call process. ![stage-call](figures/stage-call.png) +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> The startup mode of the callee must be **singleton**. +> Currently, only system applications and Service Extension abilities can use the **Call** APIs to access the callee. + ## Available APIs The table below describes the ability call APIs. For details, see [Ability](../reference/apis/js-apis-application-ability.md#caller). **Table 1** Ability call APIs |API|Description| |:------|:------| -|Promise startAbilityByCall(want: Want)|Obtains the caller interface of the specified ability, and if the specified ability is not started, starts the ability in the background.| +|Promise startAbilityByCall(want: Want)|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.| |void on(method: string, callback: CalleeCallBack)|Callee.on: callback invoked when the callee registers a method.| |void off(method: string)|Callee.off: callback invoked when the callee deregisters a method.| |Promise call(method: string, data: rpc.Sequenceable)|Caller.call: sends agreed sequenceable data to the callee.| @@ -77,7 +81,7 @@ export default class MySequenceable { ``` 4. Implement **Callee.on** and **Callee.off**. - The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **CalleeSortMethod** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns them. You need to implement processing based on service requirements. The sample code is as follows: + The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **CalleeSortMethod** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows: ```ts const TAG: string = '[CalleeAbility]' const MSG_SEND_METHOD: string = 'CallSendMsg' @@ -196,7 +200,7 @@ context.requestPermissionsFromUser(permissions).then((data) => { ``` 3. Send agreed sequenceable data. -The sequenceable data can be sent to the callee in either of the following ways: without a return value or obtaining data returned by the callee. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code is as follows: +The sequenceable data can be sent to the callee with or without a return value. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code is as follows: ```ts const MSG_SEND_METHOD: string = 'CallSendMsg' async onButtonCall() { @@ -242,9 +246,6 @@ try { } ``` -## Development Example +## Samples The following sample is provided to help you better understand how to develop an ability call in the stage model: - -[StageCallAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) - -In this sample, the **AbilityStage** APIs are implemented in the **AbilityStage.ts** file in the **Application** directory, the **Ability** APIs are implemented in the **MainAbility** directory, and **pages/index** is the pages of the ability. Another ability and callee are implemented in the **CalleeAbility** directory, and its pages are the content configured in **pages/second**. The **MainAbility** functions as the caller, and the **CalleeAbility** functions as the callee. After starting the **CalleeAbility**, the **MainAbility** obtains the caller interface, processes the string entered by the user, and transfers the processed string to the **CalleeAbility**. The **CalleeAbility** refreshes the page based on the received data and returns the result to the **MainAbility**. +- [`StageCallAbility`: Stage Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) diff --git a/en/application-dev/application-dev-guide-for-gitee.md b/en/application-dev/application-dev-guide-for-gitee.md index 36b0f4a7c3f8a224dbdd2dbd8f9b983203b7a2c8..f1f397fc5145208733c85a3e711f3cda0337d409 100644 --- a/en/application-dev/application-dev-guide-for-gitee.md +++ b/en/application-dev/application-dev-guide-for-gitee.md @@ -44,7 +44,7 @@ DevEco Studio is a high-performance integrated development environment (IDE) rec ### Hands-On Tutorials -To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/app_samples/blob/master/README.md). +To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) and [codelabs](https://gitee.com/openharmony/codelabs). ### API References diff --git a/en/application-dev/application-dev-guide.md b/en/application-dev/application-dev-guide.md index 0a4df60f399da15279a2b6d344b681b56325c50b..8e47dd69696fd4ec4f6842f9f08826e181805ada 100644 --- a/en/application-dev/application-dev-guide.md +++ b/en/application-dev/application-dev-guide.md @@ -44,7 +44,7 @@ DevEco Studio is a high-performance integrated development environment (IDE) rec ### Hands-On Tutorials -To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/app_samples/blob/master/README.md). +To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) and [codelabs](https://gitee.com/openharmony/codelabs). ### API References diff --git a/en/application-dev/background-task-management/background-task-overview.md b/en/application-dev/background-task-management/background-task-overview.md index 5062447a9c9491ee0854963f4360c610fb2815f6..aa140c3d734be0ec39def56d9cee0732b0f09368 100644 --- a/en/application-dev/background-task-management/background-task-overview.md +++ b/en/application-dev/background-task-management/background-task-overview.md @@ -1,4 +1,4 @@ -# Background Task Overview +# Background Task Management Overview Frequent activities of background applications cause user devices to consume power quickly and respond slowly. To meet performance and power consumption requirements, the system allows applications to execute only activities within the specifications in the background. Activities beyond the specifications are suspended by default, and resources allocated to them will be reclaimed when the available resources are insufficient. diff --git a/en/application-dev/connectivity/Readme-EN.md b/en/application-dev/connectivity/Readme-EN.md index f6187b328a6cfee0272e63fd8f98add01bd05bc7..16bf40cf8467bc805d3b485ca46d6f0fa295b3bc 100755 --- a/en/application-dev/connectivity/Readme-EN.md +++ b/en/application-dev/connectivity/Readme-EN.md @@ -1,4 +1,4 @@ -# Network and Connectivity +# Connectivity - Network Management - [Network Management Overview](net-mgmt-overview.md) @@ -7,5 +7,5 @@ - [Socket Connection](socket-connection.md) - IPC & RPC - [IPC & RPC Overview](ipc-rpc-overview.md) - - [IPC & RPC Development Guidelines](ipc-rpc-development-guideline.md) + - [IPC & RPC Development](ipc-rpc-development-guideline.md) - [Subscribing to State Changes of a Remote Object](subscribe-remote-state.md) diff --git a/en/application-dev/connectivity/http-request.md b/en/application-dev/connectivity/http-request.md index ee4610f46c3c1f25a2509e54bbfb0e9ddb473853..0a69a2e0f79a874def98d2be58d26d6dec0c3874 100644 --- a/en/application-dev/connectivity/http-request.md +++ b/en/application-dev/connectivity/http-request.md @@ -12,20 +12,20 @@ To use related APIs, you must declare the **ohos.permission.INTERNET** permissio The following table describes the related APIs. -| API | Description | -| ----------------------------------------- | ----------------------------------- | -| createHttp() | Creates an HTTP request. | -| request() | Initiates an HTTP request to a given URL. | -| destroy() | Destroys an HTTP request. | +| API | Description | +| ----------------------------------------- | --------------------------------------------------------- | +| createHttp() | Creates an HTTP request. | +| request() | Initiates an HTTP request to a given URL. | +| destroy() | Destroys an HTTP request. | | on(type: 'headersReceive') | Registers an observer for HTTP Response Header events. | -| off(type: 'headersReceive') | Unregisters the observer for HTTP Response Header events.| +| off(type: 'headersReceive') | Unregisters the observer for HTTP Response Header events. | ## How to Develop 1. Import the required HTTP module. 2. Create an **HttpRequest** object. 3. (Optional) Listen for HTTP Response Header events. -4. Initiates an HTTP request to a given URL. +4. Initiate an HTTP request to a given URL. 5. (Optional) Process the HTTP Response Header event and the return result of the HTTP request. ```js @@ -71,3 +71,7 @@ httpRequest.request( } ); ``` + +## Samples +The following sample is provided to help you better understand how to develop the HTTP data request feature: +- [`Http`: HTTP Data Request (eTS) (API 8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Http) diff --git a/en/application-dev/connectivity/ipc-rpc-development-guideline.md b/en/application-dev/connectivity/ipc-rpc-development-guideline.md index a0107dabe7b716b4f7fe2c163c8f48970337959d..03019858805cff17ef97b4c7227ee5c86947536b 100644 --- a/en/application-dev/connectivity/ipc-rpc-development-guideline.md +++ b/en/application-dev/connectivity/ipc-rpc-development-guideline.md @@ -6,7 +6,7 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat ## Available APIs -**Table 1** Native IPC APIs +**Table 1** Native IPC APIs

Class/Interface

@@ -44,9 +44,9 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat **Using Native APIs** -1. Define the IPC interface **ITestAbility**. +1. Define the IPC interface **ITestAbility**. - **ITestAbility** inherits the IPC base class **IRemoteBroker** and defines descriptors, functions, and message code. The functions need to be implemented on both the proxy and stub. + **ITestAbility** inherits the IPC base class **IRemoteBroker** and defines descriptors, functions, and message code. The functions need to be implemented on both the proxy and stub. ``` class ITestAbility : public IRemoteBroker { @@ -58,9 +58,9 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat }; ``` -2. Define and implement service provider **TestAbilityStub**. +2. Define and implement service provider **TestAbilityStub**. - This class is related to the IPC framework and needs to inherit **IRemoteStub**. You need to override **OnRemoteRequest** on the stub to receive requests from the proxy. + This class is related to the IPC framework and needs to inherit **IRemoteStub**. You need to override **OnRemoteRequest** on the stub to receive requests from the proxy. ``` class TestAbilityStub : public IRemoteStub { @@ -85,7 +85,7 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat } ``` -3. Define the **TestAbility** class that implements functions for the stub. +3. Define the **TestAbility** class that implements functions for the stub. ``` class TestAbility : public TestAbilityStub { @@ -98,9 +98,9 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat } ``` -4. Define and implement **TestAbilityProxy**. +4. Define and implement **TestAbilityProxy**. - This class is implemented on the proxy and inherits **IRemoteProxy**. You can call **SendRequest** to send a request to the stub and expose the capabilities provided by the stub. + This class is implemented on the proxy and inherits **IRemoteProxy**. You can call **SendRequest** to send a request to the stub and expose the capabilities provided by the stub. ``` class TestAbilityProxy : public IRemoteProxy { @@ -128,7 +128,7 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat 5. Register and start an SA. - Call **AddSystemAbility** to register the **TestAbilityStub** instance of the SA with **SystemAbilityManager**. The registration parameters vary depending on whether the **SystemAbilityManager** resides on the same device as the SA. + Call **AddSystemAbility** to register the **TestAbilityStub** instance of the SA with **SystemAbilityManager**. The registration parameters vary depending on whether the **SystemAbilityManager** resides on the same device as the SA. ``` // Register the TestAbilityStub instance with the SystemAbilityManager on the same device as the SA. @@ -144,7 +144,7 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat 6. Obtain the SA. - Call the **GetSystemAbility** function of the **SystemAbilityManager** class to obtain the **IRemoteObject** for the SA, and create a **TestAbilityProxy** instance. + Call the **GetSystemAbility** function of the **SystemAbilityManager** class to obtain the **IRemoteObject** for the SA, and create a **TestAbilityProxy** instance. ``` // Obtain the proxy of the SA registered on the local device. diff --git a/en/application-dev/connectivity/ipc-rpc-overview.md b/en/application-dev/connectivity/ipc-rpc-overview.md index c586dbd1fe7e7b24496be753ef95a41f3355f119..19bbe8dc26871bec8b2f6f48273d90dacc148d70 100755 --- a/en/application-dev/connectivity/ipc-rpc-overview.md +++ b/en/application-dev/connectivity/ipc-rpc-overview.md @@ -19,4 +19,4 @@ In OpenHarmony documents, proxy represents the service requester, and stub repre ## Related Modules -Distributed Scheduler +[Distributed Scheduler](https://gitee.com/openharmony/distributedschedule_dms_fwk) diff --git a/en/application-dev/connectivity/socket-connection.md b/en/application-dev/connectivity/socket-connection.md index 98b82c8064e58de21d742efc79b51ff3ef46a331..ede8acfcbe792f81437701cb7032e3fcf7b335b9 100644 --- a/en/application-dev/connectivity/socket-connection.md +++ b/en/application-dev/connectivity/socket-connection.md @@ -10,26 +10,26 @@ Your application can transmit data through Socket connections. Currently, the TC The Socket connection function is mainly implemented by the Socket module. The following table describes the related APIs. -| API| Description| +| API| Description | | -------- | -------- | -| constructUDPSocketInstance() | Creates a **UDPSocket** object.| -| constructTCPSocketInstance() | Creates a **TCPSocket** object.| -| bind() | Binds the IP address and port number.| +| constructUDPSocketInstance() | Creates a **UDPSocket** object. | +| constructTCPSocketInstance() | Creates a **TCPSocket** object. | +| bind() | Binds the IP address and port number. | | send() | Sends data.| -| close() | Closes a Socket connection.| -| getState() | Obtains the Socket connection status.| -| connect() | Connects to the specified IP address and port. This function is supported only for TCP.| -| getRemoteAddress() | Obtains the peer address of the Socket connection. This function is supported only for TCP. The **connect** API must have been called before you use this API.| -| on(type: 'message') | Enables listening for **message** events of the Socket connection.| -| off(type: 'message') | Disables listening for **message** events of the Socket connection.| -| on(type: 'close') | Enables listening for **close** events of the Socket connection.| -| off(type: 'close') | Disables listening for **close** events of the Socket connection.| -| on(type: 'error') | Enables listening for **error** events of the Socket connection.| -| off(type: 'error') | Disables listening for **error** events of the Socket connection.| +| close() | Closes a Socket connection. | +| getState() | Obtains the Socket connection status. | +| connect() | Connects to the specified IP address and port. This function is supported only for TCP. | +| getRemoteAddress() | Obtains the peer address of the Socket connection. This function is supported only for TCP. The **connect** API must have been called before you use this API. | +| on(type: 'message') | Enables listening for **message** events of the Socket connection. | +| off(type: 'message') | Disables listening for **message** events of the Socket connection. | +| on(type: 'close') | Enables listening for **close** events of the Socket connection. | +| off(type: 'close') | Disables listening for **close** events of the Socket connection. | +| on(type: 'error') | Enables listening for **error** events of the Socket connection. | +| off(type: 'error') | Disables listening for **error** events of the Socket connection. | | on(type: 'listening') | Enables listening for **listening** events of the UDPSocket connection. | | off(type: 'listening') | Disables listening for **listening** events of the UDPSocket connection. | | on(type: 'connect') | Enables listening for **connect** events of the TCPSocket connection. | -| off(type: 'connect') | Disables listening for **connect** events of the TCPSocket connection.| +| off(type: 'connect') | Disables listening for **connect** events of the TCPSocket connection. | ## How to Develop @@ -122,3 +122,7 @@ The implementation is similar for UDPSocket and TCPSocket. The following uses th tcp.off('close'); }, 30 * 1000); ``` + +## Samples +The following sample is provided to help you better understand how to develop the socket connection feature: +- [`Socket`: Socket Connection (eTS) (API 8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Socket) diff --git a/en/application-dev/connectivity/websocket-connection.md b/en/application-dev/connectivity/websocket-connection.md index 42501508c4c89a6a3a2c35b1d585e73946c3a629..01f5f38fad74e234c8a9fb483ee4a11ae2a8c7a7 100644 --- a/en/application-dev/connectivity/websocket-connection.md +++ b/en/application-dev/connectivity/websocket-connection.md @@ -12,20 +12,20 @@ If an error occurs in any of the preceding processes, the client will receive a The WebSocket connection function is mainly implemented by the WebSocket module. To use related APIs, you must declare the **ohos.permission.INTERNET** permission. The following table describes the related APIs. -| API| Description| +| API | Description | | -------- | -------- | -| createWebSocket() | Creates a WebSocket connection.| -| connect() | Establishes a WebSocket connection to a given URL.| -| send() | Sends data through the WebSocket connection.| -| close() | Closes a WebSocket connection.| -| on(type: 'open') | Enables listening for **open** events of a WebSocket connection.| -| off(type: 'open') | Disables listening for **open** events of a WebSocket connection.| -| on(type: 'message') | Enables listening for **message** events of a WebSocket connection.| -| off(type: 'message') | Disables listening for **message** events of a WebSocket connection.| -| on(type: 'close') | Enables listening for **close** events of a WebSocket connection.| -| off(type: 'close') | Disables listening for **close** events of a WebSocket connection.| -| on(type: 'error') | Enables listening for **error** events of a WebSocket connection.| -| off(type: 'error') | Disables listening for **error** events of a WebSocket connection.| +| createWebSocket() | Creates a WebSocket connection. | +| connect() | Establishes a WebSocket connection to a given URL. | +| send() | Sends data through the WebSocket connection. | +| close() | Closes a WebSocket connection. | +| on(type: 'open') | Enables listening for **open** events of a WebSocket connection. | +| off(type: 'open') | Disables listening for **open** events of a WebSocket connection. | +| on(type: 'message') | Enables listening for **message** events of a WebSocket connection. | +| off(type: 'message') | Disables listening for **message** events of a WebSocket connection. | +| on(type: 'close') | Enables listening for **close** events of a WebSocket connection. | +| off(type: 'close') | Disables listening for **close** events of a WebSocket connection. | +| on(type: 'error') | Enables listening for **error** events of a WebSocket connection. | +| off(type: 'error') | Disables listening for **error** events of a WebSocket connection. | ## How to Develop diff --git a/en/application-dev/database/Readme-EN.md b/en/application-dev/database/Readme-EN.md index 2be9b2dc5a8f9d6c714cc81e695ade8ad11f23ab..9f7ccd0d08e8683aca6e6c86ddef80f8e0e5aad4 100644 --- a/en/application-dev/database/Readme-EN.md +++ b/en/application-dev/database/Readme-EN.md @@ -6,9 +6,9 @@ - Relational Database - [RDB Overview](database-relational-overview.md) - [RDB Development](database-relational-guidelines.md) -- Lightweight Data Store - - [Lightweight Data Store Overview](database-preference-overview.md) - - [Lightweight Data Store Development](database-preference-guidelines.md) +- Preferences + - [Preferences Overview](database-preference-overview.md) + - [Preferences Development](database-preference-guidelines.md) - Distributed Data Object - [Distributed Data Object Overview](database-distributedobject-overview.md) - [Distributed Data Object Development](database-distributedobject-guidelines.md) diff --git a/en/application-dev/database/database-distributedobject-guidelines.md b/en/application-dev/database/database-distributedobject-guidelines.md index 08b72e45cbd9c1f505f99be567e45296fbce8c52..516ed427b9b8d613b832b430cc63e7d3fa4cd30f 100644 --- a/en/application-dev/database/database-distributedobject-guidelines.md +++ b/en/application-dev/database/database-distributedobject-guidelines.md @@ -2,7 +2,7 @@ ## When to Use -The distributed data objects allow data across devices to be processed like local variables by shielding complex data interaction between devices. For the devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other devices. The devices can listen for the data changes and online and offline states of other devices. The distributed data objects support basic data types, such as number, string, and Boolean, as well as complex data types, such as array and nested basic types. +The distributed data objects allow data across devices to be processed like local variables by shielding complex data interaction between devices. For the devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other devices. The devices can listen for the data changes and online and offline status of other devices. The distributed data objects support basic data types, such as number, string, and Boolean, as well as complex data types, such as array and nested basic types. ## Available APIs @@ -13,47 +13,47 @@ Call **createDistributedObject()** to create a distributed data object instance. **Table 1** API for creating a distributed data object instance -| Package| API| Description| -| -------- | -------- | -------- | -| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.
-  **source**: attributes of the **distributedObject** set.
-  **DistributedObject**: returns the distributed object created.| + | Package | API | Description | + | -------- | -------- | -------- | + | ohos.data.distributedDataObject | createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.
- **source**: attributes of the **distributedObject** set.
- **DistributedObject**: returns the distributed object created. | ### Generating a Session ID Call **genSessionId()** to generate a session ID randomly. The generated session ID can be used to set the session ID of a distributed data object. **Table 2** API for generating a session ID randomly -| Package| API| Description| -| -------- | -------- | -------- | -| ohos.data.distributedDataObject| genSessionId(): string | Generates a session ID, which can be used as the session ID of a distributed data object.| + | Package | API | Description | + | -------- | -------- | -------- | + | ohos.data.distributedDataObject | genSessionId(): string | Generates a session ID, which can be used as the session ID of a distributed data object. | ### Setting a SessionID for Distributed Data Objects -Call setSessionId() to set the session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID. +Call **setSessionId()** to set a session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID. **Table 3** API for setting a session ID -| Class| API| Description| -| -------- | -------- | -------- | -| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.
 **sessionId**: ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| + | Class | API | Description | + | -------- | -------- | -------- | + | DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.
**sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty. | ### Observing Data Changes Call **on()** to subscribe to data changes of a distributed data object. When the data changes, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the data changes. **Table 4** APIs for observing data changes of a distributed data object -| Class| API| Description| -| -------- | -------- | -------- | -| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes.| -| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes. Callback used to return changes of the distributed object. If this parameter is not specified, all callbacks related to data changes will be unregistered.| + | Class | API | Description | + | -------- | -------- | -------- | + | DistributedDataObject | on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes. | + | DistributedDataObject | off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes.
**Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered. | ### Observing Online or Offline Status Call **on()** to subscribe to status changes of a distributed data object. The status can be online or offline. When the status changes, a callback will be invoked to return the status. You can use **off()** to unsubscribe from the status changes. **Table 5** APIs for observing status changes of a distributed data object -| Class| API| Description| -| -------- | -------- | -------- | -| DistributedDataObject| on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }>): void | Subscribes to the status changes of a distributed data object.| -| DistributedDataObject| off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }>): void | Unsubscribes from status changes of a distributed data object.| + | Class | API | Description | + | -------- | -------- | -------- | + | DistributedDataObject | on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' \ | 'offline' }>): void | Subscribes to the status changes of a distributed data object. | + | DistributedDataObject | off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' \ | 'offline' }>): void | Unsubscribes from status changes of a distributed data object. | @@ -62,13 +62,13 @@ Call **on()** to subscribe to status changes of a distributed data object. The s The following example shows how to implement a distributed data object synchronization. 1. Import the @ohos.data.distributedDataObject module to the development environment. + ```js import distributedObject from '@ohos.data.distributedDataObject' ``` 2. Obtain a distributed data object instance. - The sample code is as follows: ```js var local_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true, parent:undefined, list:undefined}); @@ -77,8 +77,6 @@ The following example shows how to implement a distributed data object synchroni 3. Add the synchronization network. The data objects in the synchronization network include the local and remote objects. - - The sample code is as follows: ```js // Local object @@ -90,13 +88,11 @@ The following example shows how to implement a distributed data object synchroni var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true, parent:undefined, list:undefined}); remote_object.setSessionId(sessionId); - // After obtaining that the device status goes online, the remote object synchronizes data. That is, name changes to jack and age to 18. + // After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18. ``` -4. Observe the data changes of the distributed data object. Subscribe to data changes of the remote end. When the data is the peer end changes, a callback will be called to return the data changes. - - The sample code is as follows: - +4. Observe the data changes of the distributed data object. You can subscribe to data changes of the remote object. When the data in the remote object changes, a callback will be called to return the data changes. + ```js function changeCallback(sessionId, changeData) { console.info("change" + sessionId); @@ -107,14 +103,13 @@ The following example shows how to implement a distributed data object synchroni }); } } - - // To refresh the page in changeCallback, correctly set this.changeCallback.bind(this) in - changeCallback. + + // To refresh the page in changeCallback, correctly bind (this) to the changeCallback. + local_object.on("change", this.changeCallback.bind(this)); ``` 5. Modify object attributes. The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types). - - The sample code is as follows: + ```js local_object.name = "jack"; local_object.age = 19; @@ -123,7 +118,7 @@ The following example shows how to implement a distributed data object synchroni local_object.list = [{mother:"jack mom"}, {father:"jack Dad"}]; ``` - > ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**
+ > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. Example: ```js // Supported modification. @@ -133,22 +128,22 @@ The following example shows how to implement a distributed data object synchroni ``` 6. Access the distributed data object. Obtain the distributed data object attribute, which is the latest data on the network. - - The sample code is as follows: + ```js console.info("name " + local_object["name"]); ``` + 7. Unsubscribe from data changes. You can specify the callback to unsubscribe from. If you do not specify the callback, all data change callbacks of the distributed data object will be unsubscribed from. - The sample code is as follows: ```js - // Unsubscribe from changeCallback. + // Unsubscribe from the specified data change callback. local_object.off("change", changeCallback); // Unsubscribe from all data change callbacks. local_object.off("change"); ``` + 8. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline. - The sample code is as follows: + ```js function statusCallback(sessionId, networkId, status) { this.response += "status changed " + sessionId + " " + status + " " + networkId; @@ -156,27 +151,28 @@ The following example shows how to implement a distributed data object synchroni local_object.on("status", this.statusCallback); ``` -9. Unsubscribe from the status changes of the distributed data object. You can specify the callback to unsubscribe from. If you do not specify the callback, all status change callbacks will be unsubscribe from. - - The sample code is as follows: + +9. Unsubscribe from the status changes of the distributed data object. You can specify the callback to unsubscribe from. If you do not specify the callback, this API unsubscribes from all callbacks of this distributed data object. + ```js - // Unsubscribe from the online status change callback. + // Unsubscribe from the specified status change callback. local_object.off("status", statusCallback); - // Unsubscribe from all online status change callbacks. + // Unsubscribe from all status change callbacks. local_object.off("status"); ``` -10. Remove a distributed data object from the synchronization network. After the distributed data object is removed from the network, the data changes on the local end will not be synchronized to the remote end. - The sample code is as follows: - ```js - local_object.setSessionId(""); - ``` -## Development Example +10. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object. + + ```js + local_object.setSessionId(""); + ``` + +## Samples -The following example is provided for you to better understand the development of distributed data object: +The following example is provided for you to better understand the development of distributed data objects: - [Distributed Notepad](https://gitee.com/openharmony/distributeddatamgr_objectstore/tree/master/samples/distributedNotepad) -When an event occurs on a device, such as a note is added, the tile or content of a note is changed, and the event list is cleared, the change will be synchronized to other devices in the trusted network by the Notepad app. - +When an event of the Notepad app occurs on a device, such as a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network. + diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md index d59fd3904ae8d8606f0ab254d78b9a4f03be3dc8..fb45be2adf83aa7c3a1dac6cc875926c3c22a705 100644 --- a/en/application-dev/database/database-mdds-guidelines.md +++ b/en/application-dev/database/database-mdds-guidelines.md @@ -11,15 +11,15 @@ The table below describes the APIs provided by the OpenHarmony DDS module. **Table 1** APIs provided by the DDS -| Category | API | Description | -| -------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | -| Creating a distributed database | createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void
createKVManager(config: KVManagerConfig): Promise<KVManager> | Creates a **KVManager** object for database management.| -| Obtaining a distributed KV store | getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void
getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> | Obtains the KV store with the specified **Options** and **storeId**.| -| Managing data in a distributed KV store| put(key: string, value: Uint8Array \| string \| number \| boolean, callback: AsyncCallback<void>): void
put(key: string, value: Uint8Array \| string \| number \| boolean): Promise<void> | Inserts and updates data. | -| Managing data in a distributed KV store| delete(key: string, callback: AsyncCallback<void>): void
delete(key: string): Promise<void> | Deletes data. | -| Managing data in a distributed KV store| get(key: string, callback: AsyncCallback<Uint8Array \| string \| boolean \| number>): void
get(key: string): Promise<Uint8Array \| string \| boolean \| number> | Queries data. | -| Subscribing to changes in the distributed data | on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void
on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void | Subscribes to data changes in the KV store. | -| Synchronizing data across devices | sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | Triggers database synchronization in manual mode. | +| Category | API | Description | +| -------- | --- | ----------- | +| Creating a distributed database | createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void
createKVManager(config: KVManagerConfig): Promise<KVManager> | Creates a **KVManager** object for database management.| +| Obtaining a distributed KV store | getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void
getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> | Obtains the KV store with the specified **Options** and **storeId**. | +| Managing data in a distributed KV store | put(key: string, value: Uint8Array \| string \| number \| boolean, callback: AsyncCallback<void>): void
put(key: string, value: Uint8Array \| string \| number \| boolean): Promise<void> | Inserts and updates data. | +| Managing data in a distributed KV store| delete(key: string, callback: AsyncCallback<void>): void
delete(key: string): Promise<void> | Deletes data. | +| Managing data in a distributed KV store | get(key: string, callback: AsyncCallback<Uint8Array \| string \| boolean \| number>): void
get(key: string): Promise<Uint8Array \| string \| boolean \| number> | Queries data. | +| Subscribing to changes in the distributed data | on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void
on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void | Subscribes to data changes in the KV store. | +| Synchronizing data across devices | sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | Triggers database synchronization in manual mode. | @@ -29,6 +29,7 @@ The table below describes the APIs provided by the OpenHarmony DDS module. The following uses a single KV store as an example to describe the development procedure. 1. Import the distributed data module. + ```js import distributedData from '@ohos.data.distributedData'; ``` @@ -95,6 +96,7 @@ The following uses a single KV store as an example to describe the development p 4. Subscribe to changes in the distributed data.
The following is the sample code for subscribing to the data changes of a single KV store: + ```js kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { console.log("dataChange callback call data: " + JSON.stringify(data)); @@ -128,6 +130,7 @@ The following uses a single KV store as an example to describe the development p 2. Query data from the single KV store. The following is the sample code for querying data of the string type from the single KV store: + ```js const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; @@ -177,5 +180,5 @@ The following uses a single KV store as an example to describe the development p ``` ## Samples The following samples are provided to help you better understand the distributed data development: -- [`KvStore`: distributed database (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore) -- [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) +- [`KvStore`: Distributed Data Management (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore) +- [Distributed Data Service](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) diff --git a/en/application-dev/database/database-preference-guidelines.md b/en/application-dev/database/database-preference-guidelines.md index fcee818beffac1e1cafaf89af82c5044f111a599..36b6878057640f6cf706efec6d9abbbc1e5b2980 100644 --- a/en/application-dev/database/database-preference-guidelines.md +++ b/en/application-dev/database/database-preference-guidelines.md @@ -1,44 +1,44 @@ -# Lightweight Data Store Development +# Preferences Development ## When to Use -The lightweight data store is ideal for storing lightweight and frequently used data, but not for storing a large amount of data or data with frequent changes. The application data is persistently stored on a device in the form of files. Note that the instance accessed by an application contains all data of the file. The data is always loaded to the memory of the device until the application removes it from the memory. The application can perform data operations using the **Storage** APIs. +Preferences are ideal for storing data frequently used by applications, but not for storing a large amount of data or data with frequent changes. The application data is persistently stored on a device in the form of files. Note that the instance accessed by an application contains all data of the file. The data is always loaded to the memory of the device until the application removes it from the memory. The application can perform data operations using the **Preferences** APIs. ## Available APIs -The lightweight data store provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value (KV) pairs. Keys are of the string type, and values can be of the number, string, or Boolean type. +Preferences provide capabilities for processing data in the form of key-value (KV) pairs and support data persistence, modification, and query. In KV pairs, keys are of the string type, and values can be of the number, string, or Boolean type. -**Creating a Storage Instance** +### Creating a Preferences Instance -Create a **Storage** instance for data operations. A **Storage** instance is created after data is read from a specified file and loaded to the instance. +Create a **Preferences** instance for data operations. A **Preferences** instance is created after data is read from a specified file and loaded to the instance. -**Table 1** API for creating a **Storage** instance +**Table 1** API for creating a **Preferences** instance | Package | API | Description | | ----------------- | ------------------------------------------- | ------------------------------------------- | -| ohos.data.storage | getStorage(path: string): Promise\ | Obtains the **Storage** singleton corresponding to a file for data operations.| +| ohos.data.preferences | getPreferences(context: Context, name: string): Promise\ | Obtains a **Preferences** instance for data operations.| -**Writing Data** +### Writing Data -Call the **put()** method to add or modify data in a **Storage** instance. +Call the **put()** method to add or modify data in a **Preferences** instance. **Table 2** API for writing data | Class | API | Description | | ------- | -------------------------------------------------- | ----------------------------------------------- | -| Storage | put(key: string, value: ValueType): Promise\ | Writes data of the number, string, and Boolean types.| +| Preferences | put(key: string, value: ValueType): Promise\ | Writes data of the number, string, and Boolean types.| -**Reading Data** +### Reading Data -Call the **get()** method to read data from a **Storage** instance. +Call the **get()** method to read data from a **Preferences** instance. **Table 3** API for reading data | Class | API | Description | | ------- | ---------------------------------------------------------- | ----------------------------------------------- | -| Storage | get(key: string, defValue: ValueType): Promise\ | Reads data of the number, string, and Boolean types.| +| Preferences | get(key: string, defValue: ValueType): Promise\ | Reads data of the number, string, and Boolean types.| -**Storing Data Persistently** +### Storing Data Persistently Call the **flush()** method to write the cached data back to its text file for persistent storage. @@ -46,119 +46,120 @@ Call the **flush()** method to write the cached data back to its text file for p | Class | API | Description | | ------- | ----------------------- | --------------------------------------- | -| Storage | flush(): Promise\ | Writes data in the **Storage** instance back to its file through an asynchronous thread.| +| Preferences | flush(): Promise\ | Writes data from the **Preferences** instance back to its file through an asynchronous thread.| -**Observing Data Changes** +### Observing Data Changes -Specify **StorageObserver** as the callback to subscribe to data changes. When the value of the subscribed key is changed and the **flush()** method is executed, **StorageObserver** will be invoked. +You can subscribe to data changes. When the value of the subscribed key is changed by **flush()**, a callback will be invoked to return the new data. -**Table 5** APIs for observing data changes +**Table 5** APIs for observing **Preferences** changes | Class | API | Description | | ------- | ------------------------------------------------------------ | -------------- | -| Storage | on(type: 'change', callback: Callback\): void | Subscribe to data changes.| -| Storage | off(type: 'change', callback: Callback\): void | Unsubscribes from data changes. | +| Preferences | on(type: 'change', callback: Callback<{ key : string }>): void | Subscribes to data changes.| +| Preferences | off(type: 'change', callback: Callback<{ key : string }>): void | Unsubscribes from data changes. | -**Deleting Data** +### Deleting Data -Use the following APIs to delete a **Storage** instance or data file. +Use the following APIs to delete a **Preferences** instance or data file. -**Table 6** APIs for deleting data +**Table 6** APIs for deleting **Preferences** | Package | API | Description | | ----------------- | ---------------------------------------------------- | ------------------------------------------------------------ | -| ohos.data.storage | deleteStorage(path: string): Promise\ | Deletes a **Storage** instance from the cache and deletes its file from the device.| -| ohos.data.storage | removeStorageFromCache(path: string): Promise\ | Deletes a **Storage** instance from the cache to release memory. | +| ohos.data.preferences | deletePreferences(context: Context, name: string): Promise; | Deletes a **Preferences** instance from the cache and deletes its file from the device.| +| ohos.data.preferences | removePreferencesFromCache(context: Context, name: string): Promise\; | Removes a **Preferences** instance from the memory to release memory. ## How to Develop -1. Import @ohos.data.storage and related modules to the development environment. +1. Import @ohos.data.preferences and related modules to the development environment. ```js - import dataStorage from '@ohos.data.storage' - import featureAbility from '@ohos.ability.featureAbility' // Used to obtain the file storage path. + import data_preferences from '@ohos.data.preferences' ``` -2. Create a **Storage** instance. +2. Create a **Preferences** instance. - Read the specified file and load its data to the **Storage** instance for data operations. + Read the specified file and load its data to the **Preferences** instance for data operations. ```js - var context = featureAbility.getContext() - context.getFilesDir().then(() => { - console.info("======================>getFilesDirPromsie====================>"); - }); - - let promise = dataStorage.getStorage(path + '/mystore') + let promise = data_preferences.getPreferences(this.context, 'mystore') ``` 3. Write data. - Use the **put()** method of the **Storage** class to write data to the cached **Storage** instance. + Use the **put()** method of the **Preferences** class to write data to the cached **Preferences** instance. ```js - promise.then((storage) => { - let getPromise = storage.put('startup', 'auto') // Save data to the Storage instance. + promise.then((preferences) => { + let getPromise = preferences.put('startup', 'auto') getPromise.then(() => { console.info("Put the value of startup successfully.") }).catch((err) => { - console.info("Put the value of startup failed with err: " + err) + console.info("Failed to put the value of startup with err: " + err) }) }).catch((err) => { - console.info("Get the storage failed") + console.info("Failed to get the preferences") }) ``` 4. Read data. - Use the **get()** method of the **Storage** class to read data. + Use the **get()** method of the **Preferences** class to read data. ```js - promise.then((storage) => { - let getPromise = storage.get('startup', 'default') + promise.then((preferences) => { + let getPromise = preferences.get('startup', 'default') getPromise.then((value) => { console.info("The value of startup is " + value) }).catch((err) => { - console.info("Get the value of startup failed with err: " + err) + console.info("Failed to get the value of startup with err: " + err) }) }).catch((err) => { - console.info("Get the storage failed")}) + console.info("Failed to get the preferences")}) ``` 5. Store data persistently. - Use the **flush()** or **flushSync()** method to flush data in the **Storage** instance to its file. + Use the **flush()** method to flush data from the **Preferences** instance to its file. ```js - storage.flush(); + preferences.flush(); ``` -6. Observe data changes. +6. Observe data changes. - Specify **StorageObserver** as the callback to subscribe to data changes for an application. When the value of the subscribed key is changed and the **flush()** method is executed, **StorageObserver** will be invoked. Unregister the **StorageObserver** when it is no longer required. + Specify an observer as the callback to subscribe to data changes for an application. When the value of the subscribed key is changed and the **flush()** method is executed, the observe callback will be invoked to return the change. ```js - promise.then((storage) => { - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - storage.on('change', observer) - storage.putSync('startup', 'auto') // Modify data in the Storage instance. - storage.flushSync() // Trigger the StorageObserver callback. - - storage.off(...change..., observer) // Unsubscribe from the data changes. - }).catch((err) => { - console.info("Get the storage failed") - }) + var observer = function (key) { + console.info("The key of " + key + " changed.") + } + preferences.on('change', observer) + preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Failed to put the value of startup with err: " + err) + return + } + console.info("Put the value of startup successfully.") + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file with err: " + err) + return + } + console.info("Flushed to file successfully.") // Observer will be called. + }) + }) ``` 7. Delete the specified file. - Use the **deleteStorage** method to delete the **Storage** singleton of the specified file from the memory, and delete the specified file, its backup file, and damaged files. After the specified files are deleted, the application cannot use that instance to perform any data operation. Otherwise, data inconsistency will occur. The deleted data and files cannot be restored. + Use the **deletePreferences** method to delete the **Preferences** singleton of the specified file from the memory, and delete the specified file, its backup file, and corrupted files. After the specified files are deleted, the application cannot use that instance to perform any data operation. Otherwise, data inconsistency will occur. The deleted data and files cannot be restored. ```js - let promise = dataStorage.deleteStorage(path + '/mystore') - promise.then(() => { - console.info("Deleted successfully.") - }).catch((err) => { - console.info("Deleted failed with err: " + err)}) + let proDelete = data_preferences.deletePreferences(context, 'mystore') + proDelete.then(() => { + console.info("Data deleted successfully.") + }).catch((err) => { + console.info("Failed to delete data with err: " + err) + }) ``` diff --git a/en/application-dev/database/database-preference-overview.md b/en/application-dev/database/database-preference-overview.md index 45639c75e8ad5d1b3f68c79da90fbc598af7e840..b26943b6109818b1ca9d74038f9df4471f69531e 100644 --- a/en/application-dev/database/database-preference-overview.md +++ b/en/application-dev/database/database-preference-overview.md @@ -1,31 +1,29 @@ -# Lightweight Data Store Overview +# Preferences Overview -Lightweight data store is applicable to access and persistence operations on the data in key-value pairs. When an application accesses a lightweight **Storage** instance, data in the **Storage** instance will be cached in the memory for faster access. The cached data can also be written back to the text file for persistent storage. Since file read and write consume system resources, you are advised to minimize the frequency of reading and writing persistent files. +Preferences are used for access and persistence operations on the data in the key-value structure. When an application accesses a **Preferences** instance, the data in the instance will be cached in the memory for faster access. The cached data can also be written back to the text file for persistent storage. Since file read and write consume system resources, you are advised to minimize the frequency of reading and writing persistent files. -## Basic Concepts +## Basic Concepts -- **Key-Value data structure** +- **Key-value data structure** - A type of data structure. The key is the unique identifier for a piece of data, and the value is the specific data being identified. + A type of data structure. The key is the unique identifier for a piece of data, and the value is the specific data being identified. -- **Non-relational database** +- **Non-relational database** - A database not in compliance with the atomicity, consistency, isolation, and durability \(ACID\) database management properties of relational data transactions. The data in a non-relational database is independent. + A database not in compliance with the atomicity, consistency, isolation, and durability (ACID) database management properties of relational data transactions. The data in a non-relational database is independent. +## Working Principles -## Working Principles +When an application loads data from a **Preferences** file to a **Preferences** instance, the system stores the instance in the memory through a static container. Each file of an application or process has only one **Preferences** instance in the memory, till the application removes the instance from the memory or deletes the **Preferences** file. -1. When an application loads data from a specified **Storage** file to a **Storage** instance, the system stores the instance in the memory through a static container. Each file of an application or process has only one **Storage** instance in the memory, till the application removes the instance from the memory or deletes the **Storage** file. -2. When obtaining a **Storage** instance, the application can read data from or write data to the instance. The data in the **Storage** instance can be flushed to its **Storage** file by calling the **flush** or **flushSync** method. +When obtaining a **Preferences** instance, the application can read data from or write data to the instance. The data in the instance can be flushed to its **Preferences** file by calling the **flush()** method. -**Figure 1** How lightweight data store works +**Figure 1** How **Preferences** work +![](figures/preferences.png) -![](figures/en-us_image_0000001199139454.png) - -## Constraints - -- **Storage** instances are loaded to the memory. To minimize non-memory overhead, the number of data records stored in a **Storage** instance cannot exceed 10,000. Delete the instances that are no longer used in a timely manner. -- The key in the key-value pairs is of the string type. It cannot be empty or exceed 80 characters. -- If the value in the key-value pairs is of the string type, it can be empty or contain a maximum of 8192 characters. +## Constraints +- **Preferences** instances are loaded to the memory. To minimize non-memory overhead, the number of data records stored in a **Preferences** instance cannot exceed 10,000. Delete the instances that are no longer used in a timely manner. +- The key in key-value pairs is of the string type. It cannot be empty or exceed 80 bytes. +- The value of the string type in key-value pairs can be empty, but cannot exceed 8192 bytes if not empty. diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index d23f0c0c5735f5fdd91b16f67705af26523ca550..d43b11ff62e73d65de6d77623641b7748a82c824 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -116,8 +116,8 @@ The RDB provides **RdbPredicates** for you to set database operation conditions. A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**. -> ![icon-notice.gif](../public_sys-resources/icon-notice.gif) **NOTICE**
-> After a result set is used, you must call the **close()** method to close it explicitly.** +> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**
+> After a result set is used, you must call the **close()** method to close it explicitly. **Table 7** APIs for using the result set @@ -306,3 +306,8 @@ You can obtain the distributed table name for a remote device based on the local let tableName = rdbStore.obtainDistributedTableName(deviceId, "test"); let resultSet = rdbStore.querySql("SELECT * FROM " + tableName) ``` +## Samples +The following samples are provided for you to better understand the RDB development: +- [`Rdb`: eTS RDB (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Rdb) +- [`DistributedRdb`: eTS Distributed Relational Database (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedRdb) +- [Relational Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData) diff --git a/en/application-dev/database/figures/en-us_image_0000001199139454.png b/en/application-dev/database/figures/en-us_image_0000001199139454.png deleted file mode 100644 index ca52bd43d384c5b2d06fe19623b50e0c66ba6295..0000000000000000000000000000000000000000 Binary files a/en/application-dev/database/figures/en-us_image_0000001199139454.png and /dev/null differ diff --git a/en/application-dev/database/figures/preferences.png b/en/application-dev/database/figures/preferences.png new file mode 100644 index 0000000000000000000000000000000000000000..ab91e2d4fb3019ca3f48a195041c9b19bdaec830 Binary files /dev/null and b/en/application-dev/database/figures/preferences.png differ diff --git a/en/application-dev/device/Readme-EN.md b/en/application-dev/device/Readme-EN.md index f77f56a5cab3c2d3765762fe6790566405e9c119..41f8cf0de280706eff7ae88c051d50d18630f173 100644 --- a/en/application-dev/device/Readme-EN.md +++ b/en/application-dev/device/Readme-EN.md @@ -13,3 +13,6 @@ - Vibrator - [Vibrator Overview](vibrator-overview.md) - [Vibrator Development](vibrator-guidelines.md) +- Update Servcie + - [Sample Server Overview](sample-server-overview.md) + - [Sample Server Development](sample-server-guidelines.md) diff --git a/en/application-dev/device/sample-server-guidelines.md b/en/application-dev/device/sample-server-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..c957c109caf505ba90686d62e7ca3d1b9ab8f89a --- /dev/null +++ b/en/application-dev/device/sample-server-guidelines.md @@ -0,0 +1,198 @@ +# Sample Server Development + +## When to Use + +The sample server provides a package search server for checking update packages and obtaining the update package download URLs, which was previously unavailable in the real-world update service. The sample server supports update service testing and secondary development function verification, building an end-to-end environment to cater for diverse update service use cases. + +## How to Develop + +1. Generate an SSL certificate. + + Generate the **serverKey.pem** and **serverCert.cer** files for SSL communication of the sample server. + + ``` + openssl req -newkey rsa:2048 -nodes -keyout serverKey.pem -x509 -days 365 -out serverCert.cer -subj "/C=CN/ST=GD/L=GZ/O=abc/OU=defg/CN=hijk/emailAddress=test.com" + ``` + + + +2. Modify the **bundle.json** file. + + Add **sub_component** to the **build** field. + + ``` + "sub_component": [ + "//base/update/updateservice/server_sample:testserver", + ... + ], + ``` + +3. Create a code directory. + + Go to the **update_updateservice** directory and run the following commands to create a code directory: + + ``` + mkdir server_sample // Create the server_sample folder. + touch server_sample/BUILD.gn // Create the BUILD.gn file. + mkdir server_sample/include // Create the include folder to store the header file of the sample server. + touch server_process.h // Create the server_process.h header file. + mkdir server_sample/src // Create the src folder to store the C/C++ files of the sample server. + touch server_sample/src/server_process.c // Create the server_process.c file. + touch server_sample/src/main.cpp // Create the main.cpp file. + ``` + +4. Write the **BUILD.gn** file. + + The **BUILD.gn** file contains two **ohos** components: **ohos_shared_library** file named **libserver_process.z.so** and **ohos_executable** file named **testserver**. + + ``` + import("//build/ohos.gni") + + ohos_shared_library("server_process") { + sources = [ + "//base/update/updateservice/server_sample/src/server_process.c", + ] + + include_dirs = [ + "//base/update/updateservice/server_sample/include", + "//third_party/openssl/include", + ] + + deps = [ + "//base/update/updater/services/log:libupdaterlog", + "//third_party/bounds_checking_function:libsec_static", + "//third_party/openssl:crypto_source", + "//third_party/openssl:ssl_source", + "//utils/native/base:utils", + ] + + part_name = "update_service" + } + + ohos_executable("testserver") { + sources = [ + "//base/update/updateservice/server_sample/src/main.cpp", + ] + + include_dirs = [ + "//base/update/updateservice/server_sample/include", + ] + + deps = [ + "//base/update/updateservice/server_sample:server_process", + ] + + part_name = "update_service" + } + ``` + +5. Write the **server_process.h** file. + + Declare the sample server APIs in the **server_process.h** file. + + ```c++ + #ifndef __SERVER_PROCESS_H__ + #define __SERVER_PROCESS_H__ + + /* + Init: creates a socket environment and presets certain attributes. + */ + int Init(); + + /* + SetParam: sets all plug-in parameters. + */ + int SetParam(const char *key, const char *value); + + /* + GetParam: obtains all plug-in parameters. + */ + int GetParam(const char *key, char *value); + + /* + ReverseSetParamCallback: callback. + */ + int ReverseSetParamCallback(int(*setParam)(const char *key, const char *value)); + + /* + Open: starts the service. + */ + int Open(); + + /* + MainLoop: invoked every 100 ms. + */ + int MainLoop(); + + /* + Close: stops the service and releases related resources. + */ + int Close(); + + #endif //__SERVER_PROCESS_H__ + ``` + +6. Write the **server_process.c** and **main.cpp** files. + + In the **server_process.c** file, mainly declare **respondContent**, the format of the response message returned by the server. Write the **main.cpp** file based on instructions for the common SSL protocol server. Be sure to include related header files and load the **serverKey.pem** and **serverCert.cer** files. + + ```c + #include "server_process.h" + + #include + #include + #include + #include + #include + #include + #include + #include + + #include "openssl/err.h" + #include "openssl/ssl.h" + + #define SERVER_PEM "/data/sdcard/serverKey.pem" // Use an absolute path. + #define SERVER_CER "/data/sdcard/serverCert.cer" // Use an absolute path. + + #define LOG_PRINT(fmt, ...) printf("[ServerProcess][%s:%d] " fmt "\n", __func__, __LINE__, ##__VA_ARGS__) + #define DO_CHECK(cond, log, ...) \ + if (!(cond)) {\ + LOG_PRINT(log);\ + __VA_ARGS__;\ + return -1;\ + } + + // Implement the function by referring to the APIs in the server_process.h file. Pay attention to the format of the response message from the server. + respondContent = "{" + "\"searchStatus\": 0," + "\"errMsg\": \"success\"," + "\"checkResults\": [{" + "\"versionName\": \"sampleVersionName\"," + "\"versionCode\": \"sampleVersionCode\"," + "\"verifyInfo\": \"sampleVerifyInfoSha256Value\"," + "\"size\": 1234567," + "\"packageType\": 1," + "\"descriptPackageId\": \"abcdefg1234567ABCDEFG\"," + "}]," + "\"descriptInfo\": [{" + "\"descriptPackageId\": \"abcdefg1234567ABCDEFG\"," + "\"content\": \"This package message is used for sampleContent\"" + "}]" + "}"; + ``` + +7. Start building. + + The **testserver** and **libserver_process.z.so** files are added to the build output directory. + +8. Develop an update package. + + For details, see the [update_packaging_tools repository](https://gitee.com/openharmony/update_packaging_tools). + +9. Start the package search server. + + Create a directory that contains only English characters on the development board. Place the **testserver**, **libserver_process.z.so**, **serverCert.cer**, and **serverKey.pem** files in the directory, go to the directory, and run the following command to start the package search server: + + ``` + ./testserver ./libserver_process.z.so & + ``` diff --git a/en/application-dev/device/sample-server-overview.md b/en/application-dev/device/sample-server-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..6924f8d7f2256dff9ec828cc5fb62248f68599f1 --- /dev/null +++ b/en/application-dev/device/sample-server-overview.md @@ -0,0 +1,37 @@ +# Sample Server Overview + +The sample server provides a simple server instance for deploying update packages. It can be used as an auxiliary test environment for the UpdateService subsystem. + +## Basic Concepts + +- Package search service: one of the service capabilities provided by the UpdateService. It depends on the server that supports the TCP and SSL protocols. + +- Package search server: a server that provisions the package search service through the TCP connection and the SSL protocol. The sample server mentioned in this document is such a package search server. + +- Download server: an HTTP server. + +- update.serverip.search: a system parameter that indicates the IP address of the package search server configured on the UpdateService. The default value is **127.0.0.1**. + +## Constraints + +The following is an example of the JSON response returned by the server. Note that the **verifyInfo** field indicates the SHA-256 value of the update package, and the **size** field indicates the size of the update package, in bytes. + +```json +{ + "searchStatus": 0, + "errMsg": "success", + "checkResults": [{ + "versionName": "versionNameSample", + "versionCode": "versionCodeSample", + "verifyInfo": "verifyInfoSHA256Value1234567", + "size": 1234567, + "packageType": 1, + "url": "http://serverAddressSample/packageNameSample.fileTypeSample", + "descriptPackageId": "abcdefg1234567ABCDEFG" + }], + "descriptInfo": [{ + "descriptPackageId": "abcdefg1234567ABCDEFG", + "content": "This package is used for update." + }] +} +``` diff --git a/en/application-dev/device/vibrator-guidelines.md b/en/application-dev/device/vibrator-guidelines.md index b1d7f7c42bf05cbf616742d63351dd5bc542b50a..f0eb8c5f896ae881550aeae85759692fd052c2ce 100644 --- a/en/application-dev/device/vibrator-guidelines.md +++ b/en/application-dev/device/vibrator-guidelines.md @@ -20,38 +20,38 @@ You can set different vibration effects as needed, for example, customizing the ## How to Develop -1. Declare the permissions required for controlling vibrators on the hardware device in the **config.json** file. +1. Declare the permissions required for controlling vibrators on the hardware device in the `config.json` file. ``` - "reqPermissions":[ + "reqPermissions": [ { - "name":"ohos.permission.ACCELEROMETER", - "reason"":"", - "usedScene":{ - "ability""[ - ".MainAbility" + "name": "ohos.permission.ACCELEROMETER", + "reason": "", + "usedScene": { + "ability": [ + ".MainAbility" ], - "when":"inuse" + "when": "inuse" } }, { - "name":"ohos.permission.VIBRATE", - "reason"":"", - "usedScene":{ - "ability""[ - ".MainAbility" + "name": "ohos.permission.VIBRATE", + "reason": "", + "usedScene": { + "ability": [ + ".MainAbility" ], - "when":"inuse" + "when": "inuse" } }, { - "name":"ohos.permission.ACTIVITY_MOTION", - "reason"":"", - "usedScene":{ - "ability""[ - ".MainAbility" + "name": "ohos.permission.ACTIVITY_MOTION", + "reason": "", + "usedScene": { + "ability": [ + ".MainAbility" ], - "when":"inuse" + "when": "inuse" } }, ] @@ -77,7 +77,7 @@ You can set different vibration effects as needed, for example, customizing the vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then((error)=>{ if(error){ // The call fails, and error.code and error.message are printed. Console.log("Promise return failed.error.code"+error.code+"error.message"+error.message); - }else{ // The call is successful, and the device stops vibration. + }else{ // The call is successful, and the device stops vibrating. Console.log("Promise returned to indicate a successful stop."); }; }) diff --git a/en/application-dev/dfx/hiappevent-guidelines.md b/en/application-dev/dfx/hiappevent-guidelines.md index 17c599878816756cdf40f2dd3791dde61ed2ea00..b4d267de31436a70061f5f97e4bbd9b739006328 100644 --- a/en/application-dev/dfx/hiappevent-guidelines.md +++ b/en/application-dev/dfx/hiappevent-guidelines.md @@ -75,4 +75,4 @@ In this example, an application event is logged after the application startup ex The following sample is provided to help you better understand how to develop the application event logging feature: -- [`JsDotTest`: Event Logging Test (JavaScript) (API 7)](https://gitee.com/openharmony/app_samples/tree/master/DFX/JsDotTest) +- [`JsDotTest`: Event Logging Test (JavaScript) (API 8)](https://gitee.com/openharmony/app_samples/tree/master/DFX/JsDotTest) diff --git a/en/application-dev/internationalization/i18n-guidelines.md b/en/application-dev/internationalization/i18n-guidelines.md index 1be7b7dff8fe59b423fa2766b81dc6c164aeec31..4b1d2c4998f74700553127216fe48354d13dce6a 100644 --- a/en/application-dev/internationalization/i18n-guidelines.md +++ b/en/application-dev/internationalization/i18n-guidelines.md @@ -9,7 +9,7 @@ APIs are provided to access the system language and region information. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.i18n | getSystemLanguage(): string | Obtains the system language. | | ohos.i18n | getSystemRegion(): string | Obtains the system region. | @@ -22,7 +22,7 @@ APIs are provided to access the system language and region information. ### How to Develop -1. Obtain the system language. +1. Obtain the system language.
Call the **getSystemLanguage** method to obtain the system language (**i18n** is the name of the imported module). @@ -30,21 +30,21 @@ APIs are provided to access the system language and region information. var language = i18n.getSystemLanguage(); ``` -2. Obtains the system region. +2. Obtain the system region.
Call the **getSystemRegion** method to obtain the system region. ``` var region = i18n.getSystemRegion(); ``` -3. Obtain the system locale. +3. Obtain the system locale.
Call the **getSystemLocale** method to obtain the system locale. ``` var locale = i18n.getSystemLocale(); ``` -4. Check whether the locale's language is RTL. +4. Check whether the locale's language is RTL.
Call the **isRTL** method to check whether the locale's language is RTL. @@ -52,15 +52,15 @@ APIs are provided to access the system language and region information. var rtl = i18n.isRTL("zh-CN"); ``` -5. Check whether the system uses a 24-hour clock. - Call the **is24HourClock** method to check whether the system uses a 24-hour clock. +5. Check whether the system uses a 24-hour clock.
+ Call the **is24HourClock** method to check whether the system uses a 24-hour clock. ``` var hourClock = i18n.is24HourClock(); ``` -6. Obtain the localized display of a language. - Call the **getDisplayLanguage** method to obtain the localized display of a language. **language** indicates the language to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. +6. Obtain the localized display of a language.
+ Call the **getDisplayLanguage** method to obtain the localized display of a language. **language** indicates the language to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. ``` var language = "en"; @@ -69,8 +69,8 @@ APIs are provided to access the system language and region information. var localizedLanguage = i18n.getDisplayLanguage(language, locale, sentenceCase); ``` -7. Obtain the localized display of a country. - Call the **getDisplayCountry** method to obtain the localized display of a country. **country** indicates the country to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. +7. Obtain the localized display of a country.
+ Call the **getDisplayCountry** method to obtain the localized display of a country. **country** indicates the country to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. ``` var country = "US"; @@ -105,7 +105,7 @@ APIs are provided to access the system language and region information. ### How to Develop -1. Instantiate a **Calendar** object. +1. Instantiate a **Calendar** object.
Call the **getCalendar** method to obtain the time zone object of a specific locale and type (**i18n** is the name of the imported module). **type** indicates the valid calendar type, for example, **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic_civil**, **islamic_tbla**, **islamic_umalqura**, **japanese**, and **persian**. If **type** is left unspecified, the default calendar type of the locale is used. @@ -113,8 +113,8 @@ APIs are provided to access the system language and region information. var calendar = i18n.getCalendar("zh-CN", "gregory); ``` -2. Set the time for the **Calendar** object. - Call the **setTime** method to set the time of the **Calendar** object. This method receives two types of parameters. One is a **Date** object, and the other is a value indicating the number of milliseconds elapsed since January 1, 1970, 00:00:00 GMT. +2. Set the time for the **Calendar** object.
+ Call the **setTime** method to set the time of the **Calendar** object. This method receives two types of parameters. One is a **Date** object, and the other is a value indicating the number of milliseconds elapsed since January 1, 1970, 00:00:00 GMT. ``` var date1 = new Date(); @@ -123,14 +123,14 @@ APIs are provided to access the system language and region information. calendar.setTime(date2); ``` -3. Set the year, month, day, hour, minute, and second for the **Calendar** object. - Call the **set** method to set the year, month, day, hour, minute, and second for the **Calendar** object. +3. Set the year, month, day, hour, minute, and second for the **Calendar** object.
+ Call the **set** method to set the year, month, day, hour, minute, and second for the **Calendar** object. ``` calendar.set(2021, 12, 21, 6, 0, 0) ``` -4. Set and obtain the time zone for the **Calendar** object. +4. Set and obtain the time zone for the **Calendar** object.
Call the **setTimeZone** and **getTimeZone** methods to set and obtain the time zone for the **Calendar** object. The **setTimeZone** method requires an input string to indicate the time zone to be set. @@ -139,7 +139,7 @@ APIs are provided to access the system language and region information. var timezone = calendar.getTimeZone(); ``` -5. Set and obtain the first day of a week for the **Calendar** object. +5. Set and obtain the first day of a week for the **Calendar** object.
Call the **setFirstDayOfWeek** and **getFirstDayOfWeek** methods to set and obtain the first day of a week for the **Calendar** object. **setFirstDayOfWeek** must be set to a value indicating the first day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday. @@ -148,15 +148,15 @@ APIs are provided to access the system language and region information. var firstDayOfWeek = calendar.getFirstDayOfWeek(); ``` -6. Set and obtain the minimum count of days in the first week for the **Calendar** object. - Call the **setMinimalDaysInFirstWeek** and **getMinimalDaysInFirstWeek** methods to set and obtain the minimum count of days in the first week for the **Calendar** object. +6. Set and obtain the minimum count of days in the first week for the **Calendar** object.
+ Call the **setMinimalDaysInFirstWeek** and **getMinimalDaysInFirstWeek** methods to set and obtain the minimum count of days in the first week for the **Calendar** object. ``` calendar.setMinimalDaysInFirstWeek(3); var minimalDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek(); ``` -7. Obtain the localized display of the **Calendar** object. +7. Obtain the localized display of the **Calendar** object.
Call the **getDisplayName** method to obtain the localized display of the **Calendar** object. @@ -164,7 +164,7 @@ APIs are provided to access the system language and region information. var localizedName = calendar.getDisplayName("zh-CN"); ``` -8. Check whether a date is a weekend. +8. Check whether a date is a weekend.
Call the **isWeekend** method to determine whether the input date is a weekend. @@ -181,7 +181,7 @@ APIs are provided to access the system language and region information. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.i18n | constructor(country: string, options?: PhoneNumberFormatOptions)8+ | Instantiates a **PhoneNumberFormat** object. | | ohos.i18n | isValidNumber(number: string): boolean8+ | Checks whether the value of **number** is a phone number in the correct format. | @@ -190,7 +190,7 @@ APIs are provided to access the system language and region information. ### How to Develop -1. Instantiate a **PhoneNumberFormat** object. +1. Instantiate a **PhoneNumberFormat** object.
Call the **PhoneNumberFormat** constructor to instantiate a **PhoneNumberFormat** object. The country code and formatting options of the phone number need to be passed into this constructor. The formatting options are optional, including a style option. Values of this option include: **E164**, **INTERNATIONAL**, **NATIONAL**, and **RFC3966**. @@ -199,14 +199,14 @@ APIs are provided to access the system language and region information. ``` 2. Check whether the phone number format is correct. - Call the **isValidNumber** method to check whether the format of the input phone number is correct. + Call the **isValidNumber** method to check whether the format of the input phone number is correct. ``` var validNumber = phoneNumberFormat.isValidNumber("15812341234"); ``` 3. Format a phone number. - Call the **format** method of **PhoneNumberFormat** to format the input phone number. + Call the **format** method of **PhoneNumberFormat** to format the input phone number. ``` var formattedNumber = phoneNumberFormat.format("15812341234"); @@ -258,7 +258,7 @@ An API can be called to implement measurement conversion. ### How to Develop -1. Instantiate an **IndexUtil** object. +1. Instantiate an **IndexUtil** object.
Call the **getInstance** method to instantiate an **IndexUtil** object for a specific locale. When the **locale** parameter is empty, instantiate an **IndexUtil** object of the default locale. @@ -266,22 +266,22 @@ An API can be called to implement measurement conversion. var indexUtil = getInstance("zh-CN"); ``` -2. Obtain the index list. - Call the **getIndexList** method to obtain the alphabet index list of the current locale. +2. Obtain the index list.
+ Call the **getIndexList** method to obtain the alphabet index list of the current locale. ``` var indexList = indexUtil.getIndexList(); ``` -3. Add an index. - Call the **addLocale** method to add the alphabet index of a new locale to the current index list. +3. Add an index.
+ Call the **addLocale** method to add the alphabet index of a new locale to the current index list. ``` indexUtil.addLocale("ar") ``` -4. Obtain the index of a string. - Call the **getIndex** method to obtain the alphabet index of a string. +4. Obtain the index of a string.
+ Call the **getIndex** method to obtain the alphabet index of a string. ``` var text = "access index"; @@ -312,7 +312,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api ### How to Develop -1. Instantiate a **BreakIterator** object. +1. Instantiate a **BreakIterator** object.
Call the **getLineInstance** method to instantiate a **BreakIterator** object. @@ -321,7 +321,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api var breakIterator = i18n.getLineInstance(locale); ``` -2. Set and access the text that requires line breaking. +2. Set and access the text that requires line breaking.
Call the **setLineBreakText** and **getLineBreakText** methods to set and access the text that requires line breaking. @@ -331,7 +331,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api var breakText = breakIterator.getLineBreakText(); ``` -3. Obtain the current position of the **BreakIterator** object. +3. Obtain the current position of the **BreakIterator** object.
Call the **current** method to obtain the current position of the **BreakIterator** object in the text being processed. @@ -339,7 +339,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api var pos = breakIterator.current(); ``` -4. Set the position of a **BreakIterator** object. +4. Set the position of a **BreakIterator** object.
The following APIs are provided to adjust the **first**, **last**, **next**, **previous**, or **following** position of the **BreakIterator** object in the text to be processed. @@ -355,7 +355,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api var followingPos = breakIterator.following(10); ``` -5. Determine whether a position is a break point. +5. Determine whether a position is a break point.
Call the **isBoundary** method to determine whether a position is a break point. If yes, **true** is returned and the **BreakIterator** object is moved to this position. If no, **false** is returned and the **BreakIterator** object is moved to a break point after this position. diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md index 76c00eb557816681efb54e9e7ec5d0a3754471b6..a27df95ea9c9657c30401b1fd1ad9d9b21d77fca 100644 --- a/en/application-dev/internationalization/intl-guidelines.md +++ b/en/application-dev/internationalization/intl-guidelines.md @@ -2,14 +2,17 @@ This development guide describes how to use i18n APIs that are defined in ECMA 402. +> **NOTE**
+> In the code snippets in this document, **intl** refers to the name of the imported module. + ## Setting Locale Information -[Locale](../reference/apis/js-apis-intl.md) APIs are used to maximize or minimize locale information. +Use [Locale](../reference/apis/js-apis-intl.md) APIs to maximize or minimize locale information. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Instantiates a **Locale** object. | | ohos.intl | constructor(locale?: string, options?: options) | Instantiates a **Locale** object based on the locale parameter and options. | @@ -20,8 +23,8 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ### How to Develop -1. Instantiate a **Locale** object. - Create a **Locale** object using the **Locale** constructor. This method receives a string representing the locale and an optional [Attributes](../reference/apis/js-apis-intl.md) list (**intl** is the name of the imported module). +1. Instantiate a **Locale** object.
+ Create a **Locale** object by using the **Locale** constructor. This method receives a string representing the locale and an optional [Attributes](../reference/apis/js-apis-intl.md) list. ``` @@ -30,22 +33,22 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 var localeObj = new intl.Locale(locale, options); ``` -2. Obtain the string representing a **Locale** object. - Call the **toString** method to obtain the string representing a **Locale** object, including the language, region, and other options. +2. Obtain the string representing a **Locale** object.
+ Call the **toString** method to obtain the string representing a **Locale** object, which includes the language, region, and other options. ``` var localeStr = localeObj.toString(); ``` -3. Maximize locale information. - Call the **maximize** method to maximize locale information; that is, supplement the missing script and region information. +3. Maximize locale information.
+ Call the **maximize** method to maximize locale information; that is, supplement the missing script and region information. ``` var maximizedLocale = localeObj.maximize(); ``` -4. Minimize locale information. - Call the **minimize** method to minimize locale information; that is, delete the unnecessary script and region information. +4. Minimize locale information.
+ Call the **minimize** method to minimize locale information; that is, delete the unnecessary script and region information. ``` var minimizedLocale = localeObj.minimize(); @@ -54,12 +57,12 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ## Formatting the Date and Time -[DateTimeFormat](../reference/apis/js-apis-intl.md) APIs are used to format the date and time for a specific locale. +Use [DateTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the date and time for a specific locale. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Creates a **DateTimeFormat** object. | | ohos.intl | constructor(locale: string \| Array<string>, options?: DateTimeOptions) | Creates a **DateTimeFormat** object and sets the locale and other formatting-related attributes. | @@ -70,31 +73,31 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ### How to Develop -1. Instantiate a **DateTimeFormat** object. - Use the default constructor of **DateTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **DateTimeFormat** object (**intl** is the name of the imported module). +1. Instantiate a **DateTimeFormat** object.
+ Use the default constructor of **DateTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **DateTimeFormat** object. ``` var dateTimeFormat = new intl.DateTimeFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md). + Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md). ``` var options = {dateStyle: "full", timeStyle: "full"}; var dateTimeFormat = new intl.DateTimeFormat("zh-CN", options); ``` -2. Format the date and time. - Use the **format** method of **DateTimeFormat** to format a **Date** object. A string is returned as the formatting result. +2. Format the date and time.
+ Call the **format** method to format a **Date** object. This method returns a string representing the formatting result. ``` Date date = new Date(); var formatResult = dateTimeFormat.format(date); ``` -3. Format a period. - Use the **formatRange** method of **DateTimeFormat** to format a period. This method requires the input of two **Date** objects, which respectively indicate the start date and end date of a period. A string is returned as the formatting result. +3. Format a period.
+ Call the **formatRange** method to format a period. This method requires input of two **Date** objects, which respectively indicate the start date and end date of a period. This method returns a string representing the formatting result. ``` Date startDate = new Date(); @@ -102,8 +105,8 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 var formatResult = dateTimeFormat.formatRange(startDate, endDate); ``` -4. Access the attributes of the **DateTimeFormat** object. - The **resolvedOptions** method of **DateTimeFormat** returns an object that contains all related attributes and values of the **DateTimeFormat** object. +4. Obtain attributes of the **DateTimeFormat** object.
+ Call the **resolvedOptions** method to obtain attributes of the **DateTimeFormat** object. This method will return an array that contains all attributes and values of the object. ``` var options = dateTimeFormat.resolvedOptions(); @@ -112,46 +115,46 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ## Number Formatting -[NumberFormat](../reference/apis/js-apis-intl.md) APIs are used to format a number for a specific locale. +Use [NumberFormat](../reference/apis/js-apis-intl.md) APIs to format a number for a specific locale. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Creates a **NumberFormat** object. | | ohos.intl | constructor(locale: string \| Array<string>, options?: NumberOptions) | Creates a **NumberFormat** object and sets the locale and other formatting-related attributes. | | ohos.intl | format(number: number): string | Calculates the number based on the locale and other formatting-related attributes of the **NumberFormat** object. | -| ohos.intl | resolvedOptions(): NumberOptions | Obtains the attributes of the **NumberFormat** object. | +| ohos.intl | resolvedOptions(): NumberOptions | Obtains attributes of the **NumberFormat** object. | ### How to Develop -1. Instantiate a **NumberFormat** object. - Use the default constructor of **NumberFormat** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **NumberFormat** object (**intl** is the name of the imported module). +1. Instantiate a **NumberFormat** object.
+ Use the default constructor of **NumberFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **NumberFormat** object. ``` var numberFormat = new intl.NumberFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md). + Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md). ``` var options = {compactDisplay: "short", notation: "compact"}; var numberFormat = new intl.NumberFormat("zh-CN", options); ``` -2. Format a number. - Use the **format** method of **NumberFormat** to format a number. A string is returned as the formatting result. +2. Format a number.
+ Call the **format** method to format a number. A string is returned as the formatting result. ``` var number = 1234.5678 var formatResult = numberFormat.format(number); ``` -3. Access the attributes of the **NumberFormat** object. - The **resolvedOptions** method of NumberFormat returns an object that contains all related attributes and values of the **NumberFormat** object. +3. Obtain attributes of the **NumberFormat** object.
+ Call the **resolvedOptions** method to obtain attributes of the **NumberFormat** object. This method will return an array that contains all attributes and values of the object. ``` var options = numberFormat.resolvedOptions(); @@ -160,37 +163,37 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ## String Sorting -Users in different regions have different requirements for string sorting. [Collator](../reference/apis/js-apis-intl.md) APIs are used to sort strings based on a specific locale. +Use [Collator](../reference/apis/js-apis-intl.md) APIs to sort strings based on a specific locale. Users in different regions have different preferences for string sorting. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Creates a **Collator** object. | | ohos.intl | constructor(locale: string \| Array<string>, options?: CollatorOptions)8+ | Creates a **Collator** object and sets the locale and other related attributes. | | ohos.intl | compare(first: string, second: string): number8+ | Calculates the comparison result of two strings based on the locale and other attributes of the **Collator** object. | -| ohos.intl | resolvedOptions(): CollatorOptions8+ | Obtains the attributes of the **Collator** object. | +| ohos.intl | resolvedOptions(): CollatorOptions8+ | Obtains attributes of the **Collator** object. | ### How to Develop -1. Instantiate a **Collator** object. - Use the default constructor of **Collator** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **Collator** object (**intl** is the name of the imported module). +1. Instantiate a **Collator** object.
+ Use the default constructor of **Collator** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **Collator** object. ``` var collator = new intl.Collator(); ``` - Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md). + Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md). ``` var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"}; ``` -2. Compare two strings. - Use the **compare** method of **Collator** to compare two input strings. This method returns a value as the comparison result. The return value **-1** indicates that the first string is shorter than the second string, the return value **1** indicates that the first string is longer than the second string, and the return value **0** indicates that the two strings are of equal lengths. +2. Compare two strings.
+ Call the **compare** method to compare two input strings. This method returns a value as the comparison result. The return value **-1** indicates that the first string is shorter than the second string, the return value **1** indicates that the first string is longer than the second string, and the return value **0** indicates that the two strings are of equal lengths. ``` var str1 = "first string"; @@ -198,8 +201,8 @@ Users in different regions have different requirements for string sorting. [Coll var compareResult = collator.compare(str1, str2); ``` -3. Access the attributes of the **Collator** object. - The **resolvedOptions** method of **Collator** returns an object that contains all related attributes and values of the **Collator** object. +3. Obtain attributes of the **Collator** object.
+ Call the **resolvedOptions** method to obtain attributes of the **Collator** object. This method will return an array that contains all attributes and values of the object. ``` var options = collator.resolvedOptions(); @@ -208,12 +211,12 @@ Users in different regions have different requirements for string sorting. [Coll ## Determining the Singular-Plural Type -According to grammars in certain languages, the singular or plural form of a noun depends on the number prior to the noun. [PluralRules](../reference/apis/js-apis-intl.md) APIs are used to determine the singular-plural type for a specific locale. +Use [PluralRules](../reference/apis/js-apis-intl.md) APIs to determine the singular-plural type for a specific locale. According to the grammar of certain languages, the singular or plural form of a noun depends on its preceding number. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Creates a **PluralRules** object. | | ohos.intl | constructor(locale: string \| Array<string>, options?: PluralRulesOptions)8+ | Creates a **PluralRules** object and sets the locale and other related attributes. | @@ -222,22 +225,22 @@ According to grammars in certain languages, the singular or plural form of a nou ### How to Develop -1. Instantiate a **PluralRules** object. - Use the default constructor of **PluralRules** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **PluralRules** object (**intl** is the name of the imported module). +1. Instantiate a **PluralRules** object.
+ Use the default constructor of **PluralRules** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **PluralRules** object. ``` var pluralRules = new intl.PluralRules(); ``` - Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md). + Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md). ``` var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}; ``` -2. Determine the singular or plural category. - Use the **select** method of **PluralRules** to determine the singular-plural type for an input number. This method returns a string as the category of the input number, which can be any of the following: **zero**, **one**, **two**, **few**, **many**, and **other**. +2. Determine the singular-plural type.
+ Call the **select** method to determine the singular-plural type of an input number. This method will return a string representing the singular-plural type, which can be any of the following: **zero**, **one**, **two**, **few**, **many**, and **other**. ``` var number = 1234.5678 @@ -247,38 +250,38 @@ According to grammars in certain languages, the singular or plural form of a nou ## Formatting Relative Time -[RelativeTimeFormat](../reference/apis/js-apis-intl.md) APIs are used to format the relative time for a specific locale. +Use [RelativeTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the relative time for a specific locale. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Creates a **RelativeTimeFormat** object. | | ohos.intl | constructor(locale: string \| Array<string>, options?: RelativeTimeFormatInputOptions)8+ | Creates a **RelativeTimeFormat** object and sets the locale and other formatting-related attributes. | | ohos.intl | format(value: number, unit: string): string8+ | Calculates the relative time format based on the locale and other formatting-related attributes of the **RelativeTimeFormat** object. | | ohos.intl | formatToParts(value: number, unit: string): Array<object>8+ | Returns each part of the relative time format based on the locale and other formatting-related attributes of the **RelativeTimeFormat** object. | -| ohos.intl | resolvedOptions(): RelativeTimeFormatResolvedOptions8+ | Obtains the attributes of the **RelativeTimeFormat** object. | +| ohos.intl | resolvedOptions(): RelativeTimeFormatResolvedOptions8+ | Obtains attributes of the **RelativeTimeFormat** object. | ### How to Develop -1. Instantiate a **RelativeTimeFormat** object. - Use the default constructor of **RelativeTimeFormat** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **RelativeTimeFormat** object (**intl** is the name of the imported module). +1. Instantiate a **RelativeTimeFormat** object.
+ Use the default constructor of **RelativeTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **RelativeTimeFormat** object. ``` var relativeTimeFormat = new intl.RelativeTimeFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md). + Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md). ``` var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}; ``` -2. Format the relative time. - Use the **format** method of **RelativeTimeFormat** to format the relative time. This method receives a numeric value representing the time length and a string-form unit, like **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, and **second**. A string is returned as the formatting result. +2. Format the relative time.
+ Call the **format** method to format the relative time. This method receives a numeric value representing the time length and a string-form unit, like **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, and **second**. This method returns a string representing the formatting result. ``` var number = 2; @@ -286,8 +289,8 @@ According to grammars in certain languages, the singular or plural form of a nou var formatResult = relativeTimeFormat.format(number, unit); ``` -3. Obtain each part of the relative time format. - On obtaining each part of the relative time format, customize the relative time formatting result. +3. Obtain each part of the relative time format.
+ Upon obtaining each part of the relative time format, customize the relative time formatting result. ``` var number = 2; @@ -295,8 +298,8 @@ According to grammars in certain languages, the singular or plural form of a nou var formatResult = relativeTimeFormat.formatToParts(number, unit); ``` -4. Access the attributes of the **RelativeTimeFormat** object. - The **resolvedOptions** method of **RelativeTimeFormat** returns an object that contains all related attributes and values of the **RelativeTimeFormat** object. For a full list of attributes, see [ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md). +4. Obtain attributes of the **RelativeTimeFormat** object.
+ Call the **resolvedOptions** method to obtain attributes of the **RelativeTimeFormat** object. This method will return an array that contains all attributes and values of the object. For a full list of attributes, see [ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md). ``` var options = numberFormat.resolvedOptions(); @@ -306,4 +309,4 @@ According to grammars in certain languages, the singular or plural form of a nou The following sample is provided to help you better understand how to develop internationalization capabilities: --[`International`: Internationalization (JS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/International) +-[`International`: Internationalization (JS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/International) diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md index 926bb335311ed38323d8a481aa39c0b2047902c9..f4c117684b891c43b1dd94513420f6793f52d886 100755 --- a/en/application-dev/media/Readme-EN.md +++ b/en/application-dev/media/Readme-EN.md @@ -4,11 +4,10 @@ - [Audio Overview](audio-overview.md) - [Audio Playback Development](audio-playback.md) - - [Audio Recording Development](audio-recorder.md) - [Audio Rendering Development](audio-renderer.md) - - - [Audio Capture Development](audio-capturer) + - [Audio Capture Development](audio-capturer.md) + - [OpenSL ES Audio Playback Development](opensles-playback.md) - Video - [Video Playback Development](video-playback.md) diff --git a/en/application-dev/media/audio-playback.md b/en/application-dev/media/audio-playback.md index 085506f3c514624f8fd8a2a8526b149a8e0927a8..c8dabdf0bea89476f3ff9d81392d2d0d1ee4dc28 100644 --- a/en/application-dev/media/audio-playback.md +++ b/en/application-dev/media/audio-playback.md @@ -39,36 +39,36 @@ function printfDescription(obj) { // Set the player callbacks. function setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the dataLoad event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered. + audioPlayer.play(); // The play() API can be invoked only after the dataLoad event callback is complete. The play event callback is then triggered. }); - audioPlayer.on('play', () => { // Set the 'play' event callback. + audioPlayer.on('play', () => { // Set the play event callback. console.info('audio play success'); - audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback. + audioPlayer.pause(); // Trigger the pause event callback and pause the playback. }); - audioPlayer.on('pause', () => { // Set the 'pause' event callback. + audioPlayer.on('pause', () => { // Set the pause event callback. console.info('audio pause success'); - audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback. + audioPlayer.seek(5000); // Trigger the timeUpdate event callback, and seek to 5000 ms for playback. }); - audioPlayer.on('stop', () => { // Set the 'stop' event callback. + audioPlayer.on('stop', () => { // Set the stop event callback. console.info('audio stop success'); - audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song. + audioPlayer.reset(); // Trigger the reset event callback, and reconfigure the src attribute to switch to the next song. }); - audioPlayer.on('reset', () => { // Set the 'reset' event callback. + audioPlayer.on('reset', () => { // Set the reset event callback. console.info('audio reset success'); audioPlayer.release(); // Release the AudioPlayer resources. audioPlayer = undefined; }); - audioPlayer.on('timeUpdate', (seekDoneTime) => {// Set the 'timeUpdate' event callback. + audioPlayer.on('timeUpdate', (seekDoneTime) => {// Set the timeUpdate event callback. if (typeof(seekDoneTime) == 'undefined') { console.info('audio seek fail'); return; } console.info('audio seek success, and seek time is ' + seekDoneTime); - audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback. + audioPlayer.setVolume(0.5); // Trigger the volumeChange event callback. }); - audioPlayer.on('volumeChange', () => { // Set the 'volumeChange' event callback. + audioPlayer.on('volumeChange', () => { // Set the volumeChange event callback. console.info('audio volumeChange success'); audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode. if (typeof (arrlist) != 'undefined') { @@ -78,13 +78,13 @@ function setCallBack(audioPlayer) { } else { console.log(`audio getTrackDescription fail, error:${error.message}`); } - audioPlayer.stop(); // Trigger the 'stop' event callback to stop the playback. + audioPlayer.stop(); // Trigger the stop event callback to stop the playback. }); }); - audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. + audioPlayer.on('finish', () => { // Set the finish event callback, which is triggered when the playback is complete. console.info('audio play finish'); }); - audioPlayer.on('error', (error) => { // Set the 'error' event callback. + audioPlayer.on('error', (error) => { // Set the error event callback. console.info(`audio error called, errName is ${error.name}`); console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errMessage is ${error.message}`); @@ -92,22 +92,22 @@ function setCallBack(audioPlayer) { } async function audioPlayerDemo() { - // 1. Create an audioPlayer instance. + // 1. Create an AudioPlayer instance. let audioPlayer = media.createAudioPlayer(); setCallBack(audioPlayer); // Set the event callbacks. - // 2. Set the URI of the audio file selected by the user. + // 2. Set the URI of the audio file. let fdPath = 'fd://' // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); + console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + audioPlayer.src = fdPath; // Set the src attribute and trigger the dataLoad event callback. } ``` @@ -119,14 +119,14 @@ import fileIO from '@ohos.fileio' export class AudioDemo { // Set the player callbacks. setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the dataLoad event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. + audioPlayer.play(); // Call the play() API to start the playback and trigger the play event callback. }); - audioPlayer.on('play', () => { // Set the 'play' event callback. + audioPlayer.on('play', () => { // Set the play event callback. console.info('audio play success'); }); - audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. + audioPlayer.on('finish', () => { // Set the finish event callback, which is triggered when the playback is complete. console.info('audio play finish'); audioPlayer.release(); // Release the AudioPlayer resources. audioPlayer = undefined; @@ -141,13 +141,13 @@ export class AudioDemo { let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); + console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + audioPlayer.src = fdPath; // Set the src attribute and trigger the dataLoad event callback. } } ``` @@ -161,15 +161,15 @@ export class AudioDemo { // Set the player callbacks. private isNextMusic = false; setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the dataLoad event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. + audioPlayer.play(); // Call the play() API to start the playback and trigger the play event callback. }); - audioPlayer.on('play', () => { // Set the 'play' event callback. + audioPlayer.on('play', () => { // Set the play event callback. console.info('audio play success'); - audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback. + audioPlayer.reset(); // Call the reset() API and trigger the reset event callback. }); - audioPlayer.on('reset', () => { // Set the 'reset' event callback. + audioPlayer.on('reset', () => { // Set the reset event callback. console.info('audio play success'); if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented. this.nextMusic(audioPlayer); // Changing songs is implemented. @@ -187,13 +187,13 @@ export class AudioDemo { let nextpath = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/02.mp3'; await fileIO.open(nextpath).then((fdNumber) => { nextFdPath = nextFdPath + '' + fdNumber; - console.info('open fd sucess fd is' + nextFdPath); + console.info('open fd success fd is' + nextFdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = nextFdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + audioPlayer.src = nextFdPath; // Set the src attribute and trigger the dataLoad event callback. } async audioPlayerDemo() { @@ -204,13 +204,13 @@ export class AudioDemo { let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); + console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + audioPlayer.src = fdPath; // Set the src attribute and trigger the dataLoad event callback. } } ``` @@ -223,12 +223,12 @@ import fileIO from '@ohos.fileio' export class AudioDemo { // Set the player callbacks. setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the dataLoad event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); audioPlayer.loop = true; // Set the loop playback attribute. - audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. + audioPlayer.play(); // Call the play() API to start the playback and trigger the play event callback. }); - audioPlayer.on('play', () => { // Sets the 'play' event callback to start loop playback. + audioPlayer.on('play', () => { // Sets the play event callback to start loop playback. console.info('audio play success'); }); } @@ -241,13 +241,13 @@ export class AudioDemo { let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); + console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + audioPlayer.src = fdPath; // Set the src attribute and trigger the dataLoad event callback. } } ``` @@ -256,7 +256,7 @@ export class AudioDemo { The following samples are provided to help you better understand how to develop audio playback: -- [`JsDistributedMusicPlayer`: Distributed Music Player (JS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer) -- [`JsAudioPlayer`: Audio Playback and Management (JS, API 7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer) -- [`eTsAudioPlayer`: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) +- [JsDistributedMusicPlayer: Distributed Music Player (JS, API version 7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer) +- [JsAudioPlayer: Audio Playback and Management (JS, API version 7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer) +- [eTsAudioPlayer: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) - [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) diff --git a/en/application-dev/media/audio-recorder.md b/en/application-dev/media/audio-recorder.md index cd8d8ee0d976d6a2ee56cdb0e7ad93d2d46ac05d..d24ee72f4a322e44734a0eb7a70ca04d11dc8994 100644 --- a/en/application-dev/media/audio-recorder.md +++ b/en/application-dev/media/audio-recorder.md @@ -30,35 +30,35 @@ export class AudioRecorderDemo { // Set the callbacks related to audio recording. setCallBack(audioRecorder) { - audioRecorder.on('prepare', () => { // Set the 'prepare' event callback. + audioRecorder.on('prepare', () => { // Set the prepare event callback. console.log('prepare success'); - audioRecorder.start(); // Call the start API to start recording and trigger the 'start' event callback. + audioRecorder.start(); // Call the start API to start recording and trigger the start event callback. }); - audioRecorder.on('start', () => { // Set the 'start' event callback. + audioRecorder.on('start', () => { // Set the start event callback. console.log('audio recorder start success'); - audioRecorder.pause(); // Call the pause API to pause recording and trigger the 'pause' event callback. + audioRecorder.pause(); // Call the pause API to pause recording and trigger the pause event callback. }); - audioRecorder.on('pause', () => { // Set the 'pause' event callback. + audioRecorder.on('pause', () => { // Set the pause event callback. console.log('audio recorder pause success'); - audioRecorder.resume(); // Call the resume API to resume recording and trigger the 'resume' event callback. + audioRecorder.resume(); // Call the resume API to resume recording and trigger the resume event callback. }); - audioRecorder.on('resume', () => { // Set the 'resume' event callback. + audioRecorder.on('resume', () => { // Set the resume event callback. console.log('audio recorder resume success'); - audioRecorder.stop(); // Call the stop API to stop recording and trigger the 'stop' event callback. + audioRecorder.stop(); // Call the stop API to stop recording and trigger the stop event callback. }); - audioRecorder.on('stop', () => { // Set the 'stop' event callback. + audioRecorder.on('stop', () => { // Set the stop event callback. console.log('audio recorder stop success'); - audioRecorder.reset(); // Call the reset API to reset the recorder and trigger the 'reset' event callback. + audioRecorder.reset(); // Call the reset API to reset the recorder and trigger the reset event callback. }); - audioRecorder.on('reset', () => { // Set the 'reset' event callback. + audioRecorder.on('reset', () => { // Set the reset event callback. console.log('audio recorder reset success'); - audioRecorder.release(); // Call the release API to release resources and trigger the 'release' event callback. + audioRecorder.release(); // Call the release API to release resources and trigger the release event callback. }); - audioRecorder.on('release', () => { // Set the 'release' event callback. + audioRecorder.on('release', () => { // Set the release event callback. console.log('audio recorder release success'); audioRecorder = undefined; }); - audioRecorder.on('error', (error) => { // Set the 'error' event callback. + audioRecorder.on('error', (error) => { // Set the error event callback. console.info(`audio error called, errName is ${error.name}`); console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errMessage is ${error.message}`); @@ -103,7 +103,7 @@ export class AudioRecorderDemo { audioEncoderMime : media.CodecMimeType.AUDIO_AAC, fileFormat : media.ContainerFormatType.CFT_MPEG_4A, } - audioRecorder.prepare(audioRecorderConfig); // Call the prepare method to trigger the 'prepare' event callback. + audioRecorder.prepare(audioRecorderConfig); // Call the prepare method to trigger the prepare event callback. } } ``` @@ -120,23 +120,23 @@ export class AudioRecorderDemo { // Set the callbacks related to audio recording. setCallBack(audioRecorder) { - audioRecorder.on('prepare', () => { // Set the 'prepare' event callback. + audioRecorder.on('prepare', () => { // Set the prepare event callback. console.log('prepare success'); - audioRecorder.start(); // Call the start API to start recording and trigger the 'start' event callback. + audioRecorder.start(); // Call the start API to start recording and trigger the start event callback. }); - audioRecorder.on('start', () => { // Set the 'start' event callback. + audioRecorder.on('start', () => { // Set the start event callback. console.log('audio recorder start success'); - audioRecorder.stop(); // Call the stop API to stop recording and trigger the 'stop' event callback. + audioRecorder.stop(); // Call the stop API to stop recording and trigger the stop event callback. }); - audioRecorder.on('stop', () => { // Set the 'stop' event callback. + audioRecorder.on('stop', () => { // Set the stop event callback. console.log('audio recorder stop success'); - audioRecorder.release(); // Call the release API to release resources and trigger the 'release' event callback. + audioRecorder.release(); // Call the release API to release resources and trigger the release event callback. }); - audioRecorder.on('release', () => { // Set the 'release' event callback. + audioRecorder.on('release', () => { // Set the release event callback. console.log('audio recorder release success'); audioRecorder = undefined; }); - audioRecorder.on('error', (error) => { // Set the 'error' event callback. + audioRecorder.on('error', (error) => { // Set the error event callback. console.info(`audio error called, errName is ${error.name}`); console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errMessage is ${error.message}`); @@ -181,7 +181,7 @@ export class AudioRecorderDemo { audioEncoderMime : media.CodecMimeType.AUDIO_AAC, fileFormat : media.ContainerFormatType.CFT_MPEG_4A, } - audioRecorder.prepare(audioRecorderConfig); // Call the prepare method to trigger the 'prepare' event callback. + audioRecorder.prepare(audioRecorderConfig); // Call the prepare method to trigger the prepare event callback. } } ``` @@ -190,6 +190,7 @@ export class AudioRecorderDemo { The following samples are provided to help you better understand how to develop audio recording: -- [`Recorder`: Recorder (eTS, API 8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder) -- [`eTsAudioPlayer`: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) +- [Recorder: Recorder (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder) +- [JsRecorder: Recorder (JS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/media/JSRecorder) +- [eTsAudioPlayer: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) - [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) diff --git a/en/application-dev/media/opensles-playback.md b/en/application-dev/media/opensles-playback.md new file mode 100644 index 0000000000000000000000000000000000000000..b8568a6946d7c4f0d1647f23c9d52909e1cbd8df --- /dev/null +++ b/en/application-dev/media/opensles-playback.md @@ -0,0 +1,122 @@ +# OpenSL ES Audio Playback Development + + + +## When to Use + +You can use OpenSL ES to develop the audio playback function in OpenHarmony. Currently, only some [OpenSL ES APIs](https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h) are implemented. If an API that has not been implemented is called, **SL_RESULT_FEATURE_UNSUPPORTED** will be returned. + + + +## How to Develop + +To use OpenSL ES to develop the audio playback function in OpenHarmony, perform the following steps: + +1. Add the header files. + + ```c++ + #include + #include + #include + ``` + + + +2. Use the **slCreateEngine** API to obtain an **engine** instance. + + ```c++ + SLObjectItf engineObject = nullptr; + slCreateEngine(&engineObject, 0, nullptr, 0, nullptr, nullptr); + (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE); + ``` + + + +3. Obtain the **engineEngine** instance of the **SL_IID_ENGINE** interface. + + ```c++ + SLEngineItf engineEngine = nullptr; + (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine); + ``` + + + +4. Configure the player and create an **AudioPlayer** instance. + + ```c++ + SLDataLocator_BufferQueue slBufferQueue = { + SL_DATALOCATOR_BUFFERQUEUE, + 0 + }; + + // Configure the parameters based on the audio file format. + SLDataFormat_PCM pcmFormat = { + SL_DATAFORMAT_PCM, + 2, + 48000, + 16, + 0, + 0, + 0 + }; + SLDataSource slSource = {&slBufferQueue, &pcmFormat}; + + SLObjectItf pcmPlayerObject = nullptr; + (*engineEngine)->CreateAudioPlayer(engineEngine, &pcmPlayerObject, &slSource, null, 0, nullptr, nullptr); + (*pcmPlayerObject)->Realize(pcmPlayerObject, SL_BOOLEAN_FALSE); + ``` + + + +5. Obtain the **bufferQueueItf** instance of the **SL_IID_OH_BUFFERQUEUE** interface. + + ``` + SLOHBufferQueueItf bufferQueueItf; + (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_OH_BUFFERQUEUE, &bufferQueueItf); + ``` + + + +6. Open an audio file and register the **BufferQueueCallback** function. + + ```c++ + FILE *wavFile_ = nullptr; + + static void BuqqerQueueCallback (SLOHBufferQueueItf bufferQueueItf, void *pContext, SLuint32 size) + { + FILE *wavFile = (FILE *)pContext; + if (!feof(wavFile)) { + SLuint8 *buffer = nullptr; + SLuint32 pSize = 0; + (*bufferQueueItf)->GetBuffer(bufferQueueItf, &buffer, pSize); + // Read data from the file. + fread(buffer, 1, size, wavFile); + (*bufferQueueItf)->Enqueue(bufferQueueItf, buffer, size); + } + return; + } + + // Set wavFile_ to the descriptor of the file to be played. + wavFile_ = fopen(path, "rb"); + (*bufferQueueItf)->RegisterCallback(bufferQueueItf, BuqqerQueueCallback, wavFile_); + ``` + + + +7. Obtain the **playItf** instance of the **SL_PLAYSTATE_PLAYING** interface and start playback. + + ```c++ + SLPlayItf playItf = nullptr; + (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_PLAY, &playItf); + (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING); + ``` + + + +8. Stop audio playback. + + ```c++ + (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED); + (*pcmPlayerObject)->Destroy(pcmPlayerObject); + (*engineObject)->Destroy(engineObject); + ``` diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md index 49f0f084420b7302806ea46833636815ab12ade0..4317e0362769936b16844f22d592e5163dfbcdff 100644 --- a/en/application-dev/media/video-playback.md +++ b/en/application-dev/media/video-playback.md @@ -76,13 +76,13 @@ export class VideoPlayerDemo { async videoPlayerDemo() { let videoPlayer = undefined; - let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. + let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent. let fdPath = 'fd://' // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); + console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { @@ -97,7 +97,7 @@ export class VideoPlayerDemo { console.info('createVideoPlayer fail!'); } }, this.failureCallback).catch(this.catchCallback); - // Set the playback source URL for the player. + // Set the playback source for the player. videoPlayer.url = fdPath; // Set the surface ID to display the video image. @@ -134,19 +134,19 @@ export class VideoPlayerDemo { this.printfDescription(arrayDescription[i]); } - // Seek to the 50s position. For details about the input parameters, see the interface document. + // Seek to the 50s position. For details about the input parameters, see the API document. let seekTime = 50000; await videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { console.info('seek success'); }, this.failureCallback).catch(this.catchCallback); - // Set the volume. For details about the input parameters, see the interface document. + // Set the volume. For details about the input parameters, see the API document. let volume = 0.5; await videoPlayer.setVolume(volume).then(() => { console.info('setVolume success'); }, this.failureCallback).catch(this.catchCallback); - // Set the playback speed. For details about the input parameters, see the interface document. + // Set the playback speed. For details about the input parameters, see the API document. let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X; await videoPlayer.setSpeed(speed).then(() => { console.info('setSpeed success'); @@ -205,13 +205,13 @@ export class VideoPlayerDemo { async videoPlayerDemo() { let videoPlayer = undefined; - let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. + let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent. let fdPath = 'fd://' // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); + console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { @@ -292,14 +292,14 @@ export class VideoPlayerDemo { async videoPlayerDemo() { let videoPlayer = undefined; - let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. + let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent. let fdPath = 'fd://' // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; let nextPath = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/MP4_AAC.mp4'; await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); + console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { @@ -341,7 +341,7 @@ export class VideoPlayerDemo { fdPath = 'fd://' await fileIO.open(nextPath).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); + console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { @@ -350,7 +350,7 @@ export class VideoPlayerDemo { // Set the second video playback source. videoPlayer.url = fdPath; - // Call the prepare interface to prepare for playback. + // Call the prepare API to prepare for playback. await videoPlayer.prepare().then(() => { console.info('prepare success'); }, this.failureCallback).catch(this.catchCallback); @@ -401,19 +401,15 @@ export class VideoPlayerDemo { } } - sleep(time) { - for(let t = Date.now(); Date.now() - t <= time;); - } - async videoPlayerDemo() { let videoPlayer = undefined; - let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. + let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent. let fdPath = 'fd://' // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); + console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { @@ -442,23 +438,15 @@ export class VideoPlayerDemo { }, this.failureCallback).catch(this.catchCallback); // Set the loop playback attribute. videoPlayer.loop = true; - // Call the play API to start playback. + // Call the play API to start loop playback. await videoPlayer.play().then(() => { - console.info('play success'); - }, this.failureCallback).catch(this.catchCallback); - // After the progress bar reaches the end, the playback continues for 3 seconds and then starts from the beginning, since loop playback is configured. - await videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { - console.info('seek duration success'); + console.info('play success, loop value is ' + videoPlayer.loop); }, this.failureCallback).catch(this.catchCallback); - this.sleep(3000); - // Release playback resources. - await videoPlayer.release().then(() => { - console.info('release success'); - }, this.failureCallback).catch(this.catchCallback); - - // Set the related instances to undefined. - videoPlayer = undefined; - surfaceID = undefined; } } ``` + +## Samples +The following samples are provided to help you better understand how to develop video playback: + +- [`VideoPlayer`: Video Playback (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/media/VideoPlayer) diff --git a/en/application-dev/napi/Readme-EN.md b/en/application-dev/napi/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..33670e46af96c2bb35b120bd4be23958bce8f84b --- /dev/null +++ b/en/application-dev/napi/Readme-EN.md @@ -0,0 +1,3 @@ +# Native APIs + +- [Using Native APIs in Application Projects](napi-guidelines.md) diff --git a/en/application-dev/notification/common-event.md b/en/application-dev/notification/common-event.md index 99cbc2a32b9cfdc29e56f834e7b834ce3179ef7c..8ea3eaa2d6b2f450f28660ca9f50ad3b99947c8b 100644 --- a/en/application-dev/notification/common-event.md +++ b/en/application-dev/notification/common-event.md @@ -174,4 +174,4 @@ if (this.subscriber != null) { The following sample is provided to help you better understand how to use the common event functionality: -- [`CommonEvent`: eTS Common Event (API 7)](https://gitee.com/openharmony/app_samples/tree/master/Notification/CommonEvent) +- [`CommonEvent`: eTS Common Event (API 8)](https://gitee.com/openharmony/app_samples/tree/master/Notification/CommonEvent) diff --git a/en/application-dev/notification/notification.md b/en/application-dev/notification/notification.md index 129db615d8cf7bc52d3707cbace5121546203868..1a24922a0f7ce6e17e6d65963f13622798348dad 100644 --- a/en/application-dev/notification/notification.md +++ b/en/application-dev/notification/notification.md @@ -133,7 +133,7 @@ var subscriber = { ##### Enabling Notification -Before publishing a notification, check whether the notification feature is enabled for your application. By default, the feature is disabled. The application can use **Notification.requestEnableNotification** to prompt the user to enable the feature. +Before publishing a notification, check whether the notification feature is enabled for your application. By default, the feature is disabled. The application calls **Notification.requestEnableNotification** to prompt the user to enable the feature. ```js Notification.requestEnableNotification() .then((data) => { @@ -262,4 +262,4 @@ Notification.cancel(1, "label", cancelCallback) The following sample is provided to help you better understand how to develop notification functions: -[`Notification`: EtsNotification (API 7)](https://gitee.com/openharmony/app_samples/tree/master/common/Notification) \ No newline at end of file +[`Notification`: EtsNotification (API 8)](https://gitee.com/openharmony/app_samples/tree/master/common/Notification) \ No newline at end of file diff --git a/en/application-dev/quick-start/Readme-EN.md b/en/application-dev/quick-start/Readme-EN.md index e101158532d51ba2a072a1d860bb7eaf1bee1602..228d2f0442007f51177f074b6d2e70fcf7486395 100644 --- a/en/application-dev/quick-start/Readme-EN.md +++ b/en/application-dev/quick-start/Readme-EN.md @@ -6,9 +6,9 @@ - [Getting Started with eTS in the Low-Code Approach](start-with-ets-low-code.md) - [Getting Started with JavaScript in the Traditional Coding Approach](start-with-js.md) - [Getting Started with JavaScript in the Low-Code Approach](start-with-js-low-code.md) - - Development Fundamentals - - [Application Development Package Structure (FA Model)](package-structure.md) - - [Application Development Package Structure (Stage Model)](module-structure.md) + - [Application Package Structure Configuration File (FA Model)](package-structure.md) + - [Application Package Structure Configuration File (Stage Model)](stage-structure.md) - [Resource File Categories](basic-resource-file-categories.md) - [SysCap](syscap.md) + diff --git a/en/application-dev/quick-start/package-structure.md b/en/application-dev/quick-start/package-structure.md index 07a151684093b7d0b85745b7211b53a7283bac2b..7bdb44c158b921d8ff550b16d9b2f22b910262e7 100644 --- a/en/application-dev/quick-start/package-structure.md +++ b/en/application-dev/quick-start/package-structure.md @@ -271,11 +271,12 @@ Example of the **module** tag structure: Table 12 Internal structure of the distro attribute -| Attribute | Description | Data Type| Initial Value Allowed| -| ---------------- | ------------------------------------------------------------ | -------- | ---------- | -| moduleName | Name of the current HAP file. The maximum length is 31 characters. | String | No | -| moduleType | Type of the current HAP file. The value can be **entry** or **feature**. For the HAR type, set this attribute to **har**.| String | No | -| installationFree | Whether the HAP file supports the installation-free feature.
**true**: The HAP file supports the installation-free feature and meets installation-free constraints.
**false**: The HAP file does not support the installation-free feature.
Pay attention to the following:
When **entry.hap** is set to **true**, all **feature.hap** fields related to **entry.hap **must be **true**.
When **entry.hap** is set to **false**, **feature.hap** related to **entry.hap** can be set to **true** or **false** based on service requirements.| Boolean | No | +| Attribute | Description | Data Type| Initial Value Allowed| +| ---------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- | ---------- | +| moduleName | Name of the current HAP file. The maximum length is 31 characters. | String | No | +| moduleType | Type of the current HAP file. The value can be **entry** or **feature**. For the HAR type, set this attribute to **har**. | String | No | +| installationFree | Whether the HAP file supports the installation-free feature.
**true**: The HAP file supports the installation-free feature and meets installation-free constraints.
**false**: The HAP file does not support the installation-free feature.
Pay attention to the following:
When **entry.hap** is set to **true**, all **feature.hap** fields related to **entry.hap **must be **true**.
When **entry.hap** is set to **false**, **feature.hap** related to **entry.hap** can be set to **true** or **false** based on service requirements. | Boolean | No | +| deliveryWithInstall | Whether the HAP file supports the installation with application。
true: Support。
false:No Support。 | Boolean | No | Example of the **distro** attribute structure: @@ -283,7 +284,8 @@ Example of the **distro** attribute structure: "distro": { "moduleName": "ohos_entry", "moduleType": "entry", - "installationFree": true + "installationFree": true, + "deliveryWithInstall": true } ``` diff --git a/en/application-dev/quick-start/module-structure.md b/en/application-dev/quick-start/stage-structure.md similarity index 97% rename from en/application-dev/quick-start/module-structure.md rename to en/application-dev/quick-start/stage-structure.md index ef19d2b394b87375811dd483ab162d81a7068b4a..7d733b1b06c5996fb16cc01cbeb712422edf2b1f 100644 --- a/en/application-dev/quick-start/module-structure.md +++ b/en/application-dev/quick-start/stage-structure.md @@ -175,12 +175,12 @@ Table 2 Internal structure of the app tag | vendor | Application vendor. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) | | versionCode | Version number of the application. The value is a 32-bit non-negative integer and less than 2 to the power of 31. It is used only to determine whether a version is later than another version. A larger value indicates a later version. Ensure that a new version of the application uses a value greater than any of its predecessors. | Number | No | | versionName | Text description of the version number, which is displayed to users.
The value consists of only digits and dots. The four-segment format *A.B.C.D* is recommended, wherein:
Segment 1: major version number, which ranges from 0 to 99. A major version consists of major new features or large changes.
Segment 2: minor version number, which ranges from 0 to 99. A minor version consists of some new features and large bug fixes.
Segment 3: feature version number, which ranges from 0 to 99. A feature version consists of scheduled new features.
Segment 4: maintenance release number or patch number, which ranges from 0 to 999. A maintenance release or patch consists of resolution to security flaws or minor bugs.| String | No | -| minCompatibleVersionCode | Minimum API version required for running the application. | Number | Yes (initial value: value of **versionCode**)| -| minAPIVersion | Target API version required for running the application. | Number | No | +| minCompatibleVersionCode | Minimum API version compatible with the application. | Number | Yes (initial value: value of **versionCode**)| +| minAPIVersion | Minimum API version required for running the application. | Number | No | | targetAPIVersion | Target API version required for running the application. | Integer | No | | apiReleaseType | Type of the target API version required for running the application. The value can be **CanaryN**, **BetaN**, or **Release**, where **N** represents a positive integer.
**Canary**: indicates a restricted release.
**Beta**: indicates a publicly released beta version.
**Release**: indicates a publicly released official version.| String | Yes (initial value: **"Release"**) | | distributedNotificationEnabled | Whether the distributed notification feature is enabled for the application. | Boolean | Yes (initial value: **true**) | -| entityType | Category of the application, which can be **game**, **media**, **communication**, **news**, **travel**, **utility**, **shopping**, **education**, **kids**, **business**, and **photography**.| String | Yes (initial value: unspecified) | +| entityType | Type of the application, which can be **game**, **media**, **communication**, **news**, **travel**, **utility**, **shopping**, **education**, **kids**, **business**, and **photography**.| String | Yes (initial value: unspecified) | ### Internal Structure of the module Tag @@ -212,9 +212,9 @@ Table 4 System-defined deviceTypes values | Device Type | Value | Description | | ------------ | ------------ | -------------------------------------------------------- | | tablet | tablet | Tablet, speaker with a screen | -| smart TV | tv | | +| smart TV | tv | N/A | | smart watch | wearable | Smart watch, kids' watch, especially a watch that provides call features| -| head unit | car | | +| head unit | car | N/A | | router | router | Router | Example of the **deviceTypes** attribute structure: @@ -309,7 +309,7 @@ Table 6 Internal structure of the abilities attribute | icon | Icon of the ability. The value is the index to the resource file. This attribute can be left empty, and the default value is an empty array.
If **ability** is set to **MainElement**, this attribute is mandatory.| String | Yes (initial value: left empty)
If **ability** is set to **MainElement**, this attribute is mandatory.| | permissions | A set of permissions that need to be applied for when the capability of another application is invoked. The value is a string array. Each array element is a permission name, which is usually represented by a reverse domain name (a maximum of 255 bytes). The permission can be predefined by the system or customized by the application. For the latter, the value must be the same as the **name** value of a permission defined in the **defPermissions** attribute. | String array| Yes (initial value: left empty) | | metadata | Metadata about the ability. For details about metadata, see [Internal Structure of the metadata Attribute](#internal-structure-of-the-metadata-attribute).| Array | Yes (initial value: left empty) | -| visible | Indicates whether the ability can be invoked by other applications. The value **true** means that the ability can be invoked by other applications, and **false** means the opposite.| Boolean | Yes (initial value: **false**) | +| visible | Whether the ability can be invoked by other applications. The value **true** means that the ability can be invoked by other applications, and **false** means the opposite.| Boolean | Yes (initial value: **false**) | | continuable | Whether the ability can be migrated. The value **true** means that the ability can be migrated, and **false** means the opposite.| Boolean | Yes (initial value: **false**) | | skills | Feature set of wants that can be received by the ability.
Configuration rule: In an entry package, you can configure multiple abilities with the **skills** attribute (where **action.system.home** and **entity.system.home** are configured) that has the entry capability. The **label** and **icon** in the first ability that has **skills** configured are used as the **label** and **icon** of the entire service/application.
The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application,
but not for an OpenHarmony service.
For details about the internal structure of **skills**, see [Internal Structure of the skills Attribute](#internal-structure-of-the-skills-attribute).| Array | Yes (initial value: left empty) | | backgroundModes | Continuous task modes of the ability.
Continuous tasks are classified into the following types:
**dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices
**audioPlayback**: audio playback service
**audioRecording**: audio recording service
**location**: location and navigation services
**bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables)
**multiDeviceConnection**: multi-device interconnection service
**wifiInteraction**: Wi-Fi scanning, connection, and transmission services (multi-screen cloning)
**voip**: voice/video call and VoIP services
**taskKeeping**: computing service
| String | Yes (initial value: left empty) | @@ -361,7 +361,7 @@ Table 7 Internal structure of the skills attribute | -------- | ------------------------------------------------------------ | ---------- | -------------------- | | actions | A set of want action values that can be received. The value can be a value predefined by the system or a custom value.| String array| Yes (initial value: left empty)| | entities | Categories of abilities that can receive the want. The value can be a value predefined by the system or a custom value.| String array| Yes (initial value: left empty)| -| uris | Data specifications to be added to the want filter. The specification can be of data type only (**mimeType** attribute), URI only, or both. For details about the internal structure of **uris**, see Table 8.| Object array | Yes (initial value: left empty)| +| uris | Data specification to be added to the want filter. The specification can be of data type only (**mimeType** attribute), URI only, or both. For details about the internal structure of **uris**, see Table 8.| Object array | Yes (initial value: left empty)| Table 8 Internal structure of the uris attribute @@ -612,7 +612,7 @@ Table 13 Internal structure of the shortcuts attribute | Attribute | Description | Data Type| Initial Value Allowed | | ---------- | ------------------------------------------------------------ | -------- | -------------------------- | -| shortcutId | Shortcut ID. The value is a string with a maximum of 63 bytes. | String | No | +| shortcutId | ID of the shortcut. The value is a string with a maximum of 63 bytes. | String | No | | label | Label of the shortcut, that is, the text description displayed by the shortcut. The value can be a string or a resource index to the description. The value is a string with a maximum of 63 bytes.| String | Yes (initial value: left empty) | | icon | Icon of the shortcut. The value is the index to the resource file. | String | Yes (initial value: left empty)| | wants | Wants to which the shortcut points. The attribute consists of the **bundleName** and **abilityName** sub-attributes.
**bundleName**: target bundle name of the shortcut; string type.
**abilityName**: target component name of the shortcut; string type.| Object | Yes (initial value: left empty) | diff --git a/en/application-dev/quick-start/start-overview.md b/en/application-dev/quick-start/start-overview.md index 7dcfb3583408d68454489f1eef38f1b1e19defea..6f5bcb31545c055124156a366eea31e19f91c8c4 100644 --- a/en/application-dev/quick-start/start-overview.md +++ b/en/application-dev/quick-start/start-overview.md @@ -47,4 +47,4 @@ This document provides a Page ability instance with two pages. For more informat 2. Install DevEco Studio and configure the development environment. For details, see [Configuring the OpenHarmony SDK](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-setting-up-environment-0000001263160443). -When you are done, follow the instructions in [Getting Started with eTS in the Traditional Coding Approach](start-with-ets.md),[Getting Started with eTS in the Low-Code Approach](start-with-ets-low-code.md), [Getting Started with JavaScript in the Traditional Coding Approach](start-with-js.md), and [Getting Started with JavaScript in the Low-Code Approach](start-with-js-low-code.md). +When you are done, follow the instructions in [Getting Started with eTS in the Traditional Coding Approach](start-with-ets.md), [Getting Started with eTS in the Low-Code Approach](start-with-ets-low-code.md), [Getting Started with JavaScript in the Traditional Coding Approach](start-with-js.md), and [Getting Started with JavaScript in the Low-Code Approach](start-with-js-low-code.md). diff --git a/en/application-dev/quick-start/start-with-ets.md b/en/application-dev/quick-start/start-with-ets.md index 53c1133bfb918ed07e1c6d81f90a2f46a85ca500..66485cd8aaeada2f1896013c7822aacc30b5872d 100644 --- a/en/application-dev/quick-start/start-with-ets.md +++ b/en/application-dev/quick-start/start-with-ets.md @@ -20,17 +20,18 @@ ## eTS Project Files -- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). - - **src > main > ets** : a collection of eTS source code. - - **src > main > ets > MainAbility** : entry to your application/service. - - **src > main > ets > MainAbility > pages** : pages contained in **MainAbility**. - - **src > main > ets > MainAbility > app.ets** : ability lifecycle file. - - **src > main > resources** : a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. - - **src > main > config.json** : module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. - - **build-profile.json5** : current module information and build configuration options, including **buildOption target**. - - **hvigorfile.js** : module-level compilation and build task script. You can customize related tasks and code implementation. -- **build-profile.json5** : application-level configuration information, including the signature and product configuration. -- **hvigorfile.js** : application-level compilation and build task script. +- **entry**: OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). + - **src > main > ets**: a collection of eTS source code. + - **src > main > ets > MainAbility**: entry to your application/service. + - **src > main > ets > MainAbility > pages**: pages contained in **MainAbility**. + - **src > main > ets > MainAbility > pages > index.ets**: the first page in the pages list, that is, the home page of your application. + - **src > main > ets > MainAbility > app.ets**: ability lifecycle file. + - **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. + - **src > main > config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. + - **build-profile.json5**: current module information and build configuration options, including **buildOption target**. + - **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation. +- **build-profile.json5**: application-level configuration information, including the signature and product configuration. +- **hvigorfile.js**: application-level compilation and build task script. ## Building the First Page @@ -62,7 +63,7 @@ 2. Add a **<Button>** component. - On the default page, add a **<Button>** component to accept user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below: + On the default page, add a **<Button>** component to respond to user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below: ``` @@ -77,7 +78,7 @@ Text(this.message) .fontSize(50) .fontWeight(FontWeight.Bold) - // Add a button to accept user clicks. + // Add a button to respond to user clicks. Button() { Text('Next') .fontSize(30) @@ -174,7 +175,7 @@ You can implement page redirection through the page router, which finds the targ Text(this.message) .fontSize(50) .fontWeight(FontWeight.Bold) - // Add a button to accept user clicks. + // Add a button to respond to user clicks. Button() { Text('Next') .fontSize(30) diff --git a/en/application-dev/quick-start/start-with-js-low-code.md b/en/application-dev/quick-start/start-with-js-low-code.md index a20c01c2f459fc07b799ca847683f99350dd4829..69e650671909a57d56c6486346938a4804de2fdf 100644 --- a/en/application-dev/quick-start/start-with-js-low-code.md +++ b/en/application-dev/quick-start/start-with-js-low-code.md @@ -37,10 +37,11 @@ After the project synchronization is complete, a low-code directory structure is ![en-us_image_0000001223558810](figures/en-us_image_0000001223558810.png) -- **entry > src > main > js > MainAbility > pages > index > index.js** : defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages. +- **entry > src > main > js > MainAbility > pages > index > index.js**: defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
To avoid build errors when using the low-code development page, make sure the directory where the corresponding **.js** file is located does not contain **.hml** or **.css** files. For example, in the preceding example, no **.hml** or **.css** file is allowed in **js** > **MainAbility** > **pages** > **index**. > -- **entry > src > main > supervisual > MainAbility > pages > index > index.visual** : stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages. +- **entry > src > main > supervisual > MainAbility > pages > index > index.visual**: stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages. ## Building the First Page diff --git a/en/application-dev/quick-start/start-with-js.md b/en/application-dev/quick-start/start-with-js.md index 60131768f2dd3727a4d1467ca92896abb0239752..301da91e43a7f751c4e70135acf5fbce64c3eef8 100644 --- a/en/application-dev/quick-start/start-with-js.md +++ b/en/application-dev/quick-start/start-with-js.md @@ -19,7 +19,7 @@ ## JavaScript Project Files -- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). +- **entry**: OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). - **src > main > js**: a collection of JS source code. - **src > main > js > MainAbility**: entry to your application/service. - **src > main > js > MainAbility > i18n**: resources in different languages, for example, UI strings and image paths. @@ -50,7 +50,7 @@ 2. Add a button and bind the **onclick** method to this button. - On the default page, add an **<input>** component of the button type to accept user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below: + On the default page, add an **<input>** component of the button type to respond to user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below: ``` diff --git a/en/application-dev/quick-start/syscap.md b/en/application-dev/quick-start/syscap.md index 3d9d733441f5ab19016a3cabeada6abe41d6e1bc..41ce7f114359edae353b6fd0783cf55aab8a2adb 100644 --- a/en/application-dev/quick-start/syscap.md +++ b/en/application-dev/quick-start/syscap.md @@ -1,4 +1,4 @@ -# SysCap Usage Guidelines +# SysCap ## Overview diff --git a/en/application-dev/reference/Readme-EN.md b/en/application-dev/reference/Readme-EN.md index c2252e1a8f56f93c52ee4278681fc7fb23d28366..30bb3aacd85d9e11012fb66dc276a88476139126 100644 --- a/en/application-dev/reference/Readme-EN.md +++ b/en/application-dev/reference/Readme-EN.md @@ -4,7 +4,8 @@ - [TypeScript-based Declarative Development Paradigm](arkui-ts/Readme-EN.md) - [APIs](apis/Readme-EN.md) - - [JS (eTS Included) APIs](reference/apis/Readme-EN.md) + - [JS (eTS Included) APIs](apis/Readme-EN.md) - Native APIs - - [Standard Library](reference/native-lib/third_party_libc/musl.md) - - [Node_API](reference/native-lib/third_party_napi/napi.md) \ No newline at end of file + - [Standard Library](native-lib/third_party_libc/musl.md) + - [Node_API](native-lib/third_party_napi/napi.md) + diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md index 83b61077eeae144c95e92cdad94b35b8f01ccca7..e62395b2437a0f24917a3f7356b353dad2c8dd67 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle.md +++ b/en/application-dev/reference/apis/js-apis-Bundle.md @@ -1,8 +1,8 @@ # Bundle Module (JavaScript SDK APIs) -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. - +> API version 9 is a canary version for trial use. The APIs of this version may be unstable. ## Modules to Import ``` @@ -17,8 +17,8 @@ SystemCapability.BundleManager.BundleFramework | 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.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 @@ -37,17 +37,17 @@ SystemCapability.BundleManager.BundleFramework **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 | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| 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 | 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 | | ------------------------- | ------------------ | -| Promise\ | Promise used to return the application information.| +| Promise\ | Promise used to return the application information. | **Example** @@ -84,7 +84,7 @@ SystemCapability.BundleManager.BundleFramework | 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.| +| 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. | @@ -123,7 +123,7 @@ SystemCapability.BundleManager.BundleFramework | 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.| +| 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 application information. | **Example** @@ -159,14 +159,14 @@ SystemCapability.BundleManager.BundleFramework | 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.| +| 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 | | --------------------------- | -------------------------- | -| Promise> | Promise used to return the information of all available bundles.| +| Promise> | Promise used to return the information of all available bundles. | **Example** @@ -201,7 +201,7 @@ SystemCapability.BundleManager.BundleFramework | 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.| +| 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** @@ -236,7 +236,7 @@ SystemCapability.BundleManager.BundleFramework | 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.| +| 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. | @@ -275,14 +275,14 @@ SystemCapability.BundleManager.BundleFramework | 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.| +| 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**. | **Return value** | Type | Description | | -------------------- | ---------------------------- | -| Promise\ | Promise used to return the bundle information.| +| Promise\ | Promise used to return the bundle information. | **Example** @@ -321,7 +321,7 @@ SystemCapability.BundleManager.BundleFramework | 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.| +| 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** @@ -358,7 +358,7 @@ SystemCapability.BundleManager.BundleFramework | 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.| +| 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**. | | callback | AsyncCallback\ | Yes | Callback used to return the bundle information. | @@ -398,14 +398,14 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | -| 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.| +| 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 | 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 | | -------------------------------- | ------------------------------- | -| Promise> | Promise used to return the application information.| +| Promise> | Promise used to return the application information. | **Example** @@ -440,7 +440,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | -------------------------------------- | ---- | --------------------------------------- | -| 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.| +| 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 | No | 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. | @@ -463,7 +463,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>) : void; -Obtains the information about all applications of the specified user. This API uses an asynchronous callback to return the result. +Obtains the information about all applications. This API uses an asynchronous callback to return the result. **Required permissions** @@ -477,7 +477,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | -------------------------------------- | ---- | --------------------------------------- | -| 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.| +| 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 application information. | **Example** @@ -512,13 +512,13 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------ | ---- | ---------------- | | bundleName | string | Yes | Bundle name of the application. | -| abilityName | string | Yes | Ability name.| +| abilityName | string | Yes | Ability name. | **Return value** | Type | Description | | --------------------- | --------------------- | -| Promise\ | Promise used to return the ability information.| +| Promise\ | Promise used to return the ability information. | **Example** @@ -552,8 +552,8 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------------ | ---- | ---------------- | | bundleName | string | Yes | Bundle name of the application. | -| abilityName | string | Yes | Ability name.| -| callback | AsyncCallback\ | Yes | Callback used to return the ability information.| +| abilityName | string | Yes | Ability name. | +| callback | AsyncCallback\ | Yes | Callback used to return the ability information. | **Example** @@ -588,13 +588,13 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------ | ---- | ---------------- | | bundleName | string | Yes | Bundle name of the application. | -| abilityName | string | Yes | Ability name.| +| abilityName | string | Yes | Ability name. | **Return value** | Type | Description | | ---------------- | ------------------ | -| Promise\ | Promise used to return the application name.| +| Promise\ | Promise used to return the application name. | **Example** @@ -628,7 +628,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ---------------------- | ---- | ---------------- | | bundleName | string | Yes | Bundle name of the application. | -| abilityName | string | Yes | Ability name.| +| abilityName | string | Yes | Ability name. | | callback | AsyncCallback\ | Yes | Callback used to return the application name. | **Example** @@ -649,7 +649,7 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => { isAbilityEnabled(info: AbilityInfo): Promise\ -Checks whether an ability is enabled based on a given want. This API uses a promise to return the result. +Checks whether an ability is enabled based on a given **AbilityInfo** object. This API uses a promise to return the result. **Required permissions** @@ -663,13 +663,13 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---- | ----------- | ---- | ------------ | -| info | AbilityInfo | Yes | Ability information.| +| info | AbilityInfo | Yes | Ability information. | **Return value** | Type | Description | | ----------------- | ------------------------- | -| Promise\ | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.| +| Promise\ | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned. | **Example** @@ -690,7 +690,7 @@ bundle.isAbilityEnabled(Info) isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\): void -Checks whether an ability is enabled based on a given want. This API uses an asynchronous callback to return the result. +Checks whether an ability is enabled based on a given **AbilityInfo** object. This API uses an asynchronous callback to return the result. **Required permissions** @@ -705,7 +705,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | -------- | ----------------------- | ---- | --------------- | | info | AbilityInfo | Yes | Ability information. | -| callback | AsyncCallback\ | Yes | Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.| +| callback | AsyncCallback\ | Yes | Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned. | **Example** @@ -727,7 +727,7 @@ bundle.isAbilityEnabled(Info, (err, data) => { isApplicationEnabled(bundleName: string): Promise\ -Checks whether an application is enabled based on a given want. This API uses a promise to return the result. +Checks whether an application is enabled based on a given bundle name. This API uses a promise to return the result. **Required permissions** @@ -741,13 +741,13 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---------- | ------ | ---- | ------------ | -| bundleName | string | Yes | Bundle name of the application.| +| bundleName | string | Yes | Bundle name of the application. | **Return value** | Type | Description | | ----------------- | ------------------------- | -| Promise\ | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.| +| Promise\ | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned. | **Example** @@ -780,7 +780,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---------- | ----------------------- | ---- | --------------- | | bundleName | string | Yes | Bundle name of the application. | -| callback | AsyncCallback\ | Yes | Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.| +| callback | AsyncCallback\ | Yes | Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned. | **Example** @@ -814,14 +814,14 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------ | ---- | ------------------------------------- | | 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.| +| 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 | | ---------------------------- | --------------------- | -| Promise\>| Promise used to return the ability information.| +| Promise\>| Promise used to return the ability information. | **Example** @@ -857,7 +857,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ---------------------------------- | ---- | ------------------------------------- | | 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.| +| bundleFlags | number | Yes | Type of the 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. | @@ -894,7 +894,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ---------------------------------- | ---- | ------------------------------------- | | 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.| +| bundleFlags | number | Yes | Type of the 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** @@ -934,12 +934,12 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---------- | ------ | ---- | ------------ | -| bundleName | string | Yes | Bundle name of the application.| +| bundleName | string | Yes | Bundle name of the application. | **Return value** | Type | Description | | -------------- | -------------------------------------- | -| Promise\ | Promise used to return the **Want** object.| +| Promise\ | Promise used to return the **Want** object. | **Example** @@ -972,7 +972,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---------- | -------------------- | ---- | ------------------------------ | | bundleName | string | Yes | Bundle name of the application. | -| callback | AsyncCallback\ | Yes | Callback used to return the **Want** object.| +| callback | AsyncCallback\ | Yes | Callback used to return the **Want** object. | **Example** @@ -1002,12 +1002,12 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---- | ------ | ---- | -------- | -| uid | number | Yes | UID based on which the bundle name is to obtain.| +| uid | number | Yes | UID based on which the bundle name is to obtain. | **Return value** | Type | Description | | ---------------- | --------------------------------- | -| Promise\ | Promise used to return the bundle name.| +| Promise\ | Promise used to return the bundle name. | **Example** @@ -1036,7 +1036,7 @@ SystemCapability.BundleManager.BundleFramework | 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.| +| callback | AsyncCallback\ | Yes | Callback used to return the bundle name. | **Example** @@ -1056,7 +1056,7 @@ bundle.getNameForUid(uid, (err, data) => { getAbilityIcon(bundleName: string, abilityName: string): Promise\; -Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the corresponding icon based on a given bundle name and ability name. This API uses a promise to return the result. +Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the icon corresponding to a given bundle name and ability name. This API uses a promise to return the result. **Required permissions** @@ -1076,7 +1076,7 @@ SystemCapability.BundleManager.BundleFramework **Return value** | Type | Description | | --------------------- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md)>.| +| Promise\ | Promise used to return the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md)>. | **Example** @@ -1095,7 +1095,7 @@ bundle.getAbilityIcon(bundleName, abilityName) getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\): void; -Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the corresponding icon based on a given bundle name and ability name. This API uses an asynchronous callback to return the result. +Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the icon corresponding to a given bundle name and ability name. This API uses an asynchronous callback to return the result. **Required permissions** @@ -1111,7 +1111,7 @@ SystemCapability.BundleManager.BundleFramework | ----------- | ---------------------------------------- | ---- | ---------------------------------------- | | bundleName | string | Yes | Bundle name based on which the pixel map is to obtain. | | abilityName | string | Yes | Ability name based on which the pixel map is to obtain. | -| callback | AsyncCallback\ | Yes | Callback used to return the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md)>.| +| callback | AsyncCallback\ | Yes | Callback used to return the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md)>. | **Example** @@ -1147,14 +1147,14 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | -------------- | ------ | ---- | ---------------------------------------- | | want | Want | Yes | Want that contains the bundle name. | -| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| extensionFlags | number | Yes | Extension 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 | | ------------------------------------- | ------------------------------ | -| Promise> | Promise used to return the Extension ability information.| +| Promise> | Promise used to return the Extension ability information. | **Example** @@ -1194,7 +1194,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | -------------- | ---------------------------------------- | ---- | ---------------------------------------- | | want | Want | Yes | Want that contains the bundle name. | -| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| extensionFlags | number | Yes | Extension 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 Extension ability information. | @@ -1235,7 +1235,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | -------------- | ---------------------------------------- | ---- | ---------------------------------------- | | want | Want | Yes | Want that contains the bundle name. | -| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| extensionFlags | number | Yes | Extension 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 Extension ability information. | **Example** @@ -1262,8 +1262,8 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { | 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.| +| 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**. | @@ -1274,13 +1274,13 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { | Name | Default Value | Description | | ---------------------------------------- | ---- | ------------------------- | | SUCCESS | 0 | Installation succeeded. | -| STATUS_INSTALL_FAILURE | 1 | Installation failed. (The application to be installed does not exist.) | +| STATUS_INSTALL_FAILURE | 1 | Installation failed. (The application to be installed is not found.) | | STATUS_INSTALL_FAILURE_ABORTED | 2 | Installation aborted. | | STATUS_INSTALL_FAILURE_INVALID | 3 | Invalid installation parameter. | -| STATUS_INSTALL_FAILURE_CONFLICT | 4 | Installation conflict. (The basic information about the application to upgrade is inconsistent with that of the existing application.) | +| STATUS_INSTALL_FAILURE_CONFLICT | 4 | Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.) | | STATUS_INSTALL_FAILURE_STORAGE | 5 | Failed to store the bundle information. | -| STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | Installation incompatible. (A downgrade occurs or the signature information is incorrect.) | -| STATUS_UNINSTALL_FAILURE | 7 | Uninstallation failed. (The application to be uninstalled does not exist.) | +| STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | Installation incompatibility. (A downgrade occurs or the signature information is incorrect.) | +| STATUS_UNINSTALL_FAILURE | 7 | Uninstallation failed. (The application to be uninstalled is not found.) | | STATUS_UNINSTALL_FAILURE_BLOCKED | 8 | Uninstallation aborted. (This error code is not in use.) | | STATUS_UNINSTALL_FAILURE_ABORTED | 9 | Uninstallation aborted. (Invalid parameters.) | | STATUS_UNINSTALL_FAILURE_CONFLICT | 10 | Uninstallation conflict. (Failed to uninstall a system application or end the application process.)| @@ -1309,9 +1309,9 @@ Enumerates bundle flags. | 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_METADATA8+ | 0x00000020 | Obtains the ability metadata information. | -| GET_BUNDLE_WITH_EXTENSION_ABILITY9+ | 0x00000020 | Obtains the bundle information with the Extension ability information.| +| GET_BUNDLE_WITH_EXTENSION_ABILITY9+ | 0x00000020 | Obtains the bundle information with the Extension ability information. | | GET_APPLICATION_INFO_WITH_METADATA8+ | 0x00000040 | Obtains the application metadata information. | -| GET_ABILITY_INFO_SYSTEMAPP_ONLY8+ | 0x00000080 | Obtains the ability information with information about system applications.| +| GET_ABILITY_INFO_SYSTEMAPP_ONLY8+ | 0x00000080 | Obtains the ability information of system applications.| | GET_ABILITY_INFO_WITH_DISABLE8+ | 0x00000100 | Obtains information about disabled abilities. | | GET_APPLICATION_INFO_WITH_DISABLE8+ | 0x00000200 | Obtains information about disabled applications. | | GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information. | @@ -1324,7 +1324,7 @@ 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.| +| 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. | ## BundleInfo @@ -1343,7 +1343,7 @@ Describes the application bundle information. | appInfo | ApplicationInfo | Yes | No | Application configuration information. | | abilityInfos | 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.| +| 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. | @@ -1355,7 +1355,7 @@ Describes the application bundle information. | 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. | +| entryInstallationFree | boolean | Yes | No | Whether installation-free is supported for the entry module. | | reqPermissionStates8+ | Array\ | Yes | No | Permission grant state. | | extensionAbilityInfo9+ | Array\ | Yes | No | Extended information of the ability. | @@ -1376,7 +1376,7 @@ Describes the application information. | 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 the application runs. If this parameter is not set, the bundle name is used by default.| +| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used.| | 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. | @@ -1398,8 +1398,8 @@ Describes the module information of the application. | Name | Type | Readable | Writable | Description | | --------------- | ------ | ---- | ---- | ---- | -| moduleName | string | Yes | No | Module name.| -| moduleSourceDir | string | Yes | No | Installation directory.| +| moduleName | string | Yes | No | Module name. | +| moduleSourceDir | string | Yes | No | Installation directory. | ## CustomizeData @@ -1409,7 +1409,7 @@ Describes the custom metadata. | Name | Type | Readable | Writable | Description | | ------------------ | ------ | ---- | ---- | -------- | -| name | string | Yes | Yes | Custom metadata name.| +| name | string | Yes | Yes | Custom metadata name. | | value | string | Yes | Yes | Custom metadata value. | | extra8+ | string | Yes | Yes | Custom resources. | @@ -1438,7 +1438,7 @@ Describes the HAP module information. | mainAbilityName | string | Yes | No | Name of the entry ability. | | installationFree | boolean | Yes | No | Whether installation-free is supported. | | mainElementName9+ | string | Yes | No | Information about the entry ability. | -| extensionAbilityInfo9+ | Array\ | Yes | No | Extension ability information.| +| extensionAbilityInfo9+ | Array\ | Yes | No | Extension ability information. | | metadata9+ | Array\ | Yes | No | Metadata of the ability. | ## ReqPermissionDetail @@ -1451,7 +1451,7 @@ Describes the detailed information of the permissions to request from the system | --------- | --------- | ---- | ---- | ---------- | | 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 | UsedScene | Yes | Yes | Application scenario and timing for using the permission. | ## UsedScene @@ -1461,7 +1461,7 @@ Describes the application scenario and timing for using the permission. | Name | Type | Readable | Writable | Description | | --------- | -------------- | ---- | ---- | ---------------- | -| abilities | Array\ | Yes | Yes | Abilities that use the permission.| +| abilities | Array\ | Yes | Yes | Abilities that use the permission. | | when | string | Yes | Yes | Time when the permission is used. | @@ -1481,7 +1481,7 @@ Describes the ability information. | 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.| +| 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 the 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. | @@ -1489,7 +1489,7 @@ Describes the ability information. | 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.| +| 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. | @@ -1513,7 +1513,7 @@ Enumerates ability types. | 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.| +| DATA | None | Ability that is used to provide data access services. | ## DisplayOrientation @@ -1526,7 +1526,7 @@ Enumerates display orientations. | 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.| +| FOLLOW_RECENT | None | The page ability orientation is the same as that of the nearest ability in the stack. | ## LaunchMode @@ -1536,7 +1536,7 @@ Enumerates launch modes. | Name | Type | Description | | --------- | ---- | ------------- | -| SINGLETON | 0 | The ability has only one instance.| +| SINGLETON | 0 | The ability has only one instance. | | STANDARD | 1 | The ability can have multiple instances. | ## AbilitySubType @@ -1548,7 +1548,7 @@ Enumerates ability subtypes. | Name | Type | Description | | ----------- | ---- | -------------------- | | UNSPECIFIED | 0 | Undefined ability subtype. | -| CA | 1 | Ability that has a UI.| +| CA | 1 | Ability that has a UI. | ## ExtensionAbilityType9+ @@ -1560,12 +1560,12 @@ Enumerates Extension ability types. | Name | Type | Description | | ------------------------------ | ---- | ------------------------- | | FORM9+ | 0 | Form included. | -| WORK_SCHEDULER9+ | 1 | Work scheduler included.| +| WORK_SCHEDULER9+ | 1 | Work scheduler included. | | INPUT_METHOD9+ | 2 | Input method included. | | SERVICE9+ | 3 | Service included. | | ACCESSIBILITY9+ | 4 | Accessibility included. | -| DATA_SHARE9+ | 5 | Data sharing included.| -| FILE_SHARE9+ | 6 | File sharing included.| +| DATA_SHARE9+ | 5 | Data sharing included. | +| FILE_SHARE9+ | 6 | File sharing included. | | STATIC_SUBSCRIBER9+ | 7 | Subscribers included. | | WALLPAPER9+ | 8 | Wallpaper included. | | UNSPECIFIED9+ | 9 | Unspecified type. | @@ -1581,7 +1581,7 @@ Enumerates Extension flags. | GET_EXTENSION_INFO_DEFAULT9+ | 0x00000000 | Obtains the default Extension ability information. | | GET_EXTENSION_INFO_WITH_PERMISSION9+ | 0x00000002 | Obtains the Extension ability information that carries permission information. | | GET_EXTENSION_INFO_WITH_APPLICATION9+ | 0x00000004 | Obtains the Extension ability information that carries application information. | -| GET_EXTENSION_INFO_WITH_METADATA9+ | 0x00000020 | Obtains the Extension ability information that carries metadata information.| +| GET_EXTENSION_INFO_WITH_METADATA9+ | 0x00000020 | Obtains the Extension ability information that carries metadata information. | ## ColorMode @@ -1592,20 +1592,20 @@ Enumerates color modes. | Name | Type | Description | | ---------- | ---- | ---- | -| AUTO_MODE | -1 | Automatic mode.| -| DARK_MODE | 0 | Dark mode.| -| LIGHT_MODE | 1 | Light mode.| +| AUTO_MODE | -1 | Automatic mode. | +| DARK_MODE | 0 | Dark mode. | +| LIGHT_MODE | 1 | Light mode. | ## GrantStatus -Enumerates permission grant statuses. +Enumerates permission grant states. **System capability**: SystemCapability.BundleManager.BundleFramework | Name | Type | Description | | ------------------ | ---- | ---- | -| PERMISSION_DENIED | -1 | Permission denied.| +| PERMISSION_DENIED | -1 | Permission denied. | | PERMISSION_GRANTED | 0 | Permission granted. | @@ -1625,7 +1625,7 @@ Describes the Extension ability information. | iconId9+ | number | Yes | No | Icon ID of the Extension ability. | | isVisible9+ | boolean | Yes | No | Whether the Extension ability can be called by other applications. | | extensionAbilityType9+ | bundle.ExtensionAbilityType | Yes | No | Type of the Extension ability. | -| permissions9+ | Array\ | Yes | No | Permissions required for other applications to call the Extension ability.| +| permissions9+ | Array\ | Yes | No | Permissions required for other applications to call the Extension ability. | | applicationInfo9+ | ApplicationInfo | Yes | No | Application configuration information. | | metaData9+ | Array\ | Yes | No | Metadata of the Extension ability. | | enabled9+ | boolean | Yes | No | Whether the Extension ability is enabled. | @@ -1641,6 +1641,6 @@ Describes the metadata information. | Name | Type | Readable | Writable | Description | | --------------------- | ------ | ---- | ---- | ----- | -| name9+ | string | Yes | Yes | Metadata name.| +| name9+ | string | Yes | Yes | Metadata name. | | value9+ | string | Yes | Yes | Metadata value. | -| resource9+ | string | Yes | Yes | Metadata resource.| +| resource9+ | string | Yes | Yes | Metadata resource. | diff --git a/en/application-dev/reference/apis/js-apis-Context.md b/en/application-dev/reference/apis/js-apis-Context.md index bc7b0afa88f6e9ee253b8cd8af3a5ba6633ce8b6..62ab1faf7ec09a0323252ce17873d1aca9ba13f1 100644 --- a/en/application-dev/reference/apis/js-apis-Context.md +++ b/en/application-dev/reference/apis/js-apis-Context.md @@ -1,6 +1,6 @@ # Context Module -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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 @@ -30,9 +30,9 @@ If this API is called for the first time, a root directory will be created. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | -------- | ---------------------- | ---- | -------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the local root directory.| +| callback | AsyncCallback\ | Yes | Callback used to return the local root directory. | **Example** @@ -58,9 +58,9 @@ If this API is called for the first time, a root directory will be created. **Return value** -| Type | Description | +| Type | Description | | ---------------- | ---------------------- | -| Promise\ | Promise used to return the local root directory.| +| Promise\ | Promise used to return the local root directory. | **Example** @@ -84,11 +84,11 @@ Verifies whether a specific PID and UID have the given permission. This API uses **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** @@ -113,10 +113,10 @@ Verifies whether the current PID and UID have the given permission. This API use **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** @@ -136,16 +136,16 @@ Verifies whether a specific PID and UID have the given permission. This API uses **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ---------- | --------------------------------------- | ---- | ---------------- | -| permission | string | Yes | Name of the permission to verify.| -| options | [PermissionOptions](#permissionoptions) | No | Permission options. | +| permission | string | Yes | Name of the permission to verify. | +| options | [PermissionOptions](#permissionoptions) | No | Permission options. | **Return value** -| Type | Description | +| Type | Description | | ---------------- | ----------------------------------------------------------- | -| 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.| +| 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. | **Example** @@ -171,11 +171,11 @@ Requests certain permissions from the system. This API uses an asynchronous call **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** @@ -207,9 +207,9 @@ Obtains information about the current application. This API uses an asynchronous **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** @@ -231,9 +231,9 @@ Obtains information about the current application. This API uses a promise to re **Return value** -| Type | Description | +| Type | Description | | ------------------------- | ------------------ | -| Promise\ | Promise used to return the application information.| +| Promise\ | Promise used to return the application information. | **Example** @@ -258,9 +258,9 @@ Obtains the bundle name of the current ability. This API uses an asynchronous ca **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** @@ -282,9 +282,9 @@ Obtains the bundle name of the current ability. This API uses a promise to retur **Return value** -| Type | Description | +| Type | Description | | ---------------- | ------------------------- | -| Promise\ | Promise used to return the bundle name.| +| Promise\ | Promise used to return the bundle name. | **Example** @@ -309,9 +309,9 @@ Obtains information about the current process, including the PID and process nam **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** @@ -333,9 +333,9 @@ Obtains information about the current process, including the PID and process nam **Return value** -| Type | Description | +| Type | Description | | --------------------- | -------------- | -| Promise\ | Promise used to return the process information.| +| Promise\ | Promise used to return the process information. | **Example** @@ -362,9 +362,9 @@ This API is available only to Page abilities. **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** @@ -388,9 +388,9 @@ This API is available only to Page abilities. **Return value** -| Type | Description | +| Type | Description | | --------------------- | ------------------------------------------ | -| Promise\ | Promise used to return the **ohos.bundle.ElementName** object.| +| Promise\ | Promise used to return the **ohos.bundle.ElementName** object. | **Example** @@ -413,9 +413,9 @@ Obtains the name of the current process. This API uses an asynchronous callback **Parameters** -| Name | Type | Mandatory| Description | +| 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** @@ -437,9 +437,9 @@ Obtains the name of the current process. This API uses a promise to return the r **Return value** -| Type | Description | +| Type | Description | | ---------------- | -------------------- | -| Promise\ | Promise used to return the process name.| +| Promise\ | Promise used to return the process name. | **Example** @@ -464,9 +464,9 @@ Obtains the bundle name of the calling ability. This API uses an asynchronous ca **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** @@ -488,9 +488,9 @@ Obtains the bundle name of the calling ability. This API uses a promise to retur **Return value** -| Type | Description | +| Type | Description | | --------------- | ------------------------- | -| Promise\ | Promise used to return the bundle name.| +| Promise\ | Promise used to return the bundle name. | **Example** @@ -513,9 +513,9 @@ Obtains the cache directory of the application on the internal storage. This API **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the cache directory.| +| callback | AsyncCallback\ | Yes | Callback used to return the cache directory. | **Example** @@ -541,9 +541,9 @@ Obtains the cache directory of the application on the internal storage. This API **Return value** -| Type | Description | +| Type | Description | | --------------- | ------------------------- | -| Promise\ | Promise used to return the cache directory.| +| Promise\ | Promise used to return the cache directory. | **Example** @@ -566,9 +566,9 @@ Obtains the file directory of the application on the internal storage. This API **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the file directory.| +| callback | AsyncCallback\ | Yes | Callback used to return the file directory. | **Example** @@ -594,9 +594,9 @@ Obtains the file directory of the application on the internal storage. This API **Return value** -| Type | Description | +| Type | Description | | --------------- | ------------------------- | -| Promise\ | Promise used to return the file directory.| +| Promise\ | Promise used to return the file directory. | **Example** @@ -621,9 +621,9 @@ If the distributed file path does not exist, the system will create one and retu **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path.| +| callback | AsyncCallback\ | Yes | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path. | **Example** @@ -651,9 +651,9 @@ If the distributed file path does not exist, the system will create one and retu **Return value** -| Type | Description | +| Type | Description | | --------------- | ------------------------- | -| Promise\ | Promise used to return the distributed file path. If this API is called for the first time, a new path will be created.| +| Promise\ | Promise used to return the distributed file path. If this API is called for the first time, a new path will be created. | **Example** @@ -675,9 +675,9 @@ Obtains the application type. This API uses an asynchronous callback to return t **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the application type.| +| callback | AsyncCallback\ | Yes | Callback used to return the application type. | **Example** @@ -703,9 +703,9 @@ Obtains the application type. This API uses a promise to return the result. **Return value** -| Type | Description | +| Type | Description | | --------------- | ------------------------- | -| Promise\ | Promise used to return the application type.| +| Promise\ | Promise used to return the application type. | **Example** @@ -727,9 +727,9 @@ Obtains the **ModuleInfo** object of the application. This API uses an asynchron **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | Yes | Callback used to return the **ModuleInfo** object.| +| callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | Yes | Callback used to return the **ModuleInfo** object. | **Example** @@ -755,9 +755,9 @@ Obtains the **ModuleInfo** object of the application. This API uses a promise to **Return value** -| Type | Description | +| Type | Description | | --------------- | ------------------------- | -| Promise\<[HapModuleInfo](#hapmoduleinfo)> | Promise used to return the **ModuleInfo** object.| +| Promise\<[HapModuleInfo](#hapmoduleinfo)> | Promise used to return the **ModuleInfo** object. | **Example** @@ -779,9 +779,9 @@ Obtains the version information of the application. This API uses an asynchronou **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information.| +| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information. | **Example** @@ -807,9 +807,9 @@ Obtains the version information of the application. This API uses a promise to r **Return value** -| Type | Description | +| Type | Description | | --------------- | ------------------------- | -| Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information.| +| Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information. | **Example** @@ -831,9 +831,9 @@ Obtains information of the current ability. This API uses an asynchronous callba **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes |Callback used to return the ability information.| +| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes |Callback used to return the ability information. | **Example** @@ -859,9 +859,9 @@ Obtains information of the current ability. This API uses a promise to return th **Return value** -| Type | Description | +| Type | Description | | --------------- | ------------------------- | -| Promise\<[AbilityInfo](#abilityInfo)> | Promise used to return the ability information.| +| Promise\<[AbilityInfo](#abilityInfo)> | Promise used to return the ability information. | **Example** @@ -883,9 +883,9 @@ Obtains the context of the application. **Return value** -| Type | Description | +| Type | Description | | --------- |------ | -| Context |Application context.| +| Context |Application context. | **Example** @@ -898,48 +898,48 @@ var context = featureAbility.getContext().getApplicationContext(); **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Readable/Writable| Type | Mandatory| Description | +| Name| Readable/Writable | Type | Mandatory | Description | | ---- | -------- | ------ | ---- | ------ | -| pid | Read-only | number | No | Process ID.| -| uid | Read-only | number | No | User ID.| +| pid | Read-only | number | No | Process ID. | +| uid | Read-only | number | No | User ID. | ## PermissionRequestResult7+ **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| 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 requested. | -| authResults | Read-only | Array\ | Yes | Permission request result. | +| requestCode | Read-only | number | Yes | Request code passed. | +| permissions | Read-only | Array\ | Yes | Permissions requested. | +| authResults | Read-only | Array\ | Yes | Permission request result. | ## HapModuleInfo7+ Describes the HAP module information. -| Name | Type| Readable| Writable| Description| +| 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 entrance ability. | -| installationFree | boolean | Yes | No | When installation-free is supported. | -| mainElementName | string | Yes| No| Information about the entry ability.| +| 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 entrance ability. | +| installationFree | boolean | Yes | No | When installation-free is supported. | +| mainElementName | string | Yes| No| Information about the entry ability. | ## AppVersionInfo7+ -| Name | Type| Readable | Writable | Description| -| ------ | ------ | ------| ------ | ------ | -| appName | string | Yes | No | Module name. | -| versionCode | number | Yes | No | Module description. | -| versionName | string | Yes | No | Module description ID. | +| Name | Type| Readable | Writable | Description | +| ------ | ------ | ------| ------ | ------ | +| appName | string | Yes | No | Module name. | +| versionCode | number | Yes | No | Module description. | +| versionName | string | Yes | No | Module description ID. | diff --git a/en/application-dev/reference/apis/js-apis-DataUriUtils.md b/en/application-dev/reference/apis/js-apis-DataUriUtils.md index 267ba0d27b3fbf9e3b35a8dbb884da04286f5729..1434ebb8d645af7ae531374769b8534bd5de0910 100644 --- a/en/application-dev/reference/apis/js-apis-DataUriUtils.md +++ b/en/application-dev/reference/apis/js-apis-DataUriUtils.md @@ -1,6 +1,6 @@ # DataUriUtils Module -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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 @@ -19,15 +19,15 @@ Obtains the ID attached to the end of a given URI. **Parameters** -| Name| Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ---- | ------ | ---- | --------------------------- | -| uri | string | Yes | URI object from which the ID is to be obtained.| +| uri | string | Yes | URI object from which the ID is to be obtained. | **Return value** -| Type | Description | +| Type | Description | | ------ | ------------------------ | -| number | ID obtained from the URI object.| +| number | ID obtained from the URI object. | **Example** @@ -47,16 +47,16 @@ Attaches an ID to the end of a given URI. **Parameters** -| Name| Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ---- | ------ | ---- | --------------------------- | -| uri | string | Yes | URI object to which an ID is to be attached.| -| id | number | Yes | ID to be attached. | +| uri | string | Yes | URI object to which an ID is to be attached. | +| id | number | Yes | ID to be attached. | **Return value** -| Type | Description | +| Type | Description | | ------ | --------------------- | -| string | URI object with the ID attached.| +| string | URI object with the ID attached. | **Example** @@ -80,15 +80,15 @@ Deletes the ID from the end of a given URI. **Parameters** -| Name| Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ---- | ------ | ---- | --------------------------- | -| uri | string | Yes | URI object from which the ID is to be deleted.| +| uri | string | Yes | URI object from which the ID is to be deleted. | **Return value** -| Type | Description | +| Type | Description | | ------ | ------------------- | -| string | URI object with the ID deleted.| +| string | URI object with the ID deleted. | **Example** @@ -108,16 +108,16 @@ Updates the ID in a given URI. **Parameters** -| Name| Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------------- | -| uri | string | Yes | URI object to be updated.| -| id | number | Yes | New ID. | +| uri | string | Yes | URI object to be updated. | +| id | number | Yes | New ID. | **Return value** -| Type | Description | +| Type | Description | | ------ | --------------- | -| string | URI object with the new ID.| +| string | URI object with the new ID. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md index 9db4123736ac6f7a03605c931713076e13f7d2c6..59f2b5f535283e04d6f1b499ee4e9e733f204da8 100644 --- a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @@ -1,6 +1,6 @@ # Work Scheduler Callbacks -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 9. API version 9 is a canary version for trial use. The APIs of this version may be unstable. @@ -20,9 +20,9 @@ Triggered when the Work Scheduler task starts. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ---- | --------------------- | ---- | -------------- | -| work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | Yes | Task to be added to the execution queue.| +| work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | Yes | Task to be added to the execution queue.| **Example** @@ -44,9 +44,9 @@ Triggered when the Work Scheduler task stops. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ---- | --------------------- | ---- | -------------- | -| work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | Yes | Task to be added to the execution queue.| +| work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | Yes | Task to be added to the execution queue.| **Example** 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 efab6fdd1273d247e6b95c5c5f6bc422abfcef96..b938552925150af55ec98375d48af7d9c4a78e54 100644 --- a/en/application-dev/reference/apis/js-apis-ability-context.md +++ b/en/application-dev/reference/apis/js-apis-ability-context.md @@ -1,6 +1,6 @@ # AbilityContext -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -28,7 +28,7 @@ class MainAbility extends Ability { **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Type| Readable| Writable| Description| +| Name | Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | | abilityInfo | AbilityInfo | Yes| No| Ability information.| | currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.| @@ -44,7 +44,7 @@ Starts an ability. This API uses a callback to return the result. **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| @@ -73,7 +73,7 @@ Starts an ability. This API uses a callback to return the result. **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | options | StartOptions | Yes| Parameters used for starting the ability.| @@ -106,14 +106,14 @@ Starts an ability. This API uses a promise to return the result. **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | options | StartOptions | No| Parameters used for starting the ability.| **Return value** - | Type| Description| + | Type | Description | | -------- | -------- | | Promise<void> | Promise used to return the result.| @@ -147,7 +147,7 @@ Starts an ability. This API uses a callback to return the execution result when **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| @@ -175,7 +175,7 @@ Starts an ability. This API uses a callback to return the execution result when **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | options | StartOptions | Yes| Parameters used for starting the ability.| @@ -208,7 +208,7 @@ Starts an ability. This API uses a promise to return the execution result when t **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | options | StartOptions | No| Parameters used for starting the ability.| @@ -216,7 +216,7 @@ Starts an ability. This API uses a promise to return the execution result when t **Return value** - | Type| Description| + | Type | Description | | -------- | -------- | | Promise<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Promise used to return the result.| @@ -244,7 +244,7 @@ Terminates this ability. This API uses a callback to return the result. **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the API is successfully called.| @@ -267,7 +267,7 @@ Terminates this ability. This API uses a promise to return the result. **Return value** - | Type| Description| + | Type | Description | | -------- | -------- | | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| @@ -292,7 +292,7 @@ Terminates this ability. This API uses a callback to return the information to t **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| @@ -321,13 +321,13 @@ Terminates this ability. This API uses a promise to return information to the ca **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.| **Return value** - | Type| Description| + | Type | Description | | -------- | -------- | | Promise<void> | Promise used to return the result.| @@ -355,13 +355,13 @@ Obtains the caller interface of the specified ability, and if the specified abil **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 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| + | Type | Description | | -------- | -------- | | Promise<Caller> | Promise used to return the caller object to communicate with.| @@ -397,7 +397,7 @@ Requests permissions from the user by displaying a pop-up window. This API uses **Parameters** - | Name| Type| Mandatory| Description| + | 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 API is successfully called.| @@ -421,13 +421,13 @@ Requests permissions from the user by displaying a pop-up window. This API uses **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | permissions | Array<string> | Yes| Permissions to request.| **Return value** - | Type| Description| + | Type | Description | | -------- | -------- | | Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result indicating whether the API is successfully called.| @@ -452,7 +452,7 @@ Sets the label of the ability displayed in the task. This API uses a callback to **Parameters** - | Name| Type| Mandatory| Description| + | 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 API is successfully called.| @@ -476,13 +476,13 @@ Sets the label of the ability displayed in the task. This API uses a promise to **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | label | string | Yes| Label of the ability to set.| **Return value** - | Type| Description| + | Type | Description | | -------- | -------- | | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| diff --git a/en/application-dev/reference/apis/js-apis-ability-errorCode.md b/en/application-dev/reference/apis/js-apis-ability-errorCode.md index e81e9d60f6bcf0d1b5f0376057f577c2b467f45d..d882c9b5ce0870438d9372a8470efcf5c5dad5b8 100644 --- a/en/application-dev/reference/apis/js-apis-ability-errorCode.md +++ b/en/application-dev/reference/apis/js-apis-ability-errorCode.md @@ -1,7 +1,7 @@ # ErrorCode -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. @@ -17,9 +17,9 @@ Defines the error code used when the ability is started. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name | Value | Description | +| Name | Value | Description | | ------------------------------ | ---- | ---------------------------------------- | -| NO_ERROR | 0 | No error occurs. | -| INVALID_PARAMETER | -1 | Invalid parameter.| -| ABILITY_NOT_FOUND | -2 | The ability is not found.| -| PERMISSION_DENY | -3 | Permission denied. | +| NO_ERROR | 0 | No error occurs. | +| INVALID_PARAMETER | -1 | Invalid parameter. | +| ABILITY_NOT_FOUND | -2 | The ability is not found. | +| PERMISSION_DENY | -3 | Permission denied. | diff --git a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md index ef6e3e60018a4124ef5d917217599b520d550fe1..1190acad72e203ec1d42e7f2c4979938156bad50 100644 --- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md +++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md @@ -1,7 +1,7 @@ # wantConstant -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. @@ -20,32 +20,32 @@ Lists the permissions. | Common Event Macro | Common Event Name | Subscriber Permission | | ------------ | ------------------ | ---------------------- | -| ACTION_HOME | ohos.want.action.home | None | -| ACTION_DIAL | ohos.want.action.dial | None | -| ACTION_SEARCH | ohos.want.action.search | None | -| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | None | -| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | None | -| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None | -| ACTION_SET_ALARM | ohos.want.action.setAlarm | None | -| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | None | -| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | None | -| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | None | -| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | None | -| ACTION_SEND_SMS | ohos.want.action.sendSms | None | -| ACTION_CHOOSE | ohos.want.action.choose | None | -| ACTION_IMAGE_CAPTURE8+ | ohos.want.action.imageCapture | None | -| ACTION_VIDEO_CAPTUR8+ | ohos.want.action.videoCapture | None | -| ACTION_SELECT | ohos.want.action.select | None | -| ACTION_SEND_DATA | ohos.want.action.sendData | None | -| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | None | -| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | None | -| ACTION_VIEW_DATA | ohos.want.action.viewData | None | -| ACTION_EDIT_DATA | ohos.want.action.editData | None | -| INTENT_PARAMS_INTENT | ability.want.params.INTENT | None | -| INTENT_PARAMS_TITLE | ability.want.params.TITLE | None | -| ACTION_FILE_SELECT7+ | ohos.action.fileSelect | None | -| PARAMS_STREAM7+ | ability.params.stream | None | -| ACTION_APP_ACCOUNT_OAUTH 8+ | ohos.account.appAccount.action.oauth | None | +| ACTION_HOME | ohos.want.action.home | None | +| ACTION_DIAL | ohos.want.action.dial | None | +| ACTION_SEARCH | ohos.want.action.search | None | +| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | None | +| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | None | +| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None | +| ACTION_SET_ALARM | ohos.want.action.setAlarm | None | +| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | None | +| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | None | +| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | None | +| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | None | +| ACTION_SEND_SMS | ohos.want.action.sendSms | None | +| ACTION_CHOOSE | ohos.want.action.choose | None | +| ACTION_IMAGE_CAPTURE8+ | ohos.want.action.imageCapture | None | +| ACTION_VIDEO_CAPTUR8+ | ohos.want.action.videoCapture | None | +| ACTION_SELECT | ohos.want.action.select | None | +| ACTION_SEND_DATA | ohos.want.action.sendData | None | +| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | None | +| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | None | +| ACTION_VIEW_DATA | ohos.want.action.viewData | None | +| ACTION_EDIT_DATA | ohos.want.action.editData | None | +| INTENT_PARAMS_INTENT | ability.want.params.INTENT | None | +| INTENT_PARAMS_TITLE | ability.want.params.TITLE | None | +| ACTION_FILE_SELECT7+ | ohos.action.fileSelect | None | +| PARAMS_STREAM7+ | ability.params.stream | None | +| ACTION_APP_ACCOUNT_OAUTH 8+ | ohos.account.appAccount.action.oauth | None | ## wantConstant.Entity @@ -56,12 +56,12 @@ Lists the permissions. | Common Event Macro | Common Event Name | Subscriber Permission | | ------------ | ------------------ | ---------------------- | -| ENTITY_DEFAULT | entity.system.default | None | -| ENTITY_HOME | entity.system.homel | None | -| ENTITY_VOICE | ENTITY_VOICE | None | -| ENTITY_BROWSABLE | entity.system.browsable | None | -| ENTITY_VIDEO | entity.system.video | None | -| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None | +| ENTITY_DEFAULT | entity.system.default | None | +| ENTITY_HOME | entity.system.homel | None | +| ENTITY_VOICE | ENTITY_VOICE | None | +| ENTITY_BROWSABLE | entity.system.browsable | None | +| ENTITY_VIDEO | entity.system.video | None | +| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None | ## flags @@ -70,19 +70,19 @@ Lists the permissions. | 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 continued on a remote device. | -| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. | -| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. | -| 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 ability continuation 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 in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.| -| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Indicates the operation of creating a mission on the history 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. | +| 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 continued on a remote device. | +| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. | +| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. | +| 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 ability continuation 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 in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**. | +| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Indicates the operation of creating a mission on the history 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. | diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 874341bd76311b8d5efeb676e256813dc926e58e..19a4ec0d9226f01e4a695bf5b9bb60369562a8ed 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -1,6 +1,6 @@ -# Ability Access Control +# Ability Access Control -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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 @@ -20,9 +20,9 @@ Creates an **AtManager** instance, which is used for ability access control. **Return value** -| Type| Description| -| -------- | -------- | -| [AtManager](#atmanager) | **AtManager** instance obtained.| + | Type | Description | + | -------- | -------- | + | [AtManager](#atmanager) | **AtManager** instance obtained. | **Example** @@ -44,16 +44,16 @@ Checks whether an application has been granted the specified permission. This AP **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------- | ---- | ------------------------------------------ | -| tokenID | number | Yes | ID of the application. | -| permissionName | string | Yes | Name of the permission to verify.| + | Name | Type | Mandatory | Description | + | -------- | ------------------- | ---- | ------------------------------------------ | + | tokenID | number | Yes | ID of the application. | + | permissionName | string | Yes | Name of the permission to verify. | **Return value** -| Type | Description | -| :------------ | :---------------------------------- | -| Promise<GrantStatus> | Promise instance used to return the result.| + | Type | Description | + | :------------ | :---------------------------------- | + | Promise<GrantStatus> | Promise used to return the result. | **Example** @@ -78,17 +78,17 @@ Grants a user granted permission to an application. This API uses a promise to r **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------- | ---- | ------------------------------------------------------------ | -| tokenID | number | Yes | ID of the application. | -| permissionName | string | Yes | Name of the permission to grant.| -| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | + | Name | Type | Mandatory | Description | + | --------- | ------------------- | ---- | ------------------------------------------------------------ | + | tokenID | number | Yes | ID of the application. | + | permissionName | string | Yes | Name of the permission to grant. | + | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | **Return value** -| Type | Description | -| :------------ | :---------------------------------- | -| Promise<number> | Promise instance used to return the result.| + | Type | Description | + | :------------ | :---------------------------------- | + | Promise<number> | Promise used to return the result. | **Example** @@ -115,12 +115,12 @@ Grants a user granted permission to an application. This API uses an asynchronou **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------- | ---- | ------------------------------------------------------------ | -| tokenID | number | Yes | ID of the application. | -| permissionName | string | Yes | Name of the permission to grant.| -| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | -| callback | AsyncCallback<number> | Yes| Callback used to return the result.| + | Name | Type | Mandatory | Description | + | --------- | ------------------- | ---- | ------------------------------------------------------------ | + | tokenID | number | Yes | ID of the application. | + | permissionName | string | Yes | Name of the permission to grant. | + | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | + | callback | AsyncCallback<number> | Yes | Callback used to return the result. | **Example** @@ -145,17 +145,17 @@ Revokes a user granted permission given to an application. This API uses a promi **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------- | ---- | ------------------------------------------------------------ | -| tokenID | number | Yes | ID of the application. | -| permissionName | string | Yes | Name of the permission to revoke.| -| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | + | Name | Type | Mandatory | Description | + | --------- | ------------------- | ---- | ------------------------------------------------------------ | + | tokenID | number | Yes | ID of the application. | + | permissionName | string | Yes | Name of the permission to revoke. | + | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | **Return value** -| Type | Description | -| :------------ | :---------------------------------- | -| Promise<number> | Promise instance used to return the result.| + | Type | Description | + | :------------ | :---------------------------------- | + | Promise<number> | Promise used to return the result. | **Example** @@ -181,12 +181,12 @@ Revokes a user granted permission given to an application. This API uses an asyn **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------- | ---- | ------------------------------------------------------------ | -| tokenID | number | Yes | ID of the application. | -| permissionName | string | Yes | Name of the permission to revoke.| -| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | -| callback | AsyncCallback<number> | Yes| Callback used to return the result.| + | Name | Type | Mandatory | Description | + | --------- | ------------------- | ---- | ------------------------------------------------------------ | + | tokenID | number | Yes | ID of the application. | + | permissionName | string | Yes | Name of the permission to revoke. | + | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | + | callback | AsyncCallback<number> | Yes | Callback used to return the result. | **Example** @@ -210,16 +210,16 @@ Obtains the flags of the specified permission of a given application. This API u **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------- | ---- | ------------------------------------------------------------ | -| tokenID | number | Yes | ID of the application. | -| permissionName | string | Yes | Name of the permission to query.| + | Name | Type | Mandatory | Description | + | --------- | ------------------- | ---- | ------------------------------------------------------------ | + | tokenID | number | Yes | ID of the application. | + | permissionName | string | Yes | Name of the permission to query. | **Return value** -| Type | Description | -| :------------ | :---------------------------------- | -| Promise<number> | Promise instance used to return the result.| + | Type | Description | + | :------------ | :---------------------------------- | + | Promise<number> | Promise used to return the result. | **Example** @@ -238,7 +238,7 @@ Enumerates the permission grant states. **System capability**: SystemCapability.Security.AccessToken -| Name | Default Value | Description | -| ----------------------------- | ---------------------- | ----------------------- | -| PERMISSION_DENIED | -1 | Permission denied. | -| PERMISSION_GRANTED | 0 | Permission granted. | + | Name | Default Value | Description | + | ----------------------------- | ---------------------- | ----------------------- | + | PERMISSION_DENIED | -1 | Permission denied. | + | PERMISSION_GRANTED | 0 | Permission granted. | diff --git a/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md b/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md index 5f772d8706f2872fbea97c59e42f7dfd878575df..65769dc7a2fbe62443957c415ca5c095e9473d52 100644 --- a/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md +++ b/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md @@ -1,7 +1,6 @@ # AbilityDelegatorRegistry -> **NOTE** -> +> **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 @@ -18,13 +17,13 @@ Enumerates the ability lifecycle states. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name | Value | Description | -| ------------- | ---- | --------------------------- | -| UNINITIALIZED | 0 | The ability is in an invalid state. | -| CREATE | 1 | The ability is created.| -| FOREGROUND | 2 | The ability is running in the foreground. | -| BACKGROUND | 3 | The ability is running in the background. | -| DESTROY | 4 | The ability is destroyed.| + | Name | Value | Description | + | ------------- | ---- | --------------------------- | + | UNINITIALIZED | 0 | The ability is in an invalid state. | + | CREATE | 1 | The ability is created. | + | FOREGROUND | 2 | The ability is running in the foreground. | + | BACKGROUND | 3 | The ability is running in the background. | + | DESTROY | 4 | The ability is destroyed. | @@ -38,9 +37,9 @@ Obtains the **AbilityDelegator** object of the application. **Return value** -| Type | Description | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule functions related to the test framework.| + | Type | Description | + | ------------------------------------------------------------ | ------------------------------------------------------------ | + | [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule functions related to the test framework. | **Example** @@ -62,9 +61,9 @@ Obtains the **AbilityDelegatorArgs** object of the application. **Return value** -| Type | Description | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) | [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) object, which can be used to obtain test parameters.| + | Type | Description | + | ------------------------------------------------------------ | ------------------------------------------------------------ | + | [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) | [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) object, which can be used to obtain test parameters. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md index b4f137e8d3f3da19beb7a1b5a8bbbc8a4ab74ee3..b516987cb8fd30b49f1aa2152b1024feb3a81b15 100644 --- a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md +++ b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md @@ -1,6 +1,6 @@ # AbilityRunningInfo -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. @@ -25,14 +25,14 @@ abilitymanager.getAbilityRunningInfos((err,data) => { **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| ability | ElementName | Yes| No| Information that matches an ability. | -| pid | number | Yes| No| Process ID.| -| uid | number | Yes| No| User ID. | -| processName | string | Yes| No| Process name. | -| startTime | number | Yes| No| Ability start time. | -| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes| No| Ability state. | + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | ability | ElementName | Yes | No | Information that matches an ability. | + | pid | number | Yes | No | Process ID. | + | uid | number | Yes | No | User ID. | + | processName | string | Yes | No | Process name. | + | startTime | number | Yes | No | Ability start time. | + | abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes | No | Ability state. | ## abilityManager.AbilityState @@ -41,10 +41,10 @@ Enumerates the ability states. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Value| Description| -| -------- | -------- | -------- | -| INITIAL | 0 | The ability is in the initial state.| -| FOREGROUND | 9 | The ability is in the foreground state. | -| BACKGROUND | 10 | The ability is in the background state. | -| FOREGROUNDING | 11 | The ability is in the foregrounding state. | -| BACKGROUNDING | 12 | The ability is in the backgrounding state. | + | Name | Value | Description | + | -------- | -------- | -------- | + | INITIAL | 0 | The ability is in the initial state. | + | FOREGROUND | 9 | The ability is in the foreground state. | + | BACKGROUND | 10 | The ability is in the background state. | + | FOREGROUNDING | 11 | The ability is in the foregrounding state. | + | BACKGROUNDING | 12 | The ability is in the backgrounding state. | diff --git a/en/application-dev/reference/apis/js-apis-abilitystagecontext.md b/en/application-dev/reference/apis/js-apis-abilitystagecontext.md index f5d9e951461c0ff77ac85e75bd60c6d657074a66..b2d4b885de5f85efcda7f0f5d8f4b9031d027bbd 100644 --- a/en/application-dev/reference/apis/js-apis-abilitystagecontext.md +++ b/en/application-dev/reference/apis/js-apis-abilitystagecontext.md @@ -1,6 +1,6 @@ # AbilityStageContext -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -28,7 +28,7 @@ class MyAbilityStage extends AbilityStage { **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Type| Readable| Writable| Description| +| Name| Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| currentHapModuleInfo | HapModuleInfo | Yes| No| **ModuleInfo** object corresponding to the **AbilityStage**.| -| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running.| +| currentHapModuleInfo | HapModuleInfo | Yes | No | **ModuleInfo** object corresponding to the **AbilityStage**. | +| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running. | diff --git a/en/application-dev/reference/apis/js-apis-accessibility.md b/en/application-dev/reference/apis/js-apis-accessibility.md index c39e6e8f9437e64b3f05f59986ec08d35170eb71..17ef631d0f7207b676177a59d0903cc77dcd1045 100644 --- a/en/application-dev/reference/apis/js-apis-accessibility.md +++ b/en/application-dev/reference/apis/js-apis-accessibility.md @@ -1,6 +1,6 @@ # Accessibility -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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 @@ -15,11 +15,11 @@ Enumerates the states of an accessibility application. **System capability**: SystemCapability.Barrierfree.Accessibility.Core -| Name| Description| -| -------- | -------- | -| enable | The accessibility application is enabled.| -| disable | The accessibility application is disabled.| -| install | The accessibility application has been installed.| + | Name | Description | + | -------- | -------- | + | enable | The accessibility application is enabled. | + | disable | The accessibility application is disabled. | + | install | The accessibility application has been installed. | ## AbilityType @@ -27,13 +27,13 @@ Enumerates the types of accessibility applications. **System capability**: SystemCapability.Barrierfree.Accessibility.Core -| Name| Description| -| -------- | -------- | -| audible | The accessibility application provides audible feedback.| -| generic | The accessibility application provides generic feedback.| -| haptic | The accessibility application provides haptic feedback.| -| spoken | The accessibility application provides spoken feedback.| -| visual | The accessibility application provides visual feedback.| + | Name | Description | + | -------- | -------- | + | audible | The accessibility application provides audible feedback. | + | generic | The accessibility application provides generic feedback. | + | haptic | The accessibility application provides haptic feedback. | + | spoken | The accessibility application provides spoken feedback. | + | visual | The accessibility application provides visual feedback. | ## AccessibilityAbilityInfo @@ -43,15 +43,15 @@ Provides information about an accessibility application. ### Attributes -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| id | number | Yes| No| Ability ID.| -| name | string | Yes| No| Ability name.| -| bundleName | string | Yes| No| Bundle name.| -| abilityTypes | Array<[AbilityType](#abilitytype)> | Yes| No| Accessibility application type.| -| capabilities | Array<[Capability](#capability)> | Yes| No| Capabilities list of the accessibility application.| -| description | string | Yes| No| Description of the accessibility application.| -| eventTypes | Array<[EventType](#eventtype)> | Yes| No| List of events that the accessibility application focuses on.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | id | number | Yes | No | Ability ID. | + | name | string | Yes | No | Ability name. | + | bundleName | string | Yes | No | Bundle name. | + | abilityTypes | Array<[AbilityType](#abilitytype)> | Yes | No | Accessibility application type. | + | capabilities | Array<[Capability](#capability)> | Yes | No | Capabilities list of the accessibility application. | + | description | string | Yes | No | Description of the accessibility application. | + | eventTypes | Array<[EventType](#eventtype)> | Yes | No | List of events that the accessibility application focuses on. | ## Action @@ -59,24 +59,24 @@ Describes the target action supported by an accessibility application. **System capability**: SystemCapability.Barrierfree.Accessibility.Core -| Name| Description| -| -------- | -------- | -| click | Clicking.| -| longClick | Long pressing.| -| scrollForward | Scrolling forward.| -| scrollBackward | Scrolling backward.| -| focus | Obtaining focus.| -| clearFocus | Clearing focus.| -| clearSelection | Clearing selection.| -| accessibilityFocus | Obtaining the accessibility focus.| -| clearAccessibilityFocus | Clearing the accessibility focus.| -| cut | Cut.| -| copy | Copy.| -| paste | Paste.| -| select | Select.| -| setText | Setting the text.| -| delete | Delete.| -| setSelection | Setting the selection.| + | Name | Description | + | -------- | -------- | + | click | Clicking. | + | longClick | Long pressing. | + | scrollForward | Scrolling forward. | + | scrollBackward | Scrolling backward. | + | focus | Obtaining focus. | + | clearFocus | Clearing focus. | + | clearSelection | Clearing selection. | + | accessibilityFocus | Obtaining the accessibility focus. | + | clearAccessibilityFocus | Clearing the accessibility focus. | + | cut | Cut. | + | copy | Copy. | + | paste | Paste. | + | select | Select. | + | setText | Setting the text. | + | delete | Delete. | + | setSelection | Setting the selection. | ## Capability @@ -84,13 +84,13 @@ Enumerates the capabilities of an auxiliary application. **System capability**: SystemCapability.Barrierfree.Accessibility.Core -| Name| Description| -| -------- | -------- | -| retrieve | Capability to retrieve the window content.| -| touchGuide | Capability of touch guide mode.| -| keyEventObserver | Capability to filter key events.| -| zoom | Capability to control the display zoom level.| -| gesture | Capability to perform gesture actions.| + | Name | Description | + | -------- | -------- | + | retrieve | Capability to retrieve the window content. | + | touchGuide | Capability of touch guide mode. | + | keyEventObserver | Capability to filter key events. | + | zoom | Capability to control the display zoom level. | + | gesture | Capability to perform gesture actions. | ## CaptionsFontEdgeType8+ @@ -98,13 +98,13 @@ Enumerates the caption font edge type. **System capability**: SystemCapability.Barrierfree.Accessibility.Hearing -| Name| Description| -| -------- | -------- | -| none | No effect.| -| raised | Raised effect.| -| depressed | Depressed effect.| -| uniform | Uniform effect.| -| dropShadow | Drop shadow effect.| + | Name | Description | + | -------- | -------- | + | none | No effect. | + | raised | Raised effect. | + | depressed | Depressed effect. | + | uniform | Uniform effect. | + | dropShadow | Drop shadow effect. | ## CaptionsFontFamily8+ @@ -112,16 +112,16 @@ Enumerates the caption font families. **System capability**: SystemCapability.Barrierfree.Accessibility.Hearing -| Name| Description| -| -------- | -------- | -| default | Default font family.| -| monospacedSerif | Monospaced Serif fonts, which use the same width for each character.| -| serif | Serif fonts.| -| monospacedSansSerif | Monospaced Sans Serif fonts, which use the same width for each character.| -| sansSerif | Sans Serif fonts.| -| casual | Casual fonts.| -| cursive | Cursive fonts.| -| smallCapitals | Small caps fonts.| + | Name | Description | + | -------- | -------- | + | default | Default font family. | + | monospacedSerif | Monospaced Serif fonts, which use the same width for each character. | + | serif | Serif fonts. | + | monospacedSansSerif | Monospaced Sans Serif fonts, which use the same width for each character. | + | sansSerif | Sans Serif fonts. | + | casual | Casual fonts. | + | cursive | Cursive fonts. | + | smallCapitals | Small caps fonts. | ## CaptionsStyle8+ @@ -129,14 +129,14 @@ Describes the caption style. **System capability**: SystemCapability.Barrierfree.Accessibility.Hearing -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | Yes| No| Font family of the captions.| -| fontScale | number | Yes| No| Font scale of the captions.| -| fontColor | number \| string | Yes| No| Font color of the captions.| -| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | Yes| No| Font edge type of the captions.| -| backgroundColor | number \| string | Yes| No| Background color of the captions.| -| windowColor | number \| string | Yes| No| Window color of the captions.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | Yes | No | Font family of the captions. | + | fontScale | number | Yes | No | Font scale of the captions. | + | fontColor | number \ | string | Yes | No | Font color of the captions. | + | fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | Yes | No | Font edge type of the captions. | + | backgroundColor | number \ | string | Yes | No | Background color of the captions. | + | windowColor | number \ | string | Yes | No | Window color of the captions. | ## CaptionsManager8+ @@ -144,10 +144,10 @@ Implements caption configuration management. ### Attributes -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| enabled | boolean | Yes| No| Whether to enable caption configuration.| -| style | [CaptionsStyle](#captionsstyle8) | Yes| No| Caption style.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | enabled | boolean | Yes | No | Whether to enable caption configuration. | + | style | [CaptionsStyle](#captionsstyle8) | Yes | No | Caption style. | ### Methods @@ -163,10 +163,10 @@ Enables listening for enable status changes of caption configuration. - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Type of the event to listen for, which is set to **enableChange** in this API.| - | callback | Callback<boolean> | Yes| Callback invoked when the enable status of caption configuration changes.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to listen for, which is set to **enableChange** in this API. | + | callback | Callback<boolean> | Yes | Callback invoked when the enable status of caption configuration changes. | - Example @@ -186,10 +186,10 @@ Enables listening for caption style changes. - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Type of the event to listen for, which is set to **styleChange** in this API.| - | callback | Callback<[CaptionsStyle](#captionsstyle8)> | Yes| Callback invoked when the caption style changes.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to listen for, which is set to **styleChange** in this API. | + | callback | Callback<[CaptionsStyle](#captionsstyle8)> | Yes | Callback invoked when the caption style changes. | - Example @@ -209,10 +209,10 @@ Disables listening for enable status changes of caption configuration. - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Type of the event to listen for, which is set to **enableChange** in this API.| - | callback | Callback<boolean> | No| Callback invoked when the enable status of caption configuration changes.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to listen for, which is set to **enableChange** in this API. | + | callback | Callback<boolean> | No | Callback invoked when the enable status of caption configuration changes. | - Example @@ -230,10 +230,10 @@ Disables listening for caption style changes.s is removed. - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Type of the event to listen for, which is set to **styleChange** in this API.| - | callback | Callback<[CaptionsStyle](#captionsstyle8)> | No| Callback invoked when the caption style changes.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to listen for, which is set to **styleChange** in this API. | + | callback | Callback<[CaptionsStyle](#captionsstyle8)> | No | Callback invoked when the caption style changes. | - Example @@ -249,22 +249,22 @@ Describes a GUI change event. ### Attributes -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| type | [EventType](#eventtype) | Yes| Yes| Accessibility event type.| -| windowUpdateType | [WindowUpdateType](#windowupdatetype) | Yes| Yes| Window update type.| -| bundleName | string | Yes| Yes| Target application name.| -| componentType | string | Yes| Yes| Type of the event source component, for example, button or chart.| -| pageId | number | Yes| Yes| Page ID of the event source.| -| description | string | Yes| Yes| Event description.| -| triggerAction | [Action](#action) | Yes| Yes| Action that triggers the event.| -| textMoveUnit | [TextMoveUnit](#textmoveunit) | Yes| Yes| Text movement unit.| -| contents | Array<string> | Yes| Yes| Array of contents.| -| lastContent | string | Yes| Yes| Latest content.| -| beginIndex | number | Yes| Yes| Sequence number of the first item displayed on the page.| -| currentIndex | number | Yes| Yes| Sequence number of the current item.| -| endIndex | number | Yes| Yes| Sequence number of the last item displayed on the page.| -| itemCount | number | Yes| Yes| Total number of items.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | type | [EventType](#eventtype) | Yes | Yes | Accessibility event type. | + | windowUpdateType | [WindowUpdateType](#windowupdatetype) | Yes | Yes | Window update type. | + | bundleName | string | Yes | Yes | Target application name. | + | componentType | string | Yes | Yes | Type of the event source component, for example, button or chart. | + | pageId | number | Yes | Yes | Page ID of the event source. | + | description | string | Yes | Yes | Event description. | + | triggerAction | [Action](#action) | Yes | Yes | Action that triggers the event. | + | textMoveUnit | [TextMoveUnit](#textmoveunit) | Yes | Yes | Text movement unit. | + | contents | Array<string> | Yes | Yes | Array of contents. | + | lastContent | string | Yes | Yes | Latest content. | + | beginIndex | number | Yes | Yes | Sequence number of the first item displayed on the page. | + | currentIndex | number | Yes | Yes | Sequence number of the current item. | + | endIndex | number | Yes | Yes | Sequence number of the last item displayed on the page. | + | itemCount | number | Yes | Yes | Total number of items. | ## EventType @@ -272,19 +272,19 @@ Enumerates accessibility event types. **System capability**: SystemCapability.Barrierfree.Accessibility.Core -| Name| Description| -| -------- | -------- | -| click | Event of clicking a component.| -| longClick | Event of long-pressing a component.| -| select | Event of selecting a component.| -| focus | Event indicating that the component obtains the focus.| -| textUpdate | Event indicating that the component text has been updated.| -| hoverEnter | Event indicating that the hover enters a component.| -| hoverExit | Event indicating that the hover exits a component.| -| scroll | Event of the scroll view.| -| textSelectionUpdate | Event indicating that the selected text has been updated.| -| accessibilityFocus | Event indicating that the accessibility focus has been obtained.| -| accessibilityFocusClear | Event indicating that the accessibility focus has been cleared.| + | Name | Description | + | -------- | -------- | + | click | Event of clicking a component. | + | longClick | Event of long-pressing a component. | + | select | Event of selecting a component. | + | focus | Event indicating that the component obtains the focus. | + | textUpdate | Event indicating that the component text has been updated. | + | hoverEnter | Event indicating that the hover enters a component. | + | hoverExit | Event indicating that the hover exits a component. | + | scroll | Event of the scroll view. | + | textSelectionUpdate | Event indicating that the selected text has been updated. | + | accessibilityFocus | Event indicating that the accessibility focus has been obtained. | + | accessibilityFocusClear | Event indicating that the accessibility focus has been cleared. | ## TextMoveUnit @@ -292,13 +292,13 @@ Enumerates the movement units for traversing the node text. **System capability**: SystemCapability.Barrierfree.Accessibility.Core -| Name| Description| -| -------- | -------- | -| char | The movement unit for traversing the node text is by character.| -| word | The movement unit for traversing the node text is by word.| -| line | The movement unit for traversing the node text is by line.| -| page | The movement unit for traversing the node text is by page.| -| paragraph | The movement unit for traversing the node text is by paragraph.| + | Name | Description | + | -------- | -------- | + | char | The movement unit for traversing the node text is by character. | + | word | The movement unit for traversing the node text is by word. | + | line | The movement unit for traversing the node text is by line. | + | page | The movement unit for traversing the node text is by page. | + | paragraph | The movement unit for traversing the node text is by paragraph. | ## WindowUpdateType @@ -306,19 +306,19 @@ Enumerates window update types. **System capability**: SystemCapability.Barrierfree.Accessibility.Core -| Name| Description| -| -------- | -------- | -| add | Window adding.| -| remove | Window deletion.| -| title | Window title change.| -| bounds | Window boundary change.| -| layer | Window layer change.| -| active | Window activity change.| -| focus | Window focus change.| -| accessibilityFocus | Window accessibility focus change.| -| parent | Parent window change.| -| children | Child window change.| -| pip | Picture-in-picture (PIP) mode change.| + | Name | Description | + | -------- | -------- | + | add | Window adding. | + | remove | Window deletion. | + | title | Window title change. | + | bounds | Window boundary change. | + | layer | Window layer change. | + | active | Window activity change. | + | focus | Window focus change. | + | accessibilityFocus | Window accessibility focus change. | + | parent | Parent window change. | + | children | Child window change. | + | pip | Picture-in-picture (PIP) mode change. | ## accessibility.getAbilityLists @@ -330,16 +330,16 @@ Obtains the accessibility application list. This API uses a promise to return th - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.| - | stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | abilityType | [AbilityType](#abilitytype) | Yes | Accessibility application type. | + | stateType | [AbilityState](#abilitystate) | Yes | Accessibility application status. | - Return value - | Type| Description| - | -------- | -------- | - | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise used to return the accessibility application list.| + | Type | Description | + | -------- | -------- | + | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise used to return the accessibility application list. | - Example @@ -373,11 +373,11 @@ Obtains the accessibility application list. This API uses an asynchronous callba - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.| - | stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.| - | callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | abilityType | [AbilityType](#abilitytype) | Yes | Accessibility application type. | + | stateType | [AbilityState](#abilitystate) | Yes | Accessibility application status. | + | callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes | Callback used to return the accessibility application list. | - Example @@ -412,9 +412,9 @@ Obtains the accessibility caption configuration. - Return value - | Type| Description| - | -------- | -------- | - | [CaptionsManager](#captionsmanager8) | Accessibility caption configuration.| + | Type | Description | + | -------- | -------- | + | [CaptionsManager](#captionsmanager8) | Accessibility caption configuration. | - Example @@ -430,10 +430,10 @@ Enables listening for the accessibility application or touch guide mode status c - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Type of the event to listen for.
- **accessibilityStateChange** means to listen for enable status changes of the accessibility application.
**System capability**: SystemCapability.Barrierfree.Accessibility.Core
- **touchGuideStateChange** means to listen for enable status changes of the touch guide mode.
**System capability**: SystemCapability.Barrierfree.Accessibility.Vision| - | callback | Callback<boolean> | Yes| Callback invoked when the enable status changes.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to listen for.
- **accessibilityStateChange** means to listen for enable status changes of the accessibility application.
**System capability**: SystemCapability.Barrierfree.Accessibility.Core
- **touchGuideStateChange** means to listen for enable status changes of the touch guide mode.
**System capability**: SystemCapability.Barrierfree.Accessibility.Vision | + | callback | Callback<boolean> | Yes | Callback invoked when the enable status changes. | - Example @@ -453,10 +453,10 @@ Disables listening for the accessibility application or touch guide mode status - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | No| Type of the event to listen for.
- **accessibilityStateChange** means to listen for enable status changes of the accessibility application.
**System capability**: SystemCapability.Barrierfree.Accessibility.Core
- **touchGuideStateChange** means to listen for enable status changes of the touch guide mode.
**System capability**: SystemCapability.Barrierfree.Accessibility.Vision| - | callback | Callback<boolean> | No| Callback invoked when the enable status changes.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | No | Type of the event to listen for.
- **accessibilityStateChange** means to listen for enable status changes of the accessibility application.
**System capability**: SystemCapability.Barrierfree.Accessibility.Core
- **touchGuideStateChange** means to listen for enable status changes of the touch guide mode.
**System capability**: SystemCapability.Barrierfree.Accessibility.Vision | + | callback | Callback<boolean> | No | Callback invoked when the enable status changes. | - Example @@ -476,9 +476,9 @@ Checks whether accessibility is enabled. This API uses a promise to return the r - Return value - | Type| Description| - | -------- | -------- | - | Promise<boolean> | Returns **true** if accessibility is enabled; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | Promise<boolean> | Returns **true** if accessibility is enabled; returns **false** otherwise. | - Example @@ -501,9 +501,9 @@ Checks whether accessibility is enabled. This API uses an asynchronous callback - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise. | - Example @@ -527,9 +527,9 @@ Checks whether touch guide mode is enabled. This API uses a promise to return th - Return value - | Type| Description| - | -------- | -------- | - | Promise<boolean> | Returns **true** if touch guide mode is enabled; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | Promise<boolean> | Returns **true** if touch guide mode is enabled; returns **false** otherwise. | - Example @@ -552,9 +552,9 @@ Checks whether touch guide mode is enabled. This API uses an asynchronous callba - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise. | - Example @@ -578,15 +578,15 @@ Sends an accessibility event. This API uses a promise to return the result. - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | event | [EventInfo](#eventinfo) | Yes| Accessibility event.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | event | [EventInfo](#eventinfo) | Yes | Accessibility event. | - Return value - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise.| + | Type | Description | + | -------- | -------- | + | Promise<void> | Promise used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise. | - Example @@ -609,10 +609,10 @@ Sends an accessibility event. This API uses an asynchronous callback to return t - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | event | [EventInfo](#eventinfo) | Yes| Accessibility event.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | event | [EventInfo](#eventinfo) | Yes | Accessibility event. | + | callback | AsyncCallback<void> | Yes | Callback used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise. | - Example diff --git a/en/application-dev/reference/apis/js-apis-animator.md b/en/application-dev/reference/apis/js-apis-animator.md index b259fe732e26348601c1d7a8e8a5002abe2a8a2b..d3fbcfa4e05459bfb3bad3964d5cb30eec215a56 100644 --- a/en/application-dev/reference/apis/js-apis-animator.md +++ b/en/application-dev/reference/apis/js-apis-animator.md @@ -1,7 +1,7 @@ # Animation ->![](../../public_sys-resources/icon-note.gif) **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. +> **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 diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md index 30d7ac0dd8a49df8f05cab425baa6d781d18371e..3577652546daea30400c7eadafd7e6771a55db77 100644 --- a/en/application-dev/reference/apis/js-apis-appAccount.md +++ b/en/application-dev/reference/apis/js-apis-appAccount.md @@ -1,6 +1,6 @@ -# App Account Management +# App Account Management -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. @@ -20,9 +20,9 @@ Creates an **AppAccountManager** instance. **System capability**: SystemCapability.Account.AppAccount **Return Value** -| Type | Description | -| ----------------- | ------------ | -| AppAccountManager | **AppAccountManager** instance created.| + | Type | Description | + | ----------------- | ------------ | + | AppAccountManager | **AppAccountManager** instance created. | **Example** ```js @@ -43,10 +43,10 @@ Adds an app account to the account management service. This method uses an async **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | --------------------- | -| name | string | Yes | Name of the app account to add. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is added.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | --------------------- | + | name | string | Yes | Name of the app account to add. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is added. | **Example** @@ -67,11 +67,11 @@ Adds an app account and its additional information to the account management ser **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------------------------- | ---- | ---------------------------------------- | -| name | string | Yes | Name of the app account to add. | -| extraInfo | string | Yes | Additional information (for example, token) of the app account to add. The additional information cannot contain sensitive information about the app account.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the app account and its additional information are added. | + | Name | Type | Mandatory | Description | + | --------- | ------------------------- | ---- | ---------------------------------------- | + | name | string | Yes | Name of the app account to add. | + | extraInfo | string | Yes | Additional information (for example, token) of the app account to add. The additional information cannot contain sensitive information about the app account. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the app account and its additional information are added. | **Example** @@ -94,16 +94,16 @@ Adds an app account and its additional information to the account management ser **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------ | ---- | -------------------------------- | -| name | string | Yes | Name of the app account to add. | -| extraInfo | string | Yes | Additional information of the app account to add. The additional information cannot contain sensitive information about the app account.| + | Name | Type | Mandatory | Description | + | --------- | ------ | ---- | -------------------------------- | + | name | string | Yes | Name of the app account to add. | + | extraInfo | string | Yes | Additional information of the app account to add. The additional information cannot contain sensitive information about the app account. | **Return Value** -| Type | Description | -| ------------------- | --------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | ------------------- | --------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -126,12 +126,12 @@ Implicitly adds an app account based on the specified account owner, authenticat **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------- | ---- | --------------- | -| owner | string | Yes | Bundle name of the app account to add.| -| authType | string | Yes | Authentication type of the app account to add. | -| options | {[key: string]: any} | Yes | Options for the authentication. | -| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.| + | Name | Type | Mandatory | Description | + | -------- | --------------------- | ---- | --------------- | + | owner | string | Yes | Bundle name of the app account to add. | + | authType | string | Yes | Authentication type of the app account to add. | + | options | {[key: string]: any} | Yes | Options for the authentication. | + | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. | **Example** @@ -167,10 +167,10 @@ Deletes an app account from the account management service. This method uses an **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ----------------- | -| name | string | Yes | Name of the app account to delete. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is deleted.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ----------------- | + | name | string | Yes | Name of the app account to delete. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is deleted. | **Example** @@ -191,15 +191,15 @@ Deletes an app account from the account management service. This method uses a p **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| name | string | Yes | Name of the app account to delete.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | name | string | Yes | Name of the app account to delete. | **Return Value** -| Type | Description | -| :------------------ | :-------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | :------------------ | :-------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -222,11 +222,11 @@ Disables an app account from accessing an application with the given bundle name **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ------------------------- | ---- | ------------------------------- | -| name | string | Yes | App account name. | -| bundleName | string | Yes | Bundle name of an app. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is disabled from accessing the application with the given bundle name.| + | Name | Type | Mandatory | Description | + | ---------- | ------------------------- | ---- | ------------------------------- | + | name | string | Yes | App account name. | + | bundleName | string | Yes | Bundle name of an app. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is disabled from accessing the application with the given bundle name. | **Example** @@ -247,16 +247,16 @@ Disables an app account from accessing an application with the given bundle name **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ------ | ---- | ----------------- | -| name | string | Yes | App account name.| -| bundleName | string | Yes | Bundle name of an app. | + | Name | Type | Mandatory | Description | + | ---------- | ------ | ---- | ----------------- | + | name | string | Yes | App account name. | + | bundleName | string | Yes | Bundle name of an app. | **Return Value** -| Type | Description | -| :------------------ | :-------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | :------------------ | :-------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -279,11 +279,11 @@ Enables an app account to access an application with the given bundle name. This **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ------------------------- | ---- | ------------------------------- | -| name | string | Yes | App account name. | -| bundleName | string | Yes | Bundle name of an app. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is enabled to access the application with the given bundle name.| + | Name | Type | Mandatory | Description | + | ---------- | ------------------------- | ---- | ------------------------------- | + | name | string | Yes | App account name. | + | bundleName | string | Yes | Bundle name of an app. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is enabled to access the application with the given bundle name. | **Example** @@ -304,16 +304,16 @@ Enables an app account to access an application with the given bundle name. This **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ------ | ---- | --------- | -| name | string | Yes | App account name. | -| bundleName | string | Yes | Bundle name of an app.| + | Name | Type | Mandatory | Description | + | ---------- | ------ | ---- | --------- | + | name | string | Yes | App account name. | + | bundleName | string | Yes | Bundle name of an app. | **Return Value** -| Type | Description | -| :------------------ | :-------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | :------------------ | :-------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -337,10 +337,10 @@ Checks whether an app account allows application data synchronization. This meth **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------- | ---- | ---------------------- | -| name | string | Yes | App account name. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the app account allows application data synchronization.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------- | ---- | ---------------------- | + | name | string | Yes | App account name. | + | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the app account allows application data synchronization. | **Example** @@ -364,15 +364,15 @@ Checks whether an app account allows application data synchronization. This meth **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------- | -| name | string | Yes | App account name.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------- | + | name | string | Yes | App account name. | **Return Value** -| Type | Description | -| :--------------------- | :-------------------- | -| Promise<boolean> | Promise used to return the result.| + | Type | Description | + | :--------------------- | :-------------------- | + | Promise<boolean> | Promise used to return the result. | **Example** @@ -395,12 +395,12 @@ Sets a credential for an app account. This method uses an asynchronous callback **Parameters** -| Name | Type | Mandatory | Description | -| -------------- | ------------------------- | ---- | -------------- | -| name | string | Yes | App account name. | -| credentialType | string | Yes | Type of the credential to set. | -| credential | string | Yes | Credential to set. | -| callback | AsyncCallback<void> | Yes | Callback invoked when a credential is set for the specified app account.| + | Name | Type | Mandatory | Description | + | -------------- | ------------------------- | ---- | -------------- | + | name | string | Yes | App account name. | + | credentialType | string | Yes | Type of the credential to set. | + | credential | string | Yes | Credential to set. | + | callback | AsyncCallback<void> | Yes | Callback invoked when a credential is set for the specified app account. | **Example** @@ -421,17 +421,17 @@ Sets a credential for an app account. This method uses a promise to return the r **Parameters** -| Name | Type | Mandatory | Description | -| -------------- | ------ | ---- | ---------- | -| name | string | Yes | App account name. | -| credentialType | string | Yes | Type of the credential to set.| -| credential | string | Yes | Credential to set. | + | Name | Type | Mandatory | Description | + | -------------- | ------ | ---- | ---------- | + | name | string | Yes | App account name. | + | credentialType | string | Yes | Type of the credential to set. | + | credential | string | Yes | Credential to set. | **Return Value** -| Type | Description | -| :------------------ | :-------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | :------------------ | :-------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -454,11 +454,11 @@ Sets additional information for an app account. This method uses an asynchronous **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------------------------- | ---- | ---------------- | -| name | string | Yes | App account name. | -| extraInfo | string | Yes | Additional information to set. | -| callback | AsyncCallback<void> | Yes | Callback invoked when additional information is set for the specified app account.| + | Name | Type | Mandatory | Description | + | --------- | ------------------------- | ---- | ---------------- | + | name | string | Yes | App account name. | + | extraInfo | string | Yes | Additional information to set. | + | callback | AsyncCallback<void> | Yes | Callback invoked when additional information is set for the specified app account. | **Example** @@ -479,16 +479,16 @@ Sets additional information for an app account. This method uses a promise to re **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------ | ---- | --------- | -| name | string | Yes | App account name. | -| extraInfo | string | Yes | Additional information to set.| + | Name | Type | Mandatory | Description | + | --------- | ------ | ---- | --------- | + | name | string | Yes | App account name. | + | extraInfo | string | Yes | Additional information to set. | **Return Value** -| Type | Description | -| :------------------ | :-------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | :------------------ | :-------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -513,11 +513,11 @@ Sets whether to enable application data synchronization for an app account. This **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ------------------------- | -| name | string | Yes | App account name. | -| isEnable | boolean | Yes | Whether to enable app data synchronization. | -| callback | AsyncCallback<void> | Yes | Callback invoked when application data synchronization is enabled or disabled for the app account.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------------------- | + | name | string | Yes | App account name. | + | isEnable | boolean | Yes | Whether to enable app data synchronization. | + | callback | AsyncCallback<void> | Yes | Callback invoked when application data synchronization is enabled or disabled for the app account. | **Example** @@ -540,16 +540,16 @@ Sets whether to enable application data synchronization for an app account. This **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------- | ---- | ----------- | -| name | string | Yes | App account name. | -| isEnable | boolean | Yes | Whether to enable app data synchronization.| + | Name | Type | Mandatory | Description | + | -------- | ------- | ---- | ----------- | + | name | string | Yes | App account name. | + | isEnable | boolean | Yes | Whether to enable app data synchronization. | **Return Value** -| Type | Description | -| :------------------ | :-------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | :------------------ | :-------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -572,12 +572,12 @@ Sets data to be associated with an app account. This method uses an asynchronous **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ----------------- | -| name | string | Yes | App account name. | -| key | string | Yes | Key of the data to set. The private key can be customized.| -| value | string | Yes | Value of the data to be set. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the data associated with the specified app account is set.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ----------------- | + | name | string | Yes | App account name. | + | key | string | Yes | Key of the data to set. The private key can be customized. | + | value | string | Yes | Value of the data to be set. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the data associated with the specified app account is set. | **Example** @@ -597,17 +597,17 @@ Sets data to be associated with an app account. This method uses a promise to re **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----------------- | -| name | string | Yes | App account name. | -| key | string | Yes | Key of the data to set. The private key can be customized.| -| value | string | Yes | Value of the data to be set. | + | Name | Type | Mandatory | Description | + | ----- | ------ | ---- | ----------------- | + | name | string | Yes | App account name. | + | key | string | Yes | Key of the data to set. The private key can be customized. | + | value | string | Yes | Value of the data to be set. | **Return Value** -| Type | Description | -| :------------------ | :-------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | :------------------ | :-------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -630,11 +630,11 @@ Obtains the credential of an app account. This method uses an asynchronous callb **Parameters** -| Name | Type | Mandatory | Description | -| -------------- | --------------------------- | ---- | -------------- | -| name | string | Yes | App account name. | -| credentialType | string | Yes | Type of the credential to obtain. | -| callback | AsyncCallback<string> | Yes | Callback invoked to return the credential of the specified app account.| + | Name | Type | Mandatory | Description | + | -------------- | --------------------------- | ---- | -------------- | + | name | string | Yes | App account name. | + | credentialType | string | Yes | Type of the credential to obtain. | + | callback | AsyncCallback<string> | Yes | Callback invoked to return the credential of the specified app account. | **Example** @@ -656,16 +656,16 @@ Obtains the credential of an app account. This method uses a promise to return t **Parameters** -| Name | Type | Mandatory | Description | -| -------------- | ------ | ---- | ---------- | -| name | string | Yes | App account name. | -| credentialType | string | Yes | Type of the credential to obtain.| + | Name | Type | Mandatory | Description | + | -------------- | ------ | ---- | ---------- | + | name | string | Yes | App account name. | + | credentialType | string | Yes | Type of the credential to obtain. | **Return Value** -| Type | Description | -| :-------------------- | :-------------------- | -| Promise<string> | Promise used to return the result.| + | Type | Description | + | :-------------------- | :-------------------- | + | Promise<string> | Promise used to return the result. | **Example** @@ -688,10 +688,10 @@ Obtains additional information of an app account. This method uses an asynchrono **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | ---------------- | -| name | string | Yes | App account name. | -| callback | AsyncCallback<string> | Yes | Callback invoked to return the additional information of the specified app account.| + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | ---------------- | + | name | string | Yes | App account name. | + | callback | AsyncCallback<string> | Yes | Callback invoked to return the additional information of the specified app account. | **Example** @@ -713,15 +713,15 @@ Obtains additional information of an app account. This method uses a promise to **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------- | -| name | string | Yes | App account name.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------- | + | name | string | Yes | App account name. | **Return Value** -| Type | Description | -| :-------------------- | :-------------------- | -| Promise<string> | Promise used to return the result.| + | Type | Description | + | :-------------------- | :-------------------- | + | Promise<string> | Promise used to return the result. | **Example** @@ -744,11 +744,11 @@ Obtains data associated with an app account. This method uses an asynchronous ca **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | ----------------- | -| name | string | Yes | App account name. | -| key | string | Yes | Key of the data to obtain. | -| callback | AsyncCallback<string> | Yes | Callback invoked to return the data associated with the specified app account.| + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | ----------------- | + | name | string | Yes | App account name. | + | key | string | Yes | Key of the data to obtain. | + | callback | AsyncCallback<string> | Yes | Callback invoked to return the data associated with the specified app account. | **Example** @@ -770,16 +770,16 @@ Obtains data associated with an app account. This method uses a promise to retur **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ----------- | -| name | string | Yes | App account name. | -| key | string | Yes | Key of the data to obtain.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------- | + | name | string | Yes | App account name. | + | key | string | Yes | Key of the data to obtain. | **Return Value** -| Type | Description | -| :-------------------- | :-------------------- | -| Promise<string> | Promise used to return the result.| + | Type | Description | + | :-------------------- | :-------------------- | + | Promise<string> | Promise used to return the result. | **Example** @@ -804,9 +804,9 @@ Obtains information about all accessible app accounts. This method uses an async **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | -------- | -| callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | -------- | + | callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts. | **Example** @@ -830,9 +830,9 @@ Obtains information about all accessible app accounts. This method uses an async **Parameters** -| Type | Description | -| ---------------------------------------- | --------------------- | -| Promise<Array<AppAccountInfo>> | Promise used to return the result.| + | Type | Description | + | ---------------------------------------- | --------------------- | + | Promise<Array<AppAccountInfo>> | Promise used to return the result. | **Example** @@ -857,10 +857,10 @@ Obtains information about all app accounts of the specified app. This method use **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | -------- | -| owner | string | Yes | Bundle name of the app. | -| callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | -------- | + | owner | string | Yes | Bundle name of the app. | + | callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts. | **Example** @@ -885,15 +885,15 @@ Obtains information about all app accounts of the specified app. This method use **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----- | -| owner | string | Yes | Bundle name of the app.| + | Name | Type | Mandatory | Description | + | ----- | ------ | ---- | ----- | + | owner | string | Yes | Bundle name of the app. | **Parameters** -| Type | Description | -| ---------------------------------------- | --------------------- | -| Promise<Array<AppAccountInfo>> | Promise used to return the result.| + | Type | Description | + | ---------------------------------------- | --------------------- | + | Promise<Array<AppAccountInfo>> | Promise used to return the result. | **Example** @@ -917,11 +917,11 @@ Subscribes to the account change event of the specified account owners. This met **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ------------------------------ | -| type | 'change' | Yes | Type of the event to subscribe to. The subscriber will receive a notification when the account owners update their accounts.| -| owners | Array<string> | Yes | Owners of the accounts. | -| callback | Callback<Array<AppAccountInfo>> | Yes | Callback invoked to return the account change. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ------------------------------ | + | type | 'change' | Yes | Type of the event to subscribe to. The subscriber will receive a notification when the account owners update their accounts. | + | owners | Array<string> | Yes | Owners of the accounts. | + | callback | Callback<Array<AppAccountInfo>> | Yes | Callback invoked to return the account change. | **Example** @@ -948,10 +948,10 @@ Unsubscribes from the account change event. This method uses an asynchronous cal **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------------------- | ---- | ------------ | -| type | 'change' | Yes | Account change event to unsubscribe from. | -| callback | Callback> | No | Callback used to report the account change.| + | Name | Type | Mandatory | Description | + | -------- | -------------------------------- | ---- | ------------ | + | type | 'change' | Yes | Account change event to unsubscribe from. | + | callback | Callback> | No | Callback used to report the account change. | **Example** @@ -981,13 +981,13 @@ Authenticates an app account to obtain the Open Authorization (OAuth) access tok **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------- | ---- | --------------- | -| name | string | Yes | Name of the app account to authenticate. | -| owner | string | Yes | Bundle name of the app.| -| authType | string | Yes | Authentication type. | -| options | {[key: string]: any} | Yes | Options for the authentication. | -| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.| + | Name | Type | Mandatory | Description | + | -------- | --------------------- | ---- | --------------- | + | name | string | Yes | Name of the app account to authenticate. | + | owner | string | Yes | Bundle name of the app. | + | authType | string | Yes | Authentication type. | + | options | {[key: string]: any} | Yes | Options for the authentication. | + | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. | **Example** @@ -1023,12 +1023,12 @@ Obtains the OAuth access token of an app account based on the specified authenti **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | ----------- | -| name | string | Yes | App account name. | -| owner | string | Yes | Bundle name of the app.| -| authType | string | Yes | Authentication type. | -| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. | + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | ----------- | + | name | string | Yes | App account name. | + | owner | string | Yes | Bundle name of the app. | + | authType | string | Yes | Authentication type. | + | callback | AsyncCallback<string> | Yes | Callback invoked to return the result. | **Example** @@ -1050,17 +1050,17 @@ Obtains the OAuth access token of an app account based on the specified authenti **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------ | ---- | ----------- | -| name | string | Yes | App account name. | -| owner | string | Yes | Bundle name of the app.| -| authType | string | Yes | Authentication type. | + | Name | Type | Mandatory | Description | + | -------- | ------ | ---- | ----------- | + | name | string | Yes | App account name. | + | owner | string | Yes | Bundle name of the app. | + | authType | string | Yes | Authentication type. | **Parameters** -| Type | Description | -| --------------------- | --------------------- | -| Promise<string> | Promise used to return the result.| + | Type | Description | + | --------------------- | --------------------- | + | Promise<string> | Promise used to return the result. | **Example** @@ -1083,12 +1083,12 @@ Sets an OAuth access token for an app account. This method uses an asynchronous **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | -------- | -| name | string | Yes | App account name.| -| authType | string | Yes | Authentication type. | -| token | string | Yes | OAuth access token to set.| -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | -------- | + | name | string | Yes | App account name. | + | authType | string | Yes | Authentication type. | + | token | string | Yes | OAuth access token to set. | + | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | **Example** @@ -1109,17 +1109,17 @@ Sets an OAuth access token for an app account. This method uses a promise to ret **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------ | ---- | -------- | -| name | string | Yes | App account name.| -| authType | string | Yes | Authentication type. | -| token | string | Yes | OAuth access token to set.| + | Name | Type | Mandatory | Description | + | -------- | ------ | ---- | -------- | + | name | string | Yes | App account name. | + | authType | string | Yes | Authentication type. | + | token | string | Yes | OAuth access token to set. | **Parameters** -| Type | Description | -| ------------------- | --------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | ------------------- | --------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -1142,13 +1142,13 @@ Deletes the specified OAuth access token for an app account. This method uses an **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ------------ | -| name | string | Yes | App account name. | -| owner | string | Yes | Bundle name of the app. | -| authType | string | Yes | Authentication type. | -| token | string | Yes | OAuth access token to delete.| -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------ | + | name | string | Yes | App account name. | + | owner | string | Yes | Bundle name of the app. | + | authType | string | Yes | Authentication type. | + | token | string | Yes | OAuth access token to delete. | + | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | **Example** @@ -1169,18 +1169,18 @@ Deletes the specified OAuth access token for an app account. This method uses a **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------ | ---- | ------------ | -| name | string | Yes | App account name. | -| owner | string | Yes | Bundle name of the app. | -| authType | string | Yes | Authentication type. | -| token | string | Yes | OAuth access token to delete.| + | Name | Type | Mandatory | Description | + | -------- | ------ | ---- | ------------ | + | name | string | Yes | App account name. | + | owner | string | Yes | Bundle name of the app. | + | authType | string | Yes | Authentication type. | + | token | string | Yes | OAuth access token to delete. | **Parameters** -| Type | Description | -| ------------------- | --------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | ------------------- | --------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -1203,13 +1203,13 @@ Sets the visibility of an OAuth access token to the specified app. This method u **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ------------------------- | ---- | ------------ | -| name | string | Yes | App account name. | -| authType | string | Yes | Authentication type. | -| bundleName | string | Yes | Bundle name of the app.| -| isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. | -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | + | Name | Type | Mandatory | Description | + | ---------- | ------------------------- | ---- | ------------ | + | name | string | Yes | App account name. | + | authType | string | Yes | Authentication type. | + | bundleName | string | Yes | Bundle name of the app. | + | isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. | + | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | **Example** @@ -1230,18 +1230,18 @@ Sets the visibility of an OAuth access token to the specified app. This method u **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ------- | ---- | ------------ | -| name | string | Yes | App account name. | -| authType | string | Yes | Authentication type. | -| bundleName | string | Yes | Bundle name of the app.| -| isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. | + | Name | Type | Mandatory | Description | + | ---------- | ------- | ---- | ------------ | + | name | string | Yes | App account name. | + | authType | string | Yes | Authentication type. | + | bundleName | string | Yes | Bundle name of the app. | + | isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. | **Parameters** -| Type | Description | -| ------------------- | --------------------- | -| Promise<void> | Promise used to return the result.| + | Type | Description | + | ------------------- | --------------------- | + | Promise<void> | Promise used to return the result. | **Example** @@ -1264,12 +1264,12 @@ Checks whether an OAuth token is visible to the specified app. This method uses **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ---------------------------- | ---- | ------------- | -| name | string | Yes | App account name. | -| authType | string | Yes | Authentication type. | -| bundleName | string | Yes | Bundle name of the app.| -| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. | + | Name | Type | Mandatory | Description | + | ---------- | ---------------------------- | ---- | ------------- | + | name | string | Yes | App account name. | + | authType | string | Yes | Authentication type. | + | bundleName | string | Yes | Bundle name of the app. | + | callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. | **Example** @@ -1291,17 +1291,17 @@ Checks whether an OAuth token is visible to the specified app. This method uses **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ------ | ---- | ------------- | -| name | string | Yes | App account name. | -| authType | string | Yes | Authentication type. | -| bundleName | string | Yes | Bundle name of the app.| + | Name | Type | Mandatory | Description | + | ---------- | ------ | ---- | ------------- | + | name | string | Yes | App account name. | + | authType | string | Yes | Authentication type. | + | bundleName | string | Yes | Bundle name of the app. | **Parameters** -| Type | Description | -| ---------------------- | --------------------- | -| Promise<boolean> | Promise used to return the result.| + | Type | Description | + | ---------------------- | --------------------- | + | Promise<boolean> | Promise used to return the result. | **Example** @@ -1324,11 +1324,11 @@ Obtains information about all OAuth access tokens of an app account visible to t **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ----------- | -| name | string | Yes | App account name. | -| owner | string | Yes | Bundle name of the app.| -| callback | AsyncCallback<Array<OAuthTokenInfo>> | Yes | Callback invoked to return the result. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ----------- | + | name | string | Yes | App account name. | + | owner | string | Yes | Bundle name of the app. | + | callback | AsyncCallback<Array<OAuthTokenInfo>> | Yes | Callback invoked to return the result. | **Example** @@ -1350,16 +1350,16 @@ Obtains information about all OAuth access tokens of an app account visible to t **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----------- | -| name | string | Yes | App account name. | -| owner | string | Yes | Bundle name of the app.| + | Name | Type | Mandatory | Description | + | ----- | ------ | ---- | ----------- | + | name | string | Yes | App account name. | + | owner | string | Yes | Bundle name of the app. | **Parameters** -| Type | Description | -| ---------------------------------------- | --------------------- | -| Promise<Array<OAuthTokenInfo>> | Promise used to return the result.| + | Type | Description | + | ---------------------------------------- | --------------------- | + | Promise<Array<OAuthTokenInfo>> | Promise used to return the result. | **Example** @@ -1382,11 +1382,11 @@ Obtains the authorization list of OAuth access tokens of an app account. This me **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ----------- | -| name | string | Yes | App account name. | -| owner | string | Yes | Bundle name of the app.| -| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ----------- | + | name | string | Yes | App account name. | + | owner | string | Yes | Bundle name of the app. | + | callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. | **Example** @@ -1408,16 +1408,16 @@ Obtains the authorization list of OAuth access tokens of an app account. This me **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----------- | -| name | string | Yes | App account name. | -| owner | string | Yes | Bundle name of the app.| + | Name | Type | Mandatory | Description | + | ----- | ------ | ---- | ----------- | + | name | string | Yes | App account name. | + | owner | string | Yes | Bundle name of the app. | **Parameters** -| Type | Description | -| ---------------------------------- | --------------------- | -| Promise<Array<string>> | Promise used to return the result.| + | Type | Description | + | ---------------------------------- | --------------------- | + | Promise<Array<string>> | Promise used to return the result. | **Example** @@ -1440,10 +1440,10 @@ Obtains the authenticator callback for a session. This method uses an asynchrono **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ---------------------------------------- | ---- | -------- | -| sessionId | string | Yes | ID of the session to authenticate.| -| callback | AsyncCallback<AuthenticatorCallback> | Yes | Callback invoked to return the result.| + | Name | Type | Mandatory | Description | + | --------- | ---------------------------------------- | ---- | -------- | + | sessionId | string | Yes | ID of the session to authenticate. | + | callback | AsyncCallback<AuthenticatorCallback> | Yes | Callback invoked to return the result. | **Example** @@ -1475,15 +1475,15 @@ Obtains the authenticator callback for a session. This method uses a promise to **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------ | ---- | -------- | -| sessionId | string | Yes | ID of the session to authenticate.| + | Name | Type | Mandatory | Description | + | --------- | ------ | ---- | -------- | + | sessionId | string | Yes | ID of the session to authenticate. | **Parameters** -| Type | Description | -| ------------------------------------ | --------------------- | -| Promise<AuthenticatorCallback> | Promise used to return the result.| + | Type | Description | + | ------------------------------------ | --------------------- | + | Promise<AuthenticatorCallback> | Promise used to return the result. | **Example** @@ -1515,10 +1515,10 @@ Obtains authenticator information of an app account. This method uses an asynchr **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------------------------- | ---- | ----------- | -| owner | string | Yes | Bundle name of the app.| -| callback | AsyncCallback<AuthenticatorInfo> | Yes | Callback invoked to return the result. | + | Name | Type | Mandatory | Description | + | -------- | -------------------------------------- | ---- | ----------- | + | owner | string | Yes | Bundle name of the app. | + | callback | AsyncCallback<AuthenticatorInfo> | Yes | Callback invoked to return the result. | **Example** @@ -1540,15 +1540,15 @@ Obtains authenticator information of an app account. This method uses a promise **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----------- | -| owner | string | Yes | Bundle name of the app.| + | Name | Type | Mandatory | Description | + | ----- | ------ | ---- | ----------- | + | owner | string | Yes | Bundle name of the app. | **Parameters** -| Type | Description | -| -------------------------------- | --------------------- | -| Promise<AuthenticatorInfo> | Promise used to return the result.| + | Type | Description | + | -------------------------------- | --------------------- | + | Promise<AuthenticatorInfo> | Promise used to return the result. | **Example** @@ -1567,10 +1567,10 @@ Defines app account information. **System capability**: SystemCapability.Account.AppAccount -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----------- | -| owner | string | Yes | Bundle name of the app.| -| name | string | Yes | App account name. | + | Name | Type | Mandatory | Description | + | ----- | ------ | ---- | ----------- | + | owner | string | Yes | Bundle name of the app. | + | name | string | Yes | App account name. | ## OAuthTokenInfo8+ @@ -1578,10 +1578,10 @@ Defines OAuth access token information. **System capability**: SystemCapability.Account.AppAccount -| Name | Type | Mandatory | Description | -| -------- | ------ | ---- | -------- | -| authType | string | Yes | Authentication type.| -| token | string | Yes | Value of the access token. | + | Name | Type | Mandatory | Description | + | -------- | ------ | ---- | -------- | + | authType | string | Yes | Authentication type. | + | token | string | Yes | Value of the access token. | ## AuthenticatorInfo8+ @@ -1589,11 +1589,11 @@ Defines OAuth authenticator information. **System capability**: SystemCapability.Account.AppAccount -| Name | Type | Mandatory | Description | -| ------- | ------ | ---- | ---------- | -| owner | string | Yes | Bundle name of the authenticator owner.| -| iconId | string | Yes | ID of the authenticator icon. | -| labelId | string | Yes | ID of the authenticator label. | + | Name | Type | Mandatory | Description | + | ------- | ------ | ---- | ---------- | + | owner | string | Yes | Bundle name of the authenticator owner. | + | iconId | string | Yes | ID of the authenticator icon. | + | labelId | string | Yes | ID of the authenticator label. | ## Constants8+ @@ -1601,19 +1601,19 @@ Enumerates the constants. **System capability**: SystemCapability.Account.AppAccount -| Name | Default Value | Description | -| ----------------------------- | ---------------------- | ------------- | -| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation for implicitly adding an account. | -| ACTION_AUTHENTICATE | "authenticate" | Authentication operation. | -| KEY_NAME | "name" | App account name. | -| KEY_OWNER | "owner" | App account owner.| -| KEY_TOKEN | "token" | OAuth access token. | -| KEY_ACTION | "action" | Action. | -| KEY_AUTH_TYPE | "authType" | Authentication type. | -| KEY_SESSION_ID | "sessionId" | Session ID. | -| KEY_CALLER_PID | "callerPid" | Caller process ID (PID). | -| KEY_CALLER_UID | "callerUid" | Caller user ID (UID). | -| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Caller bundle name. | + | Name | Default Value | Description | + | ----------------------------- | ---------------------- | ------------- | + | ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation for implicitly adding an account. | + | ACTION_AUTHENTICATE | "authenticate" | Authentication operation. | + | KEY_NAME | "name" | App account name. | + | KEY_OWNER | "owner" | App account owner. | + | KEY_TOKEN | "token" | OAuth access token. | + | KEY_ACTION | "action" | Action. | + | KEY_AUTH_TYPE | "authType" | Authentication type. | + | KEY_SESSION_ID | "sessionId" | Session ID. | + | KEY_CALLER_PID | "callerPid" | Caller process ID (PID). | + | KEY_CALLER_UID | "callerUid" | Caller user ID (UID). | + | KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Caller bundle name. | ## ResultCode8+ @@ -1621,27 +1621,27 @@ Enumerates the result codes. **System capability**: SystemCapability.Account.AppAccount -| Name | Default Value | Description | -| ----------------------------------- | ----- | ------------ | -| SUCCESS | 0 | The operation is successful. | -| ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist. | -| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal. | -| ERROR_INVALID_PASSWORD | 10003 | The password is invalid. | -| ERROR_INVALID_REQUEST | 10004 | The request is invalid. | -| ERROR_INVALID_RESPONSE | 10005 | The response is invalid. | -| ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal. | -| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist. | -| ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled. | -| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit. | -| ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy. | -| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal. | -| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist. | -| ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out. | -| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth access token does not exist.| -| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth access tokens reaches the limit. | -| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported. | -| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported. | -| ERROR_PERMISSION_DENIED | 10018 | The required permission is missing. | + | Name | Default Value | Description | + | ----------------------------------- | ----- | ------------ | + | SUCCESS | 0 | The operation is successful. | + | ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist. | + | ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal. | + | ERROR_INVALID_PASSWORD | 10003 | The password is invalid. | + | ERROR_INVALID_REQUEST | 10004 | The request is invalid. | + | ERROR_INVALID_RESPONSE | 10005 | The response is invalid. | + | ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal. | + | ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist. | + | ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled. | + | ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit. | + | ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy. | + | ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal. | + | ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist. | + | ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out. | + | ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth access token does not exist. | + | ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth access tokens reaches the limit. | + | ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported. | + | ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported. | + | ERROR_PERMISSION_DENIED | 10018 | The required permission is missing. | ## AuthenticatorCallback8+ @@ -1656,10 +1656,10 @@ Called back to send the authentication result. **System capability**: SystemCapability.Account.AppAccount **Parameters** -| Name | Type | Mandatory | Description | -| ------ | -------------------- | ---- | ------ | -| code | number | Yes | Authentication result code.| -| result | {[key: string]: any} | Yes | Authentication result. | + | Name | Type | Mandatory | Description | + | ------ | -------------------- | ---- | ------ | + | code | number | Yes | Authentication result code. | + | result | {[key: string]: any} | Yes | Authentication result. | **Example** @@ -1686,9 +1686,9 @@ Called back to redirect an authentication request. **System capability**: SystemCapability.Account.AppAccount **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ---- | ---- | ---------- | -| request | Want | Yes | Request to be redirected.| + | Name | Type | Mandatory | Description | + | ------- | ---- | ---- | ---------- | + | request | Want | Yes | Request to be redirected. | **Example** @@ -1723,12 +1723,12 @@ Implicitly adds an app account based on the specified authentication type and op **System capability**: SystemCapability.Account.AppAccount **Parameters** -| Name | Type | Mandatory | Description | -| ---------------- | --------------------- | ---- | --------------- | -| authType | string | Yes | Authentication type. | -| callerBundleName | string | Yes | Bundle name of the authentication requester. | -| options | {[key: string]: any} | Yes | Options for the authentication. | -| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.| + | Name | Type | Mandatory | Description | + | ---------------- | --------------------- | ---- | --------------- | + | authType | string | Yes | Authentication type. | + | callerBundleName | string | Yes | Bundle name of the authentication requester. | + | options | {[key: string]: any} | Yes | Options for the authentication. | + | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. | ### authenticate8+ @@ -1739,13 +1739,13 @@ Authenticates an app account to obtain the OAuth access token. This method uses **System capability**: SystemCapability.Account.AppAccount **Parameters** -| Name | Type | Mandatory | Description | -| ---------------- | --------------------- | ---- | --------------- | -| name | string | Yes | App account name. | -| authType | string | Yes | Authentication type. | -| callerBundleName | string | Yes | Bundle name of the authentication requester. | -| options | {[key: string]: any} | Yes | Options for the authentication. | -| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.| + | Name | Type | Mandatory | Description | + | ---------------- | --------------------- | ---- | --------------- | + | name | string | Yes | App account name. | + | authType | string | Yes | Authentication type. | + | callerBundleName | string | Yes | Bundle name of the authentication requester. | + | options | {[key: string]: any} | Yes | Options for the authentication. | + | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. | **Example** @@ -1771,4 +1771,4 @@ Authenticates an app account to obtain the OAuth access token. This method uses return new MyAuthenticator(); } } - ``` + ``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md index 39fa47376a819eeaa07fcb5e15caef9743cfc0e4..864fc6a90893ac05bb92089cfbd9c4f8e4cc0514 100644 --- a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md +++ b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md @@ -1,7 +1,7 @@ # MissionSnapshot -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. @@ -21,7 +21,7 @@ import { image } from '../@ohos.multimedia.image'; Describes the mission snapshot. - | Name| Type| Readable| Writable| Description| +| Name | Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| ability | ElementName | Yes| Yes| Information that matches an ability.| -| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission.| +| ability | ElementName | Yes | Yes | Information that matches an ability. | +| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission. | diff --git a/en/application-dev/reference/apis/js-apis-application-StartOptions.md b/en/application-dev/reference/apis/js-apis-application-StartOptions.md index 8ce70a8f8657b260f028df9f61ba01dd5d955427..b2a29f392acdac4b4e9bdfbdd1b31c7809671ce5 100644 --- a/en/application-dev/reference/apis/js-apis-application-StartOptions.md +++ b/en/application-dev/reference/apis/js-apis-application-StartOptions.md @@ -1,6 +1,6 @@ # StartOptions -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -9,7 +9,7 @@ ## Modules to Import - + ``` import StartOptions from '@ohos.application.StartOptions'; ``` @@ -18,8 +18,8 @@ import StartOptions from '@ohos.application.StartOptions'; **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -| Name| Readable| Writable| Type| Mandatory| Description| +| Name | Readable | Writable | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -------- | -------- | -| windowMode | Yes| No| number | No| Window mode.| -| displayId | Yes| No| number | No| Display ID.| - +| [windowMode](js-apis-window.md#windowmode) | Yes| No | number | No | Window mode. | +| displayId | Yes| No | number | No | Display ID. | + diff --git a/en/application-dev/reference/apis/js-apis-application-Want.md b/en/application-dev/reference/apis/js-apis-application-Want.md index 5eb470dbe514f6993ed16d3e98c018d32742b8d7..19509a5e771ce744b16a8f231faf6f75bccb772b 100644 --- a/en/application-dev/reference/apis/js-apis-application-Want.md +++ b/en/application-dev/reference/apis/js-apis-application-Want.md @@ -1,6 +1,6 @@ # Want -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. **Want** is the basic communication component of the system. @@ -17,14 +17,14 @@ import Want from '@ohos.application.Want'; **System capability**: SystemCapability.Ability.AbilityBase -| Name | Readable/Writable| Type | Mandatory| Description | -| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| deviceId | Read only | string | No | ID of the device running the ability. | -| bundleName | Read only | string | No | Bundle name of the ability. 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. If both **package** and **AbilityName** are specified in this field in a **Want** object, the **Want** object can directly match the specified ability.| -| uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| -| type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. | -| flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#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. | | + | Name | Readable/Writable | Type | Mandatory | Description | + | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | + | deviceId | Read only | string | No | ID of the device running the ability. | + | bundleName | Read only | string | No | Bundle name of the ability. 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. If both **package** and **AbilityName** are specified in this field in a **Want** object, the **Want** object can directly match the specified ability. | + | uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**. | + | type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. | + | flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#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. | diff --git a/en/application-dev/reference/apis/js-apis-application-ability.md b/en/application-dev/reference/apis/js-apis-application-ability.md index 5fce08ac4bc72bb2e7b430c4aa450f7478d80907..bca94a28134524a76e3e2f77f9b832ab620a86af 100644 --- a/en/application-dev/reference/apis/js-apis-application-ability.md +++ b/en/application-dev/reference/apis/js-apis-application-ability.md @@ -1,6 +1,6 @@ # Ability -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -18,11 +18,11 @@ import Ability from '@ohos.application.Ability'; **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.| -| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.| -| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | context | [AbilityContext](js-apis-ability-context.md) | Yes | No | Context of an ability. | + | launchWant | [Want](js-apis-application-Want.md) | Yes | No | Parameters for starting the ability. | + | lastRequestWant | [Want](js-apis-application-Want.md) | Yes | No | Parameters used when the ability was started last time. | ## Ability.onCreate @@ -35,10 +35,10 @@ Called to initialize the service logic when an ability is created. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.| - | param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-application-Want.md) | Yes | Information related to this ability, including the ability name and bundle name. | + | param | AbilityConstant.LaunchParam | Yes | Parameters for starting the ability, and the reason for the last abnormal exit. | **Example** @@ -61,9 +61,9 @@ Called when a **WindowStage** is created for this ability. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | windowStage | window.WindowStage | Yes| **WindowStage** information.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | windowStage | window.WindowStage | Yes | **WindowStage** information. | **Example** @@ -105,9 +105,9 @@ Called when the **WindowStage** is restored during the migration of this ability **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | windowStage | window.WindowStage | Yes| **WindowStage** information.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | windowStage | window.WindowStage | Yes | **WindowStage** information. | **Example** @@ -187,15 +187,15 @@ Called to save data during the ability migration preparation process. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | wantParam | {[key: string]: any} | Yes| **want** parameter.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | wantParam | {[key: string]: any} | Yes | **want** parameter. | **Return value** - | Type| Description| - | -------- | -------- | - | AbilityConstant.OnContinueResult | Continuation result.| + | Type | Description | + | -------- | -------- | + | AbilityConstant.OnContinueResult | Continuation result. | **Example** @@ -220,9 +220,9 @@ Called when the ability startup mode is set to singleton. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-application-Want.md) | Yes | Want parameters, such as the ability name and bundle name. | **Example** @@ -245,9 +245,9 @@ Called when the configuration of the environment where the ability is running is **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | config | [Configuration](js-apis-configuration.md) | Yes | New configuration. | **Example** @@ -275,16 +275,16 @@ Sends sequenceable data to the target ability. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.| - | data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. | + | data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. | **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return a response.| + | Type | Description | + | -------- | -------- | + | Promise<void> | Promise used to return a response. | **Example** @@ -345,16 +345,16 @@ Sends sequenceable data to the target ability and obtains the sequenceable data **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.| - | data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. | + | data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. | **Return value** - | Type| Description| - | -------- | -------- | - | Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability.| + | Type | Description | + | -------- | -------- | + | Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability. | **Example** @@ -451,9 +451,9 @@ Registers a callback that is invoked when the Stub on the target ability is disc **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | OnReleaseCallBack | Yes | Callback used for the **onRelease** API. | **Example** @@ -499,10 +499,10 @@ Registers a caller notification callback, which is invoked when the target abili **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | method | string | Yes| Notification message string negotiated between the two abilities.| - | callback | CaleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | method | string | Yes | Notification message string negotiated between the two abilities. | + | callback | CaleeCallBack | Yes | JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails. | **Example** @@ -552,9 +552,9 @@ Unregisters a caller notification callback, which is invoked when the target abi **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | method | string | Yes| Registered notification message string.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | method | string | Yes | Registered notification message string. | **Example** @@ -575,9 +575,9 @@ Unregisters a caller notification callback, which is invoked when the target abi **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| (msg: string) | function | Yes| No| Prototype of the listener function interface registered by the caller.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | (msg: string) | function | Yes | No | Prototype of the listener function interface registered by the caller. | ## CaleeCallBack @@ -586,6 +586,6 @@ Unregisters a caller notification callback, which is invoked when the target abi **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the message listener function interface registered by the callee.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes | No | Prototype of the message listener function interface registered by the callee. | diff --git a/en/application-dev/reference/apis/js-apis-application-abilityConstant.md b/en/application-dev/reference/apis/js-apis-application-abilityConstant.md index 226288e3cc52b09e3e110bc7b834bc134e23e6ba..1db280b4b8c111250cd1cb4230c5e665184cb0df 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityConstant.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityConstant.md @@ -1,6 +1,6 @@ # AbilityConstant -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -19,10 +19,10 @@ import AbilityConstant from '@ohos.application.AbilityConstant'; **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| launchReason | LaunchReason| Yes| Yes| Ability launch reason.| -| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | launchReason | LaunchReason | Yes | Yes | Ability launch reason. | + | lastExitReason | LastExitReason | Yes | Yes | Reason for the last exit. | ## AbilityConstant.LaunchReason @@ -30,12 +30,12 @@ Enumerates ability launch reasons. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name | Value | Description | -| ----------------------------- | ---- | ------------------------------------------------------------ | -| UNKNOWN | 0 | Unknown reason.| -| START_ABILITY | 1 | Ability startup.| -| CALL | 2 | Call.| -| CONTINUATION | 3 | Ability continuation.| + | Name | Value | Description | + | ----------------------------- | ---- | ------------------------------------------------------------ | + | UNKNOWN | 0 | Unknown reason. | + | START_ABILITY | 1 | Ability startup. | + | CALL | 2 | Call. | + | CONTINUATION | 3 | Ability continuation. | ## AbilityConstant.LastExitReason @@ -44,11 +44,11 @@ Enumerates reasons for the last exit. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name | Value | Description | -| ----------------------------- | ---- | ------------------------------------------------------------ | -| UNKNOWN | 0 | Unknown reason.| -| ABILITY_NOT_RESPONDING | 1 | The ability does not respond.| -| NORMAL | 2 | Normal status.| + | Name | Value | Description | + | ----------------------------- | ---- | ------------------------------------------------------------ | + | UNKNOWN | 0 | Unknown reason. | + | ABILITY_NOT_RESPONDING | 1 | The ability does not respond. | + | NORMAL | 2 | Normal status. | ## AbilityConstant.OnContinueResult @@ -57,8 +57,8 @@ Enumerates ability continuation results. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name | Value | Description | -| ----------------------------- | ---- | ------------------------------------------------------------ | -| AGREE | 0 | Continuation agreed.| -| REJECT | 1 | Continuation denied.| -| MISMATCH | 2 | Mismatch.| + | Name | Value | Description | + | ----------------------------- | ---- | ------------------------------------------------------------ | + | AGREE | 0 | Continuation agreed. | + | REJECT | 1 | Continuation denied. | + | MISMATCH | 2 | Mismatch. | diff --git a/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md b/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md index 13cfb0005a19959b23f14334296a9398a0308d0a..9e0d3e602e74c621b139bdc45857f2ce3d395490 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md @@ -1,6 +1,6 @@ # AbilityDelegator -> **Note** +> **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. @@ -423,7 +423,7 @@ Starts an ability. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | -------------------------------------- | ---- | ------------------ | -| want | [Want](js-apis-featureAbility.md#Want) | Yes | **Want** parameter for starting the ability. | +| want | [Want](js-apis-application-Want.md) | Yes | **Want** parameter for starting the ability. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -455,7 +455,7 @@ Starts an ability. This API uses a promise to return the result. | Name| Type | Mandatory| Description | | ------ | -------------------------------------- | ---- | --------------- | -| want | [Want](js-apis-featureAbility.md#Want) | Yes | **Want** parameter for starting the ability.| +| want | [Want](js-apis-application-Want.md) | Yes | **Want** parameter for starting the ability.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-application-abilitystage.md b/en/application-dev/reference/apis/js-apis-application-abilitystage.md index 516698bbbc1ddf7b4a3d70a89ef372ad67b48e78..8e501a482e04e33a18a8040d0183257b7c3e90c4 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilitystage.md +++ b/en/application-dev/reference/apis/js-apis-application-abilitystage.md @@ -1,6 +1,6 @@ # AbilityStage -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. @@ -45,15 +45,15 @@ Called when a specified ability is started. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-application-Want.md) | Yes | Information about the ability to start, such as the ability name and bundle name. | **Return value** - | Type| Description| - | -------- | -------- | - | string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started.| + | Type | Description | + | -------- | -------- | + | string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started. | **Example** @@ -77,9 +77,9 @@ Called when the global configuration is updated. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | config | [Configuration](js-apis-configuration.md) | Yes| Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | config | [Configuration](js-apis-configuration.md) | Yes | Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode. | **Example** @@ -96,6 +96,6 @@ Describes the configuration information about the context. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name | Type | Description | -| ----------- | --------------------------- | ------------------------------------------------------------ | -| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup.| + | Name | Type | Description | + | ----------- | --------------------------- | ------------------------------------------------------------ | + | context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup. | diff --git a/en/application-dev/reference/apis/js-apis-application-context.md b/en/application-dev/reference/apis/js-apis-application-context.md index 4b58792502051c4046f3000d006a1228c1336704..1955bc22b4ae2cb4ec80c1c7e51e7aa616f47a26 100644 --- a/en/application-dev/reference/apis/js-apis-application-context.md +++ b/en/application-dev/reference/apis/js-apis-application-context.md @@ -1,6 +1,6 @@ # Context -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -17,18 +17,18 @@ You must extend **AbilityContext** to implement this module. **System capability**: SystemCapability.Ability.AbilityRuntime.Core - | Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| resourceManager | ResourceManager | Yes| No| **ResourceManager** object.| -| applicationInfo | ApplicationInfo | Yes| No| Information about the application.| -| cacheDir | string | Yes| No| Cache directory of the application on the internal storage.| -| tempDir | string | Yes| No| Temporary file directory of the application.| -| filesDir | string | Yes| No| File directory of the application on the internal storage.| -| databaseDir | string | Yes| No| Storage directory of local data.| -| storageDir | string | Yes| No| Storage directory of lightweight data.| -| bundleCodeDir | string | Yes| No| Application installation path.| -| distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.| -| eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | resourceManager | ResourceManager | Yes | No | **ResourceManager** object. | + | applicationInfo | ApplicationInfo | Yes | No | Information about the application. | + | cacheDir | string | Yes | No | Cache directory of the application on the internal storage. | + | tempDir | string | Yes | No | Temporary file directory of the application. | + | filesDir | string | Yes | No | File directory of the application on the internal storage. | + | databaseDir | string | Yes | No | Storage directory of local data. | + | storageDir | string | Yes | No | Storage directory of lightweight data. | + | bundleCodeDir | string | Yes | No | Application installation path. | + | distributedFilesDir | string | Yes | No | Storage directory of distributed application data files. | + | eventHub | [EventHub](js-apis-eventhub.md) | Yes | No | Event hub information. | ## Context.createBundleContext @@ -41,15 +41,15 @@ Creates an application context. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | bundleName | string | Yes| Application bundle name.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | bundleName | string | Yes | Application bundle name. | **Return value** - | Type| Description| - | -------- | -------- | - | Context | Context of the application created.| + | Type | Description | + | -------- | -------- | + | Context | Context of the application created. | **Example** @@ -69,9 +69,9 @@ Obtains the context of this application. **Return value** - | Type| Description| - | -------- | -------- | - | Context | Context obtained.| + | Type | Description | + | -------- | -------- | + | Context | Context obtained. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md index 3f3a515587165c72d8fd46b495f6c68b1d9cae69..0a0a18ae37b50456db8c5e9d81ebceaaf675f18f 100644 --- a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @@ -1,7 +1,7 @@ # StaticSubscriberExtensionAbility -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -20,9 +20,9 @@ Callback of the common event of a static subscriber. **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | - | event | CommonEventData | Yes| Callback of the common event of a static subscriber.| + | event | CommonEventData | Yes | Callback of the common event of a static subscriber. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index 71f5f2a90b50513c194c3dad027b86abcb296984..e03b03206e91eac28dab5d3efa8cf5feb3b95918 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -480,8 +480,6 @@ Describes audio stream information. **System capability:** SystemCapability.Multimedia.Audio.Core -**Parameters:** - | Name | Type | Mandatory | Description | | :------------ | :---------------------------------------- | :-------- | :-------------------- | | samplingRate | [AudioSamplingRate](#audiosamplingrate8) | Yes | Sampling rate. | @@ -495,8 +493,6 @@ Describes audio renderer information. **System capability:** SystemCapability.Multimedia.Audio.Core -**Parameters:** - | Name | Type | Mandatory | Description | | :------------ | :-------------------------- | :-------- | :-------------------- | | contentType | [ContentType](#contenttype) | Yes | Content type. | @@ -509,8 +505,6 @@ Describes audio renderer configuration options. **System capability:** SystemCapability.Multimedia.Audio.Renderer -**Parameters:** - | Name | Type | Mandatory | Description | | :------------ | :-----------------------------------------| :-------- | :-------------------- | | streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Stream information. | @@ -522,8 +516,6 @@ Describes audio capturer information. **System capability:** SystemCapability.Multimedia.Audio.Core -**Parameters:** - | Name | Type | Mandatory | Description | | :---------------| :------------------------- | :-------- | :-------------------- | | source | [SourceType](#sourcetype) | Yes | Audio source type. | @@ -535,8 +527,6 @@ Describes audio capturer configuration options. **System capability:** SystemCapability.Multimedia.Audio.Capturer -**Parameters:** - | Name | Type | Mandatory | Description | | :------------ | :-----------------------------------------| :-------- | :-------------------- | | streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Stream information. | @@ -548,8 +538,6 @@ Describes the interrupt event received by the app when playback is interrupted. **System capability:** SystemCapability.Multimedia.Audio.Renderer -**Parameters:** - | Name | Type | Mandatory | Description | | :-------- | :-------------------------------------------- | :-------- | :---------------------------------------------------------------- | | eventType | [InterruptType](#interrupttype) | Yes | Whether the interruption has started or finished. | @@ -592,8 +580,6 @@ This is a system API and cannot be called by third-party applications. **System capability:** SystemCapability.Multimedia.Audio.Volume -**Parameters:** - | Name | Type | Mandatory | Description | | :--------- | :---------------------------------- | :-------- | :--------------------------------------- | | volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Volume type of the current stream. | @@ -606,8 +592,6 @@ Describes the device change type and device information. **System capability:** SystemCapability.Multimedia.Audio.Device -**Parameters:** - | Name | Type | Mandatory | Description | | :------------------ | :------------------------------------------------ | :-------- | :------------------ | | type | [DeviceChangeType](#devicechangetype) | Yes | Device change type. | diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 4d2b6c07f8170d6f930fc6522095967c3f608f92..cda24e954d1a7e4d6417e0e295af077c01d1f3a3 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -7,7 +7,7 @@ ## Modules to Import -``` +```js import call from '@ohos.telephony.call'; ``` @@ -30,7 +30,7 @@ Initiates a call. This API uses an asynchronous callback to return the execution **Example** -``` +```js call.dial("138xxxxxxxx", (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -57,7 +57,7 @@ Initiates a call. You can set call options as needed. This API uses an asynchron **Example** -``` +```js call.dial("138xxxxxxxx", { extras: false }, (err, data) => { @@ -91,7 +91,7 @@ Initiates a call. You can set call options as needed. This API uses a promise to **Example** -``` +```js let promise = call.dial("138xxxxxxxx", { extras: false }); @@ -121,7 +121,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a **Example** -``` +```js call.makeCall("138xxxxxxxx", err => { console.log(`makeCall callback: err->${JSON.stringify(err)}`); }); @@ -152,7 +152,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a **Example** -``` +```js let promise = call.makeCall("138xxxxxxxx"); promise.then(() => { console.log(`makeCall success`); @@ -177,7 +177,7 @@ Checks whether a call is in progress. This API uses an asynchronous callback to **Example** -``` +```js call.hasCall((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -200,7 +200,7 @@ Checks whether a call is in progress. This API uses a promise to return the resu **Example** -``` +```js let promise = call.hasCall(); promise.then(data => { console.log(`hasCall success, promise: data->${JSON.stringify(data)}`); @@ -226,7 +226,7 @@ Obtains the call status. This API uses an asynchronous callback to return the re **Example** -``` +```js call.getCallState((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -249,7 +249,7 @@ Obtains the call status. This API uses a promise to return the result. **Example** -``` +```js let promise = call.getCallState(); promise.then(data => { console.log(`getCallState success, promise: data->${JSON.stringify(data)}`); @@ -272,7 +272,7 @@ Checks whether a device supports voice calls. This API works in synchronous mode | ------- | ------------------------------------------------------------ | | boolean | - **true**: The device supports voice calls.
- **false**: The device does not support voice calls.| -``` +```js let result = call.hasVoiceCapability(); console.log(`hasVoiceCapability: ${JSON.stringify(result)}`); ``` @@ -294,7 +294,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg **Example** -``` +```js call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -319,7 +319,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg **Example** -``` +```js call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -349,7 +349,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg **Example** -``` +```js let promise = call.isEmergencyPhoneNumber("138xxxxxxxx", {slotId: 1}); promise.then(data => { console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`); @@ -375,7 +375,7 @@ Formats a phone number based on the specified ISO country code. This API uses an **Example** -``` +```js call.formatPhoneNumber("138xxxxxxxx", (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -400,7 +400,7 @@ Formats a phone number based on specified formatting options. This API uses an a **Example** -``` +```js call.formatPhoneNumber("138xxxxxxxx",{ countryCode: "CN" }, (err, data) => { @@ -432,7 +432,7 @@ Formats a phone number based on specified formatting options. This API uses a pr **Example** -``` +```js let promise = call.formatPhoneNumber("138xxxxxxxx", { countryCode: "CN" }); @@ -465,7 +465,7 @@ All country codes are supported. **Example** -``` +```js call.formatPhoneNumberToE164("138xxxxxxxx",{ countryCode: "CN" }, (err, data) => { @@ -501,7 +501,7 @@ All country codes are supported. **Example** -``` +```js let promise = call.formatPhoneNumberToE164("138xxxxxxxx", { countryCode: "CN" }); diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index 6a51a41b6fba50c1c4f7a061d313482e1df57ad9..7229bf0f4c6b812c6ec52d26c0d6f289858725e9 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -1,6 +1,6 @@ -# Camera +# Camera Management -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -11,25 +11,22 @@ import camera from '@ohos.multimedia.camera'; ## Required Permissions -``` ohos.permission.CAMERA -``` -## getCameraManager(context: Context, callback: AsyncCallback): void; -**System Capabilities:** +## camera.getCameraManager -SystemCapability.Multimedia.Camera.Core +getCameraManager(context: Context, callback: AsyncCallback): void -**Description** +Obtains a **CameraManager** instance. This API uses an asynchronous callback to return the result. -Gets a **CameraManager** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|-------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | -| callback | AsyncCallback | Yes | Callback used to return the CameraManager instance | +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------- | ---- | ---------------------------------- | +| context | Context | Yes | Application context. | +| callback | AsyncCallback<[CameraManager](#cameramanager)\> | Yes | Callback used to return the **CameraManager** instance.| **Example** @@ -43,116 +40,105 @@ camera.getCameraManager(context, (err, cameraManager) => { }); ``` -## getCameraManager(context: Context): Promise; - -**System Capabilities:** +## camera.getCameraManager -SystemCapability.Multimedia.Camera.Core +getCameraManager(context: Context): Promise -**Description** +Obtains a **CameraManager** instance. This API uses a promise to return the result. -Gets a **CameraManager** instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------| -| context | Context | Yes | Application context | +| Name | Type | Mandatory| Description | +| ------- | ------- | ---- | ------------ | +| context | Context | Yes | Application context.| -**Return values** +**Return value** -| Type | Description | -|-------------------------|--------------------------------------------------------| -| Promise | Promise used to return the **CameraManager** instance | +| Type | Description | +| ----------------------------------------- | ----------------------------------------- | +| Promise<[CameraManager](#cameramanager)\> | Promise used to return the **CameraManager** instance.| **Example** ``` -camera.getCameraManager(context).then((cameraManger) => { +camera.getCameraManager(context).then((cameraManager) => { console.log('Promise returned with the CameraManager instance.'); }) ``` -## CameraStatus +## CameraStatus -Enumerates camera status types. +Enumerates the camera statuses. -**System Capabilities:** +**System capability**: SystemCapability.Multimedia.Camera.Core -SystemCapability.Multimedia.Camera.Core +| Name | Default Value| Description | +| ------------------------- | ------ | ------------ | +| CAMERA_STATUS_APPEAR | 0 | The camera exists. | +| CAMERA_STATUS_DISAPPEAR | 1 | The camera does not exist.| +| CAMERA_STATUS_AVAILABLE | 2 | The camera is ready. | +| CAMERA_STATUS_UNAVAILABLE | 3 | The camera is not ready.| -| Name | Default Value | Description | -|---------------------------|---------------|--------------------| -| CAMERA_STATUS_APPEAR | 0 | Camera appear | -| CAMERA_STATUS_DISAPPEAR | 1 | Camera disappear | -| CAMERA_STATUS_AVAILABLE | 2 | Camera available | -| CAMERA_STATUS_UNAVAILABLE | 3 | Camera unavailable | - -## CameraPosition +## CameraPosition Enumerates the camera positions. -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core +**System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Default value | Description | -|-----------------------------|---------------|-----------------------| -| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position | -| CAMERA_POSITION_BACK | 1 | Rear camera | -| CAMERA_POSITION_FRONT | 2 | Front camera | +| Name | Default Value| Description | +| --------------------------- | ------ | ---------------- | +| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position.| +| CAMERA_POSITION_BACK | 1 | Rear camera. | +| CAMERA_POSITION_FRONT | 2 | Front camera. | -## CameraType +## CameraType Enumerates the camera types. -**System Capabilities:** +**System capability**: SystemCapability.Multimedia.Camera.Core -SystemCapability.Multimedia.Camera.Core +| Name | Default Value| Description | +| ----------------------- | ------ | ---------------- | +| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type.| +| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera. | +| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera. | +| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera. | +| CAMERA_TYPE_TRUE_DEPTH | 4 | True depth camera. | -| Name | Default value | Description | -|-------------------------|---------------|-------------------------| -| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type | -| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera | -| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera | -| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera | -| CAMERA_TYPE_TRUE_DEPTH | 4 | True depth camera | +## ConnectionType -## ConnectionType +Enumerates the camera connection types. -Enumerates camera connection types. +**System capability**: SystemCapability.Multimedia.Camera.Core -**System Capabilities:** +| Name | Default Value| Description | +| ---------------------------- | ------ | ------------- | +| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera. | +| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.| +| CAMERA_CONNECTION_REMOTE | 2 | Remote camera. | -SystemCapability.Multimedia.Camera.Core -| Name | Default value | Description | -|------------------------------|---------------|----------------------------| -| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera | -| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB | -| CAMERA_CONNECTION_REMOTE | 2 | Remote camera | +## CameraManager -## CameraManager +Implements camera management. Before calling any API in **CameraManager**, you must use **getCameraManager** to obtain a **CameraManager** instance. -Implements camera management, including getting supported cameras and creating **CameraInput** instances. +### getCameras -### getCameras(callback: AsyncCallback\>): void; +getCameras(callback: AsyncCallback\>): void -**System Capabilities:** +Obtains all cameras supported by the device. This API uses an asynchronous callback to return the array of supported cameras. -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets all cameras supported by the device. This method uses an asynchronous callback to return the array of supported cameras. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|--------------------------------|-----------|---------------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------- | ---- | ------------------------------------ | +| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras.| **Example** @@ -166,21 +152,19 @@ cameraManager.getCameras((err, cameras) => { }) ``` -### getCameras(): Promise\>; +### getCameras -**System Capabilities:** +getCameras(): Promise\> -SystemCapability.Multimedia.Camera.Core +Obtains all cameras supported by the device. This API uses a promise to return the array of supported cameras. -**Description** +**System capability**: SystemCapability.Multimedia.Camera.Core -Gets all cameras supported by the device. This method uses a promise to return the array of supported cameras. +**Return value** -**Return values** - -| Type | Description | -|------------------------|--------------------------------------------------------| -| Promise\> | Promise used to return an array of supported cameras | +| Type | Description | +| ----------------------------------- | ----------------------------- | +| Promise\> | Promise used to return the array of supported cameras.| **Example** @@ -191,22 +175,20 @@ cameraManager.getCameras().then((cameraArray) => { }) ``` -### createCameraInput(cameraId: string, callback: AsyncCallback): void; - -**System Capabilities:** +### createCameraInput -SystemCapability.Multimedia.Camera.Core +createCameraInput(cameraId: string, callback: AsyncCallback): void -**Description** +Creates a **CameraInput** instance with the specified camera ID. This API uses an asynchronous callback to return the instance. -Creates a **CameraInput** instance with the specified camera ID. This method uses an asynchronous callback to return the instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Default value | Mandatory | Description | -|----------|------------------------------|-----------|--------------------------------------------------| -| cameraId | string | Yes | Camera ID used to create the instance | -| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | +| Name | Default Value | Mandatory| Description | +| -------- | ------------------------------------------- | ---- | ----------------------------------- | +| cameraId | string | Yes | Camera ID used to create the instance. | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.| **Example** @@ -220,27 +202,25 @@ cameraManager.createCameraInput(cameraId, (err, cameraInput) => { }) ``` -### createCameraInput(cameraId: string): Promise; +### createCameraInput -**System Capabilities:** +createCameraInput(cameraId: string): Promise -SystemCapability.Multimedia.Camera.Core +Creates a **CameraInput** instance with the specified camera ID. This API uses a promise to return the instance. -**Description** - -Creates a **CameraInput** instance with the specified camera ID. This method uses a promise to return the instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Default value | Mandatory | Description | -|----------|-----------------------------|-----------|------------------------------------------| -| cameraId | string | Yes | Camera ID used to create the instance | +| Name | Default Value| Mandatory| Description | +| -------- | ------ | ---- | ------------ | +| cameraId | string | Yes | Camera ID used to create the instance.| -**Return values** +**Return value** -| Type | Description | -|-------------------------|-------------------------------------------------| -| Promise | Promise used to return the CameraInput instance | +| Type | Description | +| ------------------------------------- | ---------------------------------------- | +| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.| **Example** @@ -250,23 +230,21 @@ cameraManager.createCameraInput(cameraId).then((cameraInput) => { }) ``` -### createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; - -**System Capabilities:** +### createCameraInput -SystemCapability.Multimedia.Camera.Core +createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void -**Description** +Creates a **CameraInput** instance with the specified camera position and camera type. This API uses an asynchronous callback to return the instance. -Creates a **CameraInput** instance with the specified camera position and camera type. This method uses an asynchronous callback to return the instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|-----------------------------|-----------|---------------------------------------------------| -| position | CameraPosition | Yes | Camera position | -| type | CameraType | Yes | Camera type | -| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------- | ---- | ----------------------------------- | +| position | [CameraPosition](#cameraposition) | Yes | Camera position. | +| type | [CameraType](#cameratype) | Yes | Camera type. | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.| **Example** @@ -280,28 +258,26 @@ cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) = }) ``` -### createCameraInput(position: CameraPosition, type: CameraType): Promise; - -**System Capabilities:** +### createCameraInput -SystemCapability.Multimedia.Camera.Core +createCameraInput(position: CameraPosition, type: CameraType): Promise -**Description** +Creates a **CameraInput** instance with the specified camera position and camera type. This API uses a promise to return the instance. -Creates a **CameraInput** instance with the specified camera position and camera type. This method uses a promise to return the instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------------|-----------|----------------------------------------| -| position | CameraPosition | Yes | Camera position | -| type | CameraType | Yes | Camera type | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------- | ---- | ---------- | +| position | [CameraPosition](#cameraposition) | Yes | Camera position.| +| type | [CameraType](#cameratype) | Yes | Camera type.| -**Return values** +**Return value** -| Type | Description | -|-------------------------|-------------------------------------------------| -| Promise | Promise used to return the CameraInput instance | +| Type | Description | +| ------------------------------------- | ---------------------------------------- | +| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.| **Example** @@ -311,22 +287,20 @@ cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) = }) ``` -### on(type: 'cameraStatus', callback: Callback): void; +### on('cameraStatus') -**System Capabilities:** +on(type: 'cameraStatus', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Listens for camera status changes. This API uses a callback to return the camera status changes. -**Description** - -Listens for camera status changes. This method uses a callback to get camera status changes. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :--------------------------------------------------- | -| type | string | Yes | Camera status event. | -| callback | Callback | Yes | Callback used to get the camera status change. | +| Name | Type | Mandatory| Description | +| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **cameraStatus**, indicating the camera status change event.| +| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change. | **Example** @@ -337,22 +311,20 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => { }) ``` -## Camera - -when we call *cameraManager.getCameras()* API, then it will return the **Camera** class which will have all camera-related metadata such as *cameraId, cameraPosition, cameraType & connectionType*. +## Camera -**System Capabilities:** +After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera instance is returned, including camera-related metadata such as **cameraId**, **cameraPosition**, **cameraType**, and **connectionType**. -SystemCapability.Multimedia.Camera.Core +**System capability**: SystemCapability.Multimedia.Camera.Core -**Fields** +| Name | Type | Read only| Description | +| -------------- | --------------------------------- | ---- | -------------- | +| cameraId | string | Yes | Camera ID. | +| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. | +| cameraType | [CameraType](#cameratype) | Yes | Camera type. | +| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.| -| Name | Type | Access | Description | -|----------------|----------------|----------|------------------------| -| cameraId | string | readonly | Camera ID | -| cameraPosition | cameraPosition | readonly | Camera position | -| cameraType | cameraType | readonly | Camera type | -| connectionType | connectionType | readonly | Camera connection type | +**Example** ``` async function getCameraInfo() { @@ -367,41 +339,37 @@ async function getCameraInfo() { ``` -## CameraStatusInfo - -This interface is a CameraManager callback API return. **CameraStatusInfo** will have *Camera* class & *CameraStatus* predefine constants.From *Camera* class, we can have all camera-related metadata & from *CameraStatus* constants, we will have information such as *APPEAR, DISAPPEAR, AVAILABLE & UNAVAILABLE*. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core +## CameraStatusInfo -**Fields** +Describes the camera status information. -| Name | Type | Description | -|----------------|----------------|------------------| -| camera | Camera | Camera object | -| status | CameraStatus | Camera status | +**System capability**: SystemCapability.Multimedia.Camera.Core +| Name | Type | Description | +| ------ | ----------------------------- | ---------- | +| camera | [Camera](#camera) | Camera object.| +| status | [CameraStatus](#camerastatus) | Camera status.| -## CameraInput -Implements a **CameraInput** instance. +## CameraInput -### getCameraId(callback: AsyncCallback\): void; +Implements a **CameraInput** instance. Before calling any API in **CameraInput**, you must create a **CameraInput** instance. -**System Capabilities:** +### getCameraId -SystemCapability.Multimedia.Camera.Core +getCameraId(callback: AsyncCallback\): void -**Description** +Obtains the camera ID based on which this **CameraInput** instance is created. This API uses an asynchronous callback to return the camera ID. -Gets the camera ID based on which this **CameraInput** instance is created. This method uses an asynchronous callback to return the camera ID. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|------------------------|-----------|---------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the camera ID | +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | -------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the camera ID.| + +**Example** ``` cameraInput.getCameraId((err, cameraId) => { @@ -413,21 +381,19 @@ cameraInput.getCameraId((err, cameraId) => { }) ``` -### getCameraId(): Promise; - -**System Capabilities:** +### getCameraId -SystemCapability.Multimedia.Camera.Core +getCameraId(): Promise -**Description** +Obtains the camera ID based on which this **CameraInput** instance is created. This API uses a promise to return the camera ID. -Gets the camera ID based on which this **CameraInput** instance is created. This method uses a promise to return the camera ID. +**System capability**: SystemCapability.Multimedia.Camera.Core -**Return values** +**Return value** -| Type | Description | -|------------------------|--------------------------------------| -| Promise | Promise used to return the camera ID | +| Type | Description | +| ---------------- | ----------------------------- | +| Promise | Promise used to return the camera ID.| **Example** @@ -437,21 +403,20 @@ cameraInput.getCameraId().then((cameraId) => { }) ``` -### hasFlash(callback: AsyncCallback): void; -**System Capabilities:** +### hasFlash -SystemCapability.Multimedia.Camera.Core +hasFlash(callback: AsyncCallback): void -**Description** +Checks whether the device has flash light. This API uses an asynchronous callback to return the result. -Checks whether the device has flash light. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|-------------------------|-----------|----------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the flash light support status | +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the flash light support status. The value **true** means that the device has flash light.| **Example** @@ -465,21 +430,19 @@ cameraInput.hasFlash((err, status) => { }) ``` -### hasFlash(): Promise; +### hasFlash -**System Capabilities:** +hasFlash(): Promise -SystemCapability.Multimedia.Camera.Core +Checks whether the device has flash light. This API uses a promise to return the result. -**Description** +**System capability**: SystemCapability.Multimedia.Camera.Core -Checks whether the device has flash light. This method uses a promise to return the result. +**Return value** -**Return values** - -| Type | Description | -|-----------------------|--------------------------------------------------------| -| Promise | Promise used to return the flash light support status | +| Type | Description | +| ----------------- | ------------------------------------------------------- | +| Promise | Promise used to return the flash light support status. The value **true** means that the device has flash light.| **Example** @@ -489,22 +452,20 @@ cameraInput.hasFlash().then((status) => { }) ``` -### isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; - -**System Capabilities:** +### isFlashModeSupported -SystemCapability.Multimedia.Camera.Core +isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void -**Description** +Checks whether a specified flash mode is supported. This API uses an asynchronous callback to return the result. -Checks whether a specified flash mode is supported. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | -| callback | AsyncCallback | Yes | Callback used to return the device flash support status | +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ---------------------------------------- | +| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. | +| callback | AsyncCallback | Yes | Callback used to return the flash mode support status. The value **true** means that the specified flash mode is supported.| **Example** @@ -518,27 +479,25 @@ cameraInput.isFlashModeSupported(flashMode, (err, status) => { }) ``` -### isFlashModeSupported(flashMode: FlashMode): Promise; +### isFlashModeSupported -**System Capabilities:** +isFlashModeSupported(flashMode: FlashMode): Promise -SystemCapability.Multimedia.Camera.Core +Checks whether a specified flash mode is supported. This API uses a promise to return the result. -**Description** - -Checks whether a specified flash mode is supported. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ---------------- | +| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.| -**Return values** +**Return value** -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return flash mode support status. | +| Type | Description | +| ----------------- | ------------------------------------------------------------ | +| Promise | Promise used to return the flash mode support status. The value **true** means that the specified flash mode is supported.| **Example** @@ -548,24 +507,25 @@ cameraInput.isFlashModeSupported(flashMode).then((status) => { }) ``` -### setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; +### setFlashMode -**System Capabilities:** +setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Sets the flash mode. This API uses an asynchronous callback to return the result. -**Description** +Before setting the parameters, do the following checks: -Sets flash mode. This method uses an asynchronous callback to return the result. +1. Use [hasFlash](#hasflash) to check whether the device has flash light. +2. Use [isFlashModeSupported](#isflashmodesupported) to check whether the device supports a specified flash mode. -Note: Before setting the flash mode, check the support for the flash light (hasFlash method) and flash mode support (isFlashModeSupported method); +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ------------------------ | +| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -579,29 +539,30 @@ cameraInput.setFlashMode(flashMode, (err) => { }) ``` -### setFlashMode(flashMode: FlashMode): Promise; +### setFlashMode -**System Capabilities:** +setFlashMode(flashMode: FlashMode): Promise -SystemCapability.Multimedia.Camera.Core +Sets the flash mode. This API uses a promise to return the result. -**Description** +Before setting the parameters, do the following checks: -Sets flash mode. This method uses a promise to return the result. +1. Use [hasFlash](#hasflash) to check whether the device has flash light. +2. Use [isFlashModeSupported](#isflashmodesupported) to check whether the device supports a specified flash mode. -Note: Before setting the flash mode, check the support for the flash light (hasFlash method) and flash mode support (isFlashModeSupported method); +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ---------------- | +| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.| -**Return values** +**Return value** -| Type | Description | -|-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -611,21 +572,19 @@ cameraInput.setFlashMode(flashMode).then(() => { }) ``` -### getFlashMode(callback: AsyncCallback): void; +### getFlashMode -**System Capabilities:** +getFlashMode(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Obtains the current flash mode. This API uses an asynchronous callback to return the result. -**Description** - -Gets current flash mode. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|---------------------------|-----------|------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current flash mode | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback<[FlashMode](#flashmode)\> | Yes | Callback used to return the current flash mode.| **Example** @@ -639,21 +598,19 @@ cameraInput.getFlashMode((err, flashMode) => { }) ``` -### getFlashMode(): Promise; - -**System Capabilities:** +### getFlashMode -SystemCapability.Multimedia.Camera.Core +getFlashMode(): Promise -**Description** +Obtains the current flash mode. This API uses a promise to return the result. -Gets current flash mode. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core -**Return values** +**Return value** -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the flash mode | +| Type | Description | +| --------------------------------- | --------------------------------------- | +| Promise<[FlashMode](#flashmode)\> | Promise used to return the current flash mode.| **Example** @@ -663,22 +620,20 @@ cameraInput.getFlashMode().then((flashMode) => { }) ``` -### isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; +### isFocusModeSupported -**System Capabilities:** +isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Checks whether a specified focus mode is supported. This API uses an asynchronous callback to return the result. -**Description** - -Checks whether a specified focus mode is supported. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| afMode | FocusMode | Yes | Focus mode | -| callback | AsyncCallback | Yes | Callback used to return the device focus support status | +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| afMode | [FocusMode](#focusmode) | Yes | Focus mode. | +| callback | AsyncCallback | Yes | Callback used to return the focus mode support status. The value **true** means that the specified focus mode is supported.| **Example** @@ -692,27 +647,25 @@ cameraInput.isFocusModeSupported(afMode, (err, status) => { }) ``` -### isFocusModeSupported(afMode: FocusMode): Promise; - -**System Capabilities:** +### isFocusModeSupported -SystemCapability.Multimedia.Camera.Core +isFocusModeSupported(afMode: FocusMode): Promise -**Description** +Checks whether a specified focus mode is supported. This API uses a promise to return the result. -Checks whether a specified focus mode is supported. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|----------------------------------------|-----------|-------------| -| afMode | FocusMode | Yes | Focus mode | +| Name | Type | Mandatory| Description | +| ------ | ----------------------- | ---- | ---------------- | +| afMode | [FocusMode](#focusmode) | Yes | Focus mode.| -**Return values** +**Return value** -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the focus mode support status. | +| Type | Description | +| ----------------- | ----------------------------------------------------------- | +| Promise | Promise used to return the flash mode support status. The value **true** means that the specified focus mode is supported.| **Example** @@ -722,24 +675,22 @@ cameraInput.isFocusModeSupported(afMode).then((status) => { }) ``` -### setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; - -**System Capabilities:** +### setFocusMode -SystemCapability.Multimedia.Camera.Core +setFocusMode(afMode: FocusMode, callback: AsyncCallback): void -**Description** +Sets the focus mode. This API uses an asynchronous callback to return the result. -Sets focus mode. This method uses an asynchronous callback to return the result. +Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported. -Note: Before setting the focus mode, check focus mode support (isFocusModeSupported method); +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|------------------------------------| -| afMode | FocusMode | Yes | Focus mode | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ------------------------ | +| afMode | [FocusMode](#focusmode) | Yes | Focus mode. | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -753,29 +704,27 @@ cameraInput.setFocusMode(afMode, (err) => { }) ``` -### setFocusMode(afMode: FocusMode): Promise; +### setFocusMode -**System Capabilities:** +setFocusMode(afMode: FocusMode): Promise -SystemCapability.Multimedia.Camera.Core +Sets the focus mode. This API uses a promise to return the result. -**Description** +Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported. -Sets focus mode. This method uses a promise to return the result. - -Note: Before setting the focus mode, check focus mode support (isFocusModeSupported method); +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|-----------------------------------------|-----------|-------------| -| afMode | FocusMode | Yes | Focus mode | +| Name | Type | Mandatory| Description | +| ------ | ----------------------- | ---- | ---------------- | +| afMode | [FocusMode](#focusmode) | Yes | Focus mode.| -**Return values** +**Return value** -| Type | Description | -|-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -785,21 +734,19 @@ cameraInput.setFocusMode(afMode).then(() => { }) ``` -### getFocusMode(callback: AsyncCallback): void; +### getFocusMode -**System Capabilities:** +getFocusMode(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Obtains the current focus mode. This API uses an asynchronous callback to return the result. -**Description** - -Gets the current focus mode. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|---------------------------|-----------|------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current focus mode | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback<[FocusMode](#focusmode)\> | Yes | Callback used to return the current focus mode.| **Example** @@ -813,21 +760,19 @@ cameraInput.getFocusMode((err, afMode) => { }) ``` -### getFocusMode(): Promise; - -**System Capabilities:** +### getFocusMode -SystemCapability.Multimedia.Camera.Core +getFocusMode(): Promise -**Description** +Obtains the current focus mode. This API uses a promise to return the result. -Gets the current focus mode. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core -**Return values** +**Return value** -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the focus mode | +| Type | Description | +| ------------------- | ------------------------------------- | +| Promise | Promise used to return the current focus mode.| **Example** @@ -837,21 +782,19 @@ cameraInput.getFocusMode().then((afMode) => { }) ``` -### getZoomRatioRange\(callback: AsyncCallback\>\): void; +### getZoomRatioRange -**System Capabilities:** +getZoomRatioRange\(callback: AsyncCallback\>\): void -SystemCapability.Multimedia.Camera.Core +Obtains the zoom ratio range. This API uses an asynchronous callback to return the result. -**Description** - -Gets the zoom ratios of all zoom values. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|--------------------------------|-----------|-------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the zoom ratio range | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------ | ---- | ------------------------ | +| callback | AsyncCallback\> | Yes | Callback used to return the zoom ratio range.| **Example** @@ -865,21 +808,19 @@ cameraInput.getZoomRatioRange((err, zoomRatioRange) => { }) ``` -### getZoomRatioRange\(\): Promise\>; - -**System Capabilities:** +### getZoomRatioRange -SystemCapability.Multimedia.Camera.Core +getZoomRatioRange\(\): Promise\> -**Description** +Obtains the zoom ratio range. This API uses a promise to return the result. -Gets the zoom ratios of all zoom values. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core -**Return values** +**Return value** -| Type | Description | -|------------------------|---------------------------------------------| -| Promise\> | Promise used to return the zoom ratio range | +| Type | Description | +| ------------------------ | ------------------------------------------- | +| Promise\> | Promise used to return the zoom ratio range.| **Example** @@ -889,22 +830,20 @@ cameraInput.getZoomRatioRange().then((zoomRatioRange) => { }) ``` -### setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; - -**System Capabilities:** +### setZoomRatio -SystemCapability.Multimedia.Camera.Core +setZoomRatio(zoomRatio: number, callback: AsyncCallback): void -**Description** +Sets a zoom ratio. This API uses an asynchronous callback to return the result. -Sets a zoom ratio. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|------------------------------------| -| zoomRatio | number | Yes | Zoom ratio | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| --------- | -------------------- | ---- | ------------------------ | +| zoomRatio | number | Yes | Zoom ratio to set. | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -918,27 +857,25 @@ cameraInput.setZoomRatio(zoomRatio, (err) => { }) ``` -### setZoomRatio(zoomRatio: number): Promise; - -**System Capabilities:** +### setZoomRatio -SystemCapability.Multimedia.Camera.Core +setZoomRatio(zoomRatio: number): Promise -**Description** +Sets a zoom ratio. This API uses a promise to return the result. -Sets a zoom ratio. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|----------|-----------|-------------| -| zoomRatio | number | Yes | zoom ratio | +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ------------ | +| zoomRatio | number | Yes | Zoom ratio to set.| -**Return values** +**Return value** -| Type | Description | -|-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -948,21 +885,19 @@ cameraInput.setZoomRatio(zoomRatio).then(() => { }) ``` -### getZoomRatio(callback: AsyncCallback): void; - -**System Capabilities:** +### getZoomRatio -SystemCapability.Multimedia.Camera.Core +getZoomRatio(callback: AsyncCallback): void -**Description** +Obtains the current zoom ratio. This API uses an asynchronous callback to return the result. -Gets current zoom ratio value. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-----------|---------------------------|-----------|------------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current zoom ratio value | +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the current zoom ratio.| **Example** @@ -976,21 +911,19 @@ cameraInput.getZoomRatio((err, zoomRatio) => { }) ``` -### getZoomRatio(): Promise; +### getZoomRatio -**System Capabilities:** +getZoomRatio(): Promise -SystemCapability.Multimedia.Camera.Core +Obtains the current zoom ratio. This API uses a promise to return the result. -**Description** +**System capability**: SystemCapability.Multimedia.Camera.Core -Gets current zoom ratio value. This method uses a promise to return the result. +**Return value** -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the zoom ratio vaule | +| Type | Description | +| ---------------- | --------------------------- | +| Promise | Promise used to return the current zoom ratio.| **Example** @@ -1000,26 +933,24 @@ cameraInput.getZoomRatio().then((zoomRatio) => { }) ``` -### release\(callback: AsyncCallback\): void; - -**System Capabilities:** +### release -SystemCapability.Multimedia.Camera.Core +release\(callback: AsyncCallback\): void -**Description** +Releases this **CameraInput** instance. This API uses an asynchronous callback to return the result. -Releases this **CameraInput** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ``` -cameraInput.release((err) => { +camera.release((err) => { if (err) { console.error('Failed to release the CameraInput instance ${err.message}'); return; @@ -1028,21 +959,19 @@ cameraInput.release((err) => { }); ``` -### release(): Promise; +### release -**System Capabilities:** +release(): Promise -SystemCapability.Multimedia.Camera.Core +Releases this **CameraInput** instance. This API uses a promise to return the result. -**Description** +**System capability**: SystemCapability.Multimedia.Camera.Core -Releases this **CameraInput** instance. This method uses a promise to return the result. +**Return value** -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1052,22 +981,20 @@ cameraInput.release().then(() => { }) ``` -### on(type: 'focusStateChange', callback: Callback): void; +### on('focusStateChange') -**System Capabilities:** +on(type: 'focusStateChange', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Listens for focus state changes. This API uses a callback to return the focus state changes. -**Description** - -Listens for focus state changes. This method uses a callback to get focus state changes. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the focus state change. | +| Name | Type | Mandatory| Description | +| :------- | :---------------------------------------- | :--- | :------------------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **focusStateChange**, indicating the focus state change event.| +| callback | AsyncCallback<[FocusState](#focusstate)\> | Yes | Callback used to return the focus state change. | **Example** @@ -1077,22 +1004,20 @@ cameraInput.on('focusStateChange', (focusState) => { }) ``` -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** +### on('error') -SystemCapability.Multimedia.Camera.Core +on(type: 'error', callback: ErrorCallback): void -**Description** +Listens for **CameraInput** errors. This API uses a callback to return the errors. -Listens for **CameraInput** errors. This method uses a callback to get errors. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Camera input error event. | -| callback | Callback | Yes | Callback used to get the camera input errors. | +| Name | Type | Mandatory| Description | +| :------- | :------------------------------- | :--- | :---------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the camera input error event.| +| callback | ErrorCallback | Yes | Callback used to return the capture input errors. | **Example** @@ -1102,57 +1027,64 @@ cameraInput.on('error', (cameraInputError) => { }) ``` -## FlashMode -Enumerates the flash modes. +## FlashMode -**System Capabilities:** +Enumerates the flash modes. -SystemCapability.Multimedia.Camera.Core +**System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Default value | Description | -|------------------------|---------------|------------------------| -| FLASH_MODE_CLOSE | 0 | Flash mode close | -| FLASH_MODE_OPEN | 1 | Flash mode open | -| FLASH_MODE_AUTO | 2 | Flash mode auto | -| FLASH_MODE_ALWAYS_OPEN | 3 | Flash mode always open | +| Name | Default Value| Description | +| ---------------------- | ------ | ------------ | +| FLASH_MODE_CLOSE | 0 | The flash is off.| +| FLASH_MODE_OPEN | 1 | The flash is on.| +| FLASH_MODE_AUTO | 2 | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.| +| FLASH_MODE_ALWAYS_OPEN | 3 | The flash is steady on.| -## FocusMode +## FocusMode Enumerates the focus modes. -**System Capabilities:** +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Default Value| Description | +| -------------------------- | ------ | ------------------ | +| FOCUS_MODE_MANUAL | 0 | Manual focus. | +| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Continuous auto focus.| +| FOCUS_MODE_AUTO | 2 | Auto focus. | +| FOCUS_MODE_LOCKED | 3 | Locked focus. | -SystemCapability.Multimedia.Camera.Core +## FocusState -| Name | Default value | Description | -|----------------------------|---------------|----------------------------| -| FOCUS_MODE_MANUAL | 0 | Focus mode manual | -| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Focus mode continuous auto | -| FOCUS_MODE_AUTO | 2 | Focus mode auto | -| FOCUS_MODE_LOCKED | 3 | Focus mode locked | +Enumerates the focus states. -## createCaptureSession\(context: Context, callback: AsyncCallback\): void; +**System capability**: SystemCapability.Multimedia.Camera.Core -**System Capabilities:** +| Name | Default Value| Description | +| --------------------- | ------ | ------------ | +| FOCUS_STATE_SCAN | 0 | Scanning. | +| FOCUS_STATE_FOCUSED | 1 | Focused.| +| FOCUS_STATE_UNFOCUSED | 2 | Unfocused.| -SystemCapability.Multimedia.Camera.Core +## camera.createCaptureSession -**Description** +createCaptureSession\(context: Context, callback: AsyncCallback\): void -Creates a **CaptureSession** instance. This method uses an asynchronous callback to return the instance. +Creates a **CaptureSession** instance. This API uses an asynchronous callback to return the instance. + +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|--------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | -| callback | AsyncCallback | Yes | Callback used to return the CaptureSession instance | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | -------------------------------------- | +| context | Context | Yes | Application context. | +| callback | AsyncCallback<[CaptureSession](#capturesession)\> | Yes | Callback used to return the **CaptureSession** instance.| **Example** ``` -captureSession.createCaptureSession((context), (err, captureSession) => { +camera.createCaptureSession((context), (err, captureSession) => { if (err) { console.error('Failed to create the CaptureSession instance. ${err.message}'); return; @@ -1161,55 +1093,51 @@ captureSession.createCaptureSession((context), (err, captureSession) => { }); ``` -## createCaptureSession(context: Context\): Promise; - -**System Capabilities:** +## camera.createCaptureSession -SystemCapability.Multimedia.Camera.Core +createCaptureSession(context: Context\): Promise; -**Description** +Creates a **CaptureSession** instance. This API uses a promise to return the instance. -Creates a **CaptureSession** instance. This method uses a promise to return the instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|-------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | +| Name | Type | Mandatory| Description | +| ------- | ------- | ---- | ------------ | +| context | Context | Yes | Application context.| -**Return values** +**Return value** -| Type | Description | -|---------------------------|---------------------------------------------------| -| Promise | Promise used to return the CaptureSession instance. | +| Type | Description | +| ------------------------------------------- | ----------------------------------------- | +| Promise<[CaptureSession](#capturesession)\> | Promise used to return the **CaptureSession** instance.| **Example** ``` -captureSession.createCaptureSession(context).then((captureSession) => { +camera.createCaptureSession(context).then((captureSession) => { console.log('Promise returned with the CaptureSession instance'); }) ``` -## CaptureSession +## CaptureSession Implements session capture. -### beginConfig\(callback: AsyncCallback\): void; +### beginConfig -**System Capabilities:** +beginConfig\(callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +Starts configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -**Description** - -Starts configuration for this CaptureSession instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -1223,21 +1151,19 @@ captureSession.beginConfig((err) => { }); ``` -### beginConfig\(\): Promise; - -**System Capabilities:** +### beginConfig -SystemCapability.Multimedia.Camera.Core +beginConfig\(\): Promise -**Description** +Starts configuration for this **CaptureSession** instance. This API uses a promise to return the result. -Starts configuration for this CaptureSession instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core -**Return values** +**Return value** -| Type | Description | -|---------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1248,21 +1174,19 @@ captureSession.beginConfig().then(() => { }) ``` -### commitConfig\(callback: AsyncCallback\): void; - -**System Capabilities:** +### commitConfig -SystemCapability.Multimedia.Camera.Core +commitConfig\(callback: AsyncCallback\): void -**Description** +Commits the configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -Commits the configuration for this CaptureSession instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|---------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -1276,21 +1200,19 @@ captureSession.commitConfig((err) => { }); ``` -### commitConfig\(\): Promise; - -**System Capabilities:** +### commitConfig -SystemCapability.Multimedia.Camera.Core +commitConfig\(\): Promise -**Description** +Commits the configuration for this **CaptureSession** instance. This API uses a promise to return the result. -Commits the configuration for this CaptureSession instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core -**Return values** +**Return value** -| Type | Description | -|---------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1300,22 +1222,20 @@ captureSession.commitConfig().then(() => { }) ``` -### addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; - -**System Capabilities:** +### addInput -SystemCapability.Multimedia.Camera.Core +addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void -**Description** +Adds a **CameraInput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -Add a CameraInput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-------------|----------------------|-----------|---------------------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1329,27 +1249,25 @@ captureSession.addInput(cameraInput, (err) => { }); ``` -### addInput\(cameraInput: CameraInput\): Promise; +### addInput -**System Capabilities:** +addInput\(cameraInput: CameraInput\): Promise -SystemCapability.Multimedia.Camera.Core +Adds a **CameraInput** instance to this **CaptureSession** instance. This API uses a promise to return the result. -**Description** - -Add a CameraInput instance to this CaptureSession instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-------------|---------------------|-----------|-------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to add | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.| -**Return values** +**Return value** -| Type | Description | -|----------------|------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1359,22 +1277,20 @@ captureSession.addInput(cameraInput).then(() => { }) ``` -### addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; +### addOutput -**System Capabilities:** +addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -**Description** - -Add a PreviewOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|-------------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| ------------- | ------------------------------- | ---- | ----------------------------- | +| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1388,27 +1304,25 @@ captureSession.addOutput(previewOutput, (err) => { }); ``` -### addOutput\(previewOutput: PreviewOutput\): Promise; - -**System Capabilities:** +### addOutput -SystemCapability.Multimedia.Camera.Core +addOutput\(previewOutput: PreviewOutput\): Promise -**Description** +Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result. -Add a PreviewOutput instance to this CaptureSession instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|--------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to add | +| Name | Type | Mandatory| Description | +| ------------- | ------------------------------- | ---- | ----------------------------- | +| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.| -**Return values** +**Return value** -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1418,22 +1332,20 @@ captureSession.addOutput(previewOutput).then(() => { }) ``` -### addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void; - -**System Capabilities:** +### addOutput -SystemCapability.Multimedia.Camera.Core +addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void -**Description** +Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -Add a PhotoOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|-------------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to add.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1447,27 +1359,25 @@ captureSession.addOutput(photoOutput, (err) => { }); ``` -### addOutput\(photoOutput: PhotoOutput\): Promise; +### addOutput -**System Capabilities:** +addOutput\(photoOutput: PhotoOutput\): Promise -SystemCapability.Multimedia.Camera.Core +Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result. -**Description** - -Add a PhotoOutput instance to this CaptureSession instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|--------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to add | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to add.| -**Return values** +**Return value** | Type | Description | -|---------------|-----------------------------------| -| Promise | Promise used to return the result | +| -------------- | --------------------------- | +| Promise\ | Promise used to return the result.| **Example** @@ -1477,22 +1387,20 @@ captureSession.addOutput(photoOutput).then(() => { }) ``` -### addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void; - -**System Capabilities:** +### addOutput -SystemCapability.Multimedia.Camera.Core +addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void -**Description** +Adds a **VideoOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -Add a VideoOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|-------------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to add.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1506,27 +1414,25 @@ captureSession.addOutput(videoOutput, (err) => { }); ``` -### addOutput\(videoOutput: VideoOutput\): Promise; +### addOutput -**System Capabilities:** +addOutput\(videoOutput: VideoOutput\): Promise -SystemCapability.Multimedia.Camera.Core +Adds a **VideoOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result. -**Description** - -Add a VideoOutput instance to this CaptureSession instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|--------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to add | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to add.| -**Return values** +**Return value** -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise\ | Promise used to return the result.| **Example** @@ -1536,22 +1442,20 @@ captureSession.addOutput(videoOutput).then(() => { }) ``` -### removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; +### removeInput -**System Capabilities:** +removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +Removes a **CameraInput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -**Description** - -Removes a **CameraInput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-------------|----------------------|-----------|------------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to remove.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1565,27 +1469,25 @@ captureSession.removeInput(cameraInput, (err) => { }); ``` -### removeInput\(cameraInput: CameraInput\): Promise; - -**System Capabilities:** +### removeInput -SystemCapability.Multimedia.Camera.Core +removeInput\(cameraInput: CameraInput\): Promise -**Description** +Removes a **CameraInput** instance from this **CaptureSession** instance. This API uses a promise to return the result. -Removes a **CameraInput** instance from this **CaptureSession** instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|-------------|---------------------|-----------|---------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to remove | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to remove.| -**Return values** +**Return value** -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise\ | Promise used to return the result.| **Example** @@ -1595,22 +1497,20 @@ captureSession.removeInput(cameraInput).then(() => { }) ``` -### removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; - -**System Capabilities:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void -**Description** +Removes a **PreviewOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -Removes a **PreviewOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|------------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| ------------- | ------------------------------- | ---- | ----------------------------- | +| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1624,28 +1524,26 @@ captureSession.removeOutput(previewOutput, (err) => { }); ``` -### removeOutput(previewOutput: PreviewOutput): Promise; - -**System Capabilities:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput(previewOutput: PreviewOutput): Promise -**Description** +Removes a **PreviewOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result. -Removes a **PreviewOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|-----------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to remove | +| Name | Type | Mandatory| Description | +| ------------- | ------------------------------- | ---- | ----------------------------- | +| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.| -**Return values** +**Return value** -| Type | Description | -|---------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1656,22 +1554,20 @@ captureSession.removeOutput(previewOutput).then(() => { }) ``` -### removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; - -**System Capabilities:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void -**Description** +Removes a **PhotoOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -Removes a **PhotoOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|------------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to remove.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1685,28 +1581,26 @@ captureSession.removeOutput(photoOutput, (err) => { }); ``` -### removeOutput(photoOutput: PhotoOutput): Promise; +### removeOutput -**System Capabilities:** +removeOutput(photoOutput: PhotoOutput): Promise -SystemCapability.Multimedia.Camera.Core +Removes a **PhotoOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result. -**Description** - -Removes a **PhotoOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|---------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to remove | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to remove.| -**Return values** +**Return value** -| Type | Description | -|---------------|------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1717,22 +1611,20 @@ captureSession.removeOutput(photoOutput).then(() => { }) ``` -### removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; +### removeOutput -**System Capabilities:** +removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Removes a **VideoOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -**Description** - -Removes a **VideoOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|------------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to remove.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -1746,28 +1638,26 @@ captureSession.removeOutput(videoOutput, (err) => { }); ``` -### removeOutput(videoOutput: VideoOutput): Promise; - -**System Capabilities:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput(videoOutput: VideoOutput): Promise -**Description** +Removes a **VideoOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result. -Removes a **VideoOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|---------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to remove | +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | --------------------------- | +| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to remove.| -**Return values** +**Return value** -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1778,21 +1668,19 @@ captureSession.removeOutput(videoOutput).then(() => { }) ``` -### start\(callback: AsyncCallback\): void; - -**System Capabilities:** +### start -SystemCapability.Multimedia.Camera.Core +start\(callback: AsyncCallback\): void -**Description** +Starts this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -Starts this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -1806,21 +1694,19 @@ captureSession.start((err) => { }); ``` -### start\(\): Promise; - -**System Capabilities:** +### start -SystemCapability.Multimedia.Camera.Core +start\(\): Promise -**Description** +Starts this **CaptureSession** instance. This API uses a promise to return the result. -Starts this **CaptureSession** instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core -**Return values** +**Return value** -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1830,22 +1716,20 @@ captureSession.start().then(() => { }) ``` -### stop\(callback: AsyncCallback\): void; - -**System Capabilities:** +### stop -SystemCapability.Multimedia.Camera.Core +stop\(callback: AsyncCallback\): void -**Description** +Stops this **CaptureSession** instance. This API uses an asynchronous callback to return the result. -Stops this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -1859,21 +1743,19 @@ captureSession.stop((err) => { }); ``` -### stop(): Promise; +### stop -**System Capabilities:** +stop(): Promise -SystemCapability.Multimedia.Camera.Core +Stops this **CaptureSession** instance. This API uses a promise to return the result. -**Description** +**System capability**: SystemCapability.Multimedia.Camera.Core -Stops this **CaptureSession** instance. This method uses a promise to return the result. +**Return value** -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1883,21 +1765,19 @@ captureSession.stop().then(() => { }) ``` -### release\(callback: AsyncCallback\): void; +### release -**System Capabilities:** +release\(callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +Releases this **CaptureSession** instance. This API uses an asynchronous callback to return the instance. -**Description** - -Releases this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -1911,21 +1791,19 @@ captureSession.release((err) => { }); ``` -### release(): Promise; - -**System Capabilities:** +### release -SystemCapability.Multimedia.Camera.Core +release(): Promise -**Description** +Releases this **CaptureSession** instance. This API uses a promise to return the result. -Releases this **CaptureSession** instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core -**Return values** +**Return value** -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -1935,22 +1813,20 @@ captureSession.release().then(() => { }) ``` -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** +### on('error') -SystemCapability.Multimedia.Camera.Core +on(type: 'error', callback: ErrorCallback): void -**Description** +Listens for **CaptureSession** errors. This API uses a callback to return the errors. -Listens for **CaptureSession** errors. This method uses a callback to get errors. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Capture session error event. | -| callback | Callback | Yes | Callback used to get the capture session errors. | +| Name | Type | Mandatory| Description | +| :------- | :---------------------------------- | :--- | :-------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the capture session error event.| +| callback | ErrorCallback | Yes | Callback used to return the capture session errors. | **Example** @@ -1960,22 +1836,20 @@ captureSession.on('error', (captureSessionError) => { }) ``` -## createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** +## camera.createPreviewOutput -SystemCapability.Multimedia.Camera.Core +createPreviewOutput(surfaceId: string, callback: AsyncCallback): void -**Description** +Creates a **PreviewOutput** instance. This API uses an asynchronous callback to return the instance. -Creates a **PreviewOutput** instance. This method uses an asynchronous callback to return the instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from XComponent view | -| callback | AsyncCallback | Yes | Callback used to return the PreviewOutput instance | +| Name | Type | Mandatory| Description | +| --------- | ----------------------------------------------- | ---- | ------------------------------------- | +| surfaceId | string | Yes | Surface ID received from **XComponent**. | +| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes | Callback used to return the **PreviewOutput** instance.| **Example** @@ -1987,29 +1861,27 @@ camera.createPreviewOutput((surfaceId), (err, previewOutput) => { } console.log('Callback returned with previewOutput instance'); }); -``` - -## createPreviewOutput(surfaceId: string): Promise; +``` -**System Capabilities:** +## camera.createPreviewOutput -SystemCapability.Multimedia.Camera.Core +createPreviewOutput(surfaceId: string): Promise\ -**Description** +Creates a **PreviewOutput** instance. This API uses a promise to return the instance. -Creates a **PreviewOutput** instance. This method uses a promise to return the instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from XComponent view | +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ---------------------------------- | +| surfaceId | string | Yes | Surface ID received from **XComponent**.| -**Return values** +**Return value** -| Type | Description | -|-------------------------|---------------------------------------------------| -| Promise | Promise used to return the PreviewOutput instance | +| Type | Description | +| ----------------------------------------- | --------------------------- | +| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance.| **Example** @@ -2023,21 +1895,19 @@ camera.createPreviewOutput(surfaceId).then((previewOutput) => { Implements preview output. -### release(callback: AsyncCallback): void; - -**System Capabilities:** +### release -SystemCapability.Multimedia.Camera.Core +release(callback: AsyncCallback): void -**Description** +Releases this **PreviewOutput** instance. This API uses an asynchronous callback to return the result. -Releases this **PreviewOutput** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -2051,21 +1921,19 @@ previewOutput.release((err) => { }); ``` -### release(): Promise; +### release -**System Capabilities:** +release(): Promise -SystemCapability.Multimedia.Camera.Core +Releases this **PreviewOutput** instance. This API uses a promise to return the result. -**Description** +**System capability**: SystemCapability.Multimedia.Camera.Core -Releases this **PreviewOutput** instance. This method uses a promise to return the result. +**Return value** -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -2076,22 +1944,20 @@ previewOutput.release().then(() => { }) ``` -### on(type: 'frameStart', callback: Callback): void; +### on('frameStart') -**System Capabilities:** +on(type: 'frameStart', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Listens for preview frame start events. This API uses an asynchronous callback to return the result. -**Description** - -Listens for preview frame start events. This method uses a callback to get the event information. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| :------- | :------------------- | :--- | :------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **frameStart**, indicating the preview frame start event.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -2101,22 +1967,20 @@ previewOutput.on('frameStart', () => { }) ``` -### on(type: 'frameEnd', callback: Callback): void; - -**System Capabilities:** +### on('frameEnd') -SystemCapability.Multimedia.Camera.Core +on(type: 'frameEnd', callback: AsyncCallback): void -**Description** +Listens for preview frame end events. This API uses an asynchronous callback to return the result. -Listens for preview frame end event. This method uses a callback to get the event information. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| :------- | :------------------- | :--- | :----------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **frameEnd**, indicating the preview frame end event.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -2126,22 +1990,20 @@ previewOutput.on('frameEnd', () => { }) ``` -### on(type: 'error', callback: Callback): void; +### on('error') -**System Capabilities:** +on(type: 'error', callback: ErrorCallback): void -SystemCapability.Multimedia.Camera.Core +Listens for **PreviewOutput** errors. This API uses a callback to return the errors. -**Description** - -Listens for **PreviewOutput** errors. This method uses a callback to get errors. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Preview output error event. | -| callback | Callback | Yes | Callback used to get the preview output errors. | +| Name | Type | Mandatory| Description | +| :------- | :--------------------------------- | :--- | :-------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the preview output error event.| +| callback | ErrorCallback | Yes | Callback used to return the preview output errors. | **Example** @@ -2151,22 +2013,20 @@ previewOutput.on('error', (previewOutputError) => { }) ``` -## createPhotoOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** +## camera.createPhotoOutput -SystemCapability.Multimedia.Camera.Core +createPhotoOutput(surfaceId: string, callback: AsyncCallback): void -**Description** +Creates a **PhotoOutput** instance. This API uses an asynchronous callback to return the instance. -Creates a **PhotoOutput** instance. This method uses an asynchronous callback to return the instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from ImageReceiver | -| callback | AsyncCallback | Yes | Callback used to return the PhotoOutput instance | +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------- | ---- | ----------------------------------- | +| surfaceId | string | Yes | Surface ID received from **ImageReceiver**. | +| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | Yes | Callback used to return the **PhotoOutput** instance.| **Example** @@ -2178,29 +2038,27 @@ camera.createPhotoOutput((surfaceId), (err, photoOutput) => { } console.log('Callback returned with the PhotoOutput instance.'); }); -``` - -## createPhotoOutput(surfaceId: string): Promise; +``` -**System Capabilities:** +## camera.createPhotoOutput -SystemCapability.Multimedia.Camera.Core +createPhotoOutput(surfaceId: string): Promise -**Description** +Creates a **PhotoOutput** instance. This API uses a promise to return the instance. -Creates a **PhotoOutput** instance. This method uses a promise to return the PhotoOutput instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from ImageReceiver | +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | --------------------------------- | +| surfaceId | string | Yes | Surface ID received from **ImageReceiver**.| -**Return values** +**Return value** -| Type | Description | -|-------------------------|--------------------------------------------------| -| Promise | Promise used to return the PhotoOutput instance | +| Type | Description | +| ------------------------------------- | -------------------------------------- | +| Promise<[PhotoOutput](#photooutput)\> | Promise used to return the **PhotoOutput** instance.| **Example** @@ -2213,79 +2071,59 @@ camera.createPhotoOutput(surfaceId).then((photoOutput) => { Enumerates the image rotation angles. -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default Value | Description | -|--------------|---------------|----------------------------------------| -| ROTATION_0 | 0 | The capture image rotates 0 degrees | -| ROTATION_90 | 90 | The capture image rotates 90 degrees | -| ROTATION_180 | 180 | The capture image rotates 180 degrees | -| ROTATION_270 | 270 | The capture image rotates 270 degrees | +**System capability**: SystemCapability.Multimedia.Camera.Core +| Name | Default Value| Description | +| ------------ | ------ | --------------- | +| ROTATION_0 | 0 | The image rotates 0 degrees. | +| ROTATION_90 | 90 | The image rotates 90 degrees. | +| ROTATION_180 | 180 | The image rotates 180 degrees.| +| ROTATION_270 | 270 | The image rotates 270 degrees.| -## Location -Defines the location of a captured image. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Type | Access | Description | -|-----------|--------|--------------|-------------| -| latitude | number | read / write | Latitude | -| longitude | number | read / write | Longitude | ## QualityLevel Enumerates the image quality levels. -**System Capabilities:** +**System capability**: SystemCapability.Multimedia.Camera.Core -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|----------------------|---------------|----------------------| -| QUALITY_LEVEL_HIGH | 0 | High image quality | -| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality | -| QUALITY_LEVEL_LOW | 2 | Low image quality | +| Name | Default Value| Description | +| -------------------- | ------ | -------------- | +| QUALITY_LEVEL_HIGH | 0 | High image quality. | +| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality.| +| QUALITY_LEVEL_LOW | 2 | Low image quality. | ## PhotoCaptureSetting Defines the settings for image capture. -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core +**System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Type | Mandatory | Description | -|----------|---------------|-----------|---------------------| -| quality | QualityLevel | Optional | Photo image quality | -| rotation | ImageRotation | Optional | Photo rotation | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------- | ---- | -------------- | +| quality | [QualityLevel](#qualitylevel) | No | Photo image quality. | +| rotation | [ImageRotation](#imagerotation) | No | Photo rotation.| ## PhotoOutput Implements photo output. -### capture(callback: AsyncCallback): void; +### capture -**System Capabilities:** +capture(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Captures a photo. This API uses an asynchronous callback to return the result. -**Description** - -Captures a photo. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|---------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -2299,22 +2137,20 @@ photoOutput.capture((err) => { }); ``` -### capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; - -**System Capabilities:** +### capture -SystemCapability.Multimedia.Camera.Core +capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void -**Description** +Captures a photo with the specified capture settings. This API uses an asynchronous callback to return the result. -Captures a photo with the specified capture settings. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| setting | PhotoCaptureSetting | Yes | Photo capture settings | -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------- | ---- | ------------------------ | +| setting | [PhotoCaptureSetting](#photocapturesetting) | Yes | Photo capture settings. | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -2328,27 +2164,25 @@ photoOutput.capture(settings, (err) => { }); ``` -### capture(setting?: PhotoCaptureSetting): Promise; +### capture -**System Capabilities:** +capture(setting?: PhotoCaptureSetting): Promise -SystemCapability.Multimedia.Camera.Core +Captures a photo with the specified capture settings. This API uses a promise to return the result. -**Description** - -Captures a photo with the specified capture settings. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|---------------------|-----------|----------------------------------------------| -| setting | PhotoCaptureSetting | No | Photo capture settings | +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------- | ---- | ---------- | +| setting | [PhotoCaptureSetting](#photocapturesetting) | No | Photo capture settings.| -**Return values** +**Return value** -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -2359,21 +2193,19 @@ photoOutput.capture().then(() => { }) ``` -### release(callback: AsyncCallback): void; +### release -**System Capabilities:** +release(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Releases this **PhotoOutput** instance. This API uses an asynchronous callback to return the result. -**Description** - -Releases this **PhotoOutput** instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -2387,21 +2219,19 @@ photoOutput.release((err) => { }); ``` -### release(): Promise; - -**System Capabilities:** +### release -SystemCapability.Multimedia.Camera.Core +release(): Promise -**Description** +Releases this **PhotoOutput** instance. This API uses a promise to return the result. -Releases this **PhotoOutput** instance. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core -**Return values** +**Return value** -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -2412,22 +2242,20 @@ photoOutput.release().then(() => { }) ``` -### on(type: 'captureStart', callback: Callback): void; +### on('captureStart') -**System Capabilities:** +on(type: 'captureStart', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Listens for photo capture start events. This API uses a callback to return the event information. -**Description** - -Listens for photo capture start events. This method uses a callback to get the event information. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the capture ID. | +| Name | Type | Mandatory| Description | +| :------- | :--------------------- | :--- | :----------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **captureStart**, indicating the photo capture start event.| +| callback | AsyncCallback | Yes | Callback used to return the capture ID. | **Example** @@ -2437,22 +2265,20 @@ photoOutput.on('captureStart', (captureId) => { }) ``` -### on(type: 'frameShutter', callback: Callback): void; - -**System Capabilities:** +### on('frameShutter') -SystemCapability.Multimedia.Camera.Core +on(type: 'frameShutter', callback: AsyncCallback): void -**Description** +Listens for frame shutter events. This API uses a callback to return the event information. -Listens for frame shutter events. This method uses a callback to get the event information. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the frame shutter information.| +| Name | Type | Mandatory| Description | +| :------- | :------------------------------- | :--- | :--------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **frameShutter**, indicating the frame shutter event.| +| callback | AsyncCallback | Yes | Callback used to return the frame shutter information. | **Example** @@ -2463,22 +2289,20 @@ photoOutput.on('frameShutter', (frameShutterInfo) => { }) ``` -### on(type: 'captureEnd', callback: Callback): void; +### on('captureEnd') -**System Capabilities:** +on(type: 'captureEnd', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Listens for photo capture end events. This API uses a callback to return the event information. -**Description** - -Listens for photo capture end events. This method uses a callback to get the event information. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :------------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the capture end information | +| Name | Type | Mandatory| Description | +| :------- | :----------------------------- | :--- | :--------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **captureEnd**, indicating the photo capture end event.| +| callback | AsyncCallback | Yes | Callback used to return the photo capture end information. | **Example** @@ -2489,22 +2313,20 @@ photoOutput.on('captureEnd', (captureEndInfo) => { }) ``` -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** +### on('error') -SystemCapability.Multimedia.Camera.Core +on(type: 'error', callback: ErrorCallback): void -**Description** +Listens for **PhotoOutput** errors. This API uses a callback to return the errors. -Listens for **PhotoOutput** errors. This method uses a callback to get errors. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Photo output error event. | -| callback | Callback | Yes | Callback used to get the photo output errors. | +| Name | Type | Mandatory| Description | +| :------- | :------------------------------- | :--- | :---------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the photo output error event.| +| callback | ErrorCallback | Yes | Callback used to return the photo output errors. | **Example** @@ -2514,22 +2336,20 @@ photoOutput.on('error', (photoOutputError) => { }) ``` -## createVideoOutput(surfaceId: string, callback: AsyncCallback): void; +## camera.createVideoOutput -**System Capabilities:** +createVideoOutput(surfaceId: string, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Creates a **VideoOutput** instance. This API uses an asynchronous callback to return the instance. -**Description** - -Creates a **VideoOutput** instance. This method uses an asynchronous callback to return the instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from VideoRecorder | -| callback | AsyncCallback | Yes | Callback used to return the VideoOutput instance | +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------- | ---- | ----------------------------------- | +| surfaceId | string | Yes | Surface ID received from **VideoRecorder**. | +| callback | AsyncCallback<[VideoOutput](#videooutput)\> | Yes | Callback used to return the **VideoOutput** instance.| **Example** @@ -2541,29 +2361,27 @@ camera.createVideoOutput((surfaceId), (err, videoOutput) => { } console.log('Callback returned with the VideoOutput instance'); }); -``` - -## createVideoOutput(surfaceId: string): Promise; +``` -**System Capabilities:** +## camera.createVideoOutput -SystemCapability.Multimedia.Camera.Core +createVideoOutput(surfaceId: string): Promise -**Description** +Creates a **VideoOutput** instance. This API uses a promise to return the instance. -Creates a **VideoOutput** instance. This method uses a promise to return the VideoOutput instance. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from VideoRecorder | +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | --------------------------------- | +| surfaceId | string | Yes | Surface ID received from **VideoRecorder**.| -**Return values** +**Return value** -| Type | Description | -|---------------------------------------|-------------------------------------------------| -| Promise<[VideoOutput](#videooutput)\> | Promise used to return the VideoOutput instance | +| Type | Description | +| ------------------------------------- | -------------------------------------- | +| Promise<[VideoOutput](#videooutput)\> | Promise used to return the **VideoOutput** instance.| **Example** @@ -2572,25 +2390,24 @@ camera.createVideoOutput(surfaceId).then((videoOutput) => { console.log('Promise returned with the VideoOutput instance'); }) ``` + ## VideoOutput Implements video output. -### start(callback: AsyncCallback): void; - -**System Capabilities:** +### start -SystemCapability.Multimedia.Camera.Core +start(callback: AsyncCallback): void -**Description** +Starts the video output. This API uses an asynchronous callback to return the result. -Starts the video output. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -2604,21 +2421,19 @@ videoOutput.start((err) => { }); ``` -### start(): Promise; +### start -**System Capabilities:** +start(): Promise -SystemCapability.Multimedia.Camera.Core +Starts the video output. This API uses a promise to return the result. -**Description** +**System capability**: SystemCapability.Multimedia.Camera.Core -Starts the video output. This method uses a promise to return the result. +**Return value** -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -2629,21 +2444,19 @@ videoOutput.start().then(() => { }) ``` -### stop(callback: AsyncCallback): void; +### stop -**System Capabilities:** +stop(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Stops the video output. This API uses an asynchronous callback to return the result. -**Description** - -Stops the video output. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -2657,21 +2470,19 @@ videoOutput.stop((err) => { }); ``` -### stop(): Promise; - -**System Capabilities:** +### stop -SystemCapability.Multimedia.Camera.Core +stop(): Promise -**Description** +Stops the video output. This API uses a promise to return the result. -Stops the video output. This method uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core -**Return values** +**Return value** -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -2681,21 +2492,19 @@ videoOutput.start().then(() => { }) ``` -### release(callback: AsyncCallback): void; - -**System Capabilities:** +### release -SystemCapability.Multimedia.Camera.Core +release(callback: AsyncCallback): void -**Description** +Releases this **VideoOutput** instance. This API uses an asynchronous callback to return the result. -Releases this VideoOutput instance. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** @@ -2709,21 +2518,19 @@ videoOutput.release((err) => { }); ``` -### release(): Promise; +### release -**System Capabilities:** +release(): Promise -SystemCapability.Multimedia.Camera.Core +Releases this **VideoOutput** instance. This API uses a promise to return the result. -**Description** +**System capability**: SystemCapability.Multimedia.Camera.Core -Releases this VideoOutput instance. This method uses a promise to return the result. +**Return value** -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Type | Description | +| -------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** @@ -2734,22 +2541,20 @@ videoOutput.release().then(() => { }) ``` -### on(type: 'frameStart', callback: Callback): void; +### on('frameStart') -**System Capabilities:** +on(type: 'frameStart', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +Listens for video frame start events. This API uses a callback to return the event information. -**Description** - -Listens for video frame start events. This method uses a callback to get the event information. +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| :------- | :------------------- | :--- | :----------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **frameStart**, indicating the video frame start event.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -2759,16 +2564,20 @@ videoOutput.on('frameStart', () => { }) ``` -### on(type: 'frameEnd', callback: Callback): void; +### on('frameEnd') + +on(type: 'frameEnd', callback: AsyncCallback): void -Listens for video frame end events. This method uses a callback to get the event information. +Listens for video frame end events. This API uses a callback to return the event information. + +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | +| Name | Type | Mandatory| Description | +| :------- | :------------------- | :--- | :--------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **frameEnd**, indicating the video frame end event.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -2778,16 +2587,20 @@ videoOutput.on('frameEnd', () => { }) ``` -### on(type: 'error', callback: Callback): void; +### on('error') + +on(type: 'error', callback: ErrorCallback): void -Listens for **VideoOutput** errors. This method uses a callback to get errors. +Listens for **VideoOutput** errors. This API uses a callback to return the errors. + +**System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Video output error event. | -| callback | Callback | Yes | Callback used to get the video output errors. | +| Name | Type | Mandatory| Description | +| :------- | :-------------------------- | :--- | :-------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the video output error event.| +| callback | Callback | Yes | Callback used to return the video output errors. | **Example** @@ -2795,4 +2608,4 @@ Listens for **VideoOutput** errors. This method uses a callback to get errors. videoOutput.on('error', (VideoOutputError) => { console.log('Video output error code: ' + VideoOutputError.code); }) -``` \ No newline at end of file +``` diff --git a/en/application-dev/reference/apis/js-apis-configuration.md b/en/application-dev/reference/apis/js-apis-configuration.md index 50803fb4587f9e8ec8e31f447a90eeccdd44780c..0cad135c638c6663301c5a4edea7a1a436ced8f3 100644 --- a/en/application-dev/reference/apis/js-apis-configuration.md +++ b/en/application-dev/reference/apis/js-apis-configuration.md @@ -1,6 +1,6 @@ # Configuration -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -19,10 +19,10 @@ import Configuration from '@ohos.application.Configuration'; **System capability**: SystemCapability.Ability.AbilityBase - | Name| Type| Readable| Writable| Description| +| Name| Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| language | string | Yes| Yes| Language of the application.| -| colorMode | [ColorMode](js-apis-configurationconstant.md) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.| -| direction9+ | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.| -| screenDensity9+ | ScreenDensity | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).| -| displayId9+ | number | Yes| No| ID of the display where the application is located.| +| language | string | Yes | Yes| Language of the application. | +| colorMode | [ColorMode](js-apis-configurationconstant.md) | Yes | Yes | Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.| +| direction9+ | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**. | +| screenDensity9+ | ScreenDensity | Yes| No | Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640). | +| displayId9+ | number | Yes| No| ID of the display where the application is located. | diff --git a/en/application-dev/reference/apis/js-apis-configurationconstant.md b/en/application-dev/reference/apis/js-apis-configurationconstant.md index ef0917ba4a9d1838832d14117a2b002d9083f1f8..a61eeea271c180fe92f22a8be5691daf70b45da6 100644 --- a/en/application-dev/reference/apis/js-apis-configurationconstant.md +++ b/en/application-dev/reference/apis/js-apis-configurationconstant.md @@ -1,6 +1,6 @@ # ConfigurationConstant -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. @@ -17,7 +17,7 @@ import ConfigurationConstant from '@ohos.application.ConfigurationConstant'; ## ConfigurationConstant.ColorMode -The value is obtained through the **ConfigurationConstant.ColorMode** API. +You can obtain the value of this constant by calling the **ConfigurationConstant.ColorMode** API. **Example** @@ -27,16 +27,16 @@ ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT **System capability**: SystemCapability.Ability.AbilityBase -| Name| Value| Description| +| Name | Value | Description | | -------- | -------- | -------- | -| COLOR_MODE_NOT_SET | -1 | Unspecified color mode.| -| COLOR_MODE_DARK | 0 | Dark mode.| -| COLOR_MODE_LIGHT | 1 | Light mode.| +| COLOR_MODE_NOT_SET | -1 | Unspecified color mode. | +| COLOR_MODE_DARK | 0 | Dark mode. | +| COLOR_MODE_LIGHT | 1 | Light mode. | ## ConfigurationConstant.Direction9+ -The value is obtained through the **ConfigurationConstant.Direction** API. +You can obtain the value of this constant by calling the **ConfigurationConstant.Direction** API. **Example** @@ -46,16 +46,16 @@ ConfigurationConstant.Direction.DIRECTION_VERTICAL **System capability**: SystemCapability.Ability.AbilityBase -| Name| Value| Description| +| Name | Value | Description | | -------- | -------- | -------- | -| DIRECTION_NOT_SET | -1 | Unspecified direction.| -| DIRECTION_VERTICAL | 0 | Vertical direction.| -| DIRECTION_HORIZONTAL | 1 | Horizontal direction.| +| DIRECTION_NOT_SET | -1 | Unspecified direction. | +| DIRECTION_VERTICAL | 0 | Vertical direction. | +| DIRECTION_HORIZONTAL | 1 | Horizontal direction. | ## ConfigurationConstant.ScreenDensity9+ -The value is obtained through the **ConfigurationConstant.ScreenDensity** API. +You can obtain the value of this constant by calling the **ConfigurationConstant.ScreenDensity** API. **Example** @@ -65,12 +65,12 @@ ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_NOT_SET **System capability**: SystemCapability.Ability.AbilityBase -| Name| Value| Description| +| Name | Value | Description | | -------- | -------- | -------- | -| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.| -| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.| -| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.| -| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.| -| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.| -| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.| -| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.| +| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution. | +| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi. | +| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi. | +| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi. | +| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi. | +| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi. | +| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi. | diff --git a/en/application-dev/reference/apis/js-apis-connectedTag.md b/en/application-dev/reference/apis/js-apis-connectedTag.md index 5e76a594771be99634ac1cfd7e3b7089b8a58ba3..f351fb3148f0e216af608b6222b8c32a0805a3cb 100644 --- a/en/application-dev/reference/apis/js-apis-connectedTag.md +++ b/en/application-dev/reference/apis/js-apis-connectedTag.md @@ -1,6 +1,6 @@ # Active Tag -> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE**
+> **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. @@ -22,9 +22,9 @@ Initializes the active tag chip. **System capability**: SystemCapability.Communication.ConnectedTag - Return value - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if the initialization is successful; returns **false** otherwise.| + | **Type** | **Description** | + | -------- | -------- | + | boolean | Returns **true** if the initialization is successful; returns **false** otherwise. | ## connectedTag.uninit @@ -38,9 +38,9 @@ Uninitializes the active tag resources. **System capability**: SystemCapability.Communication.ConnectedTag - Return value - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + | **Type** | **Description** | + | -------- | -------- | + | boolean | Returns **true** if the operation is successful; returns **false** otherwise. | ## connectedTag.readNdefTag @@ -54,9 +54,9 @@ Reads the content of this active tag. This method uses a promise to return the r **System capability**: SystemCapability.Communication.ConnectedTag - Return value - | **Type**| **Description**| - | -------- | -------- | - | Promise<string> | Promise used to return the content of the active tag.| + | **Type** | **Description** | + | -------- | -------- | + | Promise<string> | Promise used to return the content of the active tag. | - Example ``` @@ -78,9 +78,9 @@ Reads the content of this active tag. This method uses an asynchronous callback **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<string> | Yes| Callback invoked to return the active tag content obtained.| + | **Name** | **Type** | **Mandatory** | **Description** | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<string> | Yes | Callback invoked to return the active tag content obtained. | - Example ``` @@ -102,14 +102,14 @@ Writes data to this active tag. This method uses a promise to return the result. **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | data | string | Yes| Data to write. The maximum length is 1024 bytes.| + | **Name** | **Type** | **Mandatory** | **Description** | + | -------- | -------- | -------- | -------- | + | data | string | Yes | Data to write. The maximum length is 1024 bytes. | - Return value - | **Type**| **Description**| - | -------- | -------- | - | Promise<void> | Promise used to return the result. This method returns no value.| + | **Type** | **Description** | + | -------- | -------- | + | Promise<void> | Promise used to return the result. This method returns no value. | - Example ``` @@ -136,10 +136,10 @@ Writes data to this active tag. This method uses an asynchronous callback to ret **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | data | string | Yes| Data to write. The maximum length is 1024 bytes.| - | callback | AsyncCallback<string> | Yes| Callback invoked to return the operation result.| + | **Name** | **Type** | **Mandatory** | **Description** | + | -------- | -------- | -------- | -------- | + | data | string | Yes | Data to write. The maximum length is 1024 bytes. | + | callback | AsyncCallback<string> | Yes | Callback invoked to return the operation result. | - Example ``` @@ -168,16 +168,16 @@ Registers the NFC field strength state events. **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **notify**.| - | callback | Callback<number> | Yes| Callback invoked to return the field strength state.| + | **Name** | **Type** | **Mandatory** | **Description** | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Event type. The value is **notify**. | + | callback | Callback<number> | Yes | Callback invoked to return the field strength state. | - Enumerates the field strength states. - | **Value**| **Description**| - | -------- | -------- | - | 0 | Field off. | - | 1 | Field on. | + | **Value** | **Description** | + | -------- | -------- | + | 0 | Field off. | + | 1 | Field on. | ## connectedTag.off('notify') @@ -191,10 +191,10 @@ Unregisters the NFC field strength state events. **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **notify**.| - | callback | Callback<number> | No| Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| + | **Name** | **Type** | **Mandatory** | **Description** | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Event type. The value is **notify**. | + | callback | Callback<number> | No | Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered. | - Example ``` @@ -206,10 +206,10 @@ Unregisters the NFC field strength state events. console.info("nfc rf receive state: " + result); } - // Register event + // Register event notification connectedTag.on(NFC_RF_NOTIFY, recvNfcRfNotifyFunc); - // Unregister event + // Unregister event notification connectedTag.off(NFC_RF_NOTIFY, recvNfcRfNotifyFunc); ``` @@ -217,7 +217,7 @@ Unregisters the NFC field strength state events. Enumerates the NFC states. -| Name| Default Value| Description| -| -------- | -------- | -------- | -| NFC_RF_LEAVE | 0 | Field off. | -| NFC_RF_ENTER | 1 | Field on. | + | Name | Default Value | Description | + | -------- | -------- | -------- | + | NFC_RF_LEAVE | 0 | Field off. | + | NFC_RF_ENTER | 1 | Field on. | diff --git a/en/application-dev/reference/apis/js-apis-contact.md b/en/application-dev/reference/apis/js-apis-contact.md index 9a4574e06995556c1037c45e0bfc353d980c306a..610f802066ab324e80c663d61513b062f9dfc9bf 100644 --- a/en/application-dev/reference/apis/js-apis-contact.md +++ b/en/application-dev/reference/apis/js-apis-contact.md @@ -7,7 +7,7 @@ ## Modules to Import -``` +```js import contact from '@ohos.contact'; ``` @@ -29,7 +29,7 @@ Adds a contact. This API uses an asynchronous callback to return the result. **Example** - ``` + ```js contact.addContact({ fullName: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] @@ -65,7 +65,7 @@ Adds a contact. This API uses a promise to return the result. **Example** - ``` + ```js let promise = contact.addContact({ name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] @@ -96,7 +96,7 @@ Deletes a contact based on the specified contact key. This API uses an asynchron **Example** - ``` + ```js contact.deleteContact('xxx', (err) => { if (err) { console.log(`deleteContact callback: err->${JSON.stringify(err)}`); @@ -129,7 +129,7 @@ Deletes a contact based on the specified contact key. This API uses a promise to **Example** - ``` + ```js let promise = contact.deleteContact('xxx'); promise.then(() => { console.log(`deleteContact success`); @@ -157,7 +157,7 @@ Updates a contact based on the specified contact information. This API uses an a **Example** - ``` + ```js contact.updateContact({ name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] @@ -190,7 +190,7 @@ Updates a contact based on the specified contact information and attributes. Thi **Example** - ``` + ```js contact.updateContact({ fullName: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] @@ -229,7 +229,7 @@ Updates a contact based on the specified contact information and attributes. Thi **Example** - ``` + ```js let promise = contact.updateContact({ fullName: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] @@ -262,7 +262,7 @@ Checks whether the ID of this contact is in the local address book. This API use **Example** - ``` + ```js contact.isLocalContact(/*id*/1, (err, data) => { if (err) { console.log(`isLocalContact callback: err->${JSON.stringify(err)}`); @@ -295,7 +295,7 @@ Checks whether the ID of this contact is in the local address book. This API use **Example** - ``` + ```js let promise = contact.isLocalContact(/*id*/1); promise.then((data) => { console.log(`isLocalContact success: data->${JSON.stringify(data)}`); @@ -323,7 +323,7 @@ Checks whether a contact is included in my card. This API uses an asynchronous c **Example** - ``` + ```js contact.isMyCard(/*id*/1, (err, data) => { if (err) { console.log(`isMyCard callback: err->${JSON.stringify(err)}`); @@ -356,7 +356,7 @@ Checks whether a contact is included in my card. This API uses a promise to retu **Example** - ``` + ```js let promise = contact.isMyCard(/*id*/1); promise.then((data) => { console.log(`isMyCard success: data->${JSON.stringify(data)}`); @@ -383,7 +383,7 @@ Queries my card. This API uses an asynchronous callback to return the result. **Example** - ``` + ```js contact.queryMyCard((err, data) => { if (err) { console.log(`queryMyCard callback: err->${JSON.stringify(err)}`); @@ -412,7 +412,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn **Example** - ``` + ```js contact.queryMyCard({ attributes:['ATTR_EMAIL', 'ATTR_NAME'] }, (err, data) => { @@ -447,7 +447,7 @@ Queries my card based on the specified contact attributes. This API uses a promi **Example** - ``` + ```js let promise = contact.queryMyCard({ attributes:['ATTR_EMAIL', 'ATTR_NAME'] }); @@ -478,7 +478,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a **Example** - ``` + ```js contact.selectContact((err, data) => { if (err) { console.log(`selectContact callback: err->${JSON.stringify(err)}`); @@ -508,7 +508,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a **Example** - ``` + ```js let promise = contact.selectContact(); promise.then((data) => { console.log(`selectContact success: data->${JSON.stringify(data)}`); @@ -536,7 +536,7 @@ Queries a contact based on the specified key. This API uses an asynchronous call **Example** - ``` + ```js contact.queryContact('xxx', (err, data) => { if (err) { console.log(`queryContact callback: err->${JSON.stringify(err)}`); @@ -566,7 +566,7 @@ Queries contacts based on the specified key and application. This API uses an as **Example** - ``` + ```js contact.queryContact('xxx', { holderId: 0 }, (err, data) => { @@ -598,7 +598,7 @@ Queries contacts based on the specified key and attributes. This API uses an asy **Example** - ``` + ```js contact.queryContact('xxx', { attributes: ["ATTR_EMAIL", "ATTR_NAME"] }, (err, data) => { @@ -631,7 +631,7 @@ Queries contacts based on the specified key, application, and attributes. This A **Example** - ``` + ```js contact.queryContact('xxx', { holderId: 0 }, { @@ -670,7 +670,7 @@ Queries contacts based on the specified key, application, and attributes. This A **Example** - ``` + ```js let promise = contact.queryContact('xxx', { holderId: 0 }, { @@ -701,7 +701,7 @@ Queries all contacts. This API uses an asynchronous callback to return the resul **Example** - ``` + ```js contact.queryContacts((err, data) => { if (err) { console.log(`queryContacts callback: err->${JSON.stringify(err)}`); @@ -730,7 +730,7 @@ Queries all contacts based on the specified application. This API uses an asynch **Example** - ``` + ```js contact.queryContacts({ holderId: 0 }, (err, data) => { @@ -761,7 +761,7 @@ Queries all contacts based on the specified attributes. This API uses an asynchr **Example** - ``` + ```js contact.queryContacts({ attributes: ["ATTR_EMAIL", "ATTR_NAME"] }, (err, data) => { @@ -793,7 +793,7 @@ Queries all contacts based on the specified application and attributes. This API **Example** - ``` + ```js contact.queryContacts({ holderId: 0 }, { @@ -831,7 +831,7 @@ Queries all contacts based on the specified application and attributes. This API **Example** - ``` + ```js let promise = contact.queryContacts({ holderId: 0 }, { @@ -863,7 +863,7 @@ Queries contacts based on the specified phone number. This API uses an asynchron **Example** - ``` + ```js contact.queryContactsByPhoneNumber('138xxxxxxxx', (err, data) => { if (err) { console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`); @@ -893,7 +893,7 @@ Queries contacts based on the specified phone number and application. This API u **Example** - ``` + ```js contact.queryContactsByPhoneNumber('138xxxxxxxx', { holderId: 0 }, (err, data) => { @@ -925,7 +925,7 @@ Queries contacts based on the specified phone number and attributes. This API us **Example** - ``` + ```js contact.queryContactsByPhoneNumber('138xxxxxxxx', { attributes: ["ATTR_EMAIL", "ATTR_NAME"] }, (err, data) => { @@ -958,7 +958,7 @@ Queries contacts based on the specified phone number, application, and attribute **Example** - ``` + ```js contact.queryContactsByPhoneNumber('138xxxxxxxx', { holderId: 0 }, { @@ -997,7 +997,7 @@ Queries contacts based on the specified phone number, application, and attribute **Example** - ``` + ```js let promise = contact.queryContactsByPhoneNumber('138xxxxxxxx', { holderId: 0 }, { @@ -1029,7 +1029,7 @@ Queries contacts based on the specified email address. This API uses an asynchro **Example** - ``` + ```js contact.queryContactsByEmail('xxx@email.com', (err, data) => { if (err) { console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`); @@ -1059,7 +1059,7 @@ Queries contacts based on the specified email address and application. This API **Example** - ``` + ```js contact.queryContactsByEmail('xxx@email.com', { holderId: 0 }, (err, data) => { @@ -1091,7 +1091,7 @@ Queries contacts based on the specified email address and attributes. This API u **Example** - ``` + ```js contact.queryContactsByEmail('xxx@email.com', { attributes: ["ATTR_EMAIL", "ATTR_NAME"] }, (err, data) => { @@ -1124,7 +1124,7 @@ Queries contacts based on the specified email address, application, and attribut **Example** - ``` + ```js contact.queryContactsByEmail('xxx@email.com', { holderId: 0 }, { @@ -1163,7 +1163,7 @@ Queries contacts based on the specified email address, application, and attribut **Example** - ``` + ```js let promise = contact.queryContactsByEmail('xxx@email.com', { holderId: 0 }, { @@ -1194,7 +1194,7 @@ Queries all groups of this contact. This API uses an asynchronous callback to re **Example** - ``` + ```js contact.queryGroups((err, data) => { if (err) { console.log(`queryGroups callback: err->${JSON.stringify(err)}`); @@ -1223,7 +1223,7 @@ Queries all groups of this contact based on the specified application. This API **Example** - ``` + ```js contact.queryGroups({ holderId: 0 }, (err, data) => { @@ -1258,7 +1258,7 @@ Queries all groups of this contact based on the specified application. This API **Example** - ``` + ```js let promise = contact.queryGroups({ holderId: 0 }); @@ -1287,7 +1287,7 @@ Queries all applications that have created contacts. This API uses an asynchrono **Example** - ``` + ```js contact.queryHolders((err, data) => { if (err) { console.log(`queryHolders callback: err->${JSON.stringify(err)}`); @@ -1315,7 +1315,7 @@ Queries all applications that have created contacts. This API uses a promise to **Example** - ``` + ```js let promise = contact.queryHolders(); promise.then((data) => { console.log(`queryHolders success: data->${JSON.stringify(data)}`); @@ -1343,7 +1343,7 @@ Queries the key of a contact based on the specified contact ID. This API uses an **Example** - ``` + ```js contact.queryKey(/*id*/1, (err, data) => { if (err) { console.log(`queryKey callback: err->${JSON.stringify(err)}`); @@ -1373,7 +1373,7 @@ Queries the key of a contact based on the specified contact ID and application. **Example** - ``` + ```js contact.queryKey(id, { holderId:1 }, (err, data) => { @@ -1409,7 +1409,7 @@ Queries the key of a contact based on the specified contact ID and application. **Example** - ``` + ```js let promise = contact.queryKey(id, { holderId: 0 }); @@ -1462,7 +1462,7 @@ Defines a contact. Create contact data in JSON format: -``` +```js let myContact = { phoneNumbers: [{ phoneNumber: "138xxxxxxxx" @@ -1480,7 +1480,7 @@ let myContact = { Or, create data by configuring a new Contact object. -``` +```js let myContact = new contact.Contact(); let name = new contact.Name(); name.fullName = "fullName"; @@ -1508,7 +1508,7 @@ If **null** is passed, all attributes are queried by default. Create contact data in JSON format: -``` +```js let contactAttributes = { attributes: [ contact.Attribute.ATTR_EMAIL, @@ -1521,7 +1521,7 @@ let contactAttributes = { Or, create data by configuring a **ContactAttributes** object. -``` +```js let contactAttributes = new contact.ContactAttributes(); contactAttributes.attributes = ["ATTR_EMAIL"]; ``` @@ -1555,7 +1555,7 @@ Enumerates contact attributes. Create contact data in JSON format: -``` +```js let attributes = [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_PHONE]; ``` @@ -1591,7 +1591,7 @@ Defines a contact's email. Create contact data in JSON format: -``` +```js let email = { email: "xxx@email.com", displayName: "displayName" @@ -1601,7 +1601,7 @@ let email = { Or, create data by configuring an **Email** object. -``` +```js let email = new contact.Email(); email.email = "xxx@email.com"; ``` @@ -1624,7 +1624,7 @@ Defines an application that creates the contact. Create contact data in JSON format: -``` +```js let holder = { holderId: 0 }; @@ -1632,7 +1632,7 @@ let holder = { Or, create data by configuring a **Holder** object. -``` +```js let holder = new contact.Holder(); holder.holderId = 0; ``` @@ -1668,7 +1668,7 @@ Defines a contact's event. Create contact data in JSON format: -``` +```js let event = { eventDate: "xxxxxx" }; @@ -1676,7 +1676,7 @@ let event = { Or, create data by configuring an **Event** object. -``` +```js let event = new contact.Event(); event.eventDate = "xxxxxx"; ``` @@ -1698,7 +1698,7 @@ Defines a contact group. Create contact data in JSON format: -``` +```js let group = { groupId: 1, title: "title" @@ -1707,7 +1707,7 @@ let group = { Or, create data by configuring a **Group** object. -``` +```js let group = new contact.Group(); group.title = "title"; ``` @@ -1747,7 +1747,7 @@ Enumerates IM addresses. Create contact data in JSON format: -``` +```js let imAddress = { imAddress: "imAddress", labelName: "labelName" @@ -1757,7 +1757,7 @@ let imAddress = { Or, create data by configuring an **ImAddress** object. -``` +```js let imAddress = new contact.ImAddress(); imAddress.imAddress = "imAddress"; ``` @@ -1786,7 +1786,7 @@ Defines a contact's name. Create contact data in JSON format: -``` +```js let name = { familyName: "familyName", fullName: "fullName" @@ -1795,7 +1795,7 @@ let name = { Or, create data by configuring a **Name** object. -``` +```js let name = new contact.Name(); name.familyName = "familyName"; name.fullName = "fullName"; @@ -1817,7 +1817,7 @@ Defines a contact's nickname. Create contact data in JSON format: -``` +```js let nickName = { nickName: "nickName" }; @@ -1825,7 +1825,7 @@ let nickName = { Or, create data by configuring a **NickName** object. -``` +```js let nickName = new contact.NickName(); nickName.nickName = "nickName"; ``` @@ -1846,7 +1846,7 @@ Defines a contact's note. Create contact data in JSON format: -``` +```js let note = { noteContent: "noteContent" }; @@ -1854,7 +1854,7 @@ let note = { Or, create data by configuring a **Note** object. -``` +```js let note = new contact.Note(); note.noteContent = "noteContent"; ``` @@ -1876,7 +1876,7 @@ Defines a contact's organization. Create contact data in JSON format: -``` +```js let organization = { name: "name", title: "title" @@ -1885,7 +1885,7 @@ let organization = { Or, create data by configuring an **Organization** object. -``` +```js let organization = new contact.Organization(); organization.name = "name"; organization.title = "title"; @@ -1939,7 +1939,7 @@ Defines a contact's phone number. Create contact data in JSON format: -``` +```js let phoneNumber = { phoneNumber: "138xxxxxxxx", labelId: contact.PhoneNumber.NUM_HOME @@ -1948,7 +1948,7 @@ let phoneNumber = { Or, create data by configuring a new **PhoneNumber** object. -``` +```js let phoneNumber = new contact.PhoneNumber(); phoneNumber.phoneNumber = "138xxxxxxxx"; ``` @@ -1969,7 +1969,7 @@ Defines a contact's portrait. Create contact data in JSON format: -``` +```js let portrait = { uri: "uri" }; @@ -1977,7 +1977,7 @@ let portrait = { Or, create data by configuring a new **Portrait** object. -``` +```js let portrait = new contact.Portrait(); portrait.uri = "uri"; ``` @@ -2020,7 +2020,7 @@ Defines a contact's postal address. Create contact data in JSON format: -``` +```js let postalAddress = { city: "city" }; @@ -2028,7 +2028,7 @@ let postalAddress = { Or, create data by configuring a new **PostalAddress** object. -``` +```js let postalAddress = new contact.PostalAddress(); postalAddress.city = "city"; ``` @@ -2075,7 +2075,7 @@ Defines a contact's relationship. Create contact data in JSON format: -``` +```js let relation = { relationName: "relationName", labelId: contact.Relation.RELATION_ASSISTANT @@ -2084,7 +2084,7 @@ let relation = { Or, create data by configuring a new **Relation** object. -``` +```js let relation = new contact.Relation(); relation.relationName = "relationName"; relation.labelId = contact.Relation.RELATION_ASSISTANT; @@ -2121,7 +2121,7 @@ Defines a contact's SIP address. Create contact data in JSON format: -``` +```js var sipAddress = { sipAddress: "sipAddress" }; @@ -2129,7 +2129,7 @@ var sipAddress = { Or, create data by configuring a new **SipAddress** object. -``` +```js let sipAddress = new contact.SipAddress(); sipAddress.sipAddress = "sipAddress"; ``` @@ -2150,7 +2150,7 @@ Defines a contact's website. Create contact data in JSON format: -``` +```js let website = { website: "website" }; @@ -2158,7 +2158,7 @@ let website = { Or, create data by configuring a new **Website** object. -``` +```js let website = new contact.Website(); website.website = "website"; ``` diff --git a/en/application-dev/reference/apis/js-apis-data-ability.md b/en/application-dev/reference/apis/js-apis-data-ability.md index 14fba2457383feceeefe0b302b1710e856bc187e..7149bdeeaa292cc1b41a29fc09feef097dcea29f 100644 --- a/en/application-dev/reference/apis/js-apis-data-ability.md +++ b/en/application-dev/reference/apis/js-apis-data-ability.md @@ -1,6 +1,6 @@ # DataAbilityPredicates -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. @@ -22,6 +22,7 @@ Creates an **RdbPredicates** object based on a **DataAabilityPredicates** object **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | name | string | Yes| Table name in the RDB store.| diff --git a/en/application-dev/reference/apis/js-apis-data-distributedobject.md b/en/application-dev/reference/apis/js-apis-data-distributedobject.md index 6670e2eefaea1bd07d85083bf5436833613f998e..36761408ca6fe04d507711a0664f0903fa48be90 100644 --- a/en/application-dev/reference/apis/js-apis-data-distributedobject.md +++ b/en/application-dev/reference/apis/js-apis-data-distributedobject.md @@ -1,6 +1,6 @@ # Distributed Data Object -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. @@ -10,8 +10,6 @@ import distributedObject from '@ohos.data.distributedDataObject'; ``` - - ## distributedDataObject.createDistributedObject createDistributedObject(source: object): DistributedObject @@ -26,7 +24,7 @@ Creates a distributed data object. | -------- | -------- | -------- | -------- | | source | object | Yes| Attribute of the distributed data object to create.| -**Return Value** +**Return value** | Type| Description| | -------- | -------- | | [DistributedObject](#distributedobject) | Distributed data object created.| @@ -34,7 +32,7 @@ Creates a distributed data object. **Example** ```js import distributedObject from '@ohos.data.distributedDataObject' - // Create a distributedObject instance. The attribute type of the object can be string, number, boolean, or Object. + // Create a distributed data object, which contains attributes of four types, namely, string, number, boolean, and object. var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, parent:{mother:"jack mom",father:"jack Dad"}}); ``` @@ -48,7 +46,7 @@ Creates a random session ID. **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject -**Return Value** +**Return value** | Type| Description| | -------- | -------- | | string | Session ID created.| @@ -62,7 +60,7 @@ Creates a random session ID. ## DistributedObject -Represents a **distributedObject** instance. +Represents a distributed data object. ### setSessionId @@ -78,7 +76,7 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo | -------- | -------- | -------- | -------- | | sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| -**Return Value** +**Return value** | Type| Description| | -------- | -------- | @@ -101,15 +99,15 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void -Subscribes to the data changes of this distributed data object. +Subscribes to the changes of this distributed data object. **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data change events.| - | callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback used to return the changes of the distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the attributes of the distributed data object changed.| + | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.| + | callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback used to return the changes of the distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.| **Example** ```js @@ -130,15 +128,15 @@ Subscribes to the data changes of this distributed data object. off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void -Unsubscribes from the data changes of this distributed data object. +Unsubscribes from the changes of this distributed data object. **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data change events.| - | callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the attributes of the distributed data object changed.| + | type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.| + | callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback used to return the changes of the distributed data object. If this parameter is not specified, this API unsubscribes from all callbacks for data changes of this distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.| **Example** @@ -149,11 +147,11 @@ Unsubscribes from the data changes of this distributed data object. g_object.on("change", function (sessionId, changeData) { console.info("change" + sessionId); }); - // Unsubscribe from the data change callback for the specified distributed data object. + // Unsubscribe from the specified data change callback for the distributed data object. g_object.off("change", function (sessionId, changeData) { console.info("change" + sessionId); }); - // Unsubscribe from all data change callbacks. + // Unsubscribe from all data change callbacks for the distributed data object. g_object.off("change"); ``` @@ -161,15 +159,15 @@ Unsubscribes from the data changes of this distributed data object. on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' | 'offline' }>): void -Subscribes to the status changes (online or offline) of this distributed data object. +Subscribes to the status change (online or offline) of this distributed data object. **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type to subscribe to. The value is "status", which indicates the status (online or offline) change events.| - | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the online or offline status.
**sessionId** indicates the session ID of the distributed data object.
**networkId** indicates the network ID of the device.
**status** indicates the status, which can be online or offline.| + | type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the change in the status (online or offline) of the distributed data object.| + | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the status change.
**sessionId** indicates the session ID of the distributed data object.
**networkId** indicates the network ID of the device.
**status** indicates the status, which can be online or offline.| **Example** ```js @@ -186,15 +184,15 @@ Subscribes to the status changes (online or offline) of this distributed data ob off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' | 'offline' }>): void -Unsubscribes from the status (online or offline) changes of the distributed data object. +Unsubscribes from the status change (online or offline) of this distributed data object. **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type to subscribe to. The value is "status", which indicates the status (online or offline) change events.| - | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback used to return the status changes. If this parameter is not specified, all the status change callbacks will be unregistered.
**sessionId** indicates the session ID of the distributed data object.
**deviceId** indicates the device ID of the distributed data object.
**status** indicates the status, which can be online or offline.| + | type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the change in the status (online or offline) of the distributed data object.| + | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback used to return the status change. If this parameter is not specified, this API unsubscribes from all callbacks of this distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**deviceId** indicates the device ID of the distributed data object.
**status** indicates the status, which can be online or offline.| **Example** @@ -203,10 +201,10 @@ Unsubscribes from the status (online or offline) changes of the distributed data g_object.on("status", function (sessionId, networkId, status) { this.response += "status changed " + sessionId + " " + status + " " + networkId; }); - // Unsubscribe from the status change callback for the specified distributed data object. + // Unsubscribe from the specified status change callback for the distributed data object. g_object.off("status", function (sessionId, networkId, status) { this.response += "status changed " + sessionId + " " + status + " " + networkId; }); - // Unsubscribe from all status change callbacks. + // Unsubscribe from all status change callbacks for the distributed data object. g_object.off("status"); ``` diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md index 791908e6c9a8e8509f364c587fa132958e475c31..1010a20849fb9da41e445bc5212e88427b3f28c5 100644 --- a/en/application-dev/reference/apis/js-apis-data-preferences.md +++ b/en/application-dev/reference/apis/js-apis-data-preferences.md @@ -1,9 +1,9 @@ # Preferences -Preferences provide capabilities for processing key-value (KV) data for applications and supports lightweight data persistence, modification, and query. Data is stored in KV pairs. Keys are of the string type, and values can be of the number, string, or Boolean type. +Preferences provide capabilities for processing data in the form of key-value (KV) pairs and supports lightweight data persistence, modification, and query. In KV pairs, keys are of the string type, and values can be of the number, string, or Boolean type. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -27,7 +27,7 @@ import data_preferences from '@ohos.data.preferences'; getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): void -Reads a preference persistence file and loads data to the **Preferences** instance for data operations. This API uses an asynchronous callback to return the result. +Reads a **Preferences** persistence file and loads data to the **Preferences** instance for data operations. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -35,86 +35,50 @@ Reads a preference persistence file and loads data to the **Preferences** instan **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| - | callback | AsyncCallback<[Preferences](#preferences)> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<[Preferences](#preferences)> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { +```ts +data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { console.info("Failed to get the preferences") - return; - } - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Failed to put the value of startup, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data to file, err: " + err) - return - } - console.info("Flushed data to file successfully.") - }) - }) - }) - } - ``` + return; + } + console.info("Got preferences successfully.") +}) +``` ## data_preferences.getPreferences getPreferences(context: Context, name: string): Promise<Preferences> -Reads a preference persistence file and loads data to the **Preferences** instance for data operations. This API uses a promise to return the result. +Reads a **Preferences** persistence file and loads data to the **Preferences** instance for data operations. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| **Return value** | Type| Description| | -------- | -------- | - | Promise<[Preferences](#preferences)> | Promise used to return the execution result.| + | Promise<[Preferences](#preferences)> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Failed to put the value of startup, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data to file, err: " + err) - return - } - console.info("Flushed data to file successfully.") - }) - }) - }).catch((err) => { +```ts +let promise = data_preferences.getPreferences(this.context, 'mystore') +promise.then((preferences) => { + console.info("Got preferences successfully.") +}).catch((err) => { console.info("Failed to get the preferences") - }) - } - ``` +}) +``` ## data_preferences.deletePreferences @@ -122,32 +86,27 @@ Reads a preference persistence file and loads data to the **Preferences** instan deletePreferences(context: Context, name: string, callback: AsyncCallback<void>): void Deletes a **Preferences** singleton instance, the persistence file and backup file, and corrupted files from the memory. -Once a preference persistence file is deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result. +Once a **Preferences** persistence file is deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.deletePreferences(this.context, 'mystore', function (err) { - if (err) { +```ts +data_preferences.deletePreferences(this.context, 'mystore', function (err) { + if (err) { console.info("Failed to delete data, err: " + err) - return - } - console.info("Deleted data successfully.") - }) - } - ``` + return + } + console.info("Deleted preferences successfully.") +}) +``` ## data_preferences.deletePreferences @@ -155,35 +114,30 @@ Once a preference persistence file is deleted, the **Preferences** instance cann deletePreferences(context: Context, name: string): Promise<void> Deletes a **Preferences** singleton instance, the persistence file and backup file, and corrupted files from the memory. -Once a preference persistence file is deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the execution result. +Once a **Preferences** persistence file is deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| **Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the execution result.| + | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.deletePreferences(this.context, 'mystore') - promise.then(() => { - console.info("Deleted data successfully.") - }).catch((err) => { - console.info("Failed to delete data, err: " + err) - }) - } - ``` +```ts +let promise = data_preferences.deletePreferences(this.context, 'mystore') +promise.then(() => { + console.info("Deleted preferences successfully.") +}).catch((err) => { + console.info("Failed to delete preferences, err: " + err) +}) +``` ## data_preferences.removePreferencesFromCache @@ -192,32 +146,27 @@ removePreferencesFromCache(context: Context, name: string, callback: AsyncCallba Removes a **Preferences** singleton instance from the memory. -When a **Preferences** singleton instance is removed, this instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result. +When a **Preferences** singleton instance is removed, this instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { - if (err) { - console.info("Failed to remove preferences from cache, err: " + err) - return - } - console.info("Removed preferences from cache successfully.") - }) - } - ``` +```ts +data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { + if (err) { + console.info("Failed to remove preferences from cache, err: " + err) + return + } + console.info("Removed preferences from cache successfully.") +}) +``` ## data_preferences.removePreferencesFromCache @@ -230,31 +179,26 @@ When a **Preferences** singleton instance is removed, this instance cannot be us **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -**Parameters** +Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| **Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the execution result.| + | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.removePreferencesFromCache(this.context, 'mystore') - promise.then(() => { - console.info("Removed preferences from cache successfully.") - }).catch((err) => { - console.info("Failed to remove preferences from cache, err: " + err) - }) - } - ``` +```ts +let promise = data_preferences.removePreferencesFromCache(this.context, 'mystore') +promise.then(() => { + console.info("Removed preferences from cache successfully.") +}).catch((err) => { + console.info("Failed to remove preferences from cache, err: " + err) +}) +``` ## Preferences @@ -275,29 +219,18 @@ Obtains the value of a key. If the value is null or a non-default value, the def | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data to obtain. It cannot be empty.| | defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.| - | callback | AsyncCallback<ValueType> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<ValueType> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, err: " + err) - return - } - preferences.get('startup', 'default', function(err, value) { - if (err) { - console.info("Get the value of startup failed, err: " + err) - return - } +```ts + preferences.get('startup', 'default', function(err, value) { + if (err) { + console.info("Failed to get the value of startup, err: " + err) + return + } console.info("The value of startup is " + value) - }) - }) - } - ``` +}) +``` ### get @@ -308,7 +241,7 @@ Obtains the value of a key. If the value is null or a non-default value, the def **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- **Parameters** +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data to obtain. It cannot be empty.| @@ -317,34 +250,24 @@ Obtains the value of a key. If the value is null or a non-default value, the def **Return value** | Type| Description| | -------- | -------- | - | Promise<ValueType> | Promise used to return the execution result.| + | Promise<ValueType> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseGet = preferences.get('startup', 'default') - promiseGet.then((value) => { - console.info("The value of startup is " + value) - }).catch((err) => { +```ts +let promise = preferences.get('startup', 'default') +promise.then((value) => { + console.info("The value of startup is " + value) +}).catch((err) => { console.info("Failed to get the value of startup, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - ``` +}) +``` ### put put(key: string, value: ValueType, callback: AsyncCallback<void>): void -Obtains a **Preferences** instance, writes data to the **Preferences** instance, and saves the data to the file using **flush()** or **flushSync()**. This API uses an asynchronous callback to return the execution result. +Puts a new value to this **Preferences** instance and its persistence file. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -353,36 +276,25 @@ Obtains a **Preferences** instance, writes data to the **Preferences** instance, | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data. It cannot be empty.| | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.| - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.put('startup', 'auto', function (err) { - if (err) { +```ts +preferences.put('startup', 'auto', function (err) { + if (err) { console.info("Failed to put the value of startup, err: " + err) - return - } - console.info("Put the value of startup successfully.") - }) - }) - } - ``` + return + } + console.info("Put the value of startup successfully.") +}) +``` ### put put(key: string, value: ValueType): Promise<void> -Obtains a **Preferences** instance, writes data to the **Preferences** instance, and saves the data to the file using **flush()** or **flushSync()**. This API uses a promise to return the execution result. +Puts a new value to this **Preferences** instance and its persistence file. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -395,34 +307,24 @@ Obtains a **Preferences** instance, writes data to the **Preferences** instance, **Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the execution result.| + | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promisePut = preferences.put('startup', 'auto') - promisePut.then(() => { - console.info("Put the value of startup successfully.") - }).catch((err) => { +```ts +let promise = preferences.put('startup', 'auto') +promise.then(() => { + console.info("Put the value of startup successfully.") +}).catch((err) => { console.info("Failed to put the value of startup, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - ``` +}) +``` ### has has(key: string, callback: AsyncCallback<boolean>): boolean -Checks whether the **Preferences** instance contains data with a given key. This API uses an asynchronous callback to return the result. +Checks whether this **Preferences** instance contains data with a given key. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -430,7 +332,7 @@ Checks whether the **Preferences** instance contains data with a given key. This | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data to check. It cannot be empty.| - | callback | AsyncCallback<boolean> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<boolean> | Yes| Callback used to return the result.| **Return value** | Type| Description| @@ -438,37 +340,26 @@ Checks whether the **Preferences** instance contains data with a given key. This | boolean | Returns **true** if the **Preferences** instance contains data with the specified key; returns **false** otherwise.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.has('startup', function (err, isExist) { - if (err) { - console.info("Failed to check the key of startup, err: " + err) - return - } - if (isExist) { - console.info("The key of startup is contained.") - } else { - console.info("The key of startup is not contained.") - } - }) - }) - } - ``` +```ts +preferences.has('startup', function (err, isExist) { + if (err) { + console.info("Failed to check the key of startup, err: " + err) + return + } + if (isExist) { + console.info("The key of startup is contained.") + } else { + console.info("The key of startup is not contained.") + } +}) +``` ### has has(key: string): Promise<boolean> -Checks whether the **Preferences** instance contains data with a given key. This API uses a promise to return the result. +Checks whether this **Preferences** instance contains data with a given key. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -480,38 +371,28 @@ Checks whether the **Preferences** instance contains data with a given key. This **Return value** | Type| Description| | -------- | -------- | - | Promise<boolean> | Promise used to return the execution result.| + | Promise<boolean> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseHas = preferences.has('startup') - promiseHas.then((isExist) => { - if (isExist) { - console.info("The key of startup is contained.") - } else { - console.info("The key of startup is not contained.") - } - }).catch((err) => { +```ts +let promise = preferences.has('startup') +promise.then((isExist) => { + if (isExist) { + console.info("The key of startup is contained.") + } else { + console.info("The key of startup is not contained.") + } +}).catch((err) => { console.info("Check the key of startup failed, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - ``` +}) +``` ### delete delete(key: string, callback: AsyncCallback<void>): void -Deletes the KV pair of the specified key from this **Preferences** instance. This API uses an asynchronous callback to return the result. +Deletes a KV pair of the specified key from this **Preferences** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -519,36 +400,25 @@ Deletes the KV pair of the specified key from this **Preferences** instance. Thi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the KV pair to delete. It cannot be empty.| - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.delete('startup', function (err) { - if (err) { - console.info("Failed to delete startup key, err: " + err) - return - } - console.info("Deleted startup key successfully.") - }) - }) - } - ``` +```ts +preferences.delete('startup', function (err) { + if (err) { + console.info("Failed to delete startup key, err: " + err) + return + } + console.info("Deleted startup key successfully.") +}) +``` ### delete delete(key: string): Promise<void> -Deletes the KV pair of the specified key from this **Preferences** instance. This API uses a promise to return the result. +Deletes a KV pair of the specified key from this **Preferences** instance. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -560,97 +430,66 @@ Deletes the KV pair of the specified key from this **Preferences** instance. Thi **Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the execution result.| + | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseDelete = preferences.delete('startup') - promiseDelete.then(() => { - console.info("Deleted startup key successfully.") - }).catch((err) => { - console.info("Failed to delete startup key, err: " + err) - }) - }).catch((err) => { - console.info("Failed to get the preferences, err: " + err) - }) - } - ``` +```ts +let promise = preferences.delete('startup') +promise.then(() => { + console.info("Deleted startup key successfully.") +}).catch((err) => { + console.info("Failed to delete startup key, err: " + err) +}) +``` ### flush flush(callback: AsyncCallback<void>): void -Saves the modification to this **Preferences** instance and synchronizes the modification to the preference persistence file. This API uses an asynchronous callback to return the result. +Saves the modification to this **Preferences** instance and synchronizes the modification to the **Preferences** persistence file. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data to file, err: " + err) - return - } - console.info("Flushed data to file successfully.") - }) - }) - } - ``` +```ts +preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed data to file successfully.") +}) +``` ### flush flush(): Promise<void> -Saves the modification to this **Preferences** instance and synchronizes the modification to the preference persistence file. This API uses a promise to return the result. +Saves the modification to this **Preferences** instance and synchronizes the modification to the **Preferences** persistence file. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the execution result.| + | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseFlush = preferences.flush() - promiseFlush.then(() => { - console.info("Flushed data to file successfully.") - }).catch((err) => { - console.info("Failed to flush data to file, err: " + err) - }) - }).catch((err) => { - console.info("Failed to get the preferences, err: " + err) - }) - } - ``` +```ts +let promise = preferences.flush() +promise.then(() => { + console.info("Flushed data to file successfully.") +}).catch((err) => { + console.info("Failed to flush data to file, err: " + err) +}) +``` ### clear @@ -661,32 +500,21 @@ Clears data of this **Preferences** instance. This API uses an asynchronous call **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -**Parameters** +Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.clear(function (err) { - if (err) { - console.info("Failed to clear data, err: " + err) - return - } - console.info("Cleared to file successfully.") - }) - }) - } - ``` +```ts +preferences.clear(function (err) { + if (err) { + console.info("Failed to clear data, err: " + err) + return + } + console.info("Cleared to file successfully.") +}) +``` ### clear @@ -700,27 +528,17 @@ Clears data of this **Preferences** instance. This API uses a promise to return **Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the execution result.| + | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseClear = preferences.clear() - promiseClear.then(() => { - console.info("Cleared to file successfully.") - }).catch((err) => { - console.info("Failed to clear data, err: " + err) - }) - }).catch((err) => { - console.info("Failed to get the preferences, err: " + err) - }) - } - ``` +```ts +let promise = preferences.clear() +promise.then(() => { + console.info("Cleared to file successfully.") +}).catch((err) => { + console.info("Failed to clear data, err: " + err) +}) +``` ### on('change') @@ -738,37 +556,30 @@ Subscribes to data changes. When the value of the subscribed key changes, a call | callback | Callback<{ key : string }> | Callback used to return data changes.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.on('change', observer) - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Failed to put the value of startup, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data to file, err: " + err) - return - } - console.info("Flushed data to file successfully.") // The observer will be called. - }) - }) - }) - } - ``` +```ts +var observer = function (key) { + console.info("The key of " + key + " changed.") +} + +... + +preferences.on('change', observer) +preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Failed to put the value of startup, err: " + err) + return + } + console.info("Put the value of startup successfully.") + + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed data to file successfully.") // The observer will be called. + }) +}) +``` ### off('change') @@ -786,37 +597,31 @@ Unsubscribes from data changes. | callback | Callback<{ key : string }> | Callback used to return data changes.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.on('change', observer) - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Failed to put the value of startup, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data to file, err: " + err) - return - } - console.info("Flushed to file successfully.") // observer will be called. - preferences.off('change', observer) - }) - }) - }) - } - ``` +```ts +var observer = function (key) { + console.info("The key of " + key + " changed.") +} + +... + +preferences.on('change', observer) +preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Failed to put the value of startup, err: " + err) + return + } + console.info("Put the value of startup successfully.") + + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed data to file successfully.") // The observer will be called. + preferences.off('change', observer) + }) +}) +``` ## ValueType diff --git a/en/application-dev/reference/apis/js-apis-data-rdb.md b/en/application-dev/reference/apis/js-apis-data-rdb.md index 5a688b89db49c1d008e82a263024b45c6032bc40..f1211dc922a699081aeab7a5b145771923d8f7fe 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -1,10 +1,8 @@ # Relational Database -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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 ```js @@ -31,11 +29,12 @@ Obtains a relational database (RDB) store. This API uses an asynchronous callbac ```js const STORE_CONFIG = { name: "RdbTest.db"} -const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE, null, function() { - console.info('create table done.') - }) + if (err) { + console.info("Failed to get RdbStore, err: " + err) + return + } + console.log("Got RdbStore successfully.") }) ``` ## data_rdb.getRdbStore @@ -63,17 +62,11 @@ Obtains an RDB store. This API uses a promise to return the result. You can set ```js const STORE_CONFIG = { name: "RdbTest.db" } -const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" -let promisegetRdb = data_rdb.getRdbStore(STORE_CONFIG, 1); -promisegetRdb.then(async (rdbStore) => { - let promiseExecSql = rdbStore.executeSql(SQL_CREATE_TABLE, null) - promiseExecSql.then(() => { - console.info('executeSql creat done.') - }).catch((err) => { - console.log("executeSql creat err.") - }) +let promise = data_rdb.getRdbStore(STORE_CONFIG, 1); +promise.then(async (rdbStore) => { + console.log("Got RdbStore successfully.") }).catch((err) => { - console.log("getRdbStore err.") + console.log("Failed to get RdbStore, err: " + err) }) ``` @@ -99,11 +92,12 @@ Obtains a relational database (RDB) store. This API uses an asynchronous callbac ```js const STORE_CONFIG = { name: "RdbTest.db"} -const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE, null, function() { - console.info('create table done.') - }) + if (err) { + console.info("Failed to get RdbStore, err: " + err) + return + } + console.log("Got RdbStore successfully.") }) ``` @@ -133,17 +127,11 @@ Obtains an RDB store. This API uses a promise to return the result. You can set ```js const STORE_CONFIG = { name: "RdbTest.db" } -const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" -let promisegetRdb = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1); -promisegetRdb.then(async (rdbStore) => { - let promiseExecSql = rdbStore.executeSql(SQL_CREATE_TABLE, null) - promiseExecSql.then(() => { - console.info('executeSql creat done.') - }).catch((err) => { - console.log("executeSql creat err.") - }) +let promise = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1); +promise.then(async (rdbStore) => { + console.log("Got RdbStore successfully.") }).catch((err) => { - console.log("getRdbStore err.") + console.log("Failed to get RdbStore, err: " + err) }) ``` @@ -162,11 +150,15 @@ Deletes an RDB store. This API uses a callback to return the result. | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ```js - data_rdb.deleteRdbStore("RdbTest.db", function (err, rdbStore) { - console.info('delete store done.') - }) - ``` +```js +data_rdb.deleteRdbStore("RdbTest.db", function (err, rdbStore) { + if (err) { + console.info("Failed to delete RdbStore, err: " + err) + return + } + console.log("Deleted RdbStore successfully.") +}) +``` ## data_rdb.deleteRdbStore deleteRdbStore(name: string): Promise<void> @@ -186,14 +178,14 @@ Deletes an RDB store. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Example** - ```js - let promisedeleteRdb = data_rdb.deleteRdbStore("RdbTest.db") - promisedeleteRdb.then(()=>{ - console.info('delete store done.') - }).catch((err) => { - console.log("deleteRdbStore err.") - }) - ``` +```js +let promise = data_rdb.deleteRdbStore("RdbTest.db") +promise.then(()=>{ + console.log("Deleted RdbStore successfully.") +}).catch((err) => { + console.info("Failed to delete RdbStore, err: " + err) +}) +``` ## data_rdb.deleteRdbStore8+ @@ -211,11 +203,15 @@ Deletes an RDB store. This API uses a callback to return the result. | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ```js - data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { - console.info('delete store done.') - }) - ``` +```js +data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { + if (err) { + console.info("Failed to delete RdbStore, err: " + err) + return + } + console.log("Deleted RdbStore successfully.") +}) +``` ## data_rdb.deleteRdbStore8+ @@ -237,14 +233,14 @@ Deletes an RDB store. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Example** - ```js - let promisedeleteRdb = data_rdb.deleteRdbStore("RdbTest.db") - promisedeleteRdb.then(()=>{ - console.info('delete store done.') - }).catch((err) => { - console.log("deleteRdbStore err.") - }) - ``` +```js +let promise = data_rdb.deleteRdbStore("RdbTest.db") +promise.then(()=>{ + console.log("Deleted RdbStore successfully.") +}).catch((err) => { + console.info("Failed to delete RdbStore, err: " + err) +}) +``` ## RdbPredicates @@ -267,9 +263,9 @@ A constructor used to create an **RdbPredicates** object. | name | string | Yes| Database table name.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +``` ### inDevices8+ @@ -291,10 +287,10 @@ Specifies a remote device on the network during distributed database synchroniza | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.inDevices(['12345678abcde']) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.inDevices(['12345678abcde']) +``` ### inAllDevices8+ @@ -311,10 +307,10 @@ Connects to all remote devices on the network during distributed database synchr | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.inAllDevices() - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.inAllDevices() +``` ### equalTo @@ -337,10 +333,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "lisi") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "lisi") +``` ### notEqualTo @@ -364,10 +360,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.notEqualTo("NAME", "lisi") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.notEqualTo("NAME", "lisi") +``` ### beginWrap @@ -385,15 +381,15 @@ Adds a left parenthesis to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a left parenthesis.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "lisi") - .beginWrap() - .equalTo("AGE", 18) - .or() - .equalTo("SALARY", 200.5) - .endWrap() - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "lisi") + .beginWrap() + .equalTo("AGE", 18) + .or() + .equalTo("SALARY", 200.5) + .endWrap() +``` ### endWrap @@ -411,15 +407,15 @@ Adds a right parenthesis to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a right parenthesis.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "lisi") - .beginWrap() - .equalTo("AGE", 18) - .or() - .equalTo("SALARY", 200.5) - .endWrap() - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "lisi") + .beginWrap() + .equalTo("AGE", 18) + .or() + .equalTo("SALARY", 200.5) + .endWrap() +``` ### or @@ -437,12 +433,12 @@ Adds the OR condition to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the OR condition.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Lisa") - .or() - .equalTo("NAME", "Rose") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") + .or() + .equalTo("NAME", "Rose") +``` ### and @@ -460,12 +456,12 @@ Adds the AND condition to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the AND condition.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Lisa") - .and() - .equalTo("SALARY", 200.5) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") + .and() + .equalTo("SALARY", 200.5) +``` ### contains @@ -488,10 +484,10 @@ Sets the **RdbPredicates** to match a string containing the specified value. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.contains("NAME", "os") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.contains("NAME", "os") +``` ### beginsWith @@ -515,10 +511,10 @@ Sets the **RdbPredicates** to match a string that starts with the specified valu | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.beginsWith("NAME", "os") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.beginsWith("NAME", "os") +``` ### endsWith @@ -542,10 +538,10 @@ Sets the **RdbPredicates** to match a string that ends with the specified value. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.endsWith("NAME", "se") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.endsWith("NAME", "se") +``` ### isNull @@ -568,10 +564,10 @@ Sets the **RdbPredicates** to match the field whose value is null. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| - Example - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.isNull("NAME") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.isNull("NAME") +``` ### isNotNull @@ -594,10 +590,10 @@ Sets the **RdbPredicates** to match the field whose value is not null. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.isNotNull("NAME") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.isNotNull("NAME") +``` ### like @@ -621,10 +617,10 @@ Sets the **RdbPredicates** to match a string that is similar to the specified va | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.like("NAME", "%os%") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.like("NAME", "%os%") +``` ### glob @@ -648,10 +644,10 @@ Sets the **RdbPredicates** to match the specified string. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.glob("NAME", "?h*g") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.glob("NAME", "?h*g") +``` ### between @@ -676,10 +672,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.between("AGE", 10, 50) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.between("AGE", 10, 50) +``` ### notBetween @@ -704,10 +700,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.notBetween("AGE", 10, 50) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.notBetween("AGE", 10, 50) +``` ### greaterThan @@ -730,10 +726,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.greaterThan("AGE", 18) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.greaterThan("AGE", 18) +``` ### lessThan @@ -757,10 +753,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.lessThan("AGE", 20) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.lessThan("AGE", 20) +``` ### greaterThanOrEqualTo @@ -785,10 +781,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.greaterThanOrEqualTo("AGE", 18) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.greaterThanOrEqualTo("AGE", 18) +``` ### lessThanOrEqualTo @@ -813,10 +809,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.lessThanOrEqualTo("AGE", 20) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.lessThanOrEqualTo("AGE", 20) +``` ### orderByAsc @@ -840,10 +836,10 @@ Sets the **RdbPredicates** to match the column with values sorted in ascending o | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.orderByAsc("NAME") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.orderByAsc("NAME") +``` ### orderByDesc @@ -867,10 +863,10 @@ Sets the **RdbPredicates** to match the column with values sorted in descending | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.orderByDesc("AGE") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.orderByDesc("AGE") +``` ### distinct @@ -888,17 +884,17 @@ Sets the **RdbPredicates** to filter out duplicate records. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that can filter out duplicate records.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Rose").distinct("NAME") - let promisequery = rdbStore.query(predicates, ["NAME"]) - promisequery.then((resultSet) => { - console.log("resultSet column names:" + resultSet.columnNames) - console.log("resultSet column count:" + resultSet.columnCount) - }).catch((err) => { - console.log("query err.") - }) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Rose").distinct("NAME") +let promise = rdbStore.query(predicates, ["NAME"]) +promise.then((resultSet) => { + console.log("resultSet column names:" + resultSet.columnNames) + console.log("resultSet column count:" + resultSet.columnCount) +}).catch((err) => { + console.log("query err.") +}) +``` ### limitAs @@ -921,10 +917,10 @@ Sets the **RdbPredicates** to specify the maximum number of records. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the maximum number of records.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Rose").limitAs(3) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Rose").limitAs(3) +``` ### offsetAs @@ -947,10 +943,10 @@ Sets the **RdbPredicates** to specify the start position of the returned result. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the start position of the returned result.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Rose").offsetAs(3) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Rose").offsetAs(3) +``` ### groupBy @@ -973,10 +969,10 @@ Sets the **RdbPredicates** to group rows that have the same value into summary r | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that groups rows with the same value.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.groupBy(["AGE", "NAME"]) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.groupBy(["AGE", "NAME"]) +``` ### indexedBy @@ -999,10 +995,10 @@ Sets the **RdbPredicates** object to specify the index column. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the index column.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.indexedBy("SALARY_INDEX") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.indexedBy("SALARY_INDEX") +``` ### in @@ -1027,10 +1023,10 @@ Sets the **RdbPredicates** to match the field with data type **Array<ValueTy | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.in("AGE", [18, 20]) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.in("AGE", [18, 20]) +``` ### notIn @@ -1055,10 +1051,10 @@ Sets the **RdbPredicates** to match the field with data type **Array<ValueTy | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.notIn("NAME", ["Lisa", "Rose"]) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.notIn("NAME", ["Lisa", "Rose"]) +``` ## RdbStore @@ -1082,17 +1078,21 @@ Inserts a row of data into a table. This API uses a callback to return the resul | callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| **Example** - ```js - const valueBucket = { - "NAME": "Lisa", - "AGE": 18, - "SALARY": 100.5, - "CODES": new Uint8Array([1, 2, 3, 4, 5]), - } - rdbStore.insert("EMPLOYEE", valueBucket, function (err, ret) { - console.log("insert first done: " + ret) - }) - ``` +```js +const valueBucket = { + "NAME": "Lisa", + "AGE": 18, + "SALARY": 100.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +} +rdbStore.insert("EMPLOYEE", valueBucket, function (err, ret) { + if (err) { + console.info("Failed to insert data, err: " + err) + return + } + console.log("Insert first done: " + ret) +}) +``` ### insert @@ -1115,20 +1115,20 @@ Inserts a row of data into a table. This API uses a promise to return the result | Promise<number> | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| **Example** - ```js - const valueBucket = { - "NAME": "Lisa", - "AGE": 18, - "SALARY": 100.5, - "CODES": new Uint8Array([1, 2, 3, 4, 5]), - } - let promiseinsert = rdbStore.insert("EMPLOYEE", valueBucket) - promiseinsert.then(async (ret) => { - console.log("insert first done: " + ret) - }).catch((err) => { - console.log("insert err.") - }) - ``` +```js +const valueBucket = { + "NAME": "Lisa", + "AGE": 18, + "SALARY": 100.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +} +let promise = rdbStore.insert("EMPLOYEE", valueBucket) +promise.then(async (ret) => { + console.log("Insert first done: " + ret) +}).catch((err) => { + console.log("Failed to insert data, err: " + err) +}) +``` ### update @@ -1147,18 +1147,23 @@ Updates data in the database based on the specified RdbPredicates object. This A | callback | AsyncCallback<number> | Yes| Callback used to return the number of rows updated.| **Example** - ```js - const valueBucket = { - "NAME": "Rose", - "AGE": 22, - "SALARY": 200.5, - "CODES": new Uint8Array([1, 2, 3, 4, 5]), - } - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Lisa") - rdbStore.update(valueBucket, predicates, function (err, ret) { - console.log("updated row count: " + ret)}) - ``` +```js +const valueBucket = { + "NAME": "Rose", + "AGE": 22, + "SALARY": 200.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +} +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") +rdbStore.update(valueBucket, predicates, function (err, ret) { + if (err) { + console.info("Failed to update data, err: " + err) + return + } + console.log("Updated row count: " + ret) +}) +``` ### update @@ -1181,22 +1186,22 @@ Updates data in the database based on the specified RdbPredicates object. This A | Promise<number> | Promise used to return the number of rows updated.| **Example** - ```js - const valueBucket = { - "NAME": "Rose", - "AGE": 22, - "SALARY": 200.5, - "CODES": new Uint8Array([1, 2, 3, 4, 5]), - } - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Lisa") - let promiseupdate = rdbStore.update(valueBucket, predicates) - promiseupdate.then(async (ret) => { - console.log("updated row count: " + ret) - }).catch((err) => { - console.log("update err.") - }) - ``` +```js +const valueBucket = { + "NAME": "Rose", + "AGE": 22, + "SALARY": 200.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +} +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") +let promise = rdbStore.update(valueBucket, predicates) +promise.then(async (ret) => { + console.log("Updated row count: " + ret) +}).catch((err) => { + console.info("Failed to update data, err: " + err) +}) +``` ### delete @@ -1215,13 +1220,17 @@ Deletes data from the database based on the specified RdbPredicates object. This | callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Lisa") - rdbStore.delete(predicates, function (err, rows) { - console.log("delete rows: " + rows) - }) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") +rdbStore.delete(predicates, function (err, rows) { + if (err) { + console.info("Failed to delete data, err: " + err) + return + } + console.log("Delete rows: " + rows) +}) +``` ### delete @@ -1243,16 +1252,16 @@ Deletes data from the database based on the specified RdbPredicates object. This | Promise<number> | Promise used to return the number of rows updated.| **Example** - ```js - let predicatesdelete = new data_rdb.RdbPredicates("EMPLOYEE") - predicatesdelete.equalTo("NAME", "Lisa") - let promisedelete = rdbStore.delete(predicates) - promisedelete.then((rows) => { - console.log("delete rows: " + rows) - }).catch((err) => { - console.log("delete err.") - }) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") +let promise = rdbStore.delete(predicates) +promise.then((rows) => { + console.log("Delete rows: " + rows) +}).catch((err) => { + console.info("Failed to delete data, err: " + err) +}) +``` ### query @@ -1271,14 +1280,18 @@ Queries data in the database based on specified conditions. This API uses a call | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Rose") - rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { - console.log("resultSet column names:" + resultSet.columnNames) - console.log("resultSet column count:" + resultSet.columnCount) - }) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Rose") +rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { + if (err) { + console.info("Query failed, err: " + err) + return + } + console.log("resultSet column names:" + resultSet.columnNames) + console.log("resultSet column count:" + resultSet.columnCount) +}) +``` ### query @@ -1304,12 +1317,12 @@ Queries data in the database based on specified conditions. This API uses a prom ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose") - let promisequery = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) - promisequery.then((resultSet) => { + let promise = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) + promise.then((resultSet) => { console.log("resultSet column names:" + resultSet.columnNames) console.log("resultSet column count:" + resultSet.columnCount) }).catch((err) => { - console.log("query err.") + console.info("Query failed, err: " + err) }) ``` @@ -1330,12 +1343,16 @@ Queries data in the RDB store using the specified SQL statement. This API uses a | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** - ```js - rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) { - console.log("resultSet column names:" + resultSet.columnNames) - console.log("resultSet column count:" + resultSet.columnCount) - }) - ``` +```js +rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) { + if (err) { + console.info("Query failed, err: " + err) + return + } + console.log("resultSet column names:" + resultSet.columnNames) + console.log("resultSet column count:" + resultSet.columnCount) +}) +``` ### querySql8+ @@ -1358,15 +1375,15 @@ Queries data in the RDB store using the specified SQL statement. This API uses a | Promise<[ResultSet](../apis/js-apis-data-resultset.md)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** - ```js - let promisequerySql = rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo']) - promisequerySql.then((resultSet) => { - console.log("resultSet column names:" + resultSet.columnNames) - console.log("resultSet column count:" + resultSet.columnCount) - }).catch((err) => { - console.log("querySql err.") - }) - ``` +```js +let promise = rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo']) +promise.then((resultSet) => { + console.log("resultSet column names:" + resultSet.columnNames) + console.log("resultSet column count:" + resultSet.columnCount) +}).catch((err) => { + console.info("Query failed, err: " + err) +}) +``` ### executeSql @@ -1385,11 +1402,16 @@ Runs the SQL statement that contains the specified parameters but does not retur | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ```js - rdbStore.executeSql("DELETE FROM EMPLOYEE", null, function () { - console.info('delete done.') - }) - ``` +```js +const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" +rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) { + if (err) { + console.info("executeSql failed, err: " + err) + return + } + console.info('create table done.') +}) +``` ### executeSql @@ -1412,14 +1434,15 @@ Runs the SQL statement that contains the specified parameters but does not retur | Promise<void> | Promise used to return the result.| **Example** - ```js - let promiseexecuteSql = rdbStore.executeSql("DELETE FROM EMPLOYEE") - promiseexecuteSql.then(() => { - console.info('delete done.') - }).catch((err) => { - console.log("executeSql err.") - }) - ``` +```js +const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" +let promise = rdbStore.executeSql(SQL_CREATE_TABLE) +promise.then(() => { + console.info('create table done.') +}).catch((err) => { + console.info("ExecuteSql failed, err: " + err) +}) +``` ### beginTransaction8+ @@ -1431,17 +1454,21 @@ Starts the transaction before executing an SQL statement. **Example** ```js - rdbStore.beginTransaction() - const valueBucket = { - "name": "lisi", - "age": 18, - "salary": 100.5, - "blobType": new Uint8Array([1, 2, 3]), - } - rdbStore.insert("test", valueBucket, function (err, ret) { - console.log("insert done: " + ret) - }) - rdbStore.commit() +rdbStore.beginTransaction() +const valueBucket = { + "name": "lisi", + "age": 18, + "salary": 100.5, + "blobType": new Uint8Array([1, 2, 3]), +} +rdbStore.insert("test", valueBucket, function (err, ret) { + if (err) { + console.info("Failed to insert data, err: " + err) + return + } + console.log("Inserted data successfully: " + ret) +}) +rdbStore.commit() ``` @@ -1455,18 +1482,22 @@ Commits the executed SQL statements. **Example** ```js - rdbStore.beginTransaction() - const valueBucket = { - "name": "lisi", - "age": 18, - "salary": 100.5, - "blobType": new Uint8Array([1, 2, 3]), - } - - rdbStore.insert("test", valueBucket, function (err, ret) { - console.log("insert done: " + ret) - }) - rdbStore.commit() +rdbStore.beginTransaction() +const valueBucket = { + "name": "lisi", + "age": 18, + "salary": 100.5, + "blobType": new Uint8Array([1, 2, 3]), +} + +rdbStore.insert("test", valueBucket, function (err, ret) { + if (err) { + console.info("Failed to insert data, err: " + err) + return + } + console.log("Inserted data successfully: " + ret) +}) +rdbStore.commit() ``` @@ -1480,22 +1511,26 @@ Rolls back the SQL statements that have been executed. **Example** ```js - try { - rdbStore.beginTransaction() - const valueBucket = { - "id": 1, - "name": "lisi", - "age": 18, - "salary": 100.5, - "blobType": new Uint8Array([1, 2, 3]), - } - rdbStore.insert("test", valueBucket, function (err, ret) { - console.log("insert done: " + ret) - }) - rdbStore.commit() - } catch (e) { - rdbStore.rollBack() - } +try { + rdbStore.beginTransaction() + const valueBucket = { + "id": 1, + "name": "lisi", + "age": 18, + "salary": 100.5, + "blobType": new Uint8Array([1, 2, 3]), + } + rdbStore.insert("test", valueBucket, function (err, ret) { + if (err) { + console.info("Failed to insert data, err: " + err) + return + } + console.log("Inserted data successfully: " + ret) + }) + rdbStore.commit() +} catch (e) { + rdbStore.rollBack() +} ``` @@ -1514,14 +1549,14 @@ Sets a list of distributed tables. This API uses a callback to return the result | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ```js - rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { - if (err) { - console.info('setDistributedTables failed.') - return - } - console.info('setDistributedTables success.') - }) +```js +rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { + if (err) { + console.info('setDistributedTables failed, err: ' + err) + return + } + console.info('setDistributedTables successful.') +}) ``` @@ -1544,14 +1579,14 @@ Sets a list of distributed tables. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Example** - ```js - let promiseset = rdbStore.setDistributedTables(["EMPLOYEE"]) - promiseset.then(() => { - console.info("setDistributedTables success.") - }).catch((err) => { - console.info("setDistributedTables failed.") - }) - ``` +```js +let promise = rdbStore.setDistributedTables(["EMPLOYEE"]) +promise.then(() => { + console.info("setDistributedTables successful.") +}).catch((err) => { + console.info("setDistributedTables failed, err: " + err) +}) +``` ### obtainDistributedTableName8+ @@ -1569,15 +1604,15 @@ Obtains the distributed table name for a remote device based on the local table | callback | AsyncCallback<string> | Yes| Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| **Example** - ```js - rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { - if (err) { - console.info('obtainDistributedTableName failed.') - return - } - console.info('obtainDistributedTableName success, tableName=.' + tableName) - }) - ``` +```js +rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { + if (err) { + console.info('obtainDistributedTableName failed, err: ' + err) + return + } + console.info('obtainDistributedTableName successful, tableName=.' + tableName) +}) +``` ### obtainDistributedTableName8+ @@ -1600,14 +1635,14 @@ Obtains the distributed table name for a remote device based on the local table | Promise<string> | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| **Example** - ```js - let promiseDistr = rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE") - promiseDistr.then((tableName) => { - console.info('obtainDistributedTableName success, tableName=' + tableName) - }).catch((err) => { - console.info('obtainDistributedTableName failed.') - }) - ``` +```js +let promise = rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE") +promise.then((tableName) => { + console.info('obtainDistributedTableName successful, tableName=' + tableName) +}).catch((err) => { + console.info('obtainDistributedTableName failed, err: ' + err) +}) +``` ### sync8+ @@ -1625,20 +1660,20 @@ Synchronizes data between devices. This API uses a callback to return the result | callback | AsyncCallback<Array<[string, number]>> | Yes| Callback invoked to send the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | **Example** - ```js - let predicate = new rdb.RdbPredicates('EMPLOYEE') - predicate.inDevices(['12345678abcde']) - rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicate, function (err, result) { - if (err) { - console.log('sync failed') - return - } - console.log('sync done.') - for (let i = 0; i < result.length; i++) { - console.log('device=' + result[i][0] + ' status=' + result[i][1]) - } - }) - ``` +```js +let predicates = new rdb.RdbPredicates('EMPLOYEE') +predicates.inDevices(['12345678abcde']) +rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) { + if (err) { + console.log('sync failed, err: ' + err) + return + } + console.log('sync done.') + for (let i = 0; i < result.length; i++) { + console.log('device=' + result[i][0] + ' status=' + result[i][1]) + } +}) +``` ### sync8+ @@ -1662,19 +1697,19 @@ Synchronizes data between devices. This API uses a promise to return the result. | Promise<Array<[string, number]>> | Promise used to return the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | **Example** - ```js - let predicatesync = new data_rdb.RdbPredicates('EMPLOYEE') - predicatesync.inDevices(['12345678abcde']) - let promisesync = rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicatesync) - promisesync.then((result) =>{ - console.log('sync done.') - for (let i = 0; i < result.length; i++) { - console.log('device=' + result[i][0] + ' status=' + result[i][1]) - } - }).catch((err) => { - console.log('sync failed') - }) - ``` +```js +let predicates = new data_rdb.RdbPredicates('EMPLOYEE') +predicates.inDevices(['12345678abcde']) +let promise = rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates) +promise.then((result) =>{ + console.log('sync done.') + for (let i = 0; i < result.length; i++) { + console.log('device=' + result[i][0] + ' status=' + result[i][1]) + } +}).catch((err) => { + console.log('sync failed') +}) +``` ### on('dataChange')8+ @@ -1693,18 +1728,18 @@ Registers an observer for this RDB store. When the data in the RDB store changes | observer | Callback<Array<string>> | Yes| Observer that listens for the data changes in the RDB store.| **Example** - ```js - function storeObserver(devices) { - for (let i = 0; i < devices.length; i++) { - console.log('device=' + devices[i] + ' data changed') - } - } - try { - rdbStore.on('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver) - } catch (err) { - console.log('register observer failed') - } - ``` +```js +function storeObserver(devices) { + for (let i = 0; i < devices.length; i++) { + console.log('device=' + devices[i] + ' data changed') + } +} +try { + rdbStore.on('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver) +} catch (err) { + console.log('Failed to register observer') +} +``` ### off('dataChange')8+ @@ -1723,19 +1758,18 @@ Deletes the specified observer of the RDB store. This API uses a callback to ret | observer | Callback<Array<string>> | Yes| Data change observer registered.| **Example** - - ```js - function storeObserver(devices) { - for (let i = 0; i < devices.length; i++) { - console.log('device=' + devices[i] + ' data changed') - } - } - try { - rdbStore.off('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver) - } catch (err) { - console.log('unregister observer failed') - } - ``` +```js +function storeObserver(devices) { + for (let i = 0; i < devices.length; i++) { + console.log('device=' + devices[i] + ' data changed') + } +} +try { + rdbStore.off('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver) +} catch (err) { + console.log('Failed to unregister observer') +} +``` ## StoreConfig diff --git a/en/application-dev/reference/apis/js-apis-data-resultset.md b/en/application-dev/reference/apis/js-apis-data-resultset.md index 3dca6cfcb0e84fdd90f9ce7b0cb6c79432d95eda..613e793255ded14a1ae050bdf4504e402b52b941 100644 --- a/en/application-dev/reference/apis/js-apis-data-resultset.md +++ b/en/application-dev/reference/apis/js-apis-data-resultset.md @@ -1,6 +1,6 @@ # Result Set -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. diff --git a/en/application-dev/reference/apis/js-apis-data-storage.md b/en/application-dev/reference/apis/js-apis-data-storage.md index 844b24576aa7a48f0b26207aa7886c7fb668e299..63ae9d95bc7da1a827030de4e644d44d68c7235c 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -3,7 +3,7 @@ Lightweight storage provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value (KV) pairs. Keys are of the string type, and values can be of the number, string, or Boolean type. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. > @@ -30,7 +30,7 @@ import dataStorage from '@ohos.data.storage'; getStorageSync(path: string): Storage -Reads a file and loads the data to the **Storage** instance in synchronous mode. +Reads the specified file and load its data to the **Storage** instance for data operations. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -67,7 +67,7 @@ Reads a file and loads the data to the **Storage** instance in synchronous mode. getStorage(path: string, callback: AsyncCallback<Storage>): void -Reads a file and loads the data to the **Storage** instance. This API uses an asynchronous callback to return the execution result. +Reads the specified file and loads its data to the **Storage** instance for data operations. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -105,7 +105,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses an as getStorage(path: string): Promise<Storage> -Reads a file and loads the data to the **Storage** instance. This API uses a promise to return the execution result. +Reads the specified file and loads its data to the **Storage** instance for data operations. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -146,7 +146,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses a pro deleteStorageSync(path: string): void -Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a synchronous mode. +Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -165,7 +165,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete deleteStorage(path: string, callback: AsyncCallback<void>): void -Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result. +Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -191,7 +191,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete deleteStorage(path: string): Promise<void> -Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the execution result. +Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -222,8 +222,6 @@ removeStorageFromCacheSync(path: string): void Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** @@ -241,9 +239,7 @@ This API uses a synchronous mode. removeStorageFromCache(path: string, callback: AsyncCallback<void>): void -Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. - -This API uses an asynchronous callback to return the result. +Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -269,9 +265,7 @@ This API uses an asynchronous callback to return the result. removeStorageFromCache(path: string): Promise<void> -Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. - -This API uses a promise to return the result. +Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -307,8 +301,6 @@ getSync(key: string, defValue: ValueType): ValueType Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** @@ -333,9 +325,7 @@ This API uses a synchronous mode. get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void -Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. - -This API uses an asynchronous callback to return the result. +Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -362,9 +352,7 @@ This API uses an asynchronous callback to return the result. get(key: string, defValue: ValueType): Promise<ValueType> -Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. - -This API uses a promise to return the result. +Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -397,8 +385,6 @@ putSync(key: string, value: ValueType): void Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** @@ -417,9 +403,7 @@ This API uses a synchronous mode. put(key: string, value: ValueType, callback: AsyncCallback<void>): void -Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. - -This API uses an asynchronous callback to return the result. +Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -446,9 +430,7 @@ This API uses an asynchronous callback to return the result. put(key: string, value: ValueType): Promise<void> -Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. - -This API uses a promise to return the result. +Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -480,8 +462,6 @@ hasSync(key: string): boolean Checks whether the storage object contains data with a given key. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** @@ -507,9 +487,7 @@ This API uses a synchronous mode. has(key: string, callback: AsyncCallback<boolean>): boolean -Checks whether the storage object contains data with a given key. - -This API uses an asynchronous callback to return the result. +Checks whether the storage object contains data with a given key. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -542,9 +520,7 @@ This API uses an asynchronous callback to return the result. has(key: string): Promise<boolean> -Checks whether the storage object contains data with a given key. - -This API uses a promise to return the result. +Checks whether the storage object contains data with a given key. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -577,8 +553,6 @@ deleteSync(key: string): void Deletes data with the specified key from this storage object. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** @@ -592,13 +566,11 @@ This API uses a synchronous mode. ``` -### deletej +### delete delete(key: string, callback: AsyncCallback<void>): void -Deletes data with the specified key from this storage object. - -This API uses an asynchronous callback to return the result. +Deletes data with the specified key from this storage object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -624,9 +596,7 @@ This API uses an asynchronous callback to return the result. delete(key: string): Promise<void> -Deletes data with the specified key from this storage object. - -This API uses a promise to return the result. +Deletes data with the specified key from this storage object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -657,8 +627,6 @@ flushSync(): void Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Example** @@ -671,9 +639,7 @@ This API uses a synchronous mode. flush(callback: AsyncCallback<void>): void -Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. - -This API uses an asynchronous callback to return the result. +Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -698,9 +664,7 @@ This API uses an asynchronous callback to return the result. flush(): Promise<void> -Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. - -This API uses a promise to return the result. +Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -726,8 +690,6 @@ clearSync(): void Clears this **Storage** object. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Example** @@ -740,9 +702,7 @@ This API uses a synchronous mode. clear(callback: AsyncCallback<void>): void -Clears this **Storage** object. - -This API uses an asynchronous callback to return the result. +Clears this **Storage** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -767,9 +727,7 @@ This API uses an asynchronous callback to return the result. clear(): Promise<void> -Clears this **Storage** object. - -This API uses a promise to return the result. +Clears this **Storage** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core diff --git a/en/application-dev/reference/apis/js-apis-display.md b/en/application-dev/reference/apis/js-apis-display.md index 72dfe4beb9d6151dfab5acf8636711b1437e7c3d..22ea52f17d7b5996d536c8dc223ada7ee9ae1fa2 100644 --- a/en/application-dev/reference/apis/js-apis-display.md +++ b/en/application-dev/reference/apis/js-apis-display.md @@ -1,6 +1,6 @@ # Display -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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 @@ -56,7 +56,7 @@ getDefaultDisplay(callback: AsyncCallback<Display>): void Obtains the default display object. -**System capabilities**: SystemCapability.WindowManager.WindowManager.Core +**System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** | Name| Type| Mandatory| Description| @@ -82,7 +82,7 @@ getDefaultDisplay(): Promise<Display> Obtains the default display object. -**System capabilities**: SystemCapability.WindowManager.WindowManager.Core +**System capability**: SystemCapability.WindowManager.WindowManager.Core **Return value** @@ -107,7 +107,7 @@ getAllDisplay(callback: AsyncCallback<Array<Display>>): void Obtains all the display objects. -**System capabilities**: SystemCapability.WindowManager.WindowManager.Core +**System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** @@ -133,7 +133,7 @@ getAllDisplay(): Promise<Array<Display>> Obtains all the display objects. -**System capabilities**: SystemCapability.WindowManager.WindowManager.Core +**System capability**: SystemCapability.WindowManager.WindowManager.Core **Return value** @@ -158,7 +158,7 @@ on(type: 'add'|'remove'|'change', callback: Callback<number>): void Enables listening. -**System capabilities**: SystemCapability.WindowManager.WindowManager.Core +**System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** | Name| Type| Mandatory| Description| @@ -182,7 +182,7 @@ off(type: 'add'|'remove'|'change', callback?: Callback<number>): void Disables listening. -**System capabilities**: SystemCapability.WindowManager.WindowManager.Core +**System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** | Name| Type| Mandatory| Description| diff --git a/en/application-dev/reference/apis/js-apis-distributed-account.md b/en/application-dev/reference/apis/js-apis-distributed-account.md index 73f6216d255c4629399dfbf9510ab59b176f0273..8612aad1008deb0883598892c8fdbc6e54cec571 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-account.md +++ b/en/application-dev/reference/apis/js-apis-distributed-account.md @@ -1,6 +1,6 @@ # Distributed Account Management -> ![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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -40,7 +40,7 @@ Provides methods for querying and updating the login state of a distributed acco queryOsAccountDistributedInfo(callback: AsyncCallback<DistributedInfo>): void -Obtains distributed account information. This method uses an asynchronous callback to return the result. +Obtains distributed account information. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications) @@ -63,7 +63,7 @@ Obtains distributed account information. This method uses an asynchronous callba queryOsAccountDistributedInfo(): Promise<DistributedInfo> -Obtains distributed account information. This method uses a promise to return the result asynchronously. +Obtains distributed account information. This API uses a promise to return the result asynchronously. **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications) @@ -87,7 +87,7 @@ Obtains distributed account information. This method uses a promise to return th updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback<void>): void -Updates distributed account information. This method uses an asynchronous callback to return the result. +Updates distributed account information. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only to system applications) @@ -110,7 +110,7 @@ Updates distributed account information. This method uses an asynchronous callba updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void> -Updates distributed account information. This method uses a promise to return the result asynchronously. +Updates distributed account information. This API uses a promise to return the result asynchronously. **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS (available only to system applications) @@ -141,9 +141,9 @@ Updates distributed account information. This method uses a promise to return th Defines distributed OS account information. -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| name | string | Yes| Name of a distributed account. It must be a non-null string.| -| id | string | Yes| UID of a distributed account. It must be a non-null string.| -| event | string | Yes| Login state of a distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:
- Ohos.account.event.LOGIN
- Ohos.account.event.LOGOUT
- Ohos.account.event.TOKEN_INVALID
- Ohos.account.event.LOGOFF | -| scalableData | object | No| Extended information about a distributed account. Customized information is passed in key-value pairs.
Note: This parameter is reserved and not used in query and update methods.| +| name | string | Yes| Name of a distributed account. It must be a non-null string. | +| id | string | Yes | UID of a distributed account. It must be a non-null string. | +| event | string | Yes | Login state of a distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:
- Ohos.account.event.LOGIN
- Ohos.account.event.LOGOUT
- Ohos.account.event.TOKEN_INVALID
- Ohos.account.event.LOGOFF | +| scalableData | object | No| Extended information about a distributed account. Customized information is passed in key-value pairs.
Note: This parameter is reserved and not used in query and update methods.| \ No newline at end of file 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 8f5b800d57488426664e514675c1af28864e962f..6bbe4a0111f7fa6d409457e705af60cf6d0376c7 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-data.md +++ b/en/application-dev/reference/apis/js-apis-distributed-data.md @@ -2,7 +2,7 @@ Distributed data management provides collaboration between databases of different devices for applications. The APIs provided by distributed data management can be used to save data to the distributed database and perform operations such as adding, deleting, modifying, and querying data in the distributed database. ->![](../../public_sys-resources/icon-note.gif) **NOTE**
+>**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. @@ -2922,6 +2922,7 @@ These value types can be used only by internal applications. | BOOLEAN |4 |Boolean. | | DOUBLE |5 |Double (double-precision floating point). | + ## SingleKVStore Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use [getKVStore](#getkvstore) to obtain a **SingleKVStore** object. @@ -3447,7 +3448,7 @@ Closes the **KvStoreResultSet** object obtained by **getResultSet**. This API us | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. | -| callback |AsyncCallback<void> | Yes |Callback used to return the execution result. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-document.md b/en/application-dev/reference/apis/js-apis-document.md index 0f2de0b217af39ab8b7506db1c92cee141c3bde3..7895868cf0fa4e61104b211cda4a33728c943b06 100644 --- a/en/application-dev/reference/apis/js-apis-document.md +++ b/en/application-dev/reference/apis/js-apis-document.md @@ -1,8 +1,8 @@ # File Interaction -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
-- The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. -- The APIs of this module will be deprecated and are not recommended for use. An exception will be thrown if any of the APIs is called. +> **NOTE**
+> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The APIs of this module will be deprecated and are not recommended for use. An exception will be thrown if any of the APIs is called. ## Modules to Import ```js @@ -13,21 +13,21 @@ import document from '@ohos.document'; choose(type:string[]): Promise<string> -Chooses a file of the specified type using the file manager. This method uses a promise to return the result. +Chooses a file of the specified type using the file manager. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ---------------------------- | - | type | string[] | No | Type of the file to choose.| + | Name| Type | Mandatory | Description | + | ------ | ------ | ---- | ---------------------------- | + | type | string[] | No | Type of the file to choose. | - Return value - | Type | Description | - | --------------------- | -------------- | - | Promise<string> | Promise used to return the result. An error code is returned.| + | Type | Description | + | --------------------- | -------------- | + | Promise<string> | Promise used to return the result. An error code is returned. | - Example @@ -38,15 +38,15 @@ Chooses a file of the specified type using the file manager. This method uses a choose(callback:AsyncCallback<string>): void -Chooses a file using the file manager. This method uses an asynchronous callback to return the result. +Chooses a file using the file manager. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name | Type | Mandatory| Description | - | -------- | --------------------------- | ---- | ---------------------------- | - | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. | - Example @@ -59,16 +59,16 @@ Chooses a file using the file manager. This method uses an asynchronous callback choose(type:string[], callback:AsyncCallback<string>): void -Chooses a file of the specified type using the file manager. This method uses an asynchronous callback to return the result. +Chooses a file of the specified type using the file manager. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name | Type | Mandatory| Description | - | -------- | --------------------------- | ---- | ---------------------------- | - | type | string[] | No | Type of the file to choose.| - | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | type | string[] | No | Type of the file to choose. | + | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. | - Example @@ -82,22 +82,22 @@ Chooses a file of the specified type using the file manager. This method uses an show(url:string, type:string):Promise<number> -Opens a file. This method uses a promise to return the result. +Opens a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type | Mandatory| Description | - | ---- | ------ | ---- | ---------------------------- | - | uri | string | Yes | URI of the file to open.| - | type | string | Yes | Type of the file to open.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------- | + | uri | string | Yes | URI of the file to open. | + | type | string | Yes | Type of the file to open. | - Return value - | Type | Description | - | --------------------- | ------------ | - | Promise<void> | Promise used to return the result. An error code is returned.| + | Type | Description | + | --------------------- | ------------ | + | Promise<void> | Promise used to return the result. An error code is returned. | - Example @@ -109,17 +109,17 @@ Opens a file. This method uses a promise to return the result. show(url:string, type:string, callback:AsyncCallback<void>): void -Opens a file. This method uses an asynchronous callback to return the result. +Opens a file. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name | Type | Mandatory| Description | - | -------- | --------------------------- | ---- | ---------------------------- | - | uri | string | Yes | URI of the file to open.| - | type | string | Yes | Type of the file to open.| - | callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. | + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | uri | string | Yes | URI of the file to open. | + | type | string | Yes | Type of the file to open. | + | callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. | - Example @@ -127,4 +127,4 @@ Opens a file. This method uses an asynchronous callback to return the result. await document.show(uri, type, function(err) { //do something }); - ``` + ``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-emitter.md b/en/application-dev/reference/apis/js-apis-emitter.md index 8e08290aaefa6b8f52eec4f21f4671b1099d92fc..fa54f6739279745a1f7538fd32abf0fca6402711 100644 --- a/en/application-dev/reference/apis/js-apis-emitter.md +++ b/en/application-dev/reference/apis/js-apis-emitter.md @@ -1,6 +1,7 @@ # Emitter -> Note: The initial APIs of this module are supported since API version 7. +> **NOTE**
+> The initial APIs of this module are supported since API version 7. ## Modules to Import @@ -16,12 +17,12 @@ None Enumerates the event emit priority levels. -| Name | Value | Description | -| --------- | ---- | ------------------------------------------------- | -| IMMEDIATE | 0 | The event will be emitted immediately.
**System capability**: SystemCapability.Notification.Emitter | -| HIGH | 1 | The event will be emitted before low-priority events.
**System capability**: SystemCapability.Notification.Emitter | -| LOW | 2 | The event will be emitted before idle-priority events. By default, an event is in LOW priority.
**System capability**: SystemCapability.Notification.Emitter| -| IDLE | 3 | The event will be emitted after all the other events.
**System capability**: SystemCapability.Notification.Emitter | + | Name | Value | Description | + | --------- | ---- | ------------------------------------------------- | + | IMMEDIATE | 0 | The event will be emitted immediately.
**System capability**: SystemCapability.Notification.Emitter | + | HIGH | 1 | The event will be emitted before low-priority events.
**System capability**: SystemCapability.Notification.Emitter | + | LOW | 2 | The event will be emitted before idle-priority events. By default, an event is in LOW priority.
**System capability**: SystemCapability.Notification.Emitter | + | IDLE | 3 | The event will be emitted after all the other events.
**System capability**: SystemCapability.Notification.Emitter | ## emitter.on @@ -33,10 +34,10 @@ Subscribes to an event in persistent manner. This API uses a callback to return **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------- | ---- | ------------------------ | -| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. | -| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event.| + | Name | Type | Mandatory | Description | + | -------- | ----------------------------------- | ---- | ------------------------ | + | event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. | + | callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. | **Example** @@ -60,10 +61,10 @@ Subscribes to an event in one-shot manner and unsubscribes from it after the eve **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------- | ---- | ------------------------ | -| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. | -| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event.| + | Name | Type | Mandatory | Description | + | -------- | ----------------------------------- | ---- | ------------------------ | + | event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. | + | callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. | **Example** @@ -87,9 +88,9 @@ Unsubscribes from an event. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------ | ---- | ------ | -| eventId | number | Yes | Event ID.| + | Name | Type | Mandatory | Description | + | ------- | ------ | ---- | ------ | + | eventId | number | Yes | Event ID. | **Example** @@ -107,10 +108,10 @@ Emits an event to the event queue. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------- | ---- | -------------- | -| event | [InnerEvent](#innerevent) | Yes | Event to emit. | -| data | [EventData](#eventdata) | No | Data carried by the event.| + | Name | Type | Mandatory | Description | + | ------ | ------------------------- | ---- | -------------- | + | event | [InnerEvent](#innerevent) | Yes | Event to emit. | + | data | [EventData](#eventdata) | No | Data carried by the event. | **Example** @@ -131,15 +132,15 @@ emitter.emit(innerEvent, eventData); Describes an intra-process event. -| Name | Type | Readable| Writable| Description | -| -------- | ------------------------------- | ---- | ---- | ---------------------------------- | -| eventId | number | Yes | Yes | Event ID, which is used to identify an event.
**System capability**: SystemCapability.Notification.Emitter| -| priority | [EventPriority](#eventpriority) | Yes | Yes | Emit priority of the event.
**System capability**: SystemCapability.Notification.Emitter | + | Name | Type | Readable | Writable | Description | + | -------- | ------------------------------- | ---- | ---- | ---------------------------------- | + | eventId | number | Yes | Yes | Event ID, which is used to identify an event.
**System capability**: SystemCapability.Notification.Emitter | + | priority | [EventPriority](#eventpriority) | Yes | Yes | Emit priority of the event.
**System capability**: SystemCapability.Notification.Emitter | ## EventData Describes the data passed in the event. -| Name| Type | Readable| Writable| Description | -| ---- | ------------------ | ---- | ---- | -------------- | -| data | [key: string]: any | Yes | Yes | Data carried by the event. The data type can be String, Integer, or Boolean.
**System capability**: SystemCapability.Notification.Emitter| + | Name | Type | Readable | Writable | Description | + | ---- | ------------------ | ---- | ---- | -------------- | + | data | [key: string]: any | Yes | Yes | Data carried by the event. The data type can be String, Integer, or Boolean.
**System capability**: SystemCapability.Notification.Emitter | diff --git a/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md b/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md index 3e5762750b71ceec5c3b6d852ecec054ef29ad1e..869472d43c046a68cd3d50cfe262b424b660dd0d 100644 --- a/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md +++ b/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md @@ -1,7 +1,6 @@ # Enterprise Device Management -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> +> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -28,12 +27,12 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application.| -| type | [AdminType](#AdminType) | Yes| Type of the device administrator to activate.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | + | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application. | + | type | [AdminType](#AdminType) | Yes | Type of the device administrator to activate. | + | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -71,17 +70,17 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| -------------- | ---------------------------------------------- | ---- | ------------------------ | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application.| -| type | [AdminType](#AdminType) | Yes | Type of the device administrator to activate. | + | Name | Type | Mandatory | Description | + | -------------- | ---------------------------------------------- | ---- | ------------------------ | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | + | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application. | + | type | [AdminType](#AdminType) | Yes | Type of the device administrator to activate. | **Return value** -| Type | Description | -| ----------------- | --------------------------- | -| Promise\ | Promise used to return the result.| + | Type | Description | + | ----------------- | --------------------------- | + | Promise\ | Promise used to return the result. | **Example** @@ -118,10 +117,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------------------- | ---- | ------------------------------ | -| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------------- | ---- | ------------------------------ | + | admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | + | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -157,15 +156,15 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ---------------------------------------------- | ---- | ------------------ | -| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application.| + | Name | Type | Mandatory | Description | + | ------ | ---------------------------------------------- | ---- | ------------------ | + | admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | **Return value** -| Type | Description | -| ----------------- | --------------------------- | -| Promise\ | Promise used to return the result.| + | Type | Description | + | ----------------- | --------------------------- | + | Promise\ | Promise used to return the result. | **Example** @@ -193,10 +192,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------- | ---- | ------------------------------ | -| bundleName | String | Yes | Bundle name of a device super administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| + | Name | Type | Mandatory | Description | + | ---------- | ----------------------- | ---- | ------------------------------ | + | bundleName | String | Yes | Bundle name of a device super administrator application. | + | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -223,15 +222,15 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------ | ---- | ------------------------ | -| bundleName | String | Yes | Bundle name of a device super administrator application.| + | Name | Type | Mandatory | Description | + | ---------- | ------ | ---- | ------------------------ | + | bundleName | String | Yes | Bundle name of a device super administrator application. | **Return value** -| Type | Description | -| ----------------- | --------------------------- | -| Promise\ | Promise used to return the result.| + | Type | Description | + | ----------------- | --------------------------- | + | Promise\ | Promise used to return the result. | **Example** @@ -256,10 +255,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------------------- | ---- | -------------------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------------- | ---- | -------------------------------- | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | + | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -291,15 +290,15 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ---------------------------------------------- | ---- | -------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| + | Name | Type | Mandatory | Description | + | ------ | ---------------------------------------------- | ---- | -------------- | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | **Return value** -| Type | Description | -| ----------------- | ------------------------------- | -| Promise\ | Promise used to return the result.| + | Type | Description | + | ----------------- | ------------------------------- | + | Promise\ | Promise used to return the result. | **Example** @@ -327,10 +326,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------- | ---- | -------------------------------- | -| bundleName | String | Yes | Bundle name of a device super administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| + | Name | Type | Mandatory | Description | + | ---------- | ----------------------- | ---- | -------------------------------- | + | bundleName | String | Yes | Bundle name of a device super administrator application. | + | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -359,15 +358,15 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------ | ---- | ------------------ | -| bundleName | String | Yes | Bundle name of a device super administrator application.| + | Name | Type | Mandatory | Description | + | ---------- | ------ | ---- | ------------------ | + | bundleName | String | Yes | Bundle name of a device super administrator application. | **Return value** -| Type | Description | -| ----------------- | ------------------------------- | -| Promise\ | Promise used to return the result.| + | Type | Description | + | ----------------- | ------------------------------- | + | Promise\ | Promise used to return the result. | **Example** @@ -392,9 +391,9 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback; | Callback used to return the result.| + | Type | Description | + | ------------------ | ----------------------------------- | + | Promise\; | Callback used to return the result. | **Example** @@ -545,10 +544,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------------ | ---- | ---------------------------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| callback | AsyncCallback<[EnterpriseInfo](#EnterpriseInfo)> | Yes | Callback used to return the enterprise information of the device administrator application.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------------------------------ | ---- | ---------------------------------------- | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | + | callback | AsyncCallback<[EnterpriseInfo](#EnterpriseInfo)> | Yes | Callback used to return the enterprise information of the device administrator application. | **Example** @@ -570,7 +569,7 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => { ## enterpriseDeviceManager.getEnterpriseInfo -getDeviceSettingsManager(admin: Want): Promise<EnterpriseInfo> +getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> Obtains the enterprise information of a device administrator application. This API uses a promise to return the result. @@ -580,15 +579,15 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ---------------------------------------------- | ---- | -------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| + | Name | Type | Mandatory | Description | + | ------ | ---------------------------------------------- | ---- | -------------- | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | **Return value** -| Type | Description | -| ------------------------------------------------ | ------------------------------------------- | -| Promise<[EnterpriseInfo](#EnterpriseInfo)> | Promise used to return the enterprise information of the device administrator application.| + | Type | Description | + | ------------------------------------------------ | ------------------------------------------- | + | Promise<[EnterpriseInfo](#EnterpriseInfo)> | Promise used to return the enterprise information of the device administrator application. | **Example** @@ -613,10 +612,10 @@ Describes the enterprise information of a device administrator application. SystemCapability.Customation.EnterpriseDeviceManager -| Name | Readable/Writable| Type | Mandatory| Description | -| ----------- | -------- | ------ | ---- | ---------------------------------- | -| name | Read only | string | Yes | Name of the enterprise to which the device administrator application belongs.| -| description | Read only | string | Yes | Description of the enterprise to which the device administrator application belongs.| + | Name | Readable/Writable | Type | Mandatory | Description | + | ----------- | -------- | ------ | ---- | ---------------------------------- | + | name | Read only | string | Yes | Name of the enterprise to which the device administrator application belongs. | + | description | Read only | string | Yes | Description of the enterprise to which the device administrator application belongs. | ## AdminType @@ -627,7 +626,7 @@ Enumerates the administrator types of the device administrator application. SystemCapability.Customation.EnterpriseDeviceManager -| Name| Default Value| Description| -| -------- | -------- | -------- | -| ADMIN_TYPE_NORMAL | 0x00 | Common administrator.| -| ADMIN_TYPE_SUPER | 0x01 | Super administrator.| + | Name | Default Value | Description | + | -------- | -------- | -------- | + | ADMIN_TYPE_NORMAL | 0x00 | Common administrator. | + | ADMIN_TYPE_SUPER | 0x01 | Super administrator. | diff --git a/en/application-dev/reference/apis/js-apis-eventhub.md b/en/application-dev/reference/apis/js-apis-eventhub.md index 1ee467b32f47d6f277783d6c02e6f842939d8ae8..b7afbb435c747c4b411aeaa72fb1806c47b39f60 100644 --- a/en/application-dev/reference/apis/js-apis-eventhub.md +++ b/en/application-dev/reference/apis/js-apis-eventhub.md @@ -1,6 +1,6 @@ # EventHub -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. @@ -34,10 +34,10 @@ Subscribes to an event. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | event | string | Yes| Event name.| - | callback | Function | Yes| Callback invoked when the event is triggered.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | event | string | Yes | Event name. | + | callback | Function | Yes | Callback invoked when the event is triggered. | **Example** @@ -72,10 +72,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | event | string | Yes| Event name.| - | callback | Function | No| Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | event | string | Yes | Event name. | + | callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. | **Example** @@ -110,10 +110,10 @@ Triggers an event. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | event | string | Yes| Event name.| - | ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | event | string | Yes | Event name. | + | ...args | Object[] | Yes | Variable parameters, which are passed to the callback when the event is triggered. | **Example** 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 51ce88f1cfd16bd960b2a14290d2d51481f2085e..0c73786fda860a84008d7736aa42959daca67934 100644 --- a/en/application-dev/reference/apis/js-apis-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-extension-context.md @@ -11,7 +11,7 @@ Implements the extension context. This module is inherited from **Context**. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Type| Readable| Writable| Description| +| Name | Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. | -| config | Configuration | Yes| No| Module configuration information.| +| currentHapModuleInfo | HapModuleInfo | Yes| No | Information about the current HAP. | +| config | Configuration | Yes| No | Module configuration information. | diff --git a/en/application-dev/reference/apis/js-apis-faultLogger.md b/en/application-dev/reference/apis/js-apis-faultLogger.md index 79748782fc5c92ffc8fca9ca438ff88ec0bbf73c..bcccead1778606ac11ab58329e97932e0174f014 100644 --- a/en/application-dev/reference/apis/js-apis-faultLogger.md +++ b/en/application-dev/reference/apis/js-apis-faultLogger.md @@ -15,12 +15,12 @@ Enumerates the fault types. **System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger -| Name| Default Value| Description| +| Name | Default Value | Description | | -------- | -------- | -------- | -| NO_SPECIFIC | 0 | No specific fault type.| -| CPP_CRASH | 2 | C++ program crash.| -| JS_CRASH | 3 | JS program crash.| -| APP_FREEZE | 4 | Application freezing.| +| NO_SPECIFIC | 0 | No specific fault type. | +| CPP_CRASH | 2 | C++ program crash. | +| JS_CRASH | 3 | JS program crash. | +| APP_FREEZE | 4 | Application freezing. | ## FaultLogInfo @@ -30,20 +30,20 @@ Defines the data structure of the fault log information. | Name| Type| Description| | -------- | -------- | -------- | -| pid | number | Process ID of the faulty process.| -| uid | number | User ID of the faulty process.| -| type | [FaultType](#faulttype) | Fault type.| -| timestamp | number | Second-level timestamp when the log was generated.| -| reason | string | Reason for the fault.| -| module | string | Module on which the fault occurred.| -| summary | string | Summary of the fault.| -| fullLog | string | Full log text.| +| pid | number | Process ID of the faulty process. | +| uid | number | User ID of the faulty process. | +| type | [FaultType](#faulttype) | Fault type. | +| timestamp | number | Second-level timestamp when the log was generated. | +| reason | string | Reason for the fault. | +| module | string | Module on which the fault occurred. | +| summary | string | Summary of the fault. | +| fullLog | string | Full log text. | ## faultLogger.querySelfFaultLog querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void -Obtains the fault information about the current process. This API uses a callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. +Obtains the fault information about the current process. This API uses an asynchronous callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. **System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger @@ -51,7 +51,7 @@ Obtains the fault information about the current process. This API uses a callbac | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| faultType | [FaultType](#faulttype) | Yes| Fault type.| +| faultType | [FaultType](#faulttype) | Yes| Fault type. | | callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloginfo)>> | Yes| Callback used to return the fault information array.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned. **Example** @@ -91,13 +91,13 @@ Obtains the fault information about the current process. This API uses a promise | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| faultType | [FaultType](#faulttype) | Yes| Fault type.| +| faultType | [FaultType](#faulttype) | Yes| Fault type. | **Return value** | Type| Description| | -------- | -------- | -| Promise<Array<[FaultLogInfo](#faultloginfo)>> | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.| +| Promise<Array<[FaultLogInfo](#faultloginfo)>> | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. | **Example** @@ -120,4 +120,4 @@ async function getLog() { } } } -``` +``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-featureAbility.md b/en/application-dev/reference/apis/js-apis-featureAbility.md index 516272d7ed72e632b22fd6f4c4dc0ebf6840b727..b57f529219338640cc0494bd24611063bcc4661d 100644 --- a/en/application-dev/reference/apis/js-apis-featureAbility.md +++ b/en/application-dev/reference/apis/js-apis-featureAbility.md @@ -1,6 +1,6 @@ # FeatureAbility Module (JavaScript) -> ![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 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Constraints @@ -17,7 +17,7 @@ import featureAbility from '@ohos.ability.featureAbility' startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\): void -Starts an ability. This method uses a callback to return the result. +Starts an ability. This API uses a callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -42,8 +42,9 @@ featureAbility.startAbility( type: "", flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", - bundleName: "com.example.startability", - abilityName: "com.example.startability.MainAbility", + bundleName: "com.example.myapplication", + /* In the FA model, abilityName consists of package and ability name. */ + abilityName: "com.example.entry.secondAbility",, uri: "" }, }, @@ -56,7 +57,7 @@ featureAbility.startAbility( startAbility(parameter: StartAbilityParameter): Promise\ -Starts an ability. This method uses a promise to return the result. +Starts an ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -80,8 +81,9 @@ featureAbility.startAbility( type: "MIMETYPE", flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", - bundleName: "com.example.startability", - abilityName: "com.example.startability.MainAbility", + bundleName: "com.example.myapplication", + /* In the FA model, abilityName consists of package and ability name. */ + abilityName: "com.example.entry.secondAbility", uri: "" }, } @@ -123,7 +125,7 @@ featureAbility.acquireDataAbilityHelper( startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\): void -Starts an ability. This method uses a callback to return the execution result when the ability is destroyed. +Starts an ability. This API uses a callback to return the execution result when the ability is destroyed. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -148,8 +150,9 @@ featureAbility.startAbilityForResult( type: "MIMETYPE", flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", - bundleName: "com.example.featureabilitytest", - abilityName: "com.example.featureabilitytest.MainAbility", + bundleName: "com.example.myapplication", + /* In the FA model, abilityName consists of package and ability name. */ + abilityName: "com.example.entry.secondAbility", uri:"" }, }, @@ -163,7 +166,7 @@ featureAbility.startAbilityForResult( startAbilityForResult(parameter: StartAbilityParameter): Promise\ -Starts an ability. This method uses a promise to return the execution result when the ability is destroyed. +Starts an ability. This API uses a promise to return the execution result when the ability is destroyed. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -193,8 +196,9 @@ featureAbility.startAbilityForResult( type: "MIMETYPE", flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", - bundleName: "com.example.featureabilitytest", - abilityName: "com.example.featureabilitytest.MainAbility", + bundleName: "com.example.myapplication", + /* In the FA model, abilityName consists of package and ability name. */ + abilityName: "com.example.entry.secondAbility", uri:"", parameters: { @@ -219,7 +223,7 @@ featureAbility.startAbilityForResult( terminateSelfWithResult(parameter: AbilityResult, 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. +Destroys this Page ability, with the result code and data sent to the caller. This API uses a callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -245,8 +249,9 @@ featureAbility.terminateSelfWithResult( type: "MIMETYPE", flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", - bundleName: "com.example.featureabilitytest", - abilityName: "com.example.featureabilitytest.MainAbility", + bundleName: "com.example.myapplication", + /* In the FA model, abilityName consists of package and ability name. */ + abilityName: "com.example.entry.secondAbility", uri:"", parameters: { mykey0: 2222, @@ -267,7 +272,7 @@ featureAbility.terminateSelfWithResult( 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. +Destroys this Page ability, with the result code and data sent to the caller. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -298,8 +303,9 @@ featureAbility.terminateSelfWithResult( type: "MIMETYPE", flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", - bundleName: "com.example.featureabilitytest", - abilityName: "com.example.featureabilitytest.MainAbility", + bundleName: "com.example.myapplication", + /* In the FA model, abilityName consists of package and ability name. */ + abilityName: "com.example.entry.secondAbility", uri:"", parameters: { mykey0: 2222, @@ -324,7 +330,7 @@ featureAbility.terminateSelfWithResult( hasWindowFocus(callback: AsyncCallback\): void -Checks whether the main window of this ability has the focus. This method uses a callback to return the result. +Checks whether the main window of this ability has the focus. This API uses a callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -347,7 +353,7 @@ featureAbility.hasWindowFocus() hasWindowFocus(): Promise\ -Checks whether the main window of this ability has the focus. This method uses a promise to return the result. +Checks whether the main window of this ability has the focus. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -372,7 +378,7 @@ featureAbility.hasWindowFocus().then((data) => { getWant(callback: AsyncCallback\): void -Obtains the **Want** object sent from this ability. This method uses a callback to return the result. +Obtains the **Want** object sent from this ability. This API uses a callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -380,7 +386,7 @@ Obtains the **Want** object sent from this ability. This method uses a callback | Name | Type | Mandatory | Description | | -------- | ----------------------------- | ---- | --------- | -| callback | AsyncCallback\<[Want](#want)> | Yes | Callback used to return the result.| +| callback | AsyncCallback\<[Want](js-apis-application-Want.md)> | Yes | Callback used to return the result.| **Example** @@ -395,7 +401,7 @@ featureAbility.getWant() getWant(): Promise\ -Obtains the **Want** object sent from this ability. This method uses a promise to return the result. +Obtains the **Want** object sent from this ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -403,7 +409,7 @@ Obtains the **Want** object sent from this ability. This method uses a promise t | Type | Description | | ----------------------- | ---------------- | -| Promise\<[Want](#want)> | Promise used to return the result.| +| Promise\<[Want](js-apis-application-Want.md)> | Promise used to return the result.| **Example** @@ -442,7 +448,7 @@ context.getBundleName() 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. +Destroys this Page ability, with the result code and data sent to the caller. This API uses a callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -465,7 +471,7 @@ featureAbility.terminateSelf() 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. +Destroys this Page ability, with the result code and data sent to the caller. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -488,7 +494,7 @@ featureAbility.terminateSelf().then((data) => { connectAbility(request: Want, options:ConnectOptions): number -Connects this ability to a specific Service ability. This method uses a callback to return the result. +Connects this ability to a specific Service ability. This API uses a callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -496,7 +502,7 @@ Connects this ability to a specific Service ability. This method uses a callback | Name | Type | Mandatory | Description | | ------- | -------------- | ---- | --------------------- | -| request | [Want](#want) | Yes | Service ability to connect.| +| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect.| | options | ConnectOptions | Yes | Callback used to return the result. | Want @@ -557,7 +563,7 @@ var connId = featureAbility.connectAbility( disconnectAbility(connection: number, callback:AsyncCallback\): void -Disconnects this ability from a specific Service ability. This method uses a callback to return the result. +Disconnects this ability from a specific Service ability. This API uses a callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -604,7 +610,7 @@ var result = featureAbility.disconnectAbility(connId, disconnectAbility(connection: number): Promise\ -Disconnects this ability from a specific Service ability. This method uses a promise to return the result. +Disconnects this ability from a specific Service ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -656,7 +662,7 @@ featureAbility.disconnectAbility(connId).then((error,data) => { getWindow(callback: AsyncCallback\): void -Obtains the window corresponding to this ability. This method uses a callback to return the result. +Obtains the window corresponding to this ability. This API uses a callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -676,7 +682,7 @@ featureAbility.getWindow() getWindow(): Promise\; -Obtains the window corresponding to this ability. This method uses a promise to return the result. +Obtains the window corresponding to this ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -902,7 +908,7 @@ Enumerates operation types of the Data ability. | Name | Readable/Writable| Type | Mandatory | Description | | ----------------------- | ---- | ------------- | ---- | ------------------------------------- | | resultCode7+ | Read-only | number | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.| -| want7+ | 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**. | +| want7+ | Read-only | [Want](js-apis-application-Want.md) | No | Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**. | ## StartAbilityParameter @@ -910,27 +916,9 @@ Enumerates operation types of the Data ability. | Name | Readable/Writable| Type | Mandatory | Description | | ------------------- | ---- | -------------------- | ---- | -------------------------------------- | -| want | Read-only | [Want](#want) | Yes | Information about the ability to start. | +| want | Read-only | [Want](js-apis-application-Want.md) | 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 - -**System capability**: SystemCapability.Ability.AbilityBase - -| 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.| -| abilityName | Read-only | string | No | Name of the ability to start. If both **package** and **AbilityName** are specified in this field in a **Want** object, the **Want** object can directly match the specified ability.| -| uri | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| -| type | Read-only | string | No | MIME type, for example, text/plain or image/*. | -| flags | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).| -| 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. | -| extensionAbilityName9+ | Read-only | string | No | Description of the Extension ability name in the **Want** object. | -| extensionAbilityType9+ | Read-only | number | No | Description of the Extension ability type in the **Want** object. | + | ## flags diff --git a/en/application-dev/reference/apis/js-apis-fileio.md b/en/application-dev/reference/apis/js-apis-fileio.md index 09f43ce1dadc25d4c5f99b8b65933b470084b6ff..57543a8a185d1c364f6c9abbb5fc4f0f19d89e8e 100644 --- a/en/application-dev/reference/apis/js-apis-fileio.md +++ b/en/application-dev/reference/apis/js-apis-fileio.md @@ -1,8 +1,15 @@ # File Management -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. +This module provides common file storage functions. It provides the following JavaScript I/O APIs, including: + +- Basic APIs for file management +- Basic APIs for directory management +- Statistical APIs for obtaining file information +- Stream APIs for reading and writing files + ## Modules to Import ```js @@ -10,11 +17,6 @@ import fileio from '@ohos.fileio'; ``` -## Required Permissions - -None - - ## Guidelines Before using this module to perform operations on a file or directory, obtain the absolute path of the file or directory. For details, see [getOrCreateLocalDir of the Context module](js-apis-Context.md). @@ -40,21 +42,23 @@ let fd = fileio.openSync(path); stat(path: string): Promise<Stat> -Asynchronously obtains file information. This method uses a promise to return the result. +Asynchronously obtains file information. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** + | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the target file.| -- Return value +**Return value** + | Type | Description | | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | Promise used to return the file information obtained.| -- Example +**Example** ```js fileio.stat(path).then(function(stat){ console.info("getFileInfo successfully:"+ JSON.stringify(stat)); @@ -68,17 +72,17 @@ Asynchronously obtains file information. This method uses a promise to return th stat(path:string, callback:AsyncCallback<Stat>): void -Asynchronously obtains file information. This method uses a callback to return the result. +Asynchronously obtains file information. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------- | ---- | --------------- | | path | string | Yes | Absolute path of the target file. | | callback | AsyncCallback<[Stat](#stat)> | Yes | Callback invoked to return the file information obtained.| -- Example +**Example** ```js fileio.stat(path, function (err, stat) { // Example code in Stat @@ -94,18 +98,18 @@ Synchronously obtains file information. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the target file.| -- Return value +**Return value** | Type | Description | | ------------- | ---------- | | [Stat](#stat) | File information obtained.| -- Example +**Example** ```js let stat = fileio.statSync(path); // Example code in Stat @@ -116,21 +120,21 @@ Synchronously obtains file information. opendir(path: string): Promise<Dir> -Asynchronously opens a directory. This method uses a promise to return the result. +Asynchronously opens a directory. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------- | | path | string | Yes | Absolute path of the directory to open.| -- Return value +**Return value** | Type | Description | | -------------------------- | -------- | | Promise<[Dir](#dir)> | A **Dir** instance corresponding to the directory.| -- Example +**Example** ```js fileio.opendir(path).then(function(dir){ console.info("opendir successfully:"+ JSON.stringify(dir)); @@ -144,17 +148,18 @@ Asynchronously opens a directory. This method uses a promise to return the resul opendir(path: string, callback: AsyncCallback<Dir>): void -Asynchronously opens a directory. This method uses a callback to return the result. +Asynchronously opens a directory. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** + | Name | Type | Mandatory | Description | | -------- | -------------------------------- | ---- | -------------- | | path | string | Yes | Absolute path of the directory to open. | | callback | AsyncCallback<[Dir](#dir)> | Yes | Callback invoked when the directory is open asynchronously.| -- Example +**Example** ```js fileio.opendir(path, function (err, dir) { // Example code in Dir struct @@ -172,17 +177,18 @@ Synchronously opens a directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** + | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------- | | path | string | Yes | Absolute path of the directory to open.| -- Return value +**Return value** | Type | Description | | ----------- | -------- | | [Dir](#dir) | A **Dir** instance corresponding to the directory.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); // Example code in Dir struct @@ -194,22 +200,23 @@ Synchronously opens a directory. access(path: string, mode?: number): Promise<void> -Asynchronously checks whether the current process can access a file. This method uses a promise to return the result. +Asynchronously checks whether the current process can access a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** + | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | No | Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.access(path).then(function() { console.info("access successfully"); @@ -223,18 +230,18 @@ Asynchronously checks whether the current process can access a file. This method access(path: string, mode: number, callback: AsyncCallback<void>): void -Asynchronously checks whether the current process can access a file. This method uses a callback to return the result. +Asynchronously checks whether the current process can access a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | No | Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file is asynchronously checked. | -- Example +**Example** ```js fileio.access(path, function (err) { // Do something. @@ -250,13 +257,13 @@ Synchronously checks whether the current process can access the specified file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | No | Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| -- Example +**Example** ```js try { fileio.accessSync(path); @@ -270,21 +277,21 @@ Synchronously checks whether the current process can access the specified file. close(fd: number):Promise<void> -Asynchronously closes a file. This method uses a promise to return the result. +Asynchronously closes a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to close.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js let fd = fileio.openSync(path); fileio.close(fd).then(function(){ @@ -299,17 +306,17 @@ Asynchronously closes a file. This method uses a promise to return the result. close(fd: number, callback:AsyncCallback<void>): void -Asynchronously closes a file. This method uses a callback to return the result. +Asynchronously closes a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------ | | fd | number | Yes | File descriptor of the file to close.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file is closed asynchronously.| -- Example +**Example** ```js let fd = fileio.openSync(path); fileio.close(fd, function (err) { @@ -326,12 +333,12 @@ Synchronously closes a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to close.| -- Example +**Example** ```js fileio.closeSync(fd); ``` @@ -341,16 +348,16 @@ Synchronously closes a file. close(): Promise<void> -Asynchronously closes the stream. This method uses a promise to return the result. +Asynchronously closes the stream. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.close().then(function(){ console.info("close file stream successfully"); @@ -364,16 +371,16 @@ Asynchronously closes the stream. This method uses a promise to return the resul close(callback: AsyncCallback<void>): void -Asynchronously closes the stream. This method uses a callback to return the result. +Asynchronously closes the stream. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------- | | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| -- Example +**Example** ```js fileio.close(function(err){ // Do something. @@ -385,23 +392,23 @@ Asynchronously closes the stream. This method uses a callback to return the resu copyFile(src:string | number, dest:string | number, mode?:number):Promise<void> -Asynchronously copies a file. This method uses a promise to return the result. +Asynchronously copies a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | -------------------------- | ---- | ---------------------------------------- | | src | string \| number | Yes | Path or file descriptor of the file to copy. | | dest | string \| number | Yes | Path or file descriptor of the new file. | | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.copyFile(src, dest).then(function(){ console.info("copyFile successfully"); @@ -415,11 +422,11 @@ Asynchronously copies a file. This method uses a promise to return the result. copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback<void>): void -Asynchronously copies a file. This method uses a callback to return the result. +Asynchronously copies a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | -------------------------- | ---- | ---------------------------------------- | | src | string \| number | Yes | Path or file descriptor of the file to copy. | @@ -427,7 +434,7 @@ Asynchronously copies a file. This method uses a callback to return the result. | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file is copied asynchronously. | -- Example +**Example** ```js fileio.copyFile(src, dest, function (err) { // Do something. @@ -443,14 +450,14 @@ Synchronously copies a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | -------------------------- | ---- | ---------------------------------------- | | src | string \| number | Yes | Path or file descriptor of the file to copy. | | dest | string \| number | Yes | Path or file descriptor of the new file. | | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| -- Example +**Example** ```js fileio.copyFileSync(src, dest); ``` @@ -460,22 +467,22 @@ Synchronously copies a file. mkdir(path:string, mode?: number): Promise<void> -Asynchronously creates a directory. This method uses a promise to return the result. +Asynchronously creates a directory. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the directory to create. | | mode | number | No | Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.mkdir(path).then(function() { console.info("mkdir successfully"); @@ -489,18 +496,18 @@ Asynchronously creates a directory. This method uses a promise to return the res mkdir(path: string, mode: number, callback: AsyncCallback<void>): void -Asynchronously creates a directory. This method uses a callback to return the result. +Asynchronously creates a directory. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the directory to create. | | mode | number | No | Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| | callback | AsyncCallback<void> | Yes | Callback invoked when the directory is created asynchronously. | -- Example +**Example** ```js fileio.mkdir(path, function(err) { console.info("mkdir successfully"); @@ -516,13 +523,13 @@ Synchronously creates a directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the directory to create. | | mode | number | No | Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Example +**Example** ```js fileio.mkdirSync(path); ``` @@ -532,23 +539,23 @@ Synchronously creates a directory. open(path: string, flags?: number, mode?: number): Promise<number> -Asynchronously opens a file. This method uses a promise to return the result. +Asynchronously opens a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ----- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | - | flags | number | No | Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| + | flags | number | No | Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| | mode | number | No | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Return value +**Return value** | Type | Description | | --------------------- | ----------- | | Promise<number> | File descriptor of the file opened.| -- Example +**Example** ```js fileio.open(path, 0o1, 0o0200).then(function(number){ console.info("open file successfully"); @@ -562,11 +569,11 @@ Asynchronously opens a file. This method uses a promise to return the result. open(path: string, flags: number, mode: number, callback: AsyncCallback<number>): void -Asynchronously opens a file. This method uses a callback to return the result. +Asynchronously opens a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | @@ -574,7 +581,7 @@ Asynchronously opens a file. This method uses a callback to return the result. | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| | callback | AsyncCallback <void> | Yes | Callback invoked when the file is open asynchronously. | -- Example +**Example** ```js fileio.open(path, 0, function(err, fd) { // Do something. @@ -590,19 +597,19 @@ Synchronously opens a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ----- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | flags | number | No | Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| | mode | number | No | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.
The file permissions on newly created files are affected by umask, which is set as the process starts. Currently, the modification of umask is not open.| -- Return value +**Return value** | Type | Description | | ------ | ----------- | | number | File descriptor of the file opened.| -- Example +**Example** ```js let fd = fileio.openSync(path); ``` @@ -616,23 +623,24 @@ read(fd: number, buffer: ArrayBuffer, options?: { position?: number; }): Promise<ReadOut> -Asynchronously reads data from a file. This method uses a promise to return the result. +Asynchronously reads data from a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters - | Name | Type | Mandatory | Description | - | ------- | ----------- | ---- | ---------------------------------------- | - | fd | number | Yes | File descriptor of the file to read. | - | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | +**Parameters** +| Name | Type | Mandatory| Description | +| ------- | ----------- | ---- | ------------------------------------------------------------ | +| fd | number | Yes | File descriptor of the file to read. | +| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | +| options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size| + +**Return value** -- Return value | Type | Description | | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | Data read.| -- Example +**Example** ```js let fd = fileio.openSync(path, 0o2); let buf = new ArrayBuffer(4096); @@ -653,19 +661,19 @@ read(fd: number, buffer: ArrayBuffer, options: { position?: number; }, callback: AsyncCallback<ReadOut>): void -Asynchronously reads data from a file. This method uses a callback to return the result. +Asynchronously reads data from a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size | | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously. | -- Example +**Example** ```js let fd = fileio.openSync(path, 0o2); let buf = new ArrayBuffer(4096); @@ -690,19 +698,19 @@ Synchronously reads data from a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ----------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size | -- Return value +**Return value** | Type | Description | | ------ | -------- | | number | Length of the data read.| -- Example +**Example** ```js let fd = fileio.openSync(path, 0o2); let buf = new ArrayBuffer(4096); @@ -714,21 +722,21 @@ Synchronously reads data from a file. rmdir(path: string): Promise<void> -Asynchronously deletes a directory. This method uses a promise to return the result. +Asynchronously deletes a directory. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the directory to delete.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.rmdir(path).then(function() { console.info("rmdir successfully"); @@ -742,17 +750,17 @@ Asynchronously deletes a directory. This method uses a promise to return the res rmdir(path: string, callback:AsyncCallback<void>): void -Asynchronously deletes a directory. This method uses a callback to return the result. +Asynchronously deletes a directory. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------ | | path | string | Yes | Absolute path of the directory to delete. | | callback | AsyncCallback<void> | Yes | Callback invoked when the directory is deleted asynchronously.| -- Example +**Example** ```js fileio.rmdir(path, function(err){ // Do something. @@ -769,12 +777,12 @@ Synchronously deletes a directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the directory to delete.| -- Example +**Example** ```js fileio.rmdirSync(path); ``` @@ -784,21 +792,21 @@ Synchronously deletes a directory. unlink(path:string): Promise<void> -Asynchronously deletes a file. This method uses a promise to return the result. +Asynchronously deletes a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the file to delete.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.unlink(path).then(function(){ console.info("remove file successfully"); @@ -812,17 +820,17 @@ Asynchronously deletes a file. This method uses a promise to return the result. unlink(path:string, callback:AsyncCallback<void>): void -Asynchronously deletes a file. This method uses a callback to return the result. +Asynchronously deletes a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------ | | path | string | Yes | Absolute path of the file to delete. | | callback | AsyncCallback<void> | Yes | Callback invoked when the file is deleted asynchronously.| -- Example +**Example** ```js fileio.unlink(path, function(err) { console.info("remove file successfully"); @@ -838,12 +846,12 @@ Synchronously deletes a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the file to delete.| -- Example +**Example** ```js fileio.unlinkSync(path); ``` @@ -858,23 +866,23 @@ write(fd: number, buffer: ArrayBuffer | string, options?: { encoding?: string; }): Promise<number> -Asynchronously writes data into a file. This method uses a promise to return the result. +Asynchronously writes data into a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to write. | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size| -- Return value +**Return value** | Type | Description | | --------------------- | -------- | | Promise<number> | Length of the data written in the file.| -- Example +**Example** ```js let fd = fileio.openSync(fpath, 0o100 | 0o2, 0o666); fileio.write(fd, "hello, world").then(function(number){ @@ -894,19 +902,19 @@ write(fd: number, buffer: ArrayBuffer | string, options: { encoding?: string; }, callback: AsyncCallback<number>): void -Asynchronously writes data into a file. This method uses a callback to return the result. +Asynchronously writes data into a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to write. | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size| | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | -- Example +**Example** ```js let fd = fileio.openSync(path, 0o100 | 0o2, 0o666); fileio.write(fd, "hello, world", function (err, bytesWritten) { @@ -930,19 +938,19 @@ Synchronously writes data into a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to write. | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size| -- Return value +**Return value** | Type | Description | | ------ | -------- | | number | Length of the data written in the file.| -- Example +**Example** ```js let fd = fileio.openSync(path, 0o100 | 0o2, 0o666); let num = fileio.writeSync(fd, "hello, world"); @@ -953,22 +961,22 @@ Synchronously writes data into a file. hash(path: string, algorithm: string): Promise<string> -Asynchronously calculates the hash value of a file. This method uses a promise to return the result. +Asynchronously calculates the hash value of a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | --------- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | - | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**.
**sha256** is recommended for security purposes.| + | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**. **sha256** is recommended for security purposes.| -- Return value +**Return value** | Type | Description | | --------------------- | -------------------------- | | Promise<string> | Promise used to return the hash value of the file. The hash value is a hexadecimal string consisting of digits and uppercase letters.| -- Example +**Example** ```js fileio.hash(path, "sha256").then(function(str){ console.info("calculate file hash successfully:"+ str); @@ -982,18 +990,18 @@ Asynchronously calculates the hash value of a file. This method uses a promise t hash(path: string, algorithm: string, callback: AsyncCallback<string>): void -Asynchronously calculates the hash value of a file. This method uses a callback to return the result. +Asynchronously calculates the hash value of a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | --------- | --------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | - | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**.
**sha256** is recommended for security purposes.| + | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**. **sha256** is recommended for security purposes.| | callback | AsyncCallback<string> | Yes | Callback used to return the hash value. The hash value is a hexadecimal string consisting of digits and uppercase letters.| -- Example +**Example** ```js fileio.hash(fpath, "sha256", function(err, hashStr) { if (hashStr) { @@ -1007,22 +1015,22 @@ Asynchronously calculates the hash value of a file. This method uses a callback chmod(path: string, mode: number):Promise<void> -Asynchronously changes the file permissions based on its path. This method uses a promise to return the result. +Asynchronously changes the file permissions based on its path. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.chmod(path, mode).then(function() { console.info("chmod successfully"); @@ -1036,18 +1044,18 @@ Asynchronously changes the file permissions based on its path. This method uses chmod(path: string, mode: number, callback: AsyncCallback<void>): void -Asynchronously changes the file permissions based on its path. This method uses a callback to return the result. +Asynchronously changes the file permissions based on its path. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file permissions are changed asynchronously. | -- Example +**Example** ```js fileio.chmod(path, mode, function (err) { // Do something. @@ -1063,13 +1071,13 @@ Synchronously changes the file permissions based on its path. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Example +**Example** ```js fileio.chmodSync(fpath, mode); ``` @@ -1079,21 +1087,21 @@ Synchronously changes the file permissions based on its path. fstat(fd: number): Promise<Stat> -Asynchronously obtains file status information based on the file descriptor. This method uses a promise to return the result. +Asynchronously obtains file status information based on the file descriptor. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the target file.| -- Return value +**Return value** | Type | Description | | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | Promise used to return the file status information obtained.| -- Example +**Example** ```js fileio.fstat(fd).then(function(stat){ console.info("fstat successfully:"+ JSON.stringify(stat)); @@ -1107,17 +1115,17 @@ Asynchronously obtains file status information based on the file descriptor. Thi fstat(fd: number, callback: AsyncCallback<Stat>): void -Asynchronously obtains file status information based on the file descriptor. This method uses a callback to return the result. +Asynchronously obtains file status information based on the file descriptor. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------- | ---- | ---------------- | | fd | number | Yes | File descriptor of the target file. | | callback | AsyncCallback<[Stat](#stat)> | Yes | Callback invoked when the file status information is obtained asynchronously.| -- Example +**Example** ```js let fd = fileio.openSync(path); fileio.fstat(fd, function (err) { @@ -1134,17 +1142,17 @@ Synchronously obtains file status information based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the target file.| -- Return value +**Return value** | Type | Description | | ------------- | ---------- | - | [Stat](#stat) | File status information obtained.| + | [Stat](#stat) | File information obtained.| -- Example +**Example** ```js let fd = fileio.openSync(path); let stat = fileio.fstatSync(fd); @@ -1155,22 +1163,22 @@ Synchronously obtains file status information based on the file descriptor. ftruncate(fd: number, len?: number): Promise<void> -Asynchronously truncates a file based on the file descriptor. This method uses a promise to return the result. +Asynchronously truncates a file based on the file descriptor. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------- | | fd | number | Yes | File descriptor of the file to truncate. | | len | number | Yes | File length, in bytes, after truncation.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js let fd = fileio.openSync(path); fileio.ftruncate(fd, 5).then(function(err) { @@ -1185,18 +1193,18 @@ Asynchronously truncates a file based on the file descriptor. This method uses a ftruncate(fd: number, len: number, callback:AsyncCallback<void>): void -Asynchronously truncates a file based on the file descriptor. This method uses a callback to return the result. +Asynchronously truncates a file based on the file descriptor. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------- | | fd | number | Yes | File descriptor of the file to truncate. | | len | number | Yes | File length, in bytes, after truncation.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file is truncated asynchronously. | -- Example +**Example** ```js fileio.ftruncate(fd, len, function(err){ // Do something. @@ -1212,13 +1220,13 @@ Synchronously truncates a file based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------- | | fd | number | Yes | File descriptor of the file to truncate. | | len | number | No | File length, in bytes, after truncation.| -- Example +**Example** ```js fileio.ftruncateSync(fd, len); ``` @@ -1228,22 +1236,22 @@ Synchronously truncates a file based on the file descriptor. truncate(path: string, len?: number): Promise<void> -Asynchronously truncates a file based on its path. This method uses a promise to return the result. +Asynchronously truncates a file based on its path. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------- | | path | string | Yes | Absolute path of the file to truncate. | | len | number | Yes | File length, in bytes, after truncation.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.truncate(path, len).then(function(){ console.info("File truncated successfully."); @@ -1257,18 +1265,18 @@ Asynchronously truncates a file based on its path. This method uses a promise to truncate(path: string, len: number, callback:AsyncCallback<void>): void -Asynchronously truncates a file based on its path. This method uses a callback to return the result. +Asynchronously truncates a file based on its path. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------- | | path | string | Yes | Absolute path of the file to truncate. | | len | number | Yes | File length, in bytes, after truncation.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file is truncated asynchronously. | -- Example +**Example** ```js fileio.truncate(path, len, function(err){ // Do something. @@ -1284,13 +1292,13 @@ Synchronously truncates a file based on the file path. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------- | | path | string | Yes | Absolute path of the file to truncate. | | len | number | No | File length, in bytes, after truncation.| -- Example +**Example** ```js fileio.truncateSync(path, len); ``` @@ -1304,22 +1312,22 @@ readText(filePath: string, options?: { encoding?: string; }): Promise<string> -Asynchronously reads the text of a file. This method uses a promise to return the result. +Asynchronously reads the text of a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------ | ---- | ---------------------------------------- | | filePath | string | Yes | Absolute path of the file to read. | | options | Object | No | The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| -- Return value +**Return value** | Type | Description | | --------------------- | ---------- | | Promise<string> | Promise used to return the content of the file read.| -- Example +**Example** ```js fileio.readText(path).then(function(str) { console.info("readText successfully:"+ str); @@ -1337,18 +1345,18 @@ readText(filePath: string, options: { encoding?: string; }, callback: AsyncCallback<string>): void -Asynchronously reads the text of a file. This method uses a callback to return the result. +Asynchronously reads the text of a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | ---------------------------------------- | | filePath | string | Yes | Absolute path of the file to read. | | options | Object | No | The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| | callback | AsyncCallback<string> | Yes | Callback invoked when the file is read asynchronously. | -- Example +**Example** ```js fileio.readText(path, function(err, str){ // Do something. @@ -1368,18 +1376,18 @@ Synchronously reads the text of a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------ | ---- | ---------------------------------------- | | filePath | string | Yes | Absolute path of the file to read. | | options | Object | No | The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| -- Return value +**Return value** | Type | Description | | ------ | -------------------- | - | string | Content of the file read.| + | string | Promise used to return the content of the file read.| -- Example +**Example** ```js let str = fileio.readTextSync(path, {position: 1, length: 3}); ``` @@ -1389,21 +1397,21 @@ Synchronously reads the text of a file. lstat(path: string): Promise<Stat> -Asynchronously obtains link status information. This method uses a promise to return the result. +Asynchronously obtains link status information. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------------- | | path | string | Yes | Absolute path of the target file, pointing to the link status.| -- Return value +**Return value** | Type | Description | | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | Promise used to return the link status obtained.| -- Example +**Example** ```js fileio.lstat(path).then(function(stat){ console.info("Link status obtained:"+ number); @@ -1417,17 +1425,17 @@ Asynchronously obtains link status information. This method uses a promise to re lstat(path:string, callback:AsyncCallback<Stat>): void -Asynchronously obtains link status information. This method uses a callback to return the result. +Asynchronously obtains link status information. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------- | ---- | ----------------- | | path | string | Yes | Absolute path of the target file, pointing to the link status.| | callback | AsyncCallback<[Stat](#stat)> | Yes | Callback invoked when the link status information is obtained asynchronously. | -- Example +**Example** ```js fileio.lstat(path, function (err, stat) { // Do something. @@ -1443,17 +1451,17 @@ Synchronously obtains link status information. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------------- | | path | string | Yes | Absolute path of the target file, pointing to the link status.| -- Return value +**Return value** | Type | Description | | ------------- | ---------- | | [Stat](#stat) | Link status obtained.| -- Example +**Example** ```js let stat = fileio.lstatSync(path); ``` @@ -1467,22 +1475,22 @@ read(buffer: ArrayBuffer, options?: { length?: number; }): Promise<ReadOut> -Asynchronously reads data from a file. This method uses a promise to return the result. +Asynchronously reads data from a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory| Description | | ------- | ----------- | ---- | ------------------------------------------------------------ | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
Constraints: offset + length <= Buffer size| -- Return value +**Return value** | Type | Description | | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | Data read.| -- Example +**Example** ```js fileio.read(new ArrayBuffer(4096)).then(function(readout){ console.info("read file data successfully"); @@ -1501,18 +1509,18 @@ read(buffer: ArrayBuffer, options: { length?: number; }, callback: AsyncCallback<ReadOut>): void -Asynchronously reads data from a file. This method uses a callback to return the result. +Asynchronously reads data from a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
Constraints: offset + length <= Buffer size| | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously from the file. | -- Example +**Example** ```js let buf = new ArrayBuffer(4096); fileio.read(buf, function (err, readOut) { @@ -1528,22 +1536,22 @@ Asynchronously reads data from a file. This method uses a callback to return the rename(oldPath: string, newPath: string): Promise<void> -Asynchronously renames a file. This method uses a promise to return the result. +Asynchronously renames a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory| Description | | ------- | ------ | ---- | ------------------------ | | oldPath | string | Yes | Absolute path of the file to rename.| | newPath | String | Yes | Absolute path of the file renamed. | -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.rename(oldPath, newPath).then(function() { console.info("rename successfully"); @@ -1557,18 +1565,18 @@ Asynchronously renames a file. This method uses a promise to return the result. rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): void -Asynchronously renames a file. This method uses a callback to return the result. +Asynchronously renames a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------- | | oldPath | string | Yes | Absolute path of the file to rename. | | newPath | String | Yes | Absolute path of the file renamed. | | Callback | AsyncCallback<void> | Yes | Callback invoked when the file is asynchronously renamed.| -- Example +**Example** ```js fileio.rename(oldPath, newPath, function(err){ }); @@ -1583,13 +1591,13 @@ Synchronously renames a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ------------ | | oldPath | string | Yes | Absolute path of the file to rename.| | newPath | String | Yes | Absolute path of the file renamed. | -- Example +**Example** ```js fileio.renameSync(oldPath, newPath); ``` @@ -1599,21 +1607,21 @@ Synchronously renames a file. fsync(fd: number): Promise<void> -Asynchronously synchronizes a file. This method uses a promise to return the result. +Asynchronously synchronizes a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to synchronize.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.fsync(fd).then(function(){ console.info("sync data successfully"); @@ -1627,17 +1635,17 @@ Asynchronously synchronizes a file. This method uses a promise to return the res fsync(fd: number, callback: AsyncCallback<void>): void -Asynchronously synchronizes a file. This method uses a callback to return the result. +Asynchronously synchronizes a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | --------------- | | fd | number | Yes | File descriptor of the file to synchronize. | | Callback | AsyncCallback<void> | Yes | Callback invoked when the file is synchronized in asynchronous mode.| -- Example +**Example** ```js fileio.fsync(fd, function(err){ // Do something. @@ -1653,12 +1661,12 @@ Synchronizes a file in synchronous mode. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to synchronize.| -- Example +**Example** ```js fileio.fyncsSync(fd); ``` @@ -1668,21 +1676,21 @@ Synchronizes a file in synchronous mode. fdatasync(fd: number): Promise<void> -Asynchronously synchronizes data in a file. This method uses a promise to return the result. +Asynchronously synchronizes data in a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to synchronize.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| -- Example +**Example** ```js fileio.fdatasync(fd).then(function(err) { console.info("sync data successfully"); @@ -1696,17 +1704,17 @@ Asynchronously synchronizes data in a file. This method uses a promise to return fdatasync(fd: number, callback:AsyncCallback<void>): void -Asynchronously synchronizes data in a file. This method uses a callback to return the result. +Asynchronously synchronizes data in a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ----------------- | | fd | number | Yes | File descriptor of the file to synchronize. | | callback | AsyncCallback <void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| -- Example +**Example** ```js fileio.fdatasync (fd, function (err) { // Do something. @@ -1722,12 +1730,12 @@ Synchronizes data in a file in synchronous mode. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to synchronize.| -- Example +**Example** ```js let stat = fileio.fdatasyncSync(fd); ``` @@ -1737,22 +1745,22 @@ Synchronizes data in a file in synchronous mode. symlink(target: string, srcPath: string): Promise<void> -Asynchronously creates a symbolic link based on a path. This method uses a promise to return the result. +Asynchronously creates a symbolic link based on a path. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ------------ | | target | string | Yes | Absolute path of the symbolic link. | | srcPath | string | Yes | Absolute path of the referenced file or directory contained in the symbolic link.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| -- Example +**Example** ```js fileio.symlink(target, srcPath).then(function() { console.info("symlink successfully"); @@ -1766,18 +1774,18 @@ Asynchronously creates a symbolic link based on a path. This method uses a promi symlink(target: string, srcPath: string, callback: AsyncCallback<void>): void -Asynchronously creates a symbolic link based on a path. This method uses a callback to return the result. +Asynchronously creates a symbolic link based on a path. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------- | | target | string | Yes | Absolute path of the symbolic link. | | srcPath | string | Yes | Absolute path of the referenced file or directory contained in the symbolic link. | | callback | AsyncCallback<void> | Yes | Callback invoked when the symbolic link is created asynchronously.| -- Example +**Example** ```js fileio.symlink(target, srcPath, function (err) { // Do something. @@ -1793,13 +1801,13 @@ Synchronously creates a symbolic link based on a specified path. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ------------ | | target | string | Yes | Absolute path of the symbolic link. | | srcPath | string | Yes | Absolute path of the referenced file or directory contained in the symbolic link.| -- Example +**Example** ```js fileio.symlinkSync(target, srcPath); ``` @@ -1809,23 +1817,23 @@ Synchronously creates a symbolic link based on a specified path. chown(path: string, uid: number, gid: number): Promise<void> -Asynchronously changes the file owner based on its path. This method uses a promise to return the result. +Asynchronously changes the file owner based on its path. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | --------------- | | path | string | Yes | Absolute path of the target file. | | uid | number | Yes | New user ID (UID). | | gid | number | Yes | New group ID (GID).| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| -- Example +**Example** ```js let stat = fileio.statSync(path); fileio.chown(path, stat.uid, stat.gid).then(function(){ @@ -1840,11 +1848,11 @@ Asynchronously changes the file owner based on its path. This method uses a prom chown(path: string, uid: number, gid: number, callback: AsyncCallback<void>): void -Asynchronously changes the file owner based on its path. This method uses a callback to return the result. +Asynchronously changes the file owner based on its path. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | --------------- | | path | string | Yes | Absolute path of the target file. | @@ -1852,7 +1860,7 @@ Asynchronously changes the file owner based on its path. This method uses a call | gid | number | Yes | New GID. | | callback | AsyncCallback<void> | Yes | Callback invoked when the file owner is changed asynchronously.| -- Example +**Example** ```js let stat = fileio.statSync(fpath) fileio.chown(path, stat.uid, stat.gid, function (err){ @@ -1869,14 +1877,14 @@ Synchronously changes the file owner based on its path. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the target file.| | uid | number | Yes | New UID. | | gid | number | Yes | New GID. | -- Example +**Example** ```js let stat = fileio.statSync(fpath) fileio.chownSync(path, stat.uid, stat.gid); @@ -1887,21 +1895,21 @@ Synchronously changes the file owner based on its path. mkdtemp(prefix: string): Promise<string> -Asynchronously creates a temporary directory. This method uses a promise to return the result. +Asynchronously creates a temporary directory. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------ | ------ | ---- | --------------------------- | | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| -- Return value +**Return value** | Name | Description | | --------------------- | ---------- | | Promise<string> | Unique path generated.| -- Example +**Example** ```js fileio.mkdtemp(path + "XXXX").then(function(path){ console.info("mkdtemp successfully:"+ path); @@ -1915,17 +1923,17 @@ Asynchronously creates a temporary directory. This method uses a promise to retu mkdtemp(prefix: string, callback: AsyncCallback<string>): void -Asynchronously creates a temporary directory. This method uses a callback to return the result. +Asynchronously creates a temporary directory. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | --------------------------- | | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | callback | AsyncCallback<string> | Yes | Callback invoked when a temporary directory is created asynchronously. | -- Example +**Example** ```js fileio.mkdtemp(path + "XXXX", function (err, res) { // Do something. @@ -1941,17 +1949,17 @@ Synchronously creates a temporary directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------ | ------ | ---- | --------------------------- | | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| -- Return value +**Return value** | Name | Description | | ------ | ---------- | | string | Unique path generated.| -- Example +**Example** ```js let res = fileio.mkdtempSync(path + "XXXX"); ``` @@ -1961,22 +1969,22 @@ Synchronously creates a temporary directory. fchmod(fd: number, mode: number): Promise<void> -Asynchronously changes the file permissions based on the file descriptor. This method uses a promise to return the result. +Asynchronously changes the file permissions based on the file descriptor. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Return value +**Return value** | Name | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| -- Example +**Example** ```js fileio.fchmod(fd, mode).then(function() { console.info("chmod successfully"); @@ -1990,18 +1998,18 @@ Asynchronously changes the file permissions based on the file descriptor. This m fchmod(fd: number, mode: number, callback: AsyncCallback<void>): void -Asynchronously changes the file permissions based on the file descriptor. This method uses a callback to return the result. +Asynchronously changes the file permissions based on the file descriptor. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| | callback | AsyncCallback <void> | Yes | Callback invoked when the file permissions are changed asynchronously. | -- Example +**Example** ```js fileio.fchmod(fd, mode, function (err) { // Do something. @@ -2017,13 +2025,13 @@ Synchronously changes the file permissions based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Example +**Example** ```js fileio.fchmodSync(fd, mode); ``` @@ -2033,22 +2041,22 @@ Synchronously changes the file permissions based on the file descriptor. createStream(path: string, mode: string): Promise<Stream> -Asynchronously opens a stream based on the file path. This method uses a promise to return the result. +Asynchronously opens a stream based on the file path. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -- Return value +**Return value** | Type | Description | | --------------------------------- | --------- | | Promise<[Stream](#stream7)> | Promise used to return the result.| -- Example +**Example** ```js fileio.createStream(path, "r+").then(function(stream){ console.info("createStream successfully"); @@ -2062,18 +2070,18 @@ Asynchronously opens a stream based on the file path. This method uses a promise createStream(path: string, mode: string, callback: AsyncCallback<Stream>): void -Asynchronously opens a stream based on the file path. This method uses a callback to return the result. +Asynchronously opens a stream based on the file path. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | --------------------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | callback | AsyncCallback<[Stream](#stream7)> | Yes | Callback invoked when the stream is open asynchronously. | -- Example +**Example** ```js fileio.createStream(path, mode, function(err, stream){ // Do something. @@ -2089,18 +2097,18 @@ Synchronously opens a stream based on the file path. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -- Return value +**Return value** | Name | Description | | ------------------ | --------- | | [Stream](#stream7) | Stream opened.| -- Example +**Example** ```js let ss = fileio.createStreamSync(path, "r+"); ``` @@ -2110,22 +2118,22 @@ Synchronously opens a stream based on the file path. fdopenStream(fd: number, mode: string): Promise<Stream> -Asynchronously opens a stream based on the file descriptor. This method uses a promise to return the result. +Asynchronously opens a stream based on the file descriptor. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -- Return value +**Return value** | Name | Description | | --------------------------------- | --------- | | Promise<[Stream](#stream7)> | Promise used to return the result.| -- Example +**Example** ```js fileio.fdopenStream(fd, mode).then(function(stream){ console.info("openStream successfully"); @@ -2139,18 +2147,18 @@ Asynchronously opens a stream based on the file descriptor. This method uses a p fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): void -Asynchronously opens a stream based on the file descriptor. This method uses a callback to return the result. +Asynchronously opens a stream based on the file descriptor. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | callback | AsyncCallback <[Stream](#stream7)> | Yes | Callback invoked when the stream is open asynchronously. | -- Example +**Example** ```js fileio.fdopenStream(fd, mode, function (err, stream) { // Do something. @@ -2166,18 +2174,18 @@ Synchronously opens a stream based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -- Return value - | Name | Description | +**Return value** + | Type | Description | | ------------------ | --------- | | [Stream](#stream7) | Stream opened.| -- Example +**Example** ```js let ss = fileio.fdopenStreamSync(fd, "r+"); ``` @@ -2187,23 +2195,23 @@ Synchronously opens a stream based on the file descriptor. fchown(fd: number, uid: number, gid: number): Promise<void> -Asynchronously changes the file owner based on the file descriptor. This method uses a promise to return the result. +Asynchronously changes the file owner based on the file descriptor. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the target file.| | uid | number | Yes | New UID. | | gid | number | Yes | New GID. | -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js let stat = fileio.statSync(path); fileio.fchown(fd, stat.uid, stat.gid).then(function() { @@ -2218,11 +2226,11 @@ Asynchronously changes the file owner based on the file descriptor. This method fchown(fd: number, uid: number, gid: number, callback: AsyncCallback<void>): void -Asynchronously changes the file owner based on the file descriptor. This method uses a callback to return the result. +Asynchronously changes the file owner based on the file descriptor. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | --------------- | | fd | number | Yes | File descriptor of the target file. | @@ -2230,7 +2238,7 @@ Asynchronously changes the file owner based on the file descriptor. This method | gid | number | Yes | New GID. | | callback | AsyncCallback<void> | Yes | Callback invoked when the file owner is changed asynchronously.| -- Example +**Example** ```js let stat = fileio.statSync(fpath); fileio.fchown(fd, stat.uid, stat.gid, function (err){ @@ -2247,14 +2255,14 @@ Synchronously changes the file owner based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the target file.| | uid | number | Yes | New UID. | | gid | number | Yes | New GID. | -- Example +**Example** ```js let stat = fileio.statSync(fpath); fileio.fchownSync(fd, stat.uid, stat.gid); @@ -2269,19 +2277,19 @@ Asynchronously changes the file owner based on the file path, changes the owner **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the target file.| | uid | number | Yes | New UID. | | gid | number | Yes | New GID. | -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js let stat = fileio.statSync(path); fileio.lchown(path, stat.uid, stat.gid).then(function() { @@ -2300,7 +2308,7 @@ Asynchronously changes the file owner based on the file path, changes the owner **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | --------------- | | path | string | Yes | Absolute path of the target file. | @@ -2308,7 +2316,7 @@ Asynchronously changes the file owner based on the file path, changes the owner | gid | number | Yes | New GID. | | callback | AsyncCallback<void> | Yes | Callback invoked when the file owner is changed asynchronously.| -- Example +**Example** ```js let stat = fileio.statSync(path); fileio.lchown(path, stat.uid, stat.gid, function (err){ @@ -2325,14 +2333,14 @@ Synchronously changes the file owner based on the file path and changes the owne **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the target file.| | uid | number | Yes | New UID. | | gid | number | Yes | New GID. | -- Example +**Example** ```js let stat = fileio.statSync(path); fileio.lchownSync(path, stat.uid, stat.gid); @@ -2343,23 +2351,23 @@ Synchronously changes the file owner based on the file path and changes the owne createWatcher(filename: string, events: number, callback: AsyncCallback<number>): Watcher -Asynchronously listens for the changes of a file or directory. This method uses a callback to return the result. +Asynchronously listens for the changes of a file or directory. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | --------------------------------- | ---- | ---------------------------------------- | | filename | string | Yes | Absolute path of the target file. | | events | Number | Yes | - **1**: The file or directory is renamed.
- **2**: The file or directory is modified.
- **3**: The file or directory is modified and renamed.| | callback | AsyncCallback<number > | Yes | Called each time a change is detected. | -- Return value +**Return value** | Name | Description | | -------------------- | ---------- | | [Watcher](#watcher7) | Instance for listening for a file change event.| -- Example +**Example** ```js fileio.createWatcher(filename, events, function(watcher){ // Do something. @@ -2412,12 +2420,12 @@ Checks whether this file is a block special file. A block special file supports **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ---------------- | | boolean | Whether the file is a block special file.| -- Example +**Example** ```js let isBLockDevice = fileio.statSync(path).isBlockDevice(); ``` @@ -2431,12 +2439,12 @@ Checks whether this file is a character special file. A character special file s **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ----------------- | | boolean | Whether the file is a character special file.| -- Example +**Example** ```js let isCharacterDevice = fileio.statSync(path).isCharacterDevice(); ``` @@ -2450,12 +2458,12 @@ Checks whether this file is a directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ------------- | | boolean | Whether the file is a directory.| -- Example +**Example** ```js let isDirectory = fileio.statSync(path).isDirectory(); ``` @@ -2469,12 +2477,12 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------------- | | boolean | Whether the file is an FIFO.| -- Example +**Example** ```js let isFIFO = fileio.statSync(path).isFIFO(); ``` @@ -2488,12 +2496,12 @@ Checks whether this file is a regular file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------- | | boolean | Whether the file is a regular file.| -- Example +**Example** ```js let isFile = fileio.statSync(fpath).isFile(); ``` @@ -2507,12 +2515,12 @@ Checks whether this file is a socket. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | -------------- | | boolean | Whether the file is a socket.| -- Example +**Example** ```js let isSocket = fileio.statSync(path).isSocket(); ``` @@ -2526,12 +2534,12 @@ Checks whether this file is a symbolic link. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------- | | boolean | Whether the file is a symbolic link.| -- Example +**Example** ```js let isSymbolicLink = fileio.statSync(path).isSymbolicLink(); ``` @@ -2546,11 +2554,11 @@ Listens for the changes of a file. You can call the **Watcher.stop()** method sy stop(): Promise<void> -Asynchronously stops **watcher**. This method uses a promise to return the result. +Asynchronously stops **watcher**. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Example +**Example** ```js fileio.stop(); ``` @@ -2560,16 +2568,16 @@ Asynchronously stops **watcher**. This method uses a promise to return the resul stop(callback: AsyncCallback<void>): void -Asynchronously stops **watcher**. This method uses a callback to return the result. +Asynchronously stops **watcher**. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------- | | callback | AsyncCallback<void> | Yes | Callback invoked when **watcher** is stopped asynchronously.| -- Example +**Example** ```js fileio.stop(function(err){ // Do something. @@ -2587,16 +2595,16 @@ File stream. Before calling a method of the **Stream** class, use the **createSt close(): Promise<void> -Asynchronously closes the stream. This method uses a promise to return the result. +Asynchronously closes the stream. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------------------- | ------------- | | Promise<void> | Promise used to return the stream close result.| -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.close().then(function(){ @@ -2611,16 +2619,16 @@ Asynchronously closes the stream. This method uses a promise to return the resul close(callback: AsyncCallback<void>): void -Asynchronously closes the stream. This method uses a callback to return the result. +Asynchronously closes the stream. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------- | | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.close(function (err) { @@ -2637,7 +2645,7 @@ Synchronously closes the stream. **System capability**: SystemCapability.FileManagement.File.FileIO -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.closeSync(); @@ -2648,16 +2656,16 @@ Synchronously closes the stream. flush(): Promise<void> -Asynchronously flushes the stream. This method uses a promise to return the result. +Asynchronously flushes the stream. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------------------- | ------------- | | Promise<void> | Promise used to return the stream flushing result.| -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.flush().then(function (){ @@ -2672,16 +2680,16 @@ Asynchronously flushes the stream. This method uses a promise to return the resu flush(callback: AsyncCallback<void>): void -Asynchronously flushes the stream. This method uses a callback to return the result. +Asynchronously flushes the stream. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | -------------- | | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is asynchronously flushed.| -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.flush(function (err) { @@ -2698,7 +2706,7 @@ Synchronously flushes the stream. **System capability**: SystemCapability.FileManagement.File.FileIO -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.flushSync(); @@ -2714,22 +2722,22 @@ write(buffer: ArrayBuffer | string, options?: { encoding?: string; }): Promise<number> -Asynchronously writes data into the stream. This method uses a promise to return the result. +Asynchronously writes data into the stream. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size | -- Return value +**Return value** | Type | Description | | --------------------- | -------- | | Promise<number> | Length of the data written in the file.| -- Example +**Example** ```js let ss= fileio.createStreamSync(fpath, "r+"); ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number){ @@ -2749,18 +2757,18 @@ write(buffer: ArrayBuffer | string, options: { encoding?: string; }, callback: AsyncCallback<number>): void -Asynchronously writes data into the stream. This method uses a callback to return the result. +Asynchronously writes data into the stream. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size| | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | -- Example +**Example** ```js let ss= fileio.createStreamSync(fpath, "r+"); ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) { @@ -2785,18 +2793,18 @@ Synchronously writes data into the stream. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size | -- Return value +**Return value** | Type | Description | | ------ | -------- | | number | Length of the data written in the file.| -- Example +**Example** ```js let ss= fileio.createStreamSync(fpath,"r+"); let num = ss.writeSync("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}); @@ -2811,22 +2819,22 @@ read(buffer: ArrayBuffer, options?: { length?: number; }): Promise<ReadOut> -Asynchronously reads data from the stream. This method uses a promise to return the result. +Asynchronously reads data from the stream. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ----------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size | -- Return value +**Return value** | Type | Description | | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | Data read.| -- Example +**Example** ```js let ss = fileio.createStreamSync(fpath, "r+"); ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readout){ @@ -2846,18 +2854,18 @@ read(buffer: ArrayBuffer, options: { length?: number; }, callback: AsyncCallback<ReadOut>): void -Asynchronously reads data from the stream. This method uses a callback to return the result. +Asynchronously reads data from the stream. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size | | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when data is read asynchronously from the stream. | -- Example +**Example** ```js let ss = fileio.createStreamSync(fpath, "r+"); ss.read(new ArrayBuffer(4096),{offset: 1, length: 5, position: 5},function (err, readOut) { @@ -2881,18 +2889,20 @@ Synchronously reads data from the stream. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** + | Name | Type | Mandatory | Description | | ------- | ----------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size | + +**Return value** -- Return value | Type | Description | | ------ | -------- | | number | Length of the data read.| -- Example +**Example** ```js let ss = fileio.createStreamSync(fpath, "r+"); let num = ss.readSync(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}); @@ -2908,16 +2918,16 @@ Manages directories. Before calling a method of the **Dir** class, use the [open read(): Promise<Dirent> -Asynchronously reads the next directory entry. This method uses a promise to return the result. +Asynchronously reads the next directory entry. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | -------------------------------- | ------------- | | Promise<[Dirent](#dirent)> | Directory entry that is read asynchronously.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); dir.read().then(function (dirent){ @@ -2932,16 +2942,16 @@ Asynchronously reads the next directory entry. This method uses a promise to ret read(callback: AsyncCallback<Dirent>): void -Asynchronously reads the next directory entry. This method uses a callback to return the result. +Asynchronously reads the next directory entry. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | -------------------------------------- | ---- | ---------------- | | callback | AsyncCallback<[Dirent](#dirent)> | Yes | Callback invoked when the next directory entry is asynchronously read.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); dir.read(function (err, dirent) { @@ -2961,12 +2971,12 @@ Synchronously reads the next directory entry. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ----------------- | -------- | | [Dirent](#dirent) | Directory entry read.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let dirent = dir.readSync(); @@ -2981,7 +2991,7 @@ Closes a directory. After a directory is closed, the file descriptor in Dir will **System capability**: SystemCapability.FileManagement.File.FileIO -- Example +**Example** ```js let dir = fileio.opendirSync(path); dir.closeSync(); @@ -3009,12 +3019,12 @@ Checks whether the current directory entry is a block special file. A block spec **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ---------------- | | boolean | Whether the directory entry is a block special file.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isBLockDevice = dir.readSync().isBlockDevice(); @@ -3029,12 +3039,12 @@ Checks whether a directory entry is a character special file. A character specia **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ----------------- | | boolean | Whether the directory entry is a character special file.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isCharacterDevice = dir.readSync().isCharacterDevice(); @@ -3049,12 +3059,12 @@ Checks whether a directory entry is a directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ------------- | | boolean | Whether the directory entry is a directory.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isDirectory = dir.readSync().isDirectory(); @@ -3069,12 +3079,12 @@ Checks whether the current directory entry is a named pipe (or FIFO). Named pipe **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------- | | boolean | Whether the directory entry is a FIFO.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isFIFO = dir.readSync().isFIFO(); @@ -3089,12 +3099,12 @@ Checks whether a directory entry is a regular file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------- | | boolean | Whether the directory entry is a regular file.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isFile = dir.readSync().isFile(); @@ -3109,12 +3119,12 @@ Checks whether a directory entry is a socket. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | -------------- | | boolean | Whether the directory entry is a socket.| -- Example +**Example** ```js let dir = fileio.opendirSync(dpath); let isSocket = dir.readSync().isSocket(); @@ -3129,12 +3139,12 @@ Checks whether a directory entry is a symbolic link. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------- | | boolean | Whether the directory entry is a symbolic link.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isSymbolicLink = dir.readSync().isSymbolicLink(); diff --git a/en/application-dev/reference/apis/js-apis-formextension.md b/en/application-dev/reference/apis/js-apis-formextension.md index f7302bbc65e031f06b732d519c8320172278ab83..dea964de0b45fdeca88defea6cb06cd70d8eb43a 100644 --- a/en/application-dev/reference/apis/js-apis-formextension.md +++ b/en/application-dev/reference/apis/js-apis-formextension.md @@ -1,6 +1,6 @@ # FormExtension -> ![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 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. Provides **FormExtension** APIs. @@ -35,7 +35,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been | Name| Type | Mandatory| Description | | ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | - | want | [Want](js-apis-featureAbility.md#want) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| + | want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-formhost.md b/en/application-dev/reference/apis/js-apis-formhost.md index 0cf54af57b8aacb91bb487e49bf8a74074ecc8da..0c01c3bcbca95cfd5fd9b2b5c42f06faa1b83fbb 100644 --- a/en/application-dev/reference/apis/js-apis-formhost.md +++ b/en/application-dev/reference/apis/js-apis-formhost.md @@ -1,6 +1,6 @@ # FormHost -> ![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. Provides APIs related to the widget host. @@ -23,24 +23,24 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void; Deletes a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formId | string | Yes | ID of a widget.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formId = "12400633174999288"; formHost.deleteForm(formId, (error, data) => { - if (error) { - console.log('formHost deleteForm, error:' + error.code); + if (error.code) { + console.log('formHost deleteForm, error:' + JSON.stringify(error)); } }); ``` @@ -51,7 +51,7 @@ deleteForm(formId: string): Promise<void>; Deletes a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -71,8 +71,10 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; - formHost.deleteForm(formId).catch((error) => { - console.log('formProvider deleteForm, error:' + JSON.stringify(error)); + formHost.deleteForm(formId).then(() => { + console.log('formHost deleteForm success'); + }).catch((error) => { + console.log('formHost deleteForm, error:' + JSON.stringify(error)); }); ``` @@ -82,24 +84,24 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void; Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager still retains the widget cache and storage information. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formId | string | Yes | ID of a widget.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formId = "12400633174999288"; formHost.releaseForm(formId, (error, data) => { - if (error) { - console.log('formHost releaseForm, error:' + error.code); + if (error.code) { + console.log('formHost releaseForm, error:' + JSON.stringify(error)); } }); ``` @@ -108,27 +110,27 @@ SystemCapability.Ability.Form releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void; -Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and determines whether to retain the cache information based on the setting. +Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name | Type | Mandatory| Description | - | -------------- | ------ | ---- | ----------- | - | formId | string | Yes | ID of a widget. | - | isReleaseCache | boolean | Yes | Whether to release the cache.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------------- | ------ | ---- | ----------- | +| formId | string | Yes | ID of a widget. | +| isReleaseCache | boolean | Yes | Whether to release the cache.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formId = "12400633174999288"; formHost.releaseForm(formId, true, (error, data) => { - if (error) { - console.log('formHost releaseForm, error:' + error.code); + if (error.code) { + console.log('formHost releaseForm, error:' + JSON.stringify(error)); } }); ``` @@ -137,9 +139,9 @@ SystemCapability.Ability.Form releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>; -Releases a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and determines whether to retain the cache information based on the setting. +Releases a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -160,8 +162,10 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; - formHost.releaseForm(formId, true).catch((error) => { - console.log('formProvider releaseForm, error:' + JSON.stringify(error)); + formHost.releaseForm(formId, true).then(() => { + console.log('formHost releaseForm success'); + }).catch((error) => { + console.log('formHost releaseForm, error:' + JSON.stringify(error)); }); ``` @@ -177,18 +181,18 @@ SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formId | string | Yes | ID of a widget.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formId = "12400633174999288"; formHost.requestForm(formId, (error, data) => { - if (error) { - console.log('formHost requestForm, error:' + error.code); + if (error.code) { + console.log('formHost requestForm, error:' + JSON.stringify(error)); } }); ``` @@ -219,8 +223,10 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; - formHost.requestForm(formId).catch((error) => { - console.log('formProvider requestForm, error:' + JSON.stringify(error)); + formHost.requestForm(formId).then(() => { + console.log('formHost requestForm success'); + }).catch((error) => { + console.log('formHost requestForm, error:' + JSON.stringify(error)); }); ``` @@ -230,24 +236,24 @@ castTempForm(formId: string, callback: AsyncCallback<void>): void; Converts a temporary widget to a normal one. This API uses an asynchronous callback to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formId | string | Yes | ID of a widget.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formId = "12400633174999288"; formHost.castTempForm(formId, (error, data) => { - if (error) { - console.log('formHost castTempForm, error:' + error.code); + if (error.code) { + console.log('formHost castTempForm, error:' + JSON.stringify(error)); } }); ``` @@ -258,7 +264,7 @@ castTempForm(formId: string): Promise<void>; Converts a temporary widget to a normal one. This API uses a promise to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -278,54 +284,56 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; - formHost.castTempForm(formId).catch((error) => { - console.log('formProvider castTempForm, error:' + JSON.stringify(error)); + formHost.castTempForm(formId).then(() => { + console.log('formHost castTempForm success'); + }).catch((error) => { + console.log('formHost castTempForm, error:' + JSON.stringify(error)); }); ``` ## notifyVisibleForms -notifyVisibleForms(formId: string, callback: AsyncCallback<void>): void; +notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void; Instructs the widget framework to make a widget visible. This API uses an asynchronous callback to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs. | +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formId = "12400633174999288"; formHost.notifyVisibleForms(formId, (error, data) => { - if (error) { - console.log('formHost notifyVisibleForms, error:' + error.code); + if (error.code) { + console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); } }); ``` ## notifyVisibleForms -notifyVisibleForms(formId: string): Promise<void>; +notifyVisibleForms(formIds: Array<string>): Promise<void>; Instructs the widget framework to make a widget visible. This API uses a promise to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs.| **Return value** @@ -337,54 +345,56 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; - formHost.notifyVisibleForms(formId).catch((error) => { - console.log('formProvider notifyVisibleForms, error:' + JSON.stringify(error)); + formHost.notifyVisibleForms(formId).then(() => { + console.log('formHost notifyVisibleForms success'); + }).catch((error) => { + console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); }); ``` ## notifyInvisibleForms -notifyInvisibleForms(formId: string, callback: AsyncCallback<void>): void; +notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void; Instructs the widget framework to make a widget invisible. This API uses an asynchronous callback to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs. | +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formId = "12400633174999288"; formHost.notifyInvisibleForms(formId, (error, data) => { - if (error) { - console.log('formHost notifyInvisibleForms, error:' + error.code); + if (error.code) { + console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); } }); ``` ## notifyInvisibleForms -notifyInvisibleForms(formId: string): Promise<void>; +notifyInvisibleForms(formIds: Array<string>): Promise<void>; Instructs the widget framework to make a widget invisible. This API uses a promise to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs.| **Return value** @@ -396,54 +406,56 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; - formHost.notifyInvisibleForms(formId).catch((error) => { - console.log('formProvider notifyInvisibleForms, error:' + JSON.stringify(error)); + formHost.notifyInvisibleForms(formId).then(() => { + console.log('formHost notifyInvisibleForms success'); + }).catch((error) => { + console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); }); ``` ## enableFormsUpdate -enableFormsUpdate(formId: string, callback: AsyncCallback<void>): void; +enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void; -Instructs the widget framework to make a widget to be updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider. +Instructs the widget framework to make a widget updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs. | +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formId = "12400633174999288"; formHost.enableFormsUpdate(formId, (error, data) => { - if (error) { - console.log('formHost enableFormsUpdate, error:' + error.code); + if (error.code) { + console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); } }); ``` ## enableFormsUpdate -enableFormsUpdate(formId: string): Promise<void>; +enableFormsUpdate(formIds: Array<string>): Promise<void>; -Instructs the widget framework to make a widget to be updatable. This API uses a promise to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider. +Instructs the widget framework to make a widget updatable. This API uses a promise to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs.| **Return value** @@ -455,54 +467,56 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; - formHost.enableFormsUpdate(formId).catch((error) => { - console.log('formProvider enableFormsUpdate, error:' + JSON.stringify(error)); + formHost.enableFormsUpdate(formId).then(() => { + console.log('formHost enableFormsUpdate success'); + }).catch((error) => { + console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); }); ``` ## disableFormsUpdate -disableFormsUpdate(formId: string, callback: AsyncCallback<void>): void; +disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void; -Instructs the widget framework to make a widget not to be updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget is in the disabled state and cannot receive updates from the widget provider. +Instructs the widget framework to make a widget not updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget cannot receive updates from the widget provider. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs. | +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formId = "12400633174999288"; formHost.disableFormsUpdate(formId, (error, data) => { - if (error) { - console.log('formHost disableFormsUpdate, error:' + error.code); + if (error.code) { + console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); } }); ``` ## disableFormsUpdate -disableFormsUpdate(formId: string): Promise<void>; +disableFormsUpdate(formIds: Array<string>): Promise<void>; -Instructs the widget framework to make a widget not to be updatable. This API uses a promise to return the result. After this API is called, the widget is in the disabled state and cannot receive updates from the widget provider. +Instructs the widget framework to make a widget not updatable. This API uses a promise to return the result. After this API is called, the widget cannot receive updates from the widget provider. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs.| **Return value** @@ -514,8 +528,10 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; - formHost.disableFormsUpdate(formId).catch((error) => { - console.log('formProvider disableFormsUpdate, error:' + JSON.stringify(error)); + formHost.disableFormsUpdate(formId).then(() => { + console.log('formHost disableFormsUpdate success'); + }).catch((error) => { + console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); }); ``` @@ -525,23 +541,23 @@ isSystemReady(callback: AsyncCallback<void>): void; Checks whether the system is ready. This API uses an asynchronous callback to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formId = "12400633174999288"; formHost.isSystemReady((error, data) => { - if (error) { - console.log('formHost isSystemReady, error:' + error.code); + if (error.code) { + console.log('formHost isSystemReady, error:' + JSON.stringify(error)); } }); ``` @@ -552,7 +568,7 @@ isSystemReady(): Promise<void>; Checks whether the system is ready. This API uses a promise to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -566,8 +582,10 @@ SystemCapability.Ability.Form ```js var formId = "12400633174999288"; - formHost.isSystemReady().catch((error) => { - console.log('formProvider isSystemReady, error:' + JSON.stringify(error)); + formHost.isSystemReady().then(() => { + console.log('formHost isSystemReady success'); + }).catch((error) => { + console.log('formHost isSystemReady, error:' + JSON.stringify(error)); }); ``` @@ -577,7 +595,7 @@ getAllFormsInfo(callback: AsyncCallback<Array<FormInfo>>): void; Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -591,8 +609,10 @@ SystemCapability.Ability.Form ```js formHost.getAllFormsInfo((error, data) => { - if (error) { - console.log('formHost getAllFormsInfo, error:' + error.code); + if (error.code) { + console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data)); } }); ``` @@ -603,7 +623,7 @@ getAllFormsInfo(): Promise<Array<FormInfo>>; Obtains the widget information provided by all applications on the device. This API uses a promise to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -616,8 +636,10 @@ SystemCapability.Ability.Form **Example** ```js - formHost.getAllFormsInfo().catch((error) => { - console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error)); + formHost.getAllFormsInfo().then((data) => { + console.log('formHost getAllFormsInfo data:' + JSON.stringify(data)); + }).catch((error) => { + console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error)); }); ``` @@ -627,7 +649,7 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<FormInfo> Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -641,9 +663,11 @@ SystemCapability.Ability.Form **Example** ```js - formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => { - if (error) { - console.log('formHost getFormsInfo, error:' + error.code); + formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => { + if (error.code) { + console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); } }); ``` @@ -654,7 +678,7 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback< Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -669,9 +693,11 @@ SystemCapability.Ability.Form **Example** ```js - formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => { - if (error) { - console.log('formHost getFormsInfo, error:' + error.code); + formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => { + if (error.code) { + console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); + } else { + console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); } }); ``` @@ -682,7 +708,7 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<FormI Obtains the widget information provided by a given application on the device. This API uses a promise to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -702,8 +728,10 @@ SystemCapability.Ability.Form **Example** ```js - formHost.getAllFormsInfo().catch((error) => { - console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error)); + formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => { + console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); + }).catch((error) => { + console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); }); ``` @@ -713,43 +741,45 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb Deletes invalid widgets from the list. This API uses an asynchronous callback to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | Yes | List of widget IDs.| - | callback | AsyncCallback<number> | Yes| Callback used to return the number of widgets deleted.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of valid widget IDs.| +| callback | AsyncCallback<number> | Yes| Callback used to return the number of widgets deleted.| **Example** ```js var formIds = new Array("12400633174999288", "12400633174999289"); formHost.deleteInvalidForms(formIds, (error, data) => { - if (error) { - console.log('formHost deleteInvalidForms, error:' + error.code); + if (error.code) { + console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); + } else { + console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); } }); ``` ## deleteInvalidForms -function deleteInvalidForms(formIds: Array<string>): Promise<number>; +function deleteInvalidForms(formIds: Array<string>): Promise<number>; Deletes invalid widgets from the list. This API uses a promise to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | Yes | List of widget IDs.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of valid widget IDs.| **Return value** @@ -761,8 +791,10 @@ SystemCapability.Ability.Form ```js var formIds = new Array("12400633174999288", "12400633174999289"); - formHost.deleteInvalidForms(formIds).catch((error) => { - console.log('formProvider deleteInvalidForms, error:' + JSON.stringify(error)); + formHost.deleteInvalidForms(formIds).then((data) => { + console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); + }).catch((error) => { + console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); }); ``` @@ -772,7 +804,7 @@ acquireFormState(want: Want, callback: AsyncCallback<FormStateInfo>): void Obtains the widget state. This API uses an asynchronous callback to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -780,7 +812,7 @@ SystemCapability.Ability.Form | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------- | -| want | [Want](js-apis-featureAbility.md#want) | Yes | **Want** information carried to query the widget state.| +| want | [Want](js-apis-application-Want.md) | Yes | **Want** information carried to query the widget state.| | callback | AsyncCallback<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | Yes| Callback used to return the widget state.| **Example** @@ -792,8 +824,10 @@ SystemCapability.Ability.Form "abilityName": "com.extreme.test.MainAbility" }; formHost.acquireFormState(want, (error, data) => { - if (error) { - console.log('formHost acquireFormState, error:' + error.code); + if (error.code) { + console.log('formHost acquireFormState, error:' + JSON.stringify(error)); + } else { + console.log('formHost acquireFormState, data:' + JSON.stringify(data)); } }); ``` @@ -806,9 +840,9 @@ Obtains the widget state. This API uses a promise to return the result. **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | Yes | List of widget IDs.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| want | [Want](js-apis-application-Want.md) | Yes | **Want** information carried to query the widget state.| **Return value** @@ -816,7 +850,7 @@ Obtains the widget state. This API uses a promise to return the result. | :------------ | :---------------------------------- | | Promise<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | Promise used to return the widget state.| -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -828,8 +862,10 @@ SystemCapability.Ability.Form "bundleName": "com.extreme.test", "abilityName": "com.extreme.test.MainAbility" }; - formHost.acquireFormState(want).catch((error) => { - console.log('formProvider acquireFormState, error:' + JSON.stringify(error)); + formHost.acquireFormState(want).then((data) => { + console.log('formHost acquireFormState, data:' + JSON.stringify(data)); + }).catch((error) => { + console.log('formHost acquireFormState, error:' + JSON.stringify(error)); }); ``` @@ -839,52 +875,50 @@ on(type: "formUninstall", callback: Callback<string>): void; Subscribes to widget uninstall events. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | type | string | Yes | Type of event to subscribe to. The value **formUninstall** indicates a widget uninstallation event.| - | callback | Callback<string> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| type | string | Yes | Type of event to subscribe to. The value **formUninstall** indicates a widget uninstallation event.| +| callback | Callback<string> | Yes| Callback used for event subscription.| **Example** ```js - formHost.on("formUninstall", (error, data) => { - if (error) { - console.log('formHost on formUninstall, error:' + error.code); - } - }); + let callback = function(formId) { + console.log('formHost on formUninstall, formId:' + formId); + } + formHost.on("formUninstall", callback); ``` ## off("formUninstall") -off(type: "formUninstall", callback: Callback<string>): void; +off(type: "formUninstall", callback?: Callback<string>): void; Unsubscribes from widget uninstall events. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | type | string | Yes | Type of event to unsubscribe from. The value **formUninstall** indicates a widget uninstallation event.| - | callback | Callback<string> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| type | string | Yes | Type of event to subscribe to. The value **formUninstall** indicates a widget uninstallation event.| +| callback | Callback<string> | No| Callback used for event unsubscription. If it is left unspecified, it indicates the callback for all the events that have been subscribed.| **Example** ```js - formHost.off("formUninstall", (error, data) => { - if (error) { - console.log('formHost off formUninstall, error:' + error.code); - } - }); + let callback = function(formId) { + console.log('formHost on formUninstall, formId:' + formId); + } + formHost.off("formUninstall", callback); ``` ## notifyFormsVisible @@ -893,25 +927,25 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A Instructs the widgets to make themselves visible. This API uses an asynchronous callback to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | Yes | List of widget IDs.| - | isVisible | boolean | Yes | Whether to be visible.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs.| +| isVisible | boolean | Yes | Whether to be visible.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formIds = new Array("12400633174999288", "12400633174999289"); formHost.notifyFormsVisible(formIds, true, (error, data) => { - if (error) { - console.log('formHost notifyFormsVisible, error:' + error.code); + if (error.code) { + console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); } }); ``` @@ -922,7 +956,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise< Instructs the widgets to make themselves visible. This API uses a promise to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -943,8 +977,10 @@ SystemCapability.Ability.Form ```js var formIds = new Array("12400633174999288", "12400633174999289"); - formHost.notifyFormsVisible(formIds, true).catch((error) => { - console.log('formProvider notifyFormsVisible, error:' + JSON.stringify(error)); + formHost.notifyFormsVisible(formIds, true).then(() => { + console.log('formHost notifyFormsVisible success'); + }).catch((error) => { + console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); }); ``` @@ -952,27 +988,27 @@ SystemCapability.Ability.Form notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void; -Instructs the widgets to enable or disable update. This API uses an asynchronous callback to return the result. +Instructs the widgets to enable or disable updates. This API uses an asynchronous callback to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | Yes | List of widget IDs.| - | isEnableUpdate | boolean | Yes | Whether to enable update.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs.| +| isEnableUpdate | boolean | Yes | Whether to enable update.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var formIds = new Array("12400633174999288", "12400633174999289"); formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => { - if (error) { - console.log('formHost notifyFormsEnableUpdate, error:' + error.code); + if (error.code) { + console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); } }); ``` @@ -981,9 +1017,9 @@ SystemCapability.Ability.Form notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void>; -Instructs the widgets to enable or disable update. This API uses a promise to return the result. +Instructs the widgets to enable or disable updates. This API uses a promise to return the result. -**System capability**: +**System capability** SystemCapability.Ability.Form @@ -1004,7 +1040,9 @@ SystemCapability.Ability.Form ```js var formIds = new Array("12400633174999288", "12400633174999289"); - formHost.notifyFormsEnableUpdate(formIds, true).catch((error) => { - console.log('formProvider notifyFormsEnableUpdate, error:' + JSON.stringify(error)); + formHost.notifyFormsEnableUpdate(formIds, true).then(() => { + console.log('formHost notifyFormsEnableUpdate success'); + }).catch((error) => { + console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-hiappevent.md b/en/application-dev/reference/apis/js-apis-hiappevent.md index 101016801113d14a03fae1cd89e5196668de0e4d..f75b45946a8f5aa6541ce502c7ff58673ecd4e8a 100644 --- a/en/application-dev/reference/apis/js-apis-hiappevent.md +++ b/en/application-dev/reference/apis/js-apis-hiappevent.md @@ -1,6 +1,6 @@ # HiAppEvent -> ![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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -23,10 +23,10 @@ Writes event information to the event file of the current day. This API supports | Name | Type | Mandatory| Description | | --------- | ------------------------- | ---- | ------------------------------------------------------------ | -| eventName | string | Yes | App event name.
You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter.| +| eventName | string | Yes | App event name.
You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter. | | eventType | [EventType](#eventtype) | Yes | Application event type. | -| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.
- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).
- The number of event parameters must be less than or equal to 32.
- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).
- A string value can contain a maximum of 8*1024 characters.
- An array value can contain a maximum of 100 elements. Excess elements will be truncated.| -| callback | AsyncCallback<void> | No | Callback used to process the received return value.
-  Value **0** indicates that the event verification is successful, and the event will be written to the event file asynchronously.
-  A value greater than **0** indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored.
-  A value smaller than **0** indicates that the event verification fails, and the event will not be written to the event file.| +| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.
- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).
- The number of event parameters must be less than or equal to 32.
- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).
- A string value can contain a maximum of 8*1024 characters.
- An array value can contain a maximum of 100 elements. Excess elements will be truncated. | +| callback | AsyncCallback<void> | No | Callback used to process the received return value.
-  Value **0** indicates that the event verification is successful, and the event will be written to the event file asynchronously.
-  A value greater than **0** indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored.
-  A value smaller than **0** indicates that the event verification fails, and the event will not be written to the event file. | **Example** @@ -56,15 +56,15 @@ Writes event information to the event file of the current day. This API supports | Name | Type | Mandatory| Description | | --------- | ----------------------- | ---- | ------------------------------------------------------------ | -| eventName | string | Yes | App event name.
You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter.| +| eventName | string | Yes | App event name.
You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter. | | eventType | [EventType](#eventtype) | Yes | Application event type. | -| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.
- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).
- The number of event parameters must be less than or equal to 32.
- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).
- A string value can contain a maximum of 8*1024 characters.
- An array value can contain a maximum of 100 elements. Excess elements will be truncated.| +| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.
- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).
- The number of event parameters must be less than or equal to 32.
- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).
- A string value can contain a maximum of 8*1024 characters.
- An array value can contain a maximum of 100 elements. Excess elements will be truncated. | **Return value** | Type | Description | | ------------------- | ------------------------------------------------------------ | -| Promise<void> | Promise used to process the callback in the then() and catch() methods when event writing succeeded or failed.| +| Promise<void> | Promise used to process the callback in the then() and catch() methods when event writing succeeded or failed. | **Example** @@ -92,13 +92,13 @@ Configures the application event logging function, such as setting the event log | Name| Type | Mandatory| Description | | ------ | ----------------------------- | ---- | ------------------------ | -| config | [ConfigOption](#configoption) | Yes | Configuration items for application event logging.| +| config | [ConfigOption](#configoption) | Yes | Configuration items for application event logging. | **Return value** | Type | Description | | ------- | ----------------------------------------------------------- | -| boolean | Returns **true** if the configuration is successful; returns **false** otherwise.| +| boolean | Returns **true** if the configuration is successful; returns **false** otherwise. | **Example** ```js @@ -122,8 +122,8 @@ Provides the configuration items for application event logging. | Name | Type | Mandatory| Description | | ---------- | ------- | ---- | ------------------------------------------------------------ | -| disable | boolean | No | Application event logging switch. The value true means to disable the application event logging function, and the value false means the opposite.| -| maxStorage | string | No | Maximum size of the event file storage directory. The default value is **10M**. If the specified size is exceeded, the oldest event logging files in the storage directory will be deleted to free up space.| +| disable | boolean | No | Application event logging switch. The value true means to disable the application event logging function, and the value false means the opposite. | +| maxStorage | string | No | Maximum size of the event file storage directory. The default value is **10M**. If the specified size is exceeded, the oldest event logging files in the storage directory will be deleted to free up space. | ## EventType @@ -150,7 +150,7 @@ Provides constants that define the names of all predefined events. | ------------------------- | -------- | ---- | ---- | -------------------- | | USER_LOGIN | string | Yes | No | User login event. | | USER_LOGOUT | string | Yes | No | User logout event. | -| DISTRIBUTED_SERVICE_START | string | Yes | No | Distributed service startup event.| +| DISTRIBUTED_SERVICE_START | string | Yes | No | Distributed service startup event. | ## Param @@ -159,8 +159,8 @@ Provides constants that define the names of all predefined event parameters. **System capability**: SystemCapability.HiviewDFX.HiAppEvent -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable | Writable | Description | | ------------------------------- | -------- | ---- | ---- | ------------------ | | USER_ID | string | Yes | No | Custom user ID. | -| DISTRIBUTED_SERVICE_NAME | string | Yes | No | Distributed service name. | -| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Yes | No | Distributed service instance ID.| +| DISTRIBUTED_SERVICE_NAME | string | Yes | No | Distributed service name. | +| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Yes | No | Distributed service instance ID. | \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-hichecker.md b/en/application-dev/reference/apis/js-apis-hichecker.md index 521eb16bc35e23985b1c29cd20c7be5306fe1ce3..914533beb47d9d4505fa7624d06f89f7a1e45984 100644 --- a/en/application-dev/reference/apis/js-apis-hichecker.md +++ b/en/application-dev/reference/apis/js-apis-hichecker.md @@ -1,6 +1,6 @@ # HiChecker -> **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. @@ -22,7 +22,7 @@ Provides the constants of all rule types. | RULE\_CAUTION\_PRINT\_LOG | BigInt | Alarm rule, which is programmed to print a log when an alarm is generated. | | RULE\_CAUTION\_TRIGGER\_CRASH | BigInt | Alarm rule, which is programmed to force the application to exit when an alarm is generated. | | RULE\_THREAD\_CHECK\_SLOW\_PROCESS | BigInt | Caution rule, which is programmed to detect whether any time-consuming function is invoked. | -| RULE\_CHECK\_SLOW\_EVENT | BigInt | Caution rule, which is programmed to detect whether the event distribution or processing time has exceeded the specified time threshold.| +| RULE\_CHECK\_SLOW\_EVENT | BigInt | Caution rule, which is programmed to detect whether the event distribution or processing time has exceeded the specified time threshold. | | RULE\_CHECK\_ABILITY\_CONNECTION\_LEAK| BigInt | Caution rule, which is programmed to detect whether ability leakage has occurred. | @@ -36,9 +36,9 @@ Adds one or more rules. HiChecker detects unexpected operations or gives feedbac **Parameters** -| Name| Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ------ | ------ | ---- | ---------------- | -| rule | BigInt | Yes | Rule to be added.| +| rule | BigInt | Yes | Rule to be added. | **Example** @@ -61,9 +61,9 @@ Removes one or more rules. The removed rules will become ineffective. **Parameters** -| Name| Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ------ | ------ | ---- | ---------------- | -| rule | BigInt | Yes | Rule to be removed.| +| rule | BigInt | Yes | Rule to be removed. | **Example** @@ -88,7 +88,7 @@ Obtains a collection of thread, process, and alarm rules that have been added. | Type | Description | | ------ | ---------------------- | -| BigInt | Collection of added rules.| +| BigInt | Collection of added rules. | **Example** @@ -110,15 +110,15 @@ Checks whether the specified rule exists in the collection of added rules. If th **Parameters** -| Name| Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ------ | ------ | ---- | ---------------- | -| rule | BigInt | Yes | Rule to be checked.| +| rule | BigInt | Yes | Rule to be checked. | **Return value** | Type | Description | | ------- | ---------------------------------------------------------- | -| boolean | Returns **true** if the rule exists in the collection of added rules; returns **false** otherwise.| +| boolean | Returns **true** if the rule exists in the collection of added rules; returns **false** otherwise. | **Example** @@ -129,4 +129,4 @@ hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // Check whether the added rule exists in the collection of added rules. hichecker.contains(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // Return true. hichecker.contains(hichecker.RULE_CAUTION_PRINT_LOG); // Return false. -``` +``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-hidebug.md b/en/application-dev/reference/apis/js-apis-hidebug.md index 8aa9c1e22f1982ad58d03bed71ff30eaf05be50b..1a60d7d8e44145f22df7a25328f371e578fcc302 100644 --- a/en/application-dev/reference/apis/js-apis-hidebug.md +++ b/en/application-dev/reference/apis/js-apis-hidebug.md @@ -1,6 +1,6 @@ # HiDebug -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. You can run the hidebug command to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data. @@ -18,9 +18,11 @@ getNativeHeapSize(): bigint Obtains the total size of the native heap memory. +This API is defined but not implemented in OpenHarmony 3.1 Release. + **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug -**Return Value** +**Return value** | Type | Description | | ------ | --------------------------- | @@ -39,10 +41,12 @@ getNativeHeapAllocatedSize(): bigint Obtains the size of the allocated native heap memory. +This API is defined but not implemented in OpenHarmony 3.1 Release. + **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug -**Return Value** +**Return value** | Type | Description | | ------ | --------------------------------- | | bigint | Size of the allocated native heap memory.| @@ -60,10 +64,12 @@ getNativeHeapFreeSize(): bigint Obtains the size of the free native heap memory. +This API is defined but not implemented in OpenHarmony 3.1 Release. + **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug -**Return Value** +**Return value** | Type | Description | | ------ | ------------------------------- | | bigint | Size of the free native heap memory.| @@ -84,7 +90,7 @@ Obtains the PSS of this process. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug -**Return Value** +**Return value** | Type | Description | | ------ | ------------------------- | | bigint | PSS of the process.| @@ -105,7 +111,7 @@ Obtains the size of the shared dirty memory of this process. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug -**Return Value** +**Return value** | Type | Description | | ------ | -------------------------- | | bigint | Size of the shared dirty memory of the process.| @@ -116,6 +122,47 @@ Obtains the size of the shared dirty memory of this process. let sharedDirty = hidebug.getSharedDirty(); ``` +## hidebug.getPrivateDirty9+ + +getPrivateDirty(): bigint + +Obtains the size of the private dirty memory of this process. + +**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug + + +**Return value** +| Type | Description | +| ------ | -------------------------- | +| bigint | Size of the private dirty memory of the process.| + + +**Example** + ```js + let privateDirty = hidebug.getPrivateDirty(); + ``` + +## hidebug.getCpuUsage9+ + +getCpuUsage(): number + +Obtains the CPU usage of this process. + +For example, if the CPU usage is **50%**, **0.5** is returned. + +**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug + + +**Return value** +| Type | Description | +| ------ | -------------------------- | +| number | CPU usage of the process.| + + +**Example** + ```js + let cpuUsage = hidebug.getCpuUsage(); + ``` ## hidebug.startProfiling @@ -135,9 +182,9 @@ Starts the profiling method. `startProfiling()` and `stopProfiling()` are called ```js hidebug.startProfiling("cpuprofiler-20220216"); -// Code block +// code block // ... -// Code block +// code block hidebug.stopProfiling(); ``` @@ -147,7 +194,7 @@ hidebug.stopProfiling(); stopProfiling() : void -Stops the profiling method. `stopProfiling()` and `startProfiling()` are called in pairs. `stopProfiling()` always occurs after `startProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`. +Stops the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug @@ -155,9 +202,9 @@ Stops the profiling method. `stopProfiling()` and `startProfiling()` are called ```js hidebug.startProfiling("cpuprofiler-20220216"); -// Code block +// code block // ... -// Code block +// code block hidebug.stopProfiling(); ``` @@ -165,13 +212,13 @@ hidebug.stopProfiling(); dumpHeapData(filename : string) : void -Exports the heap data. +Exports data from the specified heap file. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | -------- | ------ | ---- | ------------------------------------------------------------ | | filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.| @@ -180,3 +227,31 @@ Exports the heap data. ```js hidebug.dumpHeapData("heap-20220216"); ``` + +## hidebug.getServiceDump9+ + +getServiceDump(serviceid : number) : string + +Obtains information on the specified system service. + +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| serviceid | number | Yes | ID of the system service. | + +**Return value** +| Type | Description | +| ------ | -------------------------- | +| string | Absolute path of the file that contains the service information to dump. | + +**Example** + +```js +let serviceId = 10; +let pathName = hidebug.getServiceDump(serviceId); +``` diff --git a/en/application-dev/reference/apis/js-apis-hilog.md b/en/application-dev/reference/apis/js-apis-hilog.md index 7a1a32e72a5bdde07fdc930d457e8a863991a8c0..b718eb04862f6795ff8d8d95763ce173f0839257 100644 --- a/en/application-dev/reference/apis/js-apis-hilog.md +++ b/en/application-dev/reference/apis/js-apis-hilog.md @@ -1,7 +1,6 @@ # HiLog -> **Note:** -> +> ![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. ## Modules to Import @@ -21,12 +20,12 @@ Prints logs of the DEBUG level. **Parameters** -| Name| Type | Mandatory| Description | +| Name| Type | Mandatory | Description | | ------ | -------------- | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. | -| tag | string | Yes | String constant used to identify the class or service behavior. | -| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.| -| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.| +| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. | +| tag | string | Yes | String constant used to identify the class or service behavior. | +| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default. | +| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string. | **Example** @@ -50,12 +49,12 @@ Prints logs of the INFO level. **Parameters** -| Name| Type | Mandatory| Description | +| Name| Type | Mandatory | Description | | ------ | -------------- | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. | -| tag | string | Yes | String constant used to identify the class or service behavior. | -| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.| -| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.| +| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. | +| tag | string | Yes | String constant used to identify the class or service behavior. | +| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default. | +| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string. | **Example** @@ -79,12 +78,12 @@ Prints logs of the WARN level. **Parameters** -| Name| Type | Mandatory| Description | +| Name| Type | Mandatory | Description | | ------ | -------------- | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. | -| tag | string | Yes | String constant used to identify the class or service behavior. | -| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.| -| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.| +| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. | +| tag | string | Yes | String constant used to identify the class or service behavior. | +| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default. | +| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string. | **Example** @@ -108,12 +107,12 @@ Prints logs of the ERROR level. **Parameters** -| Name| Type | Mandatory| Description | +| Name| Type | Mandatory | Description | | ------ | -------------- | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. | -| tag | string | Yes | String constant used to identify the class or service behavior. | -| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.| -| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.| +| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. | +| tag | string | Yes | String constant used to identify the class or service behavior. | +| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default. | +| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string. | **Example** @@ -137,12 +136,12 @@ Prints logs of the FATAL level. **Parameters** -| Name| Type | Mandatory| Description | +| Name| Type | Mandatory | Description | | ------ | -------------- | ---- | ------------------------------------------------------------ | | domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. | | tag | string | Yes | String constant used to identify the class or service behavior. | -| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.| -| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.| +| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default. | +| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string. | **Example** @@ -166,10 +165,10 @@ Checks whether printing is enabled for a domain, tag, or log level. **Parameters** -| Name| Type | Mandatory| Description | +| Name| Type | Mandatory | Description | | ------ | --------------------- | ---- | ------------------------------------------ | | domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. | -| tag | string | Yes | String constant used to identify the class or service behavior.| +| tag | string | Yes | String constant used to identify the class or service behavior. | | level | [LogLevel](#loglevel) | Yes | Log level. | **Example** @@ -184,10 +183,10 @@ Enumerates event types. **System capability**: SystemCapability.HiviewDFX.HiLog -| Name | Default Value| Description | +| Name | Default Value | Description | | ----- | ------ | ----------- | -| DEBUG | 3 | DEBUG level| +| DEBUG | 3 | DEBUG level | | INFO | 4 | INFO level | | WARN | 5 | WARN level | -| ERROR | 6 | ERROR level| -| FATAL | 7 | FATAL level| +| ERROR | 6 | ERROR level | +| FATAL | 7 | FATAL level | diff --git a/en/application-dev/reference/apis/js-apis-hitracechain.md b/en/application-dev/reference/apis/js-apis-hitracechain.md index 9e4e2fd3f99928617418315ba44e58c326fbf612..485eddc0fbfb59946228e859760885ad0ce1b633 100644 --- a/en/application-dev/reference/apis/js-apis-hitracechain.md +++ b/en/application-dev/reference/apis/js-apis-hitracechain.md @@ -1,6 +1,6 @@ # Distributed Call Chain Tracing -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -16,16 +16,16 @@ Enumerates trace flag types. **System capability**: SystemCapability.HiviewDFX.HiTrace -| Name| Default Value| Description| +| Name | Default Value | Description | | -------- | -------- | -------- | -| DEFAULT | 0 | Default flag. | -| INCLUDE_ASYNC | 1 | Asynchronous call flag. By default, only synchronous calls are traced. If this flag is set, both synchronous and asynchronous calls will be traced. | -| DONOT_CREATE_SPAN | 1 << 1 | No span flag. By default, a span is automatically created during tracing of synchronous and asynchronous calls. If this flag is set, no span will be created. | -| TP_INFO | 1 << 2 | Trace point flag. By default, no trace point is added when tracing is enabled. This flag is used for debugging. If this flag is set, trace points will be automatically added on the TX and RX sides of synchronous and asynchronous calls to output trace point and timestamp information. Trace points are classified into four types: [CS, SR, SS, and CR](#hitracetracepointtype). For a synchronous call, the output trace points are CS, SR, SS, and CR; for an asynchronous call, the output trace points are CS, SR, and SS. | -| NO_BE_INFO | 1 << 3 | No begin/end flag. By default, information about the start and end of the trace task is printed. If this flag is set, information about the start and end of the trace task will not be printed.| +| DEFAULT | 0 | Default flag. | +| INCLUDE_ASYNC | 1 | Asynchronous call flag. By default, only synchronous calls are traced. If this flag is set, both synchronous and asynchronous calls will be traced. | +| DONOT_CREATE_SPAN | 1 << 1 | No span flag. By default, a span is automatically created during tracing of synchronous and asynchronous calls. If this flag is set, no span will be created. | +| TP_INFO | 1 << 2 | Trace point flag. By default, no trace point is added when tracing is enabled. This flag is used for debugging. If this flag is set, trace points will be automatically added on the TX and RX sides of synchronous and asynchronous calls to output trace point and timestamp information. Trace points are classified into four types: [CS, SR, SS, and CR](#hitracetracepointtype). For a synchronous call, the output trace points are CS, SR, SS, and CR; for an asynchronous call, the output trace points are CS, SR, and SS. | +| NO_BE_INFO | 1 << 3 | No begin/end flag. By default, information about the start and end of the trace task is printed. If this flag is set, information about the start and end of the trace task will not be printed. | | DISABLE_LOG | 1 << 4 | Log association flag. If this flag is set, information about the trace task will not be printed. | | FAILURE_TRIGGER | 1 << 5 | Failure trigger flag. This flag is reserved for future use. | -| D2D_TP_INFO | 1 << 6 | Device-to-device trace point flag. It is a subset of **TP_INFO**. If this flag is set, trace points are added only for call chain tracing between devices.| +| D2D_TP_INFO | 1 << 6 | Device-to-device trace point flag. It is a subset of **TP_INFO**. If this flag is set, trace points are added only for call chain tracing between devices. | ## HiTraceTracepointType @@ -33,13 +33,13 @@ Enumerates trace point types. **System capability**: SystemCapability.HiviewDFX.HiTrace -| Name| Default Value| Description| +| Name| Default Value | Description | | -------- | -------- | -------- | -| CS | 0 | Client Send (CS) trace point. | -| CR | 1 | Client Receive (CS) trace point. | -| SS | 2 | Server Send (SS) trace point. | -| SR | 3 | Server Receive (SR) trace point. | -| GENERAL | 4 | General trace points except CS, CR, SS, and SR.| +| CS | 0 | Client Send (CS) trace point. | +| CR | 1 | Client Receive (CS) trace point. | +| SS | 2 | Server Send (SS) trace point. | +| SR | 3 | Server Receive (SR) trace point. | +| GENERAL | 4 | General trace points except CS, CR, SS, and SR. | ## HiTraceCommunicationMode @@ -47,9 +47,9 @@ Enumerates communication modes. **System capability**: SystemCapability.HiviewDFX.HiTrace -| Name| Default Value| Description| +| Name| Default Value | Description | | -------- | -------- | -------- | -| DEFAULT | 0 | Default communication mode. | +| DEFAULT | 0 | Default communication mode. | | THREAD | 1 | Inter-thread communication. | | PROCESS | 2 | Inter-process communication. | | DEVICE | 3 | Inter-device communication. | @@ -60,12 +60,12 @@ Defines a **HiTraceId** object. **System capability**: SystemCapability.HiviewDFX.HiTrace -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| chainId | bigint | Yes| Call chain ID. | -| spanId | number | No| Span ID. | -| parentSpanId | number | No| Parent span ID. | -| flags | number | No| Trace flag combination.| +| chainId | bigint | Yes| Call chain ID. | +| spanId | number | No| Span ID. | +| parentSpanId | number | No| Parent span ID. | +| flags | number | No| Trace flag combination. | ## hiTraceChain.begin @@ -77,16 +77,16 @@ Starts call chain tracing. This API works in synchronous manner. **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| name | string | Yes| Traced service name.| -| flags | number | Yes| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag).| +| name | string | Yes| Traced service name. | +| flags | number | Yes| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag). | **Return Value** -| Type| Description| +| Type | Description | | -------- | -------- | -| [HiTraceId](#hitraceid) | **HiTraceId** instance.| +| [HiTraceId](#hitraceid) | **HiTraceId** instance. | **Example** @@ -104,9 +104,9 @@ Stops call chain tracing. This API works in synchronous manner. **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| +| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance. | **Example** @@ -126,9 +126,9 @@ Obtains the trace ID. This API works in synchronous manner. **Return Value** -| Type| Description| +| Type | Description | | -------- | -------- | -| [HiTraceId](#hitraceid) | **HiTraceId** instance.| +| [HiTraceId](#hitraceid) | **HiTraceId** instance. | **Example** @@ -148,13 +148,14 @@ Sets a trace ID. This API works in synchronous manner. **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| +| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance. | **Example** ```js +let asyncTraceId; let traceId = hiTraceChain.begin("business"); // Set the current trace ID after the service logic is executed for several times. hiTraceChain.setId(asyncTraceId); @@ -186,9 +187,9 @@ Creates a trace span. This API works in synchronous manner. **Return Value** -| Type| Description| +| Type | Description | | -------- | -------- | -| [HiTraceId](#hitraceid) | **HiTraceId** instance.| +| [HiTraceId](#hitraceid) | **HiTraceId** instance. | **Example** @@ -208,12 +209,12 @@ Triggers a trace point. This API works in synchronous manner. **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| mode | [HiTraceCommunicationMode](#hitracecommunicationmode) | Yes| Communication mode for the trace point.| -| type | [HiTraceTracepointType](#hitracetracepointtype)| Yes| Trace point type.| -| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance for trace point triggering.| -| msg | string | No| Trace description passed for trace point triggering.| +| mode | [HiTraceCommunicationMode](#hitracecommunicationmode) | Yes| Communication mode for the trace point. | +| type | [HiTraceTracepointType](#hitracetracepointtype)| Yes| Trace point type. | +| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance for trace point triggering. | +| msg | string | No| Trace description passed for trace point triggering. | **Example** @@ -233,15 +234,15 @@ Checks whether a **HiTraceId** instance is valid. This API works in synchronous **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| +| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance. | **Return Value** -| Type| Description| +| Type | Description | | -------- | -------- | -| boolean | Returns **true** if the **HiTraceId** instance is valid; returns **false** otherwise.| +| boolean | Returns **true** if the **HiTraceId** instance is valid; returns **false** otherwise. | **Example** @@ -260,16 +261,16 @@ Checks whether the specified trace flag in the **HiTraceId** instance is enabled **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| -| flag | [HiTraceFlag](#hitraceflag) | Yes| Specified trace flag.| +| id | [HiTraceId](#hitraceid) | Yes | **HiTraceId** instance. | +| flag | [HiTraceFlag](#hitraceflag) | Yes | Specified trace flag. | **Return Value** -| Type| Description| +| Type | Description | | -------- | -------- | -| boolean | Returns **true** if the specified trace flag in the **HiTraceId** instance is enabled; returns **false** otherwise.| +| boolean | Returns **true** if the specified trace flag in the **HiTraceId** instance is enabled; returns **false** otherwise. | **Example** @@ -288,16 +289,16 @@ Enables the specified trace flag in the **HiTraceId** instance. This API works i **System capability**: SystemCapability.HiviewDFX.HiTrace **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| -| flag | [HiTraceFlag](#hitraceflag) | Yes| Specified trace flag.| +| id | [HiTraceId](#hitraceid) | Yes | **HiTraceId** instance. | +| flag | [HiTraceFlag](#hitraceflag) | Yes | Specified trace flag. | **Example** ```js let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); -hiTraceChain.enable(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); +hiTraceChain.enableFlag(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); // The value of enabledDoNotCreateSpanFlag is true. let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); ``` diff --git a/en/application-dev/reference/apis/js-apis-hitracemeter.md b/en/application-dev/reference/apis/js-apis-hitracemeter.md index e0213ac299872e4a22ff22c65b7a80d4b1a57e00..656063edf90a71a74e8f7b5e90375acfccfdae9c 100644 --- a/en/application-dev/reference/apis/js-apis-hitracemeter.md +++ b/en/application-dev/reference/apis/js-apis-hitracemeter.md @@ -1,6 +1,6 @@ # Performance Tracing -> ![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. @@ -25,16 +25,15 @@ If the trace tasks with the same name are not performed at the same time, the sa **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| name | string | Yes| Name of the trace task to start.| -| taskId | number | Yes| Task ID.| +| name | string | Yes | Name of the trace task to start. | +| taskId | number | Yes| Task ID. | **Example** ```js hiTraceMeter.startTrace("myTestFunc", 1); -hiTraceMeter.startTrace("myTestFunc", 1, 5); // The expected duration of the trace task is 5 ms. ``` @@ -52,8 +51,8 @@ To stop a trace task, the values of name and task ID in **finishTrace** must be | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| name | string | Yes| Name of the trace task to start.| -| taskId | number | Yes| Task ID.| +| name | string | Yes| Name of the trace task to start. | +| taskId | number | Yes| Task ID. | **Example** @@ -96,8 +95,8 @@ Traces the value changes of a variable. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| name | string | Yes| Name of the variable.| -| count | number | Yes| Value of the variable.| +| name | string | Yes | Name of the variable. | +| count | number | Yes | Value of the variable. | **Example** ```js diff --git a/en/application-dev/reference/apis/js-apis-http.md b/en/application-dev/reference/apis/js-apis-http.md index c4c8d11faf8efc3e840d617552ee1cb2da2b121d..f1ef654168a4696ee3f0e54e361a5e81ac7dc6a9 100644 --- a/en/application-dev/reference/apis/js-apis-http.md +++ b/en/application-dev/reference/apis/js-apis-http.md @@ -7,13 +7,13 @@ ## Modules to Import -``` +```js import http from '@ohos.net.http'; ``` ## Example -``` +```js import http from '@ohos.net.http'; // Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused. @@ -71,7 +71,7 @@ Creates an HTTP request. You can use this API to initiate or destroy an HTTP req **Example** -``` +```js import http from '@ohos.net.http'; let httpRequest = http.createHttp(); ``` @@ -100,7 +100,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback **Example** -``` +```js httpRequest.request("EXAMPLE_URL", (err, data) => { if (!err) { console.info('Result:' + data.result); @@ -133,7 +133,7 @@ Initiates an HTTP request containing specified options to a given URL. This API **Example** -``` +```js httpRequest.request("EXAMPLE_URL", { method: http.RequestMethod.GET, @@ -183,7 +183,7 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the **Example** -``` +```js let promise = httpRequest.request("EXAMPLE_URL", { method: http.RequestMethod.GET, connectTimeout: 60000, @@ -214,7 +214,7 @@ Destroys an HTTP request. **Example** -``` +```js httpRequest.destroy(); ``` @@ -239,7 +239,7 @@ Registers an observer for HTTP Response Header events. **Example** -``` +```js httpRequest.on('headerReceive', (err, data) => { if (!err) { console.info('header: ' + JSON.stringify(data)); @@ -273,7 +273,7 @@ Unregisters the observer for HTTP Response Header events. **Example** -``` +```js httpRequest.off('headerReceive'); ``` @@ -294,7 +294,7 @@ Registers an observer for HTTP Response Header events. **Example** -``` +```js httpRequest.on('headersReceive', (header) => { console.info('header: ' + JSON.stringify(header)); }); @@ -322,7 +322,7 @@ Unregisters the observer for HTTP Response Header events. **Example** -``` +```js httpRequest.off('headersReceive'); ``` @@ -343,7 +343,7 @@ Registers a one-time observer for HTTP Response Header events. Once triggered, t **Example** -``` +```js httpRequest.once('headersReceive', (header) => { console.info('header: ' + JSON.stringify(header)); }); diff --git a/en/application-dev/reference/apis/js-apis-huks.md b/en/application-dev/reference/apis/js-apis-huks.md index 9a2faa3d931c963dcaebf85ce286c3278423dd0f..9148b313e272a7ba0dbc54fa26d22b58b2486fbd 100644 --- a/en/application-dev/reference/apis/js-apis-huks.md +++ b/en/application-dev/reference/apis/js-apis-huks.md @@ -20,73 +20,73 @@ Enumerates the error codes. | Name | Value | Description| | -------------------------- | ----- | ---- | -| HUKS_SUCCESS | 0 |Success.| -| HUKS_FAILURE | -1 |Failure.| -| HUKS_ERROR_BAD_STATE | -2 |Incorrect state.| -| HUKS_ERROR_INVALID_ARGUMENT | -3 |Invalid argument.| -| HUKS_ERROR_NOT_SUPPORTED | -4 |Not supported.| -| HUKS_ERROR_NO_PERMISSION | -5 |No permission.| -| HUKS_ERROR_INSUFFICIENT_DATA | -6 |Insufficient data.| -| HUKS_ERROR_BUFFER_TOO_SMALL | -7 |Insufficient buffer.| -| HUKS_ERROR_INSUFFICIENT_MEMORY | -8 |Insufficient memory.| -| HUKS_ERROR_COMMUNICATION_FAILURE | -9 |Communication failure.| -| HUKS_ERROR_STORAGE_FAILURE | -10 |Storage failure.| -| HUKS_ERROR_HARDWARE_FAILURE | -11 |Hardware fault.| -| HUKS_ERROR_ALREADY_EXISTS | -12 |The object already exists.| -| HUKS_ERROR_NOT_EXIST | -13 |The object does not exist.| -| HUKS_ERROR_NULL_POINTER | -14 |Null pointer.| -| HUKS_ERROR_FILE_SIZE_FAIL | -15 |Incorrect file size.| -| HUKS_ERROR_READ_FILE_FAIL | -16 |Failed to read the file.| -| HUKS_ERROR_INVALID_PUBLIC_KEY | -17 |Invalid public key.| -| HUKS_ERROR_INVALID_PRIVATE_KEY | -18 |Invalid private key.| -| HUKS_ERROR_INVALID_KEY_INFO | -19 |Invalid key information.| -| HUKS_ERROR_HASH_NOT_EQUAL | -20 |The hash values are not equal.| -| HUKS_ERROR_MALLOC_FAIL | -21 |MALLOC failed.| -| HUKS_ERROR_WRITE_FILE_FAIL | -22 |Failed to write the file.| -| HUKS_ERROR_REMOVE_FILE_FAIL | -23 |Failed to delete the file.| -| HUKS_ERROR_OPEN_FILE_FAIL | -24 |Failed to open the file.| -| HUKS_ERROR_CLOSE_FILE_FAIL | -25 |Failed to close the file.| -| HUKS_ERROR_MAKE_DIR_FAIL | -26 |Failed to create the directory.| -| HUKS_ERROR_INVALID_KEY_FILE | -27 |Invalid key file.| -| HUKS_ERROR_IPC_MSG_FAIL | -28 |Incorrect IPC information.| -| HUKS_ERROR_REQUEST_OVERFLOWS | -29 |Request overflows.| -| HUKS_ERROR_PARAM_NOT_EXIST | -30 |The parameter does not exist.| -| HUKS_ERROR_CRYPTO_ENGINE_ERROR | -31 |CRYPTO ENGINE error.| -| HUKS_ERROR_COMMUNICATION_TIMEOUT | -32 |Communication timed out.| -| HUKS_ERROR_IPC_INIT_FAIL | -33 |IPC initialization failed.| -| HUKS_ERROR_IPC_DLOPEN_FAIL | -34 |IPC DLOPEN failed.| -| HUKS_ERROR_EFUSE_READ_FAIL | -35 |Failed to read eFUSE.| -| HUKS_ERROR_NEW_ROOT_KEY_MATERIAL_EXIST | -36 |New root key material exists.| -| HUKS_ERROR_UPDATE_ROOT_KEY_MATERIAL_FAIL | -37 |Failed to update the root key material.| -| HUKS_ERROR_VERIFICATION_FAILED | -38 |Failed to verify the certificate chain.| +| HUKS_SUCCESS | 0 |Success. | +| HUKS_FAILURE | -1 |Failure. | +| HUKS_ERROR_BAD_STATE | -2 |Incorrect state. | +| HUKS_ERROR_INVALID_ARGUMENT | -3 |Invalid argument. | +| HUKS_ERROR_NOT_SUPPORTED | -4 |Not supported. | +| HUKS_ERROR_NO_PERMISSION | -5 |No permission. | +| HUKS_ERROR_INSUFFICIENT_DATA | -6 |Insufficient data. | +| HUKS_ERROR_BUFFER_TOO_SMALL | -7 |Insufficient buffer. | +| HUKS_ERROR_INSUFFICIENT_MEMORY | -8 |Insufficient memory. | +| HUKS_ERROR_COMMUNICATION_FAILURE | -9 |Communication failure. | +| HUKS_ERROR_STORAGE_FAILURE | -10 |Storage failure. | +| HUKS_ERROR_HARDWARE_FAILURE | -11 |Hardware fault. | +| HUKS_ERROR_ALREADY_EXISTS | -12 |The object already exists. | +| HUKS_ERROR_NOT_EXIST | -13 |The object does not exist. | +| HUKS_ERROR_NULL_POINTER | -14 |Null pointer. | +| HUKS_ERROR_FILE_SIZE_FAIL | -15 |Incorrect file size. | +| HUKS_ERROR_READ_FILE_FAIL | -16 |Failed to read the file. | +| HUKS_ERROR_INVALID_PUBLIC_KEY | -17 |Invalid public key. | +| HUKS_ERROR_INVALID_PRIVATE_KEY | -18 |Invalid private key. | +| HUKS_ERROR_INVALID_KEY_INFO | -19 |Invalid key information. | +| HUKS_ERROR_HASH_NOT_EQUAL | -20 |The hash values are not equal. | +| HUKS_ERROR_MALLOC_FAIL | -21 |MALLOC failed. | +| HUKS_ERROR_WRITE_FILE_FAIL | -22 |Failed to write the file. | +| HUKS_ERROR_REMOVE_FILE_FAIL | -23 |Failed to delete the file. | +| HUKS_ERROR_OPEN_FILE_FAIL | -24 |Failed to open the file. | +| HUKS_ERROR_CLOSE_FILE_FAIL | -25 |Failed to close the file. | +| HUKS_ERROR_MAKE_DIR_FAIL | -26 |Failed to create the directory. | +| HUKS_ERROR_INVALID_KEY_FILE | -27 |Invalid key file. | +| HUKS_ERROR_IPC_MSG_FAIL | -28 |Incorrect IPC information. | +| HUKS_ERROR_REQUEST_OVERFLOWS | -29 |Request overflows. | +| HUKS_ERROR_PARAM_NOT_EXIST | -30 |The parameter does not exist. | +| HUKS_ERROR_CRYPTO_ENGINE_ERROR | -31 |CRYPTO ENGINE error. | +| HUKS_ERROR_COMMUNICATION_TIMEOUT | -32 |Communication timed out. | +| HUKS_ERROR_IPC_INIT_FAIL | -33 |IPC initialization failed. | +| HUKS_ERROR_IPC_DLOPEN_FAIL | -34 |IPC DLOPEN failed. | +| HUKS_ERROR_EFUSE_READ_FAIL | -35 |Failed to read eFUSE. | +| HUKS_ERROR_NEW_ROOT_KEY_MATERIAL_EXIST | -36 |New root key material exists. | +| HUKS_ERROR_UPDATE_ROOT_KEY_MATERIAL_FAIL | -37 |Failed to update the root key material. | +| HUKS_ERROR_VERIFICATION_FAILED | -38 |Failed to verify the certificate chain. | | HUKS_ERROR_CHECK_GET_ALG_FAIL | -100 |Failed to check whether the ALG is obtained. | -| HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL | -101 |Failed to check whether the key size is obtained.| -| HUKS_ERROR_CHECK_GET_PADDING_FAIL | -102 |Failed to check whether padding is obtained.| -| HUKS_ERROR_CHECK_GET_PURPOSE_FAIL | -103 |Failed to check whether the purpose is obtained.| -| HUKS_ERROR_CHECK_GET_DIGEST_FAIL | -104 |Failed to check whether digest is obtained.| -| HUKS_ERROR_CHECK_GET_MODE_FAIL | -105 |Failed to check whether the mode is obtained.| -| HUKS_ERROR_CHECK_GET_NONCE_FAIL | -106 |Failed to check whether the nonce is obtained.| -| HUKS_ERROR_CHECK_GET_AAD_FAIL | -107 |Failed to check whether the AAD is obtained.| -| HUKS_ERROR_CHECK_GET_IV_FAIL | -108 |Failed to check whether the initialization vector (IV) is obtained.| -| HUKS_ERROR_CHECK_GET_AE_TAG_FAIL | -109 |Failed to check whether the AE flag is obtained.| -| HUKS_ERROR_CHECK_GET_SALT_FAIL | -110 |Failed to check whether the SALT is obtained.| -| HUKS_ERROR_CHECK_GET_ITERATION_FAIL | -111 |Failed to check whether the iteration is obtained.| -| HUKS_ERROR_INVALID_ALGORITHM | -112 |Invalid algorithm.| -| HUKS_ERROR_INVALID_KEY_SIZE | -113 |Invalid key size.| -| HUKS_ERROR_INVALID_PADDING | -114 |Invalid padding.| -| HUKS_ERROR_INVALID_PURPOSE | -115 |Invalid purpose.| -| HUKS_ERROR_INVALID_MODE | -116 |Invalid mode.| -| HUKS_ERROR_INVALID_DIGEST | -117 |Invalid digest.| -| HUKS_ERROR_INVALID_SIGNATURE_SIZE | -118 |Invalid signature size.| -| HUKS_ERROR_INVALID_IV | -119 |Invalid IV.| -| HUKS_ERROR_INVALID_AAD | -120 |Invalid AAD.| -| HUKS_ERROR_INVALID_NONCE | -121 |Invalid nonce.| -| HUKS_ERROR_INVALID_AE_TAG | -122 |Invalid AE tag.| -| HUKS_ERROR_INVALID_SALT | -123 |Invalid SALT.| -| HUKS_ERROR_INVALID_ITERATION | -124 |Invalid iteration.| -| HUKS_ERROR_INVALID_OPERATION | -125 |Invalid operation.| -| HUKS_ERROR_INTERNAL_ERROR | -999 |Internal error.| -| HUKS_ERROR_UNKNOWN_ERROR | -1000 |Unknown error.| +| HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL | -101 |Failed to check whether the key size is obtained. | +| HUKS_ERROR_CHECK_GET_PADDING_FAIL | -102 |Failed to check whether padding is obtained. | +| HUKS_ERROR_CHECK_GET_PURPOSE_FAIL | -103 |Failed to check whether the purpose is obtained. | +| HUKS_ERROR_CHECK_GET_DIGEST_FAIL | -104 |Failed to check whether digest is obtained. | +| HUKS_ERROR_CHECK_GET_MODE_FAIL | -105 |Failed to check whether the mode is obtained. | +| HUKS_ERROR_CHECK_GET_NONCE_FAIL | -106 |Failed to check whether the nonce is obtained. | +| HUKS_ERROR_CHECK_GET_AAD_FAIL | -107 |Failed to check whether the AAD is obtained. | +| HUKS_ERROR_CHECK_GET_IV_FAIL | -108 |Failed to check whether the initialization vector (IV) is obtained. | +| HUKS_ERROR_CHECK_GET_AE_TAG_FAIL | -109 |Failed to check whether the AE flag is obtained. | +| HUKS_ERROR_CHECK_GET_SALT_FAIL | -110 |Failed to check whether the SALT is obtained. | +| HUKS_ERROR_CHECK_GET_ITERATION_FAIL | -111 |Failed to check whether the iteration is obtained. | +| HUKS_ERROR_INVALID_ALGORITHM | -112 |Invalid algorithm. | +| HUKS_ERROR_INVALID_KEY_SIZE | -113 |Invalid key size. | +| HUKS_ERROR_INVALID_PADDING | -114 |Invalid padding. | +| HUKS_ERROR_INVALID_PURPOSE | -115 |Invalid purpose. | +| HUKS_ERROR_INVALID_MODE | -116 |Invalid mode. | +| HUKS_ERROR_INVALID_DIGEST | -117 |Invalid digest. | +| HUKS_ERROR_INVALID_SIGNATURE_SIZE | -118 |Invalid signature size. | +| HUKS_ERROR_INVALID_IV | -119 |Invalid IV. | +| HUKS_ERROR_INVALID_AAD | -120 |Invalid AAD. | +| HUKS_ERROR_INVALID_NONCE | -121 |Invalid nonce. | +| HUKS_ERROR_INVALID_AE_TAG | -122 |Invalid AE tag. | +| HUKS_ERROR_INVALID_SALT | -123 |Invalid SALT. | +| HUKS_ERROR_INVALID_ITERATION | -124 |Invalid iteration. | +| HUKS_ERROR_INVALID_OPERATION | -125 |Invalid operation. | +| HUKS_ERROR_INTERNAL_ERROR | -999 |Internal error. | +| HUKS_ERROR_UNKNOWN_ERROR | -1000 |Unknown error. | ## HuksKeyPurpose @@ -97,15 +97,15 @@ Enumerates the key purposes. | Name | Value | Description | | ------------------------ | ---- | -------------------------------- | -| HUKS_KEY_PURPOSE_ENCRYPT | 1 | The key is used to encrypt plain text.| -| HUKS_KEY_PURPOSE_DECRYPT | 2 | The key is used to decrypt the cipher text.| -| HUKS_KEY_PURPOSE_SIGN | 4 | The key is used to sign data. | -| HUKS_KEY_PURPOSE_VERIFY | 8 | The key is used to verify the signed data. | -| HUKS_KEY_PURPOSE_DERIVE | 16 | The key is used to derive a key. | -| HUKS_KEY_PURPOSE_WRAP | 32 | The key is used for encrypted import. | -| HUKS_KEY_PURPOSE_UNWRAP | 64 | The key is used for encrypted export. | -| HUKS_KEY_PURPOSE_MAC | 128 | The key is used to generate a message authentication code (MAC). | -| HUKS_KEY_PURPOSE_AGREE | 256 | The key is used for key agreement. | +| HUKS_KEY_PURPOSE_ENCRYPT | 1 | Used to encrypt plain text. | +| HUKS_KEY_PURPOSE_DECRYPT | 2 | Used to decrypt cipher text. | +| HUKS_KEY_PURPOSE_SIGN | 4 | Usedd to sign data. | +| HUKS_KEY_PURPOSE_VERIFY | 8 | Used to verify the signed data. | +| HUKS_KEY_PURPOSE_DERIVE | 16 | Used to derive a key. | +| HUKS_KEY_PURPOSE_WRAP | 32 | Used for encrypted import. | +| HUKS_KEY_PURPOSE_UNWRAP | 64 | Used for encrypted export. | +| HUKS_KEY_PURPOSE_MAC | 128 | Used to generate a message authentication code (MAC). | +| HUKS_KEY_PURPOSE_AGREE | 256 | Used for key agreement. | ## HuksKeyDigest @@ -115,13 +115,13 @@ Enumerates the digest algorithms. | Name | Value | Description | | ---------------------- | ---- | ---------------------------------------- | -| HUKS_DIGEST_NONE | 0 | No digest algorithm.| -| HUKS_DIGEST_MD5 | 1 | MD5.| -| HUKS_DIGEST_SHA1 | 10 | SHA1.| -| HUKS_DIGEST_SHA224 | 11 | SHA-224.| -| HUKS_DIGEST_SHA256 | 12 | SHA-256.| -| HUKS_DIGEST_SHA384 | 13 | SHA-384.| -| HUKS_DIGEST_SHA512 | 14 | SHA-512.| +| HUKS_DIGEST_NONE | 0 | No digest algorithm. | +| HUKS_DIGEST_MD5 | 1 | MD5. | +| HUKS_DIGEST_SHA1 | 10 | SHA1. | +| HUKS_DIGEST_SHA224 | 11 | SHA-224. | +| HUKS_DIGEST_SHA256 | 12 | SHA-256. | +| HUKS_DIGEST_SHA384 | 13 | SHA-384. | +| HUKS_DIGEST_SHA512 | 14 | SHA-512. | ## HuksKeyPadding @@ -131,11 +131,11 @@ Enumerates the padding algorithms. | Name | Value | Description | | ---------------------- | ---- | ---------------------------------------- | -| HUKS_PADDING_NONE | 0 | No padding algorithm.| -| HUKS_PADDING_OAEP | 1 | Optimal Asymmetric Encryption Padding (OAEP).| -| HUKS_PADDING_PSS | 2 | Probabilistic Signature Scheme (PSS).| -| HUKS_PADDING_PKCS1_V1_5 | 3 | PKCS1_V1_5.| -| HUKS_PADDING_PKCS5 | 4 | Public Key Cryptography Standards (PKCS) #5.| +| HUKS_PADDING_NONE | 0 | No padding algorithm. | +| HUKS_PADDING_OAEP | 1 | Optimal Asymmetric Encryption Padding (OAEP). | +| HUKS_PADDING_PSS | 2 | Probabilistic Signature Scheme (PSS). | +| HUKS_PADDING_PKCS1_V1_5 | 3 | PKCS1_V1_5. | +| HUKS_PADDING_PKCS5 | 4 | Public Key Cryptography Standards (PKCS) #5. | | HUKS_PADDING_PKCS7 | 5 | PKCS #7| ## HuksCipherMode @@ -146,12 +146,12 @@ Enumerates the cipher modes. | Name | Value | Description | | ------------- | ---- | --------------------- | -| HUKS_MODE_ECB | 1 | Electronic Code BLock (ECB) mode.| -| HUKS_MODE_CBC | 2 | Cipher Block Chaining (CBC) mode.| -| HUKS_MODE_CTR | 3 | Counter (CTR) mode.| -| HUKS_MODE_OFB | 4 | Output Feedback (OFB) mode.| -| HUKS_MODE_CCM | 31 | Counter with CBC-MAC (CCM) mode.| -| HUKS_MODE_GCM | 32 | Galois/Counter (GCM) mode.| +| HUKS_MODE_ECB | 1 | Electronic Code BLock (ECB) mode. | +| HUKS_MODE_CBC | 2 | Cipher Block Chaining (CBC) mode. | +| HUKS_MODE_CTR | 3 | Counter (CTR) mode. | +| HUKS_MODE_OFB | 4 | Output Feedback (OFB) mode. | +| HUKS_MODE_CCM | 31 | Counter with CBC-MAC (CCM) mode. | +| HUKS_MODE_GCM | 32 | Galois/Counter (GCM) mode. | ## HuksKeySize @@ -175,7 +175,7 @@ Enumerates the key sizes. | HUKS_AES_KEY_SIZE_192 | 196 | AES key of 196 bits. | | HUKS_AES_KEY_SIZE_256 | 256 | AES key of 256 bits. | | HUKS_AES_KEY_SIZE_512 | 512 | AES key of 512 bits. | -| HUKS_CURVE25519_KEY_SIZE_256 | 256 | Curve25519 key of 256 bits.| +| HUKS_CURVE25519_KEY_SIZE_256 | 256 | Curve25519 key of 256 bits. | | HUKS_DH_KEY_SIZE_2048 | 2048 | DH key of 2048 bits. | | HUKS_DH_KEY_SIZE_3072 | 3072 | DH key of 3072 bits. | | HUKS_DH_KEY_SIZE_4096 | 4096 | DH key of 4096 bits. | @@ -197,7 +197,7 @@ Enumerates the key algorithms. | HUKS_ALG_PBKDF2 | 52 | PBKDF2. | | HUKS_ALG_ECDH | 100 | ECDH. | | HUKS_ALG_X25519 | 101 | X25519 algorithm. | -| HUKS_ALG_ED25519 | 102 | ED25519 algorithm.| +| HUKS_ALG_ED25519 | 102 | ED25519 algorithm. | | HUKS_ALG_DH | 103 | DH. | ## HuksKeyGenerateType @@ -208,9 +208,9 @@ Enumerates the key generation types. | Name | Value | Description | | ------------------------------ | ---- | ---------------- | -| HUKS_KEY_GENERATE_TYPE_DEFAULT | 0 | Key generated by default.| -| HUKS_KEY_GENERATE_TYPE_DERIVE | 1 | Derived key.| -| HUKS_KEY_GENERATE_TYPE_AGREE | 2 | Key generated by agreement.| +| HUKS_KEY_GENERATE_TYPE_DEFAULT | 0 | Key generated by default. | +| HUKS_KEY_GENERATE_TYPE_DERIVE | 1 | Derived key. | +| HUKS_KEY_GENERATE_TYPE_AGREE | 2 | Key generated by agreement. | ## HuksKeyFlag @@ -222,8 +222,8 @@ Enumerates the key generation modes. | -------------------------- | ---- | ------------------------------------ | | HUKS_KEY_FLAG_IMPORT_KEY | 1 | The key is imported by using the public key import API. | | HUKS_KEY_FLAG_GENERATE_KEY | 2 | The key is generated by using the private key generation API. | -| HUKS_KEY_FLAG_AGREE_KEY | 3 | The key is generated by using the key agreement API.| -| HUKS_KEY_FLAG_DERIVE_KEY | 4 | The key is generated by using the key derivation API.| +| HUKS_KEY_FLAG_AGREE_KEY | 3 | The key is generated by using the key agreement API. | +| HUKS_KEY_FLAG_DERIVE_KEY | 4 | The key is generated by using the key derivation API. | ## HuksKeyStorageType @@ -234,7 +234,7 @@ Enumerates the key storage modes. | Name | Value | Description | | ----------------------- | ---- | ------------------------------ | | HUKS_STORAGE_TEMP | 0 | The key is managed locally. | -| HUKS_STORAGE_PERSISTENT | 1 | The key is managed by the HUKS service.| +| HUKS_STORAGE_PERSISTENT | 1 | The key is managed by the HUKS service. | ## HuksSendType @@ -244,8 +244,8 @@ Enumerates the tag transfer modes. | Name | Value | Description | | -------------------- | ---- | ----------------- | -| HUKS_SEND_TYPE_ASYNC | 0 | The tag is sent asynchronously.| -| HUKS_SEND_TYPE_SYNC | 1 | The tag is sent synchronously.| +| HUKS_SEND_TYPE_ASYNC | 0 | The tag is sent asynchronously. | +| HUKS_SEND_TYPE_SYNC | 1 | The tag is sent synchronously. | ## HuksTagType @@ -258,7 +258,7 @@ Enumerates the tag data types. | --------------------- | ------- | --------------------------------------- | | HUKS_TAG_TYPE_INVALID | 0 << 28 | Invalid tag type. | | HUKS_TAG_TYPE_INT | 1 << 28 | Number of the int type. | -| HUKS_TAG_TYPE_UINT | 2 << 28 | Number of the uint type.| +| HUKS_TAG_TYPE_UINT | 2 << 28 | Number of the uint type. | | HUKS_TAG_TYPE_ULONG | 3 << 28 | bigint. | | HUKS_TAG_TYPE_BOOL | 4 << 28 | Boolean. | | HUKS_TAG_TYPE_BYTES | 5 << 28 | Uint8Array. | @@ -272,30 +272,30 @@ Enumerates the tags used to invoke parameters. | Name | Value | Description | | -------------------------------------- | ---------------------------------------- | -------------------------------------- | | HUKS_TAG_INVALID | HuksTagType.HUKS_TAG_TYPE_INVALID \| 0 | Invalid tag. | -| HUKS_TAG_ALGORITHM | HUKS_TAG_TYPE_UINT \| 1 | Indicates the algorithm. | -| HUKS_TAG_PURPOSE | HuksTagType.HUKS_TAG_TYPE_UINT \| 2 | Indicates the purpose of a key. | -| HUKS_TAG_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 3 | Indicates the key size. | -| HUKS_TAG_DIGEST | HuksTagType.HUKS_TAG_TYPE_UINT \| 4 | Indicates the digest algorithm. | -| HUKS_TAG_PADDING | HuksTagType.HUKS_TAG_TYPE_UINT \| 5 | Indicates the padding algorithm. | -| HUKS_TAG_BLOCK_MODE | HuksTagType.HUKS_TAG_TYPE_UINT \| 6 | Indicates the cipher mode. | -| HUKS_TAG_KEY_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 7 | Indicates the key type. | -| HUKS_TAG_ASSOCIATED_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 8 | Indicates the associated authentication data. | -| HUKS_TAG_NONCE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 9 | Indicates the field for key encryption and decryption. | -| HUKS_TAG_IV | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10 | Indicates the IV. | -| HUKS_TAG_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 11 | Indicates the information generated during key derivation. | -| HUKS_TAG_SALT | HuksTagType.HUKS_TAG_TYPE_BYTES \| 12 | Indicates the salt value used for key derivation. | -| HUKS_TAG_PWD | HuksTagType.HUKS_TAG_TYPE_BYTES \| 13 | Indicates the password used for key derivation. | -| HUKS_TAG_ITERATION | HuksTagType.HUKS_TAG_TYPE_UINT \| 14 | Indicates the number of iterations for key derivation. | -| HUKS_TAG_KEY_GENERATE_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 15 | Indicates the key generation type. | -| HUKS_TAG_DERIVE_MAIN_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 16 | Indicates the main key for key derivation. | -| HUKS_TAG_DERIVE_FACTOR | HuksTagType.HUKS_TAG_TYPE_BYTES \| 17 | Indicates the factor for key derivation. | -| HUKS_TAG_DERIVE_ALG | HuksTagType.HUKS_TAG_TYPE_UINT \| 18 | Indicates the type of the algorithm used for key derivation. | -| HUKS_TAG_AGREE_ALG | HuksTagType.HUKS_TAG_TYPE_UINT \| 19 | Indicates the type of the algorithm used in key agreement. | -| HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 20 | Indicates the alias of the public key during key agreement. | -| HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 21 | Indicates the private key alias used in key agreement. | -| HUKS_TAG_AGREE_PUBLIC_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 22 | Indicates the public key used in key agreement. | -| HUKS_TAG_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 23 | Indicates the key alias. | -| HUKS_TAG_DERIVE_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 24 | Indicates the size of the derived key. | +| HUKS_TAG_ALGORITHM | HUKS_TAG_TYPE_UINT \| 1 | Algorithm. | +| HUKS_TAG_PURPOSE | HuksTagType.HUKS_TAG_TYPE_UINT \| 2 | Purpose of a key. | +| HUKS_TAG_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 3 | Key size. | +| HUKS_TAG_DIGEST | HuksTagType.HUKS_TAG_TYPE_UINT \| 4 | Digest algorithm. | +| HUKS_TAG_PADDING | HuksTagType.HUKS_TAG_TYPE_UINT \| 5 | Padding algorithm. | +| HUKS_TAG_BLOCK_MODE | HuksTagType.HUKS_TAG_TYPE_UINT \| 6 | Cipher mode. | +| HUKS_TAG_KEY_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 7 | Key type. | +| HUKS_TAG_ASSOCIATED_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 8 | Associated authentication data. | +| HUKS_TAG_NONCE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 9 | Field for key encryption and decryption. | +| HUKS_TAG_IV | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10 | IV. | +| HUKS_TAG_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 11 | Information generated during key derivation. | +| HUKS_TAG_SALT | HuksTagType.HUKS_TAG_TYPE_BYTES \| 12 | Salt value used for key derivation. | +| HUKS_TAG_PWD | HuksTagType.HUKS_TAG_TYPE_BYTES \| 13 | Password used for key derivation. | +| HUKS_TAG_ITERATION | HuksTagType.HUKS_TAG_TYPE_UINT \| 14 | Number of iterations for key derivation. | +| HUKS_TAG_KEY_GENERATE_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 15 | Key generation type. | +| HUKS_TAG_DERIVE_MAIN_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 16 | Main key for key derivation. | +| HUKS_TAG_DERIVE_FACTOR | HuksTagType.HUKS_TAG_TYPE_BYTES \| 17 | Factor for key derivation. | +| HUKS_TAG_DERIVE_ALG | HuksTagType.HUKS_TAG_TYPE_UINT \| 18 | Type of the algorithm used for key derivation. | +| HUKS_TAG_AGREE_ALG | HuksTagType.HUKS_TAG_TYPE_UINT \| 19 | Type of the algorithm used in key agreement. | +| HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 20 | Alias of the public key during key agreement. | +| HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 21 | Private key alias used in key agreement. | +| HUKS_TAG_AGREE_PUBLIC_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 22 | Public key used in key agreement. | +| HUKS_TAG_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 23 | Key alias. | +| HUKS_TAG_DERIVE_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 24 | Size of the derived key. | | HUKS_TAG_ACTIVE_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 201 | Reserved. | | HUKS_TAG_ORIGINATION_EXPIRE_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 202 | Reserved. | | HUKS_TAG_USAGE_EXPIRE_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 203 | Reserved. | @@ -306,44 +306,44 @@ Enumerates the tags used to invoke parameters. | HUKS_TAG_USER_AUTH_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 304 | Reserved. | | HUKS_TAG_AUTH_TIMEOUT | HuksTagType.HUKS_TAG_TYPE_UINT \| 305 | Reserved. | | HUKS_TAG_AUTH_TOKEN | HuksTagType.HUKS_TAG_TYPE_BYTES \| 306 | Reserved. | -| HUKS_TAG_ATTESTATION_CHALLENGE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 501 | Indicates the challenge value used in the attestation. | -| HUKS_TAG_ATTESTATION_APPLICATION_ID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 502 | Indicates the application ID used in the attestation. | -| HUKS_TAG_ATTESTATION_ID_BRAND | HuksTagType.HUKS_TAG_TYPE_BYTES \| 503 | Indicates the device brand. | -| HUKS_TAG_ATTESTATION_ID_DEVICE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 504 | Indicates the device. | -| HUKS_TAG_ATTESTATION_ID_PRODUCT | HuksTagType.HUKS_TAG_TYPE_BYTES \| 505 | Indicates the product. | -| HUKS_TAG_ATTESTATION_ID_SERIAL | HuksTagType.HUKS_TAG_TYPE_BYTES \| 506 | Indicates the device SN. | -| HUKS_TAG_ATTESTATION_ID_IMEI | HuksTagType.HUKS_TAG_TYPE_BYTES \| 507 | Indicates the device IMEI. | -| HUKS_TAG_ATTESTATION_ID_MEID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 508 | Indicates the device MEID. | -| HUKS_TAG_ATTESTATION_ID_MANUFACTURER | HuksTagType.HUKS_TAG_TYPE_BYTES \| 509 | Indicates the device manufacturer. | -| HUKS_TAG_ATTESTATION_ID_MODEL | HuksTagType.HUKS_TAG_TYPE_BYTES \| 510 | Indicates the device model. | -| HUKS_TAG_ATTESTATION_ID_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 511 | Indicates the key alias used in the attestation. | -| HUKS_TAG_ATTESTATION_ID_SOCID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 512 | Indicates the device SOCID. | -| HUKS_TAG_ATTESTATION_ID_UDID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 513 | Indicates the device UDID. | -| HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 514 | Indicates the security credential used for the attestation. | -| HUKS_TAG_ATTESTATION_ID_VERSION_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 515 | Indicates the version information used in the attestation. | -| HUKS_TAG_IS_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1001 | Indicates whether to use the alias passed in during key generation.| -| HUKS_TAG_KEY_STORAGE_FLAG | HuksTagType.HUKS_TAG_TYPE_UINT \| 1002 | Indicates the key storage mode. | +| HUKS_TAG_ATTESTATION_CHALLENGE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 501 | Challenge value used in the attestation. | +| HUKS_TAG_ATTESTATION_APPLICATION_ID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 502 | Application ID used in the attestation. | +| HUKS_TAG_ATTESTATION_ID_BRAND | HuksTagType.HUKS_TAG_TYPE_BYTES \| 503 | Device brand. | +| HUKS_TAG_ATTESTATION_ID_DEVICE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 504 | Device. | +| HUKS_TAG_ATTESTATION_ID_PRODUCT | HuksTagType.HUKS_TAG_TYPE_BYTES \| 505 | Product. | +| HUKS_TAG_ATTESTATION_ID_SERIAL | HuksTagType.HUKS_TAG_TYPE_BYTES \| 506 | Device SN. | +| HUKS_TAG_ATTESTATION_ID_IMEI | HuksTagType.HUKS_TAG_TYPE_BYTES \| 507 | Device IMEI. | +| HUKS_TAG_ATTESTATION_ID_MEID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 508 | Device MEID. | +| HUKS_TAG_ATTESTATION_ID_MANUFACTURER | HuksTagType.HUKS_TAG_TYPE_BYTES \| 509 | Device manufacturer. | +| HUKS_TAG_ATTESTATION_ID_MODEL | HuksTagType.HUKS_TAG_TYPE_BYTES \| 510 | Device model. | +| HUKS_TAG_ATTESTATION_ID_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 511 | Key alias used in the attestation. | +| HUKS_TAG_ATTESTATION_ID_SOCID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 512 | Device SOCID. | +| HUKS_TAG_ATTESTATION_ID_UDID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 513 | Device UDID. | +| HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 514 | Security credential used for the attestation. | +| HUKS_TAG_ATTESTATION_ID_VERSION_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 515 | Version information used in the attestation. | +| HUKS_TAG_IS_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1001 | Whether to use the alias passed in during key generation. | +| HUKS_TAG_KEY_STORAGE_FLAG | HuksTagType.HUKS_TAG_TYPE_UINT \| 1002 | Key storage mode. | | HUKS_TAG_IS_ALLOWED_WRAP | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1003 | Reserved. | | HUKS_TAG_KEY_WRAP_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 1004 | Reserved. | | HUKS_TAG_KEY_AUTH_ID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 1005 | Reserved. | | HUKS_TAG_KEY_ROLE | HuksTagType.HUKS_TAG_TYPE_UINT \| 1006 | Reserved. | -| HUKS_TAG_KEY_FLAG | HuksTagType.HUKS_TAG_TYPE_UINT \| 1007 | Indicates the flag of the key. | +| HUKS_TAG_KEY_FLAG | HuksTagType.HUKS_TAG_TYPE_UINT \| 1007 | Flag of the key. | | HUKS_TAG_IS_ASYNCHRONIZED | HuksTagType.HUKS_TAG_TYPE_UINT \| 1008 | Reserved. | | HUKS_TAG_SECURE_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1009 | Reserved. | | HUKS_TAG_SECURE_KEY_UUID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 1010 | Reserved. | | HUKS_TAG_KEY_DOMAIN | HuksTagType.HUKS_TAG_TYPE_UINT \| 1011 | Reserved. | -| HUKS_TAG_PROCESS_NAME | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10001 | Indicates the process name. | +| HUKS_TAG_PROCESS_NAME | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10001 | Process name. | | HUKS_TAG_PACKAGE_NAME | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10002 | Reserved. | | HUKS_TAG_ACCESS_TIME | HuksTagType.HUKS_TAG_TYPE_UINT \| 10003 | Reserved. | | HUKS_TAG_USES_TIME | HuksTagType.HUKS_TAG_TYPE_UINT \| 10004 | Reserved. | | HUKS_TAG_CRYPTO_CTX | HuksTagType.HUKS_TAG_TYPE_ULONG \| 10005 | Reserved. | | HUKS_TAG_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10006 | Reserved. | -| HUKS_TAG_KEY_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10007 | Indicates the key version. | +| HUKS_TAG_KEY_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10007 | Key version. | | HUKS_TAG_PAYLOAD_LEN | HuksTagType.HUKS_TAG_TYPE_UINT \| 10008 | Reserved. | | HUKS_TAG_AE_TAG | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10009 | Reserved. | | HUKS_TAG_IS_KEY_HANDLE | HuksTagType.HUKS_TAG_TYPE_ULONG \| 10010 | Reserved. | -| HUKS_TAG_OS_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10101 | Indicates the operating system version. | -| HUKS_TAG_OS_PATCHLEVEL | HuksTagType.HUKS_TAG_TYPE_UINT \| 10102 | Indicates the operating system patch level. | +| HUKS_TAG_OS_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10101 | OS version. | +| HUKS_TAG_OS_PATCHLEVEL | HuksTagType.HUKS_TAG_TYPE_UINT \| 10102 | OS patch level. | | HUKS_TAG_SYMMETRIC_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20001 | Reserved. | | HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20002 | Reserved. | | HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20003 | Reserved. | @@ -362,7 +362,7 @@ Generates a key. This API uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Alias of the key. | | options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code defined in **HuksResult** will be returned.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code defined in **HuksResult** will be returned. | **Example** @@ -411,13 +411,13 @@ Generates a key. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ------------------------ | | keyAlias | string | Yes | Alias of the key. | -| options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key.| +| options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. | **Return value** | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. | **Example** @@ -463,7 +463,7 @@ Deletes a key. This API uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | -------------------------------------------------- | | keyAlias | string | Yes | Key alias passed in when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. | **Example** @@ -488,14 +488,14 @@ Deletes a key. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | ----------- | ---- | ----------------------------------------------------- | -| keyAlias | string | Yes | Key alias passed in when the key was generated.| -| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).| +| keyAlias | string | Yes | Key alias passed in when the key was generated. | +| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | **Return value** | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. | **Example** @@ -520,13 +520,13 @@ Obtains the SDK version of the current system. | Name | Type | Mandatory| Description | | ------- | ---------- | ---- | ------------------------- | -| options | [HuksOptions](#huksoptions) | Yes | Empty object, which is used to hold the SDK version.| +| options | [HuksOptions](#huksoptions) | Yes | Empty object, which is used to hold the SDK version. | **Return value** | Type | Description | | ------ | ------------- | -| string | SDK version obtained.| +| string | SDK version obtained. | **Example** @@ -550,9 +550,9 @@ Imports a key. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | ------------------------------------------------- | -| keyAlias | string | Yes | Key alias, which is used to hold the key pair.| -| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key pair to import.| -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.| +| keyAlias | string | Yes | Key alias, which is used to hold the key pair. | +| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key pair to import. | +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. | **Example** @@ -608,14 +608,14 @@ Imports a key. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | ----------- | ---- | ------------------------------------ | -| keyAlias | string | Yes | Key alias, which is used to hold the key pair.| -| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key pair to import.| +| keyAlias | string | Yes | Key alias, which is used to hold the key pair. | +| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key pair to import. | **Return value** | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. | **Example** @@ -675,7 +675,7 @@ Exports a key. This API uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. **outData** contains the public key exported.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. **outData** contains the public key exported. | **Example** @@ -700,14 +700,14 @@ Exports a key. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | ----------- | ---- | ------------------------------------------------------------ | -| keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated.| -| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).| +| keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | +| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | **Return value** | Type | Description | | ----------------------------------- | ------------------------------------------------------------ | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. **outData** contains the public key exported.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. **outData** contains the public key exported. | **Example** @@ -734,7 +734,7 @@ Obtains key properties. This API uses an asynchronous callback to return the res | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. **HUKS_SUCCESS** will be returned if the operation is successful; an error code will be returned otherwise.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. **HUKS_SUCCESS** will be returned if the operation is successful; an error code will be returned otherwise. | **Example** @@ -759,14 +759,14 @@ Obtains key properties. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | ----------- | ---- | ------------------------------------------------------------ | -| keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated.| -| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).| +| keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | +| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | **Return value** | Type | Description | | ------------------ | ------------------------------------------------------------ | -| Promise\<[HuksResult](#huksoptions)> | Promise used to return the result. In the return result, **HUKS_SUCCESS** will be returned for **errorCode** if the operation is successful; an error code will be returned otherwise. **properties** returns the parameters required for generating the key.| +| Promise\<[HuksResult](#huksoptions)> | Promise used to return the result. In the return result, **HUKS_SUCCESS** will be returned for **errorCode** if the operation is successful; an error code will be returned otherwise. **properties** returns the parameters required for generating the key. | **Example** @@ -791,9 +791,9 @@ Checks whether a key exists. This API uses an asynchronous callback to return th | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------- | -| keyAlias | string | Yes | Alias of the key to check.| -| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).| -| callback | AsyncCallback\ | Yes | Callback used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite.| +| keyAlias | string | Yes | Alias of the key to check. | +| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | +| callback | AsyncCallback\ | Yes | Callback used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite. | **Example** @@ -818,14 +818,14 @@ Checks whether a key exists. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | ----------- | ---- | -------------------------------- | -| keyAlias | string | Yes | Alias of the key to check.| -| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).| +| keyAlias | string | Yes | Alias of the key to check. | +| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | **Return value** | Type | Description | | ----------------- | --------------------------------------- | -| Promise\ | Promise used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite.| +| Promise\ | Promise used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite. | **Example** @@ -852,9 +852,9 @@ Initializes a key. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------- | -| keyAlias | string | Yes | Alias of the target key.| -| options | [HuksOptions](#huksoptions) | Yes | Parameters used for initialization.| -| callback | AsyncCallback\<[HuksHandle](#hukshandle)> | Yes | Callback used to return the handle of the initialization operation.| +| keyAlias | string | Yes | Alias of the target key. | +| options | [HuksOptions](#huksoptions) | Yes | Parameters used for initialization. | +| callback | AsyncCallback\<[HuksHandle](#hukshandle)> | Yes | Callback used to return the handle of the initialization operation. | ## huks.init @@ -869,9 +869,9 @@ Initializes a key. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------- | -| keyAlias | string | Yes | Alias of the target key.| -| options | [HuksOptions](#huksoptions) | Yes | Parameters used for initialization.| -| promise | Promise\<[HuksHandle](#hukshandle)> | Yes | Promise used to return the handle of the initialization operation.| +| keyAlias | string | Yes | Alias of the target key. | +| options | [HuksOptions](#huksoptions) | Yes | Parameters used for initialization. | +| promise | Promise\<[HuksHandle](#hukshandle)> | Yes | Promise used to return the handle of the initialization operation. | ## huks.update @@ -886,10 +886,10 @@ Updates a key. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------- | -| handle | number | Yes | Handle of the **Update** operation.| -| token | Uint8Array | No| Token of the **Update** operation.| -| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation.| -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result.| +| handle | number | Yes | Handle of the **Update** operation. | +| token | Uint8Array | No| Token of the **Update** operation. | +| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation. | +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result. | ## huks.update @@ -904,10 +904,10 @@ Updates a key. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------- | -| handle | number | Yes | Handle of the **Update** operation.| -| token | Uint8Array | No| Token of the **Update** operation.| -| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation.| -| promise | Promise\<[HuksResult](#huksresult)> | Yes| Promise used to return the operation result.| +| handle | number | Yes | Handle of the **Update** operation. | +| token | Uint8Array | No| Token of the **Update** operation. | +| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation. | +| promise | Promise\<[HuksResult](#huksresult)> | Yes| Promise used to return the operation result. | ## huks.finish @@ -922,9 +922,9 @@ Completes the key operation and releases resources. This API uses an asynchronou | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------- | -| handle | number | Yes | Handle of the **Finish** operation.| -| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation.| -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result.| +| handle | number | Yes | Handle of the **Finish** operation. | +| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation. | +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result. | ## huks.finish @@ -939,9 +939,9 @@ Completes the key operation and releases resources. This API uses a promise to r | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------- | -| handle | number | Yes | Handle of the **Finish** operation.| -| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation.| -| promise | Promise\<[HuksResult](#HuksResult)> | Yes| Promise used to return the operation result.| +| handle | number | Yes | Handle of the **Finish** operation. | +| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation. | +| promise | Promise\<[HuksResult](#HuksResult)> | Yes| Promise used to return the operation result. | ## huks.abort @@ -956,9 +956,9 @@ Aborts the use of the key. This API uses an asynchronous callback to return the | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------- | -| handle | number | Yes | Handle of the **Abort** operation.| -| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Abort** operation.| -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result.| +| handle | number | Yes | Handle of the **Abort** operation. | +| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Abort** operation. | +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result. | **Example** @@ -1176,9 +1176,9 @@ Aborts the use of the key. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------- | -| handle | number | Yes | Handle of the **Abort** operation.| -| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Abort** operation.| -| promise | Promise\<[HuksResult](#huksresult)> | Yes| Promise used to return the operation result.| +| handle | number | Yes | Handle of the **Abort** operation. | +| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Abort** operation. | +| promise | Promise\<[HuksResult](#huksresult)> | Yes| Promise used to return the operation result. | **Example** @@ -1399,7 +1399,7 @@ Defines the **param** in the **properties** array of **options** used in the API | Name| Type | Mandatory| Description | | ------ | ----------------------------------- | ---- | ---------- | | tag | HuksTag | Yes | Tag. | -| value | boolean\|number\|bigint\|Uint8Array | Yes | Value of the tag.| +| value | boolean\|number\|bigint\|Uint8Array | Yes | Value of the tag. | ## HuksOptions @@ -1409,7 +1409,7 @@ Defines the **options** used in the APIs. | Name | Type | Mandatory| Description | | ---------- | ----------------- | ---- | ------------------------ | -| properties | Array\ | No | Array used to hold **HuksParam**.| +| properties | Array\ | No | Array used to hold **HuksParam**. | | inData | Uint8Array | No | Input data. | ## HuksHandle @@ -1418,11 +1418,11 @@ Defines the HUKS handle structure. **System capability**: SystemCapability.Security.Huks -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ---------- | ---------------- | ---- | -------- | -| errorCode | number | Yes | Error code.| -| handle | number | Yes| Value of the handle.| -| token | Uint8Array | No| Reserved.| +| errorCode | number | Yes | Error code. | +| handle | number | Yes| Value of the handle. | +| token | Uint8Array | No| Reserved. | ## HuksResult @@ -1433,9 +1433,9 @@ Defines the **HuksResult** structure. -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ---------- | ----------------- | ---- | -------- | | errorCode | number | Yes | Error code. | -| outData | Uint8Array | No | Output data.| +| outData | Uint8Array | No | Output data. | | properties | Array\ | No | Properties. | | certChains | Array\ | No | Certificate chain. | diff --git a/en/application-dev/reference/apis/js-apis-inputmethod.md b/en/application-dev/reference/apis/js-apis-inputmethod.md index 6e5ef326d3bc6362f59ce7b6fffa2ea0214e94f4..a89590f552dd1a55408fd2743bffc9cde1f73e14 100644 --- a/en/application-dev/reference/apis/js-apis-inputmethod.md +++ b/en/application-dev/reference/apis/js-apis-inputmethod.md @@ -1,7 +1,7 @@ # Input Method Framework -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **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 @@ -40,16 +40,18 @@ Obtains an [InputMethodController](#InputMethodController) instance. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Return value +**Return value** - | Type| Description| - | -------- | -------- | - | [InputMethodController](#InputMethodController) | Returns the current **InputMethodController** instance.| +| Type| Description| +| -------- | -------- | +| [InputMethodController](#InputMethodController) | Returns the current **InputMethodController** instance.| + +**Example** + +``` +var InputMethodController = inputMethod.getInputMethodController(); +``` -- Example - ``` - var InputMethodController = inputMethod.getInputMethodController(); - ``` ## inputMethod.getInputMethodSetting8+ getInputMethodSetting(): InputMethodSetting @@ -58,17 +60,17 @@ Obtains an [InputMethodSetting](#InputMethodSetting) instance. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Return value +**Return value** - | Type | Description | - | ----------------------------------------- | ---------------------------- | - | [InputMethodSetting](#InputMethodSetting) | Returns the current **InputMethodSetting** instance.| +| Type | Description | +| ----------------------------------------- | ---------------------------- | +| [InputMethodSetting](#InputMethodSetting) | Returns the current **InputMethodSetting** instance.| +**Example** -- Example - ``` - var InputMethodSetting = inputMethod.getInputMethodSetting(); - ``` +```js +var InputMethodSetting = inputMethod.getInputMethodSetting(); +``` ## InputMethodController @@ -82,15 +84,15 @@ Hides the keyboard. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes| Callback used to return whether the keyboard is successfully hidden.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | Yes| Callback used to return whether the keyboard is successfully hidden.| -- Example +**Example** -``` +```js InputMethodController.stopInput((error)=>{ console.info('stopInput'); }); @@ -104,16 +106,16 @@ Hides the keyboard. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Return value +**Return value** - | Type| Description| - | -------- | -------- | - | Promise<boolean> | Promise used to return whether the keyboard is successfully hidden.| +| Type| Description| +| -------- | -------- | +| Promise<boolean> | Promise used to return whether the keyboard is successfully hidden.| -- Example +**Example** -``` +```js var isSuccess = InputMethodController.stopInput(); console.info('stopInput isSuccess = ' + isSuccess); ``` @@ -130,42 +132,46 @@ Obtains the list of installed input methods. This API uses an asynchronous callb **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------------------- | ---- | ---------------------- | - | callback | Array<[InputMethodProperty](#InputMethodProperty)> | Yes | Callback used to return the list of installed input methods.| - -- Example - ``` - InputMethodSetting.listInputMethod((properties)=>{ - for (var i = 0;i < properties.length; i++) { - var property = properties[i]; - console.info(property.packageName + "/" + property.methodId); - } - }); - ``` +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------------- | ---- | ---------------------- | +| callback | Array<[InputMethodProperty](#InputMethodProperty)> | Yes | Callback used to return the list of installed input methods.| + +**Example** + +```js + InputMethodSetting.listInputMethod((properties)=>{ + for (var i = 0;i < properties.length; i++) { + var property = properties[i]; + console.info(property.packageName + "/" + property.methodId); + } +}); +``` ### listInputMethod -listInputMethod(): Promise<Array<InputMethodProperty>> +listInputMethod(): Array<InputMethodProperty> Obtains the list of installed input methods. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Return value - | Type | Description | - | ----------------------------------------------------------- | ---------------------- | - | Promise> | Promise used to return the list of installed input methods.| +**Return value** -- Example - ``` - var properties = InputMethodSetting.listInputMethod(); - for (var i = 0;i < properties.length; i++) { - var property = properties[i]; - console.info(property.packageName + "/" + property.methodId); - } - ``` +| Type | Description | +| ----------------------------------------------------------- | ---------------------- | +| Promise> | Promise used to return the list of installed input methods.| + +**Example** + +```js + var properties = InputMethodSetting.listInputMethod(); + for (var i = 0;i < properties.length; i++) { + var property = properties[i]; + console.info(property.packageName + "/" + property.methodId); + } +``` ### displayOptionalInputMethod @@ -181,12 +187,12 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| -- Example - ``` - InputMethodSetting.displayOptionalInputMethod(()=>{ - console.info('displayOptionalInputMethod is called'); - }); - ``` +**Example** +```js + InputMethodSetting.displayOptionalInputMethod(()=>{ + console.info('displayOptionalInputMethod is called'); + }); +``` ### displayOptionalInputMethod @@ -194,15 +200,16 @@ displayOptionalInputMethod(): Promise<void> Displays a dialog box for selecting an input method. This API uses an asynchronous callback to return the result. - **System capability**: SystemCapability.Miscservices.InputMethodFramework +**System capability**: SystemCapability.Miscservices.InputMethodFramework -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the execution result.| - - Example - ``` - InputMethodSetting.displayOptionalInputMethod(); - ``` +**Example** + +```js + InputMethodSetting.displayOptionalInputMethod(); +``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-inputmethodengine.md b/en/application-dev/reference/apis/js-apis-inputmethodengine.md index ba43211b4ae577be55718a6d32f50a565b2093b5..60c6c8a4ce2d0caad26c838e6353cdc21bcbc785 100644 --- a/en/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/en/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -1,7 +1,7 @@ # Input Method Engine -> ![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. +> ![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 @@ -52,17 +52,17 @@ Obtains an **InputMethodEngine** instance. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Return value +**Return value** - | Type | Description | - | --------------------------------------- | ------------ | - | [InputMethodEngine](#InputMethodEngine) | **InputMethodEngine** instance obtained.| +| Type | Description | +| --------------------------------------- | ------------ | +| [InputMethodEngine](#InputMethodEngine) | **InputMethodEngine** instance obtained.| -- Example +**Example** - ``` - var InputMethodEngine = inputMethodEngine.getInputMethodEngine(); - ``` +```js +var InputMethodEngine = inputMethodEngine.getInputMethodEngine(); +``` ## inputMethodEngine.createKeyboardDelegate @@ -72,17 +72,17 @@ Obtains a **KeyboardDelegate** instance. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Return value +**Return value** - | Type | Description | - | ------------------------------------- | ---------------- | - | [KeyboardDelegate](#KeyboardDelegate) | **KeyboardDelegate** instance obtained.| +| Type | Description | +| ------------------------------------- | ---------------- | +| [KeyboardDelegate](#KeyboardDelegate) | **KeyboardDelegate** instance obtained.| -- Example +**Example** - ``` - var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); - ``` +```js +var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); +``` ## InputMethodEngine @@ -96,21 +96,21 @@ Listens for the input method binding event. This API uses a callback to return t **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Listening type.
Set it to **'inputStart'**, which indicates listening for the input method binding event.| | callback | [KeyboardController](#KeyboardController), [TextInputClient](#TextInputClient) | Yes| Callback used to return the result.| -- Example +**Example** - ``` - InputMethodEngine.on('inputStart', (kbController, textInputClient) => { - KeyboardController = kbController; - TextInputClient = textInputClient; - }); - ``` +```js +InputMethodEngine.on('inputStart', (kbController, textInputClient) => { + KeyboardController = kbController; + TextInputClient = textInputClient; +}); +``` ### off('inputStart') @@ -120,20 +120,18 @@ Cancels listening for the input method binding event. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters - - | Name | Type | Mandatory| Description | - | -------- | -------------------- | ---- | ------------------------ | - | type | string | Yes | Listening type.
Set it to **'inputStart'**, which indicates listening for the input method binding event.| - | callback | [KeyboardController](#KeyboardController), [TextInputClient](#TextInputClient) | No| Callback used to return the result.| - +**Parameters** +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| type | string | Yes | Listening type.
Set it to **'inputStart'**, which indicates listening for the input method binding event.| +| callback | [KeyboardController](#KeyboardController), [TextInputClient](#TextInputClient) | No| Callback used to return the result.| -- Example +**Example** - ``` - InputMethodEngine.off('inputStart'); - ``` +```js +InputMethodEngine.off('inputStart'); +``` ### on('keyboardShow'|'keyboardHide') @@ -143,20 +141,20 @@ Listens for an input method event. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------ | ---- | ------------------------------------------------------------ | - | type | string | Yes | Listening type.
- The value **'keyboardShow'** means to listen for displaying of the input method.
- The value **'keyboardHide'** means to listen for hiding of the input method.| - | callback | void | No | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Listening type.
- The value **'keyboardShow'** means to listen for displaying of the input method.
- The value **'keyboardHide'** means to listen for hiding of the input method.| +| callback | void | No | Callback used to return the result. | -- Example +**Example** - ``` - InputMethodEngine.on('keyboardShow', (err) => { - console.info('keyboardShow'); - }); - ``` +```js +InputMethodEngine.on('keyboardShow', (err) => { + console.info('keyboardShow'); +}); +``` ### off('keyboardShow'|'keyboardHide') @@ -166,19 +164,18 @@ Cancels listening for an input method event. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------ | ---- | ------------------------------------------------------------ | - | type | string | Yes | Listening type.
- The value **'keyboardShow'** means to listen for displaying of the input method.
- The value **'keyboardHide'** means to listen for hiding of the input method.| - | callback | void | No | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Listening type.
- The value **'keyboardShow'** means to listen for displaying of the input method.
- The value **'keyboardHide'** means to listen for hiding of the input method.| +| callback | void | No | Callback used to return the result. | -- Example +**Example** - ``` - InputMethodEngine.off('keyboardShow'); - ``` - +```js +InputMethodEngine.off('keyboardShow'); +``` ## KeyboardDelegate @@ -192,22 +189,20 @@ Listens for a hard keyboard even. This API uses a callback to return the key inf **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters - - | Name | Type | Mandatory| Description | - | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Listening type.
- The value **'keyDown'** means to listen for pressing of a key.
- The value **'keyUp'** means to listen for releasing of a key.| - | callback | [KeyEvent](#KeyEvent) | Yes| Callback used to return the key information.| - +**Parameters** +| Name | Type | Mandatory| Description | +| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Listening type.
- The value **'keyDown'** means to listen for pressing of a key.
- The value **'keyUp'** means to listen for releasing of a key.| +| callback | [KeyEvent](#KeyEvent) | Yes| Callback used to return the key information.| -- Example +**Example** - ``` - KeyboardDelegate.on('keyDown', (event) => { - console.info('keyDown'); - }); - ``` +```js +KeyboardDelegate.on('keyDown', (event) => { + console.info('keyDown'); +}); +``` ### off('keyDown'|'keyUp') @@ -217,18 +212,18 @@ Cancels listening for a hard keyboard even. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Listening type.
- The value **'keyDown'** means to listen for pressing of a key.
- The value **'keyUp'** means to listen for releasing of a key.| - | callback | [KeyEvent](#KeyEvent) | No | Callback used to return the key information. | +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Listening type.
- The value **'keyDown'** means to listen for pressing of a key.
- The value **'keyUp'** means to listen for releasing of a key.| +| callback | [KeyEvent](#KeyEvent) | No | Callback used to return the key information. | -- Example +**Example** - ``` - KeyboardDelegate.off('keyDown'); - ``` +```js +KeyboardDelegate.off('keyDown'); +``` ### on('cursorContextChange') @@ -236,24 +231,22 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = Listens for cursor context changes. This API uses a callback to return the cursor information. - **System capability**: SystemCapability.Miscservices.InputMethodFramework - - - Parameters +**System capability**: SystemCapability.Miscservices.InputMethodFramework - | Name | Type | Mandatory| Description | - | -------- | ------ | ---- | ------------------------------------------------------------ | - | type | string | Yes | Listening type.
Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.| - | callback | number | Yes | Callback used to return the cursor information. | +**Parameters** +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Listening type.
Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.| +| callback | number | Yes | Callback used to return the cursor information. | +**Example** - - Example - - ``` - KeyboardDelegate.on('cursorContextChange', (x, y, height) => { - console.info('cursorContextChange'); - }); - ``` +```js +KeyboardDelegate.on('cursorContextChange', (x, y, height) => { + console.info('cursorContextChange'); +}); +``` ### off('cursorContextChange') @@ -263,19 +256,19 @@ Cancels listening for cursor context changes. **System capability**: SystemCapability.Miscservices.InputMethodFramework - - Parameters +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------- | ---- | ------------------------ | - | type | string | Yes | Listening type.
Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.| - | callback | number | No| Callback used to return the cursor information.| +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| type | string | Yes | Listening type.
Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.| +| callback | number | No| Callback used to return the cursor information.| +**Example** - - Example +```js +KeyboardDelegate.off('cursorContextChange'); +``` - ``` - KeyboardDelegate.off('cursorContextChange'); - ``` ### on('selectionChange') on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void @@ -284,20 +277,20 @@ Listens for text selection changes. This API uses a callback to return the text **System capability**: SystemCapability.Miscservices.InputMethodFramework - - Parameters +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Listening type.
Set it to **'selectionChange'**, which indicates listening for text selection changes.| +| callback | number | Yes | Callback used to return the text selection information. | - | Name | Type | Mandatory| Description | - | -------- | ------ | ---- | ------------------------------------------------------------ | - | type | string | Yes | Listening type.
Set it to **'selectionChange'**, which indicates listening for text selection changes.| - | callback | number | Yes | Callback used to return the text selection information. | +**Example** - - Example - - ``` - KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { - console.info('selectionChange'); - }); - ``` +```js +KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { + console.info('selectionChange'); +}); +``` ### off('selectionChange') @@ -307,18 +300,18 @@ Cancels listening for text selection changes. **System capability**: SystemCapability.Miscservices.InputMethodFramework - - Parameters +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------- | ---- | ------------------------ | - | type | string | Yes | Listening type.
Set it to **'selectionChange'**, which indicates listening for text selection changes.| - | callback | number | No| Callback used to return the text selection information.| +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| type | string | Yes | Listening type.
Set it to **'selectionChange'**, which indicates listening for text selection changes.| +| callback | number | No| Callback used to return the text selection information.| - - Example +**Example** - ``` - KeyboardDelegate.off('selectionChange'); - ``` +```js +KeyboardDelegate.off('selectionChange'); +``` ### on('textChange') @@ -329,20 +322,20 @@ Listens for text changes. This API uses a callback to return the current text co **System capability**: SystemCapability.Miscservices.InputMethodFramework - - Parameters +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Listening type.
Set it to **'textChange'**, which indicates listening for text changes.| - | callback | string | Yes| Callback used to return the current text content.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Listening type.
Set it to **'textChange'**, which indicates listening for text changes.| +| callback | string | Yes| Callback used to return the current text content.| - - Example +**Example** - ``` - KeyboardDelegate.on('textChange', (text) => { - console.info('textChange'); - }); - ``` +```js +KeyboardDelegate.on('textChange', (text) => { + console.info('textChange'); +}); +``` ### off('textChange') @@ -352,18 +345,18 @@ Cancels listening for text changes. **System capability**: SystemCapability.Miscservices.InputMethodFramework - - Parameters +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------- | ---- | ------------------------ | - | type | string | Yes | Listening type.
Set it to **'textChange'**, which indicates listening for text changes.| - | callback | string | No| Callback used to return the current text content.| +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| type | string | Yes | Listening type.
Set it to **'textChange'**, which indicates listening for text changes.| +| callback | string | No| Callback used to return the current text content.| - - Example +**Example** - ``` - KeyboardDelegate.off('textChange'); - ``` +```js +KeyboardDelegate.off('textChange'); +``` ## KeyboardController @@ -377,16 +370,16 @@ Hides the keyboard. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------- | ---- | -------- | - | callback | AsyncCallback<void> | No | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | -------- | +| callback | AsyncCallback<void> | No | Callback used to return the result.| -- Example +**Example** -``` +```js KeyboardController.hideKeyboard(()=>{ }); ``` @@ -399,16 +392,16 @@ Hides the keyboard. This API uses a promise to return the result. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Return value +**Return value** - | Type | Description: | - | ---------------- | -------- | - | Promise<void> | Promise used to return the result.| +| Type | Description: | +| ---------------- | -------- | +| Promise<void> | Promise used to return the result.| -- Example +**Example** -``` +```js KeyboardController.hideKeyboard(); ``` @@ -424,19 +417,20 @@ Obtains the specific-length text before the cursor. This API uses an asynchronou **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| length | number | Yes| Text length.| +| callback | AsyncCallback<string> | Yes| Text returned.| - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | length | number | Yes| Text length.| - | callback | AsyncCallback<string> | Yes| Text returned.| +**Example** -- Example - ``` - TextInputClient.getForward(5,(text) =>{ - console.info("text = " + text); - }); - ``` +```js + TextInputClient.getForward(5,(text) =>{ + console.info("text = " + text); + }); +``` ### getForward @@ -446,22 +440,24 @@ Obtains the specific-length text before the cursor. This API uses a promise to r **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | length | number | Yes| Text length.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| length | number | Yes| Text length.| -- Return value - | Type | Description | - | ------------------------------- | ------------------------------------------------------------ | - | Promise<string> | Text returned. | +**Return value** -- Example - ``` - var text = TextInputClient.getForward(5); - console.info("text = " + text); - ``` +| Type | Description | +| ------------------------------- | ------------------------------------------------------------ | +| Promise<string> | Text returned. | + +**Example** + +```js + var text = TextInputClient.getForward(5); + console.info("text = " + text); +``` ### getBackward @@ -471,19 +467,20 @@ Obtains the specific-length text after the cursor. This API uses an asynchronous **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | length | number | Yes| Text length.| - | callback | AsyncCallback<string> | Yes| Text returned.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| length | number | Yes| Text length.| +| callback | AsyncCallback<string> | Yes| Text returned.| -- Example - ``` - TextInputClient.getBackward(5,(text)=>{ - console.info("text = " + text); - }); - ``` +**Example** + +```js + TextInputClient.getBackward(5,(text)=>{ + console.info("text = " + text); +}); +``` ### getBackward @@ -493,22 +490,24 @@ Obtains the specific-length text after the cursor. This API uses a promise to re **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | length | number | Yes| Text length.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| length | number | Yes| Text length.| -- Return value - | Type | Description | - | ------------------------------- | ------------------------------------------------------------ | - | Promise<string> | Text returned. | +**Return value** -- Example - ``` - var text = TextInputClient.getBackward(5); - console.info("text = " + text); - ``` +| Type | Description | +| ------------------------------- | ------------------------------------------------------------ | +| Promise<string> | Text returned. | + +**Example** + +```js + var text = TextInputClient.getBackward(5); + console.info("text = " + text); +``` ### deleteForward @@ -518,19 +517,21 @@ Deletes the fixed-length text before the cursor. This API uses an asynchronous c **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | length | number | Yes| Text length.| - | callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| length | number | Yes| Text length.| +| callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.| + +**Example** + +```js +TextInputClient.deleteForward(5,(isSuccess)=>{ + console.info("isSuccess = " + isSuccess); +}); +``` -- Example - ``` - TextInputClient.deleteForward(5,(isSuccess)=>{ - console.info("isSuccess = " + isSuccess); - }); - ``` ### deleteForward deleteForward(length:number): Promise<boolean> @@ -539,23 +540,25 @@ Deletes the fixed-length text before the cursor. This API uses a promise to retu **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters - - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | length | number | Yes| Text length.| - -- Return value - | Type | Description | - | ------------------------------- | ------------------------------------------------------------ | - | Promise<boolean> | Returns whether the operation is successful. | - - - Example - ``` - var isSuccess = TextInputClient.deleteForward(5); - console.info("isSuccess = " + isSuccess); - ``` - +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| length | number | Yes| Text length.| + +**Return value** + +| Type | Description | +| ------------------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Returns whether the operation is successful. | + +**Example** + +```js + var isSuccess = TextInputClient.deleteForward(5); + console.info("isSuccess = " + isSuccess); +``` + ### deleteBackward deleteBackward(length:number, callback: AsyncCallback<boolean>): void @@ -564,19 +567,20 @@ Deletes the fixed-length text after the cursor. This API uses an asynchronous ca **System capability**: SystemCapability.Miscservices.InputMethodFramework - - Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | length | number | Yes| Text length.| - | callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| length | number | Yes| Text length.| +| callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.| - - Example - ``` - TextInputClient.deleteBackward(5, (isSuccess)=>{ - console.info("isSuccess = " + isSuccess); - }); - ``` +**Example** + +```js + TextInputClient.deleteBackward(5, (isSuccess)=>{ + console.info("isSuccess = " + isSuccess); +}); +``` ### deleteBackward @@ -586,22 +590,25 @@ Deletes the fixed-length text after the cursor. This API uses a promise to retur **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | length | number | Yes| Text length.| +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| length | number | Yes| Text length.| -- Return value - | Type | Description | - | ------------------------------- | ------------------------------------------------------------ | - | Promise<boolean> | Returns whether the operation is successful. | +**Return value** -- Example +| Type | Description | +| ------------------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Returns whether the operation is successful. | + +**Example** + +```js +var isSuccess = TextInputClient.deleteBackward(5); +console.info("isSuccess = " + isSuccess); +``` - ``` - var isSuccess = TextInputClient.deleteBackward(5); - console.info("isSuccess = " + isSuccess); - ``` ### sendKeyFunction sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void @@ -610,19 +617,20 @@ Sets the Enter key to send the text to its target. This API uses an asynchronous **System capability**: SystemCapability.Miscservices.InputMethodFramework - - Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | action | number | Yes| Edit box attribute.| - | callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| action | number | Yes| Edit box attribute.| +| callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.| - - Example - ``` - TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{ - console.info("isSuccess = " + isSuccess); - }); - ``` +**Example** + +```js + TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{ + console.info("isSuccess = " + isSuccess); +}); +``` ### sendKeyFunction @@ -632,23 +640,25 @@ Sets the Enter key to send the text to its target. This API uses a promise to re **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | action | number | Yes| Edit box attribute.| +**Parameters** -- Return value - | Type | Description | - | ------------------------------- | ------------------------------------------------------------ | - | Promise<boolean> | Returns whether the operation is successful. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| action | number | Yes| Edit box attribute.| -- Example +**Return value** + +| Type | Description | +| ------------------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Returns whether the operation is successful. | + +**Example** + +```js +var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT); +console.info("isSuccess = " + isSuccess); +``` - ``` - var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT); - console.info("isSuccess = " + isSuccess); - ``` - ### insertText insertText(text:string, callback: AsyncCallback<boolean>): void @@ -657,19 +667,20 @@ Inserts text. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | text | string | Yes| Text to insert.| - | callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| text | string | Yes| Text to insert.| +| callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.| -- Example - ``` - TextInputClient.insertText("test", (isSuccess)=>{ - console.info("isSuccess = " + isSuccess); - }); - ``` +**Example** + +```js +TextInputClient.insertText("test", (isSuccess)=>{ + console.info("isSuccess = " + isSuccess); +}); +``` ### insertText @@ -679,23 +690,25 @@ Inserts text. This API uses a promise to return the result. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | text | string | Yes| Text to insert.| +**Parameters** -- Return value - | Type | Description | - | ------------------------------- | ------------------------------------------------------------ | - | Promise<boolean> | Returns whether the operation is successful. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| text | string | Yes| Text to insert.| -- Example +**Return value** + +| Type | Description | +| ------------------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Returns whether the operation is successful. | + +**Example** + +```js +var isSuccess = TextInputClient.insertText("test"); +console.info("isSuccess = " + isSuccess); +``` - ``` - var isSuccess = TextInputClient.insertText("test"); - console.info("isSuccess = " + isSuccess); - ``` - ### getEditorAttribute getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void @@ -704,34 +717,38 @@ Obtains the attribute of the edit box. This API uses an asynchronous callback to **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Parameters - | Name | Type | Mandatory | Description | - | ------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | - | callback | AsyncCallback<[EditorAttribute](#EditorAttribute)> | Yes| Attribute of the edit box. | +**Parameters** + +| Name | Type | Mandatory | Description | +| ------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| callback | AsyncCallback<[EditorAttribute](#EditorAttribute)> | Yes| Attribute of the edit box. | + +**Example** -- Example - ``` - TextInputClient.getEditorAttribute((EditorAttribute)=>{ - }); - ``` +```js + TextInputClient.getEditorAttribute((EditorAttribute)=>{ + }); +``` ### getEditorAttribute -getEditorAttribute(): Promise<EditorAttribute> +getEditorAttribute(): EditorAttribute Obtains the attribute of the edit box. This API uses a promise to return the result. **System capability**: SystemCapability.Miscservices.InputMethodFramework -- Return value - | Type | Description | - | ------------------------------- | ------------------------------------------------------------ | - | Promise<[EditorAttribute](#EditorAttribute)> | Returns the attribute of the edit box. | +**Return value** + +| Type | Description | +| ------------------------------- | ------------------------------------------------------------ | +| Promise<[EditorAttribute](#EditorAttribute)> | Returns the attribute of the edit box. | -- Example - ``` - var EditorAttribute = TextInputClient.getEditorAttribute(); - ``` +**Example** + +```js +var EditorAttribute = TextInputClient.getEditorAttribute(); +``` ## EditorAttribute diff --git a/en/application-dev/reference/apis/js-apis-media.md b/en/application-dev/reference/apis/js-apis-media.md index 4dc50368c1af59ab0f7b1f0326e21f63e97b8b12..90041e190287f35f80ed0913690a8cdc3b11ae45 100644 --- a/en/application-dev/reference/apis/js-apis-media.md +++ b/en/application-dev/reference/apis/js-apis-media.md @@ -576,7 +576,7 @@ let fdPath = 'fd://' let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; fileIO.open(path).then(fdNumber) => { fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); + console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); }).catch((err) => { diff --git a/en/application-dev/reference/apis/js-apis-medialibrary.md b/en/application-dev/reference/apis/js-apis-medialibrary.md index 5499cc815509f85de6930cf7130d7ac1e74f259a..6b1b11f9e17627eea877edf5b34b25551f25ce24 100644 --- a/en/application-dev/reference/apis/js-apis-medialibrary.md +++ b/en/application-dev/reference/apis/js-apis-medialibrary.md @@ -1,6 +1,6 @@ # Media Library Management -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -208,7 +208,7 @@ async function example() { let mediaType = mediaLibrary.MediaType.IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; const path = await media.getPublicDirectory(DIR_IMAGE); - mediaLibrary.createAsset(mediaType, 'imageCallBack.jpg', path + 'myPicture/', (err, fileAsset) => { + media.createAsset(mediaType, 'imageCallBack.jpg', path + 'myPicture/', (err, fileAsset) => { if (fileAsset != undefined) { console.info('createAsset successfully, message = ' + err); } else { @@ -250,7 +250,7 @@ async function example() { let mediaType = mediaLibrary.MediaType.IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; const path = await media.getPublicDirectory(DIR_IMAGE); - mediaLibrary.createAsset(mediaType, "image01.jpg", path + 'myPicture/').then (function (asset) { + media.createAsset(mediaType, "image01.jpg", path + 'myPicture/').then (function (asset) { console.info("createAsset successfully:"+ JSON.stringify(asset)); }).catch(function(err){ console.info("createAsset failed with error:"+ err); @@ -720,29 +720,29 @@ Provides APIs for encapsulating file asset attributes. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core -| Name | Type | Readable | Writable | Description | +| Name | Type | Readable| Writable| Description | | ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ | -| id | number | Yes | No | File asset ID. | -| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. | -| mimeType | string | Yes | No | Extended file attributes. | -| mediaType8+ | [MediaType](#mediatype8) | Yes | No | Media type. | -| displayName | string | Yes | Yes | Display file name, including the file name extension. | -| title | string | Yes | Yes | Title in the file. | -| relativePath8+ | string | Yes | Yes | Relative public directory of the file. | -| parent8+ | number | Yes | No | Parent directory ID. | -| size | number | Yes | No | File size, in bytes. | -| dateAdded | number | Yes | No | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.) | -| dateModified | number | Yes | No | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.) | -| dateTaken | number | Yes | No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) | -| artist8+ | string | Yes | No | Artist of the file. | -| audioAlbum8+ | string | Yes | No | Audio album. | -| width | number | Yes | No | Image width, in pixels. | -| height | number | Yes | No | Image height, in pixels. | -| orientation | number | Yes | Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees). | -| duration8+ | number | Yes | No | Duration, in seconds. | -| albumId | number | Yes | No | ID of the album to which the file belongs. | -| albumUri8+ | string | Yes | No | URI of the album to which the file belongs. | -| albumName | string | Yes | No | Name of the album to which the file belongs. | +| id | number | Yes | No | File asset ID. | +| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. | +| mimeType | string | Yes | No | Extended file attributes. | +| mediaType8+ | [MediaType](#mediatype8) | Yes | No | Media type. | +| displayName | string | Yes | Yes | Display file name, including the file name extension. | +| title | string | Yes | Yes | Title in the file. | +| relativePath8+ | string | Yes | Yes | Relative public directory of the file. | +| parent8+ | number | Yes | No | Parent directory ID. | +| size | number | Yes | No | File size, in bytes. | +| dateAdded | number | Yes | No | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.) | +| dateModified | number | Yes | No | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.) | +| dateTaken | number | Yes | No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) | +| artist8+ | string | Yes | No | Artist of the file. | +| audioAlbum8+ | string | Yes | No | Audio album. | +| width | number | Yes | No | Image width, in pixels. | +| height | number | Yes | No | Image height, in pixels. | +| orientation | number | Yes | Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees).| +| duration8+ | number | Yes | No | Duration, in seconds. | +| albumId | number | Yes | No | ID of the album to which the file belongs. | +| albumUri8+ | string | Yes | No | URI of the album to which the file belongs. | +| albumName | string | Yes | No | Name of the album to which the file belongs. | ### isDirectory8+ @@ -757,9 +757,9 @@ Checks whether this file asset is a directory. This API uses an asynchronous cal **Parameters** -| Parameter | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | -------- | ---------------------------- | ---- | ------------------- | -| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the file asset is a directory. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the file asset is a directory.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-missionManager.md b/en/application-dev/reference/apis/js-apis-missionManager.md index a36fc053da29747df95dcab84468288cd7421acc..a9c0c75becf3397a933fe15dc57429029759624b 100644 --- a/en/application-dev/reference/apis/js-apis-missionManager.md +++ b/en/application-dev/reference/apis/js-apis-missionManager.md @@ -1,11 +1,11 @@ # missionManager -> ![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. -Provides mission management. You can use the APIs to lock, unlock, and clear missions, and switch a mission to the foreground. +missionManager provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground. ## Modules to Import @@ -34,7 +34,7 @@ Registers a listener to observe the mission status. | Type| Description| | -------- | -------- | - | number | Returns the index of the listener, which is created by the system and allocated when the mission status listener is registered. Each listener has a unique index.| + | number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.| **Example** @@ -55,7 +55,7 @@ Registers a listener to observe the mission status. unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>): void; -Unregisters a mission status listener. This API uses an asynchronous callback to return the result. +Deregisters a mission status listener. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Mission @@ -63,7 +63,7 @@ Unregisters a mission status listener. This API uses an asynchronous callback to | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.| + | listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -88,7 +88,7 @@ Unregisters a mission status listener. This API uses an asynchronous callback to unregisterMissionListener(listenerId: number): Promise<void>; -Unregisters a mission status listener. This API uses a promise to return the result. +Deregisters a mission status listener. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Mission @@ -96,7 +96,7 @@ Unregisters a mission status listener. This API uses a promise to return the res | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.| + | listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.| **Return value** @@ -126,7 +126,7 @@ Unregisters a mission status listener. This API uses a promise to return the res getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<MissionInfo>): void; -Obtains the information of a given mission. This API uses an asynchronous callback to return the result. +Obtains the information about a given mission. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Mission @@ -159,7 +159,7 @@ Obtains the information of a given mission. This API uses an asynchronous callba getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>; -Obtains the information of a given mission. This API uses a promise to return the result. +Obtains the information about a given mission. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Mission @@ -191,7 +191,7 @@ Obtains the information of a given mission. This API uses a promise to return th getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Array<MissionInfo>>): void; -Obtains information of all missions. This API uses an asynchronous callback to return the result. +Obtains information about all missions. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Mission @@ -220,7 +220,7 @@ Obtains information of all missions. This API uses an asynchronous callback to r getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionInfo>>; -Obtains information of all missions. This API uses a promise to return the result. +Obtains information about all missions. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Mission @@ -617,7 +617,7 @@ Switches a given mission to the foreground. This API uses an asynchronous callba moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback<void>): void; -Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses an asynchronous callback to return the result. +Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Mission @@ -651,7 +651,7 @@ Switches a given mission to the foreground, with the startup parameters for the moveMissionToFront(missionId: number, options?: StartOptions): Promise<void>; -Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses a promise to return the result. +Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Mission @@ -697,7 +697,7 @@ Describes the mission information. | runningState | number | Yes| Yes| Running state of the mission.| | lockedState | boolean | Yes| Yes| Locked state of the mission.| | timestamp | string | Yes| Yes| Latest time when the mission was created or updated.| -| want | [Want](js-apis-featureAbility.md#want) | Yes| Yes| **Want** information of the mission.| +| want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.| | label | string | Yes| Yes| Label of the mission.| | iconPath | string | Yes| Yes| Path of the mission icon.| | continuable | boolean | Yes| Yes| Whether the mission is continuable.| diff --git a/en/application-dev/reference/apis/js-apis-net-connection.md b/en/application-dev/reference/apis/js-apis-net-connection.md index bd4404ebc0f7c9e74a5e67dd302b6f867089ccf6..6e1eab82dbbd426d7e1facd48a0516d981658f28 100644 --- a/en/application-dev/reference/apis/js-apis-net-connection.md +++ b/en/application-dev/reference/apis/js-apis-net-connection.md @@ -7,7 +7,7 @@ ## Modules to Import -```javascript +```js import connection from '@ohos.net.connection' ``` @@ -29,7 +29,7 @@ Obtains the default active data network. This API uses an asynchronous callback **Example** -```javascript +```js connection.getDefaultNet(function (error, netHandle) { console.log(JSON.stringify(error)) console.log(JSON.stringify(netHandle)) @@ -54,7 +54,7 @@ Obtains the default active data network. This API uses a promise to return the r **Example** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { console.log(JSON.stringify(netHandle)) }) @@ -76,7 +76,7 @@ Checks whether the default data network is activated. This API uses an asynchron **Example** -```javascript +```js connection.hasDefaultNet(function (error, has) { console.log(JSON.stringify(error)) console.log(has) @@ -99,7 +99,7 @@ Checks whether the default data network is activated. This API uses a promise to **Example** -```javascript +```js connection.hasDefaultNet().then(function (has) { console.log(has) }) @@ -122,7 +122,7 @@ Obtains the list of all active data networks. This API uses an asynchronous call **Example** -``` +```js connection.getAllNets(function (error, nets) { console.log(JSON.stringify(error)) console.log(JSON.stringify(nets)) @@ -147,7 +147,7 @@ Obtains the list of all active data networks. This API uses a promise to return **Example** -``` +```js connection.getAllNets().then(function (nets) { console.log(JSON.stringify(nets)) }); @@ -172,7 +172,7 @@ Obtains connection properties of the network corresponding to given network hand **Example** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { connection.getConnectionProperties(netHandle, function (error, info) { console.log(JSON.stringify(error)) @@ -205,7 +205,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi **Example** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { connection.getConnectionProperties(netHandle).then(function (info) { console.log(JSON.stringify(info)) @@ -232,7 +232,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th **Example** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { connection.getNetCapabilities(netHandle, function (error, info) { console.log(JSON.stringify(error)) @@ -265,7 +265,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th **Example** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { connection.getNetCapabilities(netHandle).then(function (info) { console.log(JSON.stringify(info)) @@ -291,7 +291,7 @@ Reports connection of the data network. This API uses an asynchronous callback t **Example** -``` +```js connection.getDefaultNet().then(function (netHandle) { connection.reportNetConnected(netHandle, function (error) { console.log(JSON.stringify(error)) @@ -322,7 +322,7 @@ Reports connection of the data network. This API uses a promise to return the re **Example** -``` +```js connection.getDefaultNet().then(function (netHandle) { connection.reportNetConnected(netHandle).then(function () { console.log(`report success`) @@ -349,7 +349,7 @@ Reports disconnection of the data network. This API uses an asynchronous callbac **Example** -``` +```js connection.getDefaultNet().then(function (netHandle) { connection.reportNetDisconnected(netHandle, function (error) { console.log(JSON.stringify(error)) @@ -380,7 +380,7 @@ Reports disconnection of the data network. This API uses a promise to return the **Example** -``` +```js connection.getDefaultNet().then(function (netHandle) { connection.reportNetDisconnected(netHandle).then(function () { console.log(`report success`) @@ -407,7 +407,7 @@ Resolves the host name by using the default network to obtain all IP addresses. **Example** -``` +```js let host = "xxxx"; connection.getAddressesByName(host, function (error, addresses) { console.log(JSON.stringify(error)) @@ -439,7 +439,7 @@ Resolves the host name by using the default network to obtain all IP addresses. **Example** -``` +```js let host = "xxxx"; connection.getAddressesByName(host).then(function (addresses) { console.log(JSON.stringify(addresses)) @@ -469,7 +469,7 @@ Obtains the handle of the network specified by **netSpecifier**. **Example** -```javascript +```js // Default network let netConnection = connection.createNetConnection() @@ -502,7 +502,7 @@ Registers a listener for **netAvailable** events. **Example** -```javascript +```js netConnection.on('netAvailable', function (data) { console.log(JSON.stringify(data)) }) @@ -525,7 +525,7 @@ Registers a listener for **netCapabilitiesChange** events. **Example** -```javascript +```js netConnection.on('netCapabilitiesChange', function (data) { console.log(JSON.stringify(data)) }) @@ -548,7 +548,7 @@ Registers a listener for **netConnectionPropertiesChange** events. **Example** -```javascript +```js netConnection.on('netConnectionPropertiesChange', function (data) { console.log(JSON.stringify(data)) }) @@ -571,7 +571,7 @@ Registers a listener for **netBlockStatusChange** events. **Example** -```javascript +```js netConnection.on('netBlockStatusChange', function (data) { console.log(JSON.stringify(data)) }) @@ -594,7 +594,7 @@ Registers a listener for **netLost** events. **Example** -```javascript +```js let netConnection1 = connection.createNetConnection() netConnection1.on('netLost', function (data) { console.log(JSON.stringify(data)) @@ -618,7 +618,7 @@ Registers a listener for **netUnavailable** events. **Example** -```javascript +```js netConnection.on('netUnavailable', function (data) { console.log(JSON.stringify(data)) }) @@ -642,7 +642,7 @@ Registers a listener for network status changes. **Example** -```javascript +```js netConnection.register(function (error) { console.log(JSON.stringify(error)) }) @@ -664,7 +664,7 @@ Unregisters the listener for network status changes. **Example** -```javascript +```js netConnection.unregister(function (error) { console.log(JSON.stringify(error)) }) @@ -703,7 +703,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre **Example** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { let host = "xxxx"; netHandle.getAddressesByName(host, function (error, addresses) { @@ -737,7 +737,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre **Example** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { let host = "xxxx"; netHandle.getAddressesByName(host).then(function (addresses) { @@ -765,7 +765,7 @@ Resolves the host name by using the corresponding network to obtain the first IP **Example** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { let host = "xxxx"; netHandle.getAddressByName(host, function (error, address) { @@ -799,7 +799,7 @@ Resolves the host name by using the corresponding network to obtain the first IP **Example** -```javascript +```js connection.getDefaultNet().then(function (netHandle) { let host = "xxxx"; netHandle.getAddressByName(host).then(function (address) { diff --git a/en/application-dev/reference/apis/js-apis-observer.md b/en/application-dev/reference/apis/js-apis-observer.md index 29d9e85a234e0817b29645ac6daed24d8d5eb8cf..b68d1dc35be314220feb88ba2d67a3429ce75c58 100644 --- a/en/application-dev/reference/apis/js-apis-observer.md +++ b/en/application-dev/reference/apis/js-apis-observer.md @@ -7,7 +7,7 @@ ## Modules to Import -``` +```js import observer from '@ohos.telephony.observer' ``` @@ -30,7 +30,7 @@ Registers an observer for network status change events. This API uses an asynchr **Example** -``` +```js observer.on('networkStateChange', data =>{ console.log("on networkStateChange, data:" + JSON.stringify(data)); }); @@ -57,7 +57,7 @@ Registers an observer for network status change events of the SIM card in the sp **Example** -``` +```js observer.on('networkStateChange', {slotId: 0}, data =>{ console.log("on networkStateChange, data:" + JSON.stringify(data)); }); @@ -87,7 +87,7 @@ Unregisters the observer for network status change events. This API uses an asyn **Example** -``` +```js let callback = data => { console.log("on networkStateChange, data:" + JSON.stringify(data)); } @@ -114,7 +114,7 @@ Registers an observer for signal status change events. This API uses an asynchro **Example** -``` +```js observer.on('signalInfoChange', data =>{ console.log("on signalInfoChange, data:" + JSON.stringify(data)); }); @@ -139,7 +139,7 @@ Registers an observer for signal status change events of the SIM card in the spe **Example** -``` +```js observer.on('signalInfoChange', {slotId: 0}, data =>{ console.log("on signalInfoChange, data:" + JSON.stringify(data)); }); @@ -167,7 +167,7 @@ Unregisters the observer for signal status change events. This API uses an async **Example** -``` +```js let callback = data => { console.log("on signalInfoChange, data:" + JSON.stringify(data)); } @@ -197,7 +197,7 @@ Registers an observer for call status change events. This API uses an asynchrono **Example** -``` +```js observer.on('callStateChange', value =>{ console.log("on callStateChange, state:" + value.state + ", number:" + value.number); }); @@ -224,7 +224,7 @@ Registers an observer for call status change events. This API uses an asynchrono **Example** -``` +```js observer.on('callStateChange', {slotId: 0}, value =>{ console.log("on callStateChange, state:" + value.state + ", number:" + value.number); }); @@ -254,7 +254,7 @@ Unregisters the observer for call status change events. This API uses an asynchr **Example** -``` +```js let callback = value => { console.log("on callStateChange, state:" + value.state + ", number:" + value.number); } @@ -282,7 +282,7 @@ Registers an observer for connection status change events of the cellular data l **Example** -``` +```js observer.on('cellularDataConnectionStateChange', value =>{ console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); }); @@ -307,7 +307,7 @@ Registers an observer for connection status change events of the cellular data l **Example** -``` +```js observer.on('cellularDataConnectionStateChange', {slotId: 0}, value =>{ console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); }); @@ -335,7 +335,7 @@ Unregisters the observer for connection status change events of the cellular dat **Example** -``` +```js let callback = value => { console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); } @@ -363,7 +363,7 @@ Registers an observer for the uplink and downlink data flow status change events **Example** -``` +```js observer.on('cellularDataFlowChange', data =>{ console.log("on networkStateChange, data:" + JSON.stringify(data)); }); @@ -388,7 +388,7 @@ Registers an observer for the uplink and downlink data flow status change events **Example** -``` +```js observer.on('cellularDataFlowChange', {slotId: 0}, data =>{ console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); }); @@ -416,7 +416,7 @@ Unregisters the observer for the uplink and downlink data flow status change eve **Example** -``` +```js let callback = data => { console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); } @@ -444,7 +444,7 @@ Registers an observer for SIM card status change events. This API uses an asynch **Example** -``` +```js observer.on('simStateChange', data =>{ console.log("on simStateChange, data:" + JSON.stringify(data)); }); @@ -469,7 +469,7 @@ Registers an observer for status change events of the SIM card in the specified **Example** -``` +```js observer.on('simStateChange', {slotId: 0}, data =>{ console.log("on simStateChange, data:" + JSON.stringify(data)); }); @@ -497,7 +497,7 @@ Unregisters the observer for SIM card status change events. This API uses an asy **Example** -``` +```js let callback = data => { console.log("on simStateChange, data:" + JSON.stringify(data)); } diff --git a/en/application-dev/reference/apis/js-apis-particleAbility.md b/en/application-dev/reference/apis/js-apis-particleAbility.md index 7955a810d33f3b6e9cfe23d6c939c1a83bae92c4..a5a215f95741a7467179df5e59fef4115012d5c3 100644 --- a/en/application-dev/reference/apis/js-apis-particleAbility.md +++ b/en/application-dev/reference/apis/js-apis-particleAbility.md @@ -1,6 +1,6 @@ # ParticleAbility Module -> ![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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Constraints @@ -260,16 +260,16 @@ Requests a continuous task from the system. This API uses a promise to return th **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| id | number | Yes| Notification ID of a continuous task.| -| request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.| +| id | number | Yes | Notification ID of a continuous task. | +| 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.| +| Promise\ | Promise used to return the result. | **Example** @@ -323,9 +323,9 @@ Requests to cancel a continuous task from the system. This API uses an asynchron **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** @@ -354,9 +354,9 @@ Requests a continuous task from the system. This API uses a promise to return th **Return value** -| Type | Description | +| Type | Description | | -------------- | ------------------------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise used to return the result. | **Example** @@ -382,21 +382,21 @@ Connects this ability to a specific Service ability. This API uses a callback to **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | ------- | -------------- | ---- | ---------------------------- | -| request | [Want](js-apis-featureAbility.md#want) | Yes | Service ability to connect.| -| options | ConnectOptions | Yes | Callback used to return the result. | +| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect. | +| options | ConnectOptions | Yes | Callback used to return the result. | -ConnectOptions +**ConnectOptions** **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| 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. | +| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. | +| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called. | **Example** @@ -440,9 +440,9 @@ Disconnects this ability from the Service ability. This API uses a callback to r **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** @@ -486,9 +486,9 @@ Disconnects this ability from the Service ability. This API uses a promise to re **Return value** -| Type | Description | +| Type | Description | | -------------- | ------------------------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise used to return the result. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-pasteboard.md b/en/application-dev/reference/apis/js-apis-pasteboard.md index f6bfa278469a5c930c2140078ceee5f0613ec56b..c5ca90fd33c1de4b2eb4f4fff33eee5e2d899a79 100644 --- a/en/application-dev/reference/apis/js-apis-pasteboard.md +++ b/en/application-dev/reference/apis/js-apis-pasteboard.md @@ -1,8 +1,8 @@ # Pasteboard -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **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 @@ -19,11 +19,11 @@ import pasteboard from '@ohos.pasteboard'; | Name | Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| MAX_RECORD_NUM7+ | number | Yes | No | Maximum number of records allowed in a **PasteData** object. | -| MIMETYPE_TEXT_HTML7+ | string | Yes | No | MIME type of the HTML text. | -| MIMETYPE_TEXT_WANT7+ | string | Yes | No | MIME type of the Want text. | -| MIMETYPE_TEXT_PLAIN7+ | string | Yes | No | MIME type of the plain text. | -| MIMETYPE_TEXT_URI7+ | string | Yes | No | MIME type of the URI text. | +| MAX_RECORD_NUM7+ | number | Yes | No | Maximum number of records allowed in a **PasteData** object. | +| MIMETYPE_TEXT_HTML7+ | string | Yes | No | MIME type of the HTML text. | +| MIMETYPE_TEXT_WANT7+ | string | Yes | No | MIME type of the Want text. | +| MIMETYPE_TEXT_PLAIN7+ | string | Yes | No | MIME type of the plain text. | +| MIMETYPE_TEXT_URI7+ | string | Yes | No | MIME type of the URI text. | ## pasteboard.createPlainTextData @@ -34,21 +34,23 @@ Creates a **PasteData** object for plain text. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | text | string | Yes | Plain text. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | [PasteData](#pastedata) | **PasteData** object with the specified content. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| text | string | Yes | Plain text. | -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("content"); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| [PasteData](#pastedata) | **PasteData** object with the specified content. | + +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("content"); +``` ## pasteboard.createHtmlData7+ @@ -59,22 +61,24 @@ Creates a **PasteData** object for HTML text. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | htmlText | string | Yes | HTML text. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| htmlText | string | Yes | HTML text. | -- Return values - | Type | Description | - | -------- | -------- | - | [PasteData](#pastedata) | **PasteData** object with the specified content. | +**Return value** -- Example - - ``` - var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; - var pasteData = pasteboard.createHtmlData(html); - ``` +| Type | Description | +| -------- | -------- | +| [PasteData](#pastedata) | **PasteData** object with the specified content. | + +**Example** + +```js +var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +var pasteData = pasteboard.createHtmlData(html); +``` ## pasteboard.createWantData7+ @@ -85,25 +89,27 @@ Creates a **PasteData** object for Want text. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#want) | Yes | Want text. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | [PasteData](#pastedata) | **PasteData** object with the specified content. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes | Want text. | -- Example - - ``` - var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" - }; - var pasteData = pasteboard.createWantData(object); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| [PasteData](#pastedata) | **PasteData** object with the specified content. | + +**Example** + +```js +var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" +}; +var pasteData = pasteboard.createWantData(object); +``` ## pasteboard.createUriData7+ @@ -114,21 +120,23 @@ Creates a **PasteData** object for URI text. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | uri | string | Yes | URI text. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| uri | string | Yes | URI text. | -- Return values - | Type | Description | - | -------- | -------- | - | [PasteData](#pastedata) | **PasteData** object with the specified content. | +**Return value** -- Example - - ``` - var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); - ``` +| Type | Description | +| -------- | -------- | +| [PasteData](#pastedata) | **PasteData** object with the specified content. | + +**Example** + +```js +var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); +``` ## pasteboard.createPlainTextRecord7+ @@ -139,21 +147,23 @@ Creates a **PasteDataRecord** object of the plain text type. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | text | string | Yes | Plain text. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| text | string | Yes | Plain text. | -- Return values - | Type | Description | - | -------- | -------- | - | [PasteDataRecord](#pastedatarecord7) | New plain text record. | +**Return value** -- Example - - ``` - var record = pasteboard.createPlainTextRecord("hello"); - ``` +| Type | Description | +| -------- | -------- | +| [PasteDataRecord](#pastedatarecord7) | New plain text record. | + +**Example** + +```js +var record = pasteboard.createPlainTextRecord("hello"); +``` ## pasteboard.createHtmlTextRecord7+ @@ -164,22 +174,24 @@ Creates a **PasteDataRecord** object of the HTML text type. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | htmlText | string | Yes | HTML text. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| htmlText | string | Yes | HTML text. | + +**Return value** -- Return values - | Type | Description | - | -------- | -------- | - | [PasteDataRecord](#pastedatarecord7) | New HTML record. | +| Type | Description | +| -------- | -------- | +| [PasteDataRecord](#pastedatarecord7) | New HTML record. | -- Example - - ``` - var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; - var record = pasteboard.createHtmlTextRecord(html); - ``` +**Example** + +```js +var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +var record = pasteboard.createHtmlTextRecord(html); +``` ## pasteboard.createWantRecord7+ @@ -190,25 +202,27 @@ Creates a **PasteDataRecord** object of the Want text type. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#want) | Yes | Want text. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | [PasteDataRecord](#pastedatarecord7) | New Want record. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes | Want text. | -- Example - - ``` - var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" - }; - var record = pasteboard.createWantRecord(object); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| [PasteDataRecord](#pastedatarecord7) | New Want record. | + +**Example** + +```js +var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" +}; +var record = pasteboard.createWantRecord(object); +``` ## pasteboard.createUriRecord7+ @@ -219,21 +233,23 @@ Creates a **PasteDataRecord** object of the URI text type. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | uri | string | Yes | URI text. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | [PasteDataRecord](#pastedatarecord7) | New URI record. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| uri | string | Yes | URI text. | -- Example - - ``` - var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| [PasteDataRecord](#pastedatarecord7) | New URI record. | + +**Example** + +```js +var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); +``` ## PasteDataProperty7+ @@ -244,11 +260,11 @@ Defines the properties of all data records on the pasteboard, including the time | Name | Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| additions | {[key: string]: object} | Yes | Yes | Additional property data. | -| mimeTypes | Array<string> | Yes | No | Non-repeating data types of the data records on the pasteboard. | -| tag | string | Yes | Yes | User-defined tag. | -| timestamp | number | Yes | No | Timestamp at which the data is written to the pasteboard, in milliseconds. | -| localOnly | boolean | Yes | Yes | Whether local access only is set for the pasteboard.
- The default value is **true**.
- **true**: The **PasteData** is set for local access only.
- **false**: The **PasteData** can be shared between devices. | +| additions | {[key: string]: object} | Yes | Yes | Additional property data. | +| mimeTypes | Array<string> | Yes | No | Non-repeating data types of the data records on the pasteboard. | +| tag | string | Yes | Yes | User-defined tag. | +| timestamp | number | Yes | No | Timestamp at which the data is written to the pasteboard, in milliseconds. | +| localOnly | boolean | Yes | Yes | Whether local access only is set for the pasteboard.
- The default value is **true**.
- **true**: The **PasteData** is set for local access only.
- **false**: The **PasteData** can be shared between devices. | ## PasteDataRecord7+ @@ -262,63 +278,65 @@ A data record is an abstract definition of the content on the pasteboard. The pa | Name | Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| htmlText7+ | string | Yes | No | HTML text. | -| want7+ | [Want](js-apis-featureAbility.md#want) | Yes | No | Want text. | -| mimeType7+ | string | Yes | No | Data type. | -| plainText7+ | string | Yes | No | Plain text. | -| uri7+ | string | Yes | No | URI text. | +| htmlText7+ | string | Yes | No | HTML text. | +| want7+ | [Want](js-apis-application-Want.md) | Yes | No | Want text. | +| mimeType7+ | string | Yes | No | Data type. | +| plainText7+ | string | Yes | No | Plain text. | +| uri7+ | string | Yes | No | URI text. | ### convertToText7+ convertToText(): Promise<string> -Forcibly converts the content in this **PasteData** object to the plain text. This method uses a promise to return the result. +Forcibly converts the content in this **PasteData** object to the plain text. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result. If the operation is successful, the plain text content after conversion is returned. Otherwise, error information is returned. | +**Return value** -- Example - - ``` - var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); - record.convertToText().then((data) => { - console.info('convertToText success data : ' + JSON.stringify(data)); - }).catch((error) => { - console.error('convertToText failed because ' + JSON.stringify(error)); - }); - ``` +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the result. If the operation is successful, the plain text content after conversion is returned. Otherwise, error information is returned. | + +**Example** + +```js +var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); +record.convertToText().then((data) => { + console.info('convertToText success data : ' + JSON.stringify(data)); +}).catch((error) => { + console.error('convertToText failed because ' + JSON.stringify(error)); +}); +``` ### convertToText7+ convertToText(callback: AsyncCallback<string>): void -Forcibly converts the content in this **PasteData** object to the plain text. This method uses an asynchronous callback to return the result. +Forcibly converts the content in this **PasteData** object to the plain text. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<string> | Yes | Callback used to return the result. If this callback is successful, the plain text content after conversion is returned. Otherwise, error information is returned. | - -- Example - - ``` - var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); - record.convertToText((err, data) => { - if (err) { - console.error('convertToText failed because ' + JSON.stringify(err)); - return; - } - console.info('convertToText success data : ' + JSON.stringify(data)); - }); - ``` +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<string> | Yes | Callback used to return the result. If this callback is successful, the plain text content after conversion is returned. Otherwise, error information is returned. | + +**Example** + +```js +var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); +record.convertToText((err, data) => { + if (err) { + console.error('convertToText failed because ' + JSON.stringify(err)); + return; + } + console.info('convertToText success data : ' + JSON.stringify(data)); +}); +``` ## PasteData @@ -339,22 +357,19 @@ Obtains the plain text of the primary record. **System capability**: SystemCapability.MiscServices.Pasteboard +**Return value** -- Parameters - None +| Type | Description | +| -------- | -------- | +| string | Plain text. | -- Return values - | Type | Description | - | -------- | -------- | - | string | Plain text. | +**Example** -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var plainText = pasteData.getPrimaryText(); - ``` +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var plainText = pasteData.getPrimaryText(); +``` ### getPrimaryHtml7+ @@ -365,18 +380,19 @@ Obtains the HTML text of the primary record. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | string | HTML text. | +**Return value** -- Example - - ``` - var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; - var pasteData = pasteboard.createHtmlData(html); - var htmlText = pasteData.getPrimaryHtml(); - ``` +| Type | Description | +| -------- | -------- | +| string | HTML text. | + +**Example** + +```js +var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +var pasteData = pasteboard.createHtmlData(html); +var htmlText = pasteData.getPrimaryHtml(); +``` ### getPrimaryWant7+ @@ -387,21 +403,22 @@ Obtains the **Want** object of the primary record. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | [Want](js-apis-featureAbility.md#want) | Want object. | +**Return value** + +| Type | Description | +| -------- | -------- | +| [Want](js-apis-application-Want.md) | Want object. | + +**Example** -- Example - - ``` - var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" - }; - var pasteData = pasteboard.createWantData(object); - var want = pasteData.getPrimaryWant(); - ``` +```js +var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" +}; +var pasteData = pasteboard.createWantData(object); +var want = pasteData.getPrimaryWant(); +``` ### getPrimaryUri7+ @@ -412,17 +429,18 @@ Obtains the URI text of the primary record. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | string | URI text. | +**Return value** + +| Type | Description | +| -------- | -------- | +| string | URI text. | -- Example - - ``` - var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); - var uri = pasteData.getPrimaryUri(); - ``` +**Example** + +```js +var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); +var uri = pasteData.getPrimaryUri(); +``` ### addTextRecord7+ @@ -435,17 +453,18 @@ The pasteboard supports a maximum number of 128 data records. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | text | string | Yes | Plain text. | +**Parameters** -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - pasteData.addTextRecord("good"); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| text | string | Yes | Plain text. | + +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +pasteData.addTextRecord("good"); +``` ### addHtmlRecord7+ @@ -458,18 +477,19 @@ The pasteboard supports a maximum number of 128 data records. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | htmlText | string | Yes | HTML text. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| htmlText | string | Yes | HTML text. | + +**Example** -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; - pasteData.addHtmlRecord(html); - ``` +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +pasteData.addHtmlRecord(html); +``` ### addWantRecord7+ @@ -482,21 +502,22 @@ The pasteboard supports a maximum number of 128 data records. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#want) | Yes | Want object. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes | Want object. | -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" - }; - pasteData.addWantRecord(object); - ``` +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" +}; +pasteData.addWantRecord(object); +``` ### addUriRecord7+ @@ -509,17 +530,18 @@ The pasteboard supports a maximum number of 128 data records. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | uri | string | Yes | URI text. | +**Parameters** -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| uri | string | Yes | URI text. | + +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); +``` ### addRecord7+ @@ -532,21 +554,22 @@ The pasteboard supports a maximum number of 128 data records. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | record | [PasteDataRecord](#pastedatarecord7) | Yes | Record to add. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| record | [PasteDataRecord](#pastedatarecord7) | Yes | Record to add. | + +**Example** -- Example - - ``` - var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); - var textRecord = pasteboard.createPlainTextRecord("hello"); - var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; - var htmlRecord = pasteboard.createHtmlTextRecord(html); - pasteData.addRecord(textRecord); - pasteData.addRecord(htmlRecord); - ``` +```js +var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); +var textRecord = pasteboard.createPlainTextRecord("hello"); +var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +var htmlRecord = pasteboard.createHtmlTextRecord(html); +pasteData.addRecord(textRecord); +pasteData.addRecord(htmlRecord); +``` ### getMimeTypes7+ @@ -557,17 +580,18 @@ Obtains **mimeTypes** in [PasteDataProperty](#pastedataproperty7) from this past **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | Array<string> | List of non-duplicate MIME types. | +**Return value** + +| Type | Description | +| -------- | -------- | +| Array<string> | List of non-duplicate MIME types. | -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var types = pasteData.getMimeTypes(); - ``` +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var types = pasteData.getMimeTypes(); +``` ### getPrimaryMimeType7+ @@ -578,17 +602,18 @@ Obtains the data type of the primary record. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | string | Data type of the primary record. | +**Return value** -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var type = pasteData.getPrimaryMimeType(); - ``` +| Type | Description | +| -------- | -------- | +| string | Data type of the primary record. | + +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var type = pasteData.getPrimaryMimeType(); +``` ### getProperty7+ @@ -599,17 +624,18 @@ Obtains the property description object. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | [PasteDataProperty](#pastedataproperty7) | Property description object. | +**Return value** + +| Type | Description | +| -------- | -------- | +| [PasteDataProperty](#pastedataproperty7) | Property description object. | + +**Example** -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var property = pasteData.getProperty(); - ``` +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var property = pasteData.getProperty(); +``` ### getRecordAt7+ @@ -620,22 +646,24 @@ Obtains the record with the specified index. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | index | number | Yes | Index of the specified record. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| index | number | Yes | Index of the specified record. | + +**Return value** -- Return values - | Type | Description | - | -------- | -------- | - | [PasteDataRecord](#pastedatarecord7) | Record with the specified index. | +| Type | Description | +| -------- | -------- | +| [PasteDataRecord](#pastedatarecord7) | Record with the specified index. | -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var record = pasteData.getRecordAt(0); - ``` +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var record = pasteData.getRecordAt(0); +``` ### getRecordCount7+ @@ -646,17 +674,18 @@ Obtains the number of data records in this pasteboard. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | number | Number of records. | +**Return value** -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var count = pasteData.getRecordCount(); - ``` +| Type | Description | +| -------- | -------- | +| number | Number of records. | + +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var count = pasteData.getRecordCount(); +``` ### getTag7+ @@ -667,17 +696,18 @@ Obtains the user-defined tag content. If the tag content is not set, null is ret **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | string | User-defined tag content if obtained and null if no tag is set. | +**Return value** -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var tag = pasteData.getTag(); - ``` +| Type | Description | +| -------- | -------- | +| string | User-defined tag content if obtained and null if no tag is set. | + +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var tag = pasteData.getTag(); +``` ### hasMimeType7+ @@ -688,22 +718,24 @@ Checks whether the content of this pasteboard contains the specified data type. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | mimeType | string | Yes | Type of the data to query. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| mimeType | string | Yes | Type of the data to query. | + +**Return value** -- Return values - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the specified data type exists; returns **false** otherwise. | +| Type | Description | +| -------- | -------- | +| boolean | Returns **true** if the specified data type exists; returns **false** otherwise. | -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); - ``` +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); +``` ### removeRecordAt7+ @@ -714,22 +746,24 @@ Removes the data record with a specified index from this pasteboard. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | index | number | Yes | Specified index. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| index | number | Yes | Specified index. | -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var isRemove = pasteData.removeRecordAt(0); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | + +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var isRemove = pasteData.removeRecordAt(0); +``` ### replaceRecordAt7+ @@ -740,24 +774,26 @@ Replaces the data record with a specified index in this pasteboard. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | index | number | Yes | Specified index. | - | record | [PasteDataRecord](#pastedatarecord7) | Yes | New record. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| index | number | Yes | Specified index. | +| record | [PasteDataRecord](#pastedatarecord7) | Yes | New record. | -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("hello"); - var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); - var isReplace = pasteData.replaceRecordAt(0, record); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | + +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); +var isReplace = pasteData.replaceRecordAt(0, record); +``` ## pasteboard.getSystemPasteboard @@ -768,21 +804,22 @@ Obtains the system pasteboard. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | [SystemPasteboard](#systempasteboard) | System pasteboard. | +**Return value** -- Example - - ``` - var systemPasteboard = pasteboard.getSystemPasteboard(); - ``` +| Type | Description | +| -------- | -------- | +| [SystemPasteboard](#systempasteboard) | System pasteboard. | + +**Example** + +```js +var systemPasteboard = pasteboard.getSystemPasteboard(); +``` ## SystemPasteboard - Before calling any **SystemPasteboard** method, you must obtain a **SystemPasteboard** object using [getSystemPasteboard](#pasteboardgetsystempasteboard). +Before calling any **SystemPasteboard** method, you must obtain a **SystemPasteboard** object using [getSystemPasteboard](#pasteboardgetsystempasteboard). ``` var systemPasteboard = pasteboard.getSystemPasteboard(); @@ -793,112 +830,117 @@ var systemPasteboard = pasteboard.getSystemPasteboard(); setPasteData(data:PasteData, callback:AsyncCallback<void>): void -Writes data to a pasteboard. This method uses an asynchronous callback to return the result. +Writes data to a pasteboard. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | data | [PasteData](#pastedata) | Yes | **PasteData** object. | - | callback | AsyncCallback<void> | Yes | Callback used to return the data write result. | - -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("content"); - var systemPasteboard = pasteboard.getSystemPasteboard(); - systemPasteboard.setPasteData(pasteData, (error, data) => { - if (error) { - console.error('Failed to setPasteData. Cause: ' + error.message); - return; - } - console.info('setPasteData successfully.'); - }); - ``` +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| data | [PasteData](#pastedata) | Yes | **PasteData** object. | +| callback | AsyncCallback<void> | Yes | Callback used to return the data write result. | + +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("content"); +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.setPasteData(pasteData, (error, data) => { + if (error) { + console.error('Failed to setPasteData. Cause: ' + error.message); + return; + } + console.info('setPasteData successfully.'); +}); +``` ### setPasteData setPasteData(data:PasteData): Promise<void> -Writes data to a pasteboard. This method uses a promise to return the result. +Writes data to a pasteboard. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Description | - | -------- | -------- | -------- | - | data | [PasteData](#pastedata) | **PasteData** object. | - -- Return values - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the data write result. | - -- Example - - ``` - var pasteData = pasteboard.createPlainTextData("content"); - var systemPasteboard = pasteboard.getSystemPasteboard(); - systemPasteboard.setPasteData(pasteData).then((data) => { - console.info('setPasteData success.'); - }).catch((error) => { - console.error('Failed to setPasteData. Cause: ' + error.message); - }); - ``` +**Parameters** + +| Name | Type | Description | +| -------- | -------- | -------- | +| data | [PasteData](#pastedata) | **PasteData** object. | + +**Return value** + +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the data write result. | + +**Example** + +```js +var pasteData = pasteboard.createPlainTextData("content"); +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.setPasteData(pasteData).then((data) => { + console.info('setPasteData success.'); +}).catch((error) => { + console.error('Failed to setPasteData. Cause: ' + error.message); +}); +``` ### getPasteData getPasteData( callback:AsyncCallback<PasteData>): void -Reads the system pasteboard content. This method uses an asynchronous callback to return the result. +Reads the system pasteboard content. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[PasteData](#pastedata)> | Yes | Callback used to return the system pasteboard data. | - -- Example - - ``` - var systemPasteboard = pasteboard.getSystemPasteboard(); - systemPasteboard.getPasteData((error, pasteData) => { - if (error) { - console.error('Failed to getPasteData. Cause: ' + error.message); - return; - } - var text = pasteData.getPrimaryText(); - }); - ``` +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[PasteData](#pastedata)> | Yes | Callback used to return the system pasteboard data. | + +**Example** + +```js +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.getPasteData((error, pasteData) => { + if (error) { + console.error('Failed to getPasteData. Cause: ' + error.message); + return; + } + var text = pasteData.getPrimaryText(); +}); +``` ### getPasteData getPasteData(): Promise<PasteData> -Reads the system pasteboard content. This method uses a promise to return the result. +Reads the system pasteboard content. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | Promise<[PasteData](#pastedata)> | Promise used to return the system pasteboard data. | +**Return value** -- Example - - ``` - var systemPasteboard = pasteboard.getSystemPasteboard(); - systemPasteboard.getPasteData().then((pasteData) => { - var text = pasteData.getPrimaryText(); - }).catch((error) => { - console.error('Failed to getPasteData. Cause: ' + error.message); - }) - ``` +| Type | Description | +| -------- | -------- | +| Promise<[PasteData](#pastedata)> | Promise used to return the system pasteboard data. | + +**Example** + +```js +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.getPasteData().then((pasteData) => { + var text = pasteData.getPrimaryText(); +}).catch((error) => { + console.error('Failed to getPasteData. Cause: ' + error.message); +}) +``` ### on('update')7+ @@ -909,21 +951,22 @@ Subscribes to the content change event of the system pasteboard. If the pasteboa **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Data type. The value **update** indicates the pasteboard content has changed. | - | callback | function | Yes | Callback invoked when the pasteboard content changes. | +**Parameters** -- Example - - ``` - var systemPasteboard = pasteboard.getSystemPasteboard(); - var listener = ()=>{ - console.info('The system pasteboard has changed'); - }; - systemPasteboard.on('update', listener); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Data type. The value **update** indicates the pasteboard content has changed. | +| callback | function | Yes | Callback invoked when the pasteboard content changes. | + +**Example** + +```js +var systemPasteboard = pasteboard.getSystemPasteboard(); +var listener = ()=>{ + console.info('The system pasteboard has changed'); +}; +systemPasteboard.on('update', listener); +``` ### off('update')7+ @@ -934,114 +977,119 @@ Unsubscribes from the system pasteboard content change event. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Data type. The value **update** indicates the pasteboard content has changed. | - | callback | function | No | Callback invoked when the pasteboard content changes. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Data type. The value **update** indicates the pasteboard content has changed. | +| callback | function | No | Callback invoked when the pasteboard content changes. | -- Example - - ``` - systemPasteboard.off('update', listener); - ``` +**Example** + +```js +systemPasteboard.off('update', listener); +``` ### hasPasteData7+ hasPasteData(callback: AsyncCallback<boolean>): void -Checks whether the system pasteboard contains content. This method uses an asynchronous callback to return the result. +Checks whether the system pasteboard contains content. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes | Returns **true** if the pasteboard contains content; returns **false** otherwise. | - -- Example - - ``` - systemPasteboard.hasPasteData((err, data) => { - if (err) { - console.error('failed to hasPasteData because ' + JSON.stringify(err)); - return; - } - console.info('success hasPasteData : ' + JSON.stringify(data)); - }); - ``` +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | Yes | Returns **true** if the pasteboard contains content; returns **false** otherwise. | + +**Example** + +```js +systemPasteboard.hasPasteData((err, data) => { + if (err) { + console.error('failed to hasPasteData because ' + JSON.stringify(err)); + return; + } + console.info('success hasPasteData : ' + JSON.stringify(data)); +}); +``` ### hasPasteData7+ hasPasteData(): Promise<boolean> -Checks whether the system pasteboard contains content. This method uses a promise to return the result. +Checks whether the system pasteboard contains content. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | Promise<boolean> | Returns **true** if the pasteboard contains content; returns **false** otherwise. | +**Return value** + +| Type | Description | +| -------- | -------- | +| Promise<boolean> | Returns **true** if the pasteboard contains content; returns **false** otherwise. | + +**Example** -- Example - - ``` - systemPasteboard.hasPasteData().then((data) => { - console.info('Operation succeeded. ' + JSON.stringify(data)); - }).catch((error) => { - console.error('failed to hasPasteData because ' + JSON.stringify(error)); - }); - ``` +```js +systemPasteboard.hasPasteData().then((data) => { + console.info('Operation succeeded. ' + JSON.stringify(data)); +}).catch((error) => { + console.error('failed to hasPasteData because ' + JSON.stringify(error)); +}); +``` ### clear7+ clear(callback: AsyncCallback<void>): void -Clears the system pasteboard content. This method uses an asynchronous callback to return the result. +Clears the system pasteboard content. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Pasteboard -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the result. | - -- Example - - ``` - systemPasteboard.clear((err, data) => { - if (err) { - console.error('failed to clear because ' + JSON.stringify(err)); - return; - } - console.info('success clear'); - }); - ``` +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +```js +systemPasteboard.clear((err, data) => { + if (err) { + console.error('failed to clear because ' + JSON.stringify(err)); + return; + } + console.info('success clear'); +}); +``` ### clear7+ clear(): Promise<void> -Clears the system pasteboard content. This method uses a promise to return the result. +Clears the system pasteboard content. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Pasteboard -- Return values - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result. | - -- Example - - ``` - systemPasteboard.clear().then((data) => { - console.info('success clear'); - }).catch((error) => { - console.error('failed to clear because ' + JSON.stringify(error)); - }); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the result. | + +**Example** + +```js +systemPasteboard.clear().then((data) => { + console.info('success clear'); +}).catch((error) => { + console.error('failed to clear because ' + JSON.stringify(error)); +}); +``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index 468091db605fd24ac24887c126238cea264c3a52..4df1f4e33d37e28fc1ea83d7fde57d32c21df143 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -7,7 +7,7 @@ ## Modules to Import -``` +```js import radio from '@ohos.telephony.radio' ``` @@ -30,7 +30,7 @@ Obtains the radio access technology (RAT) used by the CS and PS domains. This AP **Example** -``` +```js let slotId = 0; radio.getRadioTech(slotId, (err, data) =>{ console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -62,7 +62,7 @@ Obtains the RAT used by the CS and PS domains. This API uses a promise to return **Example** -``` +```js let slotId = 0; let promise = radio.getRadioTech(slotId); promise.then(data => { @@ -91,7 +91,7 @@ Obtains the network status. This API uses an asynchronous callback to return the **Example** -``` +```js radio.getNetworkState((err, data) =>{ console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -117,7 +117,7 @@ Obtains the network status. This API uses an asynchronous callback to return the **Example** -``` +```js let slotId = 0; radio.getNetworkState(slotId, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -149,7 +149,7 @@ Obtains the network status of the SIM card in the specified slot. This API uses **Example** -``` +```js let slotId = 0; let promise = radio.getNetworkState(slotId); promise.then(data => { @@ -177,7 +177,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A **Example** -``` +```js let slotId = 0; radio.getNetworkSelectionMode(slotId, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -207,7 +207,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A **Example** -``` +```js let slotId = 0; let promise = radio.getNetworkSelectionMode(slotId); promise.then(data => { @@ -235,7 +235,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci **Example** -``` +```js let slotId = 0; radio.getISOCountryCodeForNetwork(slotId, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -265,7 +265,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci **Example** -``` +```js let slotId = 0; let promise = radio.getISOCountryCodeForNetwork(slotId); promise.then(data => { @@ -292,7 +292,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a **Example** -``` +```js radio.getPrimarySlotId((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -315,7 +315,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a **Example** -``` +```js let promise = radio.getPrimarySlotId(); promise.then(data => { console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`); @@ -342,7 +342,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the **Example** -``` +```js let slotId = 0; radio.getSignalInformation(slotId, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -372,7 +372,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the **Example** -``` +```js let slotId = 0; let promise = radio.getSignalInformation(slotId); promise.then(data => { @@ -405,7 +405,7 @@ Checks whether the current device supports 5G \(NR\). **Example** -``` +```js let slotId = 0; let result = radio.isNrSupported(slotId); console.log(result); @@ -430,7 +430,7 @@ Checks whether the radio service is enabled on the primary SIM card. This API us **Example** -``` +```js radio.isRadioOn((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -456,7 +456,7 @@ Checks whether the radio service is enabled on the SIM card in the specified slo **Example** -``` +```js let slotId = 0; radio.isRadioOn(slotId, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -488,7 +488,7 @@ Checks whether the radio service is enabled. This API uses a promise to return t **Example** -``` +```js let slotId = 0; let promise = radio.isRadioOn(slotId); promise.then(data => { @@ -516,7 +516,7 @@ Obtains the carrier name. This API uses an asynchronous callback to return the r **Example** -``` +```js let slotId = 0; radio.getOperatorName(slotId, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -546,7 +546,7 @@ Obtains the carrier name. This API uses a promise to return the result. **Example** -``` +```js let slotId = 0; let promise = radio.getOperatorName(slotId); promise.then(data => { diff --git a/en/application-dev/reference/apis/js-apis-request.md b/en/application-dev/reference/apis/js-apis-request.md index 0a8f08d0210217fcf972ce30e1bdabdcc8e1ac10..0a4b8c5ac6d2570ba34b5567322fef99e6b8bb1f 100644 --- a/en/application-dev/reference/apis/js-apis-request.md +++ b/en/application-dev/reference/apis/js-apis-request.md @@ -1,8 +1,8 @@ # Upload and Download -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **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 @@ -37,56 +37,58 @@ import request from '@ohos.request'; | Name | Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| NETWORK_MOBILE | number | Yes | No | Whether download is allowed when the cellular network is used. | -| NETWORK_WIFI | number | Yes | No | Whether download is allowed when the WLAN is used. | -| ERROR_CANNOT_RESUME7+ | number | Yes | No | Failure to resume the download due to an error. | -| ERROR_DEVICE_NOT_FOUND7+ | number | Yes | No | Failure to find a storage device such as an SD card. | -| ERROR_FILE_ALREADY_EXISTS7+ | number | Yes | No | Failure to download the file because it already exists. | -| ERROR_FILE_ERROR7+ | number | Yes | No | File operation failure. | -| ERROR_HTTP_DATA_ERROR7+ | number | Yes | No | HTTP transmission failure. | -| ERROR_INSUFFICIENT_SPACE7+ | number | Yes | No | Insufficient storage space. | -| ERROR_TOO_MANY_REDIRECTS7+ | number | Yes | No | Error caused by too many network redirections. | -| ERROR_UNHANDLED_HTTP_CODE7+ | number | Yes | No | Unidentified HTTP code. | -| ERROR_UNKNOWN7+ | number | Yes | No | Unknown error. | -| PAUSED_QUEUED_FOR_WIFI7+ | number | Yes | No | Download paused and queuing for WLAN connection, because the file size exceeds the maximum value allowed by a cellular network session. | -| PAUSED_UNKNOWN7+ | number | Yes | No | Download paused due to unknown reasons. | -| PAUSED_WAITING_FOR_NETWORK7+ | number | Yes | No | Download paused due to a network connection problem, for example, network disconnection. | -| PAUSED_WAITING_TO_RETRY7+ | number | Yes | No | Download paused and then retried. | -| SESSION_FAILED7+ | number | Yes | No | Download failure without retry. | -| SESSION_PAUSED7+ | number | Yes | No | Download paused. | -| SESSION_PENDING7+ | number | Yes | No | Download pending. | -| SESSION_RUNNING7+ | number | Yes | No | Download in progress. | -| SESSION_SUCCESSFUL7+ | number | Yes | No | Successful download. | +| NETWORK_MOBILE | number | Yes | No | Whether download is allowed when the cellular network is used. | +| NETWORK_WIFI | number | Yes | No | Whether download is allowed when the WLAN is used. | +| ERROR_CANNOT_RESUME7+ | number | Yes | No | Failure to resume the download due to an error. | +| ERROR_DEVICE_NOT_FOUND7+ | number | Yes | No | Failure to find a storage device such as an SD card. | +| ERROR_FILE_ALREADY_EXISTS7+ | number | Yes | No | Failure to download the file because it already exists. | +| ERROR_FILE_ERROR7+ | number | Yes | No | File operation failure. | +| ERROR_HTTP_DATA_ERROR7+ | number | Yes | No | HTTP transmission failure. | +| ERROR_INSUFFICIENT_SPACE7+ | number | Yes | No | Insufficient storage space. | +| ERROR_TOO_MANY_REDIRECTS7+ | number | Yes | No | Error caused by too many network redirections. | +| ERROR_UNHANDLED_HTTP_CODE7+ | number | Yes | No | Unidentified HTTP code. | +| ERROR_UNKNOWN7+ | number | Yes | No | Unknown error. | +| PAUSED_QUEUED_FOR_WIFI7+ | number | Yes | No | Download paused and queuing for WLAN connection, because the file size exceeds the maximum value allowed by a cellular network session. | +| PAUSED_UNKNOWN7+ | number | Yes | No | Download paused due to unknown reasons. | +| PAUSED_WAITING_FOR_NETWORK7+ | number | Yes | No | Download paused due to a network connection problem, for example, network disconnection. | +| PAUSED_WAITING_TO_RETRY7+ | number | Yes | No | Download paused and then retried. | +| SESSION_FAILED7+ | number | Yes | No | Download failure without retry. | +| SESSION_PAUSED7+ | number | Yes | No | Download paused. | +| SESSION_PENDING7+ | number | Yes | No | Download pending. | +| SESSION_RUNNING7+ | number | Yes | No | Download in progress. | +| SESSION_SUCCESSFUL7+ | number | Yes | No | Successful download. | ## request.upload upload(config: UploadConfig): Promise<UploadTask> -Uploads files. This method uses a promise to return the result. +Uploads files. This API uses a promise to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Upload -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | Promise<[UploadTask](#uploadtask)> | Promise used to return the **UploadTask** object. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. | -- Example - - ``` - request.upload({ url: 'https://patch' }).then((data) => { - uploadTask = data; - }).catch((err) => { - console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); - }) +**Return value** + +| Type | Description | +| -------- | -------- | +| Promise<[UploadTask](#uploadtask)> | Promise used to return the **UploadTask** object. | + +**Example** + + ```js +request.upload({ url: 'https://patch' }).then((data) => { + uploadTask = data; +}).catch((err) => { + console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); +}) ``` @@ -94,28 +96,29 @@ Uploads files. This method uses a promise to return the result. upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void -Uploads files. This method uses an asynchronous callback to return the result. +Uploads files. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Upload -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. | - | callback | AsyncCallback<[UploadTask](#uploadtask)> | No | Callback used to return the **UploadTask** object. | +**Parameters** -- Example - - ``` - request.upload({ url: 'https://patch' }, (err, data) => { - if (err) { - console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); - return; - } - uploadTask = data; - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. | +| callback | AsyncCallback<[UploadTask](#uploadtask)> | No | Callback used to return the **UploadTask** object. | + +**Example** + + ```js +request.upload({ url: 'https://patch' }, (err, data) => { + if (err) { + console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); + return; + } + uploadTask = data; +}); ``` @@ -128,32 +131,33 @@ Implements file uploads. Before using a method of this class, you must obtain an on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => void): void -Subscribes to the upload progress event. This method uses an asynchronous callback to return the result. +Subscribes to the upload progress event. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Upload -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to subscribe to. The value is **progress** (upload progress). | - | callback | function | Yes | Callback for the upload progress event. | +**Parameters** - Parameters of the callback function +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the event to subscribe to. The value is **progress** (upload progress). | +| callback | function | Yes | Callback for the upload progress event. | - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | uploadedSize | number | Yes | Size of the uploaded files, in KB. | - | totalSize | number | Yes | Total size of the files to upload, in KB. | +Parameters of the callback function -- Example - - ``` - uploadTask.on('progress', function callback(uploadedSize, totalSize) { - console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); - } - ); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| uploadedSize | number | Yes | Size of the uploaded files, in KB. | +| totalSize | number | Yes | Total size of the files to upload, in KB. | + +**Example** + + ```js +uploadTask.on('progress', function callback(uploadedSize, totalSize) { + console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); +} +); ``` @@ -161,31 +165,32 @@ Subscribes to the upload progress event. This method uses an asynchronous callba on(type: 'headerReceive', callback: (header: object) => void): void -Subscribes to the **headerReceive** event, which is triggered when an HTTP response header is received. This method uses an asynchronous callback to return the result. +Subscribes to the **headerReceive** event, which is triggered when an HTTP response header is received. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Upload -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to subscribe to. The value is **headerReceive** (response header). | - | callback | function | Yes | Callback for the HTTP Response Header event. | +**Parameters** - Parameters of the callback function +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the event to subscribe to. The value is **headerReceive** (response header). | +| callback | function | Yes | Callback for the HTTP Response Header event. | - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | header | object | Yes | HTTP Response Header. | +Parameters of the callback function -- Example - - ``` - uploadTask.on('headerReceive', function callback(headers){ - console.info("upOnHeader headers:" + JSON.stringify(headers)); - } - ); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| header | object | Yes | HTTP Response Header. | + +**Example** + + ```js +uploadTask.on('headerReceive', function callback(headers){ + console.info("upOnHeader headers:" + JSON.stringify(headers)); +} +); ``` @@ -193,32 +198,33 @@ Subscribes to the **headerReceive** event, which is triggered when an HTTP respo off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) => void): void -Unsubscribes from the upload progress event. This method uses an asynchronous callback to return the result. +Unsubscribes from the upload progress event. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Upload -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to unsubscribe from. The value is **progress** (upload progress). | - | callback | function | No | Callback for the upload progress event. | +**Parameters** - Parameters of the callback function +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the event to unsubscribe from. The value is **progress** (upload progress). | +| callback | function | No | Callback for the upload progress event. | - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | uploadedSize | number | Yes | Size of the uploaded files, in KB. | - | totalSize | number | Yes | Total size of the files to upload, in KB. | +Parameters of the callback function -- Example - - ``` - uploadTask.off('progress', function callback(uploadedSize, totalSize) { - console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); - } - ); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| uploadedSize | number | Yes | Size of the uploaded files, in KB. | +| totalSize | number | Yes | Total size of the files to upload, in KB. | + +**Example** + + ```js +uploadTask.off('progress', function callback(uploadedSize, totalSize) { + console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); +} +); ``` @@ -226,31 +232,32 @@ Unsubscribes from the upload progress event. This method uses an asynchronous ca off(type: 'headerReceive', callback?: (header: object) => void): void -Unsubscribes from the **headerReceive** event. This method uses an asynchronous callback to return the result. +Unsubscribes from the **headerReceive** event. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Upload -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to unsubscribe from. The value is **headerReceive** (response header). | - | callback | function | No | Callback for the HTTP Response Header event. | +**Parameters** - Parameters of the callback function +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the event to unsubscribe from. The value is **headerReceive** (response header). | +| callback | function | No | Callback for the HTTP Response Header event. | - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | header | object | Yes | HTTP Response Header. | +Parameters of the callback function -- Example - - ``` - uploadTask.off('headerReceive', function callback(headers) { - console.info("upOnHeader headers:" + JSON.stringify(headers)); - } - ); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| header | object | Yes | HTTP Response Header. | + +**Example** + + ```js +uploadTask.off('headerReceive', function callback(headers) { + console.info("upOnHeader headers:" + JSON.stringify(headers)); +} +); ``` @@ -258,29 +265,30 @@ Unsubscribes from the **headerReceive** event. This method uses an asynchronous remove(): Promise<boolean> -Removes this upload task. This method uses a promise to return the result. +Removes this upload task. This API uses a promise to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Upload -- Return values - | Type | Description | - | -------- | -------- | - | Promise<boolean> | Promise used to return the task removal result. If **true** is returned, the task is removed. If **false** is returned, the task fails to be removed. | +**Return value** -- Example - - ``` - uploadTask.remove().then((result) => { - if (result) { - console.info('Upload task removed successfully. '); - } else { - console.error('Failed to remove the upload task. '); - } - }).catch((err) => { - console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); - }); +| Type | Description | +| -------- | -------- | +| Promise<boolean> | Promise used to return the task removal result. If **true** is returned, the task is removed. If **false** is returned, the task fails to be removed. | + +**Example** + + ```js +uploadTask.remove().then((result) => { + if (result) { + console.info('Upload task removed successfully. '); + } else { + console.error('Failed to remove the upload task. '); + } +}).catch((err) => { + console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); +}); ``` @@ -288,31 +296,32 @@ Removes this upload task. This method uses a promise to return the result. remove(callback: AsyncCallback<boolean>): void -Removes this upload task. This method uses an asynchronous callback to return the result. +Removes this upload task. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Upload -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. | +**Parameters** -- Example - - ``` - uploadTask.remove((err, result) => { - if (err) { - console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); - return; - } - if (result) { - console.info('Upload task removed successfully.'); - } else { - console.error('Failed to remove the upload task.'); - } - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. | + +**Example** + + ```js +uploadTask.remove((err, result) => { + if (err) { + console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); + return; + } + if (result) { + console.info('Upload task removed successfully.'); + } else { + console.error('Failed to remove the upload task.'); + } +}); ``` @@ -322,11 +331,11 @@ Removes this upload task. This method uses an asynchronous callback to return th | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| url | string | Yes | Resource URL. | -| header | object | No | HTTP or HTTPS header added to an upload request. | -| method | string | No | Request methods available: **POST** and **PUT**. The default value is **POST**. | -| files | Array<[File](#file)> | Yes | List of files to upload, which is submitted through **multipart/form-data**. | -| data | Array<[RequestData](#requestdata)> | No | Form data in the request body. | +| url | string | Yes | Resource URL. | +| header | object | No | HTTP or HTTPS header added to an upload request. | +| method | string | No | Request methods available: **POST** and **PUT**. The default value is **POST**. | +| files | Array<[File](#file)> | Yes | List of files to upload, which is submitted through **multipart/form-data**. | +| data | Array<[RequestData](#requestdata)> | No | Form data in the request body. | ## File @@ -335,10 +344,10 @@ Removes this upload task. This method uses an asynchronous callback to return th | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| filename | string | No | File name in the header when **multipart** is used. | -| name | string | No | Name of a form item when **multipart** is used. The default value is **file**. | -| uri | string | Yes | Local path for storing files.
The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. The following is an example:
dataability:///com.domainname.dataability.persondata/person/10/file.txt
internal://cache/path/to/file.txt | -| type | string | No | Type of the file content. By default, the type is obtained based on the extension of the file name or URI. | +| filename | string | No | File name in the header when **multipart** is used. | +| name | string | No | Name of a form item when **multipart** is used. The default value is **file**. | +| uri | string | Yes | Local path for storing files.
The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. The following is an example:
dataability:///com.domainname.dataability.persondata/person/10/file.txt
internal://cache/path/to/file.txt | +| type | string | No | Type of the file content. By default, the type is obtained based on the extension of the file name or URI. | ## RequestData @@ -347,68 +356,71 @@ Removes this upload task. This method uses an asynchronous callback to return th | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| name | string | Yes | Name of a form element. | -| value | string | Yes | Value of a form element. | +| name | string | Yes | Name of a form element. | +| value | string | Yes | Value of a form element. | ## request.download download(config: DownloadConfig): Promise<DownloadTask> -Downloads files. This method uses a promise to return the result. +Downloads files. This API uses a promise to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | Promise<[DownloadTask](#downloadtask)> | Promise used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. | -- Example - - ``` - request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => { - downloadTask = data; - }).catch((err) => { - console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); - }) - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| Promise<[DownloadTask](#downloadtask)> | Promise used to return the result. | + +**Example** + +```js +request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => { + downloadTask = data; +}).catch((err) => { + console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); +}) +``` ## request.download download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void -Downloads files. This method uses an asynchronous callback to return the result. +Downloads files. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. | - | callback | AsyncCallback<[DownloadTask](#downloadtask)> | No | Callback used to return the result. | +**Parameters** -- Example - - ``` - request.download({ url: 'https://xxxx/xxxxx.hap', - filePath: 'xxx/xxxxx.hap'}, (err, data) => { - if (err) { - console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); - return; - } - downloadTask = data; - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. | +| callback | AsyncCallback<[DownloadTask](#downloadtask)> | No | Callback used to return the result. | + +**Example** + + ```js +request.download({ url: 'https://xxxx/xxxxx.hap', +filePath: 'xxx/xxxxx.hap'}, (err, data) => { + if (err) { + console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); + return; + } + downloadTask = data; +}); ``` @@ -421,28 +433,29 @@ Implements file downloads. on(type: 'progress', callback:(receivedSize: number, totalSize: number) => void): void -Subscribes to the download progress event. This method uses an asynchronous callback to return the result. +Subscribes to the download progress event. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to subscribe to. The value is **progress** (download progress). | - | callback | function | Yes | Callback for the download progress event. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the event to subscribe to. The value is **progress** (download progress). | +| callback | function | Yes | Callback for the download progress event. | - Parameters of the callback function +Parameters of the callback function - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | receivedSize | number | Yes | Size of the downloaded files, in KB. | - | totalSize | number | Yes | Total size of the files to download, in KB. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| receivedSize | number | Yes | Size of the downloaded files, in KB. | +| totalSize | number | Yes | Total size of the files to download, in KB. | -- Example - - ``` +**Example** + + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -461,39 +474,40 @@ Subscribes to the download progress event. This method uses an asynchronous call off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => void): void -Unsubscribes from the download progress event. This method uses an asynchronous callback to return the result. +Unsubscribes from the download progress event. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to unsubscribe from. The value is **progress** (download progress). | - | callback | function | No | Callback for the download progress event. | +**Parameters** - Parameters of the callback function +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the event to unsubscribe from. The value is **progress** (download progress). | +| callback | function | No | Callback for the download progress event. | - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | receivedSize | number | Yes | Size of the downloaded files, in KB. | - | totalSize | number | Yes | Total size of the files to download, in KB. | +Parameters of the callback function -- Example - - ``` - request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { - if (err) { - console.error('Failed to request download. Cause:' + err); - return; - } - downloadTask = data; - downloadTask .off('progress', function download_callback(receivedSize, totalSize) { - console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); - } - ); - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| receivedSize | number | Yes | Size of the downloaded files, in KB. | +| totalSize | number | Yes | Total size of the files to download, in KB. | + +**Example** + + ```js +request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { + if (err) { + console.error('Failed to request download. Cause:' + err); + return; + } + downloadTask = data; + downloadTask .off('progress', function download_callback(receivedSize, totalSize) { + console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); + } +); +}); ``` @@ -501,32 +515,33 @@ Unsubscribes from the download progress event. This method uses an asynchronous on(type: 'complete'|'pause'|'remove', callback:() => void): void -Subscribes to a download event. This method uses an asynchronous callback to return the result. +Subscribes to a download event. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Event type.
- **complete**: download task completion event.
- **pause**: download task pause event.
- **remove**: download task removal event. | - | callback | function | Yes | Callback used to return the result. | +**Parameters** -- Example - - ``` - request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { - if (err) { - console.error('Failed to request download. Cause:' + err); - return; - } - downloadTask= data; - downloadTask.on('complete', function callback() { - console.info('Download task completed.'); - } - ); - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Event type.
- **complete**: download task completion event.
- **pause**: download task pause event.
- **remove**: download task removal event. | +| callback | function | Yes | Callback used to return the result. | + +**Example** + + ```js +request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { + if (err) { + console.error('Failed to request download. Cause:' + err); + return; + } + downloadTask= data; + downloadTask.on('complete', function callback() { + console.info('Download task completed.'); + } +); +}); ``` @@ -534,32 +549,33 @@ Subscribes to a download event. This method uses an asynchronous callback to ret off(type: 'complete'|'pause'|'remove', callback?:() => void): void -Unsubscribes from the download event. This method uses an asynchronous callback to return the result. +Unsubscribes from the download event. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Event type.
- **complete**: download task completion event.
- **pause**: download task pause event.
- **remove**: download task removal event. | - | callback | function | No | Callback used to return the result. | +**Parameters** -- Example - - ``` - request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { - if (err) { - console.error('Failed to request download. Cause:' + JSON.stringify(err)); - return; - } - downloadTask = data; - downloadTask.off('complete', function callback() { - console.info('Download task completed.'); - } - ); - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Event type.
- **complete**: download task completion event.
- **pause**: download task pause event.
- **remove**: download task removal event. | +| callback | function | No | Callback used to return the result. | + +**Example** + + ```js +request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { + if (err) { + console.error('Failed to request download. Cause:' + JSON.stringify(err)); + return; + } + downloadTask = data; + downloadTask.off('complete', function callback() { + console.info('Download task completed.'); + } +); +}); ``` @@ -567,38 +583,39 @@ Unsubscribes from the download event. This method uses an asynchronous callback on(type: 'fail', callback: (err: number) => void): void -Subscribes to the download task failure event. This method uses an asynchronous callback to return the result. +Subscribes to the download task failure event. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the subscribed event. The value is **fail** (download failure). | - | callback | function | Yes | Callback for the download task failure event. | +**Parameters** - Parameters of the callback function +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the subscribed event. The value is **fail** (download failure). | +| callback | function | Yes | Callback for the download task failure event. | - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). | +Parameters of the callback function -- Example - - ``` - request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { - if (err) { - console.error('Failed to request download. Cause:' + err); - return; - } - downloadTask = data; - downloadTask.on('fail', function callBack(err) { - console.info('Download task failed. Cause:' + err); - } - ); - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). | + +**Example** + + ```js +request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { + if (err) { + console.error('Failed to request download. Cause:' + err); + return; + } + downloadTask = data; + downloadTask.on('fail', function callBack(err) { + console.info('Download task failed. Cause:' + err); + } +); +}); ``` @@ -606,27 +623,28 @@ Subscribes to the download task failure event. This method uses an asynchronous off(type: 'fail', callback?: (err: number) => void): void -Unsubscribes from the download task failure event. This method uses an asynchronous callback to return the result. +Unsubscribes from the download task failure event. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to unsubscribe from. The value is **fail** (download failure). | - | callback | function | No | Callback for the download task failure event. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the event to unsubscribe from. The value is **fail** (download failure). | +| callback | function | No | Callback for the download task failure event. | - Parameters of the callback function +Parameters of the callback function - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). | -- Example - - ``` +**Example** + + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -645,20 +663,21 @@ Unsubscribes from the download task failure event. This method uses an asynchron remove(): Promise<boolean> -Removes this download task. This method uses a promise to return the result. +Removes this download task. This API uses a promise to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Return values - | Type | Description | - | -------- | -------- | - | Promise<boolean> | Promise used to return the task removal result. | +**Return value** -- Example - - ``` +| Type | Description | +| -------- | -------- | +| Promise<boolean> | Promise used to return the task removal result. | + +**Example** + + ```js downloadTask.remove().then((result) => { if (result) { console.info('Download task removed.'); @@ -675,31 +694,32 @@ Removes this download task. This method uses a promise to return the result. remove(callback: AsyncCallback<boolean>): void -Removes this download task. This method uses an asynchronous callback to return the result. +Removes this download task. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the task removal result. | +**Parameters** -- Example - - ``` - downloadTask.remove((err, result)=>{ - if(err) { - console.error('Failed to remove the download task.'); - return; - } - if (result) { - console.info('Download task removed.'); - } else { - console.error('Failed to remove the download task.'); - } - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the task removal result. | + +**Example** + + ```js +downloadTask.remove((err, result)=>{ + if(err) { + console.error('Failed to remove the download task.'); + return; + } + if (result) { + console.info('Download task removed.'); + } else { + console.error('Failed to remove the download task.'); + } +}); ``` @@ -707,25 +727,26 @@ Removes this download task. This method uses an asynchronous callback to return query(): Promise<DownloadInfo> -Queries this download task. This method uses a promise to return the result. +Queries this download task. This API uses a promise to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Type | Description | - | -------- | -------- | - | Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information. | +**Parameters** -- Example - - ``` - downloadTask.query().then((downloadInfo) => { - console.info('Download task queried. Data:' + JSON.stringify(downloadInfo)) - }) .catch((err) => { - console.error('Failed to query the download task. Cause:' + err) - }); +| Type | Description | +| -------- | -------- | +| Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information. | + +**Example** + + ```js +downloadTask.query().then((downloadInfo) => { + console.info('Download task queried. Data:' + JSON.stringify(downloadInfo)) +}) .catch((err) => { + console.error('Failed to query the download task. Cause:' + err) +}); ``` @@ -733,27 +754,28 @@ Queries this download task. This method uses a promise to return the result. query(callback: AsyncCallback<DownloadInfo>): void -Queries this download task. This method uses an asynchronous callback to return the result. +Queries this download task. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes | Callback used to return the download task information. | +**Parameters** -- Example - - ``` - downloadTask.query((err, downloadInfo)=>{ - if(err) { - console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); - } else { - console.info('download query success. data:'+ JSON.stringify(downloadInfo)); - } - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes | Callback used to return the download task information. | + +**Example** + + ```js +downloadTask.query((err, downloadInfo)=>{ + if(err) { + console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); + } else { + console.info('download query success. data:'+ JSON.stringify(downloadInfo)); + } +}); ``` @@ -761,25 +783,26 @@ Queries this download task. This method uses an asynchronous callback to return queryMimeType(): Promise<string> -Queries **MimeType** of this download task. This method uses a promise to return the result. +Queries **MimeType** of this download task. This API uses a promise to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Return values - | Type | Description | - | -------- | -------- | - | Promise<string> | Promise used to return **MimeType** of the download task. | +**Return value** -- Example - - ``` - downloadTask.queryMimeType().then((data) => { - console.info('Download task queried. Data:' + JSON.stringify(data)); - }).catch((err) => { - console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err)) - }); +| Type | Description | +| -------- | -------- | +| Promise<string> | Promise used to return **MimeType** of the download task. | + +**Example** + + ```js +downloadTask.queryMimeType().then((data) => { + console.info('Download task queried. Data:' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err)) +}); ``` @@ -787,27 +810,28 @@ Queries **MimeType** of this download task. This method uses a promise to return queryMimeType(callback: AsyncCallback<string>): void; -Queries **MimeType** of this download task. This method uses an asynchronous callback to return the result. +Queries **MimeType** of this download task. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<string> | Yes | Callback used to return **MimeType** of the download task. | +**Parameters** -- Example - - ``` - downloadTask.queryMimeType((err, data)=>{ - if(err) { - console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); - } else { - console.info('Download task queried. data:' + JSON.stringify(data)); - } - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<string> | Yes | Callback used to return **MimeType** of the download task. | + +**Example** + + ```js +downloadTask.queryMimeType((err, data)=>{ + if(err) { + console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); + } else { + console.info('Download task queried. data:' + JSON.stringify(data)); + } +}); ``` @@ -815,29 +839,30 @@ Queries **MimeType** of this download task. This method uses an asynchronous cal pause(): Promise<void> -Pauses this download task. This method uses a promise to return the result. +Pauses this download task. This API uses a promise to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Return values - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the download task pause result. | +**Return value** -- Example - - ``` - downloadTask.pause().then((result) => { - if (result) { - console.info('Download task paused. '); - } else { - console.error('Failed to pause the download task. Cause:' + JSON.stringify(result)); - } - }).catch((err) => { - console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); - }); +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the download task pause result. | + +**Example** + + ```js +downloadTask.pause().then((result) => { + if (result) { + console.info('Download task paused. '); + } else { + console.error('Failed to pause the download task. Cause:' + JSON.stringify(result)); + } +}).catch((err) => { + console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); +}); ``` @@ -845,31 +870,32 @@ Pauses this download task. This method uses a promise to return the result. pause(callback: AsyncCallback<void>): void -Pauses this download task. This method uses an asynchronous callback to return the result. +Pauses this download task. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the result. | +**Parameters** -- Example - - ``` - downloadTask.pause((err, result)=>{ - if(err) { - console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); - return; - } - if (result) { - console.info('Download task paused. '); - } else { - console.error('Failed to pause the download task. Cause:' + JSON.stringify(result)); - } - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + + ```js +downloadTask.pause((err, result)=>{ + if(err) { + console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); + return; + } + if (result) { + console.info('Download task paused. '); + } else { + console.error('Failed to pause the download task. Cause:' + JSON.stringify(result)); + } +}); ``` @@ -877,30 +903,31 @@ Pauses this download task. This method uses an asynchronous callback to return t resume(): Promise<void> -Resumes this download task. This method uses a promise to return the result. +Resumes this download task. This API uses a promise to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result. | +**Parameters** -- Example - - ``` - downloadTask.resume().then((result) => { - if (result) { - console.info('Download task resumed.') - } else { - console.error('Failed to resume the download task. '); - } - console.info('Download task resumed.') - }).catch((err) => { - console.error('Failed to resume the download task. Cause:' + err); - }); +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the result. | + +**Example** + + ```js +downloadTask.resume().then((result) => { + if (result) { + console.info('Download task resumed.') + } else { + console.error('Failed to resume the download task. '); + } + console.info('Download task resumed.') +}).catch((err) => { + console.error('Failed to resume the download task. Cause:' + err); +}); ``` @@ -908,31 +935,32 @@ Resumes this download task. This method uses a promise to return the result. resume(callback: AsyncCallback<void>): void -Resumes this download task. This method uses an asynchronous callback to return the result. +Resumes this download task. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the result. | +**Parameters** -- Example - - ``` - downloadTask.resume((err, result)=>{ - if (err) { - console.error('Failed to resume the download task. Cause:' + err); - return; - } - if (result) { - console.info('Download task resumed.'); - } else { - console.error('Failed to resume the download task.'); - } - }); +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + + ```js +downloadTask.resume((err, result)=>{ + if (err) { + console.error('Failed to resume the download task. Cause:' + err); + return; + } + if (result) { + console.info('Download task resumed.'); + } else { + console.error('Failed to resume the download task.'); + } +}); ``` @@ -942,14 +970,14 @@ Resumes this download task. This method uses an asynchronous callback to return | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| url | string | Yes | Resource URL. | -| header | object | No | HTTP or HTTPS header added to a download request. | -| enableMetered | boolean | No | Download allowed in metered connections. | -| enableRoaming | boolean | No | Download allowed on a roaming network. | -| description | string | No | Description of the download session. | -| filePath7+ | string | No | Download path. (The default path is [ERROR:Invalid link:en-us_topic_0000001135742582.xml#xref8132147102215,link:en-us_topic_0000001127125012.xml#section1856519365229](en-us_topic_0000001127125012.xml#section1856519365229)).
- filePath:'workspace/test.txt': The **workspace** directory is created in the default path to store files.
- filePath:'test.txt': Files are stored in the default path.
- filePath:'workspace/': The **workspace** directory is created in the default path to store files. | -| networkType | number | No | Network type allowed for download. | -| title | string | No | Title of the download session. | +| url | string | Yes | Resource URL. | +| header | object | No | HTTP or HTTPS header added to a download request. | +| enableMetered | boolean | No | Download allowed in metered connections. | +| enableRoaming | boolean | No | Download allowed on a roaming network. | +| description | string | No | Description of the download session. | +| filePath7+ | string | No | Download path. (The default path is [ERROR:Invalid link:en-us_topic_0000001135742582.xml#xref8132147102215,link:en-us_topic_0000001127125012.xml#section1856519365229](en-us_topic_0000001127125012.xml#section1856519365229)).
- filePath:'workspace/test.txt': The **workspace** directory is created in the default path to store files.
- filePath:'test.txt': Files are stored in the default path.
- filePath:'workspace/': The **workspace** directory is created in the default path to store files. | +| networkType | number | No | Network type allowed for download. | +| title | string | No | Title of the download session. | ## DownloadInfo7+ @@ -958,14 +986,14 @@ Resumes this download task. This method uses an asynchronous callback to return | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| downloadId | number | Yes | ID of the downloaded file. | -| failedReason | number | No | Download failure cause, which can be any constant of [ERROR_*](#constants). | -| fileName | string | Yes | Name of the downloaded file. | -| filePath | string | Yes | URI of the saved file. | -| pausedReason | number | No | Reason for session pause, which can be any constant of [PAUSED_*](#constants). | -| status | number | Yes | Download status code, which can be any constant of [SESSION_*](#constants). | -| targetURI | string | Yes | URI of the downloaded file. | -| downloadTitle | string | Yes | Title of the downloaded file. | -| downloadTotalBytes | number | Yes | Total size of the downloaded file (int bytes). | -| description | string | Yes | Description of the file to download. | -| downloadedBytes | number | Yes | Size of the files downloaded (int bytes). | +| downloadId | number | Yes | ID of the downloaded file. | +| failedReason | number | No | Download failure cause, which can be any constant of [ERROR_*](#constants). | +| fileName | string | Yes | Name of the downloaded file. | +| filePath | string | Yes | URI of the saved file. | +| pausedReason | number | No | Reason for session pause, which can be any constant of [PAUSED_*](#constants). | +| status | number | Yes | Download status code, which can be any constant of [SESSION_*](#constants). | +| targetURI | string | Yes | URI of the downloaded file. | +| downloadTitle | string | Yes | Title of the downloaded file. | +| downloadTotalBytes | number | Yes | Total size of the downloaded file (int bytes). | +| description | string | Yes | Description of the file to download. | +| downloadedBytes | number | Yes | Size of the files downloaded (int bytes). | diff --git a/en/application-dev/reference/apis/js-apis-resource-manager.md b/en/application-dev/reference/apis/js-apis-resource-manager.md index 19572a3c963ceb80761f3b5961d7323615efa1c0..2effb8b20a713c2c1f9a27baa8c12cabdcd37cda 100644 --- a/en/application-dev/reference/apis/js-apis-resource-manager.md +++ b/en/application-dev/reference/apis/js-apis-resource-manager.md @@ -1,6 +1,8 @@ # Resource Management -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+The resource management module provides APIs to obtain information about the current device configuration (including the language, region, screen direction, and MCC/MNC) and device capability (including the device type and resolution). + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. @@ -14,14 +16,14 @@ import resourceManager from '@ohos.resourceManager'; getResourceManager(callback: AsyncCallback<ResourceManager>): void -Obtains the **ResourceManager** object of this application. This method uses a callback to return the result. +Obtains the **ResourceManager** object of this application. This API uses a callback to return the result. **System capability**: SystemCapability.Global.ResourceManager **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ----------------------------- | -| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the **ResourceManager** object obtained.| +| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Asynchronous callback used to return the **ResourceManager** object obtained.| **Example** ``` @@ -45,7 +47,7 @@ Obtains the **ResourceManager** object of this application. This method uses a c getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManager>): void -Obtains the **ResourceManager** object of an application. This method uses an asynchronous callback to return the result. +Obtains the **ResourceManager** object of an application. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -53,7 +55,7 @@ Obtains the **ResourceManager** object of an application. This method uses an as | Name | Type | Mandatory | Description | | ---------- | ---------------------------------------- | ---- | ----------------------------- | | bundleName | string | Yes | Bundle name of the target application. | -| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the **ResourceManager** object obtained.| +| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Asynchronous callback used to return the **ResourceManager** object obtained.| **Example** ``` @@ -66,7 +68,7 @@ Obtains the **ResourceManager** object of an application. This method uses an as getResourceManager(): Promise<ResourceManager> -Obtains the **ResourceManager** object of this application. This method uses a promise to return the result. +Obtains the **ResourceManager** object of this application. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -95,7 +97,7 @@ Obtains the **ResourceManager** object of this application. This method uses a p getResourceManager(bundleName: string): Promise<ResourceManager> -Obtains the **ResourceManager** object of an application. This method uses a promise to return the result. +Obtains the **ResourceManager** object of an application. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -139,12 +141,12 @@ Enumerates the device types. | Name | Default Value | Description | | -------------------- | ---- | ---- | -| DEVICE_TYPE_PHONE | 0x00 | Mobile phone. | -| DEVICE_TYPE_TABLET | 0x01 | Tablet. | -| DEVICE_TYPE_CAR | 0x02 | Automobile. | -| DEVICE_TYPE_PC | 0x03 | Computer. | -| DEVICE_TYPE_TV | 0x04 | TV. | -| DEVICE_TYPE_WEARABLE | 0x06 | Wearable. | +| DEVICE_TYPE_PHONE | 0x00 | Phone | +| DEVICE_TYPE_TABLET | 0x01 | Tablet | +| DEVICE_TYPE_CAR | 0x02 | Head unit | +| DEVICE_TYPE_PC | 0x03 | PC | +| DEVICE_TYPE_TV | 0x04 | TV | +| DEVICE_TYPE_WEARABLE | 0x06 | Wearable | ## ScreenDensity @@ -175,6 +177,16 @@ Defines the device configuration. | direction | [Direction](#direction) | Yes | No | Screen direction of the device.| | locale | string | Yes | No | Current system language. | +**Example** + + ``` +resourceManager.getResourceManager((error, mgr) => { + mgr.getConfiguration((error, value) => { + console.log(value.direction); + console.log(value.locale); + }); + }); + ``` ## DeviceCapability @@ -188,6 +200,16 @@ Defines the device capability. | screenDensity | [ScreenDensity](#screendensity) | Yes | No | Screen density of the device.| | deviceType | [DeviceType](#devicetype) | Yes | No | Type of the device. | +**Example** + + ``` +resourceManager.getResourceManager((error, mgr) => { + mgr.getDeviceCapability((error, value) => { + console.log(value.screenDensity); + console.log(value.deviceType); + }); + }); + ``` ## RawFileDescriptor8+ @@ -205,7 +227,7 @@ Defines the descriptor information of the raw file.
Defines the capability of accessing application resources. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> - The methods involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm. > > - Resource files are defined in the **resources** directory of the project. You can obtain the resource ID using **$r(resource address).id**, for example, **$r('app.string.test').id**. @@ -215,7 +237,7 @@ Defines the capability of accessing application resources. getString(resId: number, callback: AsyncCallback<string>): void -Obtains the string corresponding to the specified resource ID. This method uses an asynchronous callback to return the result. +Obtains the string corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -223,7 +245,7 @@ Obtains the string corresponding to the specified resource ID. This method uses | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | --------------- | | resId | number | Yes | Resource ID. | -| callback | AsyncCallback<string> | Yes | Callback used to return the string obtained.| +| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the obtained string.| **Example** ``` @@ -243,7 +265,7 @@ Obtains the string corresponding to the specified resource ID. This method uses getString(resId: number): Promise<string> -Obtains the string corresponding to the specified resource ID. This method uses a promise to return the result. +Obtains the string corresponding to the specified resource ID. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -273,7 +295,7 @@ Obtains the string corresponding to the specified resource ID. This method uses getStringArray(resId: number, callback: AsyncCallback<Array<string>>): void -Obtains the array of strings corresponding to the specified resource ID. This method uses an asynchronous callback to return the result. +Obtains the array of strings corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -281,7 +303,7 @@ Obtains the array of strings corresponding to the specified resource ID. This me | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ----------------- | | resId | number | Yes | Resource ID. | -| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the obtained array of strings.| +| callback | AsyncCallback<Array<string>> | Yes | Asynchronous callback used to return the obtained array of strings.| **Example** ``` @@ -301,7 +323,7 @@ Obtains the array of strings corresponding to the specified resource ID. This me getStringArray(resId: number): Promise<Array<string>> -Obtains the array of strings corresponding to the specified resource ID. This method uses a promise to return the result. +Obtains the array of strings corresponding to the specified resource ID. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -331,7 +353,7 @@ Obtains the array of strings corresponding to the specified resource ID. This me getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void -Obtains the content of the media file corresponding to the specified resource ID. This method uses an asynchronous callback to return the result. +Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -339,7 +361,7 @@ Obtains the content of the media file corresponding to the specified resource ID | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ------------------ | | resId | number | Yes | Resource ID. | -| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the content of the media file obtained.| +| callback | AsyncCallback<Uint8Array> | Yes | Asynchronous callback used to return the content of the media file obtained.| **Example** ``` @@ -359,7 +381,7 @@ Obtains the content of the media file corresponding to the specified resource ID getMedia(resId: number): Promise<Uint8Array> -Obtains the content of the media file corresponding to the specified resource ID. This method uses a promise to return the result. +Obtains the content of the media file corresponding to the specified resource ID. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -389,7 +411,7 @@ Obtains the content of the media file corresponding to the specified resource ID getMediaBase64(resId: number, callback: AsyncCallback<string>): void -Obtains the Base64 code of the image corresponding to the specified resource ID. This method uses an asynchronous callback to return the result. +Obtains the Base64 code of the image corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -397,7 +419,7 @@ Obtains the Base64 code of the image corresponding to the specified resource ID. | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | ------------------------ | | resId | number | Yes | Resource ID. | -| callback | AsyncCallback<string> | Yes | Callback used to return the Base64 code of the image obtained.| +| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the Base64 code of the image obtained.| **Example** ``` @@ -417,7 +439,7 @@ Obtains the Base64 code of the image corresponding to the specified resource ID. getMediaBase64(resId: number): Promise<string> -Obtains the Base64 code of the image corresponding to the specified resource ID. This method uses a promise to return the result. +Obtains the Base64 code of the image corresponding to the specified resource ID. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -447,14 +469,14 @@ Obtains the Base64 code of the image corresponding to the specified resource ID. getConfiguration(callback: AsyncCallback<Configuration>): void -Obtains the device configuration. This method uses an asynchronous callback to return the result. +Obtains the device configuration. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------- | -| callback | AsyncCallback<[Configuration](#configuration)> | Yes | Callback used to return the obtained device configuration.| +| callback | AsyncCallback<[Configuration](#configuration)> | Yes | Asynchronous callback used to return the obtained device configuration.| **Example** ``` @@ -474,7 +496,7 @@ Obtains the device configuration. This method uses an asynchronous callback to r getConfiguration(): Promise<Configuration> -Obtains the device configuration. This method uses a promise to return the result. +Obtains the device configuration. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -499,14 +521,14 @@ Obtains the device configuration. This method uses a promise to return the resul getDeviceCapability(callback: AsyncCallback<DeviceCapability>): void -Obtains the device capability. This method uses an asynchronous callback to return the result. +Obtains the device capability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------- | -| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes | Callback used to return the obtained device capability.| +| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes | Asynchronous callback used to return the obtained device capability.| **Example** ``` @@ -526,7 +548,7 @@ Obtains the device capability. This method uses an asynchronous callback to retu getDeviceCapability(): Promise<DeviceCapability> -Obtains the device capability. This method uses a promise to return the result. +Obtains the device capability. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -551,7 +573,7 @@ Obtains the device capability. This method uses a promise to return the result. getPluralString(resId: number, num: number, callback: AsyncCallback<string>): void -Obtains the specified number of singular-plural strings corresponding to the specified resource ID. This method uses an asynchronous callback to return the result. +Obtains the specified number of singular-plural strings corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -560,7 +582,7 @@ Obtains the specified number of singular-plural strings corresponding to the spe | -------- | --------------------------- | ---- | ------------------------------- | | resId | number | Yes | Resource ID. | | num | number | Yes | Number that determines the plural or singular form. | -| callback | AsyncCallback<string> | Yes | Callback used to return the singular-plural string obtained.| +| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the singular-plural string obtained.| **Example** ``` @@ -580,7 +602,7 @@ Obtains the specified number of singular-plural strings corresponding to the spe getPluralString(resId: number, num: number): Promise<string> -Obtains the specified number of singular-plural strings corresponding to the specified resource ID. This method uses a promise to return the result. +Obtains the specified number of singular-plural strings corresponding to the specified resource ID. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -610,7 +632,7 @@ Obtains the specified number of singular-plural strings corresponding to the spe getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void -Obtains the content of the raw file in the specified path. This method uses an asynchronous callback to return the result. +Obtains the content of rawfile in the specified path. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -618,7 +640,7 @@ Obtains the content of the raw file in the specified path. This method uses an a | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ----------------------- | | path | string | Yes | Path of the raw file. | -| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the raw file content, in byte arrays.| +| callback | AsyncCallback<Uint8Array> | Yes | Asynchronous callback used to return the raw file content, in byte arrays.| **Example** ``` @@ -637,7 +659,7 @@ Obtains the content of the raw file in the specified path. This method uses an a getRawFile(path: string): Promise<Uint8Array> -Obtains the content of the raw file in the specified path. This method uses a promise to return the result. +Obtains the content of the raw file in the specified path. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -666,7 +688,7 @@ Obtains the content of the raw file in the specified path. This method uses a pr getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor>): void -Obtains the descriptor of the raw file in the specified path. This method uses an asynchronous callback to return the result. +Obtains the descriptor of the raw file in the specified path. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -674,7 +696,7 @@ Obtains the descriptor of the raw file in the specified path. This method uses a | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | -------------------------------- | | path | string | Yes | Path of the raw file. | -| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | Yes | Callback used to return the raw file descriptor.| +| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | Yes | Asynchronous callback used to return the raw file descriptor.| **Example** ``` @@ -695,7 +717,7 @@ Obtains the descriptor of the raw file in the specified path. This method uses a getRawFileDescriptor(path: string): Promise<RawFileDescriptor> -Obtains the descriptor of the raw file in the specified path. This method uses a promise to return the result. +Obtains the descriptor of the raw file in the specified path. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -726,7 +748,7 @@ Obtains the descriptor of the raw file in the specified path. This method uses a closeRawFileDescriptor(path: string, callback: AsyncCallback<void>): void -Closes the descriptor of the raw file in the specified path. This method uses an asynchronous callback to return the result. +Closes the descriptor of the raw file in the specified path. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -734,7 +756,7 @@ Closes the descriptor of the raw file in the specified path. This method uses an | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ----------- | | path | string | Yes | Path of the raw file.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| callback | AsyncCallback<void> | Yes | Asynchronous callback used to return the result. | **Example** ``` @@ -751,7 +773,7 @@ Closes the descriptor of the raw file in the specified path. This method uses an closeRawFileDescriptor(path: string): Promise<void> -Closes the descriptor of the raw file in the specified path. This method uses a promise to return the result. +Closes the descriptor of the raw file in the specified path. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager diff --git a/en/application-dev/reference/apis/js-apis-router.md b/en/application-dev/reference/apis/js-apis-router.md index 50205792031201bfae6b3bb2d8fbbcfbad0cb426..b17d29151d7c1c9a9ee53de976cd4c0f77ea838a 100644 --- a/en/application-dev/reference/apis/js-apis-router.md +++ b/en/application-dev/reference/apis/js-apis-router.md @@ -1,6 +1,6 @@ # Page Routing -> ![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. > - Page routing APIs can be invoked only after page rendering is complete. Do not call the APIs in **onInit** and **onReady** when the page is still in the rendering phase. @@ -24,13 +24,13 @@ Navigates to a specified page in the application. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | options | [RouterOptions](#routeroptions) | Yes| Page routing parameters.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| options | [RouterOptions](#routeroptions) | Yes| Page routing parameters.| **Example** - ``` + ```js // Current page export default { pushPage() { @@ -46,7 +46,7 @@ Navigates to a specified page in the application. } } ``` - ``` + ```js // routerpage2 page export default { data: { @@ -72,12 +72,13 @@ Replaces the current page with another one in the application and destroys the c **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | options | [RouterOptions](#routeroptions) | Yes| Description of the new page.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| options | [RouterOptions](#routeroptions) | Yes| Description of the new page.| **Example** - ``` + + ```js // Current page export default { replacePage() { @@ -91,7 +92,7 @@ Replaces the current page with another one in the application and destroys the c } ``` - ``` + ```js // detail page export default { data: { @@ -112,12 +113,12 @@ Returns to the previous page or a specified page. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | options | [RouterOptions](#routeroptions) | Yes| Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| options | [RouterOptions](#routeroptions) | Yes| Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.| **Example** - ``` + ```js // index page export default { indexPushPage() { @@ -128,7 +129,7 @@ Returns to the previous page or a specified page. } ``` - ``` + ```js // detail page export default { detailPushPage() { @@ -139,7 +140,7 @@ Returns to the previous page or a specified page. } ``` - ``` + ```js // Navigate from the mall page to the detail page through router.back(). export default { mallBackPage() { @@ -148,7 +149,7 @@ Returns to the previous page or a specified page. } ``` - ``` + ```js // Navigate from the detail page to the index page through router.back(). export default { defaultBack() { @@ -157,7 +158,7 @@ Returns to the previous page or a specified page. } ``` - ``` + ```js // Return to the detail page through router.back(). export default { backToDetail() { @@ -175,12 +176,12 @@ Clears all historical pages in the stack and retains only the current page at th **System capability**: SystemCapability.ArkUI.ArkUI.Full **Example** - ``` + ```js export default { clearPage() { router.clear(); } - } + }js ``` ## router.getLength @@ -190,12 +191,12 @@ getLength(): string Obtains the number of pages in the current stack. **Return value** - | Type| Description| - | -------- | -------- | - | string | Number of pages in the stack. The maximum value is **32**.| +| Type| Description| +| -------- | -------- | +| string | Number of pages in the stack. The maximum value is **32**.| **Example** - ``` + ```js export default { getLength() { var size = router.getLength(); @@ -222,14 +223,14 @@ Describes the page routing state. **System capability**: SystemCapability.ArkUI.ArkUI.Full - | Name| Type| Description| - | -------- | -------- | -------- | - | index | number | Index of the current page in the stack.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The index starts from 1 from the bottom to the top of the stack.| - | name | string | Name of the current page, that is, the file name.| - | path | string | Path of the current page.| +| Name| Type| Description| +| -------- | -------- | -------- | +| index | number | Index of the current page in the stack.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The index starts from 1 from the bottom to the top of the stack.| +| name | string | Name of the current page, that is, the file name.| +| path | string | Path of the current page.| **Example** - ``` + ```js export default { getState() { var page = router.getState(); @@ -249,13 +250,13 @@ Enables the display of a confirm dialog box before returning to the previous pag **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | options | [EnableAlertOptions](#enablealertoptions) | Yes| Description of the dialog box.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| options | [EnableAlertOptions](#enablealertoptions) | Yes| Description of the dialog box.| **Example** - ``` + ```js export default { enableAlertBeforeBackPage() { router.enableAlertBeforeBackPage({ @@ -289,7 +290,7 @@ Disables the display of a confirm dialog box before returning to the previous pa **System capability**: SystemCapability.ArkUI.ArkUI.Full **Example** - ``` + ```js export default { disableAlertBeforeBackPage() { router.disableAlertBeforeBackPage(); @@ -314,7 +315,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu **Example** - Web-like example - ``` + ```js // Current page export default { pushPage() { @@ -327,7 +328,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu } } ``` - ``` + ```js // detail page export default { onInit() { @@ -338,7 +339,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu - Declarative example - ``` + ```ts // Navigate to the target page through router.push with the params parameter carried. import router from '@ohos.router' @@ -384,7 +385,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu } ``` - ``` + ```ts // Receive the transferred parameters on the second page. import router from '@ohos.router' @@ -392,8 +393,8 @@ Obtains the parameters passed from the page that initiates redirection to the cu @Component struct Second { private content: string = "This is the second page." - @State text: string = router.getParams().text - @State data: any = router.getParams().data + @State text: string = router.getParams()['text'] + @State data: any = router.getParams()['data'] @State secondData : string = '' build() { diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md index cd33c37764b39dbf11bd630a3b3fba3ac45a1f92..690a77e0d9563a066d7f1da9352aca640b6fbea3 100644 --- a/en/application-dev/reference/apis/js-apis-screenshot.md +++ b/en/application-dev/reference/apis/js-apis-screenshot.md @@ -1,6 +1,6 @@ # Screenshot -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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 @@ -54,7 +54,7 @@ save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>) Takes a screenshot and saves it as a **PixelMap** object. This method uses a callback to return the result. -**System capabilities**: SystemCapability.WindowManager.WindowManager.Core +**System capability**: SystemCapability.WindowManager.WindowManager.Core **Required permissions**: ohos.permission.CAPTURE_SCREEN @@ -94,15 +94,15 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap> Takes a screenshot and saves it as a **PixelMap** object. This method uses a promise to return the result. -**System capabilities**: SystemCapability.WindowManager.WindowManager.Core +**System capability**: SystemCapability.WindowManager.WindowManager.Core **Required permissions**: ohos.permission.CAPTURE_SCREEN **Parameters** - | Name | Type | Mandatory| Description | - | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | - | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| +| Name | Type | Mandatory| Description | +| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-settings.md b/en/application-dev/reference/apis/js-apis-settings.md index 82ae2c2f0c346f80cf133ec75700a78ff4cb59c1..9b56d25f9f841be73f607a6ef249d57c3f3f3a8d 100644 --- a/en/application-dev/reference/apis/js-apis-settings.md +++ b/en/application-dev/reference/apis/js-apis-settings.md @@ -9,7 +9,7 @@ This module provides APIs for setting data items. ## Modules to Import -``` +```typescript import settings from '@ohos.settings'; ``` @@ -34,7 +34,7 @@ Obtains the URI of a data item. | string | URI of the data item.| - Example - ``` + ```typescript // Obtain the URI of a data item. let urivar = settings.getUriSync('settings.screen.brightness'); ``` @@ -61,7 +61,7 @@ Obtains the value of a data item. | string | Value of the data item.| - Example - ``` + ```typescript import featureAbility from '@ohos.featureAbility'; // Obtain the value of 'settings.screen.brightness' (this data item already exists in the database). @@ -96,7 +96,7 @@ If the specified data item exists in the database, the **setValueSync** method u | boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.| - Example - ``` + ```typescript import featureAbility from '@ohos.featureAbility'; // Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md index 85e895952f7d9eeafa395b9e3337806e0213f250..f1f20e8d810c3f3fa648e680d494199e30bc1dfe 100644 --- a/en/application-dev/reference/apis/js-apis-sim.md +++ b/en/application-dev/reference/apis/js-apis-sim.md @@ -7,7 +7,7 @@ ## Modules to Import -``` +```js import sim from '@ohos.telephony.sim'; ``` @@ -28,7 +28,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses an **Example** -``` +```js sim.isSimActive(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -57,7 +57,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses a **Example** -``` +```js let promise = sim.isSimActive(0); promise.then(data => { console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`); @@ -83,7 +83,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A **Example** -``` +```js sim.getDefaultVoiceSlotId((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -106,7 +106,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A **Example** -``` +```js let promise = sim.getDefaultVoiceSlotId(); promise.then(data => { console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`); @@ -132,7 +132,7 @@ Checks whether the application (caller) has been granted the operator permission **Example** -``` +```js sim.hasOperatorPrivileges(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -160,7 +160,7 @@ Checks whether the application (caller) has been granted the operator permission **Example** -``` +```js let promise = sim.hasOperatorPrivileges(0); promise.then(data => { console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`); @@ -186,7 +186,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use **Example** -``` +```js sim.getISOCountryCodeForSim(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -215,7 +215,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use **Example** -``` +```js let promise = sim.getISOCountryCodeForSim(0); promise.then(data => { console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`); @@ -242,7 +242,7 @@ Obtains the public land mobile network (PLMN) ID of the SIM card in the specifie **Example** -``` +```js sim.getSimOperatorNumeric(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -271,7 +271,7 @@ Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promi **Example** -``` +```js let promise = sim.getSimOperatorNumeric(0); promise.then(data => { console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`); @@ -298,7 +298,7 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T **Example** -``` +```js sim.getSimSpn(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -327,7 +327,7 @@ Obtains the SPN of the SIM card in the specified slot. This API uses a promise t **Example** -``` +```js let promise = sim.getSimSpn(0); promise.then(data => { console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`); @@ -354,7 +354,7 @@ Obtains the status of the SIM card in the specified slot. This API uses an async **Example** -``` +```js sim.getSimState(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -383,7 +383,7 @@ Obtains the status of the SIM card in the specified slot. This API uses a promis **Example** -``` +```js let promise = sim.getSimState(0); promise.then(data => { console.log(`getSimState success, promise: data->${JSON.stringify(data)}`); @@ -409,7 +409,7 @@ Obtains the type of the SIM card in the specified slot. This API uses an asynchr **Example** -``` +```js sim.getCardType(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -438,7 +438,7 @@ Obtains the type of the SIM card in the specified slot. This API uses a promise **Example** -``` +```js let promise = sim.getCardType(0); promise.then(data => { console.log(`getCardType success, promise: data->${JSON.stringify(data)}`); @@ -465,7 +465,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an **Example** -``` +```js sim.hasSimCard(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -494,7 +494,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses a **Example** -``` +```js let promise = sim.hasSimCard(0); promise.then(data => { console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`); @@ -520,7 +520,7 @@ Obtains the number of card slots. **Example** -``` +```js console.log(sim.getMaxSimCount()) ``` diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index e874588b5e209f5386a34c4fc8e10f2b5fc6aef0..85e8f3f411ea91289ecfcb410eae43b6ea4e57b6 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -6,7 +6,7 @@ ## Modules to Import -``` +```js import sms from '@ohos.telephony.sms'; ``` @@ -28,7 +28,7 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp **Example** -``` +```js const specification = '3gpp'; // Display PDUs using numbers in an array, for example, [0x08, 0x91, ...]. const pdu = [0x08, 0x91]; @@ -61,7 +61,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol. **Example** -``` +```js const specification = '3gpp'; // Display PDUs using numbers in an array, for example, [0x08, 0x91, ...]. const pdu = [0x08, 0x91]; @@ -91,7 +91,7 @@ Sends an SMS message. **Example** -``` +```js let sendCallback = function (err, data) { console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); } @@ -124,7 +124,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use **Example** -``` +```js sms.getDefaultSmsSlotId((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -147,7 +147,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use **Example** -``` +```js let promise = sms.getDefaultSmsSlotId(); promise.then(data => { console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); @@ -179,7 +179,7 @@ This is a system API and cannot be called by third-party applications. **Example** -``` +```js let slotId = 0; let smscAddr = '+861xxxxxxxxxx'; sms.setSmscAddr(slotId, smscAddr, (err,data) => { @@ -215,7 +215,7 @@ This is a system API and cannot be called by third-party applications. **Example** -``` +```js let slotId = 0; let smscAddr = '+861xxxxxxxxxx'; let promise = sms.setSmscAddr(slotId, smscAddr); @@ -248,7 +248,7 @@ This is a system API and cannot be called by third-party applications. **Example** -``` +```js let slotId = 0; sms.getSmscAddr(slotId, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -282,7 +282,7 @@ This is a system API and cannot be called by third-party applications. **Example** -``` +```js let slotId = 0; let promise = sms.getSmscAddr(slotId); promise.then(data => { @@ -306,7 +306,7 @@ Checks whether the current device can send and receive SMS messages. This API wo | ------- | ------------------------------------------------------------ | | boolean | - **true**: The device can send and receive SMS messages.
- **false**: The device cannot send or receive SMS messages.| -``` +```js let result = sms.hasSmsCapability(); console.log(`hasSmsCapability: ${JSON.stringify(result)}`); ``` diff --git a/en/application-dev/reference/apis/js-apis-socket.md b/en/application-dev/reference/apis/js-apis-socket.md index dcaf0416c84747d430a115d5cc5f48d132d7b675..2c83bd2e48d0405e5fcd19d883f72d667756e3f8 100644 --- a/en/application-dev/reference/apis/js-apis-socket.md +++ b/en/application-dev/reference/apis/js-apis-socket.md @@ -7,7 +7,7 @@ ## Modules to Import -``` +```js import socket from '@ohos.net.socket'; ``` @@ -28,7 +28,7 @@ Creates a **UDPSocket** object. **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); ``` @@ -56,7 +56,7 @@ Binds the IP address and port number. The port number can be specified or random **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { if (err) { @@ -93,7 +93,7 @@ Binds the IP address and port number. The port number can be specified or random **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); let promise = udp.bind({address: '192.168.xx.xxx', port: 8080, family: 1}); promise .then(() => { @@ -123,7 +123,7 @@ Sends data over a UDPSocket connection. This API uses an asynchronous callback t **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.send({ data:'Hello, server!', @@ -166,7 +166,7 @@ Sends data over a UDPSocket connection. This API uses a promise to return the re **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); let promise = udp.send({ data:'Hello, server!', @@ -202,7 +202,7 @@ Closes a UDPSocket connection. This API uses an asynchronous callback to return **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.close(err => { if (err) { @@ -232,7 +232,7 @@ Closes a UDPSocket connection. This API uses a promise to return the result. **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); let promise = udp.close(); promise.then(() => { @@ -264,7 +264,7 @@ Obtains the status of the UDPSocket connection. This API uses an asynchronous ca **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { if (err) { @@ -304,7 +304,7 @@ Obtains the status of the UDPSocket connection. This API uses a promise to retur **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { if (err) { @@ -345,7 +345,7 @@ Sets other properties of the UDPSocket connection. This API uses an asynchronous **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> { if (err) { @@ -397,7 +397,7 @@ Sets other properties of the UDPSocket connection. This API uses a promise to re **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); let promise = udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}); promise.then(() => { @@ -437,7 +437,7 @@ Enables listening for message receiving events of the UDPSocket connection. This **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.on('message', value => { console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); @@ -465,7 +465,7 @@ Disables listening for message receiving events of the UDPSocket connection. Thi **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); let callback = value =>{ console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); @@ -494,7 +494,7 @@ Enables listening for data packet message events or close events of the UDPSocke **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.on('listening', () => { console.log("on listening success"); @@ -525,7 +525,7 @@ Disables listening for data packet message events or close events of the UDPSock **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); let callback1 = () =>{ console.log("on listening, success"); @@ -562,7 +562,7 @@ Enables listening for error events of the UDPSocket connection. This API uses an **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); udp.on('error', err => { console.log("on error, err:" + JSON.stringify(err)) @@ -590,7 +590,7 @@ Disables listening for error events of the UDPSocket connection. This API uses a **Example** -``` +```js let udp = socket.constructUDPSocketInstance(); let callback = err =>{ console.log("on error, err:" + JSON.stringify(err)); @@ -680,7 +680,7 @@ Creates a **TCPSocket** object. **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); ``` @@ -709,7 +709,7 @@ Binds the IP address and port number. The port number can be specified or random **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { if (err) { @@ -745,7 +745,7 @@ Binds the IP address and port number. The port number can be specified or random **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise = tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}); promise.then(() => { @@ -775,7 +775,7 @@ Sets up a connection to the specified IP address and port number. This API uses **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}, err => { if (err) { @@ -811,7 +811,7 @@ Sets up a connection to the specified IP address and port number. This API uses **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); promise.then(() => { @@ -844,7 +844,7 @@ Sends data over a TCPSocket connection. This API uses an asynchronous callback t **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); promise.then(() => { @@ -891,7 +891,7 @@ Sends data over a TCPSocket connection. This API uses a promise to return the re **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); promise1.then(() => { @@ -929,7 +929,7 @@ Closes a TCPSocket connection. This API uses an asynchronous callback to return **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); tcp.close(err => { if (err) { @@ -959,7 +959,7 @@ Closes a TCPSocket connection. This API uses a promise to return the result. **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise = tcp.close(); promise.then(() => { @@ -991,7 +991,7 @@ Obtains the remote address of a TCPSocket connection. This API uses an asynchron **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); promise.then(() => { @@ -1030,7 +1030,7 @@ Obtains the remote address of a TCPSocket connection. This API uses a promise to **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); promise1.then(() => { @@ -1069,7 +1069,7 @@ Obtains the status of the TCPSocket connection. This API uses an asynchronous ca **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); promise.then(() => { @@ -1109,7 +1109,7 @@ Obtains the status of the TCPSocket connection. This API uses a promise to retur **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); promise.then(() => { @@ -1148,7 +1148,7 @@ Sets other properties of the TCPSocket connection. This API uses an asynchronous **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); promise.then(() => { @@ -1203,7 +1203,7 @@ Sets other properties of the TCPSocket connection. This API uses a promise to re **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); promise.then(() => { @@ -1246,7 +1246,7 @@ Enables listening for message receiving events of the TCPSocket connection. This **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); tcp.on('message', value => { console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo) @@ -1274,7 +1274,7 @@ Disables listening for message receiving events of the TCPSocket connection. Thi **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let callback = value =>{ console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); @@ -1304,7 +1304,7 @@ Enables listening for connection or close events of the TCPSocket connection. Th **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); tcp.on('connect', () => { console.log("on connect success") @@ -1335,7 +1335,7 @@ Disables listening for connection or close events of the TCPSocket connection. T **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let callback1 = () =>{ console.log("on connect success"); @@ -1371,7 +1371,7 @@ Enables listening for error events of the TCPSocket connection. This API uses an **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); tcp.on('error', err => { console.log("on error, err:" + JSON.stringify(err)) @@ -1399,7 +1399,7 @@ Disables listening for error events of the TCPSocket connection. This API uses a **Example** -``` +```js let tcp = socket.constructTCPSocketInstance(); let callback = err =>{ console.log("on error, err:" + JSON.stringify(err)); diff --git a/en/application-dev/reference/apis/js-apis-system-app.md b/en/application-dev/reference/apis/js-apis-system-app.md index 761d2276e31642f1890ce4127929fb9272c62602..e0cf8d10a1e79872dc6d59a908281610fd01ba23 100644 --- a/en/application-dev/reference/apis/js-apis-system-app.md +++ b/en/application-dev/reference/apis/js-apis-system-app.md @@ -1,6 +1,6 @@ # Application Context -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> - The APIs of this module are no longer maintained since API version 7. You are advised to use the new APIs. > > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -138,7 +138,8 @@ Sets the maximum size (in bytes) of the image data cached in the memory before d export default { onCreate() { - app.setImageRawDataCacheSize(100) // Set the upper limit of the memory for caching image data before decoding to 100 MB. + app.setImageRawDataCacheSize(104857600) + // Set the upper limit of the memory for caching image data before decoding to 100 MB. (100 x 1024 x 1024 B =104857600 B = 100 MB). console.info('Application onCreate') }, onDestroy() { @@ -168,7 +169,8 @@ Sets the maximum size of the image file cache (in bytes) to speed up the loading export default { onCreate() { - app.setImageFileCacheSize(200) // Set the upper limit of the image file cache to 200 MB. + app.setImageFileCacheSize(209715200) + // Set the upper limit of the image file cache to 200 MB. (200 x 1024 x 1024 B= 209715200 B = 200 MB). console.info('Application onCreate') }, onDestroy() { diff --git a/en/application-dev/reference/apis/js-apis-system-storage.md b/en/application-dev/reference/apis/js-apis-system-storage.md index d80bf1ea12d54ac3d2bae32ec81c88cd293dfa62..37e8dc5de76e930a81a337c9afd3fe0adcd459c4 100644 --- a/en/application-dev/reference/apis/js-apis-system-storage.md +++ b/en/application-dev/reference/apis/js-apis-system-storage.md @@ -1,6 +1,6 @@ # Data Storage -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> > - The APIs of this module are no longer maintained since API Version 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From API Version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md). > @@ -67,7 +67,7 @@ Sets the value in the cache based on the specified key. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| key | string | Yes| Key of the value to set.| +| key | string | Yes| Key of the data to set.| | value | string | Yes| New value to set. The maximum length is 128 bytes.| | success | Function | No| Called when **storage.set()** is successful.| | fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.| diff --git a/en/application-dev/reference/apis/js-apis-system-time.md b/en/application-dev/reference/apis/js-apis-system-time.md index 35096fe9a772de7ef95ea21d4e7660f850db366d..74beca3c0aacbabd628f99f7987b96caf5988f61 100644 --- a/en/application-dev/reference/apis/js-apis-system-time.md +++ b/en/application-dev/reference/apis/js-apis-system-time.md @@ -1,12 +1,12 @@ # Setting the System Time -> ![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. +> ![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. +> ## Modules to Import - + ``` import systemTime from '@ohos.systemTime'; ``` @@ -22,16 +22,17 @@ Sets the system time. This API uses an asynchronous callback to return the resul **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | time | number | Yes| Timestamp to set, in milliseconds.| - | callback | AsyncCallback<void> | Yes| Callback used to process the received return value.| +**Parameters** -- Example - - ``` - // Set the system time to 2021-01-20 02:36:25. +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| time | number | Yes| Timestamp to set, in milliseconds.| +| callback | AsyncCallback<void> | Yes| Callback used to process the received return value.| + +**Example** + + ```js +// Set the system time to 2021-01-20 02:36:25. var time = 1611081385000; systemTime.setTime(time, (error, data) => { if (error) { @@ -53,26 +54,28 @@ Sets the system time. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | time | number | Yes| Timestamp to set, in milliseconds.| +**Parameters** -- Return value - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| time | number | Yes| Timestamp to set, in milliseconds.| -- Example - - ``` - // Set the system time to 2021-01-20 02:36:25. - var time = 1611081385000; - systemTime.setTime(time).then((data) => { - console.log(`systemTime.setTime success data : ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to systemTime.setTime because ` + JSON.stringify(error)); - }); +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```js +// Set the system time to 2021-01-20 02:36:25. +var time = 1611081385000; +systemTime.setTime(time).then((data) => { + console.log(`systemTime.setTime success data : ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`failed to systemTime.setTime because ` + JSON.stringify(error)); +}); ``` @@ -84,15 +87,16 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| - | callback | AsyncCallback<number> | Yes| Callback used to return the time.| +**Parameters** -- Example - - ``` +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| +| callback | AsyncCallback<number> | Yes| Callback used to return the time.| + +**Example** + + ```js systemTime.getCurrentTime(true, (error, data) => { if (error) { console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); @@ -111,19 +115,21 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| +**Parameters** -- Return value - | Type| Description| - | -------- | -------- | - | Promise<number> | Promise used to return the time.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| -- Example - - ``` +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<number> | Promise used to return the time.| + +**Example** + + ```js systemTime.getCurrentTime().then((data) => { console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -140,15 +146,16 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| - | callback | AsyncCallback<number> | Yes| Callback used to return the time.| +**Parameters** -- Example - - ``` +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| +| callback | AsyncCallback<number> | Yes| Callback used to return the time.| + +**Example** + + ```js systemTime.getRealActiveTime(true, (error, data) => { if (error) { console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error)); @@ -167,19 +174,21 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| +**Parameters** -- Return value - | Type| Description| - | -------- | -------- | - | Promise<number> | Promise used to return the time.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| -- Example - - ``` +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<number> | Promise used to return the time.| + +**Example** + + ```js systemTime.getCurrentTime().then((data) => { console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -196,15 +205,16 @@ Obtains the time elapsed since system start, including the deep sleep time. This **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| - | callback | AsyncCallback<number> | Yes| Callback used to return the time.| +**Parameters** -- Example - - ``` +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| +| callback | AsyncCallback<number> | Yes| Callback used to return the time.| + +**Example** + + ```js systemTime.getRealTime(true, (error, data) => { if (error) { console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); @@ -223,19 +233,21 @@ Obtains the time elapsed since system start, including the deep sleep time. This **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| +**Parameters** -- Return value - | Type| Description| - | -------- | -------- | - | Promise<number> | Promise used to return the time.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.| -- Example - - ``` +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<number> | Promise used to return the time.| + +**Example** + + ```js systemTime.getRealTime().then((data) => { console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); }).catch((error) => { @@ -254,15 +266,16 @@ Sets the system date. This API uses an asynchronous callback to return the resul **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | date | Date | Yes| Target date to set.| - | callback | AsyncCallback<void> | Yes| Callback used to process the received return value.| +**Parameters** -- Example - - ``` +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| date | Date | Yes| Target date to set.| +| callback | AsyncCallback<void> | Yes| Callback used to process the received return value.| + +**Example** + + ```js var data = new Date("October 13, 2020 11:13:00"); systemTime.setDate(data,(error, data) => { if (error) { @@ -284,19 +297,21 @@ Sets the system date. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | date | Date | Yes| Target date to set.| +**Parameters** -- Return value - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| date | Date | Yes| Target date to set.| -- Example - - ``` +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```js var data = new Date("October 13, 2020 11:13:00"); systemTime.setDate(data).then((value) => { console.log(`systemTime.setDate success data : ` + JSON.stringify(value)); @@ -314,14 +329,15 @@ Obtains the current system date. This API uses an asynchronous callback to retur **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<Date> | Yes| Callback used to return the current system date.| +**Parameters** -- Example - - ``` +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<Date> | Yes| Callback used to return the current system date.| + +**Example** + + ```js systemTime.getDate((error, data) => { if (error) { console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); @@ -340,14 +356,15 @@ Obtains the current system date. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Time -- Return value - | Type| Description| - | -------- | -------- | - | Promise<Date> | Promise used to return the current system date.| +**Return value** -- Example - - ``` +| Type| Description| +| -------- | -------- | +| Promise<Date> | Promise used to return the current system date.| + +**Example** + + ```js systemTime.getDate().then((data) => { console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -366,15 +383,16 @@ Sets the system time zone. This API uses an asynchronous callback to return the **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | timezone | string | Yes| System time zone to set.| - | callback | AsyncCallback<void> | Yes| Callback used to process the received return value.| +**Parameters** -- Example - - ``` +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| timezone | string | Yes| System time zone to set.| +| callback | AsyncCallback<void> | Yes| Callback used to process the received return value.| + +**Example** + + ```js systemTime.setTimezone('Asia/Shanghai', (error, data) => { if (error) { console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error)); @@ -395,19 +413,21 @@ Sets the system time zone. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | timezone | string | Yes| System time zone to set.| +**Parameters** -- Return value - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| timezone | string | Yes| System time zone to set.| -- Example - - ``` +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```js systemTime.setTimezone('Asia/Shanghai').then((data) => { console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -424,14 +444,15 @@ Obtains the system time zone. This API uses an asynchronous callback to return t **System capability**: SystemCapability.MiscServices.Time -- **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<string> | Yes| Callback used to return the system time zone.| +**Parameters** -- Example - - ``` +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<string> | Yes| Callback used to return the system time zone.| + +**Example** + + ```js systemTime.getTimezone((error, data) => { if (error) { console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); @@ -450,14 +471,15 @@ Obtains the system time zone. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Time -- Return value - | Type| Description| - | -------- | -------- | - | Promise<string> | Promise used to return the system time zone.| +**Return value** -- Example - - ``` +| Type| Description| +| -------- | -------- | +| Promise<string> | Promise used to return the system time zone.| + +**Example** + + ```js systemTime.getTimezone().then((data) => { console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); }).catch((error) => { diff --git a/en/application-dev/reference/apis/js-apis-uri.md b/en/application-dev/reference/apis/js-apis-uri.md index 0975f28256cffeacdfbf40ed5dcf56250ff21d5d..4952c227c32677d8bc1f13b3cd07d448ff0d21f0 100644 --- a/en/application-dev/reference/apis/js-apis-uri.md +++ b/en/application-dev/reference/apis/js-apis-uri.md @@ -1,6 +1,6 @@ # URI String Parsing -> ![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. @@ -10,15 +10,12 @@ import uri from '@ohos.uri' ``` -## System Capabilities - -SystemCapability.Utils.Lang - ## URI - ### Attributes +**System capability**: SystemCapability.Utils.Lang + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | | scheme | string | Yes| No| Scheme in the URI.| @@ -38,6 +35,8 @@ constructor(uri: string) A constructor used to create a URI instance. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type.| Readable| Writable| Description| @@ -59,6 +58,8 @@ new uri.URI('http://username:password@host:8080'); // Output 'http://username:pa toString(): string +**System capability**: SystemCapability.Utils.Lang + Obtains the query string applicable to this URL. **Return value** @@ -81,6 +82,8 @@ equals(other: URI): boolean Checks whether this URI is the same as another URI object. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type.| Mandatory| Description| @@ -107,6 +110,8 @@ checkIsAbsolute(): boolean Checks whether this URI is an absolute URI (whether the scheme component is defined). +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type.| Description| @@ -127,6 +132,8 @@ normalize(): URI Normalizes the path of this URI. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type.| Description| diff --git a/en/application-dev/reference/apis/js-apis-uripermissionmanager.md b/en/application-dev/reference/apis/js-apis-uripermissionmanager.md index 1a0c320f80c90faa313d9e53681024b6a289195d..506611ba4807edf47d583bd57bd8a4d656496010 100644 --- a/en/application-dev/reference/apis/js-apis-uripermissionmanager.md +++ b/en/application-dev/reference/apis/js-apis-uripermissionmanager.md @@ -1,6 +1,6 @@ # uriPermissionManager -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -27,12 +27,12 @@ SystemCapability.Ability.AbilityRuntime.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.| - | flag | wantConstant.Flags | Yes| Read or write permission on the file specified by the URI.| - | accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.| - | callback | AsyncCallback<number> | Yes| Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. | + | flag | wantConstant.Flags | Yes | Read or write permission on the file specified by the URI. | + | accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. | + | callback | AsyncCallback<number> | Yes | Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. | **Example** @@ -56,17 +56,17 @@ SystemCapability.Ability.AbilityRuntime.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.| - | flag | wantConstant.Flags | Yes| Read or write permission on the file specified by the URI.| - | accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. | + | flag | wantConstant.Flags | Yes | Read or write permission on the file specified by the URI. | + | accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. | **Return value** - | Type| Description| - | -------- | -------- | - | Promise<number> | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.| + | Type | Description | + | -------- | -------- | + | Promise<number> | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. | **Example** @@ -78,4 +78,4 @@ SystemCapability.Ability.AbilityRuntime.Core }).catch((error) => { console.log('Verification failed.'); }) - ``` + ``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-url.md b/en/application-dev/reference/apis/js-apis-url.md index b3d39d36eb25fb1e43e8f503e8933cb58e008e58..9f105f845950f1f206c326dcd94c4adf8b83c12c 100755 --- a/en/application-dev/reference/apis/js-apis-url.md +++ b/en/application-dev/reference/apis/js-apis-url.md @@ -1,6 +1,6 @@ # URL String Parsing -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. @@ -10,10 +10,6 @@ import Url from '@ohos.url' ``` -## System Capabilities - -SystemCapability.Utils.Lang - ## URLSearchParams @@ -23,11 +19,13 @@ constructor(init?: string[][] | Record<string, string> | string | URLSearc Creates a **URLSearchParams** instance. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following:
- **string[][]**: two-dimensional string array
- **Record<string, string>**: list of objects
- **string**: string
- **URLSearchParams**: object| +| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following:
- **string[][]**: two-dimensional string array
- **Record<string, string>**: list of objects
- **string**: string
- **URLSearchParams**: object | **Example** @@ -46,12 +44,14 @@ append(name: string, value: string): void Appends a key-value pair into the query string. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| name | string | Yes| Key of the key-value pair to append.| -| value | string | Yes| Value of the key-value pair to append.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Key of the key-value pair to append. | + | value | string | Yes | Value of the key-value pair to append. | **Example** @@ -68,11 +68,13 @@ delete(name: string): void Deletes key-value pairs of the specified key. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| name | string | Yes| Key of the key-value pairs to delete.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Key of the key-value pairs to delete. | **Example** @@ -89,17 +91,19 @@ getAll(name: string): string[] Obtains all the key-value pairs based on the specified key. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| name | string | Yes| Key specified to obtain all key-value pairs.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Key specified to obtain all key-value pairs. | **Return value** -| Type| Description| -| -------- | -------- | -| string[] | All key-value pairs matching the specified key.| + | Type | Description | + | -------- | -------- | + | string[] | All key-value pairs matching the specified key. | **Example** @@ -117,11 +121,13 @@ entries(): IterableIterator<[string, string]> Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| -| -------- | -------- | -| IterableIterator<[string, string]> | ES6 iterator.| + | Type | Description | + | -------- | -------- | + | IterableIterator<[string, string]> | ES6 iterator. | **Example** @@ -139,20 +145,22 @@ forEach(callbackfn: (value: string, key: string, searchParams: this) => void, th Traverses the key-value pairs in the **URLSearchParams** instance by using a callback. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callbackfn | function | Yes| Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance.| -| thisArg | Object | No| Value to use when the callback is invoked.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callbackfn | function | Yes | Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance. | + | thisArg | Object | No | Value to use when the callback is invoked. | **Table 1** callbackfn parameter description -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | string | Yes| Value that is currently traversed.| -| key | string | Yes| Key that is currently traversed.| -| searchParams | Object | Yes| Instance that invokes the **forEach** method.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | string | Yes | Value that is currently traversed. | + | key | string | Yes | Key that is currently traversed. | + | searchParams | Object | Yes | Instance that invokes the **forEach** method. | **Example** @@ -170,18 +178,20 @@ get(name: string): string | null Obtains the value of the first key-value pair based on the specified key. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| name | string | Yes| Key specified to obtain the value.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Key specified to obtain the value. | **Return value** -| Type| Description| -| -------- | -------- | -| string | Returns the value of the first key-value pair if obtained.| -| null | Returns null if no value is obtained.| + | Type | Description | + | -------- | -------- | + | string | Returns the value of the first key-value pair if obtained. | + | null | Returns null if no value is obtained. | **Example** @@ -199,17 +209,19 @@ has(name: string): boolean Checks whether a key has a value. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| name | string | Yes| Key specified to search for its value.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Key specified to search for its value. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the value exists; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the value exists; returns **false** otherwise. | **Example** @@ -226,12 +238,14 @@ set(name: string, value: string): void Sets the value for a key. If key-value pairs matching the specified key exist, the value of the first key-value pair will be set to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair will be appended to the query string. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| name | string | Yes| Key of the value to set.| -| value | string | Yes| Value to set.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Key of the value to set. | + | value | string | Yes | Value to set. | **Example** @@ -246,8 +260,9 @@ paramsObject.set('baz', 3); // Add a third parameter. sort(): void +Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained. -Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained. +**System capability**: SystemCapability.Utils.Lang **Example** @@ -262,14 +277,15 @@ console.log(searchParamsObject.toString()); // Display the sorted query string / keys(): IterableIterator<string> - Obtains an ES6 iterator that contains the keys of all the key-value pairs. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| -| -------- | -------- | -| IterableIterator<string> | ES6 iterator that contains the keys of all the key-value pairs.| + | Type | Description | + | -------- | -------- | + | IterableIterator<string> | ES6 iterator that contains the keys of all the key-value pairs. | **Example** @@ -287,11 +303,13 @@ values(): IterableIterator<string> Obtains an ES6 iterator that contains the values of all the key-value pairs. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| -| -------- | -------- | -| IterableIterator<string> | ES6 iterator that contains the values of all the key-value pairs.| + | Type | Description | + | -------- | -------- | + | IterableIterator<string> | ES6 iterator that contains the values of all the key-value pairs. | **Example** @@ -307,14 +325,15 @@ for (var value of searchParams.values()) { [Symbol.iterator]\(): IterableIterator<[string, string]> - Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| -| -------- | -------- | -| IterableIterator<[string, string]> | ES6 iterator.| + | Type | Description | + | -------- | -------- | + | IterableIterator<[string, string]> | ES6 iterator. | **Example** @@ -330,14 +349,15 @@ for (const [name, value] of paramsObject) { toString(): string - Obtains search parameters that are serialized as a string and, if necessary, percent-encodes the characters in the string. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| -| -------- | -------- | -| string | String of serialized search parameters, which is percent-encoded if necessary.| + | Type | Description | + | -------- | -------- | + | string | String of serialized search parameters, which is percent-encoded if necessary. | **Example** @@ -351,9 +371,10 @@ console.log(params.toString()); ## URL - ### Attributes +**System capability**: SystemCapability.Utils.Lang + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | | hash | string | Yes| Yes| String that contains a harsh mark (#) followed by the fragment identifier of a URL.| @@ -374,15 +395,16 @@ console.log(params.toString()); constructor(url: string, base?: string | URL) - Creates a URL. +**System capability**: SystemCapability.Utils.Lang + **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| url | string | Yes| Input object.| -| base | string \| URL | No| Input parameter, which can be any of the following:
- **string**: string
- **URL**: string or object| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | url | string | Yes | Input object. | + | base | string \ | URL | No | Input parameter, which can be any of the following:
- **string**: string
- **URL**: string or object | **Example** @@ -408,11 +430,13 @@ toString(): string Converts the parsed URL into a string. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| -| -------- | -------- | -| string | Website address in a serialized string.| + | Type | Description | + | -------- | -------- | + | string | Website address in a serialized string. | **Example** @@ -426,17 +450,18 @@ url.toString() toJSON(): string - Converts the parsed URL into a JSON string. +**System capability**: SystemCapability.Utils.Lang + **Return value** -| Type| Description| -| -------- | -------- | -| string | Website address in a serialized string.| + | Type | Description | + | -------- | -------- | + | string | Website address in a serialized string. | **Example** ```js const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toJSON() -``` +``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md index 7ff865803cc3c32c0a78197ebac2996516e7dd54..06aee1c2fe533edae1e869152beefc1b8afb1984 100644 --- a/en/application-dev/reference/apis/js-apis-usb.md +++ b/en/application-dev/reference/apis/js-apis-usb.md @@ -1,11 +1,11 @@ # USB -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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 -``` +```js import usb from "@ohos.usb"; ``` @@ -17,13 +17,13 @@ Obtains the USB device list. **System capability**: SystemCapability.USB.USBManager -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | Array<Readonly<[USBDevice](#usbdevice)>> | Device information list.| + | Array<Readonly<[USBDevice](#usbdevice)>> | Device information list. | -- Example - ``` +- **Example** + ```js let devicesList = usb.getDevices(); console.log(`devicesList = ${JSON.stringify(devicesList)}`); // devicesList is a list of USB devices. @@ -89,18 +89,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | device | [USBDevice](#usbdevice) | Yes| USB device information.| + | device | [USBDevice](#usbdevice) | Yes| USB device information. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | Readonly<[USBDevicePipe](#usbdevicepipe)> | USB device pipe for data transfer.| + | Readonly<[USBDevicePipe](#usbdevicepipe)> | USB device pipe for data transfer. | -- Example - ``` +- **Example** + ```js let devicepipe= usb.connectDevice(device); console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); ``` @@ -114,18 +114,18 @@ Checks whether the application has the permission to access the device. **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | deviceName | string | Yes| Device name.| + | deviceName | string | Yes| Device name. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.| + | boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise. | -- Example - ``` +- **Example** + ```js let divicesName="1-1"; let bool = usb.hasRight(divicesName); console.log(bool); @@ -140,18 +140,18 @@ Requests the temporary permission for the application to access the USB device. **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | deviceName | string | Yes| Device name.| + | deviceName | string | Yes| Device name. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | Promise<boolean> | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise.| + | Promise<boolean> | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise. | -- Example - ``` +- **Example** + ```js let divicesName="1-1"; usb.requestRight(divicesName).then((ret) => { console.log(`requestRight = ${JSON.stringify(ret)}`); @@ -169,20 +169,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| - | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.| - | force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.| + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | + | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim. | + | force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.| + | number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise. | -- Example - ``` +- **Example** + ```js let ret = usb.claimInterface(devicepipe, interfaces); console.log(`claimInterface = ${ret}`); ``` @@ -198,19 +198,19 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| - | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.| + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | + | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.| + | number | Returns **0** if the USB interface is successfully released; returns an error code otherwise. | -- Example - ``` +- **Example** + ```js let ret = usb.releaseInterface(devicepipe, interfaces); console.log(`releaseInterface = ${ret}`); ``` @@ -226,19 +226,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| - | config | [USBConfig](#usbconfig) | Yes| USB configuration to set.| + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | + | config | [USBConfig](#usbconfig) | Yes| USB configuration to set. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.| + | number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise. | -- Example - ``` +- **Example** + ```js let ret = usb.setConfiguration(devicepipe, config); console.log(`setConfiguration = ${ret}`); ``` @@ -254,19 +254,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| - | iface | [USBInterface](#usbinterface) | Yes| USB interface to set.| + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | + | iface | [USBInterface](#usbinterface) | Yes| USB interface to set. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.| + | number | Returns **0** if the USB interface is successfully set; returns an error code otherwise. | -- Example - ``` +- **Example** + ```js let ret = usb.setInterface(devicepipe, interfaces); console.log(`setInterface = ${ret}`); ``` @@ -282,18 +282,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | Uint8Array | Raw descriptor data.| + | Uint8Array | Raw descriptor data. | -- Example - ``` +- **Example** + ```js let ret = usb.getRawDescriptor(devicepipe); ``` @@ -308,18 +308,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | number | File descriptor of the USB device.| + | number | File descriptor of the USB device. | -- Example - ``` +- **Example** + ```js let ret = usb.getFileDescriptor(devicepipe); ``` @@ -334,20 +334,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| - | contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.| - | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.| + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device. | + | contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters. | + | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | Promise<number> | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.| + | Promise<number> | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs. | -- Example - ``` +- **Example** + ```js usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { console.log(`controlTransfer = ${JSON.stringify(ret)}`); }) @@ -364,21 +364,21 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| - | endpoint | [USBEndpoint](#usbendpoint) | Yes| USB endpoint, which is used to determine the USB port for data transfer.| - | buffer | Uint8Array | Yes| Buffer for writing or reading data.| - | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.| + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device. | + | endpoint | [USBEndpoint](#usbendpoint) | Yes| USB endpoint, which is used to determine the USB port for data transfer. | + | buffer | Uint8Array | Yes| Buffer for writing or reading data. | + | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | Promise<number> | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.| + | Promise<number> | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs. | -- Example - ``` +- **Example** + ```js // Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission. // Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. // Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. @@ -398,18 +398,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -- Parameters +- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.| + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe. | -- Return value +- **Return value** | Type| Description| | -------- | -------- | - | number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.| + | number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise. | -- Example - ``` +- **Example** + ```js let ret = usb.closePipe(devicepipe); console.log(`closePipe = ${ret}`); ``` @@ -423,14 +423,14 @@ Represents the USB endpoint from which data is sent or received. You can obtain | Name| Type| Description| | -------- | -------- | -------- | -| address | number | Endpoint address.| -| attributes | number | Endpoint attributes.| -| interval | number | Endpoint interval.| -| maxPacketSize | number | Maximum size of data packets on the endpoint.| -| direction | [USBRequestDirection](#usbrequestdirection) | Endpoint direction.| -| number | number | Endpoint number.| -| type | number | Endpoint type.| -| interfaceId | number | Unique ID of the interface to which the endpoint belongs.| +| address | number | Endpoint address. | +| attributes | number | Endpoint attributes. | +| interval | number | Endpoint interval. | +| maxPacketSize | number | Maximum size of data packets on the endpoint. | +| direction | [USBRequestDirection](#usbrequestdirection) | Endpoint direction. | +| number | number | Endpoint number. | +| type | number | Endpoint type. | +| interfaceId | number | Unique ID of the interface to which the endpoint belongs. | ## USBInterface @@ -441,13 +441,13 @@ Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **U | Name| Type| Description| | -------- | -------- | -------- | -| id | number | Unique ID of the USB interface.| -| protocol | number | Interface protocol.| -| clazz | number | Device type.| -| subClass | number | Device subclass.| -| alternateSetting | number | Settings for alternating between descriptors of the same USB interface.| -| name | string | Interface name.| -| endpoints | Array<[USBEndpoint](#usbendpoint)> | Endpoints that belong to the USB interface.| +| id | number | Unique ID of the USB interface. | +| protocol | number | Interface protocol. | +| clazz | number | Device type. | +| subClass | number | Device subclass. | +| alternateSetting | number | Settings for alternating between descriptors of the same USB interface. | +| name | string | Interface name. | +| endpoints | Array<[USBEndpoint](#usbendpoint)> | Endpoints that belong to the USB interface. | ## USBConfig @@ -458,13 +458,13 @@ Represents the USB configuration. One [USBDevice](#usbdevice) can contain multip | Name| Type| Description| | -------- | -------- | -------- | -| id | number | Unique ID of the USB configuration.| -| attributes | number | Configuration attributes.| -| maxPower | number | Maximum power consumption, in mA.| -| name | string | Configuration name, which can be left empty.| -| isRemoteWakeup | boolean | Support for remote wakeup.| -| isSelfPowered | boolean | Support for independent power supplies.| -| interfaces | Array <[USBInterface](#usbinterface)> | Supported interface attributes.| +| id | number | Unique ID of the USB configuration. | +| attributes | number | Configuration attributes. | +| maxPower | number | Maximum power consumption, in mA. | +| name | string | Configuration name, which can be left empty. | +| isRemoteWakeup | boolean | Support for remote wakeup. | +| isSelfPowered | boolean | Support for independent power supplies. | +| interfaces | Array <[USBInterface](#usbinterface)> | Supported interface attributes. | ## USBDevice @@ -475,19 +475,19 @@ Represents USB device information. | Name| Type| Description| | -------- | -------- | -------- | -| busNum | number | Bus address.| -| devAddress | number | Device address.| -| serial | string | Device SN.| -| name | string | Device name.| -| manufacturerName | string | Device manufacturer.| -| productName | string | Product information.| -| version | string | Version.| -| vendorId | number | Vendor ID.| -| productId | number | Product ID.| -| clazz | number | Device class.| -| subClass | number | Device subclass.| -| protocol | number | Device protocol code.| -| configs | Array<[USBConfig](#usbconfig)> | Device configuration descriptor information.| +| busNum | number | Bus address. | +| devAddress | number | Device address. | +| serial | string | Device SN. | +| name | string | Device name. | +| manufacturerName | string | Device manufacturer. | +| productName | string | Product information. | +| version | string | Version. | +| vendorId | number | Vendor ID. | +| productId | number | Product ID. | +| clazz | number | Device class. | +| subClass | number | Device subclass. | +| protocol | number | Device protocol code. | +| configs | Array<[USBConfig](#usbconfig)> | Device configuration descriptor information. | ## USBDevicePipe @@ -498,8 +498,8 @@ Represents a USB device pipe, which is used to determine a USB device. | Name| Type| Description| | -------- | -------- | -------- | -| busNum | number | Bus address.| -| devAddress | number | Device address.| +| busNum | number | Bus address. | +| devAddress | number | Device address. | ## USBControlParams @@ -510,12 +510,12 @@ Represents control transfer parameters. | Name| Type| Description| | -------- | -------- | -------- | -| request | number | Request type.| -| target | [USBRequestTargetType](#usbrequesttargettype) | Represents the request target type.| -| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Request control type.| +| request | number | Request type. | +| target | [USBRequestTargetType](#usbrequesttargettype) | Type of the request target. | +| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Request control type. | | value | number | Request parameters| -| index | number | Index of the request parameter value.| -| data | Uint8Array | Buffer for writing or reading data.| +| index | number | Index of the request parameter value. | +| data | Uint8Array | Buffer for writing or reading data. | ## USBRequestTargetType @@ -526,8 +526,8 @@ Represents the request target type. | Name| Default Value | Description| | -------- | -------- | -------- | -| USB_REQUEST_TARGET_DEVICE | 0 | Device.| -| USB_REQUEST_TARGET_INTERFACE | 1 | Interface.| +| USB_REQUEST_TARGET_DEVICE | 0 | Device. | +| USB_REQUEST_TARGET_INTERFACE | 1 | Interface. | | USB_REQUEST_TARGET_ENDPOINT | 2 | Endpoint| | USB_REQUEST_TARGET_OTHER | 3 | Others| @@ -541,7 +541,7 @@ Enumerates control request types. | Name| Default Value | Description| | -------- | -------- | -------- | | USB_REQUEST_TYPE_STANDARD | 0 | Standard| -| USB_REQUEST_TYPE_CLASS | 1 | Class.| +| USB_REQUEST_TYPE_CLASS | 1 | Class. | | USB_REQUEST_TYPE_VENDOR | 2 | Vendor| @@ -553,5 +553,5 @@ Enumerates request directions. | Name| Default Value | Description| | -------- | -------- | -------- | -| USB_REQUEST_DIR_TO_DEVICE | 0 | Request for writing data from the host to the device.| -| USB_REQUEST_DIR_FROM_DEVICE | 0x80 | Request for reading data from the device to the host.| +| USB_REQUEST_DIR_TO_DEVICE | 0 | Request for writing data from the host to the device. | +| USB_REQUEST_DIR_FROM_DEVICE | 0x80 | Request for reading data from the device to the host. | diff --git a/en/application-dev/reference/apis/js-apis-useriam-userauth.md b/en/application-dev/reference/apis/js-apis-useriam-userauth.md index 02992c0a5f646bd1016cbcdd3aae92aac0c32f2a..39b0daf04ecbf60d2f4cefbeb4b60416c187ed68 100644 --- a/en/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/en/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -1,6 +1,6 @@ # User Authentication -> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE**
+> **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. @@ -122,7 +122,7 @@ Obtains an **Authenticator** object for user authentication. **Return value** | Type | Description | | ----------------------------------------- | ------------ | -| [Authenticator](#authenticatordeprecated) | **Authenticator** object obtained.| +| [Authenticator](#authenticatordeprecated) | **Authenticator** object obtained. | **Example** ```js @@ -144,7 +144,7 @@ execute(type: string, level: string, callback: AsyncCallback<number>): voi > **NOTE**
> This API is not longer maintained since API version 8. You are advised to use [auth](#auth8). -Performs user authentication. This method uses asynchronous callback to return the result. +Performs user authentication. This API uses asynchronous callback to return the result. **Required permissions**: ohos.permission.ACCESS_BIOMETRIC @@ -154,15 +154,15 @@ Performs user authentication. This method uses asynchronous callback to return t | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.
**ALL** is reserved and not supported by the current version.| -| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).
Devices capable of 3D facial recognition support S3 and lower-level authentication.
Devices capable of 2D facial recognition support S2 and lower-level authentication.| +| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.
**ALL** is reserved and not supported by the current version. | +| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).
Devices capable of 3D facial recognition support S3 and lower-level authentication.
Devices capable of 2D facial recognition support S2 and lower-level authentication. | | callback | AsyncCallback<number> | No | Callback used to return the result. | Parameters returned in callback | Type | Description | | ------ | ------------------------------------------------------------ | -| number | Authentication result. For details, see [AuthenticationResult](#authenticationresultdeprecated).| +| number | Authentication result. For details, see [AuthenticationResult](#authenticationresultdeprecated). | **Example** ```js @@ -183,7 +183,7 @@ execute(type:string, level:string): Promise<number> > **NOTE**
> This API is not longer maintained since API version 8. You are advised to use [auth](#auth8). -Performs user authentication. This method uses a promise to return the result. +Performs user authentication. This API uses a promise to return the result. **Required permissions**: ohos.permission.ACCESS_BIOMETRIC @@ -192,13 +192,13 @@ Performs user authentication. This method uses a promise to return the result. **Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.
**ALL** is reserved and not supported by the current version.| -| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).
Devices capable of 3D facial recognition support S3 and lower-level authentication.
Devices capable of 2D facial recognition support S2 and lower-level authentication.| +| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.
**ALL** is reserved and not supported by the current version. | +| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).
Devices capable of 3D facial recognition support S3 and lower-level authentication.
Devices capable of 2D facial recognition support S2 and lower-level authentication. | **Return value** | Type | Description | | --------------------- | ------------------------------------------------------------ | -| Promise<number> | Promise used to return the authentication result, which is a number. For details, see [AuthenticationResult](#authenticationresultdeprecated).| +| Promise<number> | Promise used to return the authentication result, which is a number. For details, see [AuthenticationResult](#authenticationresultdeprecated). | **Example** @@ -222,7 +222,7 @@ Enumerates the authentication results. | Name | Default Value| Description | | ------------------ | ------ | -------------------------- | -| NO_SUPPORT | -1 | The device does not support the current authentication mode.| +| NO_SUPPORT | -1 | The device does not support the current authentication mode. | | SUCCESS | 0 | The authentication is successful. | | COMPARE_FAILURE | 1 | The feature comparison failed. | | CANCELED | 2 | The authentication was canceled by the user. | @@ -230,7 +230,7 @@ Enumerates the authentication results. | CAMERA_FAIL | 4 | The camera failed to start. | | BUSY | 5 | The authentication service is not available. Try again later. | | INVALID_PARAMETERS | 6 | The authentication parameters are invalid. | -| LOCKED | 7 | The user account is locked because the number of authentication failures has reached the threshold.| +| LOCKED | 7 | The user account is locked because the number of authentication failures has reached the threshold. | | NOT_ENROLLED | 8 | No authentication credential is registered. | | GENERAL_ERROR | 100 | Other errors. | @@ -252,7 +252,7 @@ A constructor used to create an **authenticator** object. | Type | Description | | ---------------------- | -------------------- | -| [UserAuth](#userauth8) | **Authenticator** object obtained.| +| [UserAuth](#userauth8) | **Authenticator** object obtained. | **Example** @@ -276,7 +276,7 @@ Obtains the authentication executor version. | Type | Description | | ------ | ---------------------- | -| number | Authentication executor version obtained.| +| number | Authentication executor version obtained. | **Example** @@ -302,14 +302,14 @@ Checks whether the authentication capability of the specified trust level is ava | Name | Type | Mandatory| Description | | -------------- | ---------------------------------- | ---- | -------------------------- | -| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported.| +| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported. | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level of the authentication result. | **Return value** | Type | Description | | ------ | ------------------------------------------------------------ | -| number | Whether the authentication capability of the specified trust level is available. For details, see [ResultCode](#resultcode8).| +| number | Whether the authentication capability of the specified trust level is available. For details, see [ResultCode](#resultcode8). | **Example** @@ -331,7 +331,7 @@ Checks whether the authentication capability of the specified trust level is ava auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array -Performs user authentication. This method uses a callback to return the result. +Performs user authentication. This API uses a callback to return the result. **Required permissions**: ohos.permission.ACCESS_BIOMETRIC @@ -342,7 +342,7 @@ Performs user authentication. This method uses a callback to return the result. | Name | Type | Mandatory| Description | | -------------- | ---------------------------------------- | ---- | ------------------------ | | challenge | Uint8Array | Yes | Challenge value, which can be null. | -| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported.| +| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported. | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level. | | callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback used to return the result. | @@ -350,7 +350,7 @@ Performs user authentication. This method uses a callback to return the result. | Type | Description | | ---------- | ------------------------------------------------------------ | -| Uint8Array | ContextId, which is used as the input parameter of [cancelAuth](#cancelauth8).| +| Uint8Array | ContextId, which is used as the input parameter of [cancelAuth](#cancelauth8). | **Example** @@ -389,13 +389,13 @@ Cancels an authentication. | Name | Type | Mandatory| Description | | --------- | ---------- | ---- | ------------------------------------------ | -| contextID | Uint8Array | Yes | Context ID, which is obtained using [auth](#auth8).| +| contextID | Uint8Array | Yes | Context ID, which is obtained using [auth](#auth8). | **Return value** | Type | Description | | ------ | ------------------------ | -| number | Whether the authentication is canceled.| +| number | Whether the authentication is canceled. | **Example** @@ -429,7 +429,7 @@ Obtains the authentication result. | Name | Type | Mandatory| Description | | --------- | -------------------------- | ---- | ------------------------------------------------------------ | | result | number | Yes | Authentication result obtained. For details, see [ResultCode](#resultcode8). | -| extraInfo | [AuthResult](#authresult8) | Yes | Extended information, which varies depending on the authentication result.
If the authentication is successful, the user authentication token will be returned in **extraInfo**.
If the authentication fails, the remaining number of authentication times will be returned in **extraInfo**.
If the authentication executor is locked, the freeze time will be returned in **extraInfo**.| +| extraInfo | [AuthResult](#authresult8) | Yes | Extended information, which varies depending on the authentication result.
If the authentication is successful, the user authentication token will be returned in **extraInfo**.
If the authentication fails, the remaining number of authentication times will be returned in **extraInfo**.
If the authentication executor is locked, the freeze time will be returned in **extraInfo**. | **Example** @@ -478,7 +478,7 @@ Obtains the tip code information during authentication. This function is optiona | Name | Type | Mandatory| Description | | --------- | ------ | ---- | ------------------------------ | | module | number | Yes | Type of the authentication executor. | -| acquire | number | Yes | Interaction information of the authentication executor during the authentication process.| +| acquire | number | Yes | Interaction information of the authentication executor during the authentication process. | | extraInfo | any | Yes | Reserved field. | **Example** @@ -523,8 +523,8 @@ Represents the authentication result object. | Name | Type | Mandatory| Description | | ------------ | ---------- | ---- | -------------------- | | token | Uint8Array | No | Identity authentication token. | -| remainTimes | number | No | Number of remaining authentication operations.| -| freezingTime | number | No | Time for which the authentication operation is frozen.| +| remainTimes | number | No | Number of remaining authentication operations. | +| freezingTime | number | No | Time for which the authentication operation is frozen. | ## ResultCode8+ @@ -544,7 +544,7 @@ Enumerates the operation results. | BUSY | 7 | Indicates the busy state. | | INVALID_PARAMETERS | 8 | Invalid parameters are detected. | | LOCKED | 9 | The authentication executor is locked. | -| NOT_ENROLLED | 10 | The user has not entered the authentication information.| +| NOT_ENROLLED | 10 | The user has not entered the authentication information. | ## FaceTips8+ @@ -563,7 +563,7 @@ Enumerates the tip codes used during the facial authentication process. | FACE_AUTH_TIP_TOO_LOW | 6 | Only the lower part of the face is captured because the device is angled too low. | | FACE_AUTH_TIP_TOO_RIGHT | 7 | Only the right part of the face is captured because the device is deviated to the right. | | FACE_AUTH_TIP_TOO_LEFT | 8 | Only the left part of the face is captured because the device is deviated to the left. | -| FACE_AUTH_TIP_TOO_MUCH_MOTION | 9 | The face moves too fast during facial information collection.| +| FACE_AUTH_TIP_TOO_MUCH_MOTION | 9 | The face moves too fast during facial information collection. | | FACE_AUTH_TIP_POOR_GAZE | 10 | The face is not facing the camera. | | FACE_AUTH_TIP_NOT_DETECTED | 11 | No face is detected. | @@ -577,7 +577,7 @@ Enumerates the tip codes used during the fingerprint authentication process. | Name | Default Value| Description | | --------------------------------- | ------ | -------------------------------------------------- | | FINGERPRINT_AUTH_TIP_GOOD | 0 | The obtained fingerprint image is in good condition. | -| FINGERPRINT_AUTH_TIP_DIRTY | 1 | Large fingerprint image noise is detected due to suspicious or detected dirt on the sensor.| +| FINGERPRINT_AUTH_TIP_DIRTY | 1 | Large fingerprint image noise is detected due to suspicious or detected dirt on the sensor. | | FINGERPRINT_AUTH_TIP_INSUFFICIENT | 2 | The noise of the fingerprint image is too large to be processed. | | FINGERPRINT_AUTH_TIP_PARTIAL | 3 | Incomplete fingerprint image is detected. | | FINGERPRINT_AUTH_TIP_TOO_FAST | 4 | The fingerprint image is incomplete due to fast movement. | @@ -592,8 +592,8 @@ Enumerates the identity authentication types. | Name | Default Value| Description | | ----------- | ------ | ---------- | -| FACE | 2 | Facial authentication.| -| FINGERPRINT | 4 | Fingerprint authentication.| +| FACE | 2 | Facial authentication. | +| FINGERPRINT | 4 | Fingerprint authentication. | ## AuthTrustLevel8+ @@ -603,7 +603,7 @@ Enumerates the trust levels of the authentication result. | Name| Default Value| Description | | ---- | ------ | ------------------------- | -| ATL1 | 10000 | Trust level 1.| -| ATL2 | 20000 | Trust level 2.| -| ATL3 | 30000 | Trust level 3.| -| ATL4 | 40000 | Trust level 4.| +| ATL1 | 10000 | Trust level 1. | +| ATL2 | 20000 | Trust level 2. | +| ATL3 | 30000 | Trust level 3. | +| ATL4 | 40000 | Trust level 4. | diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index ecc46e0c2d4b17d6d6a462c312a7860627b579a2..0ee9fb84705d1c23d9c453e75dd47689bc66d1d3 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -1,7 +1,7 @@ # util -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. @@ -23,15 +23,15 @@ Prints the input content in a formatted string. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| format | string | Yes| Format of the string to print.| -| ...args | Object[] | No| Data to format.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | format | string | Yes | Format of the string to print. | + | ...args | Object[] | No | Data to format. | **Return value** -| Type| Description| -| -------- | -------- | -| string | String in the specified format.| + | Type | Description | + | -------- | -------- | + | string | String in the specified format. | **Example** ```js @@ -49,14 +49,14 @@ Obtains detailed information about a system error code. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| errno | number | Yes| Error code generated.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | errno | number | Yes | Error code generated. | **Return value** -| Type| Description| -| -------- | -------- | -| string | Detailed information about the error code.| + | Type | Description | + | -------- | -------- | + | string | Detailed information about the error code. | **Example** ```js @@ -76,14 +76,14 @@ Calls back an asynchronous function. In the callback, the first parameter indica **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| original | Function | Yes| Asynchronous function.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | original | Function | Yes | Asynchronous function. | **Return value** -| Type| Description| -| -------- | -------- | -| Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value.| + | Type | Description | + | -------- | -------- | + | Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value. | **Example** ```js @@ -107,14 +107,14 @@ Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| original | Function | Yes| Asynchronous function.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | original | Function | Yes | Asynchronous function. | **Return value** -| Type| Description| -| -------- | -------- | -| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version.| + | Type | Description | + | -------- | -------- | + | Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version. | **Example** ```js @@ -138,11 +138,11 @@ Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| encoding | string | Yes| No| Encoding format.
- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le| -| fatal | boolean | Yes| No| Whether to display fatal errors.| -| ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | encoding | string | Yes | No | Encoding format.
- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le | + | fatal | boolean | Yes | No | Whether to display fatal errors. | + | ignoreBOM | boolean | Yes | No | Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM. | ### constructor @@ -154,17 +154,17 @@ A constructor used to create a **TextDecoder** object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| encoding | string | No| Encoding format.| -| options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | encoding | string | No | Encoding format. | + | options | Object | No | Encoding-related options, which include **fatal** and **ignoreBOM**. | **Table 1** options -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| fatal | boolean | No| Whether to display fatal errors.| -| ignoreBOM | boolean | No| Whether to ignore the BOM.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | fatal | boolean | No | Whether to display fatal errors. | + | ignoreBOM | boolean | No | Whether to ignore the BOM. | **Example** ```js @@ -181,21 +181,21 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| input | Unit8Array | Yes| Uint8Array to decode.| -| options | Object | No| Options related to decoding.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | input | Unit8Array | Yes | Uint8Array to decode. | + | options | Object | No | Options related to decoding. | **Table 2** options -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| stream | boolean | No| Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | stream | boolean | No | Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**. | **Return value** -| Type| Description| -| -------- | -------- | -| string | Data decoded.| + | Type | Description | + | -------- | -------- | + | string | Data decoded. | **Example** ```js @@ -222,9 +222,9 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| encoding | string | Yes| No| Encoding format. The default format is **utf-8**.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | encoding | string | Yes | No | Encoding format. The default format is **utf-8**. | ### constructor @@ -250,14 +250,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| input | string | Yes| String to encode.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | input | string | Yes | String to encode. | **Return value** -| Type| Description| -| -------- | -------- | -| Uint8Array | Encoded text.| + | Type | Description | + | -------- | -------- | + | Uint8Array | Encoded text. | **Example** ```js @@ -276,15 +276,15 @@ Stores the UTF-8 encoded text. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| input | string | Yes| String to encode.| -| dest | Uint8Array | Yes| **Uint8Array** instance used to store the UTF-8 encoded text.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | input | string | Yes | String to encode. | + | dest | Uint8Array | Yes | **Uint8Array** instance used to store the UTF-8 encoded text. | **Return value** -| Type| Description| -| -------- | -------- | -| Uint8Array | Encoded text.| + | Type | Description | + | -------- | -------- | + | Uint8Array | Encoded text. | **Example** ```js @@ -306,10 +306,10 @@ A constructor used to create a **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| numerator | number | Yes| Numerator, which is an integer.| -| denominator | number | Yes| Denominator, which is an integer.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | numerator | number | Yes | Numerator, which is an integer. | + | denominator | number | Yes | Denominator, which is an integer. | **Example** ```js @@ -326,14 +326,14 @@ Creates a **RationalNumber** object based on the given string. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| rationalString | string | Yes| String used to create the **RationalNumber** object.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | rationalString | string | Yes | String used to create the **RationalNumber** object. | **Return value** -| Type| Description| -| -------- | -------- | -| object | **RationalNumber** object created.| + | Type | Description | + | -------- | -------- | + | object | **RationalNumber** object created. | **Example** ```js @@ -351,14 +351,14 @@ Compares this **RationalNumber** object with a given object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| another | RationalNumber | Yes| Object used to compare with this **RationalNumber** object.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | another | RationalNumber | Yes | Object used to compare with this **RationalNumber** object. | **Return value** -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.| + | Type | Description | + | -------- | -------- | + | number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object. | **Example** @@ -378,9 +378,9 @@ Obtains the value of this **RationalNumber** object as an integer or a floating- **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | An integer or a floating-point number.| + | Type | Description | + | -------- | -------- | + | number | An integer or a floating-point number. | **Example** ```js @@ -398,14 +398,14 @@ Checks whether this **RationalNumber** object equals the given object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| object | Object | Yes| Object used to compare with this **RationalNumber** object.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | object | Object | Yes | Object used to compare with this **RationalNumber** object. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the two objects are equal; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the two objects are equal; returns **false** otherwise. | **Example** ```js @@ -424,15 +424,15 @@ Obtains the greatest common divisor of two specified integers. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| number1 | number | Yes| The first integer used to get the greatest common divisor.| -| number2 | number | Yes| The second integer used to get the greatest common divisor.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | number1 | number | Yes | The first integer used to get the greatest common divisor. | + | number2 | number | Yes | The second integer used to get the greatest common divisor. | **Return value** -| Type| Description| -| -------- | -------- | -| number | Greatest common divisor obtained.| + | Type | Description | + | -------- | -------- | + | number | Greatest common divisor obtained. | **Example** ```js @@ -451,9 +451,9 @@ Obtains the numerator of this **RationalNumber** object. **Return value** -| Type| Description| -| -------- | -------- | -| number | Numerator of this **RationalNumber** object.| + | Type | Description | + | -------- | -------- | + | number | Numerator of this **RationalNumber** object. | **Example** ```js @@ -471,9 +471,9 @@ Obtains the denominator of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Denominator of this **RationalNumber** object.| + | Type | Description | + | -------- | -------- | + | number | Denominator of this **RationalNumber** object. | **Example** ```js @@ -491,9 +491,9 @@ Checks whether this **RationalNumber** object is **0**. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise. | **Example** ```js @@ -511,9 +511,9 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise. | **Example** ```js @@ -531,9 +531,9 @@ Checks whether this **RationalNumber** object represents a finite value. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise. | **Example** ```js @@ -551,9 +551,9 @@ Obtains the string representation of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**.| + | Type | Description | + | -------- | -------- | + | string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**. | **Example** ```js @@ -567,9 +567,9 @@ Obtains the string representation of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| length | number | Yes| No| Total number of values in this buffer.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | length | number | Yes | No | Total number of values in this buffer. | **Example** ```js @@ -589,9 +589,9 @@ A constructor used to create an **LruBuffer** instance. The default capacity of **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| capacity | number | No| Capacity of the **LruBuffer** to create.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | capacity | number | No | Capacity of the **LruBuffer** to create. | **Example** ```js @@ -608,9 +608,9 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| newCapacity | number | Yes| New capacity of the **LruBuffer**.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | newCapacity | number | Yes | New capacity of the **LruBuffer**. | **Example** ```js @@ -628,9 +628,9 @@ Obtains the string representation of this **LruBuffer** object. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| string | String representation of this **LruBuffer** object.| + | Type | Description | + | -------- | -------- | + | string | String representation of this **LruBuffer** object. | **Example** ```js @@ -651,9 +651,9 @@ Obtains the capacity of this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Capacity of this buffer.| + | Type | Description | + | -------- | -------- | + | number | Capacity of this buffer. | **Example** ```js @@ -688,9 +688,9 @@ Obtains the number of return values for **createDefault()**. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Number of return values for **createDefault()**.| + | Type | Description | + | -------- | -------- | + | number | Number of return values for **createDefault()**. | **Example** ```js @@ -709,9 +709,9 @@ Obtains the number of times that the queried values are mismatched. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Number of times that the queried values are mismatched.| + | Type | Description | + | -------- | -------- | + | number | Number of times that the queried values are mismatched. | **Example** ```js @@ -731,9 +731,9 @@ Obtains the number of removals from this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Number of removals from the buffer.| + | Type | Description | + | -------- | -------- | + | number | Number of removals from the buffer. | **Example** ```js @@ -754,9 +754,9 @@ Obtains the number of times that the queried values are matched. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Number of times that the queried values are matched.| + | Type | Description | + | -------- | -------- | + | number | Number of times that the queried values are matched. | **Example** ```js @@ -776,9 +776,9 @@ Obtains the number of additions to this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Number of additions to the buffer.| + | Type | Description | + | -------- | -------- | + | number | Number of additions to the buffer. | **Example** ```js @@ -797,9 +797,9 @@ Checks whether this buffer is empty. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the buffer does not contain any value.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the buffer does not contain any value. | **Example** ```js @@ -811,21 +811,21 @@ Checks whether this buffer is empty. ### get8+ -get(key: K): V | undefined +get(key: K): V | undefined Obtains the value of the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| key | K | Yes| Key based on which the value is queried.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | key | K | Yes | Key based on which the value is queried. | **Return value** -| Type| Description| -| -------- | -------- | -| V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| + | Type | Description | + | -------- | -------- | + | V \ | undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise. | **Example** ```js @@ -844,15 +844,15 @@ Adds a key-value pair to this buffer. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| key | K | Yes| Key of the key-value pair to add.| -| value | V | Yes| Value of the key-value pair to add.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | key | K | Yes | Key of the key-value pair to add. | + | value | V | Yes | Value of the key-value pair to add. | **Return value** -| Type| Description| -| -------- | -------- | -| V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | + | Type | Description | + | -------- | -------- | + | V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | **Example** ```js @@ -870,9 +870,9 @@ Obtains all values in this buffer, listed from the most to the least recently ac **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| V [] | All values in the buffer, listed from the most to the least recently accessed.| + | Type | Description | + | -------- | -------- | + | V [] | All values in the buffer, listed from the most to the least recently accessed. | **Example** ```js @@ -893,9 +893,9 @@ Obtains all keys in this buffer, listed from the most to the least recently acce **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| K [] | All keys in the buffer, listed from the most to the least recently accessed.| + | Type | Description | + | -------- | -------- | + | K [] | All keys in the buffer, listed from the most to the least recently accessed. | **Example** ```js @@ -907,21 +907,21 @@ Obtains all keys in this buffer, listed from the most to the least recently acce ### remove8+ -remove(key: K): V | undefined +remove(key: K): V | undefined Removes the specified key and its value from this buffer. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| key | K | Yes| Key to remove.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | key | K | Yes | Key to remove. | **Return value** -| Type| Description| -| -------- | -------- | -| V \| undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.| + | Type | Description | + | -------- | -------- | + | V \ | undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown. | **Example** ```js @@ -940,12 +940,12 @@ Performs subsequent operations after a value is removed. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| isEvict | boolean | No| Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity.| -| key | K | Yes| Key removed.| -| value | V | Yes| Value removed.| -| newValue | V | No| New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | isEvict | boolean | No | Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity. | + | key | K | Yes | Key removed. | + | value | V | Yes | Value removed. | + | newValue | V | No | New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank. | **Example** ```js @@ -985,14 +985,14 @@ Checks whether this buffer contains the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| key | K | Yes| Key to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | key | K | Yes | Key to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise. | **Example** ```js @@ -1011,14 +1011,14 @@ Creates a value if the value of the specified key is not available. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| key | K | Yes| Key of which the value is missing.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | key | K | Yes | Key of which the value is missing. | **Return value** -| Type| Description| -| -------- | -------- | -| V | Value of the key.| + | Type | Description | + | -------- | -------- | + | V | Value of the key. | **Example** ```js @@ -1036,9 +1036,9 @@ Obtains a new iterator object that contains all key-value pairs in this object. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| [K, V] | Iterable array.| + | Type | Description | + | -------- | -------- | + | [K, V] | Iterable array. | **Example** ```js @@ -1057,9 +1057,9 @@ Obtains a two-dimensional array in key-value pairs. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| [K, V] | Two-dimensional array in key-value pairs.| + | Type | Description | + | -------- | -------- | + | [K, V] | Two-dimensional array in key-value pairs. | **Example** ```js @@ -1081,7 +1081,7 @@ The values of the **ScopeComparable** type are used to implement the **compareTo interface ScopeComparable{ compareTo(other: ScopeComparable): boolean; } -type ScopeType = ScopeComparable | number; +type ScopeType = ScopeComparable | number; ``` @@ -1116,10 +1116,10 @@ A constructor used to create a **Scope** object with the specified upper and low **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit of the **Scope** object.| -| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit of the **Scope** object.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit of the **Scope** object. | + | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit of the **Scope** object. | **Example** ```js @@ -1138,9 +1138,9 @@ Obtains a string representation that contains this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| string | String representation containing the **Scope**.| + | Type | Description | + | -------- | -------- | + | string | String representation containing the **Scope**. | **Example** ```js @@ -1160,14 +1160,14 @@ Obtains the intersection of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| range | [Scope](#scope8) | Yes| **Scope** specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | range | [Scope](#scope8) | Yes | **Scope** specified. | **Return value** -| Type| Description| -| -------- | -------- | -| [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.| + | Type | Description | + | -------- | -------- | + | [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**. | **Example** ```js @@ -1190,15 +1190,15 @@ Obtains the intersection of this **Scope** and the given lower and upper limits. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| -| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit. | + | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit. | **Return value** -| Type| Description| -| -------- | -------- | -| [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits.| + | Type | Description | + | -------- | -------- | + | [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits. | **Example** ```js @@ -1221,9 +1221,9 @@ Obtains the upper limit of this **Scope**. **Return value** -| Type| Description| -| -------- | -------- | -| [ScopeType](#scopetype8) | Upper limit of this **Scope**.| + | Type | Description | + | -------- | -------- | + | [ScopeType](#scopetype8) | Upper limit of this **Scope**. | **Example** ```js @@ -1243,9 +1243,9 @@ Obtains the lower limit of this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| [ScopeType](#scopetype8) | Lower limit of this **Scope**.| + | Type | Description | + | -------- | -------- | + | [ScopeType](#scopetype8) | Lower limit of this **Scope**. | **Example** ```js @@ -1265,15 +1265,15 @@ Obtains the union set of this **Scope** and the given lower and upper limits. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| -| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit. | + | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit. | **Return value** -| Type| Description| -| -------- | -------- | -| [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.| + | Type | Description | + | -------- | -------- | + | [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits. | **Example** ```js @@ -1295,14 +1295,14 @@ Obtains the union set of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| range | [Scope](#scope8) | Yes| **Scope** specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | range | [Scope](#scope8) | Yes | **Scope** specified. | **Return value** -| Type| Description| -| -------- | -------- | -| [Scope](#scope8) | Union set of this **Scope** and the given **Scope**.| + | Type | Description | + | -------- | -------- | + | [Scope](#scope8) | Union set of this **Scope** and the given **Scope**. | **Example** ```js @@ -1325,14 +1325,14 @@ Obtains the union set of this **Scope** and the given value. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | [ScopeType](#scopetype8) | Yes| Value specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | [ScopeType](#scopetype8) | Yes | Value specified. | **Return value** -| Type| Description| -| -------- | -------- | -| [Scope](#scope8) | Union set of this **Scope** and the given value.| + | Type | Description | + | -------- | -------- | + | [Scope](#scope8) | Union set of this **Scope** and the given value. | **Example** ```js @@ -1353,14 +1353,14 @@ Checks whether a value is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | [ScopeType](#scopetype8) | Yes| Value specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | [ScopeType](#scopetype8) | Yes | Value specified. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise. | **Example** ```js @@ -1381,14 +1381,14 @@ Checks whether a range is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| range | [Scope](#scope8) | Yes| **Scope** specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | range | [Scope](#scope8) | Yes | **Scope** specified. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise. | **Example** ```js @@ -1411,14 +1411,14 @@ Limits a value to this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | [ScopeType](#scopetype8) | Yes| Value specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | [ScopeType](#scopetype8) | Yes | Value specified. | **Return value** -| Type| Description| -| -------- | -------- | -| [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**.| + | Type | Description | + | -------- | -------- | + | [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**. | **Example** ```js @@ -1456,14 +1456,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array | Yes| Uint8Array to encode.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array | Yes | Uint8Array to encode. | **Return value** -| Type| Description| -| -------- | -------- | -| Uint8Array | Uint8Array encoded.| + | Type | Description | + | -------- | -------- | + | Uint8Array | Uint8Array encoded. | **Example** ```js @@ -1482,14 +1482,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array | Yes| Uint8Array to encode.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array | Yes | Uint8Array to encode. | **Return value** -| Type| Description| -| -------- | -------- | -| string | String encoded from the Uint8Array.| + | Type | Description | + | -------- | -------- | + | string | String encoded from the Uint8Array. | **Example** ```js @@ -1501,21 +1501,21 @@ Encodes the input content. ### decodeSync8+ -decodeSync(src: Uint8Array | string): Uint8Array +decodeSync(src: Uint8Array | string): Uint8Array Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array \| string | Yes| Uint8Array or string to decode.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array \ | string | Yes | Uint8Array or string to decode. | **Return value** -| Type| Description| -| -------- | -------- | -| Uint8Array | Uint8Array decoded.| + | Type | Description | + | -------- | -------- | + | Uint8Array | Uint8Array decoded. | **Example** ```js @@ -1534,14 +1534,14 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array | Yes | Uint8Array to encode asynchronously. | **Return value** -| Type| Description| -| -------- | -------- | -| Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding.| + | Type | Description | + | -------- | -------- | + | Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding. | **Example** ```js @@ -1565,14 +1565,14 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array | Yes | Uint8Array to encode asynchronously. | **Return value** -| Type| Description| -| -------- | -------- | -| Promise<string> | String obtained after asynchronous encoding.| + | Type | Description | + | -------- | -------- | + | Promise<string> | String obtained after asynchronous encoding. | **Example** ```js @@ -1586,21 +1586,21 @@ Encodes the input content asynchronously. ### decode8+ -decode(src: Uint8Array | string): Promise<Uint8Array> +decode(src: Uint8Array | string): Promise<Uint8Array> Decodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array \ | string | Yes | Uint8Array or string to decode asynchronously. | **Return value** -| Type| Description| -| -------- | -------- | -| Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding.| + | Type | Description | + | -------- | -------- | + | Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding. | **Example** ```js @@ -1641,14 +1641,14 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise. | **Example** ```js @@ -1668,14 +1668,14 @@ Checks whether the input value is of the **ArrayBufferView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise. | **Example** ```js @@ -1693,14 +1693,14 @@ Checks whether the input value is of the **arguments** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise. | **Example** ```js @@ -1721,14 +1721,14 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise. | **Example** ```js @@ -1746,14 +1746,14 @@ Checks whether the input value is an asynchronous function. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise. | **Example** ```js @@ -1771,14 +1771,14 @@ Checks whether the input value is of the **Boolean** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise. | **Example** ```js @@ -1796,14 +1796,14 @@ Checks whether the input value is of the **Boolean**, **Number**, **String**, or **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise. | **Example** ```js @@ -1821,14 +1821,14 @@ Checks whether the input value is of the **DataView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise. | **Example** ```js @@ -1847,14 +1847,14 @@ Checks whether the input value is of the **Date** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise. | **Example** ```js @@ -1872,14 +1872,14 @@ Checks whether the input value is of the **native external** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise. | **Example** ```js @@ -1898,14 +1898,14 @@ Checks whether the input value is of the **Float32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise. | **Example** ```js @@ -1923,14 +1923,14 @@ Checks whether the input value is of the **Float64Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise. | **Example** ```js @@ -1948,14 +1948,14 @@ Checks whether the input value is a generator function. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a generator function; returns **false** otherwise. | **Example** ```js @@ -1973,14 +1973,14 @@ Checks whether the input value is a generator object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a generator object; returns **false** otherwise. | **Example** ```js @@ -2000,14 +2000,14 @@ Checks whether the input value is of the **Int8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise. | **Example** ```js @@ -2025,14 +2025,14 @@ Checks whether the input value is of the **Int16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise. | **Example** ```js @@ -2050,14 +2050,14 @@ Checks whether the input value is of the **Int32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise. | **Example** ```js @@ -2075,14 +2075,14 @@ Checks whether the input value is of the **Map** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise. | **Example** ```js @@ -2100,14 +2100,14 @@ Checks whether the input value is of the **MapIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise. | **Example** ```js @@ -2126,14 +2126,14 @@ Checks whether the input value is of the **Error** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise. | **Example** ```js @@ -2151,14 +2151,14 @@ Checks whether the input value is a number object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a number object; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a number object; returns **false** otherwise. | **Example** ```js @@ -2176,14 +2176,14 @@ Checks whether the input value is a promise. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a promise; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a promise; returns **false** otherwise. | **Example** ```js @@ -2201,14 +2201,14 @@ Checks whether the input value is a proxy. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a proxy; returns **false** otherwise. | **Example** ```js @@ -2228,14 +2228,14 @@ Checks whether the input value is of the **RegExp** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise. | **Example** ```js @@ -2253,14 +2253,14 @@ Checks whether the input value is of the **Set** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise. | **Example** ```js @@ -2278,14 +2278,14 @@ Checks whether the input value is of the **SetIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise. | **Example** ```js @@ -2304,14 +2304,14 @@ Checks whether the input value is a string object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a string object; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a string object; returns **false** otherwise. | **Example** ```js @@ -2329,14 +2329,14 @@ Checks whether the input value is a symbol object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise. | **Example** ```js @@ -2357,14 +2357,14 @@ Checks whether the input value is of the **TypedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise. | **Example** ```js @@ -2382,14 +2382,14 @@ Checks whether the input value is of the **Uint8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise. | **Example** ```js @@ -2407,14 +2407,14 @@ Checks whether the input value is of the **Uint8ClampedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise. | **Example** ```js @@ -2432,14 +2432,14 @@ Checks whether the input value is of the **Uint16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise. | **Example** ```js @@ -2457,14 +2457,14 @@ Checks whether the input value is of the **Uint32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise. | **Example** ```js @@ -2482,14 +2482,14 @@ Checks whether the input value is of the **WeakMap** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise. | **Example** ```js @@ -2507,17 +2507,17 @@ Checks whether the input value is of the **WeakSet** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise. | **Example** ```js var that = new util.types(); var result = that.isWeakSet(new WeakSet()); - ``` + ``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-vector.md b/en/application-dev/reference/apis/js-apis-vector.md index dd540d63eb2153ffd6166df967481d63a9ec13d5..004ff8a1c46f14e2bb7916153de47cb7e25e5314 100644 --- a/en/application-dev/reference/apis/js-apis-vector.md +++ b/en/application-dev/reference/apis/js-apis-vector.md @@ -1,6 +1,6 @@ # Linear Container Vector -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. @@ -20,9 +20,9 @@ SystemCapability.Utils.Lang ### Attributes -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| length | number | Yes| No| Number of entries in a vector (called container later).| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | length | number | Yes | No | Number of entries in a vector (called container later). | ### constructor @@ -46,15 +46,15 @@ Adds an entry at the end of this container. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| element | T | Yes| Entry to add.| + | 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.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the entry is added successfully; returns **false** otherwise. | **Example** @@ -76,10 +76,10 @@ 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.| + | 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** @@ -98,15 +98,15 @@ Checks whether this container has the specified entry. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| element | T | Yes| Entry to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | element | T | Yes | Entry to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the entry is contained; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the entry is contained; returns **false** otherwise. | **Example** @@ -125,15 +125,15 @@ Obtains the index of the first occurrence of the specified entry in this contain **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| element | T | Yes| Entry to obtain.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | element | T | Yes | Entry to obtain. | **Return value** -| Type| Description| -| -------- | -------- | -| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + | Type | Description | + | -------- | -------- | + | number | Returns the position index if obtained; returns **-1** if the specified entry is not found. | **Example** @@ -157,15 +157,15 @@ Obtains the index of the last occurrence of the specified entry in this containe **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| element | T | Yes| Entry to obtain.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | element | T | Yes | Entry to obtain. | **Return value** -| Type| Description| -| -------- | -------- | -| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + | Type | Description | + | -------- | -------- | + | number | Returns the position index if obtained; returns **-1** if the specified entry is not found. | **Example** @@ -189,15 +189,15 @@ Removes an entry at the specified position from this container. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| index | number | Yes| Position index of the entry to remove.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | index | number | Yes | Position index of the entry to remove. | **Return value** -| Type| Description| -| -------- | -------- | -| T | Entry removed.| + | Type | Description | + | -------- | -------- | + | T | Entry removed. | **Example** @@ -219,15 +219,15 @@ Removes the first occurrence of the specified entry from this container. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| element | T | Yes| Entry to remove.| + | 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.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise. | **Return value** @@ -248,10 +248,10 @@ Removes from this container all of the entries within a range, including the ent **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| fromIndex | number | Yes| Index of the start position.| -| toIndex | number | Yes| Index of the end position.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | fromIndex | number | Yes | Index of the start position. | + | toIndex | number | Yes | Index of the end position. | **Example** @@ -275,18 +275,18 @@ Replaces all entries in this container with new entries, and returns the new one **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callbackfn | function | Yes| Callback invoked for replacement.| -| thisArg | Object | No| Value to use when the callback is invoked.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callbackfn | function | Yes | Callback invoked for 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.| -| vector | Vector<T> | No| Instance that invokes the **replaceAllElements** API.| + | 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. | + | vector | Vector<T> | No | Instance that invokes the **replaceAllElements** API. | **Example** @@ -313,18 +313,18 @@ Uses a callback to traverse the entries in this container and obtain their posit **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callbackfn | function | Yes| Callback invoked for replacement.| -| thisArg | Object | No| Value to use when the callback is invoked.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callbackfn | function | Yes | Callback invoked for 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.| -| vector | Vector<T> | No| Instance that invokes the **forEach** API.| + | 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. | + | vector | Vector<T> | No | Instance that invokes the **forEach** API. | **Example** @@ -348,16 +348,16 @@ Sorts entries in this container. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------- | -------- | -------- | -| comparator | function | No | Callback invoked for sorting. | + | 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. | + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | firstValue | T | Yes | Previous entry. | + | secondValue | T | Yes | Next entry. | **Example** @@ -380,16 +380,16 @@ Obtains entries within a range in this container, including the entry at the sta **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| fromIndex | number | Yes| Index of the start position.| -| toIndex | number | Yes| Index of the end position.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | fromIndex | number | Yes | Index of the start position. | + | toIndex | number | Yes | Index of the end position. | **Return value** -| Type| Description| -| -------- | -------- | -| Vector<T> | New **Vector** instance obtained.| + | Type | Description | + | -------- | -------- | + | Vector<T> | New **Vector** instance obtained. | **Return value** @@ -430,9 +430,9 @@ Clones this container and returns a copy. The modification to the copy does not **Return value** -| Type| Description| -| -------- | -------- | -| Vector<T> | New **Vector** instance obtained.| + | Type | Description | + | -------- | -------- | + | Vector<T> | New **Vector** instance obtained. | **Example** @@ -453,9 +453,9 @@ Obtains the capacity of this container. **Return value** -| Type| Description| -| -------- | -------- | -| number | Capacity obtained.| + | Type | Description | + | -------- | -------- | + | number | Capacity obtained. | **Example** @@ -476,9 +476,9 @@ Converts this container into an array. **Return value** -| Type| Description| -| -------- | -------- | -| Array<T> | Array obtained.| + | Type | Description | + | -------- | -------- | + | Array<T> | Array obtained. | **Example** @@ -499,9 +499,9 @@ Checks whether this container is empty (contains no entries). **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the container is empty; returns **false** otherwise. | **Example** @@ -522,9 +522,9 @@ Increases the capacity of this container. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| newCapacity | number | Yes| New capacity.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | newCapacity | number | Yes | New capacity. | **Example** @@ -563,9 +563,9 @@ Uses commas (,) to concatenate entries in this container into a string. **Return value** -| Type| Description| -| -------- | -------- | -| string | String obtained.| + | Type | Description | + | -------- | -------- | + | string | String obtained. | **Example** @@ -586,9 +586,9 @@ Copies entries in this container into an array to overwrite elements of the same **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| array | Array<T> | Yes| Array to which the entries in the container will be copied.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | array | Array<T> | Yes | Array to which the entries in the container will be copied. | **Example** @@ -610,9 +610,9 @@ Obtains the first entry in this container. **Return value** -| Type| Description| -| -------- | -------- | -| T | The first entry obtained.| + | Type | Description | + | -------- | -------- | + | T | The first entry obtained. | **Example** @@ -633,9 +633,9 @@ Obtains the last entry in this container. **Return value** -| Type| Description| -| -------- | -------- | -| T | The last entry obtained.| + | Type | Description | + | -------- | -------- | + | T | The last entry obtained. | **Example** @@ -656,16 +656,16 @@ Searches for an entry backward from the specified position index and returns the **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| element | T | Yes| Entry to query.| -| index | number | Yes| Position index where the search starts.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | element | T | Yes | Entry to query. | + | index | number | Yes | Position index where the search starts. | **Return value** -| Type| Description| -| -------- | -------- | -| number | Returns the position index if obtained; returns **-1** if the entry is not found.| + | Type | Description | + | -------- | -------- | + | number | Returns the position index if obtained; returns **-1** if the entry is not found. | **Example** @@ -687,16 +687,16 @@ Searches for an entry forward from the specified position index and returns the **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| element | T | Yes| Entry to query.| -| index | number | Yes| Position index where the search starts.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | element | T | Yes | Entry to query. | + | index | number | Yes | Position index where the search starts. | **Return value** -| Type| Description| -| -------- | -------- | -| number | Returns the position index if obtained; returns **-1** if the entry is not found.| + | Type | Description | + | -------- | -------- | + | number | Returns the position index if obtained; returns **-1** if the entry is not found. | **Example** @@ -718,9 +718,9 @@ Sets a new length for this container. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| newSize | number | Yes| New length to set.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | newSize | number | Yes | New length to set. | **Example** @@ -742,15 +742,15 @@ Obtains an entry at the specified position in this container. **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | - | index | number | Yes| Position index of the entry to obtain.| + | index | number | Yes | Position index of the entry to obtain. | **Return value** - | Type| Description| + | Type | Description | | -------- | -------- | - | T | Entry obtained.| + | T | Entry obtained. | **Example** @@ -770,16 +770,16 @@ Replaces an entry at the specified position in this container with a given entry **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| index | number | Yes| Position index of the entry to replace.| -| element | T | Yes| Entry to be used for replacement.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | index | number | Yes | Position index of the entry to replace. | + | element | T | Yes | Entry to be used for replacement. | **Return value** - | Type| Description| + | Type | Description | | -------- | -------- | - | T | New entry.| + | T | New entry. | **Example** @@ -800,9 +800,9 @@ Replaces an entry at the specified position in this container with a given entry Obtains an iterator. Each item of the iterator is a JavaScript object. **Return value** -| Type| Description| -| -------- | -------- | -| IterableIterator<T> | Iterator obtained.| + | Type | Description | + | -------- | -------- | + | IterableIterator<T> | Iterator obtained. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-vibrator.md b/en/application-dev/reference/apis/js-apis-vibrator.md index 1251c4b6d0a6cb4b9f88b555101e230972906b05..6ea1af902df9dd714aa0e3476c3419011a21f2d2 100644 --- a/en/application-dev/reference/apis/js-apis-vibrator.md +++ b/en/application-dev/reference/apis/js-apis-vibrator.md @@ -1,6 +1,6 @@ # Vibrator -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> **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. @@ -23,14 +23,14 @@ Triggers vibration with a specific duration. This API uses a promise to return t **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------ | ---- | ------------ | -| duration | number | Yes | Vibration duration.| + | Name | Type | Mandatory | Description | + | -------- | ------ | ---- | ------------ | + | duration | number | Yes | Vibration duration. | **Return value** -| Type | Description | -| ------------------- | ----------- | -| Promise<void> | Promise used to indicate whether the vibration is triggered successfully.| + | Type | Description | + | ------------------- | ----------- | + | Promise<void> | Promise used to indicate whether the vibration is triggered successfully. | **Example** @@ -54,10 +54,10 @@ Triggers vibration with a specific duration. This API uses an asynchronous callb **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ----------------------- | -| duration | number | Yes | Vibration duration. | -| callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is triggered successfully.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ----------------------- | + | duration | number | Yes | Vibration duration. | + | callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is triggered successfully. | **Example** ``` @@ -82,14 +82,14 @@ Triggers vibration with a specific effect. This API uses a promise to return the **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------- | ---- | ------------- | -| effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect.| + | Name | Type | Mandatory | Description | + | -------- | --------------------- | ---- | ------------- | + | effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. | **Return value** -| Type | Description | -| ------------------- | ----------- | -| Promise<void> | Promise used to indicate whether the vibration is triggered successfully.| + | Type | Description | + | ------------------- | ----------- | + | Promise<void> | Promise used to indicate whether the vibration is triggered successfully. | **Example** ``` @@ -112,10 +112,10 @@ Triggers vibration with a specific effect. This API uses an asynchronous callbac **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ----------------------- | -| effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. | -| callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is triggered successfully.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ----------------------- | + | effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. | + | callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is triggered successfully. | **Example** ``` @@ -140,14 +140,14 @@ Stops the vibration based on the specified **stopMode**. This API uses a promise **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------------- | ---- | --------------- | -| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------------- | ---- | --------------- | + | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. | **Return value** -| Type | Description | -| ------------------- | ----------- | -| Promise<void> | Promise used to indicate whether the vibration is stopped successfully.| + | Type | Description | + | ------------------- | ----------- | + | Promise<void> | Promise used to indicate whether the vibration is stopped successfully. | **Example** ``` @@ -170,10 +170,10 @@ Stops the vibration based on the specified **stopMode**. This API uses an asynch **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------------- | ---- | ----------------------- | -| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. | -| callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is stopped successfully.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------------- | ---- | ----------------------- | + | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. | + | callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is stopped successfully. | **Example** ``` @@ -193,9 +193,9 @@ Describes the vibration effect. **System capability**: SystemCapability.Sensors.MiscDevice -| Name | Default Value | Description | -| ------------------ | -------------------- | --------------- | -| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer.| + | Name | Default Value | Description | + | ------------------ | -------------------- | --------------------------------------------------------------- | + | EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer. | ## VibratorStopMode @@ -204,7 +204,7 @@ Describes the vibration mode to stop. **System capability**: SystemCapability.Sensors.MiscDevice -| Name | Default Value | Description | -| ------------------------- | -------- | ---------------------------------------- | -| VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type.| -| VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type.| + | Name | Default Value | Description | + | ------------------------- | -------- | ---------------------------------------- | + | VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type. | + | VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type. | diff --git a/en/application-dev/reference/apis/js-apis-wallpaper.md b/en/application-dev/reference/apis/js-apis-wallpaper.md index 8f0d4aaae67090bf9335b223e6882852397a4a23..726134af57d86fcb611dd5a03c898d3e656bd272 100644 --- a/en/application-dev/reference/apis/js-apis-wallpaper.md +++ b/en/application-dev/reference/apis/js-apis-wallpaper.md @@ -1,8 +1,8 @@ # Wallpaper -> ![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. +> ![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. +> ## Modules to Import @@ -21,8 +21,8 @@ Defines the wallpaper type. | Name | Description | | -------- | -------- | -| WALLPAPER_LOCKSCREEN | Lock screen wallpaper. | -| WALLPAPER_SYSTEM | Home screen wallpaper. | +| WALLPAPER_LOCKSCREEN | Lock screen wallpaper. | +| WALLPAPER_SYSTEM | Home screen wallpaper. | ## wallpaper.getColors @@ -36,12 +36,12 @@ Obtains the main color information of the wallpaper of a specified type. - Parameters | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | - | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | Yes | Callback used to return the main color information of the wallpaper. | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | Yes | Callback used to return the main color information of the wallpaper. | - Example - ``` + ```js wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to getColors because: ` + JSON.stringify(error)); @@ -60,25 +60,27 @@ Obtains the main color information of the wallpaper of a specified type. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | Promise<Array<[RgbaColor](#rgbacolor)>> | Promise used to return the main color information of the wallpaper. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | -- Example - - ``` - wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to getColors.`); - }).catch((error) => { - console.error(`failed to getColors because: ` + JSON.stringify(error)); - }); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| Promise<Array<[RgbaColor](#rgbacolor)>> | Promise used to return the main color information of the wallpaper. | + +**Example** + +```js +wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to getColors.`); +}).catch((error) => { + console.error(`failed to getColors because: ` + JSON.stringify(error)); +}); +``` ## wallpaper.getId @@ -89,23 +91,24 @@ Obtains the ID of the wallpaper of the specified type. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | - | callback | AsyncCallback<number> | Yes | Callback used to return the wallpaper ID. If the wallpaper of the specified type is configured, a number greater than or equal to **0** is returned. Otherwise, **-1** is returned. The value ranges from -1 to 2^31-1. | +**Parameters** -- Example - - ``` - wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - if (error) { - console.error(`failed to getId because: ` + JSON.stringify(error)); - return; - } - console.log(`success to getId: ` + JSON.stringify(data)); - }); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | +| callback | AsyncCallback<number> | Yes | Callback used to return the wallpaper ID. If the wallpaper of the specified type is configured, a number greater than or equal to **0** is returned. Otherwise, **-1** is returned. The value ranges from -1 to 2^31-1. | + +**Example** + +```js +wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to getId because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getId: ` + JSON.stringify(data)); +}); +``` ## wallpaper.getId @@ -116,26 +119,27 @@ Obtains the ID of the wallpaper of the specified type. **System capability**: SystemCapability.MiscServices.Wallpaper +**Parameters** -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | -- Return values - | Type | Description | - | -------- | -------- | - | Promise<number> | Promise used to return the wallpaper ID. If this type of wallpaper is configured, a number greater than or equal to **0** is returned. Otherwise, **-1** is returned. The value ranges from -1 to 2^31-1. | +**Return value** -- Example - - ``` - wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to getId: ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to getId because: ` + JSON.stringify(error)); - }); - ``` +| Type | Description | +| -------- | -------- | +| Promise<number> | Promise used to return the wallpaper ID. If this type of wallpaper is configured, a number greater than or equal to **0** is returned. Otherwise, **-1** is returned. The value ranges from -1 to 2^31-1. | + +**Example** + +```js +wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to getId: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`failed to getId because: ` + JSON.stringify(error)); +}); +``` ## wallpaper.getMinHeight @@ -146,22 +150,23 @@ Obtains the minimum height of the wallpaper. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<number> | Yes | Callback used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead. | +**Parameters** -- Example - - ``` - wallpaper.getMinHeight((error, data) => { - if (error) { - console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); - return; - } - console.log(`success to getMinHeight: ` + JSON.stringify(data)); - }); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<number> | Yes | Callback used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead. | + +**Example** + +```js +wallpaper.getMinHeight((error, data) => { + if (error) { + console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getMinHeight: ` + JSON.stringify(data)); +}); +``` ## wallpaper.getMinHeight @@ -172,21 +177,21 @@ Obtains the minimum height of the wallpaper. **System capability**: SystemCapability.MiscServices.Wallpaper +**Return value** -- Return values - | Type | Description | - | -------- | -------- | - | Promise<number> | Promise used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead. | +| Type | Description | +| -------- | -------- | +| Promise<number> | Promise used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead. | -- Example - - ``` - wallpaper.getMinHeight().then((data) => { - console.log(`success to getMinHeight: ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); - }); - ``` +**Example** + +```js +wallpaper.getMinHeight().then((data) => { + console.log(`success to getMinHeight: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); +}); +``` ## wallpaper.getMinWidth @@ -197,23 +202,23 @@ Obtains the minimum width of the wallpaper. **System capability**: SystemCapability.MiscServices.Wallpaper +**Parameters** -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<number> | Yes | Callback used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<number> | Yes | Callback used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead. | -- Example - - ``` - wallpaper.getMinWidth((error, data) => { - if (error) { - console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); - return; - } - console.log(`success to getMinWidth: ` + JSON.stringify(data)); - }); - ``` +**Example** + +```js +wallpaper.getMinWidth((error, data) => { + if (error) { + console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getMinWidth: ` + JSON.stringify(data)); +}); +``` ## wallpaper.getMinWidth @@ -224,20 +229,21 @@ Obtains the minimum width of the wallpaper. **System capability**: SystemCapability.MiscServices.Wallpaper -- Return values - | Type | Description | - | -------- | -------- | - | Promise<number> | Promised used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead. | +**Return value** -- Example - - ``` - wallpaper.getMinWidth().then((data) => { - console.log(`success to getMinWidth: ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); - }); - ``` +| Type | Description | +| -------- | -------- | +| Promise<number> | Promised used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead. | + +**Example** + +```js +wallpaper.getMinWidth().then((data) => { + console.log(`success to getMinWidth: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); +}); +``` ## wallpaper.isChangePermitted @@ -248,22 +254,23 @@ Checks whether to allow the application to change the wallpaper for the current **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the queried result. Returns **true** if it is allowed; returns **false** otherwise. | +**Parameters** -- Example - - ``` - wallpaper.isChangePermitted((error, data) => { - if (error) { - console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); - return; - } - console.log(`success to isChangePermitted: ` + JSON.stringify(data)); - }); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the queried result. Returns **true** if it is allowed; returns **false** otherwise. | + +**Example** + +```js +wallpaper.isChangePermitted((error, data) => { + if (error) { + console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); + return; + } + console.log(`success to isChangePermitted: ` + JSON.stringify(data)); +}); +``` ## wallpaper.isChangePermitted @@ -274,20 +281,21 @@ Checks whether to allow the application to change the wallpaper for the current **System capability**: SystemCapability.MiscServices.Wallpaper -- Return values - | Type | Description | - | -------- | -------- | - | Promise<boolean> | Promise used to return whether to allow the application to change the wallpaper for the current user. Returns **true** if it is allowed; returns **false** otherwise. | +**Return value** -- Example - - ``` - wallpaper.isChangePermitted().then((data) => { - console.log(`success to isChangePermitted: ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); - }); - ``` +| Type | Description | +| -------- | -------- | +| Promise<boolean> | Promise used to return whether to allow the application to change the wallpaper for the current user. Returns **true** if it is allowed; returns **false** otherwise. | + +**Example** + +```js +wallpaper.isChangePermitted().then((data) => { + console.log(`success to isChangePermitted: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); +}); +``` ## wallpaper.isOperationAllowed @@ -298,22 +306,23 @@ Checks whether the user is allowed to set wallpapers. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. | +**Parameters** -- Example - - ``` - wallpaper.isOperationAllowed((error, data) => { - if (error) { - console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); - return; - } - console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); - }); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. | + +**Example** + +```js +wallpaper.isOperationAllowed((error, data) => { + if (error) { + console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); + return; + } + console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); +}); +``` ## wallpaper.isOperationAllowed @@ -324,20 +333,21 @@ Checks whether the user is allowed to set wallpapers. **System capability**: SystemCapability.MiscServices.Wallpaper -- Return values - | Type | Description | - | -------- | -------- | - | Promise<boolean> | Promise used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. | +**Return value** -- Example - - ``` - wallpaper.isOperationAllowed().then((data) => { - console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); - }); - ``` +| Type | Description | +| -------- | -------- | +| Promise<boolean> | Promise used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. | + +**Example** + +```js +wallpaper.isOperationAllowed().then((data) => { + console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); +}); +``` ## wallpaper.reset @@ -350,23 +360,24 @@ Removes a wallpaper of the specified type and restores the default one. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | - | callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. | +**Parameters** -- Example - - ``` - wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - if (error) { - console.error(`failed to reset because: ` + JSON.stringify(error)); - return; - } - console.log(`success to reset.`); - }); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. | + +**Example** + +```js +wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to reset because: ` + JSON.stringify(error)); + return; + } + console.log(`success to reset.`); +}); +``` ## wallpaper.reset @@ -379,25 +390,27 @@ Removes a wallpaper of the specified type and restores the default one. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | -- Example - - ``` - wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to reset.`); - }).catch((error) => { - console.error(`failed to reset because: ` + JSON.stringify(error)); - }); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. | + +**Example** + +```js +wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to reset.`); +}).catch((error) => { + console.error(`failed to reset because: ` + JSON.stringify(error)); +}); +``` ## wallpaper.setWallpaper @@ -410,47 +423,48 @@ Sets a specified source as the wallpaper of a specified type. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | Uri path of the JPEG or PNG file, or bitmap of the PNG file. | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | - | callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. | - -- Example - - ``` - //The source type is string. - let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; - wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - if (error) { - console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); - return; - } - console.log(`success to setWallpaper.`); - }); - - //The source type is image.PixelMap. - import image from '@ohos.multimedia.image'; - let imageSource = image.createImageSource("file://" + wallpaperPath); - let opts = { - "desiredSize": { - "height": 3648, - "width": 2736 - } - }; - imageSource.createPixelMap(opts).then((pixelMap) => { - wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - if (error) { - console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); - return; - } - console.log(`success to setWallpaper.`); - }); - }).catch((error) => { - console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); - }); - ``` +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | URI path of the JPEG or PNG file, or bitmap of the PNG file. | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. | + +**Example** + +```js +// The source type is string. +let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; +wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + return; + } + console.log(`success to setWallpaper.`); +}); + +// The source type is image.PixelMap. +import image from '@ohos.multimedia.image'; +let imageSource = image.createImageSource("file://" + wallpaperPath); +let opts = { + "desiredSize": { + "height": 3648, + "width": 2736 + } +}; +imageSource.createPixelMap(opts).then((pixelMap) => { + wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + return; + } + console.log(`success to setWallpaper.`); + }); +}).catch((error) => { + console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); +}); +``` ## wallpaper.setWallpaper @@ -463,47 +477,49 @@ Sets a specified source as the wallpaper of a specified type. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | Uri path of the JPEG or PNG file, or bitmap of the PNG file. | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | URI path of the JPEG or PNG file, or bitmap of the PNG file. | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | -- Example - - ``` - //The source type is string. - let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; - wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to setWallpaper.`); - }).catch((error) => { - console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); - }); - - //The source type is image.PixelMap. - import image from '@ohos.multimedia.image'; - let imageSource = image.createImageSource("file://" + wallpaperPath); - let opts = { - "desiredSize": { - "height": 3648, - "width": 2736 - } - }; - imageSource.createPixelMap(opts).then((pixelMap) => { - wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to setWallpaper.`); - }).catch((error) => { - console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); - }); - }).catch((error) => { - console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); - }); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. | + +**Example** + +```js +// The source type is string. +let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; +wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to setWallpaper.`); +}).catch((error) => { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); +}); + +// The source type is image.PixelMap. +import image from '@ohos.multimedia.image'; +let imageSource = image.createImageSource("file://" + wallpaperPath); +let opts = { + "desiredSize": { + "height": 3648, + "width": 2736 + } +}; +imageSource.createPixelMap(opts).then((pixelMap) => { + wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to setWallpaper.`); + }).catch((error) => { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + }); +}).catch((error) => { + console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); +}); +``` ## wallpaper.getFile8+ @@ -511,27 +527,28 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): vo Obtains the wallpaper of the specified type. -**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE +**Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | - | callback | AsyncCallback<number> | Yes | Callback used to return the result. If the operation is successful, the file descriptor ID to the wallpaper is returned. Otherwise, error information is returned. | +**Parameters** -- Example - - ``` - wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - if (error) { - console.error(`failed to getFile because: ` + JSON.stringify(error)); - return; - } - console.log(`success to getFile: ` + JSON.stringify(data)); - }); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | +| callback | AsyncCallback<number> | Yes | Callback used to return the result. If the operation is successful, the file descriptor ID to the wallpaper is returned. Otherwise, error information is returned. | + +**Example** + +```js +wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to getFile because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getFile: ` + JSON.stringify(data)); +}); +``` ## wallpaper.getFile8+ @@ -543,25 +560,27 @@ Obtains the wallpaper of the specified type. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | +**Parameters** -- Return values - | Type | Description | - | -------- | -------- | - | Promise<number> | Promise used to return the result. If the operation is successful, the file descriptor ID to the wallpaper is returned. Otherwise, error information is returned. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | -- Example - - ``` - wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`success to getFile: ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to getFile because: ` + JSON.stringify(error)); - }); - ``` +**Return value** + +| Type | Description | +| -------- | -------- | +| Promise<number> | Promise used to return the result. If the operation is successful, the file descriptor ID to the wallpaper is returned. Otherwise, error information is returned. | + +**Example** + +```js +wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to getFile: ` + JSON.stringify(data)); +}).catch((error) => { + console.error(`failed to getFile because: ` + JSON.stringify(error)); +}); +``` ## wallpaper.on('colorChange') @@ -572,20 +591,21 @@ Subscribes to the wallpaper color change event. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to subscribe to. The value **colorChange** indicates subscribing to the wallpaper color change event. | - | callback | function | Yes | Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.
- colors
  Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).
- wallpaperType
  Wallpaper type. | +**Parameters** -- Example - - ``` - let listener = (colors, wallpaperType) => { - console.log(`wallpaper color changed.`); - }; - wallpaper.on('colorChange', listener); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the event to subscribe to. The value **colorChange** indicates subscribing to the wallpaper color change event. | +| callback | function | Yes | Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.
- colors
Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).
- wallpaperType
Wallpaper type. | + +**Example** + +```js +let listener = (colors, wallpaperType) => { + console.log(`wallpaper color changed.`); +}; +wallpaper.on('colorChange', listener); +``` ## wallpaper.off('colorChange') @@ -596,24 +616,25 @@ Unsubscribes from the wallpaper color change event. **System capability**: SystemCapability.MiscServices.Wallpaper -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to unsubscribe from. The value **colorChange** indicates unsubscribing from the wallpaper color change event. | - | callback | function | No |   Callback for the wallpaper color change event. If this parameter is not specified, all callbacks corresponding to the wallpaper color change event are invoked.
- colors
  Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).
- wallpaperType
  Wallpaper type. | +**Parameters** -- Example - - ``` - let listener = (colors, wallpaperType) => { - console.log(`wallpaper color changed.`); - }; - wallpaper.on('colorChange', listener); - // Unsubscribe from the listener. - wallpaper.off('colorChange', listener); - //Unsubscribe from all subscriptions of the colorChange type. - wallpaper.off('colorChange'); - ``` +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the event to unsubscribe from. The value **colorChange** indicates unsubscribing from the wallpaper color change event. | +| callback | function | No | Callback for the wallpaper color change event. If this parameter is not specified, all callbacks corresponding to the wallpaper color change event are invoked.
- colors
Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).
- wallpaperType
Wallpaper type. | + +**Example** + +```js +let listener = (colors, wallpaperType) => { + console.log(`wallpaper color changed.`); +}; +wallpaper.on('colorChange', listener); +// Unsubscribe from the listener. +wallpaper.off('colorChange', listener); +//Unsubscribe from all subscriptions of the colorChange type. +wallpaper.off('colorChange'); +``` ## RgbaColor @@ -622,7 +643,7 @@ Unsubscribes from the wallpaper color change event. | Name | Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| red | number | Yes | Yes | Red color. The value ranges from 0 to 255. | -| green | number | Yes | Yes | Green color. The value ranges from 0 to 255. | -| blue | number | Yes | Yes | Blue color. The value ranges from 0 to 255. | -| alpha | number | Yes | Yes | Alpha value. The value ranges from 0 to 255. | +| red | number | Yes | Yes | Red color. The value ranges from 0 to 255. | +| green | number | Yes | Yes | Green color. The value ranges from 0 to 255. | +| blue | number | Yes | Yes | Blue color. The value ranges from 0 to 255. | +| alpha | number | Yes | Yes | Alpha value. The value ranges from 0 to 255. | diff --git a/en/application-dev/reference/apis/js-apis-webSocket.md b/en/application-dev/reference/apis/js-apis-webSocket.md index 1796e369ab3d562eab9cf49815c31c3d53dd26e1..a1a24975f9e67c6acfccfc42fe9669b07fa90e22 100644 --- a/en/application-dev/reference/apis/js-apis-webSocket.md +++ b/en/application-dev/reference/apis/js-apis-webSocket.md @@ -12,13 +12,13 @@ If an error occurs in any of the preceding processes, the client will receive a ## Modules to Import -``` +```js import webSocket from '@ohos.net.webSocket'; ``` ## Complete Example -``` +```js import webSocket from '@ohos.net.webSocket'; var defaultIpAddress = "ws://"; @@ -78,7 +78,7 @@ Creates a WebSocket connection. You can use this API to create or close a WebSoc **Example** -``` +```js let ws = webSocket.createWebSocket(); ``` @@ -107,7 +107,7 @@ Initiates a WebSocket request to establish a WebSocket connection to a given URL **Example** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" ws.connect(url, (err, value) => { @@ -141,7 +141,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke **Example** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" ws.connect(url, { @@ -184,7 +184,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke **Example** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" let promise = ws.connect(url); @@ -215,7 +215,7 @@ Sends data through a WebSocket connection. This API uses an asynchronous callbac **Example** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" ws.connect(url, (err, value) => { @@ -254,7 +254,7 @@ Sends data through a WebSocket connection. This API uses a promise to return the **Example** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" ws.connect(url, (err, value) => { @@ -286,7 +286,7 @@ Closes a WebSocket connection. This API uses an asynchronous callback to return **Example** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" ws.close((err, value) => { @@ -318,7 +318,7 @@ Closes a WebSocket connection carrying specified options such as **code** and ** **Example** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" ws.close({ @@ -358,7 +358,7 @@ Closes a WebSocket connection carrying specified options such as **code** and ** **Example** -``` +```js let ws = webSocket.createWebSocket(); let url = "ws://" let promise = ws.close({ @@ -391,7 +391,7 @@ Enables listening for the **open** events of a WebSocket connection. This API us **Example** -``` +```js let ws = webSocket.createWebSocket(); ws.on('open', (err, value) => { console.log("on open, status:" + value.status + ", message:" + value.message); @@ -419,7 +419,7 @@ Disables listening for the **open** events of a WebSocket connection. This API u **Example** -``` +```js let ws = webSocket.createWebSocket(); let callback1 = (err, value) => { console.log("on open, status:" + value.status + ", message:" + value.message); @@ -451,7 +451,7 @@ Enables listening for the **message** events of a WebSocket connection. This API **Example** -``` +```js let ws = webSocket.createWebSocket(); ws.on('message', (err, value) => { console.log("on message, message:" + value); @@ -480,7 +480,7 @@ Disables listening for the **message** events of a WebSocket connection. This AP **Example** -``` +```js let ws = webSocket.createWebSocket(); ws.off('message'); ``` @@ -503,7 +503,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u **Example** -``` +```js let ws = webSocket.createWebSocket(); ws.on('close', (err, value) => { console.log("on close, code is " + value.code + ", reason is " + value.reason); @@ -532,7 +532,7 @@ Disables listening for the **close** events of a WebSocket connection. This API **Example** -``` +```js let ws = webSocket.createWebSocket(); ws.off('close'); ``` @@ -556,7 +556,7 @@ Enables listening for the **error** events of a WebSocket connection. This API u **Example** -``` +```js let ws = webSocket.createWebSocket(); ws.on('error', (err) => { console.log("on error, error:" + JSON.stringify(err)) @@ -584,7 +584,7 @@ Disables listening for the **error** events of a WebSocket connection. This API **Example** -``` +```js let ws = webSocket.createWebSocket(); ws.off('error'); ``` diff --git a/en/application-dev/reference/apis/js-apis-webgl.md b/en/application-dev/reference/apis/js-apis-webgl.md index 93a0097271884f8fb6a1db27be251d658c2a63b7..5538e471be7bc9d6541a54438f9eb0008483b170 100644 --- a/en/application-dev/reference/apis/js-apis-webgl.md +++ b/en/application-dev/reference/apis/js-apis-webgl.md @@ -1,6 +1,6 @@ # webgl -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. @@ -13,10 +13,10 @@ Create a **** component in the HML file. The following is an example: ``` - - +
+ - +
``` Obtain the **** component instance in the JS file. The following is an example: diff --git a/en/application-dev/reference/apis/js-apis-webgl2.md b/en/application-dev/reference/apis/js-apis-webgl2.md index 3f96a4e9ad839f6201c1303c2f6bad2dce249ab7..85559c1a9fcff3f4ac093fb4cf00957972f05145 100644 --- a/en/application-dev/reference/apis/js-apis-webgl2.md +++ b/en/application-dev/reference/apis/js-apis-webgl2.md @@ -1,6 +1,6 @@ # webgl2 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. @@ -13,10 +13,10 @@ Create a **** component in the HML file. The following is an example: ``` - - +
+ - +
``` Obtain the **** component instance in the JS file. The following is an example: diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md index d2dfe5b33e2b60e2da26f66fb998d0123ee5247e..4c4f1e76a0fbfb8d847f092698a27899fba367d3 100644 --- a/en/application-dev/reference/apis/js-apis-window.md +++ b/en/application-dev/reference/apis/js-apis-window.md @@ -2,9 +2,9 @@ The **Window** module provides basic capabilities for managing windows, including creating and destroying windows and setting serial port attributes. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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 @@ -96,7 +96,7 @@ This is a system API and cannot be called by third-party applications. ## Rect7+ -Describes a rectangle. +Describes the rectangular area of the window. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -137,20 +137,19 @@ Describes the window properties. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name | Type | Readable| Writable| Description | -| ------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| windowRect7+ | [Rect](#rect) | Yes | Yes | Window size. | -| type7+ | [WindowType](#windowtype) | Yes | Yes | Window type. | -| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is **false**. | -| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is **false**. | -| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is **true**. | -| touchable7+ | boolean | Yes | No | Whether the window is touchable. The default value is **true**. | -| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value **1** indicates the maximum brightness.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| -| dimBehindValue7+ | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value **1** indicates the maximum dimness.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| -| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| -| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| -| isRoundCorner7+ | boolean | Yes | Yes | Whether the window has rounded corners. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| -| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| +| Name | Type | Readable| Writable| Description | +| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- | +| windowRect7+ | [Rect](#rect) | Yes | Yes | Window size. | +| type7+ | [WindowType](#windowtype) | Yes | Yes | Window type. | +| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is **false**. | +| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is **false**. | +| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is **true**. | +| touchable7+ | boolean | Yes | No | Whether the window is touchable. The default value is **true**. | +| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value **1** indicates the maximum brightness. | +| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is **false**. | +| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is **false**. | +| isRoundCorner7+ | boolean | Yes | Yes | Whether the window has rounded corners. The default value is **false**. | +| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is **false**. | ## ColorSpace8+ @@ -175,11 +174,11 @@ This API is discarded since API version 8. You are advised to use [window.create **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | -------------------------- | - | id | string | Yes | Window ID. | - | type | [WindowType](#windowtype) | Yes | Window type. | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | -------------------------- | +| id | string | Yes | Window ID. | +| type | [WindowType](#windowtype) | Yes | Window type. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| **Example** @@ -208,16 +207,16 @@ This API is discarded since API version 8. You are advised to use [window.create **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------------------------- | ---- | ---------- | - | id | string | Yes | Window ID. | - | type | [WindowType](#windowtype) | Yes | Window type.| +| Name| Type | Mandatory| Description | +| ------ | ------------------------- | ---- | ---------- | +| id | string | Yes | Window ID. | +| type | [WindowType](#windowtype) | Yes | Window type.| **Return value** - | Type | Description | - | -------------------------------- | ------------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the subwindow created.| +| Type | Description | +| -------------------------------- | ------------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the subwindow created.| **Example** @@ -238,18 +237,18 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi Creates a subwindow when the context is [Context](js-apis-Context.md). This API uses an asynchronous callback to return the result. -Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md), starting from API version 9. This API uses an asynchronous callback to return the result. +Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md). This API uses an asynchronous callback to return the result. It is valid since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | - | ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).| - | id | string | Yes | Window ID. | - | type | [WindowType](#windowtype) | Yes | Window type. | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window created. | +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).| +| id | string | Yes | Window ID. | +| type | [WindowType](#windowtype) | Yes | Window type. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window created. | **Example** @@ -272,23 +271,23 @@ create(ctx: Context, id: string, type: WindowType): Promise<Window> Creates a subwindow when the context is [Context](js-apis-Context.md). This API uses a promise to return the result. -Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md), starting from API version 9. This API uses a promise to return the result. +Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md). This API uses a promise to return the result. It is valid since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------------------------- | ---- | ------------------------------------------------------------ | - | ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).| - | id | string | Yes | Window ID. | - | type | [WindowType](#windowtype) | Yes | Window type. | +| Name| Type | Mandatory| Description | +| ------ | ------------------------- | ---- | ------------------------------------------------------------ | +| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).| +| id | string | Yes | Window ID. | +| type | [WindowType](#windowtype) | Yes | Window type. | **Return value** - | Type | Description | - | -------------------------------- | ----------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the window created.| +| Type | Description | +| -------------------------------- | ----------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the window created.| **Example** @@ -313,10 +312,10 @@ Finds a window based on the ID. This API uses an asynchronous callback to return **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | ---------------------------- | - | id | string | Yes | Window ID. | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window found.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ---------------------------- | +| id | string | Yes | Window ID. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window found.| **Example** @@ -342,15 +341,15 @@ Finds a window based on the ID. This API uses a promise to return the result. **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | -------- | - | id | string | Yes | Window ID.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------- | +| id | string | Yes | Window ID.| **Return value** - | Type | Description | - | -------------------------------- | ----------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the window found.| +| Type | Description | +| -------------------------------- | ----------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the window found.| **Example** @@ -371,13 +370,15 @@ getTopWindow(callback: AsyncCallback<Window>): void Obtains the top window of the current application. This API uses an asynchronous callback to return the result. +This API is discarded since API version 8. You are advised to use [window.getTopWindow8+](#windowgettopwindow8) instead. + **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | -------------------------------------- | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained.| **Example** @@ -399,13 +400,15 @@ getTopWindow(): Promise<Window> Obtains the top window of the current application. This API uses a promise to return the result. +This API is discarded since API version 8. You are advised to use [window.getTopWindow8+](#windowgettopwindow8) instead. + **System capability**: SystemCapability.WindowManager.WindowManager.Core **Return value** - | Type | Description | - | -------------------------------- | --------------------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the top window obtained.| +| Type | Description | +| -------------------------------- | --------------------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the top window obtained.| **Example** @@ -430,10 +433,10 @@ Obtains the top window of the current application. This API uses an asynchronous **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | - | ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. | +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. | **Example** @@ -459,15 +462,15 @@ Obtains the top window of the current application. This API uses a promise to re **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------- | ---- | ------------------------------------------------------------ | - | ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| +| Name| Type | Mandatory| Description | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| **Return value** - | Type | Description | - | -------------------------------- | --------------------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the top window obtained.| +| Type | Description | +| -------------------------------- | --------------------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the top window obtained.| **Example** @@ -494,10 +497,10 @@ This is a system API and cannot be called by third-party applications. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.| - | callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.| +| callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the information. | **Example** @@ -520,10 +523,10 @@ This is a system API and cannot be called by third-party applications. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.| - | callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.| +| callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the information. | **Example** @@ -548,9 +551,9 @@ This is a system API and cannot be called by third-party applications. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| **Example** @@ -576,9 +579,9 @@ This is a system API and cannot be called by third-party applications. **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -601,9 +604,9 @@ Shows this window. This API uses an asynchronous callback to return the result. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| **Example** @@ -627,9 +630,9 @@ Shows this window. This API uses a promise to return the result. **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -652,9 +655,9 @@ Destroys this window. This API uses an asynchronous callback to return the resul **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| **Example** @@ -678,9 +681,9 @@ Destroys this window. This API uses a promise to return the result. **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -697,17 +700,17 @@ Destroys this window. This API uses a promise to return the result. moveTo(x: number, y: number, callback: AsyncCallback<void>): void -Moves the position of this window. This API uses an asynchronous callback to return the result. +Moves this window. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | --------------------------------------- | - | x | number | Yes | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.| - | y | number | Yes | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | --------------------------------------- | +| x | number | Yes | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.| +| y | number | Yes | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -726,22 +729,22 @@ Moves the position of this window. This API uses an asynchronous callback to ret moveTo(x: number, y: number): Promise<void> -Moves the position of this window. This API uses a promise to return the result. +Moves this window. This API uses a promise to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | --------------------------------------- | - | x | number | Yes | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.| - | y | number | Yes | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | --------------------------------------- | +| x | number | Yes | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.| +| y | number | Yes | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -764,11 +767,11 @@ Changes the size of this window. This API uses an asynchronous callback to retur **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------------- | - | width | number | Yes | New width of the window.| - | height | number | Yes | New height of the window.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------------- | +| width | number | Yes | New width of the window.| +| height | number | Yes | New height of the window.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -792,16 +795,16 @@ Changes the size of this window. This API uses a promise to return the result. **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ---------------- | - | width | number | Yes | New width of the window.| - | height | number | Yes | New height of the window.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------- | +| width | number | Yes | New width of the window.| +| height | number | Yes | New height of the window.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -826,10 +829,10 @@ This is a system API and cannot be called by third-party applications. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------- | - | type | [WindowType](#windowtype) | Yes | Window type.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| type | [WindowType](#windowtype) | Yes | Window type.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| **Example** @@ -856,15 +859,15 @@ This is a system API and cannot be called by third-party applications. **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------------------------- | ---- | ---------- | - | type | [WindowType](#windowtype) | Yes | Window type.| +| Name| Type | Mandatory| Description | +| ------ | ------------------------- | ---- | ---------- | +| type | [WindowType](#windowtype) | Yes | Window type.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -888,9 +891,9 @@ Obtains the properties of this window. This API uses an asynchronous callback to **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------------------------------------------- | ---- | ------------------ | - | callback | AsyncCallback<[WindowProperties](#windowproperties)> | Yes | Callback used to return the window properties.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------------------- | ---- | ------------------ | +| callback | AsyncCallback<[WindowProperties](#windowproperties)> | Yes | Callback used to return the window properties.| **Example** @@ -914,9 +917,9 @@ Obtains the properties of this window. This API uses a promise to return the res **Return value** - | Type | Description | - | ---------------------------------------------------- | ------------------------------------- | - | Promise<[WindowProperties](#windowproperties)> | Promise used to return the window properties.| +| Type | Description | +| ---------------------------------------------------- | ------------------------------------- | +| Promise<[WindowProperties](#windowproperties)> | Promise used to return the window properties.| **Example** @@ -939,10 +942,10 @@ Obtains the area where this window cannot be displayed, for example, the system **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | - | type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| - | callback | AsyncCallback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| +| callback | AsyncCallback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | **Example** @@ -967,15 +970,15 @@ Obtains the area where this window cannot be displayed, for example, the system **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------------------------------- | ---- | ------------------------------------------------------------ | - | type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| +| Name| Type | Mandatory| Description | +| ------ | ------------------------------- | ---- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| **Return value** - | Type | Description | - | -------------------------------------- | --------------------------------------------- | - | Promise<[AvoidArea](#avoidarea)> | Promise used to return the area.| +| Type | Description | +| -------------------------------------- | --------------------------------------------- | +| Promise<[AvoidArea](#avoidarea)> | Promise used to return the area.| **Example** @@ -998,10 +1001,10 @@ Sets whether to enable the full-screen mode for this window. This API uses an as **Parameters** - | Name | Type | Mandatory| Description | - | ------------ | ------------------------- | ---- | ---------------------------------------------- | - | isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ------------ | ------------------------- | ---- | ---------------------------------------------- | +| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1026,15 +1029,15 @@ Sets whether to enable the full-screen mode for this window. This API uses a pro **Parameters** - | Name | Type | Mandatory| Description | - | ------------ | ------- | ---- | ---------------------------------------------- | - | isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| +| Name | Type | Mandatory| Description | +| ------------ | ------- | ---- | ---------------------------------------------- | +| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1052,16 +1055,16 @@ Sets whether to enable the full-screen mode for this window. This API uses a pro setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void -Sets whether the window layout is in full-screen mode. This API uses an asynchronous callback to return the result. +Sets whether to enable the full-screen mode for the window layout. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | - | isLayoutFullScreen | boolean | Yes | Whether the window layout is in full-screen mode, in which the status bar and navigation bar are displayed.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1080,21 +1083,21 @@ Sets whether the window layout is in full-screen mode. This API uses an asynchro setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> -Sets whether the window layout is in full-screen mode. This API uses a promise to return the result. +Sets whether to enable the full-screen mode for the window layout. This API uses a promise to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ------------------ | ------- | ---- | ------------------------------------------------------------ | - | isLayoutFullScreen | boolean | Yes | Whether the window layout is in full-screen mode, in which the status bar and navigation bar are displayed.| +| Name | Type | Mandatory| Description | +| ------------------ | ------- | ---- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1118,10 +1121,10 @@ Sets whether to display the status bar and navigation bar in this window. This A **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ------------------------------------------------------------ | - | names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------------------------------------------ | +| names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1146,15 +1149,15 @@ Sets whether to display the status bar and navigation bar in this window. This A **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ----- | ---- | ------------------------------------------------------------ | - | names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.| +| Name| Type | Mandatory| Description | +| ------ | ----- | ---- | ------------------------------------------------------------ | +| names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1178,10 +1181,10 @@ Sets the properties of the status bar and navigation bar in this window. This AP **Parameters** - | Name | Type | Mandatory| Description | - | ------------------- | ------------------------------------------- | ---- | -------------------- | - | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ------------------- | ------------------------------------------- | ---- | -------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1215,15 +1218,15 @@ Sets the properties of the status bar and navigation bar in this window. This AP **Parameters** - | Name | Type | Mandatory| Description | - | ------------------- | ------------------------------------------- | ---- | -------------------- | - | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| +| Name | Type | Mandatory| Description | +| ------------------- | ------------------------------------------- | ---- | -------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1256,10 +1259,10 @@ Loads content to this window. This API uses an asynchronous callback to return t **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | -------------------- | - | path | string | Yes | Path of the page from which the content will be loaded.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------- | +| path | string | Yes | Path of the page from which the content will be loaded.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1283,15 +1286,15 @@ Loads content to this window. This API uses a promise to return the result. **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | -------------------- | - | path | string | Yes | Path of the page from which the content will be loaded.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------- | +| path | string | Yes | Path of the page from which the content will be loaded.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1314,9 +1317,9 @@ Checks whether this window is displayed. This API uses an asynchronous callback **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------------- | ---- | -------------------------------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the window is displayed.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | -------------------------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the window is displayed.| **Example** @@ -1340,9 +1343,9 @@ Checks whether this window is displayed. This API uses a promise to return the r **Return value** - | Type | Description | - | ---------------------- | ----------------------------------------------------- | - | Promise<boolean> | Promise used to return whether the window is displayed.| +| Type | Description | +| ---------------------- | ----------------------------------------------------- | +| Promise<boolean> | Promise used to return whether the window is displayed.| **Example** @@ -1365,10 +1368,10 @@ Enables listening for window size changes. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ----------------------------- | ---- | -------------------------------------------------------- | - | type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| - | callback | Callback<[Size](#size)> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------------- | ---- | -------------------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| +| callback | Callback<[Size](#size)> | Yes | Callback used to return the information. | **Example** @@ -1389,10 +1392,10 @@ Disables listening for window size changes. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ----------------------------- | ---- | -------------------------------------------------------- | - | type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| - | callback | Callback<[Size](#size)> | No | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------------- | ---- | -------------------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| +| callback | Callback<[Size](#size)> | No | Callback used to return the information. | **Example** @@ -1411,10 +1414,10 @@ Enables listening for changes to the area where the window cannot be displayed. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.| - | callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.| +| callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the information. | **Example** @@ -1435,10 +1438,10 @@ Disables listening for changes to the area where the window cannot be displayed. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.| - | callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.| +| callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the information. | **Example** @@ -1453,16 +1456,14 @@ on(type: 'keyboardHeightChange', callback: Callback<number>): void Enables listening for keyboard height changes. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------ | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| - | callback | Callbacknumber> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| +| callback | Callbacknumber> | Yes | Callback used to return the information. | **Example** @@ -1479,16 +1480,14 @@ off(type: 'keyboardHeightChange', callback?: Callback<number>): void Disables listening for keyboard height changes. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| - | callback | Callback<number> | No | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| +| callback | Callback<number> | No | Callback used to return the information. | **Example** @@ -1507,9 +1506,9 @@ Checks whether this window supports the wide color gamut mode. This API uses an **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------------- | ---- | -------------------------------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the wide color gamut mode is supported.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | -------------------------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the wide color gamut mode is supported.| **Example** @@ -1533,9 +1532,9 @@ Checks whether this window supports the wide color gamut mode. This API uses a p **Return value** - | Type | Description | - | ---------------------- | ------------------------------------------------------------ | - | Promise<boolean> | Promise used to return whether the wide color gamut mode is supported.| +| Type | Description | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise used to return whether the wide color gamut mode is supported.| **Example** @@ -1558,10 +1557,10 @@ Sets this window to the wide or default color gamut mode. This API uses an async **Parameters** - | Name | Type | Mandatory| Description | - | ---------- | ------------------------- | ---- | ------------ | - | colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | ------------ | +| colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1585,15 +1584,15 @@ Sets this window to the wide or default color gamut mode. This API uses a promis **Parameters** - | Name | Type | Mandatory| Description | - | ---------- | ------------------------- | ---- | ------------ | - | colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | ------------ | +| colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1616,9 +1615,9 @@ Obtains the color gamut mode of this window. This API uses an asynchronous callb **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------------------------------- | ---- | -------------------------- | - | callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the color gamut mode obtained.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------- | ---- | -------------------------- | +| callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the color gamut mode obtained.| **Example** @@ -1642,9 +1641,9 @@ Obtains the color gamut mode of this window. This API uses a promise to return t **Return value** - | Type | Description | - | ---------------------------------------- | ----------------------------------------- | - | Promise<[ColorSpace](#colorspace)> | Promise used to return the color gamut mode obtained.| +| Type | Description | +| ---------------------------------------- | ----------------------------------------- | +| Promise<[ColorSpace](#colorspace)> | Promise used to return the color gamut mode obtained.| **Example** @@ -1663,16 +1662,14 @@ setBackgroundColor(color: string, callback: AsyncCallback<void>): void Sets the background color for this window. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ------------------------------------------------------------ | - | color | string | Yes | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------------------------------------------ | +| color | string | Yes | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1693,21 +1690,19 @@ setBackgroundColor(color: string): Promise<void> Sets the background color for this window. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------------------------------------------------------------ | - | color | string | Yes | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| color | string | Yes | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1727,16 +1722,14 @@ setBrightness(brightness: number, callback: AsyncCallback<void>): void Sets the screen brightness for this window. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ---------- | ------------------------- | ---- | ------------------------------------ | - | brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | ------------------------------------ | +| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1757,21 +1750,19 @@ setBrightness(brightness: number): Promise<void> Sets the screen brightness for this window. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ---------- | ------ | ---- | ------------------------------------ | - | brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------------------------ | +| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1785,84 +1776,20 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a }); ``` -### setDimBehind7+ - -setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void - -Sets the dimness of the window that is not on top. This API uses an asynchronous callback to return the result. - -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - -**System capability**: SystemCapability.WindowManager.WindowManager.Core - -**Parameters** - - | Name | Type | Mandatory| Description | - | -------------- | ------------------------- | ---- | -------------------------------------------------- | - | dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | - -**Example** - - ```js - 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> - -Sets the dimness of the window that is not on top. This API uses a promise to return the result. - -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - -**System capability**: SystemCapability.WindowManager.WindowManager.Core - -**Parameters** - - | Name | Type | Mandatory| Description | - | -------------- | ------ | ---- | -------------------------------------------------- | - | dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.| - -**Return value** - - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| - -**Example** - - ```js - 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 Sets whether this window can gain focus. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ----------- | ------------------------- | ---- | ---------------------------- | - | isFocusable | boolean | Yes | Whether the window can gain focus.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------- | ---- | ---------------------------- | +| isFocusable | boolean | Yes | Whether the window can gain focus.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1883,21 +1810,19 @@ setFocusable(isFocusable: boolean): Promise<void> Sets whether this window can gain focus. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ----------- | ------- | ---- | ---------------------------- | - | isFocusable | boolean | Yes | Whether the window can gain focus.| +| Name | Type | Mandatory| Description | +| ----------- | ------- | ---- | ---------------------------- | +| isFocusable | boolean | Yes | Whether the window can gain focus.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1917,16 +1842,14 @@ setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): v Sets whether to keep the screen always on. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------------- | ------------------------- | ---- | ------------------------ | - | isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------------- | ------------------------- | ---- | ------------------------ | +| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1947,21 +1870,19 @@ setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> Sets whether to keep the screen always on. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------------- | ------- | ---- | ------------------------ | - | isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| +| Name | Type | Mandatory| Description | +| -------------- | ------- | ---- | ------------------------ | +| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1975,84 +1896,20 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a }); ``` -### setOutsideTouchable7+ - -setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void - -Sets whether the area outside the subwindow is touchable. This API uses an asynchronous callback to return the result. - -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - -**System capability**: SystemCapability.WindowManager.WindowManager.Core - -**Parameters** - - | Name | Type | Mandatory| Description | - | --------- | ------------------------- | ---- | ---------------- | - | touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value **true** means that such an area is touchable, and **false** means the opposite.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | - -**Example** - - ```js - 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> - -Sets whether the area outside the subwindow is touchable. This API uses a promise to return the result. - -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - -**System capability**: SystemCapability.WindowManager.WindowManager.Core - -**Parameters** - - | Name | Type | Mandatory| Description | - | --------- | ------- | ---- | ---------------- | - | touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value **true** means that such an area is touchable, and **false** means the opposite.| - -**Return value** - - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| - -**Example** - - ```js - 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 Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ------------- | ------------------------- | ---- | -------------------- | - | isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ------------- | ------------------------- | ---- | -------------------- | +| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -2074,21 +1931,19 @@ setPrivacyMode(isPrivacyMode: boolean): Promise<void> Sets whether this window is in privacy mode. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ------------- | ------- | ---- | -------------------- | - | isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| +| Name | Type | Mandatory| Description | +| ------------- | ------- | ---- | -------------------- | +| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -2108,16 +1963,14 @@ setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void Sets whether this window is touchable. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ----------- | ------------------------- | ---- | -------------------- | - | isTouchable | boolean | Yes | Whether the window is touchable.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------- | ---- | -------------------- | +| isTouchable | boolean | Yes | Whether the window is touchable.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -2139,21 +1992,19 @@ setTouchable(isTouchable: boolean): Promise<void> Sets whether this window is touchable. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ----------- | ------- | ---- | -------------------- | - | isTouchable | boolean | Yes | Whether the window is touchable.| +| Name | Type | Mandatory| Description | +| ----------- | ------- | ---- | -------------------- | +| isTouchable | boolean | Yes | Whether the window is touchable.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -2194,9 +2045,9 @@ Obtains the main window of this window stage. This API uses a promise to return **Return value** - | Type | Description | - | -------------------------------- | ---------------------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the main window.| +| Type | Description | +| -------------------------------- | ---------------------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the main window.| **Example** @@ -2226,9 +2077,9 @@ Obtains the main window of this window stage. This API uses an asynchronous call **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | --------------------------------------- | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the main window.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | --------------------------------------- | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the main window.| **Example** @@ -2259,15 +2110,15 @@ Creates a subwindow for this window stage. This API uses a promise to return the **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | -------------- | - | name | String | Yes | Name of the subwindow.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------- | +| name | String | Yes | Name of the subwindow.| **Return value** - | Type | Description | - | -------------------------------- | ------------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the subwindow created.| +| Type | Description | +| -------------------------------- | ------------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the subwindow created.| **Example** @@ -2297,10 +2148,10 @@ Creates a subwindow for this window stage. This API uses an asynchronous callbac **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | ------------------------------ | - | name | String | Yes | Name of the subwindow. | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------ | +| name | String | Yes | Name of the subwindow. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| **Example** @@ -2332,9 +2183,9 @@ Obtains all the subwindows of this window stage. This API uses a promise to retu **Return value** - | Type | Description | - | --------------------------------------------- | ------------------------------------------------------------ | - | Promise<Array<[Window](#window)>> | Promise used to return all the subwindows.| +| Type | Description | +| --------------------------------------------- | ------------------------------------------------------------ | +| Promise<Array<[Window](#window)>> | Promise used to return all the subwindows.| **Example** @@ -2364,9 +2215,9 @@ Obtains all the subwindows of this window stage. This API uses an asynchronous c **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------------------- | ---- | ------------------------------------------- | - | callback | AsyncCallback<Array<[Window](#window)>> | Yes | Callback used to return all the subwindows.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------- | +| callback | AsyncCallback<Array<[Window](#window)>> | Yes | Callback used to return all the subwindows.| **Example** @@ -2393,14 +2244,14 @@ loadContent(path: string, callback: AsyncCallback<void>): void Loads content to this window stage. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.WindowManager.WindowManager.Coretype with the value 'windowSizeChange' +**System capability**: SystemCapability.WindowManager.WindowManager.Coretype with the value **windowSizeChange** **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | -------------------- | - | path | string | Yes | Path of the page from which the content will be loaded.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------- | +| path | string | Yes | Path of the page from which the content will be loaded.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -2429,10 +2280,10 @@ Enables listening for window stage lifecycle changes. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| - | callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| +| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | Yes | Callback used to return the information. | **Example** @@ -2458,10 +2309,10 @@ Disables listening for window stage lifecycle changes. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| - | callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | No | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| +| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | No | Callback used to return the information. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-xml.md b/en/application-dev/reference/apis/js-apis-xml.md index 124d845c0e1101346a0783b9e56cd74b089b2424..c014e5dbbef4cd972a9af5bb77efd71c3c363ae3 100644 --- a/en/application-dev/reference/apis/js-apis-xml.md +++ b/en/application-dev/reference/apis/js-apis-xml.md @@ -1,6 +1,6 @@ # XML Parsing and Generation -> ![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. @@ -10,10 +10,6 @@ import xml from '@ohos.xml'; ``` -## System Capabilities - -SystemCapability.Utils.Lang - ## XmlSerializer @@ -23,6 +19,8 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) A constructor used to create an **XmlSerializer** instance. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -45,6 +43,8 @@ setAttributes(name: string, value: string): void Sets an attribute. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -66,6 +66,8 @@ addEmptyElement(name: string): void Adds an empty element. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -86,6 +88,8 @@ setDeclaration(): void Sets a declaration. +**System capability**: SystemCapability.Utils.Lang + **Example** ```js @@ -100,6 +104,8 @@ startElement(name: string): void Writes the start tag based on the given element name. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -122,6 +128,8 @@ endElement(): void Writes the end tag of the element. +**System capability**: SystemCapability.Utils.Lang + **Example** ```js @@ -140,6 +148,8 @@ setNamespace(prefix: string, namespace: string): void Sets the namespace for an element tag. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -164,6 +174,8 @@ setComment(text: string): void Sets the comment. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -187,6 +199,8 @@ setCDATA(text: string): void Sets CDATA attributes. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -208,6 +222,8 @@ setText(text: string): void Sets **Text**. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -232,6 +248,8 @@ setDocType(text: string): void Sets **DocType**. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -256,6 +274,8 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) Creates and returns an **XmlPullParser** object. The **XmlPullParser** object passes two parameters. The first parameter is the memory of the **ArrayBuffer** or **DataView** type, and the second parameter is the file format (UTF-8 by default). +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -289,6 +309,8 @@ parse(option: ParseOptions): void Parses XML information. +**System capability**: SystemCapability.Utils.Lang + **Parameters** | Name| Type| Mandatory| Description| @@ -329,6 +351,8 @@ that.parse(options); Defines the XML parsing options. +**System capability**: SystemCapability.Utils.Lang + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -349,6 +373,8 @@ getColumnNumber(): number Obtains the column line number, which starts from 1. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -362,6 +388,8 @@ getDepth(): number Obtains the depth of this element. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -375,6 +403,8 @@ getLineNumber(): number Obtains the current line number, starting from 1. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -388,6 +418,8 @@ getName(): string Obtains the name of this element. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -401,6 +433,8 @@ getNamespace(): string Obtains the namespace of this element. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -414,6 +448,8 @@ getPrefix(): string Obtains the prefix of this element. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -427,6 +463,8 @@ getText(): string Obtains the text of the current event. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -440,6 +478,8 @@ isEmptyElementTag(): boolean Checks whether the current element is empty. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -453,6 +493,8 @@ isWhitespace(): boolean Checks whether the current text event contains only whitespace characters. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| @@ -466,6 +508,8 @@ getAttributeCount(): number Obtains the number of attributes for the current start tag. +**System capability**: SystemCapability.Utils.Lang + **Return value** | Type| Description| | -------- | -------- | @@ -476,6 +520,8 @@ Obtains the number of attributes for the current start tag. Enumerates the events. +**System capability**: SystemCapability.Utils.Lang + | Name| Value| Description| | -------- | -------- | -------- | | START_DOCUMENT | 0 | Indicates a start document event.| diff --git a/en/application-dev/reference/arkui-js/Readme-EN.md b/en/application-dev/reference/arkui-js/Readme-EN.md index f0b0e7b6c9d76f3380dd78f21c92108c969f9e77..fd00b650bc95c252d91fc55c323af6882030d93c 100644 --- a/en/application-dev/reference/arkui-js/Readme-EN.md +++ b/en/application-dev/reference/arkui-js/Readme-EN.md @@ -106,5 +106,5 @@ - [Event Parameter](js-components-custom-event-parameter.md) - [slot](js-components-custom-slot.md) - [Lifecycle Definition](js-components-custom-lifecycle.md) -- [Type Attributes](js-appendix-types.md) - +- Appendix + - [Type Attributes](js-appendix-types.md) diff --git a/en/application-dev/reference/arkui-js/js-components-common-events.md b/en/application-dev/reference/arkui-js/js-components-common-events.md index f52edb34df93742d37039bf7f0c4babbbb47508f..cd470f8eda16f21d44ed970a3d55a7f6e20fa484 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-events.md +++ b/en/application-dev/reference/arkui-js/js-components-common-events.md @@ -1,468 +1,113 @@ -# Universal Events +# Universal Events -## Event Description +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> Universal events are supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + +## Event Description + +- Events are bound to components. When a component meets the event triggering condition, the corresponding event callback in the JS is executed to implement the interaction between the UI and the JS logic layer of the page. + +- The event callback can carry additional information through parameters, such as the dataset on the component and event-specific callback parameters. -- Events are bound to components. When a component meets the event triggering condition, the corresponding event callback in the JS is executed to implement the interaction between the UI and the JS logic layer of the page. -- The event callback can carry additional information through parameters, such as the dataset on the component and event-specific callback parameters. Different from private events, universal events can be bound to most components. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter

-

Description

-

Support Bubbling

-

touchstart

-

TouchEvent

-

Triggered when the tapping starts.

-

Yes5+

-

touchmove

-

TouchEvent

-

Triggered when the tapping moves.

-

Yes5+

-

touchcancel

-

TouchEvent

-

Triggered when the tapping is interrupted.

-

Yes5+

-

touchend

-

TouchEvent

-

Triggered when the tapping ends.

-

Yes5+

-

click

-

-

-

Triggered when a component is clicked.

-

Yes6+

-

doubleclick7+

-
  

Triggered when a component is double-clicked.

-

No

-

longpress

-

-

-

Triggered when a component is long pressed.

-

No

-

swipe5+

-

SwipeEvent

-

Triggered when a user quickly swipes on a component.

-

No

-

attached6+

-

-

-

Triggered after the current component node is mounted to the render tree.

-

No

-

detached6+

-

-

-

Triggered when the current component node is removed from the render tree.

-

No

-

pinchstart7+

-

PinchEvent

-

Triggered when a pinch operation is started.

-

No

-

pinchupdate7+

-

PinchEvent

-

Triggered when a pinch operation is in progress.

-

No

-

pinchend7+

-

PinchEvent

-

Triggered when a pinch operation is ended.

-

No

-

pinchcancel7+

-

PinchEvent

-

Triggered when the pinch operation is interrupted.

-

No

-

dragstart7+

-

DragEvent

-

Triggered when dragging starts.

-

No

-

drag7+

-

DragEvent

-

Triggered when dragging is in progress.

-

No

-

dragend7+

-

DragEvent

-

Triggered when dragging is ended.

-

No

-

dragenter7+

-

DragEvent

-

Triggered when the dragged component enters a drop target.

-

No

-

dragover7+

-

DragEvent

-

Triggered when the dragged component is being dragged over a drop target.

-

No

-

dragleave7+

-

DragEvent

-

Triggered when the dragged component leaves a drop target.

-

No

-

drop7+

-

DragEvent

-

Triggered when a component is dropped on a drop target.

-

No

-
- ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->Events not listed in the preceding table are non-bubbling events, such as the [change event](js-components-basic-input.md#section1721512551218). For details, see the specific component. - -**Table 1** Attributes of the BaseEvent object - - - - - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

type

-

string

-

Event type, such as click and longpress

-

timestamp

-

number

-

Timestamp when the event is triggered

-
- -**Table 2** Attributes of the TouchEvent object \(inherited from BaseEvent\) - - - - - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

touches

-

Array<TouchInfo>

-

Attribute set of the touch event, including the information array of the touch points on the screen.

-

changedTouches

-

Array<TouchInfo>

-

Attribute set when a touch event occurs, including the information array of changed touch points on the screen. changedTouches has the same data format as touches and indicates touch point changes, such as from no touch point to newly generated touch points, from some touch points to no touch point, and location changes. For example, when the user's finger leaves the touchscreen, no data exists in the touches array, but changedTouches will save the generated data.

-
- -**Table 3** TouchInfo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

globalX

-

number

-

Horizontal distance from the upper left corner of the screen (excluding the status bar). The upper left corner of the screen acts as the coordinate origin.

-

globalY

-

number

-

Vertical distance from the upper left corner of the screen (excluding the status bar). The upper left corner of the screen acts as the coordinate origin.

-

localX

-

number

-

Horizontal distance from the upper left corner of the touched component. The upper left corner of the component acts as the coordinate origin.

-

localY

-

number

-

Vertical distance from the upper left corner of the touched component. The upper left corner of the component acts as the coordinate origin.

-

size

-

number

-

Touch area.

-

force6+

-

number

-

Touch force.

-
- -**Table 4** Attributes of the SwipeEvent object \(inherited from BaseEvent\) - - - - - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

direction

-

string

-

Swiping direction. The value can be one of the following:

-
  1. left: Swipe from right to left
  2. right: Swipe from left to right
  3. up: Swipe upwards
  4. down: Swipe downwards
-

distance6+

-

number

-

Swiping distance in the swiping direction.

-
- -**Table 5** Attributes of the PinchEvent object7+ - - - - - - - - - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

scale

-

number

-

Scale factor.

-

pinchCenterX

-

number

-

X-coordinate of the pinch center, in px.

-

pinchCenterY

-

number

-

Y-coordinate of the pinch center, in px.

-
- -**Table 6** Attributes of the DragEvent object \(inherited from BaseEvent\)7+ - - - - - - - - - - - - - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

type

-

string

-

Event name.

-

globalX

-

number

-

Horizontal distance from the origin of the coordinates in the upper left corner of the screen.

-

globalY

-

number

-

Vertical distance from the origin of the coordinates in the upper left corner of the screen.

-

timestamp

-

number

-

Timestamp.

-
- -## Event Object + +| Name | Parameter | Name | Support Bubbling | +| ------------------------ | ---------- | ---------------------------------------- | -------------- | +| touchstart | TouchEvent | Triggered when the tapping starts.
> **Note**: For details about **TouchEvent**, see Table 2.| Yes5+| +| touchmove | TouchEvent | Triggered when the tapping moves. | Yes5+| +| touchcancel | TouchEvent | Triggered when the tapping is interrupted. | Yes5+| +| touchend | TouchEvent | Triggered when the tapping ends. | Yes5+| +| click | - | Triggered when a component is clicked. | Yes6+| +| doubleclick7+ | - | Triggered when a component is double-clicked. | No
**Note**: Bubbling is supported since API version 9.| +| longpress | - | Triggered when a component is long pressed. | No
**Note**: Bubbling is supported since API version 9.| +| swipe5+ | SwipeEvent | Triggered when a user quickly swipes on a component.
> **Note**: For details about **SwipeEvent**, see Table 6.| No
**Note**: Bubbling is supported since API version 9.| +| attached6+ | - | Triggered after the current component node is mounted to the render tree. | No | +| detached6+ | - | Triggered when the current component node is removed from the render tree. | No | +| pinchstart7+ | PinchEvent | Triggered when a pinch operation is started.
> **Note**: For details about **PinchEvent**, see Table 7.| No | +| pinchupdate7+ | PinchEvent | Triggered when a pinch operation is in progress. | No | +| pinchend7+ | PinchEvent | Triggered when a pinch operation is ended. | No | +| pinchcancel7+ | PinchEvent | Triggered when a pinch operation is interrupted. | No | +| dragstart7+ | DragEvent | Triggered when dragging starts.
> **Note**: For details about **DragEvent**, see Table 8 .| No | +| drag7+ | DragEvent | Triggered when dragging is in progress. | No | +| dragend7+ | DragEvent | Triggered when dragging is ended. | No | +| dragenter7+ | DragEvent | Triggered when the dragged component enters a drop target. | No | +| dragover7+ | DragEvent | Triggered when the dragged component is being dragged over a drop target. | No | +| dragleave7+ | DragEvent | Triggered when the dragged component leaves a drop target. | No | +| drop7+ | DragEvent | Triggered when the dragged component is dropped on a drop target. | No | + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> Events not listed in the preceding table are non-bubbling events, such as the [change event](../arkui-js/js-components-basic-input.md#events). For details, see the specific component. + +**Table 1** BaseEvent + +| Attribute | Type | Description | +| --------- | ------ | --------------------------- | +| type | string | Event type, such as **click** and **longpress**.| +| timestamp | number | Timestamp when the event is triggered. | + +**Table 2** TouchEvent (inherited from BaseEvent) + +| Attribute | Type | Description | +| -------------- | ---------------------- | ---------------------------------------- | +| touches | Array<TouchInfo> | Attribute set of the touch event, including the information array of the touch points on the screen. | +| changedTouches | Array<TouchInfo> | Attribute set when a touch event occurs, including the information array of changed touch points on the screen. **changedTouches** has the same data format as **touches** and indicates touch point changes, such as from no touch point to newly generated touch points, from some touch points to no touch point, and location changes. For example, when the user's finger leaves the touchscreen, no data exists in the **touches** array, but **changedTouches** will save the generated data.| + +**Table 3** TouchInfo + +| Attribute | Type | Description | +| ------------------ | ------ | ------------------------------ | +| globalX | number | Horizontal distance from the upper left corner of the screen (excluding the status bar), which acts as the origin of coordinates.| +| globalY | number | Vertical distance from the upper left corner of the screen (excluding the status bar), which acts as the origin of coordinates.| +| localX | number | Horizontal distance from the upper left corner of the touched component, which acts as the origin of coordinates. | +| localY | number | Vertical distance from the upper left corner of the touched component, which acts as the origin of coordinates. | +| size | number | Touch area. | +| force6+ | number | Touch force. | + +**Table 4** SwipeEvent (inherited from BaseEvent) + +| Attribute | Type | Description | +| --------------------- | ------ | ---------------------------------------- | +| direction | string | Swiping direction. The value can be one of the following:
1. **left**: Swipe from right to left.
2. **right**: Swipe from left to right.
3. **up**: Swipe upwards.
4. **down**: Swipe downwards.| +| distance6+ | number | Swiping distance in the swiping direction. | + +**Table 5** PinchEvent7+ + +| Attribute | Type | Description | +| ------------ | ------ | -------------- | +| scale | number | Scale factor. | +| pinchCenterX | number | X-coordinate of the pinch center, in px.| +| pinchCenterY | number | Y-coordinate of the pinch center, in px.| + +**Table 6** DragEvent7+ (inherited from BaseEvent) + +| Attribute | Type | Description | +| --------- | ------ | ---------------- | +| type | string | Event name. | +| globalX | number | Horizontal distance from the upper left corner of the screen, which acts as the origin of coordinates.| +| globalY | number | Vertical distance from the upper left corner of the screen, which acts as the origin of coordinates.| +| timestamp | number | Timestamp. | + +## Event Object When a component triggers an event, the event callback receives an event object by default. You can obtain the corresponding information through the event object. -**target object:** - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

dataSet6+

-

Object

-

Custom attribute set defined through data-*.

-
- -**Example:** +**target object** + +| Attribute | Type | Description | +| -------------------- | ------ | ---------------------------------------- | +| dataSet6+ | Object | Custom attribute set defined through [data-*](../arkui-js/js-components-common-attributes.md).| + +**Example** ``` - -
+ +
-
+ ``` ``` @@ -474,4 +119,3 @@ export default { } } ``` - diff --git a/en/application-dev/reference/arkui-js/js-framework-multiple-languages.md b/en/application-dev/reference/arkui-js/js-framework-multiple-languages.md deleted file mode 100644 index 30b72ecc2952f75283be2f275dd59af37ee9eb09..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-js/js-framework-multiple-languages.md +++ /dev/null @@ -1,196 +0,0 @@ -# Multi-Language Capability - - -Applications designed based on the JS UI framework apply to different countries and regions. With the multi-language capability, you do not need to develop application versions in different languages, and your users can switch between various locales. This also facilitates project maintenance. - - -You only need to perform operations in [Resource Files](#resource-files) and [Resource Reference](#resource-reference) to use the multi-language capability of this framework. For details about how to obtain the current system language, see [Language Acquisition](#language-acquisition). - - -## Resource Files - -Resource files store application content in multiple languages. This framework uses JSON files to store resource definitions. Place the resource file of each locale in the i18n directory described in [File Organization](js-framework-file.md). - -Resource files should be named in _language-script-region_.json format. For example, the resource file for Hong Kong Chinese in the traditional script is named zh-Hant-HK. You can omit the region, for example, zh-CN for simplified Chinese, or omit both the script and region, for example, zh for Chinese. - - -``` -language[-script-region].json -``` - -The following table describes the requirements for the qualifiers of resource file names. - -Table 1 Requirements for qualifier values - -| Qualifier Type | Description and Value Range | -| -------- | -------- | -| Language | Indicates the language used by the device. The value consists of two or three lowercase letters, for example, zh indicates Chinese, en indicates English, and mai indicates Maithili.
For details about the value range, refer to ISO 639 (codes for the representation of names of languages). | -| Script | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters, for example, Hans indicates simplified Chinese and Hant indicates traditional Chinese.
For details about the value range, refer to ISO 15924 (codes for the representation of names of scripts). | -| Country/Region | Indicates the country or region where a user is located. The value consists of two or three uppercase letters or three digits, for example, CN indicates China and GB indicates the United Kingdom.
For details about the value range, refer to ISO 3166-1 (codes for the representation of names of countries and their subdivisions). | - -If there is no resource file of the locale that matches the system language, content in the en-US.json file will be used by default. - -The format of the resource file content is as follows: - -**en-US.json** - -``` -{ - "strings": { - "hello": "Hello world!", - "object": "Object parameter substitution-{name}", - "array": "Array type parameter substitution-{0}", - "symbol": "@#$%^&*()_+-={}[]\\|:;\"'<>,./?" - }, - - "files": { - "image": "image/en_picture.PNG" - } -} -``` - - -Different languages have different matching rules for singular and plural forms. In the resource file, zero, one, two, few, many, and other are used to define the string content in different singular and plural forms. For example, there is only the other scenario in Chinese since the language does not have singular and plural forms. one and other scenarios are applicable to English. All six scenarios are needed for Arabic. - - -The following example takes en-US.json and ar-AE.json as examples: - -**en-US.json** - - -``` -{ - "strings": { - "people": { - "one": "one person", - "other": "{count} people" - } - } -} -``` - - -ar-AE.json - - -``` -{ - "strings": { - "people": { - "zero": "لا أحد", - "one": "وحده", - "two": "اثنان", - "few": "ستة اشخاص", - "many": "خمسون شخص", - "other": "مائة شخص" - } - } -} -``` - - -## Resource Reference - -Multi-language syntax used on application development pages (including simple formatting and singular-plural formatting) can be used in .hml or .js files. - -- Simple formatting - - Use the `$t` function to reference to resources of different locales. The `$t` function is available for both .hml and .js files. The system displays content based on a resource file path specified via $t and the specified resource file whose locale matches the current system language. - - Table 2 Simple formatting - - | Attribute | Type | Parameter | Mandatory | Description | - | -------- | -------- | -------- | -------- | -------- | - | $t | Function | See Table3 | Yes | Sets the parameters based on the system language, for example, this.$t('strings.hello'). | - - -Table 3 $t function parameters - -| Parameter | Type | Mandatory | Description | -| -------- | -------- | -------- | -------- | -| path | string | Yes | Path of the language resource key | -| params | Array\|Object | No | Content used to replace placeholders during runtime. There are two types of placeholders available:
- Named placeholder, for example, {name}. The actual content must be of the object type, for example, \```$t('strings.object', {name:'Hello world'})```.
- Digit placeholder, for example, {0}. The actual content must be of the array type, for example, \```$t('strings.array', [Hello world']```. | - -- Example code for simple formatting - - ``` - -
- - {{ $t('strings.hello') }} - - {{ $t('strings.object', { name: 'Hello world' }) }} - - {{ $t('strings.array', ['Hello world']) }} - - {{ hello }} - - {{ replaceObject }} - - {{ replaceArray }} - - - - - -
- ``` - - - ``` - // xxx.js - // The following example uses the $t function in the .js file. - export default { - data: { - hello: '', - replaceObject: '', - replaceArray: '', - replaceSrc: '', - }, - onInit() { - this.hello = this.$t('strings.hello'); - this.replaceObject = this.$t('strings.object', { name: 'Hello world' }); - this.replaceArray = this.$t('strings.array', ['Hello world']); - this.replaceSrc = this.$t('files.image'); - }, - } - ``` - -- Singular-plural formatting - Table 4 Singular-plural formatting - - | Attribute | Type | Parameter | Mandatory | Description | - | -------- | -------- | -------- | -------- | -------- | - | $tc | Function | See Table 5. | Yes | Converts between the singular and plural forms based on the system language, for example, this.$tc('strings.people').
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The resource content is distinguished by the following JSON keys: zero, one, two, few, many, and other. | - - Table 5 $tc function parameters - - | Parameter | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | path | string | Yes | Path of the language resource key | - | count | number | Yes | Number | - -- Sample code for singular-plural formatting - - ``` - -
- - {{ $tc('strings.people', 0) }} - - {{ $tc('strings.people', 1) }} - - {{ $tc('strings.people', 2) }} - - {{ $tc('strings.people', 6) }} - - {{ $tc('strings.people', 50) }} - - {{ $tc('strings.people', 100) }} -
- ``` - - -## Language Acquisition - -For details about how to obtain the language, see the Application Configuration section. diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index f686f9a01011f7afb704d3f10d5fadc7bd521ee3..18351055d42a9f1a42085dbe5afcfd4b2ba70b83 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -1,8 +1,8 @@ # TextArea -> ![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. +> ![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 **<TextArea>** component provides multi-line text input. @@ -90,7 +90,7 @@ Sets the position of the caret. ``` @Entry @Component -struct TextAreaExample2 { +struct TextAreaExample1 { @State text: string = '' build() { Column() { @@ -126,7 +126,7 @@ struct TextAreaExample2 { ``` @Entry @Component -struct TextAreaTest { +struct TextAreaExample2 { controller: TextAreaController = new TextAreaController() build() { Column() { diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index 591d688e88b6869b429efd51f6a5348f9156e68d..a10e217459ce850706675e0a7a9f1e3dcb48f415 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -1,7 +1,6 @@ # TextInput - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> ![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. @@ -61,13 +60,21 @@ In addition to universal attributes, the following attributes are supported. | InputType.Number | Digit input mode. | -### TextInputController8+ - -Implements the controller of the **<TextInput>** component. +## Events | Name | Description | | -------- | -------- | -| caretPosition(value: number):void | Position of the input cursor.
**value**: indicates the length from the start of the string to the position where the input cursor is located. | +| onChange(value: string) => void | Triggered when the input changes. | +| onSubmit(callback: (enterKey: EnterKeyType) => void) | Triggered when the Enter key on the physical or soft keyboard is pressed. | +| onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | Triggered when the input status changes. | +| onEditChange(callback: (isEditing: boolean) => void) 8+ | Triggered when the input status changes. | +| onCopy8+(callback:(value: string) => void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be copied. | +| onCut8+(callback:(value: string) => void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be cut. | +| onPaste8+(callback:(value: string) => void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be pasted. | + +### TextInputController8+ + +Implements the controller of the **<TextInput>** component. ### Objects to Import @@ -78,7 +85,7 @@ controller: TextInputController = new TextInputController() ``` -### controller.createPosition +#### caretPosition caretPosition(value: number): void @@ -90,18 +97,6 @@ Sets the cursor in a specified position. | value | number | Yes | - | Position of the input cursor.
**value**: indicates the length from the start of the string to the position where the input cursor is located. | -## Events - -| Name | Description | -| -------- | -------- | -| onChange(value: string) => void | Triggered when the input changes. | -| onSubmit(callback: (enterKey: EnterKeyType) => void) | Triggered when the Enter key on the physical or soft keyboard is pressed. | -| onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | Triggered when the input status changes. | -| onEditChange(callback: (isEditing: boolean) => void) 8+ | Triggered when the input status changes. | -| onCopy8+(callback:(value: string) => void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be copied. | -| onCut8+(callback:(value: string) => void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be cut. | -| onPaste8+(callback:(value: string) => void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be pasted. | - ## Example @@ -112,7 +107,7 @@ Sets the cursor in a specified position. ``` @Entry @Component -struct TextAreaExample2 { +struct TextInputExample1 { @State text: string = '' build() { @@ -147,7 +142,7 @@ struct TextAreaExample2 { ``` @Entry @Component -struct TextInputTest { +struct TextInputExample2 { @State text: string = '' controller: TextInputController = new TextInputController() build() { diff --git a/en/application-dev/reference/arkui-ts/ts-container-flex.md b/en/application-dev/reference/arkui-ts/ts-container-flex.md index 8e47369ccfe0454e165416dc69b84206d3bb8465..f3c451f768755ab02dffca81937df95b063ddc42 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-flex.md +++ b/en/application-dev/reference/arkui-ts/ts-container-flex.md @@ -1,11 +1,11 @@ # Flex -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> ![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 **<Flex>** component allows for an elastic layout. +The **\** component allows for an elastic layout. ## Required Permissions @@ -22,46 +22,45 @@ This component can contain child components. Flex(options?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign }) -Creates a standard **<Flex>** component. +Creates a standard **\** component. - Parameters - | Name | Type | Mandatory | Default Value | Description | + | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | direction | FlexDirection | No | FlexDirection.Row | Direction in which child components are arranged in the **<Flex>** component, that is, the direction of the main axis. | - | wrap | FlexWrap | No | FlexWrap.NoWrap | Whether the **<Flex>** component has a single line or multiple lines. | - | justifyContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in the **<Flex>** component along the main axis. | - | alignItems | [ItemAlign](ts-appendix-enums.md#itemalign-enums) | No | ItemAlign.Stretch | Alignment mode of the child components in the **<Flex>** component along the cross axis. | - | alignContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **<Flex>** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**. | + | direction | FlexDirection | No | FlexDirection.Row | Direction in which child components are arranged in the **\** component, that is, the direction of the main axis. | + | wrap | FlexWrap | No | FlexWrap.NoWrap | Whether the **\** component has a single line or multiple lines. | + | justifyContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in the **\** component along the main axis. | + | alignItems | [ItemAlign](ts-appendix-enums.md#itemalign-enums) | No | ItemAlign.Stretch | Alignment mode of the child components in the **\** component along the cross axis. | + | alignContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **\** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**. | - FlexDirection enums - | Name | Description | + | Name | Description | | -------- | -------- | - | Row | The child components are arranged in the same direction as the main axis runs along the rows. | - | RowReverse | The child components are arranged opposite to the **Row** direction. | - | Column | The child components are arranged in the same direction as the main axis runs down the columns. | - | ColumnReverse | The child components are arranged opposite to the **Column** direction. | + | Row | The child components are arranged in the same direction as the main axis runs along the rows. | + | RowReverse | The child components are arranged opposite to the **Row** direction. | + | Column | The child components are arranged in the same direction as the main axis runs down the columns. | + | ColumnReverse | The child components are arranged opposite to the **Column** direction. | - FlexWrap enums - | Name | Description | + | Name | Description | | -------- | -------- | - | NoWrap | The child components in the **<Flex>** component are arranged in a single line, and they may overflow. | - | Wrap | The child components in the **<Flex>** component are arranged in multiple lines, and they may overflow. | - | WrapReverse | The child components in the **<Flex>** component are reversely arranged in multiple lines, and they may overflow. | + | NoWrap | The child components in the **<Flex>** component are arranged in a single line, and they may overflow. | + | Wrap | The child components in the **<Flex>** component are arranged in multiple lines, and they may overflow. | + | WrapReverse | The child components in the **<Flex>** component are reversely arranged in multiple lines, and they may overflow. | - FlexAlign enums - | Name | Description | + | Name | Description | | -------- | -------- | - | Start | The child components are aligned with the start edge of the main axis. The first component is aligned with the main-start, and subsequent components are aligned with the previous one. | - | Center | The child components are aligned in the center of the main axis. The space between the first component and the main-start is the same as that between the last component and the main-end. | - | End | The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one. | - | SpaceBetween | The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same. | - | SpaceAround | The child components are evenly distributed along the main axis, with a half-size space on either end. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components. | - | SpaceEvenly | The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same. | + | Start | The child components are aligned with the start edge of the main axis. The first component is aligned with the main-start, and subsequent components are aligned with the previous one. | + | Center | The child components are aligned in the center of the main axis. The space between the first component and the main-start is the same as that between the last component and the main-end. | + | End | The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one. | + | SpaceBetween | The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same. | + | SpaceAround | The child components are evenly distributed along the main axis, with a half-size space on either end. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components. | + | SpaceEvenly | The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same. | ## Example - ``` // Example 01 @Entry diff --git a/en/application-dev/reference/native-lib/Readme-EN.md b/en/application-dev/reference/native-lib/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..5f61d33c8bb134f9473c03ac79e0aec5db3248d7 --- /dev/null +++ b/en/application-dev/reference/native-lib/Readme-EN.md @@ -0,0 +1,6 @@ +# Standard Libraries Supported by Native APIs + +- [Standard Libraries](third_party_libc/musl.md) +- [Native API Symbols Not Exported](third_party_libc/musl-peculiar-symbol.md) +- [Node_API](third_party_napi/napi.md) +- [libuv](third_party_libuv/libuv.md) \ No newline at end of file diff --git a/en/application-dev/security/huks-guidelines.md b/en/application-dev/security/huks-guidelines.md index 9d1d0fde76338b73eeb1bce98e704faf398a0dd0..4b89db682161071a11136e4510fac134159e8b66 100644 --- a/en/application-dev/security/huks-guidelines.md +++ b/en/application-dev/security/huks-guidelines.md @@ -2,19 +2,19 @@ ## When to Use - Openharmony Universal KeyStore (HUKS) provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations. HUKS also provides APIs for applications to import or generate keys. + OpenHarmony Universal KeyStore (HUKS) provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations. HUKS also provides APIs for applications to import or generate keys. ## Available APIs | API | Description | | ------------------------------------------------------------ | ---------------- | -| function generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Generates a private key. This method uses an asynchronous callback to return the result. | -| function generateKey(keyAlias: string, options: HuksOptions) : Promise; | Generates a private key. This method uses a promise to return the result. | +| function generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Generates a key. This method uses an asynchronous callback to return the result. | +| function generateKey(keyAlias: string, options: HuksOptions) : Promise; | Generates a key. This method uses a promise to return the result. | | function exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Exports the public key. This method uses an asynchronous callback to return the result. | | function exportKey(keyAlias: string, options: HuksOptions) : Promise; | Exports the public key. This method uses a promise to return the result. | -| function isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Check whether a key exists. This method uses an asynchronous callback to return the result.| -| function isKeyExist(keyAlias: string, options: HuksOptions) : Promise; | Check whether a key exists. This method uses a promise to return the result.| +| function isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Checks whether a key exists. This method uses an asynchronous callback to return the result. | +| function isKeyExist(keyAlias: string, options: HuksOptions) : Promise; | Checks whether a key exists. This method uses a promise to return the result. | | function deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Deletes a key. This method uses an asynchronous callback to return the result. | | function deleteKey(keyAlias: string, options: HuksOptions) : Promise; | Deletes a key. This method uses a promise to return the result. | @@ -26,7 +26,7 @@ import huks from '@ohos.security.huks' ``` -2. Call **generateKey()** to generate a private key. +2. Call **generateKey()** to generate a key. **keyAlias** indicates the alias of the key generated. **options** indicates the parameters used for generating the key. Set **options** based on the actual situation. @@ -59,7 +59,7 @@ 3. Call **Init()** to initialize the key. - **Alias** indicates the alias of the key to initialize, and **options** indicates the parameters used for initializing the key. + **Alias** indicates the alias of the key to initialize, and **options** indicates the parameters used for initializing the key. Set **options** based on the actual situation. The value returned indicates whether the **Init** operation is successful. @@ -92,7 +92,7 @@ 4. Call **update()** to update the key. - **handle** indicates the session ID for updating the key. **options** indicates the parameters used for updating the key. + **handle** indicates the session ID for updating the key. **options** indicates the parameters used for updating the key. Set **options** based on the actual situation. The value returned indicates whether the **Update** operation is successful. @@ -118,7 +118,7 @@ 5. Call **finish()** to complete the operation. - **handle** indicates the session ID of the **Finish** operation. **options** indicates the parameters used for this operation. + **handle** indicates the session ID of the **Finish** operation. **options** indicates the parameters used for this operation. Set **options** based on the actual situation. The value returned indicates whether the **Finish** operation is successful. diff --git a/en/application-dev/ui/Readme-EN.md b/en/application-dev/ui/Readme-EN.md index c30638bdfaf54722e9bab725a12f816604b7ee1e..acc4bd0613c1741db03277fffecce33195c592df 100644 --- a/en/application-dev/ui/Readme-EN.md +++ b/en/application-dev/ui/Readme-EN.md @@ -55,7 +55,7 @@ - [CanvasRenderingContext2D](ui-js-components-canvasrenderingcontext2d.md) - [Path2D](ui-js-components-path2d.md) - [OffscreenCanvas](ui-js-components-offscreencanvas.md) - - [Grid-container Development](ui-js-components-calendar.md) + - [Grid-container Development](ui-js-components-grid.md) - Svg - [Basics](ui-js-components-svg-overview.md) - [Graph Drawing](ui-js-components-svg-graphics.md) diff --git a/en/application-dev/ui/ts-component-based-builder.md b/en/application-dev/ui/ts-component-based-builder.md index 94e75620e5a4d9c1f24cb7c0325d6f852017f797..a07b244ffdc2bd9105102058e6881b14289fdf34 100644 --- a/en/application-dev/ui/ts-component-based-builder.md +++ b/en/application-dev/ui/ts-component-based-builder.md @@ -1,8 +1,7 @@ # @Builder -The @Builder decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the @Builder decorator are the same as those of the [build Function](ts-function-build.md). - +The **@Builder** decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the **@Builder** decorator are the same as those of the [build Function](ts-function-build.md). ``` @@ -42,30 +41,29 @@ struct CompA { } } ``` - -## @BuilderParam8+ - -The @BuilderParam decorator is used to modify the function type attributes (for example, @BuilderParam content: () => any) in a custom component. When the custom component is initialized, the attributes modified by the @BuilderParam decorator must be assigned values. +## @BuilderParam8+ +The **@BuilderParam** decorator is used to modify the function type attributes (for example, `@BuilderParam content: () => any;`) in a custom component. When the custom component is initialized, the attributes modified by the **@BuilderParam** decorator must be assigned values. ### Background -In certain circumstances, you may need to add a specific function, such as a click-to-jump action, to a custom component. However, embedding an event method directly inside of the component can add the function to all places where the component is initialized. This is where the @BuilderParam decorator come into the picture. When initializing a custom component, you can assign a @Builder decorated method to the @BuilderParam decorated attribute, thereby adding the specific function to the custom component. +In certain circumstances, you may need to add a specific function, such as a click-to-jump action, to a custom component. However, embedding an event method directly inside of the component will add the function to all places where the component is initialized. This is where the **@BuilderParam** decorator comes into the picture. When initializing a custom component, you can assign a **@Builder** decorated method to the **@BuilderParam** decorated attribute, thereby adding the specific function to the custom component. ### Component Initialization Through Parameters - -When initializing a custom component through parameters, assign a @Builder decorated method to the @BuilderParam decorated attribute —content, and call the value of content in the custom component. +When initializing a custom component through parameters, assign a **@Builder** decorated method to the **@BuilderParam** decorated attribute — **content**, and call the value of **content** in the custom component. If no parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `content: this.specificParam`), define the type of the attribute as a function without a return value (for example, `@BuilderParam content: () => void`). If any parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `callContent: this.specificParam1("111")`), define the type of the attribute as `any` (for example,`@BuilderParam callContent: any;`). ``` @Component struct CustomContainer { header: string = ""; - @BuilderParam content: () => any; + @BuilderParam noParam: () => void; + @BuilderParam withParam: any; footer: string = ""; build() { Column() { Text(this.header) .fontSize(50) - this.content() + this.noParam() + this.withParam() Text(this.footer) .fontSize(50) } @@ -75,7 +73,12 @@ struct CustomContainer { @Entry @Component struct CustomContainerUser { - @Builder specificParam(label: string) { + @Builder specificNoParam() { + Column() { + Text("noParam").fontSize(50) + } + } + @Builder SpecificWithParam(label: string) { Column() { Text(label).fontSize(50) } @@ -85,25 +88,23 @@ struct CustomContainerUser { Column() { CustomContainer({ header: "Header", - content: this.specificParam("111") + noParam: this.specificNoParam, + withParam: this.SpecificWithParam("WithParam"), footer: "Footer", }) } } } ``` - ### Component Initialization Through Trailing Closure +In a custom component, use the **@BuilderParam** decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (`CustomComponent(){}`). You can consider a trailing closure as a container and add content to it. For example, you can add a component (`{Column(){Text("content")}`) to a trailing closure. The syntax of the closure is the same as that of [build](../ui/ts-function-build.md). In this scenario, the custom component has one and only one **@BuilderParam** decorated attribute. -In a custom component, use the @BuilderParam decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (CustomComponent(){}). You can consider a trailing closure as a container and add content to it. For example, you can add a component ({Column(){Text("content")}) to the closure. The syntax of the closure is the same as that of [build](ts-function-build.md). In this scenario, the custom component has one and only one @BuilderParam decorated attribute. - -Example: Add a <Column> component and a click event to the closure, and call the specificParam method decorated by @Builder in the new <Column> component. After the <Column> component is clicked, the value of the component's header attribute will be changed to changeHeader. In addition, when the component is initialized, the content of the trailing closure will be assigned to the closer attribute decorated by @BuilderParam. - +Example: Add a **\** component and a click event to the closure, and call the **specificParam** method decorated by **@Builder** in the new **\** component. After the **\** component is clicked, the value of the component's `header` attribute will change to `changeHeader`. In addition, when the component is initialized, the content of the trailing closure will be assigned to the `closer` attribute decorated by **@BuilderParam**. ``` @Component struct CustomContainer { header: string = ""; - @BuilderParam closer: () => any; + @BuilderParam closer: () => void; build() { Column() { Text(this.header) diff --git a/en/application-dev/ui/ui-js-animate-transform.md b/en/application-dev/ui/ui-js-animate-transform.md index c8d5c6b233b5b263e6614fa836386441486eb870..3b6fe35a82a50468f5321d3d97eb98a55a3c87ff 100644 --- a/en/application-dev/ui/ui-js-animate-transform.md +++ b/en/application-dev/ui/ui-js-animate-transform.md @@ -8,7 +8,7 @@ Set the transform attribute for component rotation, scaling, translation, and sk Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower part of the rhombus with a rectangle to form a roof. Set the translate attribute of the rectangle to the coordinate (150px, -150px) to form a door, use the position attribute to translate the horizontal and vertical axes to the specified coordinates of the parent component (square), set the scale attribute to scale up the parent and child components together to determine the window size, and use the skewX attribute to skew the component and set the coordinate translate(200px,-830px) to form a chimney. - + ```
@@ -24,10 +24,12 @@ Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower p
``` - + ``` /* xxx.css */ .container { + width:100%; + height:100%; background-color:#F1F3F5; align-items: center; flex-direction: column; @@ -97,7 +99,7 @@ Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower p Decrease the y-coordinate over a time frame to make the ball bounce back. Gradually decrease the bounce height until it drops to 0. An animation where the ball falls is hereby created. - + ```
@@ -106,10 +108,12 @@ Decrease the y-coordinate over a time frame to make the ball bounce back. Gradua
``` - + ``` /* xxx.css */ .container { + width:100%; + height:100%; background-color:#F1F3F5; display: flex; justify-content: center; @@ -176,7 +180,7 @@ Decrease the y-coordinate over a time frame to make the ball bounce back. Gradua Set the rotation center around an element in different transform-origin positions. Of the rotate3d values, the first three values are the rotation vectors of the x-axis, y-axis, and z-axis, respectively; the fourth value is the rotation angle, which can be a negative value to indicate that the rotation is performed counterclockwise. - + ```
@@ -196,7 +200,7 @@ Set the rotation center around an element in different transform-origin position
``` - + ``` /* xxx.css */ .container { @@ -304,7 +308,7 @@ Set the rotation center around an element in different transform-origin position ![en-us_image_0000001222807776](figures/en-us_image_0000001222807776.gif) -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> transform-origin specifies the origin of an element's transformation. If only one value is set, the other value is 50%. If both values are set, the first value indicates the position on the x-axis, and the second value indicates the position on the y-axis. @@ -314,7 +318,7 @@ This example implements a ripple animation with the scale attribute. Here is the Set the scaling values for the x-axis, y-axis, and z-axis in scale3d to implement the animation. - + ```
@@ -330,7 +334,7 @@ Set the scaling values for the x-axis, y-axis, and z-axis in scale3d to implemen
``` - + ``` /* xxx.css */ .container { @@ -419,7 +423,7 @@ text{ ![en-us_image_0000001267887837](figures/en-us_image_0000001267887837.gif) -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> After the transform attributes are set, the child element changes with the parent element. Value changing of other attributes (such as height and width) of the parent element will not affect the child element. @@ -427,7 +431,7 @@ text{ The matrix attribute defines a transformation matrix with six input parameters: scaleX, skewY, skewX, scaleY, translateX, and translateY. In the following example, matrix is set to matrix(1,0,0,1,0,200) to skew and translate the component. - + ```
@@ -435,7 +439,7 @@ The matrix attribute defines a transformation matrix with six input parameters:
``` - + ``` /* xxx.css */ .container{ @@ -472,7 +476,7 @@ The matrix attribute defines a transformation matrix with six input parameters: You can set multiple transform attributes at the same time to apply different transformations to a component. The following example applies the scale, translate, and rotate attributes simultaneously. - + ```
@@ -484,7 +488,7 @@ You can set multiple transform attributes at the same time to apply different tr
``` - + ``` /* xxx.css */ .container{ @@ -577,9 +581,21 @@ You can set multiple transform attributes at the same time to apply different tr ![en-us_image_0000001223127712](figures/en-us_image_0000001223127712.gif) -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: -> 1. When multiple transform attributes are set, the later one overwrites the previous one. To apply multiple transform styles at the same time, use the shorthand notation; that is, write multiple style values in one transform, for example, transform: scale(1) rotate(0) translate(0,0). +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> - When multiple transform attributes are set, the later one overwrites the previous one. To apply multiple transform styles at the same time, use the shorthand notation; that is, write multiple style values in one transform, for example, transform: scale(1) rotate(0) translate(0,0). > -> 2. When using the shorthand notion, **NOTE** that the animation effect varies according to the sequence of the style values. +> - When using the shorthand notion, note that the animation effect varies according to the sequence of the style values. > -> 3. The style values in the transform attribute used when the animation starts and ends must be in one-to-one mapping. Only the styles that have value mappings are played. +> - The style values in the transform attribute used when the animation starts and ends must be in one-to-one mapping. Only the styles that have value mappings are played. +## Samples + +The following samples are provided to help you better understand how to develop animations with the **transform** attribute: + +- [`JsAnimation`: Animation App (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimation) +- [`JsAnimationStyle`: JS Animation and Custom Font Styles (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimationStyle) + +- [`Clock`: Clock (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/common/Clock) + +- [Animation Styles (JavaScaript)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/AnimationDemo) + +- [Common Image Operations](https://gitee.com/openharmony/codelabs/tree/master/Media/ImageJsDemo) \ No newline at end of file diff --git a/en/application-dev/ui/ui-js-building-ui-component.md b/en/application-dev/ui/ui-js-building-ui-component.md index 50b3fccf7a613a43117c879be4005c98ba822c92..752b8c4e4d527c9ffa0357fa9474aa1430bca6d9 100644 --- a/en/application-dev/ui/ui-js-building-ui-component.md +++ b/en/application-dev/ui/ui-js-building-ui-component.md @@ -11,11 +11,26 @@ You can also customize a new component through proper combination of components Components can be classified into the following types based on their functions. - | Type | Components | +| Type | Components | | -------- | -------- | -| Container | badge, dialog, div, form, list, list-item, list-item-group, panel, popup, refresh, stack, stepper, stepper-item, swiper, tabs, tab-bar, tab-content | -| Basic | button, chart, divider, image, image-animator, input, label, marquee, menu, option, picker, picker-view, piece, progress, qrcode, rating, richtext, search, select, slider, span, switch, text, textarea, toolbar, toolbar-item, toggle | -| Media | video | -| Canvas | canvas | -| Grid | grid-container, grid-row, grid-col | +| Container | badge, dialog, div, form, list, list-item, list-item-group, panel, popup, refresh, stack, stepper, stepper-item, swiper, tabs, tab-bar, tab-content | +| Basic | button, chart, divider, image, image-animator, input, label, marquee, menu, option, picker, picker-view, piece, progress, qrcode, rating, richtext, search, select, slider, span, switch, text, textarea, toolbar, toolbar-item, toggle | +| Media | video | +| Canvas | canvas | +| Grid | grid-container, grid-row, grid-col | | SVG | svg, rect, circle, ellipse, path, line, polyline, polygon, text, tspan, textPath, animate, animateMotion, animateTransform | +## Samples + +The following samples are provided to help you better understand how to develop components: + +- [`JsPanel`: Content Display Panel (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsPanel) +- [`Popup`: JavaScript Bubble (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Popup) +- [`RefreshContainer`: Refresh Container (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/RefreshContainer) +- [`JSComponments`: JavaScript Bubble (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JSComponments) +- [`JsUserRegistration`: User Registration (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsUserRegistration) +- [`ECG`: Heart Rate Detection (JavaScript, API 7)](https://gitee.com/openharmony/app_samples/tree/master/common/ECG) + +- [`Badge`: Badge (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Badge) +- [`JsVideo`: JsVideo (API 8)](https://gitee.com/openharmony/app_samples/tree/master/media/JsVideo) +- [Rating (JavaScript)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/RatingApplication) +- [Simple Video Player](https://gitee.com/openharmony/codelabs/tree/master/Media/VideoOpenHarmony) diff --git a/en/application-dev/ui/ui-js-building-ui-routes.md b/en/application-dev/ui/ui-js-building-ui-routes.md index 4fcdb531fd87488f639df54d3d8aef5a016d799c..c4fccae121e30d9c2c2aa6ea4cbf3c707421cc29 100644 --- a/en/application-dev/ui/ui-js-building-ui-routes.md +++ b/en/application-dev/ui/ui-js-building-ui-routes.md @@ -7,16 +7,16 @@ An application generally consist of more than one page. For example, in a music The page router finds the target page based on the page URI. The following describes how to implement redirection between two pages: -1. In the “Project“ window of DevEco Studio, choose entry > src > mainjsdefault. Right-click the pages folder and choose NewJS Page from the shortcut menu to create the detail page. +1. In the **Project** window of DevEco Studio, choose **entry** > **src** > **mainjsdefault**. Right-click the **pages** folder and choose **NewJS Page** from the shortcut menu to create the detail page. -2. Call router.push() to navigate users to the detail page. +2. Call **router.push()** to navigate users to the detail page. -3. Call router.back() to navigate users to the index page. +3. Call **router.back()** to navigate users to the index page. ## Building the Page Layout -The index and detail pages each contains a <text> component that specifies the current page, and a <button> component that implements the switching between two pages. Example code in .hml files is as follows: +The index and detail pages each contains a <text> component that specifies the current page, and a **\