diff --git a/BUILD.gn b/BUILD.gn index d1f6685aa44a49ba6261997fb11eeadecd1c14a5..86c156e6dc497b91374fd80916afeaf9aa17bcf6 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -30,15 +30,12 @@ ohos_copy("ets_internal_api") { ohos_copy("ets_component") { sources = [ - "api/@internal/component/ets/ability_component.d.ts", "api/@internal/component/ets/action_sheet.d.ts", "api/@internal/component/ets/alert_dialog.d.ts", "api/@internal/component/ets/alphabet_indexer.d.ts", - "api/@internal/component/ets/animator.d.ts", "api/@internal/component/ets/badge.d.ts", "api/@internal/component/ets/blank.d.ts", "api/@internal/component/ets/button.d.ts", - "api/@internal/component/ets/calendar.d.ts", "api/@internal/component/ets/canvas.d.ts", "api/@internal/component/ets/checkbox.d.ts", "api/@internal/component/ets/checkboxgroup.d.ts", @@ -57,7 +54,6 @@ ohos_copy("ets_component") { "api/@internal/component/ets/enums.d.ts", "api/@internal/component/ets/flex.d.ts", "api/@internal/component/ets/for_each.d.ts", - "api/@internal/component/ets/form_component.d.ts", "api/@internal/component/ets/gauge.d.ts", "api/@internal/component/ets/gesture.d.ts", "api/@internal/component/ets/grid.d.ts", @@ -81,7 +77,6 @@ ohos_copy("ets_component") { "api/@internal/component/ets/panel.d.ts", "api/@internal/component/ets/path.d.ts", "api/@internal/component/ets/pattern_lock.d.ts", - "api/@internal/component/ets/plugin_component.d.ts", "api/@internal/component/ets/polygon.d.ts", "api/@internal/component/ets/polyline.d.ts", "api/@internal/component/ets/progress.d.ts", @@ -91,7 +86,6 @@ ohos_copy("ets_component") { "api/@internal/component/ets/rect.d.ts", "api/@internal/component/ets/refresh.d.ts", "api/@internal/component/ets/relative_container.d.ts", - "api/@internal/component/ets/remote_window.d.ts", "api/@internal/component/ets/rich_text.d.ts", "api/@internal/component/ets/row.d.ts", "api/@internal/component/ets/row_split.d.ts", @@ -135,13 +129,6 @@ ohos_copy("common_api") { module_install_name = "" } -ohos_copy("bundle_api") { - sources = [ "api/bundle/bundleStatusCallback.d.ts" ] - outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] - module_source_dir = target_out_dir + "/$target_name" - module_install_name = "" -} - template("ohos_declaration_template") { forward_variables_from(invoker, "*") action_with_pydeps(target_name) { diff --git a/api/@internal/component/ets/ability_component.d.ts b/api/@internal/component/ets/ability_component.d.ts index 78640db90c7f89d454b391cc98b4e62d9ac6c6d0..fb139d442ab2cc08dadf1c63c926fbf39305fb36 100644 --- a/api/@internal/component/ets/ability_component.d.ts +++ b/api/@internal/component/ets/ability_component.d.ts @@ -47,6 +47,11 @@ declare class AbilityComponentAttribute extends CommonMethod void): AbilityComponentAttribute; } - +/** + * @systemapi + */ declare const AbilityComponent: AbilityComponentInterface; +/** + * @systemapi + */ declare const AbilityComponentInstance: AbilityComponentAttribute; diff --git a/api/@internal/component/ets/animator.d.ts b/api/@internal/component/ets/animator.d.ts index ff253c2ebaa90bfc339572b4c13555577ca65064..d924974ba2145d346efd9b8c9c84ba78b02daa81 100644 --- a/api/@internal/component/ets/animator.d.ts +++ b/api/@internal/component/ets/animator.d.ts @@ -187,6 +187,11 @@ declare class AnimatorAttribute extends CommonMethod { */ onFrame(event: (value: number) => void): AnimatorAttribute; } - +/** + * @systemapi + */ declare const Animator: AnimatorInterface; +/** + * @systemapi + */ declare const AnimatorInstance: AnimatorAttribute; diff --git a/api/@internal/component/ets/calendar.d.ts b/api/@internal/component/ets/calendar.d.ts index 63569d81073600b4718ce87c33e435a764bbde85..95322e1df51e82e2c72c59390216781a844b42ac 100644 --- a/api/@internal/component/ets/calendar.d.ts +++ b/api/@internal/component/ets/calendar.d.ts @@ -630,6 +630,11 @@ declare class CalendarAttribute { }) => void, ): CalendarAttribute; } - +/** + * @systemapi + */ declare const Calendar: CalendarInterface; +/** + * @systemapi + */ declare const CalendarInstance: CalendarAttribute; diff --git a/api/@internal/component/ets/common_ts_ets_api.d.ts b/api/@internal/component/ets/common_ts_ets_api.d.ts index 1416b44d7570d2f9fec34036881df542460c28e7..a6bbd6e4b6446c717059e812cc3200e953793dec 100644 --- a/api/@internal/component/ets/common_ts_ets_api.d.ts +++ b/api/@internal/component/ets/common_ts_ets_api.d.ts @@ -25,6 +25,7 @@ declare class AppStorage { static Link(propName: string): any; /** + * @systemapi * Called when a hyperlink is set. * @since 7 */ @@ -37,6 +38,7 @@ declare class AppStorage { static Prop(propName: string): any; /** + * @systemapi * Called when dynamic properties are set. * @since 7 */ diff --git a/api/@internal/component/ets/form_component.d.ts b/api/@internal/component/ets/form_component.d.ts index e94054f90fc62702d70c57a1d4e7993ddf680d4c..0b4327df8998e3a95ba957d8140afa42aa39eb0f 100644 --- a/api/@internal/component/ets/form_component.d.ts +++ b/api/@internal/component/ets/form_component.d.ts @@ -139,6 +139,11 @@ declare class FormComponentAttribute extends CommonMethod void): FormComponentAttribute; } - +/** + * @systemapi + */ declare const FormComponent: FormComponentInterface; +/** + * @systemapi + */ declare const FormComponentInstance: FormComponentAttribute; diff --git a/api/@internal/component/ets/plugin_component.d.ts b/api/@internal/component/ets/plugin_component.d.ts index 08ddae847e61272cd9d92d6692229872ed6711ef..d00d0ff974b32c0645ad21baca70f42222c597d9 100644 --- a/api/@internal/component/ets/plugin_component.d.ts +++ b/api/@internal/component/ets/plugin_component.d.ts @@ -67,6 +67,11 @@ declare class PluginComponentAttribute extends CommonMethod void): PluginComponentAttribute; } - +/** + * @systemapi + */ declare const PluginComponent: PluginComponentInterface; +/** + * @systemapi + */ declare const PluginComponentInstance: PluginComponentAttribute; diff --git a/api/@internal/component/ets/remote_window.d.ts b/api/@internal/component/ets/remote_window.d.ts index 9f6c2cbd2356055fc28e8724ae3b1836e3779bda..f18e82bf88e38b250fafb18659aa351659863baf 100644 --- a/api/@internal/component/ets/remote_window.d.ts +++ b/api/@internal/component/ets/remote_window.d.ts @@ -68,6 +68,11 @@ interface RemoteWindowInterface { * @since 9 */ declare class RemoteWindowAttribute extends CommonMethod {} - +/** + * @systemapi + */ declare const RemoteWindow: RemoteWindowInterface; +/** + * @systemapi + */ declare const RemoteWindowInstance: RemoteWindowAttribute; diff --git a/api/@ohos.account.osAccount.d.ts b/api/@ohos.account.osAccount.d.ts index 25f559d21904f303f76a84baf05d134b2aa1e30d..50d3c69374ec811f5c437a2cd681b535e89720bf 100644 --- a/api/@ohos.account.osAccount.d.ts +++ b/api/@ohos.account.osAccount.d.ts @@ -564,6 +564,7 @@ declare namespace osAccount { /** * Provides the abilities for user authentication. + * @systemapi * @name UserAuth * @since 8 * @syscap SystemCapability.Account.OsAccount @@ -667,6 +668,7 @@ declare namespace osAccount { /** * Provides the abilities for Pin code authentication. * + * @systemapi * @name PINAuth * @since 8 * @syscap SystemCapability.Account.OsAccount @@ -703,6 +705,7 @@ declare namespace osAccount { /** * Provides the abilities for managing user identity. * + * @systemapi * @name UserIdentityManager * @since 8 * @syscap SystemCapability.Account.OsAccount diff --git a/api/@ohos.application.Ability.d.ts b/api/@ohos.application.Ability.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.application.EnvironmentCallback.d.ts b/api/@ohos.application.EnvironmentCallback.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.application.abilityManager.d.ts b/api/@ohos.application.abilityManager.d.ts index 1546b095a45657e84908068ad75eec0d05927704..de6d6bb224572dec057bd917ed52d50ff3fc2ecd 100644 --- a/api/@ohos.application.abilityManager.d.ts +++ b/api/@ohos.application.abilityManager.d.ts @@ -22,6 +22,7 @@ import { ElementName } from './bundle/elementName'; /** * The class of an ability manager. * + * @systemapi * @since 8 * @syscap SystemCapability.Ability.AbilityRuntime.Core * @permission N/A diff --git a/api/@ohos.application.context.d.ts b/api/@ohos.application.context.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.batteryStatistics.d.ts b/api/@ohos.batteryStatistics.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.brightness.d.ts b/api/@ohos.brightness.d.ts index bb8b0988049e37d66b524897ad8c45d672ee5326..34c2200d1074357c4ebd317434de4fe946f868fe 100644 --- a/api/@ohos.brightness.d.ts +++ b/api/@ohos.brightness.d.ts @@ -18,6 +18,7 @@ import { AsyncCallback } from './basic'; /** * Provides interfaces to control the power of display. * + * @systemapi * @syscap SystemCapability.PowerManager.DisplayPowerManager * @since 7 */ diff --git a/api/@ohos.configPolicy.d.ts b/api/@ohos.configPolicy.d.ts index d12690c30faca84069c5fedcbef457ed789f20f1..af9c7ada162f6256c4e8ecfc93864a3dfaadc0b4 100644 --- a/api/@ohos.configPolicy.d.ts +++ b/api/@ohos.configPolicy.d.ts @@ -18,6 +18,7 @@ import {AsyncCallback} from "./basic"; /** * Provides file path related APIS. * + * @systemapi * @since 8 * @syscap SystemCapability.Customization.ConfigPolicy */ diff --git a/api/@ohos.connectedTag.d.ts b/api/@ohos.connectedTag.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.distributedHardware.deviceManager.d.ts b/api/@ohos.distributedHardware.deviceManager.d.ts index 6d84f8a597573e3142a0295e8526d69e314b2ea5..93449cd7d5129cec63725999b9390c98da34a842 100644 --- a/api/@ohos.distributedHardware.deviceManager.d.ts +++ b/api/@ohos.distributedHardware.deviceManager.d.ts @@ -302,6 +302,7 @@ declare namespace deviceManager { /** * Provides methods for managing devices. + * @systemapi */ interface DeviceManager { /** diff --git a/api/@ohos.distributedMissionManager.d.ts b/api/@ohos.distributedMissionManager.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.fileManager.d.ts b/api/@ohos.fileManager.d.ts index e9676f7e977203de6f3d2ac022a862e1b3355b9a..95a7a8ba99b1a71401eb3f403bea282192a97ced 100644 --- a/api/@ohos.fileManager.d.ts +++ b/api/@ohos.fileManager.d.ts @@ -16,7 +16,9 @@ import { AsyncCallback } from './basic' export default filemanager; - +/** + * @systemapi + */ declare namespace filemanager { export { listFile }; export { getRoot }; diff --git a/api/@ohos.intl.d.ts b/api/@ohos.intl.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.multimodalInput.inputDevice.d.ts b/api/@ohos.multimodalInput.inputDevice.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.multimodalInput.inputEvent.d.ts b/api/@ohos.multimodalInput.inputEvent.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.multimodalInput.keyEvent.d.ts b/api/@ohos.multimodalInput.keyEvent.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.multimodalInput.mouseEvent.d.ts b/api/@ohos.multimodalInput.mouseEvent.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.multimodalInput.touchEvent.d.ts b/api/@ohos.multimodalInput.touchEvent.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.nfc.cardEmulation.d.ts b/api/@ohos.nfc.cardEmulation.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.nfc.controller.d.ts b/api/@ohos.nfc.controller.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.privacyManager.d.ts b/api/@ohos.privacyManager.d.ts index d5d0c94d986f22afc65153699c2b9dc0aa97adb9..dc574f8c89cb0a270b31f0335bd34bd5c080e40b 100644 --- a/api/@ohos.privacyManager.d.ts +++ b/api/@ohos.privacyManager.d.ts @@ -16,6 +16,7 @@ import {AsyncCallback} from './basic' /** + * @systemapi * @syscap SystemCapability.Security.AccessToken */ declare namespace privacyManager { diff --git a/api/@ohos.process.d.ts b/api/@ohos.process.d.ts index 02b7e123eadc87d0134c66a73260165ee024263e..4cd2b717ef26913d5892733c4104c58cad01c11b 100644 --- a/api/@ohos.process.d.ts +++ b/api/@ohos.process.d.ts @@ -22,7 +22,9 @@ */ declare namespace process { - + /** + * @systemapi + */ export interface ChildProcess { /** * return pid is the pid of the current process diff --git a/api/@ohos.security.huks.d.ts b/api/@ohos.security.huks.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.systemTime.d.ts b/api/@ohos.systemTime.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.telephony.call.d.ts b/api/@ohos.telephony.call.d.ts index ea018eefd1f7c8cf596c419a53266c809ad5f8c9..2a48ba7418b654723231e5e6e2f6c91b4b92c33c 100644 --- a/api/@ohos.telephony.call.d.ts +++ b/api/@ohos.telephony.call.d.ts @@ -703,7 +703,7 @@ declare namespace call { CALL_NOT_ALLOW = 1029, SIM_INVALID = 1045, UNKNOWN = 1279, - }; + } } export default call; \ No newline at end of file diff --git a/api/@ohos.telephony.observer.d.ts b/api/@ohos.telephony.observer.d.ts index 5ea7c6a3250c18ec1f8c0b4340252e424a1e087c..90dfff7dbd586402a57ff473e3a8ada7a8e186be 100644 --- a/api/@ohos.telephony.observer.d.ts +++ b/api/@ohos.telephony.observer.d.ts @@ -29,6 +29,9 @@ import sim from "./@ohos.telephony.sim"; declare namespace observer { type NetworkState = radio.NetworkState; type SignalInformation = radio.SignalInformation; + /** + * @systemapi + */ type CellInformation = radio.CellInformation; type DataConnectState = data.DataConnectState; type RatType = radio.RadioTechnology; diff --git a/api/@ohos.userIAM.faceAuth.d.ts b/api/@ohos.userIAM.faceAuth.d.ts index fc6276dc025a1e17dea8a02338463bf2f1fa5ca5..0ef500a103a84344fc07a9f0c3a135cbf667da24 100644 --- a/api/@ohos.userIAM.faceAuth.d.ts +++ b/api/@ohos.userIAM.faceAuth.d.ts @@ -16,6 +16,7 @@ /** * This module provides the capability to manage face auth. * + * @systemapi * @since 9 */ declare namespace faceAuth { diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts old mode 100755 new mode 100644 diff --git a/api/@ohos.wifi.d.ts b/api/@ohos.wifi.d.ts index 21ad360b0075b96d9e2d898de7b3d453a4eb83c9..108517b9273a6e7137196f7ed65d3d3953d56207 100644 --- a/api/@ohos.wifi.d.ts +++ b/api/@ohos.wifi.d.ts @@ -1155,7 +1155,10 @@ declare namespace wifi { /** Center frequency */ centerFrequency1: number; - /** Information elements */ + /** + * Information elements + * @systemapi + */ infoElems: Array; /** Time stamp */ diff --git a/api/@system.battery.d.ts b/api/@system.battery.d.ts old mode 100755 new mode 100644 diff --git a/api/@system.brightness.d.ts b/api/@system.brightness.d.ts old mode 100755 new mode 100644 diff --git a/api/application/AbilityContext.d.ts b/api/application/AbilityContext.d.ts old mode 100755 new mode 100644 diff --git a/api/application/ApplicationContext.d.ts b/api/application/ApplicationContext.d.ts old mode 100755 new mode 100644 diff --git a/api/application/Context.d.ts b/api/application/Context.d.ts old mode 100755 new mode 100644 diff --git a/api/application/FormExtensionContext.d.ts b/api/application/FormExtensionContext.d.ts index db22ad84756c52349481e2fd5d507d34a6d8c711..5365812b7e3edc9d4c9cd50e77c9d321dc74e66f 100644 --- a/api/application/FormExtensionContext.d.ts +++ b/api/application/FormExtensionContext.d.ts @@ -22,6 +22,7 @@ import Want from '../@ohos.application.Want'; * The context of form extension. It allows access to * formExtension-specific resources. * + * @systemapi * @since 9 * @syscap SystemCapability.Ability.Form * @permission N/A diff --git a/api/application/MissionCallbacks.d.ts b/api/application/MissionCallbacks.d.ts old mode 100755 new mode 100644 diff --git a/api/application/MissionDeviceInfo.d.ts b/api/application/MissionDeviceInfo.d.ts old mode 100755 new mode 100644 diff --git a/api/application/MissionParameter.d.ts b/api/application/MissionParameter.d.ts old mode 100755 new mode 100644 diff --git a/api/application/PermissionRequestResult.d.ts b/api/application/PermissionRequestResult.d.ts old mode 100755 new mode 100644 diff --git a/api/application/ProcessRunningInformation.d.ts b/api/application/ProcessRunningInformation.d.ts old mode 100755 new mode 100644 diff --git a/api/basic.d.ts b/api/basic.d.ts old mode 100755 new mode 100644 diff --git a/api/bundle/launcherAbilityInfo.d.ts b/api/bundle/launcherAbilityInfo.d.ts index ea83266096c200057cd08cc868884e7d7cc5bf1b..f9b7cf5fa588cdee7eca0b7671f4dfc9e2c58e4d 100644 --- a/api/bundle/launcherAbilityInfo.d.ts +++ b/api/bundle/launcherAbilityInfo.d.ts @@ -13,6 +13,9 @@ * limitations under the License. */ +import { ApplicationInfo } from './applicationInfo'; +import { ElementName } from './elementName' + /** * Contains basic Ability information, which uniquely identifies an ability. * You can use this class to obtain values of the fields set in an AbilityInfo, @@ -24,10 +27,6 @@ * @permission N/A * @systemapi Hide this for inner system use */ - -import { ApplicationInfo } from './applicationInfo'; -import { ElementName } from './elementName' - export interface LauncherAbilityInfo { /** * @name Obtains application info information about an launcher ability. diff --git a/api/bundle/shortcutInfo.d.ts b/api/bundle/shortcutInfo.d.ts index 98c0a85563cd95a2dad1f72bd0a3305fe0fc7a15..1e2b61b3a842b55f5bafd6ed40cb5f510b11edb8 100644 --- a/api/bundle/shortcutInfo.d.ts +++ b/api/bundle/shortcutInfo.d.ts @@ -99,6 +99,7 @@ */ readonly disableMessage: string; /** + * @systemapi * @default Indicates the wants of the shortcut * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework diff --git a/api/common/lite/featureability.d.ts b/api/common/lite/featureability.d.ts index 014cbb7538d408c8d24df4e8bab19f4f62256651..6df6c9815fd435305c21d3631661fbe2c64f54f6 100644 --- a/api/common/lite/featureability.d.ts +++ b/api/common/lite/featureability.d.ts @@ -115,6 +115,7 @@ export interface SubscribeMessageOptions { } /** + * @systemapi * @since 5 * @deprecated since 8 */ diff --git a/api/data/rdb/resultSet.d.ts b/api/data/rdb/resultSet.d.ts old mode 100755 new mode 100644 diff --git a/api/global/resource.d.ts b/api/global/resource.d.ts old mode 100755 new mode 100644 diff --git a/api/notification/notificationFlags.ts b/api/notification/notificationFlags.ts index 9fcc00325e5b07d7ea8042a778ecd51c6d7ffe47..f1dc10011bcd4301ddcdff5015da74301cf64428 100644 --- a/api/notification/notificationFlags.ts +++ b/api/notification/notificationFlags.ts @@ -40,6 +40,7 @@ /** * Describes a NotificationFlags instance. * + * @systemapi * @name NotificationFlags * @since 8 * @permission N/A diff --git a/api/notification/notificationRequest.d.ts b/api/notification/notificationRequest.d.ts index f04f0a7a788600f4e0a6e204e7f08046a3d7a6d6..0d28871ea8e3705a43c311a651228c5d78547999 100644 --- a/api/notification/notificationRequest.d.ts +++ b/api/notification/notificationRequest.d.ts @@ -222,6 +222,7 @@ export interface NotificationRequest { /** * Obtains the set of identifiers for the notification. * + * @systemapi * @since 8 */ readonly notificationFlags?: NotificationFlags; diff --git a/api/tag/tagSession.d.ts b/api/tag/tagSession.d.ts old mode 100755 new mode 100644 diff --git a/api/webgl/webgl.d.ts b/api/webgl/webgl.d.ts old mode 100755 new mode 100644 diff --git a/api/webgl/webgl2.d.ts b/api/webgl/webgl2.d.ts old mode 100755 new mode 100644 diff --git a/build-tools/api/@internal/component/ets/action_sheet.d.ts b/build-tools/api/@internal/component/ets/action_sheet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..736d5ce6b4e49e544a1eab4a649e91f38c352d96 --- /dev/null +++ b/build-tools/api/@internal/component/ets/action_sheet.d.ts @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The information of sheet. + * @since 8 + */ +interface SheetInfo { + /** + * Title Properties + * @since 8 + */ + title: string | Resource; + /** + * Icon Properties. + * @since 8 + */ + icon?: string | Resource; + /** + * Callback method after the operation. + * @since 8 + */ + action: () => void; +} +/** + * Declare the ActionSheet + * @since 8 + */ +declare class ActionSheet { + /** + * Invoking method display. + * @since 8 + */ + static show(value: { + /** + * Title Properties + * @since 8 + */ + title: string | Resource; + /** + * message Properties + * @since 8 + */ + message: string | Resource; + /** + * Invoke the commit function. + * @since 8 + */ + confirm?: { + /** + * Text content of the confirmation button. + * @since 8 + */ + value: string | Resource; + /** + * Method executed by the callback. + * @since 8 + */ + action: () => void; + }; + /** + * Execute Cancel Function. + * @since 8 + */ + cancel?: () => void; + /** + * The Array of sheets + * @since 8 + */ + sheets: Array; + /** + * Allows users to click the mask layer to exit. + * @since 8 + */ + autoCancel?: boolean; + /** + * Alignment in the vertical direction. + * @since 8 + */ + alignment?: DialogAlignment; + /** + * Offset of the pop-up window relative to the alignment position. + * @since 8 + */ + offset?: { + dx: number | string | Resource; + dy: number | string | Resource; + }; + }); +} diff --git a/build-tools/api/@internal/component/ets/alert_dialog.d.ts b/build-tools/api/@internal/component/ets/alert_dialog.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8d7b3ed05edcb9990d1b2888256b376b0927b3a --- /dev/null +++ b/build-tools/api/@internal/component/ets/alert_dialog.d.ts @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The alignment of dialog, + * @since 7 + */ +declare enum DialogAlignment { + /** + * Vertical top alignment. + * @since 7 + */ + Top, + /** + * Align vertically to the center. + * @since 7 + */ + Center, + /** + * Vertical bottom alignment. + * @since 7 + */ + Bottom, + /** + * Default alignment. + * @since 7 + */ + Default, + /** + * Align the upper left corner. + * @since 8 + */ + TopStart, + /** + * Align the upper right corner. + * @since 8 + */ + TopEnd, + /** + * Left center alignment. + * @since 8 + */ + CenterStart, + /** + * Right center alignment. + * @since 8 + */ + CenterEnd, + /** + * Align the lower left corner. + * @since 8 + */ + BottomStart, + /** + * Align the lower right corner. + * @since 8 + */ + BottomEnd +} +/** + * Base param used for AlertDialog.show method. + * @since 7 + */ +declare interface AlertDialogParam { + /** + * Title Properties + * @since 7 + */ + title?: ResourceStr; + /** + * message Properties + * @since 7 + */ + message: ResourceStr; + /** + * Allows users to click the mask layer to exit. + * @since 7 + */ + autoCancel?: boolean; + /** + * Execute Cancel Function. + * @since 7 + */ + cancel?: () => void; + /** + * Alignment in the vertical direction. + * @since 7 + */ + alignment?: DialogAlignment; + /** + * Offset of the pop-up window relative to the alignment position. + * @since 7 + */ + offset?: Offset; + /** + * Grid count of dialog. + * @since 7 + */ + gridCount?: number; +} +/** + * Defines the AlertDialog with confirm button. + * @since 7 + */ +declare interface AlertDialogParamWithConfirm extends AlertDialogParam { + /** + * Invoke the commit function. + * @since 7 + */ + confirm?: { + /** + * Text content of the confirmation button. + * @since 7 + */ + value: ResourceStr; + /** + * Text color of the confirmation button. + * @since 7 + */ + fontColor?: ResourceColor; + /** + * Background color of the confirmation button. + * @since 7 + */ + backgroundColor?: ResourceColor; + /** + * Method executed by the callback. + * @since 7 + */ + action: () => void; + }; +} +/** + * Defines the dialog param with buttons. + * @since 7 + */ +declare interface AlertDialogParamWithButtons extends AlertDialogParam { + /** + * First button. + * @since 7 + */ + primaryButton: { + /** + * Text content of the confirmation button. + * @since 7 + */ + value: ResourceStr; + /** + * Text color of the confirmation button. + * @since 7 + */ + fontColor?: ResourceColor; + /** + * Background color of the confirmation button. + * @since 7 + */ + backgroundColor?: ResourceColor; + /** + * Method executed by the callback. + * @since 7 + */ + action: () => void; + }; + /** + * Second button. + * @since 7 + */ + secondaryButton: { + /** + * Text content of the confirmation button. + * @since 7 + */ + value: ResourceStr; + /** + * Text color of the confirmation button. + * @since 7 + */ + fontColor?: ResourceColor; + /** + * Background color of the confirmation button. + * @since 7 + */ + backgroundColor?: ResourceColor; + /** + * Method executed by the callback. + * @since 7 + */ + action: () => void; + }; +} +/** + * Defines AlertDialog which uses show method to show alert dialog. + * @since 7 + */ +declare class AlertDialog { + /** + * Invoking method display. + * @since 7 + */ + static show(value: AlertDialogParamWithConfirm | AlertDialogParamWithButtons); +} diff --git a/build-tools/api/@internal/component/ets/alphabet_indexer.d.ts b/build-tools/api/@internal/component/ets/alphabet_indexer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c82e556c5bee44b0090e65f3c52e2ddbe4330ced --- /dev/null +++ b/build-tools/api/@internal/component/ets/alphabet_indexer.d.ts @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * indexer align property. + * @since 7 + */ +declare enum IndexerAlign { + /** + * A dialog box is displayed on the right of the index bar. + * @since 7 + */ + Left, + /** + * A dialog box is displayed on the left of the index bar. + * @since 7 + */ + Right +} +/** + * Alphabet index bar. + * @since 7 + */ +interface AlphabetIndexerInterface { + /** + * ArrayValue: Alphabetical index string array. + * selected: ID of the selected item. + * @since 7 + */ + (value: { + arrayValue: Array; + selected: number; + }): AlphabetIndexerAttribute; +} +/** + * Defines the alphabet index bar attribute functions. + * @since 7 + */ +declare class AlphabetIndexerAttribute extends CommonMethod { + /** + * Index bar selection callback. + * @since 7 + * @deprecated since 8 + */ + onSelected(callback: (index: number) => void): AlphabetIndexerAttribute; + /** + * Definitions color. + * @since 7 + */ + color(value: ResourceColor): AlphabetIndexerAttribute; + /** + * Select the text color. + * @since 7 + */ + selectedColor(value: ResourceColor): AlphabetIndexerAttribute; + /** + * Font color of the pop-up prompt text. + * @since 7 + */ + popupColor(value: ResourceColor): AlphabetIndexerAttribute; + /** + * Select the text background color. + * @since 7 + */ + selectedBackgroundColor(value: ResourceColor): AlphabetIndexerAttribute; + /** + * Background color of the pop-up window index. + * @since 7 + */ + popupBackground(value: ResourceColor): AlphabetIndexerAttribute; + /** + * Whether to use pop-up index hints. + * @since 7 + */ + usingPopup(value: boolean): AlphabetIndexerAttribute; + /** + * Select the text text style, + * @since 7 + */ + selectedFont(value: Font): AlphabetIndexerAttribute; + /** + * Select the text background color. + * @since 7 + */ + popupFont(value: Font): AlphabetIndexerAttribute; + /** + * Size of the letter area on the letter index bar. The letter area is a square. Set the length of the square side. + * @since 7 + */ + itemSize(value: string | number): AlphabetIndexerAttribute; + /** + * Definitions fonts. + * @since 7 + */ + font(value: Font): AlphabetIndexerAttribute; + /** + * Alphabet index bar alignment style. The left and right alignment styles are supported, which affects the pop-up position of the pop-up window. + * @since 7 + */ + alignStyle(value: IndexerAlign): AlphabetIndexerAttribute; + /** + * Index bar selection callback. + * @since 8 + */ + onSelect(callback: (index: number) => void): AlphabetIndexerAttribute; + /** + * Index bar selection callback and return the strings which display on pop-up. + * @since 8 + */ + onRequestPopupData(callback: (index: number) => Array): AlphabetIndexerAttribute; + /** + * Pop-up selection callback. + * @since 8 + */ + onPopupSelect(callback: (index: number) => void): AlphabetIndexerAttribute; + /** + * Sets the selected index. + * @since 8 + */ + selected(index: number): AlphabetIndexerAttribute; + /** + * Position of the pop-up windows, relative to the midpoint of the top border of the indexer bar. + * @since 8 + */ + popupPosition(value: Position): AlphabetIndexerAttribute; +} +declare const AlphabetIndexer: AlphabetIndexerInterface; +declare const AlphabetIndexerInstance: AlphabetIndexerAttribute; diff --git a/build-tools/api/@internal/component/ets/badge.d.ts b/build-tools/api/@internal/component/ets/badge.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0ac24210a46ac104dce2e736c39fec91e2d1e74a --- /dev/null +++ b/build-tools/api/@internal/component/ets/badge.d.ts @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the badge position property. + * @since 7 + */ +declare enum BadgePosition { + /** + * The dot is displayed vertically centered on the right. + * @since 7 + */ + RightTop, + /** + * Dots are displayed in the upper right corner. + * @since 7 + */ + Right, + /** + * The dot is displayed in the left vertical center. + * @since 7 + */ + Left +} +/** + * BadgeStyle object + * @since 7 + */ +declare interface BadgeStyle { + /** + * Text Color + * @since 7 + */ + color?: ResourceColor; + /** + * Text size. + * @since 7 + */ + fontSize?: number | string; + /** + * Size of a badge. + * @since 7 + */ + badgeSize?: number | string; + /** + * Color of the badge. + * @since 7 + */ + badgeColor?: ResourceColor; +} +/** + * Defines the base param of badge. + * @since 7 + */ +declare interface BadgeParam { + /** + * Set the display position of the prompt point. + * @since 7 + */ + position?: BadgePosition; + /** + * Defines the style of the Badge component, including the text color, size, dot color, and size. + * @since 7 + */ + style: BadgeStyle; +} +/** + * Defines the badge param with count and maxCount. + * @since 7 + */ +declare interface BadgeParamWithNumber extends BadgeParam { + /** + * Set the number of reminder messages. + * @since 7 + */ + count: number; + /** + * Maximum number of messages. If the number of messages exceeds the maximum, only maxCount+ is displayed. + * @since 7 + */ + maxCount?: number; +} +/** + * Defines the badge param with string value. + * @since 7 + */ +declare interface BadgeParamWithString extends BadgeParam { + /** + * Text string of the prompt content. + * @since 7 + */ + value: string; +} +/** + * Defines Badge Componrnt. + * @since 7 + */ +interface BadgeInterface { + /** + * position: Set the display position of the prompt point. + * maxCount: Maximum number of messages. If the number of messages exceeds the maximum, only maxCount+ is displayed. + * count: Set the number of reminder messages. + * style: You can set the style of the Badge component, including the text color, size, dot color, and size. + * @since 7 + */ + (value: BadgeParamWithNumber): BadgeAttribute; + /** + * value: Text string of the prompt content. + * position: Set the display position of the prompt point. + * maxCount: Maximum number of messages. If the number of messages exceeds the maximum, only maxCount+ is displayed. + * style: You can set the style of the Badge component, including the text color, size, dot color, and size. + * @since 7 + */ + (value: BadgeParamWithString): BadgeAttribute; +} +/** + * Defines Badge Componrnt attribute. + * @since 7 + */ +declare class BadgeAttribute extends CommonMethod { +} +declare const Badge: BadgeInterface; +declare const BadgeInstance: BadgeAttribute; diff --git a/build-tools/api/@internal/component/ets/blank.d.ts b/build-tools/api/@internal/component/ets/blank.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac2e6922f039e30ba12783eb2a1b10df2e994db3 --- /dev/null +++ b/build-tools/api/@internal/component/ets/blank.d.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Create Blank. + * @since 7 + */ +interface BlankInterface { + /** + * The minimum size of the blank fill assembly on the container spindle. + * @since 7 + */ + (min?: number | string): BlankAttribute; +} +/** + * Inheritance CommonMethod Set Styles + * @since 7 + */ +declare class BlankAttribute extends CommonMethod { + /** + * color: set color. + * @since 7 + */ + color(value: ResourceColor): BlankAttribute; +} +declare const Blank: BlankInterface; +declare const BlankInstance: BlankAttribute; diff --git a/build-tools/api/@internal/component/ets/button.d.ts b/build-tools/api/@internal/component/ets/button.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f884fbf6057aef126201ef71ed494de0ba00ef29 --- /dev/null +++ b/build-tools/api/@internal/component/ets/button.d.ts @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides a button component. + * @since 7 + */ +declare enum ButtonType { + /** + * Capsule button (rounded corners default to half the height). + * @since 7 + */ + Capsule, + /** + * Round buttons. + * @since 7 + */ + Circle, + /** + * Common button (no rounded corners by default). + * @since 7 + */ + Normal +} +/** + * Defines the button options. + * @since 7 + */ +declare interface ButtonOptions { + /** + * Describes the button style. + * @since 7 + */ + type?: ButtonType; + /** + * Indicates whether to enable the switchover effect when the button is pressed. When the status is set to false, the switchover effect is disabled. + * @since 7 + */ + stateEffect?: boolean; +} +/** + * Defines the Button Component. + * @since 7 + */ +interface ButtonInterface { + /** + * Button object + * @since 7 + */ + (): ButtonAttribute; + /** + * Create Button with Text child. + * @since 7 + */ + (options: ButtonOptions): ButtonAttribute; + /** + * Create Button with inner text label. + * @since 7 + */ + (label: ResourceStr, options?: ButtonOptions): ButtonAttribute; +} +/** + * Defines the button attribute functions. + * @since 7 + */ +declare class ButtonAttribute extends CommonMethod { + /** + * Describes the button style. + * @since 7 + */ + type(value: ButtonType): ButtonAttribute; + /** + * Indicates whether to enable the switchover effect when the button is pressed. When the status is set to false, the switchover effect is disabled. + * @since 7 + */ + stateEffect(value: boolean): ButtonAttribute; + /** + * Text color. + * @since 7 + */ + fontColor(value: ResourceColor): ButtonAttribute; + /** + * Text size. + * @since 7 + */ + fontSize(value: Length): ButtonAttribute; + /** + * Font weight. + * @since 7 + */ + fontWeight(value: number | FontWeight | string): ButtonAttribute; + /** + * Font style. + * @since 8 + */ + fontStyle(value: FontStyle): ButtonAttribute; + /** + * Font family. + * @since 8 + */ + fontFamily(value: string | Resource): ButtonAttribute; +} +declare const Button: ButtonInterface; +declare const ButtonInstance: ButtonAttribute; diff --git a/build-tools/api/@internal/component/ets/canvas.d.ts b/build-tools/api/@internal/component/ets/canvas.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b3f60b7f5e3c6c3d089fcd543b358964602284c --- /dev/null +++ b/build-tools/api/@internal/component/ets/canvas.d.ts @@ -0,0 +1,975 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Filling style algorithm, which determines whether a point is within or outside the path. The following + * two configurations are supported: + * "evenodd": odd and even round rule + * "nonzero": (Default) Non-zero Wrap Rules + * @since 8 + */ +declare type CanvasFillRule = "evenodd" | "nonzero"; +/** + * Specifies the attribute of drawing the end of each line segment. The following configurations are supported: + * "butt": (Default) Segment Ends in Square + * "round": Segment ends in a circle + * "square": The end of the segment ends in a square, but a rectangular area is added that is the same width + * as the segment and is half the thickness of the segment. + * @since 8 + */ +declare type CanvasLineCap = "butt" | "round" | "square"; +/** + * Sets the attribute of how two connected parts (line segments, arcs, and curves) whose length is not 0 + * are connected together. The following three configurations are supported: + * "bevel": Fill the ends of the connected sections with an additional triangle-base area, + * each with its own independent rectangular corner. + * "miter": (Default) An additional diamond region is formed by extending the outer edges of the connected portions + * so that they intersect at a point. + * "round": Draw the shape of the corner by filling in an additional sector with the center at the end of the + * connected section. The radius of the fillet is the width of the segment. + * @since 8 + */ +declare type CanvasLineJoin = "bevel" | "miter" | "round"; +/** + * Indicates the attribute of the current text direction. The options are as follows: + * "inherit": (Default) Inherit current Canvas component settings + * "ltr": The text direction is left to right. + * "rtl": The text direction is from right to left. + * @since 8 + */ +declare type CanvasDirection = "inherit" | "ltr" | "rtl"; +/** + * Describes the alignment mode for drawing text. The options are as follows: + * "center": The text is centered. + * "end": Where text aligns lines end (Left alignment refers to the local from left to right, + * and right alignment refers to the local from right to left) + * "left": The text is left-aligned. + * "right": The text is right-aligned. + * "start": (Default) Where the text snap line begins (Left alignment refers to the local from left to right, + * and right alignment refers to the local from right to left) + * @since 8 + */ +declare type CanvasTextAlign = "center" | "end" | "left" | "right" | "start"; +/** + * Text baseline, which supports the following configurations: + * "alphabetic": (Default) The text baseline is the standard letter baseline. + * "bottom": The text baseline is at the bottom of the text block. The difference between the ideographic baseline + * and the ideographic baseline is that the ideographic baseline does not need to consider downlink letters. + * "hanging": The text baseline is a hanging baseline. + * "ideographic": The text baseline is the ideographic baseline; If the character itself exceeds the alphabetic + * baseline, the ideograhpic baseline is at the bottom of the character itself. + * "middle": The text baseline is in the middle of the text block. + * "top": The text baseline is at the top of the text block. + * @since 8 + */ +declare type CanvasTextBaseline = "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top"; +/** + * Sets the image smoothness attribute. The options are as follows: + * "high": height + * "low": (default)low + * "medium": medium + * @since 8 + */ +declare type ImageSmoothingQuality = "high" | "low" | "medium"; +/** + * Opaque objects that describe gradients, created by createLinearGradient() or createRadialGradient() + * @since 8 + */ +declare class CanvasGradient { + /** + * Add a breakpoint defined by offset and color to the gradient + * @param number Value between 0 and 1, out of range throws INDEX_SIZE_ERR error + * @param string CSS color value . If the color value cannot be resolved to a valid CSS color value + * a SYNTAX_ERR error is thrown. + * @since 8 + */ + addColorStop(offset: number, color: string): void; +} +/** + * Path object, which provides basic methods for drawing paths. + * @since 8 + */ +declare class CanvasPath { + /** + * Draw an arc path + * @param x The x-axis coordinate of the center (center of the circle) of the arc. + * @param y The y-axis coordinate of the center (center of the circle) of the arc. + * @param radius Radius of the arc. + * @param startAngle Start point of an arc, which starts to be calculated in the x-axis direction. The unit is radian. + * @param endAngle The end point of the arc, in radians. + * @param counterclockwise If the value is true, the arc is drawn counterclockwise. Otherwise, + * the arc is drawn clockwise. The default value is false. + * @since 8 + */ + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void; + /** + * Draw arc paths based on control points and radius + * @param x1 The x-axis coordinate of the first control point. + * @param y1 The y-axis coordinate of the first control point. + * @param x2 The x-axis coordinate of the second control point. + * @param y2 The y-axis coordinate of the second control point. + * @param radius Radius of the arc. + * @since 8 + */ + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + /** + * Drawing Cubic Bessel Curve Paths + * @param cp1x The x-axis coordinate of the first control point. + * @param cp1y The y-axis coordinate of the first control point. + * @param cp2x The x-axis coordinate of the second control point. + * @param cp2y The y-axis coordinate of the second control point. + * @param x x-axis coordinate of the end point. + * @param y y-axis coordinate of the end point. + * @since 8 + */ + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + /** + * Returns the pen point to the start point of the current subpath + * @since 8 + */ + closePath(): void; + /** + * Draw an Elliptic Path + * @param x x-axis coordinate of the center of the ellipse. + * @param y y-axis coordinate of the center of the ellipse. + * @param radiusX Radius of the major axis of the ellipse. + * @param radiusY Radius of the minor axis of the ellipse. + * @param rotation The rotation angle of the ellipse, in radians (not angular degrees). + * @param startAngle The angle of the starting point to be drawn, measured from the x-axis in radians + * (not angular degrees). + * @param endAngle The angle, in radians, at which the ellipse is to be drawn (not angular degrees). + * @param counterclockwise If the value is true, the ellipse is drawn counterclockwise. Otherwise, + * the ellipse is drawn clockwise. The default value is false. + * @since 8 + */ + ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void; + /** + * Connect subpaths using straight lines + * @param x The x-axis coordinate of the end point of the line. + * @param y The y-axis coordinate of the end point of the line. + * @since 8 + */ + lineTo(x: number, y: number): void; + /** + * Moves the start point of a new subpath to the (x, y) coordinate. + * @param x The x-axis coordinate of the point. + * @param y The y-axis coordinate of the point. + * @since 8 + */ + moveTo(x: number, y: number): void; + /** + * Draw quadratic Bezier curve paths + * @param cpx The x-axis coordinate of the control point. + * @param cpy The y-axis coordinate of the control point. + * @param x x-axis coordinate of the end point. + * @param y y-axis coordinate of the end point. + * @since 8 + */ + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + /** + * Draw Rectangular Paths + * @param x The x-axis coordinate of the start point of the rectangle. + * @param y The y-axis coordinate of the start point of the rectangle. + * @param w Width of the rectangle. + * @param h Height of the rectangle. + * @since 8 + */ + rect(x: number, y: number, w: number, h: number): void; +} +/** + * 2D path object for path drawing + * @since 8 + */ +declare class Path2D extends CanvasPath { + /** + * Adds a path according to the specified path variable. + * @param path Indicates the path object to be added. + * @param transform Transformation matrix of the new trail + * @since 8 + */ + addPath(path: Path2D, transform?: Matrix2D): void; + /** + * Create an empty path object. + * @since 8 + */ + constructor(); + /** + * Create a copy of a path object + * @param path Path object to be copied + * @since 8 + */ + constructor(path: Path2D); + /** + * Create a new path according to the description. + * @param d Indicates the path string that compiles with the SVG path description specifications. + * @since 8 + */ + constructor(d: string); +} +/** + * Describes an opaque object of a template, which is created using the createPattern() method. + * @since 8 + */ +declare interface CanvasPattern { + /** + * Adds the matrix transformation effect to the current template. + * @param transform transformation matrix + * @since 8 + */ + setTransform(transform?: Matrix2D): void; +} +/** + * Size information of the text + * @since 8 + */ +declare interface TextMetrics { + /** + * Double, the distance from the horizontal line indicated by the textBaseline property to the top of + * the rectangular boundary of the rendered text. + * @since 8 + */ + readonly actualBoundingBoxAscent: number; + /** + * Double, the distance from the horizontal line indicated by the textBaseline property to the bottom of + * the rectangular boundary of the rendered text. + * @since 8 + */ + readonly actualBoundingBoxDescent: number; + /** + * Double, parallel to the baseline, distance from the alignment point determined by the textAlign property to + * the left of the text rectangle boundary. + * @since 8 + */ + readonly actualBoundingBoxLeft: number; + /** + * Double, parallel to the baseline, distance from the alignment point determined by the textAlign property to + * the right of the text rectangle boundary. + * @since 8 + */ + readonly actualBoundingBoxRight: number; + /** + * Double, the distance from the horizontal line indicated by the textBaseline property to the alphabetic baseline of + * the wireframe. + * @since 8 + */ + readonly alphabeticBaseline: number; + /** + * Double, the distance from the horizontal line indicated by the textBaseline property to the top of the + * em square in the wireframe. + * @since 8 + */ + readonly emHeightAscent: number; + /** + * Double, distance from the horizontal line indicated by the textBaseline property to the bottom of the + * em box in the wireframe. + * @since 8 + */ + readonly emHeightDescent: number; + /** + * Double, distance from the horizontal line indicated by the textBaseline property to the top of the + * highest rectangle boundary of all fonts rendering text. + * @since 8 + */ + readonly fontBoundingBoxAscent: number; + /** + * Double, distance from the horizontal line indicated by the textBaseline property to the bottom of the + * rectangular boundary of all fonts rendering text. + * @since 8 + */ + readonly fontBoundingBoxDescent: number; + /** + * Double, distance from the horizontal line indicated by the textBaseline property to + * the hanging baseline of the wireframe. + * @since 8 + */ + readonly hangingBaseline: number; + /** + * Double, distance from the horizontal line indicated by the textBaseline property to + * the ideographic baseline of the wireframe. + * @since 8 + */ + readonly ideographicBaseline: number; + /** + * Indicates the width of a character string. The value is of the double type. + * @since 8 + */ + readonly width: number; + /** + * Indicates the height of a character string. The value is of the double type. + * @since 8 + */ + readonly height: number; +} +/** + * Bitmap image object that can be drawn onto the current Canvas + * @since 8 + */ +declare class ImageBitmap { + /** + * Indicates the height of the CSS pixel unit of ImageData. + * @since 8 + */ + readonly height: number; + /** + * Indicates the width of the CSS pixel unit of ImageData. + * @since 8 + */ + readonly width: number; + /** + * Releases all graphics resources associated with an ImageBitmap. + * @since 8 + */ + close(): void; + /** + * Create an ImageBitmap object based on the transferred image path. + * @param src Path of the image object. + * @since 8 + */ + constructor(src: string); + /** + * Transfer a PixelMap object to construct an ImageBitmap object. + * @param data PixelMap object + * @since 8 + */ + constructor(data: PixelMap); +} +/** + * Image data object + * @since 8 + */ +declare class ImageData { + /** + * Array containing image pixel data + * @since 8 + */ + readonly data: Uint8ClampedArray; + /** + * Width of the image. + * @since 8 + */ + readonly height: number; + /** + * Height of the image. + * @since 8 + */ + readonly width: number; + /** + * Create an ImageData object based on the input parameters. + * @param width Width of the image. + * @param height Height of the image. + * @param data Data of the image. If this parameter is not specified, the default value is a black rectangular image. + * @since 8 + */ + constructor(width: number, height: number, data?: Uint8ClampedArray); +} +/** + * This object allows you to set properties when creating a rendering context + * @since 8 + */ +declare class RenderingContextSettings { + /** + * Indicates whether anti-aliasing is enabled for canvas. The default value is false. + * @since 8 + */ + antialias?: boolean; + /** + * Create an RenderingContextSettings object based on the antialias and alpha. + * @param antialias Indicates whether anti-aliasing is enabled for canvas + * @since 8 + */ + constructor(antialias?: boolean); +} +/** + * Canvas renderer for drawing shapes, text, images and other objects + * @since 8 + */ +declare class CanvasRenderer extends CanvasPath { + /** + * Transparency. The value ranges from 0.0 (completely transparent) to 1.0 (completely opaque). + * The default value is 1.0. If the value is out of range, the assignment is invalid. + * @since 8 + */ + globalAlpha: number; + /** + * Type of composition operation applied when drawing a new shape. The following types are supported: + * source-over: (Default) Draws a new drawing on top of an existing canvas context. + * source-in: The new drawing is drawn only where the new drawing overlaps the target canvas. + * Everything else is transparent. + * source-out: Draws a new drawing where it does not overlap with the existing canvas content. + * source-atop: The new drawing is drawn only where it overlaps the content of the existing canvas. + * destination-over: Draws a new graphic behind the existing canvas content. + * destination-in: Existing canvas content remains where the new drawing overlaps the existing canvas content. + * Everything else is transparent. + * destination-out: Existing content remains where the new drawing does not overlap. + * destination-atop: The existing canvas retains only the part that overlaps with the new drawing, + * which is drawn behind the canvas content. + * lighter: The color of two overlapping shapes is determined by adding the color values. + * copy: Only new graphics are displayed. + * xor: In the image, those overlaps and other places outside of the normal drawing are transparent. + * multiply: Multiply the top pixel by the bottom pixel, and the result is a darker picture. + * screen: The pixels are inverted, multiplied, and inverted again, and the result is a brighter picture. + * overlay: The combination of multiply and screen enables dark places to be darker and bright places to be brighter. + * darken: Keeps the darkest pixel in both layers. + * lighten: Keeps the brightest pixel in both layers. + * color-dodge: The inverse of dividing the bottom layer by the top layer. + * color-burn: Divide the inverted bottom layer by the top layer, and reverse the result. + * hard-light: A combination of multiplication and screen is similar to overlay, but the layers are interchanged. + * soft-light: Subtract the bottom from the top or vice versa to get a positive value. + * difference: A softer version of hard-light. Pure black or pure white does not result in pure black or pure white. + * exclusion: Similar to difference, but with lower contrast. + * hue: The luminance and chroma of the bottom layer are retained while the hue of the top layer is employed. + * saturation: The luminance (luma) and hue (hue) of the bottom layer are retained while the chroma (chroma) of + * the top layer is used. + * color: The luminance (luma) of the bottom layer is retained while the hue (hue) and chroma (chroma) of + * the top layer are used. + * luminosity: The hue and chroma of the bottom layer are maintained while the luminance of the top layer is used. + * @since 8 + */ + globalCompositeOperation: string; + /** + * Draw an image on a canvas + * @param image Picture objects drawn to the canvas. + * @param dx x-axis coordinate of the upper left corner of the image on the target canvas. + * @param dy y-axis coordinate of the upper left corner of the image on the target canvas. + * @since 8 + */ + drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number): void; + /** + * Draw an image on a canvas + * @param image Picture objects drawn to the canvas. + * @param dx x-axis coordinate of the upper left corner of the image on the target canvas. + * @param dy y-axis coordinate of the upper left corner of the image on the target canvas. + * @param dw Specifies the drawing width of the image on the target canvas. The width of the drawn image will be scaled. + * @param dh Specifies the drawing height of the image on the target canvas. The height of the drawn image will be scaled. + * @since 8 + */ + drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number, dw: number, dh: number): void; + /** + *Draw an image on a canvas + * @param image Picture objects drawn to the canvas. + * @param sx x coordinate of the upper left corner of the rectangle (cropping) selection box of the image. + * @param sy y coordinate of the upper left corner of the rectangle (cropping) selection box of the image. + * @param sw Width of the rectangle (cropping) selection box of the image. + * @param sh Height of the rectangle (cropping) selection box of the image. + * @param dx x-axis coordinate of the upper left corner of the image on the target canvas. + * @param dy y-axis coordinate of the upper left corner of the image on the target canvas. + * @param dw Specifies the drawing width of the image on the target canvas. The width of the drawn image will be scaled. + * @param dh Specifies the drawing height of the image on the target canvas. The height of the drawn image will be scaled. + * @since 8 + */ + drawImage(image: ImageBitmap | PixelMap, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void; + /** + * Clear the sub-path list and start a new path. + * @since 8 + */ + beginPath(): void; + /** + * Sets the currently created path as the current clipping path + * @param fillRule Algorithm rule. For details, see {@link CanvasFillRule}. + * @since 8 + */ + clip(fillRule?: CanvasFillRule): void; + /** + * Tailoring according to the specified path + * @param path Path to be cut. + * @param fillRule Algorithm rule. For details, see {@link CanvasFillRule}. + * @since 8 + */ + clip(path: Path2D, fillRule?: CanvasFillRule): void; + /** + * Fills existing paths according to the current fill style. + * @param fillRule Algorithm rule. For details, see {@link CanvasFillRule}. + * @since 8 + */ + fill(fillRule?: CanvasFillRule): void; + /** + * Fills the specified path according to the current fill style + * @param path Path to be filled. + * @param fillRule Algorithm rule. For details, see {@link CanvasFillRule}. + * @since 8 + */ + fill(path: Path2D, fillRule?: CanvasFillRule): void; + /** + * Draws an existing path according to the current stroke style. + * @since 8 + */ + stroke(): void; + /** + * Draws the specified path according to the current stroke style + * @param path Specified stroke path object + * @since 8 + */ + stroke(path: Path2D): void; + /** + * Attributes that describe the fill color and style. The default value is # 000 (black). The options are as follows: + * color: Color String + * CanvasGradient: Color gradient object. For details, see {@link CanvasGradient}. + * CanvasPattern: Template object. For details, see {@link CanvasPattern}. + * @param path Specified stroke path object + * @since 8 + */ + fillStyle: string | CanvasGradient | CanvasPattern; + /** + * Attributes of the stroke color and style. The default value is # 000 (black). The options are as follows: + * color: Color String + * CanvasGradient: Color gradient object. For details, see {@link CanvasGradient}. + * CanvasPattern: Template object. For details, see {@link CanvasPattern}. + * @param path Specified stroke path object + * @since 8 + */ + strokeStyle: string | CanvasGradient | CanvasPattern; + /** + * Creates a linear gradient object that is specified along the parameter coordinates + * @param x0 The x-axis coordinate of the start point. + * @param y0 The y-axis coordinate of the start point. + * @param x1 x-axis coordinate of the end point. + * @param y1 y-axis coordinate of the end point. + * @since 8 + */ + createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; + /** + * Creates a template object using the specified image + * @param image Objects as duplicate image sources + * @param repetition Specifies how to repeat images. The following four modes are supported: + * "repeat": Repeated images in both X and Y directions + * "repeat-x": Repeated images in the X-axis direction but not in the Y-axis direction + * "repeat-y": The image is repeated in the Y axis direction, and the image is not repeated in the X axis direction. + * "no-repeat": Non-repeating images in both X and Y directions + * @since 8 + */ + createPattern(image: ImageBitmap, repetition: string | null): CanvasPattern | null; + /** + * Creates a radioactive gradient object based on parameters that determine the coordinates of two circles + * @param x0 The x-axis coordinate of the start circle. + * @param y0 The y-axis coordinate of the start circle. + * @param r0 Radius of the starting circle. + * @param x1 The x-axis coordinate of the end circle. + * @param y1 The y-axis coordinate of the end circle. + * @param r1 Radius of the end circle. + * @since 8 + */ + createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + /** + * Provides filter effects such as blur and grayscale. You can set the following filter effects: + * blur(): Adds a Gaussian blur effect to the drawing + * brightness(): Provides a linear multiplication for the drawing and adjusts the brightness level. + * contrast(): Adjusts the contrast of the image. When the value is 0%, the image is completely blacked out. + * When the value is 100%, there is no change in the image. + * drop-shadow(, , , , ): Shading Drawings + * --- : Describes the horizontal distance of the shadow. + * --- : Describes the vertical distance of the shadow. + * --- : Blur radius. The larger the value, the greater the blur. The value cannot be a negative number. + * --- : Positive numbers make the shadow expand larger, negative numbers make the shadow shrink. + * --- : Shadow Color + * grayscale():Converts the image to a gray image. When the value is 100%, the image is completely grayed out. + * When the value is 0%, there is no change in the image. + * hue-rotate():Perform color rotation on an image. When the value is 0 degrees, there is no change in the image. + * invert():Inverted image (representing the effect of a photographic negative). When the value is 100%, + * the image is completely inverted. When the value is 0%, there is no change in the image. + * opacity():Transparency of the image. At 0%, the image is completely transparent. + * When the value is 100%, there is no change in the image. + * saturate():Perform saturation processing on the image. At 0%, the image is completely unsaturated. + * When the value is 100%, there is no change in the image. + * sepia():The image is sepia (nostalgic style). At 100%, the image turns completely sepia. + * When the value is 0%, there is no change in the image. + * none:Turn off filter effects + * @since 8 + */ + filter(filter: string): void; + /** + * Creates a new, empty ImageData object of the specified size + * @param sw Width of the ImageData object. + * @param sh Height of the ImageData object. + * @since 8 + */ + createImageData(sw: number, sh: number): ImageData; + /** + * From an existing ImageData object, copy an object with the same width and height as the image. + * The image content is not copied. + * @param imagedata ImageData object to be copied. + * @since 8 + */ + createImageData(imagedata: ImageData): ImageData; + /** + * Obtains the pixel data of a specified area on the current canvas. + * @param sx x coordinate of the upper left corner of the rectangular area of the image data to be extracted. + * @param sy y coordinate of the upper left corner of the rectangular area of the image data to be extracted. + * @param sw The width of the rectangular area of the image data to be extracted. + * @param sh The height of the rectangular area of the image data to be extracted. + * @since 8 + */ + getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + /** + * Obtains the PixelMap of a specified area on the current canvas. + * @param sx x coordinate of the upper left corner of the rectangular area of the PixelMap to be extracted. + * @param sy y coordinate of the upper left corner of the rectangular area of the PixelMap to be extracted. + * @param sw The width of the rectangular area of the PixelMap to be extracted. + * @param sh The height of the rectangular area of the PixelMap to be extracted. + * @since 8 + */ + getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap; + /** + * Draws the specified ImageData object onto the canvas + * @param imagedata ImageData object to be drawn. + * @param dx Position offset of the source image data in the target canvas (the offset in the x-axis direction). + * @param dy Position offset of the source image data in the target canvas (the offset in the y-axis direction). + * @since 8 + */ + putImageData(imagedata: ImageData, dx: number, dy: number): void; + /** + * Draws the specified ImageData object onto the canvas + * @param imagedata ImageData object to be drawn. + * @param dx Position offset of the source image data in the target canvas (the offset in the x-axis direction). + * @param dy Position offset of the source image data in the target canvas (the offset in the y-axis direction). + * @param dirtyX Position of the upper left corner of the rectangular area in the source image data. + * The default is the upper left corner (x coordinate) of the entire image data. + * @param dirtyY Position of the upper left corner of the rectangular area in the source image data. + * The default is the upper left corner (y coordinate) of the entire image data. + * @param dirtyWidth Width of the rectangular area in the source image data. + * The default is the width of the image data. + * @param dirtyHeight Height of the rectangular area in the source image data. + * The default is the height of the image data. + * @since 8 + */ + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX: number, dirtyY: number, dirtyWidth: number, dirtyHeight: number): void; + /** + * Specifies whether to smooth the image. The value true indicates that the image is smooth (default value). + * The value false indicates that the image is not smooth. + * @since 8 + */ + imageSmoothingEnabled: boolean; + /** + * Smoothness level of the current image. For details, see {@link ImageSmoothingQuality}. + * @since 8 + */ + imageSmoothingQuality(quality: ImageSmoothingQuality): void; + /** + * Line segment endpoint attribute. For details, see {@link CanvasLineCap}. + * @since 8 + */ + lineCap: CanvasLineCap; + /** + * Dotted line offset attribute. The default value is 0.0. + * @since 8 + */ + lineDashOffset: number; + /** + * Line segment connection point attribute. For details, see {@link CanvasLineJoin}. + * @since 8 + */ + lineJoin: CanvasLineJoin; + /** + * Line thickness attribute. The value cannot be 0 or a negative number. + * @since 8 + */ + lineWidth: number; + /** + * The value of this parameter cannot be 0 or a negative number. + * @since 8 + */ + miterLimit: number; + /** + * Gets the current segment style. + * @since 8 + */ + getLineDash(): number[]; + /** + * Sets the dashed line mode for line drawing. + * @param segments A set of numbers that describe the length of alternating drawn line segments and + * spacing (coordinate space units). + * @since 8 + */ + setLineDash(segments: number[]): void; + /** + * Clears the drawing content of a rectangular area. + * @param x The x-axis coordinate of the start point of the rectangle. + * @param y The y-axis coordinate of the start point of the rectangle. + * @param w Width of the rectangle. + * @param h Height of the rectangle. + * @since 8 + */ + clearRect(x: number, y: number, w: number, h: number): void; + /** + * Fills a specified rectangular area + * @param x The x-axis coordinate of the start point of the rectangle. + * @param y The y-axis coordinate of the start point of the rectangle. + * @param w Width of the rectangle. + * @param h Height of the rectangle. + * @since 8 + */ + fillRect(x: number, y: number, w: number, h: number): void; + /** + * Stroke Specify Rectangular Area + * @param x The x-axis coordinate of the start point of the rectangle. + * @param y The y-axis coordinate of the start point of the rectangle. + * @param w Width of the rectangle. + * @param h Height of the rectangle. + * @since 8 + */ + strokeRect(x: number, y: number, w: number, h: number): void; + /** + * Shadow blur radius. The default value is 0. The value cannot be a negative number. + * @since 8 + */ + shadowBlur: number; + /** + * Shadow color. The default value is transparent black. + * @since 8 + */ + shadowColor: string; + /** + * Horizontal offset distance of the shadow. The default value is 0. + * @since 8 + */ + shadowOffsetX: number; + /** + * Vertical offset distance of the shadow. The default value is 0. + * @since 8 + */ + shadowOffsetY: number; + /** + * Top of the stack pop-up state in the drawing state stack + * @since 8 + */ + restore(): void; + /** + * Saves the current drawing state to the drawing state stack + * @since 8 + */ + save(): void; + /** + * Fills the specified text at the specified location + * @param text Text string to be drawn. + * @param x The x-axis coordinate of the start point of the text. + * @param y The y-axis coordinate of the start point of the text. + * @param maxWidth Maximum width of the drawing. + * @since 8 + */ + fillText(text: string, x: number, y: number, maxWidth?: number): void; + /** + * Measure the size of a specified text. For details about the return value, see {@link TextMetrics}. + * @param text Text string to be measured. + * @since 8 + */ + measureText(text: string): TextMetrics; + /** + * Stroke specified text at specified position + * @param text Text string to be stroked. + * @param x The x-axis coordinate of the start point of the text. + * @param y The y-axis-axis coordinate of the start point of the text. + * @param maxWidth Maximum width of the stroke. + * @since 8 + */ + strokeText(text: string, x: number, y: number, maxWidth?: number): void; + /** + * Text drawing direction. For details, see {@link CanvasDirection}. + * @since 8 + */ + direction(direction: CanvasDirection): void; + /** + * Font style. The default value is 10px sans-serif. + * @since 8 + */ + font: string; + /** + * Text alignment mode. For details, see {@link CanvasTextAlign}. + * @since 8 + */ + textAlign: CanvasTextAlign; + /** + * Text baseline. For details, see {@link CanvasTextBaseline}. + * @since 8 + */ + textBaseline: CanvasTextBaseline; + /** + * Obtains the currently applied transformation matrix. + * @since 8 + */ + getTransform(): Matrix2D; + /** + * Resets the current transformation matrix using the identity matrix + * @since 8 + */ + resetTransform(): void; + /** + * Adds the effect of a rotation + * @param angle The radian of clockwise rotation, which can be converted to an angle value using the formula: + * degree * Math.PI / 180 + * @since 8 + */ + rotate(angle: number): void; + /** + * Increases the scaling effect of the X and Y axes. + * @param x Horizontal scaling factor + * @param y Vertical scaling factor + * @since 8 + */ + scale(x: number, y: number): void; + /** + * Adds 2D transformation effects, including rotation, translation, and scaling. + * The current transformation matrix will not be overwritten. Multiple transformations will be superimposed. + * @param a Horizontal Zoom + * @param b Vertical Tilt + * @param c Horizontal Tilt + * @param d Vertical Zoom + * @param e Horizontal movement + * @param f Vertical movement + * @since 8 + */ + setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void; + /** + * The 2D transformation effect is added. The current transformation matrix is not overwritten and + * the transformations are superimposed for multiple times. + * @param transform 2D transformation matrix. For details, see {@link Matrix2D}. + * @since 8 + */ + setTransform(transform?: Matrix2D): void; + /** + * Adds the 2D transformation effect, including rotation, translation, and scaling, + * and overwrites the current transformation matrix. + * @param a Horizontal Zoom + * @param b Vertical Tilt + * @param c Horizontal Tilt + * @param d Vertical Zoom + * @param e Horizontal movement + * @param f Vertical movement + * @since 8 + */ + transform(a: number, b: number, c: number, d: number, e: number, f: number): void; + /** + * Increases the translation effect of the X and Y axes + * @param x Horizontal movement distance + * @param y Vertical travel distance + * @since 8 + */ + translate(x: number, y: number): void; + /** + * Set a PixelMap to the current context. The drawing content is synchronized to the PixelMap. + * @param value PixelMap object + * @since 8 + */ + setPixelMap(value?: PixelMap): void; + /** + * transfer ImageBitmap to content. + * @param ImageBitmap + * @since 8 + */ + transferFromImageBitmap(bitmap: ImageBitmap): void; +} +/** + * Draw context object for the Canvas component. + * @since 8 + */ +declare class CanvasRenderingContext2D extends CanvasRenderer { + /** + * The default value is 0, which is bound to the height of the specified canvas. The value is read-only. + * @since 8 + */ + readonly height: number; + /** + * The default value is 0, which is bound to the width of the specified canvas. The value is read-only. + * @since 8 + */ + readonly width: number; + /** + * Generate a character string in the data url format. + * @param type Image format. The default value is image/png. + * @param quality If the image format is image/jpeg or image/webp, you can select the image quality from 0 to 1. + * If the value is out of the range, the default value 0.92 is used. + * @since 8 + */ + toDataURL(type?: string, quality?: any): string; + /** + * Constructor of the canvas drawing context object, which is used to create a drawing context object. + * @param settings Drawing attribute. For details, see {@link RenderingContextSettings}. + * @since 8 + */ + constructor(settings?: RenderingContextSettings); +} +/** + * Draw context object for the OffscreenCanvas component. + * @since 8 + */ +declare class OffscreenCanvasRenderingContext2D extends CanvasRenderer { + /** + * Generate a character string in the data url format. + * @param type Image format. The default value is image/png. + * @param quality If the image format is image/jpeg or image/webp, you can select the image quality from 0 to 1. + * If the value is out of the range, the default value 0.92 is used. + * @since 8 + */ + toDataURL(type?: string, quality?: any): string; + /** + * transfer the content to ImageBitmap + * @since 8 + */ + transferToImageBitmap(): ImageBitmap; + /** + * Constructor of the canvas drawing context object, which is used to create a drawing context object. + * @param width the width of the OffscreenCanvas + * @param height the height of the OffscreenCanvas + * @param settings Drawing attribute. For details, see {@link RenderingContextSettings}. + * @since 8 + */ + constructor(width: number, height: number, settings?: RenderingContextSettings); +} +/** + * Draw an object off the screen. The drawing content is not directly displayed on the screen. + * @since 8 + */ +declare class OffscreenCanvas extends CanvasRenderer { + /** + * Height of the off-screen canvas. + * @since 8 + */ + height: number; + /** + * Width of the off-screen canvas. + * @since 8 + */ + width: number; + /** + * Exports rendered content as an ImageBitmap object + * @since 8 + */ + transferToImageBitmap(): ImageBitmap; + /** + * Constructor of the off-screen canvas, which is used to create an off-screen canvas object. + * @param width Width of the off-screen canvas. + * @param height Height of the off-screen canvas. + * @since 8 + */ + constructor(width: number, height: number); +} +/** + *TextTimer component, which provides the text timer capability. + * @since 8 + */ +interface CanvasInterface { + /** + * Construct a canvas component. + * @param context Canvas context object. For details, see {@link CanvasRenderingContext2D}. + * @since 8 + */ + (context?: CanvasRenderingContext2D): CanvasAttribute; +} +declare class CanvasAttribute extends CommonMethod { + /** + * Event notification after the canvas component is constructed. You can draw the canvas at this time. + * @since 8 + */ + onReady(event: () => void): CanvasAttribute; +} +declare const Canvas: CanvasInterface; +declare const CanvasInstance: CanvasAttribute; diff --git a/build-tools/api/@internal/component/ets/checkbox.d.ts b/build-tools/api/@internal/component/ets/checkbox.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b64853fa513255a66e45137cf3341eec6045a9de --- /dev/null +++ b/build-tools/api/@internal/component/ets/checkbox.d.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the options of Checkbox. + * @since 8 + */ +declare interface CheckboxOptions { + /** + * Current name of Checkbox. + * @since 8 + */ + name?: string; + /** + * Sets the group of Checkbox. + * @since 8 + */ + group?: string; +} +/** + * Provides an interface for the Checkbox component. + * @since 8 + */ +interface CheckboxInterface { + /** + * Construct the Checkbox component. + * Called when the Checkbox component is used. + * @since 8 + */ + (options?: CheckboxOptions): CheckboxAttribute; +} +/** + * Defines the attribute functions of Checkbox. + * @since 8 + */ +declare class CheckboxAttribute extends CommonMethod { + /** + * setting whether checkbox is selected. + * @since 8 + */ + select(value: boolean): CheckboxAttribute; + /** + * setting the display color of checkbox. + * @since 8 + */ + selectedColor(value: ResourceColor): CheckboxAttribute; + /** + * Called when the selection status changes. + * @since 8 + */ + onChange(callback: (value: boolean) => void): CheckboxAttribute; +} +declare const Checkbox: CheckboxInterface; +declare const CheckboxInstance: CheckboxAttribute; diff --git a/build-tools/api/@internal/component/ets/checkboxgroup.d.ts b/build-tools/api/@internal/component/ets/checkboxgroup.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ed22e63168ba7d826606573cd45bad13df42d4c --- /dev/null +++ b/build-tools/api/@internal/component/ets/checkboxgroup.d.ts @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * CheckboxGroup SelectStatus + * @since 8 + */ +declare enum SelectStatus { + /** + * All checkboxs is selected. + * @since 8 + */ + All, + /** + * Part of the checkbox is selected. + * @since 8 + */ + Part, + /** + * None of the checkbox is selected. + * @since 8 + */ + None +} +/** + * Defines the options of CheckboxGroup. + * @since 8 + */ +declare interface CheckboxGroupOptions { + /** + * Setting the group of CheckboxGroup. + * @since 8 + */ + group?: string; +} +/** + * Defines the options of CheckboxGroupResult. + * @since 8 + */ +declare interface CheckboxGroupResult { + /** + * Checkbox name. + * @since 8 + */ + name: Array; + /** + * Set the group of status. + * @since 8 + */ + status: SelectStatus; +} +/** + * Provides an interface for the CheckboxGroup component. + * @since 8 + */ +interface CheckboxGroupInterface { + /** + * Called when the CheckboxGroup component is used. + * @since 8 + */ + (options?: CheckboxGroupOptions): CheckboxGroupAttribute; +} +/** + * Defines the attribute functions of CheckboxGroup. + * @since 8 + */ +declare class CheckboxGroupAttribute extends CommonMethod { + /** + * setting whether all checkbox is selected. + * @since 8 + */ + selectAll(value: boolean): CheckboxGroupAttribute; + /** + * setting the display color of checkbox. + * @since 8 + */ + selectedColor(value: ResourceColor): CheckboxGroupAttribute; + /** + * Called when the selection status changes. + * @since 8 + */ + onChange(callback: (event: CheckboxGroupResult) => void): CheckboxGroupAttribute; +} +declare const CheckboxGroup: CheckboxGroupInterface; +declare const CheckboxGroupInstance: CheckboxGroupAttribute; diff --git a/build-tools/api/@internal/component/ets/circle.d.ts b/build-tools/api/@internal/component/ets/circle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..80313cc22fcb35d3e444f0425f6c157a0dc79aa5 --- /dev/null +++ b/build-tools/api/@internal/component/ets/circle.d.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines circle options for Circle component. + * @since 7 + */ +declare interface CircleOptions { + /** + * Defines the width property. + * @since 7 + */ + width?: string | number; + /** + * Defines the height property. + * @since 7 + */ + height?: string | number; +} +/** + * Defines circle component. + * @since 7 + */ +interface CircleInterface { + /** + * use new function to set the value. + * @since 7 + */ + new (value?: CircleOptions): CircleAttribute; + /** + * Set the value.. + * @since 7 + */ + (value?: CircleOptions): CircleAttribute; +} +/** + * Circle drawing component attribute functions. + * @since 7 + */ +declare class CircleAttribute extends CommonShapeMethod { +} +declare const Circle: CircleInterface; +declare const CircleInstance: CircleAttribute; diff --git a/build-tools/api/@internal/component/ets/column.d.ts b/build-tools/api/@internal/component/ets/column.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..92b598ab876f10eb18e02e61e9d3ef457c508e56 --- /dev/null +++ b/build-tools/api/@internal/component/ets/column.d.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the Column Component. + * @since 7 + */ +interface ColumnInterface { + /** + * Set the value. + * useAlign:Use a custom alignment. + * space: Vertical layout element spacing. + * @since 7 + */ + (value?: { + space?: string | number; + }): ColumnAttribute; +} +/** + * Defines the Column component attribute functions. + * @since 7 + */ +declare class ColumnAttribute extends CommonMethod { + /** + * Sets the alignment format of the subassembly in the horizontal direction. + * @since 7 + */ + alignItems(value: HorizontalAlign): ColumnAttribute; + /** + * Sets the alignment format of the subassembly in the vertical direction. + * @since 8 + */ + justifyContent(value: FlexAlign): ColumnAttribute; +} +declare const Column: ColumnInterface; +declare const ColumnInstance: ColumnAttribute; diff --git a/build-tools/api/@internal/component/ets/column_split.d.ts b/build-tools/api/@internal/component/ets/column_split.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c5d8a0d1403919c146ab26bbe287bfbc0b511195 --- /dev/null +++ b/build-tools/api/@internal/component/ets/column_split.d.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the ColumnSplit component. + * @since 7 + */ +interface ColumnSplitInterface { + /** + * Layout the subassemblies vertically and insert a horizontal divider line between each subassemblies. + * @since 7 + */ + (): ColumnSplitAttribute; +} +/** + * Defines the ColumnSplit component attribute functions. + * @since 7 + */ +declare class ColumnSplitAttribute extends CommonMethod { + /** + * Indicates whether the split line can be dragged. The default value is false. + * @since 7 + */ + resizeable(value: boolean): ColumnSplitAttribute; +} +declare const ColumnSplitInstance: ColumnSplitAttribute; +declare const ColumnSplit: ColumnSplitInterface; diff --git a/build-tools/api/@internal/component/ets/common.d.ts b/build-tools/api/@internal/component/ets/common.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..70402c47b1934d2fc6dad01a64503e2adeb7c16d --- /dev/null +++ b/build-tools/api/@internal/component/ets/common.d.ts @@ -0,0 +1,2009 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Defining Component ClassDecorator * @since 7 + */ +declare const Component: ClassDecorator; + +/** + * Defining Entry ClassDecorator. + * Only API 9 and later support parameters. + * @since 9 + */ +declare const Entry: ClassDecorator & ((storage?: LocalStorage) => ClassDecorator); + +/** + * Defining Observed ClassDecorator. + * @since 7 + */ +declare const Observed: ClassDecorator; + +/** + * Defining Preview ClassDecorator. + * @since 7 + */ +declare const Preview: ClassDecorator & ((value: PreviewParams) => ClassDecorator); + +/** + * Defining BuilderParam PropertyDecorator + * @since 7 + */ +declare const BuilderParam: PropertyDecorator; + +/** + * Defining State PropertyDecorator. + * @since 7 + */ +declare const State: PropertyDecorator; + +/** + * Defining Prop PropertyDecorator. + * @since 7 + */ +declare const Prop: PropertyDecorator; + +/** + * Defining Link PropertyDecorator. + * @since 7 + */ +declare const Link: PropertyDecorator; + +/** + * Defining ObjectLink PropertyDecorator. + * @since 7 + */ +declare const ObjectLink: PropertyDecorator; + +/** + * Defining Provide PropertyDecorator. + * @since 7 + */ +declare const Provide: PropertyDecorator & ((value: string) => PropertyDecorator); + +/** + * Defining Consume PropertyDecorator. + * @since 7 + */ +declare const Consume: PropertyDecorator & ((value: string) => PropertyDecorator); + +/** + * Defining StorageProp PropertyDecorator. + * @since 7 + */ +declare const StorageProp: (value: string) => PropertyDecorator; + +/** + * Defining StorageLink PropertyDecorator. + * @since 7 + */ +declare const StorageLink: (value: string) => PropertyDecorator; + +/** + * Defining Watch PropertyDecorator. + * @since 7 + */ +declare const Watch: (value: string) => PropertyDecorator; + +/** + * Defining Builder MethodDecorator + * @since 7 + */ +declare const Builder: MethodDecorator; + +/** + * Defining Styles MethodDecorator + * @since 8 + */ +declare const Styles: MethodDecorator; + +/** + * Defining Extend MethodDecorator + * @since 7 + */ +declare const Extend: MethodDecorator & ((value: any) => MethodDecorator); + +/** + * Defining CustomDialog ClassDecorator + * @since 7 + */ +declare const CustomDialog: ClassDecorator; + +/** + * Defining LocalStorageLink PropertyDecorator. + * @since 9 + */ +declare const LocalStorageLink: (value: string) => PropertyDecorator; + +/** + * Defining LocalStorageProp PropertyDecorator. + * @since 9 + */ +declare const LocalStorageProp: (value: string) => PropertyDecorator; + +/** + * Get context. + * @StageModelOnly + * @since 9 + */ +declare function getContext(component?: Object): Object; + +/** + * Defines the data type of the interface restriction. + * @since 7 + */ +declare interface Configuration { + /** + * Set colorMode. + * @since 7 + */ + readonly colorMode: string; + + /** + * Set fontScale. + * @since 7 + */ + readonly fontScale: number; +} + +/** + * Defines the data type of the interface restriction. + * @since 8 + */ +declare interface Rectangle { + /** + * x:Horizontal coordinate + * @since 8 + */ + x?: Length; + + /** + * y:Vertical axis coordinate. + * @since 8 + */ + y?: Length; + + /** + * Sets the width of the current touchRect. + * @since 8 + */ + width?: Length; + + /** + * Sets the height of the current touchRect. + * @since 8 + */ + height?: Length; +} + +/** + * global $r function + * @since 7 + */ +declare function $r(value: string, ...params: any[]): Resource; + +/** + * global $rawfile function + * @since 7 + */ +declare function $rawfile(value: string): Resource; + +/** + * Defines the animate function params. + * @since 7 + */ +declare interface AnimateParam { + /** + * Animation duration, in ms. + * @since 7 + */ + duration?: number; + /** + * Animation playback speed. A larger value indicates faster animation playback, and a smaller value indicates slower + * animation playback. The value 0 means that there is no animation. + * @since 7 + */ + tempo?: number; + /** + * Animation curve. + * @type { string | Curve} + * @since 7 + */ + /** + * Animation curve. + * @type { string | Curve | ICurve} + * @since 9 + */ + curve?: Curve | string | ICurve; + /** + * Animation playback mode. By default, the animation is played from the beginning after the playback is complete. + * @since 7 + */ + delay?: number; + /** + * Animation playback mode. By default, the animation is played from the beginning after the playback is complete. + * @since 7 + */ + iterations?: number; + /** + * Animation playback mode. By default, the animation is played from the beginning after the playback is complete. + * @since 7 + */ + playMode?: PlayMode; + /** + * Callback invoked when the animation playback is complete. + * @since 7 + */ + onFinish?: () => void; +} + +/** + * Interface for curve object. + * @since 9 + */ +interface ICurve { + /** + * Get curve value by fraction. + * @since 9 + */ + interpolate(fraction : number) : number; +} + +/** + * Defines the motion path options. + * @since 7 + */ +declare interface MotionPathOptions { + /** + * The path info. + * @since 7 + */ + path: string; + /** + * The origin point info. + * @since 7 + */ + from?: number; + /** + * The distance point info. + * @since 7 + */ + to?: number; + /** + * The rotate info. + * @since 7 + */ + rotatable?: boolean; +} + +/** + * Defines the shard transition function params. + * @since 7 + */ +declare interface sharedTransitionOptions { + /** + * Animation duration, in ms. + * @since 7 + */ + duration?: number; + /** + * Animation duration, in ms. + * @since 7 + */ + curve?: Curve | string; + /** + * Animation playback mode. By default, the animation is played from the beginning after the playback is complete. + * @since 7 + */ + delay?: number; + /** + * The motion path info. + * @since 7 + */ + motionPath?: MotionPathOptions; + /** + * Z index info. + * @since 7 + */ + zIndex?: number; + /** + * the animate type. + * @since 7 + */ + type?: SharedTransitionEffectType; +} + +/** + * Defines the options of translate. + * @since 7 + */ +declare interface TranslateOptions { + /** + * The param of x direction. + * @since 7 + */ + x?: number | string; + /** + * The param of y direction. + * @since 7 + */ + y?: number | string; + /** + * The param of z direction. + * @since 7 + */ + z?: number | string; +} + +/** + * Defines the options of scale. + * @since 7 + */ +declare interface ScaleOptions { + /** + * The param of x direction. + * @since 7 + */ + x?: number; + /** + * The param of y direction. + * @since 7 + */ + y?: number; + /** + * The param of z direction. + * @since 7 + */ + z?: number; + /** + * The param of center point of x. + * @since 7 + */ + centerX?: number | string; + /** + * The param of center point of y. + * @since 7 + */ + centerY?: number | string; +} + +/** + * Defines the align rule options of relative container. + * @since 9 + */ +declare interface AlignRuleOption { + /** + * The param of left align. + * @since 9 + */ + left?: { anchor: string, align: HorizontalAlign }; + /** + * The param of right align. + * @since 9 + */ + right?: { anchor: string, align: HorizontalAlign }; + /** + * The param of middle align. + * @since 9 + */ + middle?: { anchor: string, align: HorizontalAlign }; + /** + * The param of top align. + * @since 9 + */ + top?: { anchor: string, align: VerticalAlign }; + /** + * The param of bottom align. + * @since 9 + */ + bottom?: { anchor: string, align: VerticalAlign }; + /** + * The param of center align. + * @since 9 + */ + center?: { anchor: string, align: VerticalAlign }; +} + +declare interface RotateOptions { + /** + * The param of x direction. + * @since 7 + */ + x?: number; + /** + * The param of y direction. + * @since 7 + */ + y?: number; + /** + * The param of z direction. + * @since 7 + */ + z?: number; + /** + * The param of center point of x. + * @since 7 + */ + centerX?: number | string; + /** + * The param of center point of y. + * @since 7 + */ + centerY?: number | string; + /** + * The param of angle. + * @since 7 + */ + angle: number | string; +} + +/** + * Defines the param of transition. + * @since 7 + */ +declare interface TransitionOptions { + /** + * Defines the param of type. + * @since 7 + */ + type?: TransitionType; + /** + * Defines the param of opacity. + * @since 7 + */ + opacity?: number; + /** + * Defines the param of translate. + * @since 7 + */ + translate?: TranslateOptions; + /** + * Defines the param of scale. + * @since 7 + */ + scale?: ScaleOptions; + /** + * Defines the param of rotate. + * @since 7 + */ + rotate?: RotateOptions; +} + +/** + * Define Preview property + * @since 9 + */ +interface PreviewParams { + /** + * Define Preview title + * @since 9 + */ + title?: string; + /** + * Define Preview width + * @since 9 + */ + width?: number; + /** + * Define Preview height + * @since 9 + */ + height?: number; + /** + * Define Preview locale + * @since 9 + */ + locale?: string; + /** + * Define Preview colorMode + * @since 9 + */ + colorMode?: string; + /** + * Define Preview deviceType + * @since 9 + */ + deviceType?: string; + /** + * Define Preview dpi + * @since 9 + */ + dpi?: number; + /** + * Define Preview orientation + * @since 9 + */ + orientation?: string; + /** + * Define Preview roundScreen + * @since 9 + */ + roundScreen?: boolean; +} + +/** + * ItemDragInfo object description + * @since 8 + */ +declare interface ItemDragInfo { + /** + * Obtains the X coordinate of the drag window, in vp. + * @since 8 + */ + x: number; + + /** + * Obtains the Y coordinate of the drag window, in vp. + * @since 8 + */ + y: number; +} + +/** + * DragItemInfo object description + * @since 8 + */ +declare interface DragItemInfo { + /** + * Uses the pixelMap object for drawing. + * @since 8 + */ + pixelMap?: PixelMap; + + /** + * Uses the custom builder for drawing, if pixelMap is set, this value is ignored. + * @since 8 + */ + builder?: CustomBuilder; + + /** + * Sets the extra info for drag event. + * @since 8 + */ + extraInfo?: string; +} + +/** + * Defining animation function. + * @since 7 + */ +declare function animateTo(value: AnimateParam, event: () => void): void; + +/** + * Converts a value in vp units to a value in px. + * @since 7 + */ +declare function vp2px(value: number): number; + +/** + * Converts a number in units of px to a number in units of vp. + * @since 7 + */ +declare function px2vp(value: number): number; + +/** + * Converts a number in fp units to a number in px. + * @since 7 + */ +declare function fp2px(value: number): number; + +/** + * Converts a number in units of px to a number in units of fp. + * @since 7 + */ +declare function px2fp(value: number): number; + +/** + * Converts a number in units of lpx to a number in units of px. + * @since 7 + */ +declare function lpx2px(value: number): number; + +/** + * Converts a number in units of px to a number in units of lpx. + * @since 7 + */ +declare function px2lpx(value: number): number; + +/** + * Defines the event target. + * @since 8 + */ +declare interface EventTarget { + /** + * Area of current target. + * @since 8 + */ + area: Area; +} + +/** + * Defines the event source type. + * @since 8 + */ +declare enum SourceType { + /** + * Unknown type. + * @since 8 + */ + Unknown, + + /** + * The mouse type. + * @since 8 + */ + Mouse, + + /** + * The touch screen type. + * @since 8 + */ + TouchScreen, +} + +/** + * Defines the Border Image Repeat Mode. + * @since 9 + */ +declare enum RepeatMode { + /** + * Repeat mode. + * @since 9 + */ + Repeat, + + /** + * Stretch mode. + * @since 9 + */ + Stretch, + + /** + * Round mode. + * @since 9 + */ + Round, + + /** + * Space mode. + * @since 9 + */ + Space, +} +/** + * enum Blur style + * @since 9 + */ + declare enum BlurStyle { + /** + * Defines the fuzzy scale. + * @since 9 + */ + Thin, + + /** + * Defines the fuzzy scale. + * @since 9 + */ + Regular, + + /** + * Defines the fuzzy scale. + * @since 9 + */ + Thick, +} + +/** + * Defines the base event. + * @since 8 + */ +declare interface BaseEvent { + /** + * Defines the current target which fires this event. + * @since 8 + */ + target: EventTarget; + + /** + * Event timestamp. + * @since 8 + */ + timestamp: number; + + /** + * the event source info. + * @since 8 + */ + source: SourceType; +} + +/** + * Border image option + * @since 9 + */ +declare interface BorderImageOption { + /** + * Border image slice + * @since 9 + */ + slice?: Length | EdgeWidths, + + /** + * Border image repeat + * @since 9 + */ + repeat?: RepeatMode, + + /** + * Border image source + * @since 9 + */ + source?: string | Resource | linearGradient, + + /** + * Border image width + * @since 9 + */ + width?: Length | EdgeWidths, + + /** + * Border image outset + * @since 9 + */ + outset?: Length | EdgeWidths, + + /** + * Border image center fill + * @since 9 + */ + fill?: boolean +} + +/** + * The tap action triggers this method invocation. + * @since 7 + */ +declare interface ClickEvent extends BaseEvent { + /** + * X coordinate of the click point relative to the left edge of the device screen. + * @since 7 + */ + screenX: number; + + /** + * The Y coordinate of the touch point relative to the upper edge of the device screen. + * @since 7 + */ + screenY: number; + + /** + * X coordinate of the click point relative to the left edge of the clicked element. + * @since 7 + */ + x: number; + + /** + * Y coordinate of the click point relative to the upper edge of the clicked element. + * @since 7 + */ + y: number; +} + +/** + * The mouse click action triggers this method invocation. + * @since 8 + */ +declare interface MouseEvent extends BaseEvent { + /** + * Mouse button of the click event. + * @since 8 + */ + button: MouseButton; + + /** + * Mouse action of the click event. + * @since 8 + */ + action: MouseAction; + + /** + * X coordinate of the click point relative to the left edge of the device screen. + * @since 8 + */ + screenX: number; + + /** + * The Y coordinate of the click point relative to the upper edge of the device screen. + * @since 8 + */ + screenY: number; + + /** + * X coordinate of the click point relative to the left edge of the clicked element. + * @since 8 + */ + x: number; + + /** + * Y coordinate of the click point relative to the upper edge of the clicked element. + * @since 8 + */ + y: number; + + /** + * The blocking event pops up. + * @since 8 + */ + stopPropagation?: () => void; +} + +/** + * Type of the touch event. + * @since 7 + */ +declare interface TouchObject { + /** + * Type of the touch event. + * @since 7 + */ + type: TouchType; + + /** + * Finger unique identifier. + * @since 7 + */ + id: number; + + /** + * X coordinate of the touch point relative to the left edge of the device screen. + * @since 7 + */ + screenX: number; + + /** + * The Y coordinate of the touch point relative to the upper edge of the device screen. + * @since 7 + */ + screenY: number; + + /** + * X coordinate of the touch point relative to the left edge of the touched element. + * @since 7 + */ + x: number; + + /** + * Y coordinate of the touch point relative to the upper edge of the touched element. + * @since 7 + */ + y: number; +} + +/** + * Touch Action Function Parameters + * @since 7 + */ +declare interface TouchEvent extends BaseEvent { + /** + * Type of the touch event. + * @since 7 + */ + type: TouchType; + + /** + * All finger information. + * @since 7 + */ + touches: TouchObject[]; + + /** + * Indicates the current changed finger information. + * @since 7 + */ + changedTouches: TouchObject[]; + + /** + * The blocking event pops up. + * @since 7 + */ + stopPropagation?: () => void; +} + +/** + * Defines the PixelMap type object for ui component. + * @since 7 + */ +declare type PixelMap = PixelMapMock; + +/** + * pixelmap object with release function. + * @systemapi + * @since 7 + */ +declare interface PixelMapMock { + /** + * release function. + * @systemapi + * @since 7 + */ + release(): void; +} + +/** + * DragEvent object description + * @since 7 + */ +declare interface DragEvent { + /** + * Obtains the X coordinate of the drag window, in vp. + * @since 7 + */ + getX(): number; + + /** + * Obtains the Y coordinate of the drag window, in vp. + * @since 7 + */ + getY(): number; +} + +/** + * KeyEvent object description: + * @since 7 + */ +declare interface KeyEvent { + /** + * Type of a key. + * @since 7 + */ + type: KeyType; + + /** + * Key code of a key + * @since 7 + */ + keyCode: number; + + /** + * Key value of a key. + * @since 7 + */ + keyText: string; + + /** + * Type of the input device that triggers the current key, such as the keyboard or handle. + * @since 7 + */ + keySource: KeySource; + + /** + * Indicates the ID of the input device that triggers the current key. + * @since 7 + */ + deviceId: number; + + /** + * Indicates the status of the key when the key is pressed. + * The value 1 indicates the pressed state, and the value 0 indicates the unpressed state. + * @since 7 + */ + metaKey: number; + + /** + * Timestamp when the key was pressed. + * @since 7 + */ + timestamp: number; + + /** + * Block event bubbling. + * @since 7 + */ + stopPropagation?: () => void; +} + +/** + * Component State Styels. + * @since 8 + */ +declare interface StateStyles { + /** + * Defines normal state styles. + * @since 8 + */ + normal?: any; + + /** + * Defines pressed state styles. + * @since 8 + */ + pressed?: any; + + /** + * Defines disabled state styles. + * @since 8 + */ + disabled?: any; + + /** + * Defines focused state styles. + * @since 8 + */ + focused?: any; + + /** + * Defines clicked state styles. + * @since 8 + */ + clicked?: any; +} + +/** + * Defines the popup options. + * @since 7 + */ +declare interface PopupOptions { + /** + * Information in the pop-up window. + * @since 7 + */ + message: string; + + /** + * placement On Top + * @since 7 + */ + placementOnTop?: boolean; + + /** + * The first button. + * @since 7 + */ + primaryButton?: { + /** + * Button text value + * @since 7 + */ + value: string; + + /** + * action + * @since 7 + */ + action: () => void; + }; + + /** + * The second button. + * @since 7 + */ + secondaryButton?: { + /** + * Button text value + * @since 7 + */ + value: string; + + /** + * action + * @since 7 + */ + action: () => void; + }; + + /** + * on State Change + * @since 7 + */ + onStateChange?: (event: { isVisible: boolean }) => void; +} + +/** + * Defines the custom popup options. + * @since 8 + */ +declare interface CustomPopupOptions { + /** + * builder of popup + * @since 8 + */ + builder: CustomBuilder; + + /** + * placement of popup + * @since 8 + */ + placement?: Placement; + + /** + * mask color of popup + * @since 8 + */ + maskColor?: Color | string | Resource | number; + + /** + * background color of popup + * @since 8 + */ + popupColor?: Color | string | Resource | number; + + /** + * whether show arrow + * @since 8 + */ + enableArrow?: boolean; + + /** + * whether hide popup when click mask + * @since 8 + */ + autoCancel?: boolean; + + /** + * on State Change + * @since 8 + */ + onStateChange?: (event: { isVisible: boolean }) => void; +} + +/** + * CommonMethod. + * @since 7 + */ +declare class CommonMethod { + /** + * constructor. + * @systemapi + * @since 7 + * @ignore + */ + constructor(); + + /** + * Sets the width of the current component. + * @since 7 + */ + width(value: Length): T; + + /** + * Sets the width of the current component. + * @since 7 + */ + height(value: Length): T; + + /** + * Sets the response region of the current component. + * @since 8 + */ + responseRegion(value: Array | Rectangle): T; + + /** + * The size of the current component. + * @since 7 + */ + size(value: SizeOptions): T; + + /** + * constraint Size: + * minWidth:minimum Width,maxWidth:maximum Width,minHeight:minimum Height ,maxHeight:maximum Height, + * @since 7 + */ + constraintSize(value: ConstraintSizeOptions): T; + + /** + * Sets the touchable of the current component + * @since 7 + */ + touchable(value: boolean): T; + + /** + * layout Weight + * @since 7 + */ + layoutWeight(value: number | string): T; + + /** + * Inner margin. + * @since 7 + */ + padding(value: Padding | Length): T; + + /** + * Outer Margin. + * @since 7 + */ + margin(value: Margin | Length): T; + + /** + * Background color + * @since 7 + */ + backgroundColor(value: ResourceColor): T; + + /** + * Background image + * src: Image address url + * @since 7 + */ + backgroundImage(src: ResourceStr, repeat?: ImageRepeat): T; + + /** + * Background image size + * @since 7 + */ + backgroundImageSize(value: SizeOptions | ImageSize): T; + + /** + * Background image position + * x:Horizontal coordinate;y:Vertical axis coordinate. + * @since 7 + */ + backgroundImagePosition(value: Position | Alignment): T; + + /** + * Background blur style. + * blurStyle:Blur style type. + * @since 9 + */ + backgroundBlurStyle(value: BlurStyle): T; + + /** + * Opacity + * @since 7 + */ + opacity(value: number | Resource): T; + + /** + * Opacity + * width:Border width;color:Border color;radius:Border radius; + * @since 7 + */ + border(value: BorderOptions): T; + + /** + * Border style + * @since 7 + */ + borderStyle(value: BorderStyle): T; + + /** + * Border style + * @since 9 + */ + borderStyle(value: EdgeStyles): T; + + /** + * Border width + * @since 7 + */ + borderWidth(value: Length): T; + + /** + * Border width + * @since 9 + */ + borderWidth(value: EdgeWidths): T; + + /** + * Border color + * @since 7 + */ + borderColor(value: ResourceColor): T; + + /** + * Border color + * @since 9 + */ + borderColor(value: EdgeColors): T; + + /** + * Border radius + * @since 7 + */ + borderRadius(value: Length): T; + + /** + * Border radius + * @since 9 + */ + borderRadius(value: BorderRadiuses): T; + + /** + * Border image + * @since 9 + */ + borderImage(value: BorderImageOption): T; + + /** + * Trigger a click event when a click is clicked. + * @since 7 + */ + onClick(event: (event?: ClickEvent) => void): T; + + /** + * Trigger a mouse hover event. + * @since 8 + */ + onHover(event: (isHover?: boolean) => void): T; + + /** + * Set hover effect. + * @since 8 + */ + hoverEffect(value: HoverEffect): T; + + /** + * Trigger a mouse event. + * @since 8 + */ + onMouse(event: (event?: MouseEvent) => void): T; + + /** + * Trigger a touch event when touched. + * @since 7 + */ + onTouch(event: (event?: TouchEvent) => void): T; + + /** + * Keyboard input + * @since 7 + */ + onKeyEvent(event: (event?: KeyEvent) => void): T; + + /** + * Set focusable. + * @since 8 + */ + focusable(value: boolean): T; + + /** + * Trigger a event when got focus. + * @since 8 + */ + onFocus(event: () => void): T; + + /** + * Trigger a event when lose focus. + * @since 8 + */ + onBlur(event: () => void): T; + + /** + * Set focus index by key tab. + * @since 9 + */ + tabIndex(index: number): T; + + /** + * animation + * @since 7 + */ + animation(value: AnimateParam): T; + + /** + * Transition parameter + * @since 7 + */ + transition(value: TransitionOptions): T; + + /** + * Bind gesture recognition. + * gesture:Bound Gesture Type,mask:GestureMask; + * @since 7 + */ + gesture(gesture: GestureType, mask?: GestureMask): T; + + /** + * Binding Preferential Recognition Gestures + * gesture:Bound Gesture Type,mask:GestureMask; + * @since 7 + */ + priorityGesture(gesture: GestureType, mask?: GestureMask): T; + + /** + * Binding gestures that can be triggered simultaneously with internal component gestures + * gesture:Bound Gesture Type,mask:GestureMask; + * @since 7 + */ + parallelGesture(gesture: GestureType, mask?: GestureMask): T; + + /** + * Adds the content blurring effect for the current component. The input parameter is the blurring radius. + * The larger the blurring radius, the more blurring the content. + * If the value is 0, the content blurring effect is not blurring. + * @since 7 + */ + blur(value: number): T; + + /** + * Adds a highlight effect to the current component. + * The input parameter is the highlight proportion. 0 indicates no highlight effect, and 1 indicates the maximum highlight proportion. + * The component is displayed as all white (percentage). + * @since 7 + */ + brightness(value: number): T; + + /** + * Adds a contrast effect to the current component. The input parameter is the contrast value. + * A larger contrast value indicates a sharper image. When the contrast value is 0, the image becomes gray. (%) + * @since 7 + */ + contrast(value: number): T; + + /** + * Adds a grayscale effect to the current component. + * The value is the gray scale conversion ratio. If the input parameter is 1.0, the gray scale image is completely converted to the gray scale image. If the input parameter is 0.0, the image does not change. + * If the input parameter is between 0.0 and 1.0, the effect changes. (Percentage) + * @since 7 + */ + grayscale(value: number): T; + + /** + * Adds a color overlay effect for the current component. The input parameter is the superimposed color. + * @since 7 + */ + colorBlend(value: Color | string | Resource): T; + + /** + * Adds a saturation effect to the current component. + * The saturation is the ratio of the color-containing component to the achromatic component (gray). + * The larger the color-containing component, the greater the saturation. + * The larger the achromatic component, the smaller the saturation. (Percentage) + * @since 7 + */ + saturate(value: number): T; + + /** + * Converts the image to sepia. Value defines the scale of the conversion. + * A value of 1 is completely sepia, and a value of 0 does not change the image. (Percentage) + * @since 7 + */ + sepia(value: number): T; + + /** + * Inverts the input image. Value defines the scale of the conversion. 100% of the value is a complete reversal. + * A value of 0% does not change the image. (Percentage) + * @since 7 + */ + invert(value: number): T; + + /** + * Adds the hue rotation effect to the current component. + * The input parameter is the rotation angle. When the input parameter is 0deg, the image does not change (the default value is 0deg), and the input parameter does not have a maximum value. + * If the value exceeds 360deg, the image is circled again. + * @since 7 + */ + hueRotate(value: number | string): T; + + /** + * Adds the background blur effect for the current component. The input parameter is the blur radius. + * The larger the blur radius, the more blurred the background. If the value is 0, the background blur is not blurred. + * @since 7 + */ + backdropBlur(value: number): T; + + /** + * Sets the translation effect during page transition. + * The value is the start point of entry and end point of exit. + * When this parameter is set together with slide, slide takes effect by default. + * @since 7 + */ + translate(value: TranslateOptions): T; + + /** + * Sets the zoom effect during page transition. The value is the start point of entry and end point of exit. + * @since 7 + */ + scale(value: ScaleOptions): T; + + /** + * Default number of occupied columns, indicating the number of occupied grid columns when the number of columns (span) of the corresponding size is not set in the useSizeType attribute. + * @since 7 + */ + gridSpan(value: number): T; + + /** + * The default offset column number indicates the number of offset columns of the current component in the start direction of the parent component when the useSizeType attribute does not set the offset of the corresponding dimension. That is, + * the current component is located in the nth column. + * @since 7 + */ + gridOffset(value: number): T; + + /** + * Sets the rotation effect during assembly transition. + * The values are the start point during insertion and the end point during deletion. + * @since 7 + */ + rotate(value: RotateOptions): T; + + /** + * Sets the transformation matrix for the current component. + * @since 7 + */ + transform(value: object): T; + + /** + * This callback is triggered when a component mounts a display. + * @since 7 + */ + onAppear(event: () => void): T; + + /** + * This callback is triggered when component uninstallation disappears. + * @since 7 + */ + onDisAppear(event: () => void): T; + + /** + * This callback is triggered when the size or position of this component change finished. + * @param event event callback. + * @since 8 + */ + onAreaChange(event: (oldValue: Area, newValue: Area) => void): T; + + /** + * Controls the display or hide of the current component. + * @since 7 + */ + visibility(value: Visibility): T; + + /** + * The percentage of the remaining space of the Flex container allocated to the component on which this property resides. + * @since 7 + */ + flexGrow(value: number): T; + + /** + * The proportion of the Flex container compression size assigned to the component on which this attribute resides. + * @since 7 + */ + flexShrink(value: number): T; + + /** + * The base dimension of the assembly on which this attribute is located in the direction of the principal axis in the Flex container. + * @since 7 + */ + flexBasis(value: number | string): T; + + /** + * Overrides the default configuration of alignItems in the Flex Layout container. + * @since 7 + */ + alignSelf(value: ItemAlign): T; + + /** + * Sets the current component and displays the priority in the layout container. This parameter is valid only in Row, Column, and Flex single-row layouts. + * @since 7 + */ + displayPriority(value: number): T; + + /** + * The sibling components in the same container are hierarchically displayed. A larger value of z indicates a higher display level. + * @since 7 + */ + zIndex(value: number): T; + + /** + * If the components of the two pages are configured with the same ID, the shared element transition is performed during transition. If the parameter is set to an empty string, the shared element transition does not occur. For details about the options parameter, see the options parameter description. + * @since 7 + */ + sharedTransition(id: string, options?: sharedTransitionOptions): T; + + /** + * Sets the sliding direction. The enumerated value supports logical AND (&) and logical OR (|). + * @since 7 + */ + direction(value: Direction): T; + + /** + * align + * @since 7 + */ + align(value: Alignment): T; + + /** + * position + * @since 7 + */ + position(value: Position): T; + + /** + * Sets the anchor point of the element when it is positioned. The base point is offset from the top start point of the element. + * @since 7 + */ + markAnchor(value: Position): T; + + /** + * Coordinate offset relative to the layout completion position. + * Setting this attribute does not affect the layout of the parent container. The position is adjusted only during drawing. + * @since 7 + */ + offset(value: Position): T; + + /** + * If the value is true, the component is available and can respond to operations such as clicking. + * If it is set to false, click operations are not responded. + * @since 7 + */ + enabled(value: boolean): T; + + /** + * Sets the number of occupied columns and offset columns for a specific device width type. + * @since 7 + */ + useSizeType(value: { + xs?: number | { span: number; offset: number }; + sm?: number | { span: number; offset: number }; + md?: number | { span: number; offset: number }; + lg?: number | { span: number; offset: number }; + }): T; + + /** + * Specifies the alignRules of relative container + * @since 9 + */ + alignRules(value: AlignRuleOption): T; + + /** + * Specifies the aspect ratio of the current component. + * @since 7 + */ + aspectRatio(value: number): T; + + /** + * After a listener is bound, the component can be dragged. After the drag occurs, a callback is triggered. + * (To be triggered, press and hold for 170 milliseconds (ms)) + * @since 8 + */ + onDragStart(event: (event?: DragEvent, extraParams?: string) => CustomBuilder | DragItemInfo): T; + + /** + * After binding, a callback is triggered when the component is dragged to the range of the component. + * @since 8 + */ + onDragEnter(event: (event?: DragEvent, extraParams?: string) => void): T; + + /** + * After binding, a callback is triggered when the drag moves within the range of a placeable component. + * @since 8 + */ + onDragMove(event: (event?: DragEvent, extraParams?: string) => void): T; + + /** + * After binding, a callback is triggered when the component is dragged out of the component range. + * @since 8 + */ + onDragLeave(event: (event?: DragEvent, extraParams?: string) => void): T; + + /** + * The component bound to this event can be used as the drag release target. + * This callback is triggered when the drag behavior is stopped within the scope of the component. + * @since 8 + */ + onDrop(event: (event?: DragEvent, extraParams?: string) => void): T; + + /** + * Add mask text to the current component. The layout is the same as that of the current component. + * @since 7 + */ + overlay(value: string, options?: { align?: Alignment; offset?: { x?: number; y?: number } }): T; + + /** + * Linear Gradient + * angle: Angle of Linear Gradient; direction:Direction of Linear Gradient; colors:Color description for gradients,repeating:repeating. + * @since 7 + */ + linearGradient(value: { + angle?: number | string; + direction?: GradientDirection; + colors: Array; + repeating?: boolean; + }): T; + + /** + * Angle Gradient + * center:is the center point of the angle gradient + * start:Start point of angle gradient + * end:End point of angle gradient + * number:number + * rotating:rotating + * colors:Color description for gradients + * repeating:repeating + * @since 7 + */ + sweepGradient(value: { + center: Array; + start?: number | string; + end?: number | string; + rotation?: number | string; + colors: Array; + repeating?: boolean; + }): T; + + /** + * Radial Gradient + * center:Center point of radial gradient + * radius:Radius of Radial Gradient + * colors:Color description for gradients + * repeating: Refill + * @since 7 + */ + radialGradient(value: { center: Array; radius: number | string; colors: Array; repeating?: boolean }): T; + + /** + * Set the motion path of the component + * path:Motion path for displacement animation, using the svg path string. + * from:Start point of the motion path. The default value is 0.0. + * to:End point of the motion path. The default value is 1.0. + * rotatble:Whether to follow the path for rotation. + * @since 7 + */ + motionPath(value: MotionPathOptions): T; + + /** + * Add a shadow effect to the current component + * @since 7 + */ + shadow(value: { + radius: number | Resource; + color?: Color | string | Resource; + offsetX?: number | Resource; + offsetY?: number | Resource; + }): T; + + /** + * When the parameter is of the Shape type, the current component is cropped according to the specified shape. + * When the parameter is of the boolean type, this parameter specifies whether to crop based on the edge contour. + * @since 7 + */ + clip(value: boolean | CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute): T; + + /** + * Applies a mask of the specified shape to the current assembly. + * @since 7 + */ + mask(value: CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute): T; + + /** + * Key. User can set an key to the component to identify it. + * @since 8 + * @systemapi + * @test + */ + key(value: string): T; + + /** + * Id. User can set an id to the component to identify it. + * @since 8 + */ + id(value: string): T; + + /** + * geometryTransition + * @since 7 + */ + geometryTransition(id: string): T; + + /** + * Popup control + * @since 7 + */ + bindPopup(show: boolean, popup: PopupOptions | CustomPopupOptions): T; + + /** + * Menu control + * @since 7 + */ + bindMenu(content: { value: string; action: () => void }[] | CustomBuilder): T; + + /** + * ContextMenu control + * @since 8 + */ + bindContextMenu(content: CustomBuilder, responseType: ResponseType): T; + + /** + * Sets styles for component state. + * @since 8 + */ + stateStyles(value: StateStyles): T; + + /** + * id for distrubte identification. + * @since 8 + */ + restoreId(value: number): T; + + /** + * Trigger a visible area change event. + * @since 9 + */ + onVisibleAreaChange(ratios: Array, event: (isVisible: boolean, currentRatio: number) => void): T; +} + +/** + * CommonAttribute for ide. + * @since 7 + */ +declare class CommonAttribute extends CommonMethod {} + +/** + * CommonInterface for ide. + * @since 7 + */ +interface CommonInterface { + (): CommonAttribute; +} + +/** + * CommonInstance for ide. + * @since 7 + */ +declare const CommonInstance: CommonAttribute; + +/** + * Common for ide. + * @since 7 + */ +declare const Common: CommonInterface; + +/** + * Defines the CustomBuilder Type. + * @since 7 + */ +declare type CustomBuilder = (() => any) | void; + +/** + * CommonShapeMethod + * @since 7 + */ +declare class CommonShapeMethod extends CommonMethod { + /** + * constructor. + * @since 7 + * @syetemapi + */ + constructor(); + + /** + * border Color + * @since 7 + */ + stroke(value: ResourceColor): T; + + /** + * Fill color. + * @since 7 + */ + fill(value: ResourceColor): T; + + /** + * Offset from the start point of the border drawing. + * @since 7 + */ + strokeDashOffset(value: number | string): T; + + /** + * Path endpoint drawing style. + * @since 7 + */ + strokeLineCap(value: LineCapStyle): T; + + /** + * Border corner drawing style. + * @since 7 + */ + strokeLineJoin(value: LineJoinStyle): T; + + /** + * Limits for drawing acute angles as bevels + * @since 7 + */ + strokeMiterLimit(value: number | string): T; + + /** + * Sets the opacity of the border. + * @since 7 + */ + strokeOpacity(value: number | string | Resource): T; + + /** + * fill Opacity + * @since 7 + */ + fillOpacity(value: number | string | Resource): T; + + /** + * Sets the width of the dividing line. + * @since 7 + */ + strokeWidth(value: Length): T; + + /** + * Indicates whether to enable anti-aliasing + * @since 7 + */ + antiAlias(value: boolean): T; + + /** + * Sets the gap for the border. + * @since 7 + */ + strokeDashArray(value: Array): T; +} + +/** + * Custom Component + * @since 7 + */ +/** + * Custom Component + * @extends CommonAttribute + * @since 9 + */ +declare class CustomComponent extends CommonAttribute { + /** + * Customize the pop-up content constructor. + * @since 7 + */ + build(): void; + + /** + * aboutToAppear Method + * @since 7 + */ + aboutToAppear?(): void; + + /** + * aboutToDisappear Method + * @since 7 + */ + aboutToDisappear?(): void; + + /** + * onPageShow Method + * @since 7 + */ + onPageShow?(): void; + + /** + * onPageHide Method + * @since 7 + */ + onPageHide?(): void; + + /** + * onBackPress Method + * @since 7 + */ + onBackPress?(): void; +} + +/** + * View + * @ignore ide should ignore this class + * @systemapi + * @since 7 + */ +declare class View { + /** + * Just use for generate tsbundle + * @ignore ide should ignore this arrtibute + * @systemapi + * @since 7 + */ + create(value: any): any; +} diff --git a/build-tools/api/@internal/component/ets/common_ts_ets_api.d.ts b/build-tools/api/@internal/component/ets/common_ts_ets_api.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..62da6dae2cc28309f56702d1b228648e5e461b82 --- /dev/null +++ b/build-tools/api/@internal/component/ets/common_ts_ets_api.d.ts @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the AppStorage interface. + * @since 7 + */ +declare class AppStorage { + /** + * Called when a link is set. + * @since 7 + */ + static Link(propName: string): any; + /** + * Called when a property is set. + * @since 7 + */ + static Prop(propName: string): any; + /** + * Called when owning or not. + * @since 7 + */ + static Has(propName: string): boolean; + /** + * Called when data is obtained. + * @since 7 + */ + static Get(propName: string): T | undefined; + /** + * Called when setting. + * @since 7 + */ + static Set(propName: string, newValue: T): boolean; + /** + * Called when setting or creating. + * @since 7 + */ + static SetOrCreate(propName: string, newValue: T): void; + /** + * Called when a deletion is made. + * @since 7 + */ + static Delete(propName: string): boolean; + /** + * Called when a dictionary is sorted. + * @since 7 + */ + static Keys(): IterableIterator; + /** + * Called when a cleanup occurs. + * @since 7 + */ + static staticClear(): boolean; + /** + * Called when the data can be changed. + * @since 7 + */ + static IsMutable(propName: string): boolean; + /** + * Called when you check how much data is stored. + * @since 7 + */ + static Size(): number; +} +/** + * Defines the Environment interface. + * @since 7 + */ +declare class Environment { + /** + * Called when a property value is checked. + * @since 7 + */ + static EnvProp(key: string, value: S): boolean; + /** + * Called when multiple property values are checked. + * @since 7 + */ + static EnvProps(props: { + key: string; + defaultValue: any; + }[]): void; + /** + * Set the key value. + * @since 7 + */ + static Keys(): Array; +} +/** + * Defines the PersistentStorage interface. + * @since 7 + */ +declare class PersistentStorage { + /** + * Called when a persistence property is stored. + * @since 7 + */ + static PersistProp(key: string, defaultValue: T): void; + /** + * Called when a property is deleted. + * @since 7 + */ + static DeleteProp(key: string): void; + /** + * Called when multiple persistence properties are stored. + * @since 7 + */ + static PersistProps(properties: { + key: string; + defaultValue: any; + }[]): void; + /** + * Set the key value. + * @since 7 + */ + static Keys(): Array; +} diff --git a/build-tools/api/@internal/component/ets/context_menu.d.ts b/build-tools/api/@internal/component/ets/context_menu.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a032e4b73e0ec23d3e6e76c1e2e176b2f5a09ff9 --- /dev/null +++ b/build-tools/api/@internal/component/ets/context_menu.d.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines Close contextMenu. + * @since 8 + */ +declare class ContextMenu { + /** + * Invoking method close. + * @since 8 + */ + static close(); +} diff --git a/build-tools/api/@internal/component/ets/counter.d.ts b/build-tools/api/@internal/component/ets/counter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9f90da67c508b331e965f132841119bb951595a1 --- /dev/null +++ b/build-tools/api/@internal/component/ets/counter.d.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Counter component, which provides corresponding increment or decrement counting operations. + * @since 7 + */ +interface CounterInterface { + /** + * Return Counter. + * @since 7 + */ + (): CounterAttribute; +} +/** + * Defines the Counter attribute functions. + * @since 7 + */ +declare class CounterAttribute extends CommonMethod { + /** + * Listen to the event that the value increases. + * @since 7 + */ + onInc(event: () => void): CounterAttribute; + /** + * Listens to the number decrease event. + * @since 7 + */ + onDec(event: () => void): CounterAttribute; +} +declare const CounterInstance: CounterAttribute; +declare const Counter: CounterInterface; diff --git a/build-tools/api/@internal/component/ets/custom_dialog_controller.d.ts b/build-tools/api/@internal/component/ets/custom_dialog_controller.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e6f8248f87c9bfdfa1f1454e279e87c78d18346c --- /dev/null +++ b/build-tools/api/@internal/component/ets/custom_dialog_controller.d.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the options of CustomDialogController. + * @since 7 + */ +declare interface CustomDialogControllerOptions { + /** + * Custom builder function. + * @since 7 + */ + builder: any; + /** + * Defines the cancel function. + * @since 7 + */ + cancel?: () => void; + /** + * Defines if use auto cancel when click on the outside of the dialog. + * @since 7 + */ + autoCancel?: boolean; + /** + * Defines the dialog alignment of the screen. + * @since 7 + */ + alignment?: DialogAlignment; + /** + * Defines the dialog offset. + * @since 7 + */ + offset?: Offset; + /** + * Defines if use costom style. + * @since 7 + */ + customStyle?: boolean; + /** + * Grid count of dialog. + * @since 8 + */ + gridCount?: number; +} +/** + * Use the CustomDialogController class to display the custom pop-up window. + * @since 7 + */ +declare class CustomDialogController { + /** + * The constructor transfers parameter settings. + * @since 7 + */ + constructor(value: CustomDialogControllerOptions); + /** + * Display the content of the customized pop-up window. If the content has been displayed, it does not take effect. + * @since 7 + */ + open(); + /** + * Closes the custom pop-up window. If the window is closed, the window does not take effect. + * @since 7 + */ + close(); +} diff --git a/build-tools/api/@internal/component/ets/data_panel.d.ts b/build-tools/api/@internal/component/ets/data_panel.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c703a36a68b637db5ca2ac1542fb25713fdb0b08 --- /dev/null +++ b/build-tools/api/@internal/component/ets/data_panel.d.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * DataPanelType enum + * @since 8 + */ +declare enum DataPanelType { + /** + * Line Type + * @since 8 + */ + Line, + /** + * Line Rainbow + * @since 8 + */ + Circle +} +/** + * Defines the options of DataPanel. + * @since 7 + */ +declare interface DataPanelOptions { + /** + * Current data value. the max length is 9. + * @since 7 + */ + values: number[]; + /** + * Maximum value of the current data. + * @since 7 + */ + max?: number; + /** + * DataPanel Type + * @since 8 + */ + type?: DataPanelType; +} +/** + * Defines the DataPanel component. + * @since 7 + */ +interface DataPanelInterface { + /** + * Return a DataPanel. + * @since 7 + */ + (options: DataPanelOptions): DataPanelAttribute; +} +/** + * Defines the DataPanel attribute functions. + * @since 7 + */ +declare class DataPanelAttribute extends CommonMethod { + /** + * Disable the special effect of the data ratio chart. + * @since 7 + */ + closeEffect(value: boolean): DataPanelAttribute; +} +declare const DataPanel: DataPanelInterface; +declare const DataPanelInstance: DataPanelAttribute; diff --git a/build-tools/api/@internal/component/ets/date_picker.d.ts b/build-tools/api/@internal/component/ets/date_picker.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..17cd0cfec9be9034bddcefd4c477dd7c9198de56 --- /dev/null +++ b/build-tools/api/@internal/component/ets/date_picker.d.ts @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the struct of DatePickerResult. + * @since 8 + */ +declare interface DatePickerResult { + /** + * Application year + * @since 8 + */ + year?: number; + /** + * Application month + * @since 8 + */ + month?: number; + /** + * Application day + * @since 8 + */ + day?: number; +} +/** + * Defines the options of DatePicker. + * @since 8 + */ +declare interface DatePickerOptions { + /** + * Specifies the start date of the date selector. + * @since 8 + */ + start?: Date; + /** + * Specifies the end date for the date selector. + * @since 8 + */ + end?: Date; + /** + * Specifies the date selector check date or time selector check time. + * @since 8 + */ + selected?: Date; +} +/** + * Defines the DatePicker Component. + * @since 8 + */ +interface DatePickerInterface { + /** + * Defines the DatePicker constructor. + * @since 8 + */ + (options?: DatePickerOptions): DatePickerAttribute; +} +/** + * Defines the DatePicker attribute functions. + * @since 8 + */ +declare class DatePickerAttribute extends CommonMethod { + /** + * Date selector: true: displays the lunar calendar. false: The lunar calendar is not displayed. + * @since 8 + */ + lunar(value: boolean): DatePickerAttribute; + /** + * This event is triggered when a DatePicker date or time is selected. + * @since 8 + */ + onChange(callback: (value: DatePickerResult) => void): DatePickerAttribute; +} +/** + * Defines the DatePickerDialogOptions for Data Picker Dialog. + * @since 8 + */ +declare interface DatePickerDialogOptions extends DatePickerOptions { + /** + * Date selector: true: displays the lunar calendar. false: The lunar calendar is not displayed. + * @since 8 + */ + lunar?: boolean; + /** + * Called when the OK button in the dialog is clicked. + * @since 8 + */ + onAccept?: (value: DatePickerResult) => void; + /** + * Called when the Cancel button in the dialog is clicked. + * @since 8 + */ + onCancel?: () => void; + /** + * This event is triggered when a DatePicker date or time is selected in dialog. + * @since 8 + */ + onChange?: (value: DatePickerResult) => void; +} +/** + * Defines DatePickerDialog which uses show method to show DatePicker dialog. + * @since 8 + */ +declare class DatePickerDialog { + /** + * Invoking method display. + * @since 8 + */ + static show(options?: DatePickerDialogOptions); +} +declare const DatePicker: DatePickerInterface; +declare const DatePickerInstance: DatePickerAttribute; diff --git a/build-tools/api/@internal/component/ets/divider.d.ts b/build-tools/api/@internal/component/ets/divider.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f690c4be5ef5ae882019eab5a0da0a39c7be7f24 --- /dev/null +++ b/build-tools/api/@internal/component/ets/divider.d.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides a divider component to separate different content blocks/content elements. + * @since 7 + */ +interface DividerInterface { + /** + * Return Divider. + * @since 7 + */ + (): DividerAttribute; +} +/** + * Defines the Divider attribute functions. + * @since 7 + */ +declare class DividerAttribute extends CommonMethod { + /** + * Indicates whether to use a horizontal splitter or a vertical splitter. + * The options are as follows: false: horizontal splitter; true: vertical splitter. + * @since 7 + */ + vertical(value: boolean): DividerAttribute; + /** + * Sets the color of the divider line. + * @since 7 + */ + color(value: ResourceColor): DividerAttribute; + /** + * Sets the width of the dividing line. + * @since 7 + */ + strokeWidth(value: number | string): DividerAttribute; + /** + * Sets the end style of the split line. The default value is Butt. + * @since 7 + */ + lineCap(value: LineCapStyle): DividerAttribute; +} +declare const Divider: DividerInterface; +declare const DividerInstance: DividerAttribute; diff --git a/build-tools/api/@internal/component/ets/ellipse.d.ts b/build-tools/api/@internal/component/ets/ellipse.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c43a6def5f82efd7a5817f131907c0e5e8780687 --- /dev/null +++ b/build-tools/api/@internal/component/ets/ellipse.d.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Ellipse drawing. + * @since 7 + */ +interface EllipseInterface { + /** + * use new function to set the value. + * @since 7 + */ + new (value?: { + width?: string | number; + height?: string | number; + }): EllipseAttribute; + /** + * Set the value. + * @since 7 + */ + (value?: { + width?: string | number; + height?: string | number; + }): EllipseAttribute; +} +/** + * @since 7 + */ +declare class EllipseAttribute extends CommonShapeMethod { +} +declare const Ellipse: EllipseInterface; +declare const EllipseInstance: EllipseAttribute; diff --git a/build-tools/api/@internal/component/ets/enums.d.ts b/build-tools/api/@internal/component/ets/enums.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8d930dab2a9cd1ef0fc8da5e953994771d3dc4f8 --- /dev/null +++ b/build-tools/api/@internal/component/ets/enums.d.ts @@ -0,0 +1,1269 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * common enum of color + * @since 7 + */ +declare enum Color { + /** + * White. + * @since 7 + */ + White, + /** + * Black. + * @since 7 + */ + Black, + /** + * Blue. + * @since 7 + */ + Blue, + /** + * Brown. + * @since 7 + */ + Brown, + /** + * Gray. + * @since 7 + */ + Gray, + /** + * Green. + * @since 7 + */ + Green, + /** + * Grey. + * @since 7 + */ + Grey, + /** + * Orange. + * @since 7 + */ + Orange, + /** + * color. + * @since 7 + */ + Pink, + /** + * Red. + * @since 7 + */ + Red, + /** + * Yellow. + * @since 7 + */ + Yellow +} +/** + * Image display mode + * @since 7 + */ +declare enum ImageFit { + /** + * Keep the aspect ratio to zoom out or zoom in so that the image is completely displayed within the display boundary. + * @since 7 + */ + Contain, + /** + * Keep the aspect ratio to zoom out or zoom in so that both sides of the image are greater than or equal to the display boundary. + * @since 7 + */ + Cover, + /** + * Adaptive display + * @since 7 + */ + Auto, + /** + * Zoom in or out without maintaining the aspect ratio so that the image fills the display boundary. + * @since 7 + */ + Fill, + /** + * Keep the aspect ratio displayed, and the image zooms out or remains unchanged. + * @since 7 + */ + ScaleDown, + /** + * Keep the original size and display it in the center. + * @since 7 + */ + None +} +/** + * Border Style + * @since 7 + */ +declare enum BorderStyle { + /** + * Displays as a series of dots with a radius of half the borderWidth. + * @since 7 + */ + Dotted, + /** + * Shows as a series of short square dashed lines. + * @since 7 + */ + Dashed, + /** + * Shows as a solid line. + * @since 7 + */ + Solid +} +/** + * Line Join Style + * @since 7 + */ +declare enum LineJoinStyle { + /** + * Connect path segments using bevels. + * @since 7 + */ + Miter, + /** + * Connect path segments using sharp corners. + * @since 7 + */ + Round, + /** + * Connect path segments using fillets. + * @since 7 + */ + Bevel +} +/** + * Function Called by Touch + * @since 7 + */ +declare enum TouchType { + /** + * Triggered when the finger is pressed. + * @since 7 + */ + Down, + /** + * Triggered when the finger is raised. + * @since 7 + */ + Up, + /** + * Triggered when the finger presses on the screen. + * @since 7 + */ + Move, + /** + * Triggers when the touch event cancels. + * @since 7 + */ + Cancel +} +/** + * Function Called by Mouse + * @since 8 + */ +declare enum MouseButton { + /** + * Mouse Left Button. + * @since 8 + */ + Left, + /** + * Mouse Right Button. + * @since 8 + */ + Right, + /** + * Mouse Middle Button. + * @since 8 + */ + Middle, + /** + * Mouse Back Button. + * @since 8 + */ + Back, + /** + * Mouse Forward Button. + * @since 8 + */ + Forward, + /** + * Mouse None Button. + * @since 8 + */ + None +} +/** + * Function Called by Mouse + * @since 8 + */ +declare enum MouseAction { + /** + * Triggered when the mouse is pressed. + * @since 8 + */ + Press, + /** + * Triggered when the mouse is released. + * @since 8 + */ + Release, + /** + * Triggered when the mouse is Moved. + * @since 8 + */ + Move, + /** + * Triggered when the mouse is Hovered. + * @since 8 + */ + Hover +} +/** + * Animation status. + * @since 7 + */ +declare enum AnimationStatus { + /** + * Initial state of the animation. + * @since 7 + */ + Initial, + /** + * The animation is playing. + * @since 7 + */ + Running, + /** + * The animation is paused. + * @since 7 + */ + Paused, + /** + * The animation is stopped. + * @since 7 + */ + Stopped +} +/** + * Sets the animation playback mode. By default, the animation starts to play again after the playback is complete. + * @since 7 + */ +declare enum Curve { + /** + * Indicates that the speed of the animation is the same from start to finish. + * @since 7 + */ + Linear, + /** + * Indicates that the animation starts at a low speed, then accelerates, and then slows down before it ends, CubicBezier(0.25, 0.1, 0.25, 1.0). + * @since 7 + */ + Ease, + /** + * Indicates that the animation starts at a low speed, CubicBezier(0.42, 0.0, 1.0, 1.0). + * @since 7 + */ + EaseIn, + /** + * Indicates that the animation ends at a low speed, CubicBezier(0.0, 0.0, 0.78, 1.0). + * @since 7 + */ + EaseOut, + /** + * Indicates that the animation starts and ends at a slow speed, CubicBezier(0.42, 0.0, 0.78, 1.0). + * @since 7 + */ + EaseInOut, + /** + * Slow-in, fast-out + * @since 7 + */ + FastOutSlowIn, + /** + * Linear Out Slow In + * @since 7 + */ + LinearOutSlowIn, + /** + * Fast OutL inear In. + * @since 7 + */ + FastOutLinearIn, + /** + * Extreme Deceleration. + * @since 7 + */ + ExtremeDeceleration, + /** + * Sharp. + * @since 7 + */ + Sharp, + /** + * Rhythm. + * @since 7 + */ + Rhythm, + /** + * Smooth. + * @since 7 + */ + Smooth, + /** + * Damping curve, CubicBezier(0.2, 0.0, 0.2, 1.0). + * @since 7 + */ + Friction +} +/** + * Sets the state before and after the animation starts. + * @since 7 + */ +declare enum FillMode { + /** + * Restores to the initial state after the playback is complete. + * @since 7 + */ + None, + /** + * Retains the state at the end of the animation when the playback is complete. + * @since 7 + */ + Forwards, + /** + * Applies the start attribute value for the period specified by animation-delay before the animation is displayed. + * @since 7 + */ + Backwards, + /** + * Both forward and backward fill modes are applied. + * @since 7 + */ + Both +} +/** + * Play Mode + * @since 7 + */ +declare enum PlayMode { + /** + * The animation plays normally. + * @since 7 + */ + Normal, + /** + * The animation plays backwards. + * @since 7 + */ + Reverse, + /** + * The animation plays forward on odd numbers (1, 3, 7...) and backward on even numbers (2, 4, 6...). + * @since 7 + */ + Alternate, + /** + * The animation plays backwards on odd numbers (1, 3, 7...) and forwards on even numbers (2, 4, 6...).. + * @since 7 + */ + AlternateReverse +} +/** + * Type of a key. + * @since 7 + */ +declare enum KeyType { + /** + * Press the key. + * @since 7 + */ + Down, + /** + * The key is released. + * @since 7 + */ + Up +} +/** + * Type of the input device that triggers the current key. + * @since 7 + */ +declare enum KeySource { + /** + * The input device type is unknown. + * @since 7 + */ + Unknown, + /** + * Set Device Type to Keyboard. + * @since 7 + */ + Keyboard +} +/** + * Edge. + * @since 7 + */ +declare enum Edge { + /** + * The top is centered horizontally. + * @since 7 + */ + Top, + /** + * Center horizontal and vertical. + * @since 7 + */ + Center, + /** + * The bottom is centered horizontally. + * @since 7 + */ + Bottom, + /** + * Cross axis direction text baseline alignment. + * @since 7 + */ + Baseline, + /** + * Align the head of the cross axis direction. + * @since 7 + */ + Start, + /** + * Middle + * @since 7 + */ + Middle, + /** + * Align the head of the cross axis direction. + * @since 7 + */ + End +} +/** + * Set Weekend + * @since 7 + */ +declare enum Week { + /** + * Monday. + * @since 7 + */ + Mon, + /** + * Tuesday. + * @since 7 + */ + Tue, + /** + * Wednesday. + * @since 7 + */ + Wed, + /** + * Thursday. + * @since 7 + */ + Thur, + /** + * Friday. + * @since 7 + */ + Fri, + /** + * Saturday. + * @since 7 + */ + Sat, + /** + * Sunday. + * @since 7 + */ + Sun +} +/** + * Sets the horizontal layout of elements. + * @since 7 + */ +declare enum Direction { + /** + * Elements are laid out from left to right. + * @since 7 + */ + Ltr, + /** + * Elements are laid out from right to left. + * @since 7 + */ + Rtl, + /** + * Use the default layout direction. + * @since 7 + */ + Auto +} +/** + * Used to set the status of the scroll bar. + * @since 7 + */ +declare enum BarState { + /** + * Not displayed. + * @since 7 + */ + Off, + /** + * On-demand display (displayed when you touch it and disappears after 2 seconds). + * @since 7 + */ + Auto, + /** + * Resident display. + * @since 7 + */ + On +} +/** + * Sliding effect + * @since 7 + */ +declare enum EdgeEffect { + /** + * Elastic physical action, sliding to the edge can continue to slide for a distance based on the initial speed or touch event, and spring back when released. + * @since 7 + */ + Spring, + /** + * Fade. + * @since 7 + */ + Fade, + /** + * Sliding to the edge has no effect. + * @since 7 + */ + None +} +/** + * Alignment enumeration description. + * @since 7 + */ +declare enum Alignment { + /** + * Top Start. + * @since 7 + */ + TopStart, + /** + * The top is centered horizontally. + * @since 7 + */ + Top, + /** + * Top tail end. + * @since 7 + */ + TopEnd, + /** + * The starting end is centered longitudinally. + * @since 7 + */ + Start, + /** + * Center horizontal and vertical. + * @since 7 + */ + Center, + /** + * The tail end is centered longitudinally. + * @since 7 + */ + End, + /** + * Bottom starting end. + * @since 7 + */ + BottomStart, + /** + * The bottom is centered horizontally. + * @since 7 + */ + Bottom, + /** + * Bottom end. + * @since 7 + */ + BottomEnd +} +/** + * TransitionType enumeration description. + * @since 7 + */ +declare enum TransitionType { + /** + * Specifies that the current transition action takes effect in all change scenarios of the component. + * @since 7 + */ + All, + /** + * Specifies the insertion scenario in which the current transition action takes effect. + * @since 7 + */ + Insert, + /** + * Specifies the deletion scenario in which the current transition action takes effect. + * @since 7 + */ + Delete +} +/** + * RelateType enumeration description + * @since 7 + */ +declare enum RelateType { + /** + * Scales the current component to fill the parent component. + * @since 7 + */ + FILL, + /** + * Scales the current component to fit the parent component. + * @since 7 + */ + FIT +} +/** + * Controls the display or hide of the current component + * @since 7 + */ +declare enum Visibility { + /** + * Show + * @since 7 + */ + Visible, + /** + * Hide, but participate in layout for placeholder. + * @since 7 + */ + Hidden, + /** + * Hides but does not participate in layout and does not take place. + * @since 7 + */ + None +} +/** + * LineCapStyle enumeration description + * @since 7 + */ +declare enum LineCapStyle { + /** + * The two ends of the dividing line are parallel lines. + * @since 7 + */ + Butt, + /** + * The two ends of the dividing line are semicircles. + * @since 7 + */ + Round, + /** + * Extends half a circle at the end of the path with a width equal to half the line width and a height equal to the line width. + * @since 7 + */ + Square +} +/** + * Axis enumeration description. + * @since 7 + */ +declare enum Axis { + /** + * Longitudinal arrangement + * @since 7 + */ + Vertical, + /** + * Horizontal arrangement. + * @since 7 + */ + Horizontal +} +/** + * HorizontalAlign enumeration description. + * @since 7 + */ +declare enum HorizontalAlign { + /** + * Aligns the start end in the language direction. + * @since 7 + */ + Start, + /** + * Center alignment. The default alignment mode is used. + * @since 7 + */ + Center, + /** + * Aligns the ends in the language direction. + * @since 7 + */ + End +} +/** + * FlexAlign enumeration description. + * @since 7 + */ +declare enum FlexAlign { + /** + * The element is aligned at the head of the principal axis, + * the first element is aligned with the head of the row, and subsequent elements are aligned with the previous one. + * @since 7 + */ + Start, + /** + * The elements are centered in the direction of the principal axis, + * and the first element is the same distance from the beginning of the row as the last element is from the end of the row. + * @since 7 + */ + Center, + /** + * The element is aligned at the tail of the principal axis, + * the last element is aligned at the end of the row, and the other elements are aligned with the next. + * @since 7 + */ + End, + /** + * Elastic elements are evenly distributed in the direction of the Flex principal axis, + * with the same distance between adjacent elements. + * The first element aligns with the beginning of the line, and the last element aligns with the end of the line. + * @since 7 + */ + SpaceBetween, + /** + * Elastic elements are evenly distributed in the direction of the Flex principal axis, + * with the same distance between adjacent elements. Half the distance between adjacent elements as the distance between + * the first element and the distance between the last element and the end of the row. + * @since 7 + */ + SpaceAround, + /** + * Elements in the Flex axis direction are evenly spaced. + * The spacing between adjacent elements, the spacing between the first element and the beginning of the row, + * and the spacing between the last element and the end of the row are the same. + * @since 7 + */ + SpaceEvenly +} +/** + * ItemAlign enumeration description + * @since 7 + */ +declare enum ItemAlign { + /** + * Use the default configuration in the Flex container. + * @since 7 + */ + Auto, + /** + * The element is in the Flex container with the cross-axis direction head aligned. + * @since 7 + */ + Start, + /** + * The element is centered in the Flex container with the cross axis direction aligned. + * @since 7 + */ + Center, + /** + * The element is bottom aligned in the Flex container with the cross axis direction. + * @since 7 + */ + End, + /** + * Element In the Flex container, the cross-axis direction text baseline is aligned. + * @since 7 + */ + Baseline, + /** + * Element In a Flex container, the fill is stretched across the axis and, when no dimension is set, to the container size. + * @since 7 + */ + Stretch +} +/** + * FlexDirection enumeration description + * @since 7 + */ +declare enum FlexDirection { + /** + * The main axis is consistent with the row direction as the layout mode. + * @since 7 + */ + Row, + /** + * The main axis is consistent with the column direction as the layout mode. + * @since 7 + */ + Column, + /** + * The layout is in the opposite direction to the Row direction. + * @since 7 + */ + RowReverse, + /** + * Layout in the opposite direction to the column. + * @since 7 + */ + ColumnReverse +} +/** + * FlexWrap enumeration description + * @since 7 + */ +declare enum FlexWrap { + /** + * The Flex container has a single row/column layout of elements, and children are allowed to go beyond the container. + * @since 7 + */ + NoWrap, + /** + * The elements of the Flex container are arranged in multiple rows or columns, and the sub-items are allowed to exceed the container. + * @since 7 + */ + Wrap, + /** + * The elements of the Flex container are arranged in reverse multiple rows/columns, and children are allowed to exceed the container. + * @since 7 + */ + WrapReverse +} +/** + * VerticalAlign enumeration description + * @since 7 + */ +declare enum VerticalAlign { + /** + * Top alignment. + * @since 7 + */ + Top, + /** + * Center alignment. The default alignment mode is used. + * @since 7 + */ + Center, + /** + * Bottom alignment. + * @since 7 + */ + Bottom +} +/** + * ImageRepeat enumeration description + * @since 7 + */ +declare enum ImageRepeat { + /** + * Do not draw the picture again. + * @since 7 + */ + NoRepeat, + /** + * Repeat the drawing only on the horizontal axis. + * @since 7 + */ + X, + /** + * Repeat the drawing only on the vertical axis. + * @since 7 + */ + Y, + /** + * Draw the picture repeatedly on both axes. + * @since 7 + */ + XY +} +/** + * ImageSize enumeration description + * @since 7 + */ +declare enum ImageSize { + /** + * Keep the scale of the original image unchanged. + * @since 7 + */ + Auto, + /** + * Default value. Keep the aspect ratio to zoom in or out the image so that both sides of the image are greater than or equal to the display boundary. + * @since 7 + */ + Cover, + /** + * Keep the aspect ratio to zoom out or zoom in so that the image is completely displayed within the display boundary. + * @since 7 + */ + Contain +} +/** + * GradientDirection enumeration description + * @since 7 + */ +declare enum GradientDirection { + /** + * Right to left. + * @since 7 + */ + Left, + /** + * From the bottom up. + * @since 7 + */ + Top, + /** + * From left to right. + * @since 7 + */ + Right, + /** + * From the top down. + * @since 7 + */ + Bottom, + /** + * Top Left + * @since 7 + */ + LeftTop, + /** + * Left Bottom + * @since 7 + */ + LeftBottom, + /** + * Right Top + * @since 7 + */ + RightTop, + /** + * Right Bottom + * @since 7 + */ + RightBottom, + /** + * None + * @since 7 + */ + None +} +/** + * SharedTransitionEffectType enumeration description + * @since 7 + */ +declare enum SharedTransitionEffectType { + /** + * The location of the destination page element remains unchanged, and you can configure the transparency animation. Currently, + * only the static effect configured for redirecting to the target page takes effect. + * @since 7 + */ + Static, + /** + * Move the source page element to the destination page element location and scale it appropriately. + * @since 7 + */ + Exchange +} +/** + * Text style + * @since 7 + */ +declare enum FontStyle { + /** + * Default style. + * @since 7 + */ + Normal, + /** + * Italic style. + * @since 7 + */ + Italic +} +/** + * The font weight of the text + * @since 7 + */ +declare enum FontWeight { + /** + * Defines a lighter value than [Inherited Value].. + * @since 7 + */ + Lighter, + /** + * Normal font. Equivalent to a digital value of 400. + * @since 7 + */ + Normal, + /** + * Defines a more general value than [Inherited Value]. + * @since 7 + */ + Regular, + /** + * Defines a value that is more centered than [Inherited Value]. + * @since 7 + */ + Medium, + /** + * Bold. Equivalent to a numeric value of 700. + * @since 7 + */ + Bold, + /** + * Defines a value that is heavier than [Inherited Value]. + * @since 7 + */ + Bolder +} +/** + * Alignment of text. + * @since 7 + */ +declare enum TextAlign { + /** + * Center the text. + * @since 7 + */ + Center, + /** + * The text is aligned in the same direction as the writing + * @since 7 + */ + Start, + /** + * The text is aligned in the opposite direction of writing + * @since 7 + */ + End +} +/** + * Declare how text overflows. + * @since 7 + */ +declare enum TextOverflow { + /** + * When the text is too long, it will be cropped and displayed. + * @since 7 + */ + Clip, + /** + * If the text is too long, the text that cannot be displayed shall be replaced by ellipsis. + * @since 7 + */ + Ellipsis, + /** + * Text is not cropped when it is too long. + * @since 7 + */ + None +} +/** + * Type of text modifier. + * @since 7 + */ +declare enum TextDecorationType { + /** + * Do not use text decorative lines. + * @since 7 + */ + None, + /** + * Underline the words. + * @since 7 + */ + Underline, + /** + * Text is in all uppercase. + * @since 7 + */ + Overline, + /** + * A modifier line that passes through the text. + * @since 7 + */ + LineThrough +} +/** + * Letter type in text + * @since 7 + */ +declare enum TextCase { + /** + * The default is normal. + * @since 7 + */ + Normal, + /** + * The text is all lowercase. + * @since 7 + */ + LowerCase, + /** + * The text is all uppercase. + * @since 7 + */ + UpperCase +} +/** + * ResponseType for contextMenu + * @since 8 + */ +declare enum ResponseType { + /** + * Right click. + * @since 8 + */ + RightClick, + /** + * Long press. + * @since 8 + */ + LongPress +} +/** + * HoverEffect enumeration description + * @since 8 + */ +declare enum HoverEffect { + /** + * Default effect + * @since 8 + */ + Auto, + /** + * Zoom in and out effect + * @since 8 + */ + Scale, + /** + * Highlight effect + * @since 8 + */ + Highlight, + /** + * None effect + * @since 8 + */ + None +} +/** + * Placement enumeration description + * @since 8 + */ +declare enum Placement { + /** + * Left placement + * @since 8 + */ + Left, + /** + * Right placement + * @since 8 + */ + Right, + /** + * Top placement + * @since 8 + */ + Top, + /** + * Bottom placement + * @since 8 + */ + Bottom, + /** + * TopLeft placement + * @since 8 + */ + TopLeft, + /** + * TopRight placement + * @since 8 + */ + TopRight, + /** + * BottomLeft placement + * @since 8 + */ + BottomLeft, + /** + * BottomRight placement + * @since 8 + */ + BottomRight, + /** + * LeftTop placement + * @since 9 + */ + LeftTop, + /** + * LeftBottom placement + * @since 9 + */ + LeftBottom, + /** + * RightTop placement + * @since 9 + */ + RightTop, + /** + * RightBottom placement + * @since 9 + */ + RightBottom +} +/** + * Indicates the share option. + * + * @since 9 + */ +declare enum CopyOption { + /** + * Share in app. + * @since 9 + */ + InApp = 0, + /** + * Share in local device. + * @since 9 + */ + LocalDevice = 1, + /** + * Share cross device. + * @since 9 + */ + CrossDevice = 2 +} diff --git a/build-tools/api/@internal/component/ets/flex.d.ts b/build-tools/api/@internal/component/ets/flex.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..26fac80798668e87de980e71429fe46673264fa2 --- /dev/null +++ b/build-tools/api/@internal/component/ets/flex.d.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the options of Flex. + * @since 7 + */ +declare interface FlexOptions { + /** + * Sets the horizontal layout of elements. + * @since 7 + */ + direction?: FlexDirection; + /** + * Whether the Flex container is a single row/column arrangement or a multi-row/column arrangement. + * @since 7 + */ + wrap?: FlexWrap; + /** + * The alignment format of the subassembly on the Flex container spindle. + * @since 7 + */ + justifyContent?: FlexAlign; + /** + * Alignment Format for Subassembly on Flex Container Cross Axis. + * @since 7 + */ + alignItems?: ItemAlign; + /** + * The alignment of multiple lines of content when there is extra space in the cross axis. + * @since 7 + */ + alignContent?: FlexAlign; +} +/** + * Provides a monthly view component to display information such as date, shift break, and schedule. + * @since 7 + */ +interface FlexInterface { + /** + * Defines the constructor of Flex. + * @since 7 + */ + (value?: FlexOptions): FlexAttribute; +} +/** + * Defines the Flex attribute functions. + * @since 7 + */ +declare class FlexAttribute extends CommonMethod { +} +declare const Flex: FlexInterface; +declare const FlexInstance: FlexAttribute; diff --git a/build-tools/api/@internal/component/ets/for_each.d.ts b/build-tools/api/@internal/component/ets/for_each.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a207ce43ab914e6023ca4d65f587e601551cf4f1 --- /dev/null +++ b/build-tools/api/@internal/component/ets/for_each.d.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * looping function. + * @since 7 + */ +interface ForEachInterface { + /** + * Set the value, array, and key. + * @since 7 + */ + (arr: Array, itemGenerator: (item: any, index?: number) => void, keyGenerator?: (item: any, index?: number) => string): ForEachInterface; +} +declare const ForEach: ForEachInterface; diff --git a/build-tools/api/@internal/component/ets/gauge.d.ts b/build-tools/api/@internal/component/ets/gauge.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f94733c23831553bf9b13d5cac6ccdb404e709b --- /dev/null +++ b/build-tools/api/@internal/component/ets/gauge.d.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the Gauge component. + * @since 8 + */ +interface GaugeInterface { + /** + * value:Current data value. + * min: Current Segment Minimum Value + * max: Current Segment Maximum Value + * @since 8 + */ + (options: { + value: number; + min?: number; + max?: number; + }): GaugeAttribute; +} +/** + * @since 8 + */ +declare class GaugeAttribute extends CommonMethod { + /** + * Sets the value for the current profile. + * @since 8 + */ + value(value: number): GaugeAttribute; + /** + * Set the start angle. Clock 0 is 0 degrees and clockwise is positive. + * @since 8 + */ + startAngle(angle: number): GaugeAttribute; + /** + * Sets the end angle position. Clock 0 is 0 degrees and clockwise is positive. + * @since 8 + */ + endAngle(angle: number): GaugeAttribute; + /** + * Set the color of the chart. You can set the solid color and segmented gradient color. + * @since 8 + */ + colors(colors: Array): GaugeAttribute; + /** + * Sets the thickness of the ring chart. + * @since 8 + */ + strokeWidth(length: Length): GaugeAttribute; +} +declare const Gauge: GaugeInterface; +declare const GaugeInstance: GaugeAttribute; diff --git a/build-tools/api/@internal/component/ets/gesture.d.ts b/build-tools/api/@internal/component/ets/gesture.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e969c598b5a109d4d8e63a7301008aac87379db6 --- /dev/null +++ b/build-tools/api/@internal/component/ets/gesture.d.ts @@ -0,0 +1,455 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Creating an Object + * @since 7 + */ +declare enum PanDirection { + /** + * Default. + * @since 7 + */ + None, + /** + * Sliding horizontally. + * @since 7 + */ + Horizontal, + /** + * Sliding left. + * @since 7 + */ + Left, + /** + * Sliding right. + * @since 7 + */ + Right, + /** + * Sliding Vertical + * @since 7 + */ + Vertical, + /** + * Sliding up. + * @since 7 + */ + Up, + /** + * Sliding Down. + * @since 7 + */ + Down, + /** + * Sliding in all directions. + * @since 7 + */ + All +} +/** + * Creating an Object + * @since 8 + */ +declare enum SwipeDirection { + /** + * Default. + * @since 8 + */ + None, + /** + * Sliding horizontally. + * @since 8 + */ + Horizontal, + /** + * Sliding Vertical + * @since 8 + */ + Vertical, + /** + * Sliding in all directions. + * @since 8 + */ + All +} +/** + * Creating an Object + * @since 7 + */ +declare enum GestureMode { + /** + * Sequential gesture recognition is performed in sequence according to the gesture registration sequence. + * @since 7 + */ + Sequence, + /** + * Simultaneous recognition. Registration gestures participate in recognition. Everything can be triggered. + * @since 7 + */ + Parallel, + /** + * Mutually exclusive recognition. Only one gesture is successfully recognized. + * @since 7 + */ + Exclusive +} +/** + * Creating an Object + * @since 7 + */ +declare enum GestureMask { + /** + * High-priority response to the current gesture.When the current gesture fails to be recognized, other gesture responses are triggered.For gestures with the same priority, responses are performed based on the recognition sequence. + * @since 7 + */ + Normal, + /** + * Ignore internal gestures and recognize the current gesture first. + * @since 7 + */ + IgnoreInternal +} +/** + * Type of the finger information. + * @since 8 + */ +interface FingerInfo { + /** + * Finger unique identifier. + * @since 8 + */ + id: number; + /** + * X coordinate of the touch point relative to the left edge of the device screen. + * @since 8 + */ + globalX: number; + /** + * The Y coordinate of the touch point relative to the upper edge of the device screen. + * @since 8 + */ + globalY: number; + /** + * X coordinate of the touch point relative to the left edge of the touched element. + * @since 8 + */ + localX: number; + /** + * Y coordinate of the touch point relative to the upper edge of the touched element. + * @since 8 + */ + localY: number; +} +/** + * Defines the Gesture Type. + * @since 7 + */ +declare type GestureType = TapGestureInterface | LongPressGestureInterface | PanGestureInterface | PinchGestureInterface | SwipeGestureInterface | RotationGestureInterface | GestureGroupInterface; +/** + * Defines event info for gesture. + * @since 7 + */ +interface GestureEvent extends BaseEvent { + /** + * Indicates whether an event is triggered repeatedly. + * Used in LongPressGesture. + * @since 7 + */ + repeat: boolean; + /** + * All finger information. + * Used in LongPressGesture and TapGesture. + * @since 8 + */ + fingerList: FingerInfo[]; + /** + * Gesture event offset X. + * The unit is vp. + * Used in PanGesture. + * @since 7 + */ + offsetX: number; + /** + * Gesture event offset Y. + * The unit is vp. + * Used in PanGesture. + * @since 7 + */ + offsetY: number; + /** + * Gesture event direction angle. + * The unit is deg. + * Used in RotationGesture and SwipeGesture. + * @since 7 + */ + angle: number; + /** + * Gesture event slide speed. + * The unit is vp. + * Used in SwipeGesture. + * @since 8 + */ + speed: number; + /** + * Scaling ratio. + * Used in PinchGesture. + * @since 7 + */ + scale: number; + /** + * X-axis coordinate of the kneading center point. + * The unit is vp. + * Used in PinchGesture. + * @since 7 + */ + pinchCenterX: number; + /** + * Y-axis coordinate of the kneading center point. + * The unit is vp. + * Used in PinchGesture. + * @since 7 + */ + pinchCenterY: number; +} +/** + * Defines TapGesture interface. + * @since 7 + */ +interface TapGestureInterface { + /** + * Set the value. + * count:Number of consecutive clicks recognized. If the value is less than 1, the default value is used. + * fingers:The hand index that triggers the click. If the value is less than 1, the default value is used. + * @since 7 + */ + (value?: { + count?: number; + fingers?: number; + }): TapGestureInterface; + /** + * Tap gesture recognition success callback. + * @since 7 + */ + onAction(event: (event?: GestureEvent) => void): TapGestureInterface; +} +/** + * Defines LongPressGesture interface. + * @since 7 + */ +interface LongPressGestureInterface { + /** + * Set the value. + * fingers: Indicates the hand index that triggers the long press. + * repeat: Indicates whether to trigger event callback continuously. + * duration: Minimum press and hold time, in milliseconds. + * @since 7 + */ + (value?: { + fingers?: number; + repeat?: boolean; + duration?: number; + }): LongPressGestureInterface; + /** + * LongPress gesture recognition success callback. + * @since 7 + */ + onAction(event: (event?: GestureEvent) => void): LongPressGestureInterface; + /** + * The LongPress gesture is successfully recognized. When the finger is lifted, the callback is triggered. + * @since 7 + */ + onActionEnd(event: (event?: GestureEvent) => void): LongPressGestureInterface; + /** + * The LongPress gesture is successfully recognized and a callback is triggered when the touch cancel event is received. + * @since 7 + */ + onActionCancel(event: () => void): LongPressGestureInterface; +} +/** + * Defines the PanGesture options. + * @since 7 + */ +declare class PanGestureOptions { + /** + * Constructor parameters. + * @since 7 + */ + constructor(value?: { + fingers?: number; + direction?: PanDirection; + distance?: number; + }); + /** + * Sets the direction attribute. + * @since 7 + */ + setDirection(value: PanDirection); + /** + * Sets the setDistance attribute. + * @since 7 + */ + setDistance(value: number); + /** + * Sets the setFingers attribute. + * @since 7 + */ + setFingers(value: number); +} +/** + * Defines the PanGesture interface. + * @since 7 + */ +interface PanGestureInterface { + /** + * Set the value. + * @since 7 + */ + (value?: { + fingers?: number; + direction?: PanDirection; + distance?: number; + } | PanGestureOptions): PanGestureInterface; + /** + * Pan gesture recognition success callback. + * @since 7 + */ + onActionStart(event: (event?: GestureEvent) => void): PanGestureInterface; + /** + * Callback when the Pan gesture is moving. + * @since 7 + */ + onActionUpdate(event: (event?: GestureEvent) => void): PanGestureInterface; + /** + * The Pan gesture is successfully recognized. When the finger is lifted, the callback is triggered. + * @since 7 + */ + onActionEnd(event: (event?: GestureEvent) => void): PanGestureInterface; + /** + * The Pan gesture is successfully recognized and a callback is triggered when the touch cancel event is received. + * @since 7 + */ + onActionCancel(event: () => void): PanGestureInterface; +} +/** + * Defines the SwipeGesture interface. + * @since 8 + */ +interface SwipeGestureInterface { + /** + * Set the value. + * @since 8 + */ + (value?: { + fingers?: number; + direction?: SwipeDirection; + speed?: number; + }): SwipeGestureInterface; + /** + * Slide gesture recognition success callback. + * @since 8 + */ + onAction(event: (event?: GestureEvent) => void): SwipeGestureInterface; +} +/** + * Defines the PinchGesture interface. + * @since 7 + */ +interface PinchGestureInterface { + /** + * Set the value. + * @since 7 + */ + (value?: { + fingers?: number; + distance?: number; + }): PinchGestureInterface; + /** + * Pan gesture recognition success callback. + * @since 7 + */ + onActionStart(event: (event?: GestureEvent) => void): PinchGestureInterface; + /** + * Callback when the Pan gesture is moving. + * @since 7 + */ + onActionUpdate(event: (event?: GestureEvent) => void): PinchGestureInterface; + /** + * The Pan gesture is successfully recognized. When the finger is lifted, the callback is triggered. + * @since 7 + */ + onActionEnd(event: (event?: GestureEvent) => void): PinchGestureInterface; + /** + * The Pan gesture is successfully recognized and a callback is triggered when the touch cancel event is received. + * @since 7 + */ + onActionCancel(event: () => void): PinchGestureInterface; +} +/** + * Defines the RotationGesture interface. + * @since 7 + */ +interface RotationGestureInterface { + /** + * Set the value. + * @since 7 + */ + (value?: { + fingers?: number; + angle?: number; + }): RotationGestureInterface; + /** + * Pan gesture recognition success callback. + * @since 7 + */ + onActionStart(event: (event?: GestureEvent) => void): RotationGestureInterface; + /** + * Callback when the Pan gesture is moving. + * @since 7 + */ + onActionUpdate(event: (event?: GestureEvent) => void): RotationGestureInterface; + /** + * The Pan gesture is successfully recognized. When the finger is lifted, the callback is triggered. + * @since 7 + */ + onActionEnd(event: (event?: GestureEvent) => void): RotationGestureInterface; + /** + * The Pan gesture is successfully recognized and a callback is triggered when the touch cancel event is received. + * @since 7 + */ + onActionCancel(event: () => void): RotationGestureInterface; +} +/** + * Defines the GestureGroup interface. + * @since 7 + */ +interface GestureGroupInterface { + /** + * Return to Obtain GestureGroup. + * @since 7 + */ + (mode: GestureMode, ...gesture: GestureType[]): GestureGroupInterface; + /** + * The Pan gesture is successfully recognized and a callback is triggered when the touch cancel event is received. + * @since 7 + */ + onCancel(event: () => void): GestureGroupInterface; +} +declare const TapGesture: TapGestureInterface; +declare const LongPressGesture: LongPressGestureInterface; +declare const PanGesture: PanGestureInterface; +declare const SwipeGesture: SwipeGestureInterface; +declare const PinchGesture: PinchGestureInterface; +declare const RotationGesture: RotationGestureInterface; +declare const GestureGroup: GestureGroupInterface; diff --git a/build-tools/api/@internal/component/ets/grid.d.ts b/build-tools/api/@internal/component/ets/grid.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4e8dc1d1607c290b163187ae7534b260fc01c766 --- /dev/null +++ b/build-tools/api/@internal/component/ets/grid.d.ts @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the grid interface. + * @since 7 + */ +interface GridInterface { + /** + * Grid is returned when the parameter is transferred. + * @since 7 + */ + (scroller?: Scroller): GridAttribute; +} +/** + * The enum of property layoutDirection + * @since 8 + */ +declare enum GridDirection { + /** + * The row direction. + * @since 8 + */ + Row, + /** + * The column direction. + * @since 8 + */ + Column, + /** + * The row reverse direction. + * @since 8 + */ + RowReverse, + /** + * The column reverse direction. + * @since 8 + */ + ColumnReverse +} +/** + * Defines the grid attibute functions. + * @since 7 + */ +declare class GridAttribute extends CommonMethod { + /** + * This parameter specifies the number of columns in the current grid layout. + * @since 7 + */ + columnsTemplate(value: string): GridAttribute; + /** + * Lets you set the number of rows in the current grid layout, + * @since 7 + */ + rowsTemplate(value: string): GridAttribute; + /** + * Allows you to set the spacing between columns. + * @since 7 + */ + columnsGap(value: Length): GridAttribute; + /** + * Lets you set the spacing between rows. + * @since 7 + */ + rowsGap(value: Length): GridAttribute; + /** + * This parameter specifies the width of the scroll bar. + * @since 7 + */ + scrollBarWidth(value: number | string): GridAttribute; + /** + * Sets the color of the scroll bar. + * @since 7 + */ + scrollBarColor(value: Color | number | string): GridAttribute; + /** + * Lets you set the spacing between rows. + * @since 7 + */ + scrollBar(value: BarState): GridAttribute; + /** + * Sets the status of the scroll bar. + * @since 7 + */ + onScrollIndex(event: (first: number) => void): GridAttribute; + /** + * cached Count + * @since 7 + */ + cachedCount(value: number): GridAttribute; + /** + * editMode + * @since 8 + */ + editMode(value: boolean): GridAttribute; + /** + * Called when judging whether it is multiSelectable. + * @since 8 + */ + multiSelectable(value: boolean): GridAttribute; + /** + * maxCount + * @since 8 + */ + maxCount(value: number): GridAttribute; + /** + * minCount + * @since 8 + */ + minCount(value: number): GridAttribute; + /** + * cellLength + * @since 8 + */ + cellLength(value: number): GridAttribute; + /** + * control GridDirection of the grid. + * @since 8 + */ + layoutDirection(value: GridDirection): GridAttribute; + /** + * control if the grid supports animation. + * @since 8 + */ + supportAnimation(value: boolean): GridAttribute; + /** + * After a listener is bound, the component can be dragged. After the drag occurs, a callback is triggered. + * (To be triggered, press and hold for 170 milliseconds (ms)) + * @since 8 + */ + onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => (() => any) | void): GridAttribute; + /** + * After binding, a callback is triggered when the component is dragged to the range of the component. + * @since 8 + */ + onItemDragEnter(event: (event: ItemDragInfo) => void): GridAttribute; + /** + * After binding, a callback is triggered when the drag moves within the range of a placeable component. + * @since 8 + */ + onItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void): GridAttribute; + /** + * After binding, a callback is triggered when the component is dragged out of the component range. + * @since 8 + */ + onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void): GridAttribute; + /** + * The component bound to this event can be used as the drag release target. + * This callback is triggered when the drag behavior is stopped within the scope of the component. + * @since 8 + */ + onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void): GridAttribute; +} +declare const Grid: GridInterface; +declare const GridInstance: GridAttribute; diff --git a/build-tools/api/@internal/component/ets/gridItem.d.ts b/build-tools/api/@internal/component/ets/gridItem.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..644193ef6be087e2e6708ad539a2ecd04d569900 --- /dev/null +++ b/build-tools/api/@internal/component/ets/gridItem.d.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Mesh container for static fixed-size layout scenarios. + * @since 7 + */ +interface GridItemInterface { + /** + * Return to get GridItem. + * @since 7 + */ + (): GridItemAttribute; +} +/** + * @since 7 + */ +declare class GridItemAttribute extends CommonMethod { + /** + * This parameter specifies the start line number of the current element. + * @since 7 + */ + rowStart(value: number): GridItemAttribute; + /** + * Specifies the end line number of the current element. + * @since 7 + */ + rowEnd(value: number): GridItemAttribute; + /** + * This parameter specifies the start column number of the current element. + * @since 7 + */ + columnStart(value: number): GridItemAttribute; + /** + * This parameter specifies the end column number of the current element. + * @since 7 + */ + columnEnd(value: number): GridItemAttribute; + /** + * This parameter specifies whether to recreate the node when the component build is triggered. + * @since 7 + */ + forceRebuild(value: boolean): GridItemAttribute; + /** + * Called when judging whether it is selectable. + * @since 8 + */ + selectable(value: boolean): GridItemAttribute; + /** + * Called when the gridItem is selected. + * @since 8 + */ + onSelect(event: (isSelected: boolean) => void): GridItemAttribute; +} +declare const GridItem: GridItemInterface; +declare const GridItemInstance: GridItemAttribute; diff --git a/build-tools/api/@internal/component/ets/grid_col.d.ts b/build-tools/api/@internal/component/ets/grid_col.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a81965ad081c3f09b85872b525030d0c31062aab --- /dev/null +++ b/build-tools/api/@internal/component/ets/grid_col.d.ts @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** +* Defines the option in number unit of grid-container child component. +* @since 9 +*/ +declare interface GridColColumnOption { + /** + * Grid Col Column Option xs + * @since 9 + */ + xs?: number; + /** + * Grid Col Column Option sm + * @since 9 + */ + sm?: number; + /** + * Grid Col Column Option md + * @since 9 + */ + md?: number; + /** + * Grid Col Column Option lg + * @since 9 + */ + lg?: number; + /** + * Grid Col Column Option xl + * @since 9 + */ + xl?: number; + /** + * Grid Col Column Option xxl + * @since 9 + */ + xxl?: number; +} +/** + * Defines the options of grid-container child component. + * @since 9 + */ +declare interface GridColOptions { + /** + * Sets the span of current gird-container item. + * @since 9 + */ + span?: number | GridColColumnOption; + /** + * Sets the offset of current gird-container item. + * @since 9 + */ + offset?: number | GridColColumnOption; + /** + * Sets the order of current gird-container item. + * @since 9 + */ + order?: number | GridColColumnOption; +} +/** + * Defines the the new version of grid-container child component. + * @since 9 + */ +interface GridColInterface { + /** + * Defines the constructor of GridContainer. + * @since 9 + */ + (optiion?: GridColOptions): GridColAttribute; +} +declare class GridColAttribute extends CommonMethod { + /** + * Sets the span of current gird-container item. + * @since 9 + */ + span(value: number | GridColColumnOption): GridRowAttribute; + /** + * Sets the offset of current gird-container item. + * @since 9 + */ + offset(value: number | GridColColumnOption): GridRowAttribute; + /** + * Sets the order of current gird-container item. + * @since 9 + */ + order(value: number | GridColColumnOption): GridRowAttribute; +} +declare const GridCol: GridColInterface; +declare const GridColInstance: GridColAttribute; diff --git a/build-tools/api/@internal/component/ets/grid_container.d.ts b/build-tools/api/@internal/component/ets/grid_container.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..038a4c72b2b385032be47cf775a3dcbdfda3fcf4 --- /dev/null +++ b/build-tools/api/@internal/component/ets/grid_container.d.ts @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the size type. + * @since 7 + */ +declare enum SizeType { + /** + * Select a value based on the device type. + * @since 7 + */ + Auto, + /** + * Select a value based on the device type. + * @since 7 + */ + XS, + /** + * Small width type device. + * @since 7 + */ + SM, + /** + * Medium width type device. + * @since 7 + */ + MD, + /** + * Large width type device. + * @since 7 + */ + LG +} +/** + * Defines the options of GridContainer. + * @since 7 + */ +declare interface GridContainerOptions { + /** + * Sets the total number of columns in the current layout. + * @since 7 + */ + columns?: number | "auto"; + /** + * Select the device width type. + * @since 7 + */ + sizeType?: SizeType; + /** + * Grid layout column spacing. + * @since 7 + */ + gutter?: number | string; + /** + * Spacing on both sides of the grid layout. + * @since 7 + */ + margin?: number | string; +} +/** + * Defines the GridContainer component. + * @since 7 + */ +interface GridContainerInterface { + /** + * Defines the constructor of GridContainer. + * @since 7 + */ + (value?: GridContainerOptions): GridContainerAttribute; +} +/** + * Defines the grid container attribute from inheritance Column + * @since 7 + */ +declare class GridContainerAttribute extends ColumnAttribute { +} +declare const GridContainer: GridContainerInterface; +declare const GridContainerInstance: GridContainerAttribute; diff --git a/build-tools/api/@internal/component/ets/grid_row.d.ts b/build-tools/api/@internal/component/ets/grid_row.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1302b58a3d331522862cbf9b1df5cc8c446669b2 --- /dev/null +++ b/build-tools/api/@internal/component/ets/grid_row.d.ts @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** +* Defines the option in length unit of grid-container component. +* @since 9 +*/ +declare interface GridRowSizeOption { + /** + * Grid Row Size Option xs + * @since 9 + */ + xs?: Length; + /** + * Grid Row Size Option sm + * @since 9 + */ + sm?: Length; + /** + * Grid Row Size Option md + * @since 9 + */ + md?: Length; + /** + * Grid Row Size Option lg + * @since 9 + */ + lg?: Length; + /** + * Grid Row Size Option xl + * @since 9 + */ + xl?: Length; + /** + * Grid Row Size Option xxl + * @since 9 + */ + xxl?: Length; +} +/** +* Defines the option in number unit of grid-container component. +* @since 9 +*/ +declare interface GridRowColumnOption { + /** + * Grid Row Column Option xs + * @since 9 + */ + xs?: number; + /** + * Grid Row Column Option sm + * @since 9 + */ + sm?: number; + /** + * Grid Row Column Option md + * @since 9 + */ + md?: number; + /** + * Grid Row Column Option lg + * @since 9 + */ + lg?: number; + /** + * Grid Row Column Option xl + * @since 9 + */ + xl?: number; + /** + * Grid Row Column Option xxl + * @since 9 + */ + xxl?: number; +} +/** +* Defines the getter of grid-container component. +* @since 9 +*/ +declare interface GetterOption { + /** + * Define x in getteroption + * @since 9 + */ + x?: Length | GridRowSizeOption; + /** + * Define y in getteroption + * @since 9 + */ + y?: Length | GridRowSizeOption; +} +/** +* Defines the breakpoint reference of grid-container component. +* @since 9 +*/ +declare enum BreakpointsReference { + /** + * Respond to breakpoint changes according to window width + * @since 9 + */ + WindowSize, + /** + * Respond to breakpoint changes according to component width + * @since 9 + */ + ComponentSize +} +/** +* Defines the direction of grid-container component. +* @since 9 +*/ +declare enum GridRowDirection { + /** + * The elements in the grid component are arranged in rows + * @since 9 + */ + Row, + /** + * The elements in the grid component are arranged in reverse order of rows + * @since 9 + */ + RowReverse +} +/** +* Defines the breakpoints of grid-container component. +* @since 9 +*/ +declare interface BreakPoints { + /** + * Breakpoint array + * @since 9 + */ + value?: Array; + /** + * Set breakpoint reference + * @since 9 + */ + reference?: BreakpointsReference; +} +/** + * Defines the options of grid-container component. + * @since 9 + */ +declare interface GridRowOptions { + /** + * grid-container layout column spacing. + * @since 9 + */ + gutter?: Length | GetterOption; + /** + * Sets the total number of columns in the current layout. + * @since 9 + */ + columns?: number | GridRowColumnOption; + /** + * grid-container layout breakpoints. + * @since 9 + */ + breakpoints?: BreakPoints; + /** + * grid-container layout direction. + * @since 9 + */ + direction?: GridRowDirection; +} +/** + * Defines the the new version of grid-container component. + * @since 9 + */ +interface GridRowInterface { + /** + * Defines the constructor of GridContainer. + * @since 9 + */ + (optiion?: GridRowOptions): GridRowAttribute; +} +declare class GridRowAttribute extends CommonMethod { + /** + * Callback triggered when the breakpoint changes + * @since 9 + */ + onBreakpointChange(callback: (breakpoints: string) => void): GridRowAttribute; +} +declare const GridRow: GridRowInterface; +declare const GridRowInstance: GridRowAttribute; diff --git a/build-tools/api/@internal/component/ets/hyperlink.d.ts b/build-tools/api/@internal/component/ets/hyperlink.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a3bb8d41812280a2546cf9cc3e125cd4f3385126 --- /dev/null +++ b/build-tools/api/@internal/component/ets/hyperlink.d.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the hyperlink interface. + * @since 7 + */ +interface HyperlinkInterface { + /** + * Return to get Hyperlink. + * adress: Web page redirected by the hyperlink component. + * content: Hyperlinks in the hyperlink component display text. + * @since 7 + */ + (address: string | Resource, content?: string | Resource): HyperlinkAttribute; +} +/** + * Defines the hyperlink attibute functions + * @since 7 + */ +declare class HyperlinkAttribute extends CommonMethod { + /** + * Set Color + * @since 7 + */ + color(value: Color | number | string | Resource): HyperlinkAttribute; +} +declare const Hyperlink: HyperlinkInterface; +declare const HyperlinkInterface: HyperlinkAttribute; diff --git a/build-tools/api/@internal/component/ets/image.d.ts b/build-tools/api/@internal/component/ets/image.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ba6a4c07e476ac293eea3c721c8a3c441e1431c --- /dev/null +++ b/build-tools/api/@internal/component/ets/image.d.ts @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @since 7 + */ +declare enum ImageRenderMode { + /** + * Render according to the original image, including colors. + * @since 7 + */ + Original, + /** + * Render the image as a template image, ignoring the color information of the image. + * @since 7 + */ + Template +} +/** + * @since 7 + */ +declare enum ImageInterpolation { + /** + * Do not use interpolated image data. + * @since 7 + */ + None, + /** + * Low usage of interpolated image data. + * @since 7 + */ + Low, + /** + * Interpolated image data is used moderately. + * @since 7 + */ + Medium, + /** + * High usage of interpolated image data may affect the speed of image rendering. + * @since 7 + */ + High +} +/** + * @since 7 + */ +interface ImageInterface { + /** + * Set src to obtain images. + * @since 7 + */ + (src: string | PixelMap | Resource): ImageAttribute; +} +/** + * @since 7 + */ +declare class ImageAttribute extends CommonMethod { + /** + * Placeholder displayed on load + * @since 7 + */ + alt(value: string | Resource): ImageAttribute; + /**match Text Direction + * @since 7 + */ + matchTextDirection(value: boolean): ImageAttribute; + /** + * Indicates whether the image follows the text direction. + * @since 7 + */ + fitOriginalSize(value: boolean): ImageAttribute; + /** + * fill Color + * @since 7 + */ + fillColor(value: ResourceColor): ImageAttribute; + /** + * Sets the zoom type of an image. + * @since 7 + */ + objectFit(value: ImageFit): ImageAttribute; + /** + * Set the repeat style of the picture + * @since 7 + */ + objectRepeat(value: ImageRepeat): ImageAttribute; + /** + * Set the auto style of the picture + * @since 7 + */ + autoResize(value: boolean): ImageAttribute; + /** + * Sets the image rendering mode. + * @since 7 + */ + renderMode(value: ImageRenderMode): ImageAttribute; + /** + * Sets the interpolation effect of an image. The interpolation effect is only magnified for the image. + * @since 7 + */ + interpolation(value: ImageInterpolation): ImageAttribute; + /** + * Specifies the picture decoding size. + * The original picture is decoded into a picture of a specified size. The unit of the number type is px. + * @since 7 + */ + sourceSize(value: { + width: number; + height: number; + }): ImageAttribute; + /** + * Sets the synchronous or asynchronous mode for image loading. + * The default parameter type is bool, and the default value is false. + * @since 8 + */ + syncLoad(value: boolean): ImageAttribute; + /** + * This callback is triggered when an image is successfully loaded. + * The size of the image source that is successfully loaded is returned, in pixels. + * @since 7 + */ + onComplete(callback: (event?: { + width: number; + height: number; + componentWidth: number; + componentHeight: number; + loadingStatus: number; + }) => void): ImageAttribute; + /** + * This callback is triggered when an exception occurs during image loading. + * @since 7 + */ + onError(callback: (event?: { + componentWidth: number; + componentHeight: number; + }) => void): ImageAttribute; + /** + * When the loaded source file is a svg image, this callback is triggered when the playback of the svg image is complete. + * If the svg image is a wireless loop image, this callback is not triggered. + * @since 7 + */ + onFinish(event: () => void): ImageAttribute; +} +declare const Image: ImageInterface; +declare const ImageInstance: ImageAttribute; diff --git a/build-tools/api/@internal/component/ets/image_animator.d.ts b/build-tools/api/@internal/component/ets/image_animator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..11706fb7624c1a35e6259966dd0b75d4b6c8e9fe --- /dev/null +++ b/build-tools/api/@internal/component/ets/image_animator.d.ts @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the ImageAnimator Interface. + * @since 7 + */ +interface ImageAnimatorInterface { + /** + * ImageAimator is returned. + * @since 7 + */ + (): ImageAnimatorAttribute; +} +/** + * Defines the ImageFrameInfo Interface. + * @since 7 + */ +interface ImageFrameInfo { + /** + * Image path + * @type { string } + * @since 7 + */ + /** + * Image path + * @type { string | Resource } + * @since 9 + */ + src: string | Resource; + /** + * Image width + * @type: { number | string } + * @since 7 + */ + width?: number | string; + /** + * Image height + * @type: { number | string } + * @since 7 + */ + height?: number | string; + /** + * Vertical coordinate of the image relative to the upper left corner of the component + * @type: { number | string } + * @since 7 + */ + top?: number | string; + /** + * Horizontal coordinate of the image relative to the upper left corner of the component + * @type: { number | string } + * @since 7 + */ + left?: number | string; + /** + * Playback duration of this image frame, in milliseconds. + * @type: { number } + * @since 7 + */ + duration?: number; +} +/** + * inheritance CommonMethod + * @since 7 + */ +declare class ImageAnimatorAttribute extends CommonMethod { + /** + * list images + * @since 7 + */ + images(value: Array): ImageAnimatorAttribute; + /** + * The default value is the initial state, which is used to control the playback status. + * @since 7 + */ + state(value: AnimationStatus): ImageAnimatorAttribute; + /** + * The unit is millisecond. + * @since 7 + */ + duration(value: number): ImageAnimatorAttribute; + /** + * Set the playback sequence. + * @since 7 + */ + reverse(value: boolean): ImageAnimatorAttribute; + /** + * Sets whether the image size is fixed to the component size. + * @since 7 + */ + fixedSize(value: boolean): ImageAnimatorAttribute; + /** + * Indicates whether to enable pre-decoding. + * @since 7 + */ + preDecode(value: number): ImageAnimatorAttribute; + /** + * Sets the state before and after the animation starts + * @since 7 + */ + fillMode(value: FillMode): ImageAnimatorAttribute; + /** + * Played once by default + * @since 7 + */ + iterations(value: number): ImageAnimatorAttribute; + /** + * Status callback, which is triggered when the animation starts to play. + * @since 7 + */ + onStart(event: () => void): ImageAnimatorAttribute; + /** + * Status callback, which is triggered when the animation pauses. + * @since 7 + */ + onPause(event: () => void): ImageAnimatorAttribute; + /** + * Status callback, triggered when the animation is replayed + * @since 7 + */ + onRepeat(event: () => void): ImageAnimatorAttribute; + /** + * Status callback, which is triggered when the animation is canceled. + * @since 7 + */ + onCancel(event: () => void): ImageAnimatorAttribute; + /** + * Status callback, which is triggered when the animation playback is complete. + * @since 7 + */ + onFinish(event: () => void): ImageAnimatorAttribute; +} +declare const ImageAnimator: ImageAnimatorInterface; +declare const ImageAnimatorInstance: ImageAnimatorAttribute; diff --git a/build-tools/api/@internal/component/ets/index-full.d.ts b/build-tools/api/@internal/component/ets/index-full.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aaadf3ba2de71619662f6f389f30d2d2ac9a82a2 --- /dev/null +++ b/build-tools/api/@internal/component/ets/index-full.d.ts @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// diff --git a/build-tools/api/@internal/component/ets/lazy_for_each.d.ts b/build-tools/api/@internal/component/ets/lazy_for_each.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5930e2073eb5d7ef00f14f6509baed681449dafc --- /dev/null +++ b/build-tools/api/@internal/component/ets/lazy_for_each.d.ts @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Data Change Listener. + * @since 7 + */ +declare interface DataChangeListener { + /** + * Data ready. + * @since 7 + */ + onDataReloaded(): void; + /** + * Data added. + * @since 7 + * @deprecated since 8 + */ + onDataAdded(index: number): void; + /** + * Data added. + * @since 8 + */ + onDataAdd(index: number): void; + /** + * Data moved. + * @since 7 + * @deprecated since 8 + */ + onDataMoved(from: number, to: number): void; + /** + * Data moved. + * @since 8 + */ + onDataMove(from: number, to: number): void; + /** + * Data deleted. + * @since 7 + * @deprecated since 8 + */ + onDataDeleted(index: number): void; + /** + * Data deleted. + * @since 8 + */ + onDataDelete(index: number): void; + /** + * Call when has data change. + * @since 7 + * @deprecated since 8 + */ + onDataChanged(index: number): void; + /** + * Call when has data change. + * @since 8 + */ + onDataChange(index: number): void; +} +/** + * Developers need to implement this interface to provide data to LazyForEach component. + * @since 7 + */ +declare interface IDataSource { + /** + * Total data count. + * @since 7 + */ + totalCount(): number; + /** + * Return the data of index. + * @since 7 + */ + getData(index: number): any; + /** + * Register data change listener. + * @since 7 + */ + registerDataChangeListener(listener: DataChangeListener): void; + /** + * Unregister data change listener. + * @since 7 + */ + unregisterDataChangeListener(listener: DataChangeListener): void; +} +/** + * Lazy loading. + * @since 7 + */ +interface LazyForEachInterface { + /** + * Enter the value to obtain the LazyForEach. + * @since 7 + */ + (dataSource: IDataSource, itemGenerator: (item: any, index?: number) => void, keyGenerator?: (item: any, index?: number) => string): LazyForEachInterface; +} +declare const LazyForEach: LazyForEachInterface; diff --git a/build-tools/api/@internal/component/ets/line.d.ts b/build-tools/api/@internal/component/ets/line.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9a9e89b0f41fb757d700449bcf936832d0894a5 --- /dev/null +++ b/build-tools/api/@internal/component/ets/line.d.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Line drawing component. + * @since 7 + */ +interface LineInterface { + /** + * Uses new to create the line. + * width: Width of the rectangle where the line resides.. + * height: Height of the rectangle where the line resides. + * @since 7 + */ + new (value?: { + width?: string | number; + height?: string | number; + }): LineAttribute; + /** + * The return value of the parameter is Line. + * width: Width of the rectangle where the line resides.. + * height: Height of the rectangle where the line resides. + * @since 7 + */ + (value?: { + width?: string | number; + height?: string | number; + }): LineAttribute; +} +/** + * inheritance CommonShapeMethod. + * @since 7 + */ +declare class LineAttribute extends CommonShapeMethod { + /** + * Coordinate of the start point of the line (relative coordinate). + * @since 7 + */ + startPoint(value: Array): LineAttribute; + /** + * Line end coordinates (relative coordinates). + * @since 7 + */ + endPoint(value: Array): LineAttribute; +} +declare const Line: LineInterface; +declare const LineInstance: LineAttribute; diff --git a/build-tools/api/@internal/component/ets/list.d.ts b/build-tools/api/@internal/component/ets/list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4ae4a8041acb72c4c178e5852ef4b53099df94b --- /dev/null +++ b/build-tools/api/@internal/component/ets/list.d.ts @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Declare scroll status + * @since 7 + */ +declare enum ScrollState { + /** + * Not activated. + * @since 7 + */ + Idle, + /** + * Scrolling status. + * @since 7 + */ + Scroll, + /** + * Drag status. + * @since 7 + */ + Fling +} +/** + * Declare list item alignment status + * @since 9 + */ +declare enum ListItemAlign { + /** + * Start position in the direction of cross axis. + * @since 9 + */ + Start, + /** + * Center position in the direction of cross axis. + * @since 9 + */ + Center, + /** + * End position in the direction of cross axis + * @since 9 + */ + End +} +/** + * The list interface is extended. + * @since 7 + */ +interface ListInterface { + /** + * Called when interface data is called. + * @since 7 + */ + (value?: { + initialIndex?: number; + space?: number | string; + scroller?: Scroller; + }): ListAttribute; +} +/** + * @since 7 + */ +declare class ListAttribute extends CommonMethod { + /** + * Called when need to decide how much lanes the list will show. + * @since 9 + */ + lanes(value: number | LengthConstrain): ListAttribute; + /** + * Called when need to decide how to align lanes in the direction of the cross axis. + * @since 9 + */ + alignListItem(value: ListItemAlign): ListAttribute; + /** + * Called when the arrangement direction of the list component is set. + * @since 7 + */ + listDirection(value: Axis): ListAttribute; + /** + * Called when the display mode of the side slider is set. + * @since 7 + */ + scrollBar(value: BarState): ListAttribute; + /** + * Called when the sliding effect is set. + * @since 7 + */ + edgeEffect(value: EdgeEffect): ListAttribute; + /** + * Called when the ListItem split line style is set. + * @since 7 + */ + divider(value: { + strokeWidth: Length; + color?: ResourceColor; + startMargin?: Length; + endMargin?: Length; + } | null): ListAttribute; + /** + * Called when judging whether it is in editable mode. + * @since 7 + */ + editMode(value: boolean): ListAttribute; + /** + * Called when judging whether it is multiSelectable. + * @since 8 + */ + multiSelectable(value: boolean): ListAttribute; + /** + * Called when the minimum number of list item caches is set for long list deferred loading. + * @since 7 + */ + cachedCount(value: number): ListAttribute; + /** + * Called when setting whether to enable chain linkage dynamic effect. + * @since 7 + */ + chainAnimation(value: boolean): ListAttribute; + /** + * Called when the offset and status callback of the slide are set. + * @since 7 + */ + onScroll(event: (scrollOffset: number, scrollState: ScrollState) => void): ListAttribute; + /** + * Called when the start and end positions of the display change. + * @since 7 + */ + onScrollIndex(event: (start: number, end: number) => void): ListAttribute; + /** + * Called when the list begins to arrive. + * @since 7 + */ + onReachStart(event: () => void): ListAttribute; + /** + * Called when the list reaches the end. + * @since 7 + */ + onReachEnd(event: () => void): ListAttribute; + /** + * Called when the slider stops. + * @since 7 + */ + onScrollStop(event: () => void): ListAttribute; + /** + * Called when a list item is deleted. + * @since 7 + */ + onItemDelete(event: (index: number) => boolean): ListAttribute; + /** + * Called when a list item is moved. + * @since 7 + */ + onItemMove(event: (from: number, to: number) => boolean): ListAttribute; + /** + * After a listener is bound, the component can be dragged. After the drag occurs, a callback is triggered. + * (To be triggered, press and hold for 170 milliseconds (ms)) + * @since 8 + */ + onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => ((() => any) | void)): ListAttribute; + /** + * After binding, a callback is triggered when the component is dragged to the range of the component. + * @since 8 + */ + onItemDragEnter(event: (event: ItemDragInfo) => void): ListAttribute; + /** + * After binding, a callback is triggered when the drag moves within the range of a placeable component. + * @since 8 + */ + onItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void): ListAttribute; + /** + * After binding, a callback is triggered when the component is dragged out of the component range. + * @since 8 + */ + onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void): ListAttribute; + /** + * The component bound to this event can be used as the drag release target. + * This callback is triggered when the drag behavior is stopped within the scope of the component. + * @since 8 + */ + onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void): ListAttribute; + /** + * Event called when list will scroll. + * @since 9 + */ + onScrollBegin(event: (dx: number, dy: number) => { + dxRemain: number; + dyRemain: number; + }): ListAttribute; +} +declare const List: ListInterface; +declare const ListInstance: ListAttribute; diff --git a/build-tools/api/@internal/component/ets/list_item.d.ts b/build-tools/api/@internal/component/ets/list_item.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..102f531aaf1bb3b35a63daefb4249c600b486716 --- /dev/null +++ b/build-tools/api/@internal/component/ets/list_item.d.ts @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Declare item ceiling attribute. + * @since 7 + */ +declare enum Sticky { + /** + * No sticky. + * @since 7 + */ + None, + /** + * Normal mode + * @since 7 + */ + Normal, + /** + * Set opacity. + * @since 7 + */ + Opacity +} +/** + * Declare whether the ListItem element is editable. + * @since 7 + */ +declare enum EditMode { + /** + * Unrestricted operations. + * @since 7 + */ + None, + /** + * Deleteable. + * @since 7 + */ + Deletable, + /** + * Movable. + * @since 7 + */ + Movable +} +/** + * @since 7 + */ +/** + * Values in the list + * @since 7 + */ +interface ListItemInterface { + /** + * Called when an interface is used. + * @since 7 + */ + (value?: string): ListItemAttribute; +} +/** + * @since 7 + */ +declare class ListItemAttribute extends CommonMethod { + /** + * Called when setting whether item is ceiling effect. + * @since 7 + */ + sticky(value: Sticky): ListItemAttribute; + /** + * Called when judging whether it is editable. + * @since 7 + */ + editable(value: boolean | EditMode): ListItemAttribute; + /** + * Called when judging whether it is selectable. + * @since 8 + */ + selectable(value: boolean): ListItemAttribute; + /** + * Called when the listItem is selected. + * @since 8 + */ + onSelect(event: (isSelected: boolean) => void): ListItemAttribute; +} +/** + * @since 7 + */ +declare const ListItemInstance: ListItemAttribute; +declare const ListItem: ListItemInterface; diff --git a/build-tools/api/@internal/component/ets/loading_progress.d.ts b/build-tools/api/@internal/component/ets/loading_progress.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa9664300afe960939a6fb1a4548f8657c94b622 --- /dev/null +++ b/build-tools/api/@internal/component/ets/loading_progress.d.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Load style of progress bar. + * @since 8 + */ +declare enum LoadingProgressStyle { + /** + * Default style. + * @since 8 + */ + Default, + /** + * Announcement style. + * @since 8 + */ + Circular, + /** + * The style of the track. + * @since 8 + */ + Orbital +} +/** + * Provides an interface for extending the loading progress. + * @since 8 + */ +interface LoadingProgressInterface { + /** + * Called when the progress bar progress is viewed. + * @since 8 + */ + (): LoadingProgressAttribute; +} +/** + * Declare the progress bar being loaded + * @since 8 + */ +declare class LoadingProgressAttribute extends CommonMethod { + /** + * Load the color of the progress bar. + * @since 8 + */ + color(value: ResourceColor): LoadingProgressAttribute; +} +/** + * @since 8 + */ +declare const LoadingProgress: LoadingProgressInterface; +/** + * Loading Progress Extensions on Declarative Classes + * @since 8 + */ +declare const LoadingProgressInstance: LoadingProgressAttribute; diff --git a/build-tools/api/@internal/component/ets/marquee.d.ts b/build-tools/api/@internal/component/ets/marquee.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d7f68b710a1c9413bfa5e396fdc635e272c9338 --- /dev/null +++ b/build-tools/api/@internal/component/ets/marquee.d.ts @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides the interface for the marquee attributes. + * @since 8 + */ +interface MarqueeInterface { + /** + * Create marquee. + * @since 8 + */ + (value: { + start: boolean; + step?: number; + loop?: number; + fromStart?: boolean; + src: string; + }): MarqueeAttribute; +} +/** + * Declares marquee properties. + * @since 8 + */ +declare class MarqueeAttribute extends CommonMethod { + /** + * Set marquee font Color. + * @since 8 + */ + fontColor(value: ResourceColor): MarqueeAttribute; + /** + * Set marquee font size. + * @since 8 + */ + fontSize(value: Length): MarqueeAttribute; + /** + * Set marquee allow scale. + * @since 8 + */ + allowScale(value: boolean): MarqueeAttribute; + /** + * Set marquee font weight. + * @since 8 + */ + fontWeight(value: number | FontWeight | string): MarqueeAttribute; + /** + * Set marquee font family. + * @since 8 + */ + fontFamily(value: string | Resource): MarqueeAttribute; + /** + * Called when scrolling starts. + * @since 8 + */ + onStart(event: () => void): MarqueeAttribute; + /** + * Called when scrolling to the bottom. + * @since 8 + */ + onBounce(event: () => void): MarqueeAttribute; + /** + * Called when scrolling is complete. + * @since 8 + */ + onFinish(event: () => void): MarqueeAttribute; +} +declare const Marquee: MarqueeInterface; +declare const MarqueeInstance: MarqueeAttribute; diff --git a/build-tools/api/@internal/component/ets/matrix2d.d.ts b/build-tools/api/@internal/component/ets/matrix2d.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..96baa7157d39cf21581672a454c3be311a4048eb --- /dev/null +++ b/build-tools/api/@internal/component/ets/matrix2d.d.ts @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * 2D transformation matrix, supporting rotation, translation, and scaling of the X-axis and Y-axis + * @since 8 + */ +declare class Matrix2D { + /** + * Horizontal Zoom + * @since 8 + */ + scaleX?: number; + /** + * Vertical Tilt + * @since 8 + */ + rotateY?: number; + /** + * Horizontal Tilt + * @since 8 + */ + rotateX?: number; + /** + * Vertical Zoom + * @since 8 + */ + scaleY?: number; + /** + * Horizontal movement + * @since 8 + */ + translateX?: number; + /** + * Vertical movement + * @since 8 + */ + translateY?: number; + /** + * Transforms the current 2D matrix back to the identity matrix (i.e., without any rotational + * translation scaling effect) + * @since 8 + */ + identity(): Matrix2D; + /** + * Transform the current 2D matrix into an inverse matrix (that is, the transformation effect + * is the opposite effect of the original) + * @since 8 + */ + invert(): Matrix2D; + /** + * The matrix is superimposed in right multiplication mode. When the input parameter is empty, + * the matrix is superimposed. + * @param other Matrix to be superimposed + * @since 8 + */ + multiply(other?: Matrix2D): Matrix2D; + /** + * Adds the rotation effect of the X and Y axes to the current matrix. + * @param rx Rotation effect of the X axis + * @param ry Rotation effect of the Y-axis + * @since 8 + */ + rotate(rx?: number, ry?: number): Matrix2D; + /** + * Adds the translation effect of the X and Y axes to the current matrix. + * @param tx X-axis translation effect + * @param ty Y-axis translation effect + * @since 8 + */ + translate(tx?: number, ty?: number): Matrix2D; + /** + * Adds the scaling effect of the X and Y axes to the current matrix. + * @param sx X-axis scaling effect + * @param sy Y-axis scaling effect + * @since 8 + */ + scale(sx?: number, sy?: number): Matrix2D; + /** + * Constructs a 2D change matrix object. The default value is the unit matrix. + * @since 8 + */ + constructor(); +} diff --git a/build-tools/api/@internal/component/ets/navigation.d.ts b/build-tools/api/@internal/component/ets/navigation.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9449b5df03ee615314deb19df6e46f96b8620c36 --- /dev/null +++ b/build-tools/api/@internal/component/ets/navigation.d.ts @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Naivagtion title mode. + * @since 8 + */ +declare enum NavigationTitleMode { + /** + * The title is free mode. + * @since 8 + */ + Free = 0, + /** + * The title is full mode. + * @since 8 + */ + Full, + /** + * The title is mini mode. + * @since 8 + */ + Mini +} +declare interface NavigationMenuItem { + /** + * The value of navigation menu item. + * @since 8 + */ + value: string; + /** + * The icon of navigation menu item. + * @since 8 + */ + icon?: string; + /** + * Trigger by navigation menu item click. + * @since 8 + */ + action?: () => void; +} +/** + * Provide navigator view interface + * @since 8 + */ +interface NavigationInterface { + /** + * Called when the navigator view interface is used. + * @since 8 + */ + (): NavigationAttribute; +} +/** + * Declare Navigation view properties. + * @since 8 + */ +declare class NavigationAttribute extends CommonMethod { + /** + * Navigation title + * @since 8 + */ + title(value: string | CustomBuilder): NavigationAttribute; + /** + * Navigation subtitle + * @since 8 + */ + subTitle(value: string): NavigationAttribute; + /** + * Hide navigation bar + * @since 8 + */ + hideTitleBar(value: boolean): NavigationAttribute; + /** + * Hide navigation back button + * @since 8 + */ + hideBackButton(value: boolean): NavigationAttribute; + /** + * Navigation title mode + * @since 8 + */ + titleMode(value: NavigationTitleMode): NavigationAttribute; + /** + * Navigation title bar's menus + * @since 8 + */ + menus(value: Array | CustomBuilder): NavigationAttribute; + /** + * Tool bar + * @since 8 + */ + toolBar(value: object | CustomBuilder): NavigationAttribute; + /** + * Hide tool bar + * @since 8 + */ + hideToolBar(value: boolean): NavigationAttribute; + /** + * Trigger callback when title mode change finished at free mode. + * @since 8 + */ + onTitleModeChange(callback: (titleMode: NavigationTitleMode) => void): NavigationAttribute; +} +declare const Navigation: NavigationInterface; +declare const NavigationInstance: NavigationAttribute; diff --git a/build-tools/api/@internal/component/ets/navigator.d.ts b/build-tools/api/@internal/component/ets/navigator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c8a2de87c7d932a213a4eaa068ff6c58572ecad --- /dev/null +++ b/build-tools/api/@internal/component/ets/navigator.d.ts @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Route jump. + * @since 7 + */ +declare enum NavigationType { + /** + * Jump to the next page. + * @since 7 + */ + Push, + /** + * Return to the previous page. + * @since 7 + */ + Back, + /** + * Replace page. + * @since 7 + */ + Replace +} +/** + * Create route + * @since 7 + */ +interface NavigatorInterface { + /** + * Called when the route jumps. + * @since 7 + */ + (value?: { + target: string; + type?: NavigationType; + }): NavigatorAttribute; + /** + * Called when using the navigator. + * @since 7 + */ + (): NavigatorAttribute; +} +/** + * Declare navigator properties. + * @since 7 + */ +declare class NavigatorAttribute extends CommonMethod { + /** + * Called when determining whether the routing component is active. + * @since 7 + */ + active(value: boolean): NavigatorAttribute; + /** + * Called when determining whether the routing component is active. + * @since 7 + */ + type(value: NavigationType): NavigatorAttribute; + /** + * Called when the path to the specified jump target page is set. + * @since 7 + */ + target(value: string): NavigatorAttribute; + /** + * Called when data is passed to the target page at the same time during jump. + * @since 7 + */ + params(value: object): NavigatorAttribute; +} +declare const Navigator: NavigatorInterface; +declare const NavigatorInstance: NavigatorAttribute; diff --git a/build-tools/api/@internal/component/ets/page_transition.d.ts b/build-tools/api/@internal/component/ets/page_transition.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5e89980a96e4a39068a0a397b4792efb21cea78 --- /dev/null +++ b/build-tools/api/@internal/component/ets/page_transition.d.ts @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Declare the jump method. + * @since 7 + */ +declare enum RouteType { + /** + * The page is not redirected. + * @since 7 + */ + None, + /** + * Go to the next page. + * @since 7 + */ + Push, + /** + * Redirect to a specified page. + * @since 7 + */ + Pop +} +/** + * Declare the sliding effect of transition. + * @since 7 + */ +declare enum SlideEffect { + /** + * Swipe left. + * @since 7 + */ + Left, + /** + * Swipe right. + * @since 7 + */ + Right, + /** + * Swipe top. + * @since 7 + */ + Top, + /** + * Swipe bottom. + * @since 7 + */ + Bottom +} +/** + * Provides interfaces for common transitions. + * @since 7 + */ +declare class CommonTransition { + /** + * Called when a transition method is required. + * @since 7 + */ + constructor(); + /** + * Called when the slide in effect of the transition is set. + * @since 7 + */ + slide(value: SlideEffect): T; + /** + * Called when the translation effect of page transition is set. + * @since 7 + */ + translate(value: { + x?: number | string; + y?: number | string; + z?: number | string; + }): T; + /** + * Called when setting the zoom effect of page transition. + * @since 7 + */ + scale(value: { + x?: number; + y?: number; + z?: number; + centerX?: number | string; + centerY?: number | string; + }): T; + /** + * Called when the transparency value of the starting point of entry or the ending point of exit is set. + * @since 7 + */ + opacity(value: number): T; +} +/** + * Provides an interface for page rotation mode. + * @since 7 + */ +interface PageTransitionEnterInterface extends CommonTransition { + /** + * Called when page Jump animation is used. + * @since 7 + */ + (value: { + type?: RouteType; + duration?: number; + curve?: Curve | string; + delay?: number; + }): PageTransitionEnterInterface; + /** + * Called when the incoming parameter is the normalized progress of the current incoming animation. + * @since 7 + */ + onEnter(event: (type?: RouteType, progress?: number) => void): PageTransitionEnterInterface; +} +/** + * Provide an interface to exit the transition. + * @since 7 + */ +interface PageTransitionExitInterface extends CommonTransition { + /** + * Called when the transition is delayed. + * @since 7 + */ + (value: { + type?: RouteType; + duration?: number; + curve?: Curve | string; + delay?: number; + }): PageTransitionExitInterface; + /** + * Called when the input parameter is the normalized progress of the current exit animation. + * @since 7 + */ + onExit(event: (type?: RouteType, progress?: number) => void): PageTransitionExitInterface; +} +declare const PageTransitionEnter: PageTransitionEnterInterface; +declare const PageTransitionExit: PageTransitionExitInterface; diff --git a/build-tools/api/@internal/component/ets/panel.d.ts b/build-tools/api/@internal/component/ets/panel.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1faab4b2d27310f53554ea025a50c8e7e239fafb --- /dev/null +++ b/build-tools/api/@internal/component/ets/panel.d.ts @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Sets the initial state of the slidable panel. + * @since 7 + */ +declare enum PanelMode { + /** + * Minimum state. + * @since 7 + */ + Mini, + /** + * SHalf-screen-like status + * @since 7 + */ + Half, + /** + * Class Full Screen Status. + * @since 7 + */ + Full +} +/** + * Sets the type of sliding panel. + * @since 7 + */ +declare enum PanelType { + /** + * The switch between the minibar and full-screen display is provided. + * @since 7 + */ + Minibar, + /** + * Permanent content display class. + * The switchover effect is provided in three sizes: large (full-screen), medium (half-screen), and small. + * @since 7 + */ + Foldable, + /** + * Temporary content display area. + * The switchover effect is provided in three sizes: large (full-screen), medium (half-screen), and small. + * @since 7 + */ + Temporary +} +/** + * Provides a sliding panel interface. + * @since 7 + */ +interface PanelInterface { + /** + * Called when the panel slidable panel pops up. + * @since 7 + */ + (show: boolean): PanelAttribute; +} +/** + * @since 7 + */ +declare class PanelAttribute extends CommonMethod { + /** + * Called when the initial state of the slidable panel is set. + * @since 7 + */ + mode(value: PanelMode): PanelAttribute; + /** + * Called when the slidable panel type is set. + * @since 7 + */ + type(value: PanelType): PanelAttribute; + /** + * Called when determining whether dragbar exists. + * @since 7 + */ + dragBar(value: boolean): PanelAttribute; + /** + * Called when the height in the full state is specified. + * @since 7 + */ + fullHeight(value: number | string): PanelAttribute; + /** + * Called when the height in the half state is specified. + * @since 7 + */ + halfHeight(value: number | string): PanelAttribute; + /** + * Called when the height in the mini state is specified. + * @since 7 + */ + miniHeight(value: number | string): PanelAttribute; + /** + * Called when the panel slidable panel pops up. + * @since 7 + */ + show(value: boolean): PanelAttribute; + /** + * Called when the state of the slidable panel changes. + * @since 7 + */ + onChange(event: ( + /** + * Width of content area. + * @since 7 + */ + width: number, + /** + * Height of content area. + * @since 7 + */ + height: number, + /** + * Initial state. + * @since 7 + */ + mode: PanelMode) => void): PanelAttribute; +} +declare const Panel: PanelInterface; +declare const PanelInstance: PanelAttribute; diff --git a/build-tools/api/@internal/component/ets/path.d.ts b/build-tools/api/@internal/component/ets/path.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4b971aecdb23c37cbb17e99a551495d842fb7036 --- /dev/null +++ b/build-tools/api/@internal/component/ets/path.d.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides the path drawing interface. + * @since 7 + */ +interface PathInterface { + /** + * Use new to create Path. + * @since 7 + */ + new (value?: { + width?: number | string; + height?: number | string; + commands?: string; + }): PathAttribute; + /** + * Called when drawing path. + * @since 7 + */ + (value?: { + width?: number | string; + height?: number | string; + commands?: string; + }): PathAttribute; +} +/** + * @since 7 + */ +declare class PathAttribute extends CommonShapeMethod { + /** + * Called when the command string drawn by the path is set. + * @since 7 + */ + commands(value: string): PathAttribute; +} +declare const Path: PathInterface; +declare const PathInstance: PathAttribute; diff --git a/build-tools/api/@internal/component/ets/pattern_lock.d.ts b/build-tools/api/@internal/component/ets/pattern_lock.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..570fef76e52b7819af046c339c672cc184e98236 --- /dev/null +++ b/build-tools/api/@internal/component/ets/pattern_lock.d.ts @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides methods for control pattern lock component. + * @since 9 + */ +declare class PatternLockController { + /** + * constructor. + */ + constructor(); + /** + * Reset pattern lock. + */ + reset(); +} +/** + * Provides an interface for generating PatternLock. + * @since 9 + */ +interface PatternLockInterface { + (controller?: PatternLockController): PatternLockAttribute; +} +/** + * @since 9 + */ +declare class PatternLockAttribute extends CommonMethod { + /** + * The square side length of pattern lock component. + * @since 9 + */ + sideLength(value: Length): PatternLockAttribute; + /** + * Circle radius. + * @since 9 + */ + circleRadius(value: Length): PatternLockAttribute; + /** + * The background color. + * @since 9 + */ + backgroundColor(value: ResourceColor): PatternLockAttribute; + /** + * Regular color. + * @since 9 + */ + regularColor(value: ResourceColor): PatternLockAttribute; + /** + * The color when cell is selected. + * @since 9 + */ + selectedColor(value: ResourceColor): PatternLockAttribute; + /** + * The color when cell is active state. + * @since 9 + */ + activeColor(value: ResourceColor): PatternLockAttribute; + /** + * The path line color. + * @since 9 + */ + pathColor(value: ResourceColor): PatternLockAttribute; + /** + * The path line stroke width. + * @since 9 + */ + pathStrokeWidth(value: number | string): PatternLockAttribute; + /** + * Called when the pattern input completed. + * @since 9 + */ + onPatternComplete(callback: (input: Array) => void): PatternLockAttribute; + /** + * Called when judging whether the input state can be reset by touch pattern lock. + * @since 9 + */ + autoReset(value: boolean): PatternLockAttribute; +} +declare const PatternLock: PatternLockInterface; +declare const PatternLockInstance: PatternLockAttribute; diff --git a/build-tools/api/@internal/component/ets/polygon.d.ts b/build-tools/api/@internal/component/ets/polygon.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..baf2cf7ec7ae119cf8d4220dafff0ac5f676e2d9 --- /dev/null +++ b/build-tools/api/@internal/component/ets/polygon.d.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides the polygon drawing interface. + * @since 7 + */ +interface PolygonInterface { + /** + * Uses new to create Polygon. + * @since 7 + */ + new (value?: { + width?: string | number; + height?: string | number; + }): PolygonAttribute; + /** + * Called when drawing a polygon. + * @since 7 + */ + (value?: { + width?: string | number; + height?: string | number; + }): PolygonAttribute; +} +declare class PolygonAttribute extends CommonShapeMethod { + /** + * Called when the vertex coordinate list of a polygon is set. + * @since 7 + */ + points(value: Array): PolygonAttribute; +} +declare const Polygon: PolygonInterface; +declare const PolygonInstance: PolygonAttribute; diff --git a/build-tools/api/@internal/component/ets/polyline.d.ts b/build-tools/api/@internal/component/ets/polyline.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..36f199f9a879867515504c1a91d0979c5ce556cc --- /dev/null +++ b/build-tools/api/@internal/component/ets/polyline.d.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides an interface for drawing polylines. + * @since 7 + */ +interface PolylineInterface { + /** + * Uses new to create Polyline. + * @since 7 + */ + new (value?: { + width?: string | number; + height?: string | number; + }): PolylineAttribute; + /** + * Called when using the draw fold. + * @since 7 + */ + (value?: { + width?: string | number; + height?: string | number; + }): PolylineAttribute; +} +/** + * @since 7 + */ +declare class PolylineAttribute extends CommonShapeMethod { + /** + * Called when the polyline is set to pass through the coordinate point list. + * @since 7 + */ + points(value: Array): PolylineAttribute; +} +declare const Polyline: PolylineInterface; +declare const PolylineInstance: PolylineAttribute; diff --git a/build-tools/api/@internal/component/ets/progress.d.ts b/build-tools/api/@internal/component/ets/progress.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7462ac7977de3e013e386b3de4d664444274aba4 --- /dev/null +++ b/build-tools/api/@internal/component/ets/progress.d.ts @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the option of Progress. + * @since 7 + */ +declare interface ProgressOptions { + /** + * Sets the value of Progress. + * @since 7 + */ + value: number; + /** + * Sets the total of Progress. + * @since 7 + */ + total?: number; + /** + * Sets the style of Progress. + * @since 7 + * @deprecated since 8 + */ + style?: ProgressStyle; + /** + * Sets the type of Progress. + * @since 8 + */ + type?: ProgressType; +} +/** + * Type of progress bar + * @since 8 + */ +declare enum ProgressType { + /** + * Linear progress bar style. + * @since 8 + */ + Linear, + /** + * Ring progress bar. + * @since 8 + */ + Ring, + /** + * Eclipse progress bar. + * @since 8 + */ + Eclipse, + /** + * ScaleRing progress bar. + * @since 8 + */ + ScaleRing, + /** + * Capsule progress bar. + * @since 8 + */ + Capsule +} +/** + * Defines style options for progress component. + * @since 8 + */ +declare interface ProgressStyleOptions { + /** + * Defines the strokeWidth property. + * @since 8 + */ + strokeWidth?: Length; + /** + * Defines the scaleCoun property. + * @since 8 + */ + scaleCount?: number; + /** + * Defines the scaleWidth property. + * @since 8 + */ + scaleWidth?: Length; +} +/** + * Type of progress bar + * @since 7 + */ +declare enum ProgressStyle { + /** + * Linear progress bar style. + * @since 7 + */ + Linear, + /** + * Ring progress bar. + * @since 8 + */ + Ring, + /** + * Eclipse progress bar. + * @since 7 + */ + Eclipse, + /** + * ScaleRing progress bar. + * @since 8 + */ + ScaleRing, + /** + * Capsule progress bar. + * @since 8 + */ + Capsule +} +/** + * Provides the progress bar interface. + * @since 7 + */ +interface ProgressInterface { + /** + * Called when the progress bar is set. + * @since 7 + */ + (options: ProgressOptions): ProgressAttribute; +} +/** + * Defines the progress attibute functions. + * @since 7 + */ +declare class ProgressAttribute extends CommonMethod { + /** + * Called when the current progress value is set. + * @since 7 + */ + value(value: number): ProgressAttribute; + /** + * Called when the progress bar foreground is set. + * @since 7 + */ + color(value: ResourceColor): ProgressAttribute; + /** + * Called when the style of progress bar is set. + * @since 8 + */ + style(value: ProgressStyleOptions): ProgressAttribute; +} +declare const Progress: ProgressInterface; +declare const ProgressInstance: ProgressAttribute; diff --git a/build-tools/api/@internal/component/ets/qrcode.d.ts b/build-tools/api/@internal/component/ets/qrcode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..95c167fd1d9511d3719affd83527fa37ed1a0c47 --- /dev/null +++ b/build-tools/api/@internal/component/ets/qrcode.d.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides an interface for generating QR codes. + * @since 7 + */ +interface QRCodeInterface { + /** + * Called when a QR code is set. + * @since 7 + */ + (value: string): QRCodeAttribute; +} +/** + * Defines the qrcode attibute functions. + * @since 7 + */ +declare class QRCodeAttribute extends CommonMethod { + /** + * Called when the QR code color is set. + * @since 7 + */ + color(value: ResourceColor): QRCodeAttribute; + /** + * Called when setting the QR code background color. + * @since 7 + */ + backgroundColor(value: ResourceColor): QRCodeAttribute; +} +declare const QRCode: QRCodeInterface; +declare const QRCodeInstance: QRCodeAttribute; diff --git a/build-tools/api/@internal/component/ets/radio.d.ts b/build-tools/api/@internal/component/ets/radio.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..69410d86c4f86dd84ca05b4c2e749b1075676fdf --- /dev/null +++ b/build-tools/api/@internal/component/ets/radio.d.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Input parameter for creating a radio box. + * @since 8 + */ +declare interface RadioOptions { + /** + * Radio group name. + * @since 8 + */ + group: string; + /** + * Radio name. + * @since 8 + */ + value: string; +} +/** + * Provides an interface for creating a radio box. + * @since 8 + */ +interface RadioInterface { + /** + * Called when a radio box is created. + * @since 8 + */ + (options: RadioOptions): RadioAttribute; +} +/** + * @since 8 + */ +declare class RadioAttribute extends CommonMethod { + /** + * Called when the radio box is selected. + * @since 8 + */ + checked(value: boolean): RadioAttribute; + /** + * Called when the radio box selection status changes. + * @since 8 + */ + onChange(callback: (isChecked: boolean) => void): RadioAttribute; +} +declare const Radio: RadioInterface; +declare const RadioInstance: RadioAttribute; diff --git a/build-tools/api/@internal/component/ets/rating.d.ts b/build-tools/api/@internal/component/ets/rating.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c5fd3b1f1782b4759645338c00328ba665a52a1b --- /dev/null +++ b/build-tools/api/@internal/component/ets/rating.d.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides the interface for scoring bars. + * @since 7 + */ +interface RatingInterface { + /** + * Called when a score bar is created. + * @since 7 + */ + (options?: { + rating: number; + indicator?: boolean; + }): RatingAttribute; +} +/** + * Defines the rating attibute functions. + * @since 7 + */ +declare class RatingAttribute extends CommonMethod { + /** + * Called when the total number of stars is set. + * @since 7 + */ + stars(value: number): RatingAttribute; + /** + * Called when the step size of the operation rating. + * @since 7 + */ + stepSize(value: number): RatingAttribute; + /** + * Called when a picture is set. + * @since 7 + */ + starStyle(value: { + backgroundUri: string; + foregroundUri: string; + secondaryUri?: string; + }): RatingAttribute; + /** + * Called when the star rating of the operation scoring bar changes. + * @since 7 + */ + onChange(callback: (value: number) => void): RatingAttribute; +} +declare const Rating: RatingInterface; +declare const RatingInstance: RatingAttribute; diff --git a/build-tools/api/@internal/component/ets/rect.d.ts b/build-tools/api/@internal/component/ets/rect.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c2d4cbadfe802ad4bef2b736bb94a86bc18b99a --- /dev/null +++ b/build-tools/api/@internal/component/ets/rect.d.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides an interface for drawing rectangles. + * @since 7 + */ +interface RectInterface { + /** + * Use new function to create Rect. + * @since 7 + */ + new (value?: { + width?: number | string; + height?: number | string; + radius?: number | string | Array; + } | { + width?: number | string; + height?: number | string; + radiusWidth?: number | string; + radiusHeight?: number | string; + }): RectAttribute; + /** + * Called when a rectangle is created. + * @since 7 + */ + (value?: { + width?: number | string; + height?: number | string; + radius?: number | string | Array; + } | { + width?: number | string; + height?: number | string; + radiusWidth?: number | string; + radiusHeight?: number | string; + }): RectAttribute; +} +/** + * @since 7 + */ +declare class RectAttribute extends CommonShapeMethod { + /** + * Called when the fillet width is set. + * @since 7 + */ + radiusWidth(value: number | string): RectAttribute; + /** + * Called when the fillet height is set. + * @since 7 + */ + radiusHeight(value: number | string): RectAttribute; + /** + * Called when the fillet size is set. + * @since 7 + */ + radius(value: number | string | Array): RectAttribute; +} +declare const Rect: RectInterface; +declare const RectInStance: RectAttribute; diff --git a/build-tools/api/@internal/component/ets/refresh.d.ts b/build-tools/api/@internal/component/ets/refresh.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac2e2cacdb22a7529cf00c6b7f38340734fd7b15 --- /dev/null +++ b/build-tools/api/@internal/component/ets/refresh.d.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The refresh status of the drop-down refresh. + * @since 8 + */ +declare enum RefreshStatus { + /** + * The refresh status of the drop-down refresh. + * @since 8 + */ + Inactive, + /** + * Drop down, but the drop-down distance is less than the refresh distance. + * @since 8 + */ + Drag, + /** + * The pull-down exceeds the refresh distance. + * @since 8 + */ + OverDrag, + /** + * After the pull-down, it rebounds to the refresh distance and enters the refresh state. + * @since 8 + */ + Refresh, + /** + * After refresh, return to the initial state. + * @since 8 + */ + Done +} +/** + * Provides a pull-down refresh interface. + * @since 8 + */ +interface RefreshInterface { + /** + * Called when the drop-down refresh is set. + * @since 8 + */ + (value: { + refreshing: boolean; + offset?: number | string; + friction?: number | string; + }): RefreshAttribute; +} +/** + * Defines the refresh attibute functions. + * @since 8 + */ +declare class RefreshAttribute extends CommonMethod { + /** + * Called when the refresh state changes. + * @since 8 + */ + onStateChange(callback: (state: RefreshStatus) => void): RefreshAttribute; + /** + * Called when the refresh state is entered. + * @since 8 + */ + onRefreshing(callback: () => void): RefreshAttribute; +} +declare const Refresh: RefreshInterface; +declare const RefreshInstance: RefreshAttribute; diff --git a/build-tools/api/@internal/component/ets/relative_container.d.ts b/build-tools/api/@internal/component/ets/relative_container.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aade2f70a40a8afec705b08ec210262b53e144ce --- /dev/null +++ b/build-tools/api/@internal/component/ets/relative_container.d.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides ports for relative containers. + * @since 9 + */ +interface RelativeContainerInterface { + (): RelativeContainerAttribute; +} +/** +* @since 9 +*/ +declare class RelativeContainerAttribute extends CommonMethod { +} +/** + * @since 9 + */ +declare const RelativeContainer: RelativeContainerInterface; +/** + * @since 9 + */ +declare const RelativeContainerInstance: RelativeContainerAttribute; diff --git a/build-tools/api/@internal/component/ets/rich_text.d.ts b/build-tools/api/@internal/component/ets/rich_text.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..505a98f0d8367f329dd1b9e153037d7bdf55b315 --- /dev/null +++ b/build-tools/api/@internal/component/ets/rich_text.d.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides an interface for RichText component. + * @since 8 + */ +interface RichTextInterface { + /** + * Set value. + * @since 8 + */ + (content: string): RichTextAttribute; +} +/** + * Defines the RichText attribute functions. + * @since 8 + */ +declare class RichTextAttribute extends CommonMethod { + /** + * Triggered when the RichText loading starts. + * @since 8 + */ + onStart(callback: () => void): RichTextAttribute; + /** + * Triggered when the RichText loading ends. + * @since 8 + */ + onComplete(callback: () => void): RichTextAttribute; +} +declare const RichText: RichTextInterface; +declare const RichTextInstance: RichTextAttribute; diff --git a/build-tools/api/@internal/component/ets/row.d.ts b/build-tools/api/@internal/component/ets/row.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..85db0df8dc85b05b8818830bc5208f6030847e03 --- /dev/null +++ b/build-tools/api/@internal/component/ets/row.d.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The components are laid out horizontally + * @since 7 + */ +interface RowInterface { + /** + * Called when the layout is set in the horizontal direction. + * @since 7 + */ + (value?: { + space?: string | number; + }): RowAttribute; +} +/** + * Defines the row attribute functions. + * @since 7 + */ +declare class RowAttribute extends CommonMethod { + /** + * Called when the vertical alignment is set. + * @since 7 + */ + alignItems(value: VerticalAlign): RowAttribute; + /** + * Called when the horizontal alignment is set. + * @since 8 + */ + justifyContent(value: FlexAlign): RowAttribute; +} +declare const Row: RowInterface; +declare const RowInstance: RowAttribute; diff --git a/build-tools/api/@internal/component/ets/row_split.d.ts b/build-tools/api/@internal/component/ets/row_split.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..912ad18a55946a9c4ef225a8a6aac61a9df2d7fd --- /dev/null +++ b/build-tools/api/@internal/component/ets/row_split.d.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides interfaces for layout in the vertical direction. + * @since 7 + */ +interface RowSplitInterface { + /** + * Called when the layout along the vertical direction is set. + * @since 7 + */ + (): RowSplitAttribute; +} +/** + * @since 7 + */ +declare class RowSplitAttribute extends CommonMethod { + /** + * Called when judging whether the split line can be dragged. + * @since 7 + */ + resizeable(value: boolean): RowSplitAttribute; +} +declare const RowSplit: RowSplitInterface; +declare const RowSplitInstance: RowSplitAttribute; diff --git a/build-tools/api/@internal/component/ets/scroll.d.ts b/build-tools/api/@internal/component/ets/scroll.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..16932047ff66979133ffa12f6858a39463a69ee2 --- /dev/null +++ b/build-tools/api/@internal/component/ets/scroll.d.ts @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Content scroll direction. + * @since 7 + */ +declare enum ScrollDirection { + /** + * Vertical scrolling is supported. + * @since 7 + */ + Vertical, + /** + * Horizontal scrolling is supported. + * @since 7 + */ + Horizontal, + /** + * Free scrolling is supported. + * @since 7 + */ + Free, + /** + * Non-scrollable. + * @since 7 + */ + None +} +/** + * @since 7 + */ +declare class Scroller { + /** + * constructor. + * @since 7 + */ + constructor(); + /** + * Called when the setting slides to the specified position. + * @since 7 + */ + scrollTo(value: { + xOffset: number | string; + yOffset: number | string; + animation?: { + duration: number; + curve: Curve; + }; + }); + /** + * Called when scrolling to the edge of the container. + * @since 7 + */ + scrollEdge(value: Edge); + /** + * Called when page turning mode is set. + * @since 7 + */ + scrollPage(value: { + next: boolean; + direction?: Axis; + }); + /** + * Called when viewing the scroll offset. + * @since 7 + */ + currentOffset(); + /** + * Called when sliding to the specified index. + * @since 7 + */ + scrollToIndex(value: number); + /** + * Called when the setting slides by offset. + * @since 9 + */ + scrollBy(dx: Length, dy: Length); +} +/** + * Provides interfaces for scrollable containers. + * @since 7 + */ +interface ScrollInterface { + /** + * Called when a scrollable container is set. + * @since 7 + */ + (scroller?: Scroller): ScrollAttribute; +} +/** + * Defines the scroll attibute functions. + * @since 7 + */ +declare class ScrollAttribute extends CommonMethod { + /** + * Called when the scroll method is slid. + * @since 7 + */ + scrollable(value: ScrollDirection): ScrollAttribute; + /** + * Called when the setting slides to the specified position. + * @since 7 + */ + onScroll(event: (xOffset: number, yOffset: number) => void): ScrollAttribute; + /** + * Called when scrolling to the edge of the container. + * @since 7 + */ + onScrollEdge(event: (side: Edge) => void): ScrollAttribute; + /** + * Called when scrolling has stopped. + * @since 7 + */ + onScrollEnd(event: () => void): ScrollAttribute; + /** + * Called when the status of the scroll bar is set. + * @since 7 + */ + scrollBar(barState: BarState): ScrollAttribute; + /** + * Called when the color of the scroll bar is set. + * @since 7 + */ + scrollBarColor(color: Color | number | string): ScrollAttribute; + /** + * Called when the width of the scroll bar is set. + * @since 7 + */ + scrollBarWidth(value: number | string): ScrollAttribute; + /** + * Called when the sliding effect is set. + * @since 7 + */ + edgeEffect(edgeEffect: EdgeEffect): ScrollAttribute; + /** + * Event called when sroll will scroll. + * @since 9 + */ + onScrollBegin(event: (dx: number, dy: number) => { + dxRemain: number; + dyRemain: number; + }): ScrollAttribute; +} +declare const Scroll: ScrollInterface; +declare const ScrollInstance: ScrollAttribute; diff --git a/build-tools/api/@internal/component/ets/scroll_bar.d.ts b/build-tools/api/@internal/component/ets/scroll_bar.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a2aa888b70c0905c0a03a895828149d8c4860d7e --- /dev/null +++ b/build-tools/api/@internal/component/ets/scroll_bar.d.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Content scroll direction. + * @since 8 + */ +declare enum ScrollBarDirection { + /** + * Vertical scrolling is supported. + * @since 8 + */ + Vertical, + /** + * Horizontal scrolling is supported. + * @since 8 + */ + Horizontal +} +/** + * Defines the options of ScrollBar. + * @since 8 + */ +declare interface ScrollBarOptions { + /** + * Sets the scroller of scroll bar. + * @since 8 + */ + scroller: Scroller; + /** + * Sets the direction of scroll bar. + * @since 8 + */ + direction?: ScrollBarDirection; + /** + * Sets the state of scroll bar. + * @since 8 + */ + state?: BarState; +} +/** + * Provides interfaces for scroll bar. + * @since 8 + */ +interface ScrollBarInterface { + /** + * Called when a ScrollBar container is set. + * @since 8 + */ + (value: ScrollBarOptions): ScrollBarAttribute; +} +/** + * Defines the scrollbar attibute functions. + * @since 8 + */ +declare class ScrollBarAttribute extends CommonMethod { +} +declare const ScrollBar: ScrollBarInterface; +declare const ScrollBarInstance: ScrollBarAttribute; diff --git a/build-tools/api/@internal/component/ets/search.d.ts b/build-tools/api/@internal/component/ets/search.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f4c89b7f70b2b1e0deeefce8e9bed908a6792c3 --- /dev/null +++ b/build-tools/api/@internal/component/ets/search.d.ts @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides the method of switching the cursor position. + * @since 8 + */ +declare class SearchController { + /** + * constructor. + * @since 8 + */ + constructor(); + /** + * Called when the position of the insertion cursor is set. + * @since 8 + */ + caretPosition(value: number): void; +} +/** + * The construct function of search + * @since 8 + */ +interface SearchInterface { + (options?: { + value?: string; + placeholder?: string; + icon?: string; + controller?: SearchController; + }): SearchAttribute; +} +/** + * The attribute function of search + * @since 8 + */ +declare class SearchAttribute extends CommonMethod { + /** + * Set the search button text + * @since 8 + */ + searchButton(value: string): SearchAttribute; + /** + * Set the place hold text color + * @since 8 + */ + placeholderColor(value: ResourceColor): SearchAttribute; + /** + * Set the font used for place holder text + * @since 8 + */ + placeholderFont(value?: Font): SearchAttribute; + /** + * Set the font used for input text + * @since 8 + */ + textFont(value?: Font): SearchAttribute; + /** + * Call the function when clicked the search button + * @since 8 + */ + onSubmit(callback: (value: string) => void): SearchAttribute; + /** + * Call the function when editing the input text + * @since 8 + */ + onChange(callback: (value: string) => void): SearchAttribute; + /** + * Called when using the Clipboard menu + * @since 8 + */ + onCopy(callback: (value: string) => void): SearchAttribute; + /** + * Called when using the Clipboard menu + * @since 8 + */ + onCut(callback: (value: string) => void): SearchAttribute; + /** + * Called when using the Clipboard menu + * @since 8 + */ + onPaste(callback: (value: string) => void): SearchAttribute; + /** + * Called when the copy option is set. + * @since 9 + */ + copyOption(value: boolean | CopyOption): SearchAttribute; + /** + * Called when the text align is set. + * @since 9 + */ + textAlign(value: TextAlign): SearchAttribute; +} +declare const Search: SearchInterface; +declare const SearchInstance: SearchAttribute; diff --git a/build-tools/api/@internal/component/ets/select.d.ts b/build-tools/api/@internal/component/ets/select.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b92920cfebbe7f7bbfebff709f9b0c4861ca10bd --- /dev/null +++ b/build-tools/api/@internal/component/ets/select.d.ts @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The declare of slectOption. + * @since 8 + */ +declare interface SelectOption { + /** + * option string. + * @since 8 + */ + value: ResourceStr; + /** + * option icon. + * @since 8 + */ + icon?: ResourceStr; +} +/** + * Provides the select interface. + * @since 8 + */ +interface SelectInterface { + /** + * Called when the select is set. + * @since 8 + */ + (options: Array): SelectAttribute; +} +/** + * The commonMethod of select. + * @since 8 + */ +declare class SelectAttribute extends CommonMethod { + /** + * Sets the serial number of the select item, starting from 0. + * @since 8 + */ + selected(value: number): SelectAttribute; + /** + * Sets the text display of the select button itself. + * @since 8 + */ + value(value: string): SelectAttribute; + /** + * Sets the text properties of the select button itself. + * @since 8 + */ + font(value: Font): SelectAttribute; + /** + * Sets the text color of the select button itself. + * @since 8 + */ + fontColor(value: ResourceColor): SelectAttribute; + /** + * Sets the background color of the selected items in the select. + * @since 8 + */ + selectedOptionBgColor(value: ResourceColor): SelectAttribute; + /** + * Sets the text style of the selected items in the select. + * @since 8 + */ + selectedOptionFont(value: Font): SelectAttribute; + /** + * Sets the text color of the selected item in the select. + * @since 8 + */ + selectedOptionFontColor(value: ResourceColor): SelectAttribute; + /** + * Sets the background color of the select item. + * @since 8 + */ + optionBgColor(value: ResourceColor): SelectAttribute; + /** + * Sets the text style for select items. + * @since 8 + */ + optionFont(value: Font): SelectAttribute; + /** + * Sets the text color for select items. + * @since 8 + */ + optionFontColor(value: ResourceColor): SelectAttribute; + /** + * Callback for selecting an item from the select. + * @since 8 + */ + onSelect(callback: (index: number, value?: string) => void): SelectAttribute; +} +declare const Select: SelectInterface; +declare const SelectInstance: SelectAttribute; diff --git a/build-tools/api/@internal/component/ets/shape.d.ts b/build-tools/api/@internal/component/ets/shape.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..75840e15eec9356cec90fca0a608148e31b4df54 --- /dev/null +++ b/build-tools/api/@internal/component/ets/shape.d.ts @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides interfaces for drawing components. + * @since 7 + */ +interface ShapeInterface { + /** + * Use the new function to create Shape. + * @since 7 + */ + new (value?: PixelMap): ShapeAttribute; + /** + * Called when a component is drawn. + * @since 7 + */ + (value?: PixelMap): ShapeAttribute; +} +/** + * @since 7 + */ +declare class ShapeAttribute extends CommonMethod { + /** + * Viewport of shape + * @since 7 + */ + viewPort(value: { + x?: number | string; + y?: number | string; + width?: number | string; + height?: number | string; + }): ShapeAttribute; + /** + * Called when the border color is set. + * @since 7 + */ + stroke(value: ResourceColor): ShapeAttribute; + /** + * Called when the fill color is set. + * @since 7 + */ + fill(value: ResourceColor): ShapeAttribute; + /** + * Called when the offset of the starting point of border drawing is set. + * @since 7 + */ + strokeDashOffset(value: number | string): ShapeAttribute; + /** + * Called when the gap of the border is set. + * @since 7 + */ + strokeDashArray(value: Array): ShapeAttribute; + /** + * Called when the path endpoint drawing style is set. + * @since 7 + */ + strokeLineCap(value: LineCapStyle): ShapeAttribute; + /** + * Called when the border corner drawing style is set. + * @since 7 + */ + strokeLineJoin(value: LineJoinStyle): ShapeAttribute; + /** + * Called when the limit value for drawing acute angles as oblique angles is set. + * @since 7 + */ + strokeMiterLimit(value: number | string): ShapeAttribute; + /** + * Called when the opacity of the border is set. + * @since 7 + */ + strokeOpacity(value: number | string | Resource): ShapeAttribute; + /** + * Called when the transparency of the border is set. + * @since 7 + */ + fillOpacity(value: number | string | Resource): ShapeAttribute; + /** + * Called when the width of the border is set. + * @since 7 + */ + strokeWidth(value: number | string): ShapeAttribute; + /** + * Called when setting whether anti aliasing is on. + * @since 7 + */ + antiAlias(value: boolean): ShapeAttribute; + /** + * Called when shape mesh. + * @since 8 + */ + mesh(value: Array, column: number, row: number): ShapeAttribute; +} +declare const Shape: ShapeInterface; +declare const ShapeInstance: ShapeAttribute; diff --git a/build-tools/api/@internal/component/ets/sidebar.d.ts b/build-tools/api/@internal/component/ets/sidebar.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..37aae0c5f33116365455f5df1e545539b230fe99 --- /dev/null +++ b/build-tools/api/@internal/component/ets/sidebar.d.ts @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Sets the sidebar style of showing + * @since 8 + */ +declare enum SideBarContainerType { + /** + * The sidebar invisible + * @since 8 + */ + Embed, + /** + * The sidebar visible + * @since 8 + */ + Overlay +} +/** + * Sets the control button style + * @since 8 + */ +declare interface ButtonStyle { + /** + * Set the left of control button + * @since 8 + */ + left?: number; + /** + * Set the top of control button + * @since 8 + */ + top?: number; + /** + * Set the width of control button + * @since 8 + */ + width?: number; + /** + * Set the heigth of control button + * @since 8 + */ + height?: number; + /** + * Set the button icon when sidebar status has changed + * @since 8 + */ + icons?: { + shown: string | PixelMap | Resource; + hidden: string | PixelMap | Resource; + switching?: string | PixelMap | Resource; + }; +} +/** + * The construct function of sidebar + * @since 8 + */ +interface SideBarContainerInterface { + /** + * Called when showing the sidebar of a block entry. + * @since 8 + */ + (type?: SideBarContainerType): SideBarContainerAttribute; +} +/** + * The attribute function of sidebar + * @since 8 + */ +declare class SideBarContainerAttribute extends CommonMethod { + /** + * Callback showControlButton function when setting the status of sidebar + * @since 8 + */ + showSideBar(value: boolean): SideBarContainerAttribute; + /** + * Callback controlButton function when setting the style of button + * @since 8 + */ + controlButton(value: ButtonStyle): SideBarContainerAttribute; + /** + * Callback showControlButton function when setting the status of button + * @since 8 + */ + showControlButton(value: boolean): SideBarContainerAttribute; + /** + * Trigger callback when sidebar style of showing change finished. + * @since 8 + */ + onChange(callback: (value: boolean) => void): SideBarContainerAttribute; + /** + * Sets the length of sidebar. + * @since 8 + */ + sideBarWidth(value: number): SideBarContainerAttribute; + /** + * Sets the min length of sidebar. + * default value is 200vp. + * @since 8 + */ + minSideBarWidth(value: number): SideBarContainerAttribute; + /** + * Sets the max length of sidebar. + * default value is 280vp. + * @since 8 + */ + maxSideBarWidth(value: number): SideBarContainerAttribute; + /** + * Sets the length of sidebar. + * @since 9 + */ + sideBarWidth(value: Length): SideBarContainerAttribute; + /** + * Sets the min length of sidebar. + * default value is 200vp. + * @since 9 + */ + minSideBarWidth(value: Length): SideBarContainerAttribute; + /** + * Sets the max length of sidebar. + * default value is 280vp. + * @since 9 + */ + maxSideBarWidth(value: Length): SideBarContainerAttribute; + /** + * Sets whether to automatically hide when drag sidebar width is less than the minimum width. + * default value is true. + * @since 9 + */ + autoHide(value: boolean): SideBarContainerAttribute; +} +declare const SideBarContainer: SideBarContainerInterface; +declare const SideBarContainerInstance: SideBarContainerAttribute; diff --git a/build-tools/api/@internal/component/ets/slider.d.ts b/build-tools/api/@internal/component/ets/slider.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b538df80fc2c7e1cfcba5a6fd55633112437746e --- /dev/null +++ b/build-tools/api/@internal/component/ets/slider.d.ts @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Declare sliderstyle + * @since 7 + */ +declare enum SliderStyle { + /** + * The slider is on the slide rail. + * @since 7 + */ + OutSet, + /** + * The slider is in the slide rail. + * @since 7 + */ + InSet +} +/** + * Declare SliderChangeMode + * @since 7 + */ +declare enum SliderChangeMode { + /** + * Start dragging the slider. + * @since 7 + */ + Begin, + /** + * Drag the slider. + * @since 7 + */ + Moving, + /** + * End dragging the slider. + * @since 7 + */ + End, + /** + * Click the slider. + * @since 8 + */ + Click +} +/** + * Defines the options of Slider. + * @since 7 + */ +declare interface SliderOptions { + /** + * Current value of Slider. + * @since 7 + */ + value?: number; + /** + * Sets the min value of Slider. + * @since 7 + */ + min?: number; + /** + * Sets the max value of Slider. + * @since 7 + */ + max?: number; + /** + * Sets the step of each slide value. + * @since 7 + */ + step?: number; + /** + * Sets the slider style. + * @since 7 + */ + style?: SliderStyle; + /** + * Sets the slider direction style. + * @since 8 + */ + direction?: Axis; + /** + * Set whether the direction of the slider needs to be reversed. + * @since 8 + */ + reverse?: boolean; +} +/** + * Provides an interface for the slide bar component. + * @since 7 + */ +interface SliderInterface { + /** + * Called when the slider bar component is used. + * @since 7 + */ + (options?: SliderOptions): SliderAttribute; +} +/** + * Defines the attribute functions of Slider. + * @since 7 + */ +declare class SliderAttribute extends CommonMethod { + /** + * Called when the slider color of the slider bar is set. + * @since 7 + */ + blockColor(value: ResourceColor): SliderAttribute; + /** + * Called when the track color of the slider is set. + * @since 7 + */ + trackColor(value: ResourceColor): SliderAttribute; + /** + * Called when the slider of the slider bar is set to slide over the area color. + * @since 7 + */ + selectedColor(value: ResourceColor): SliderAttribute; + /** + * Called when the minimum label is set. + * @since 7 + */ + minLabel(value: string): SliderAttribute; + /** + * Called when the maximum label is set. + * @since 7 + */ + maxLabel(value: string): SliderAttribute; + /** + * Called when setting whether to display step size. + * @since 7 + */ + showSteps(value: boolean): SliderAttribute; + /** + * Called when the percentage of bubble prompt is set when sliding. + * @since 7 + */ + showTips(value: boolean): SliderAttribute; + /** + * Called when the thickness of track is set. + * @since 8 + */ + trackThickness(value: Length): SliderAttribute; + /** + * Called when the selection value changes. + * @since 7 + */ + onChange(callback: (value: number, mode: SliderChangeMode) => void): SliderAttribute; +} +declare const Slider: SliderInterface; +declare const SliderInstance: SliderAttribute; diff --git a/build-tools/api/@internal/component/ets/span.d.ts b/build-tools/api/@internal/component/ets/span.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..98ae2ae8ea1f1be6461ed8540a299fc54eb3b54f --- /dev/null +++ b/build-tools/api/@internal/component/ets/span.d.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provide text decoration. + * @since 7 + */ +interface SpanInterface { + /** + * Called when text is entered in span. + * @since 7 + */ + (value: string | Resource): SpanAttribute; +} +/** + * @since 7 + */ +declare class SpanAttribute extends CommonMethod { + /** + * Called when the font color is set. + * @since 7 + */ + fontColor(value: ResourceColor): SpanAttribute; + /** + * Called when the font size is set. + * @since 7 + */ + fontSize(value: number | string | Resource): SpanAttribute; + /** + * Called when the font style of a font is set. + * @since 7 + */ + fontStyle(value: FontStyle): SpanAttribute; + /** + * Called when the font weight is set. + * @since 7 + */ + fontWeight(value: number | FontWeight | string): SpanAttribute; + /** + * Called when the font list of text is set. + * @since 7 + */ + fontFamily(value: string | Resource): SpanAttribute; + /** + * Called when the text decoration of the text is set. + * @since 7 + */ + decoration(value: { + type: TextDecorationType; + color?: ResourceColor; + }): SpanAttribute; + /** + * Called when the distance between text fonts is set. + * @since 7 + */ + letterSpacing(value: number | string): SpanAttribute; + /** + * Called when the type of letter in the text font is set. + */ + textCase(value: TextCase): SpanAttribute; +} +declare const Span: SpanInterface; +declare const SpanInstance: SpanAttribute; diff --git a/build-tools/api/@internal/component/ets/stack.d.ts b/build-tools/api/@internal/component/ets/stack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a1779d9221b34543aa699cfb2dae34e75a3f3de3 --- /dev/null +++ b/build-tools/api/@internal/component/ets/stack.d.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides ports for stacking containers. + * @since 7 + */ +interface StackInterface { + /** + * Set the value. + * @since 7 + */ + (value?: { + alignContent?: Alignment; + }): StackAttribute; +} +/** + * @since 7 + */ +declare class StackAttribute extends CommonMethod { + /** + * Called when the occupancy of items in the container is set. + * @since 7 + */ + alignContent(value: Alignment): StackAttribute; +} +declare const Stack: StackInterface; +declare const StackInstance: StackAttribute; diff --git a/build-tools/api/@internal/component/ets/state_management.d.ts b/build-tools/api/@internal/component/ets/state_management.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bcf62387e16bf7002a9f731cb36cfb513880b06b --- /dev/null +++ b/build-tools/api/@internal/component/ets/state_management.d.ts @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the ColorMode of device. + * @since 7 + */ +declare enum ColorMode { + /** + * Light mode. + * @since 7 + */ + LIGHT = 0, + /** + * Dark mode. + * @since 7 + */ + DARK +} +/** + * Defines the LayoutDirection of device. + * @since 7 + */ +declare enum LayoutDirection { + /** + * Elements are laid out from left to right. + * @since 7 + */ + LTR, + /** + * Elements are laid out from right to left. + * @since 7 + */ + RTL, + /** + * Elements are laid out from auto. + * @since 8 + */ + Auto +} +/** + * Defining LocalStorage. + * @since 9 + */ +declare class LocalStorage { + /** + * constructor. + * @since 9 + */ + constructor(initializingProperties?: Object); + /** + * Get current LocalStorage shared from stage. + * @StageModelOnly + * @since 9 + */ + static GetShared(): LocalStorage; + /** + * return true if prooperty with given name exists + * @since 9 + */ + has(propName: string): boolean; + /** + * return a Map Iterator + * @since 9 + */ + keys(): IterableIterator; + /** + * return number of properties + * @since 9 + */ + size(): number; + /** + * returns value of given property + * @since 9 + */ + get(propName: string): T; + /** + * Set value of given property + * @since 9 + */ + set(propName: string, newValue: T): boolean; + /** + * add property if not property with given name + * @since 9 + */ + setOrCreate(propName: string, newValue?: T): boolean; + /** + * create and return a 'link' (two-way sync) to named property + * @since 9 + */ + link(propName: string, linkUser?: T, subscribersName?: string): T; + /** + * Like link(), will create and initialize a new source property in LocalStorge if missing + * @since 9 + */ + setAndLink(propName: string, defaultValue: T, linkUser?: T, subscribersName?: string): T; + /** + * create and return a 'prop' (one-way sync) to named property + * @since 9 + */ + prop(propName: string, propUser?: T, subscribersName?: string): T; + /** + * Like prop(), will create and initialize a new source property in LocalStorage if missing + * @since 9 + */ + setAndProp(propName: string, defaultValue: T, propUser?: T, subscribersName?: string): T; + /** + * Delete property from StorageBase + * @since 9 + * @returns false if method failed + */ + delete(propName: string): boolean; + /** + * delete all properties from the StorageBase + * @since 9 + */ + clear(): boolean; +} diff --git a/build-tools/api/@internal/component/ets/stepper.d.ts b/build-tools/api/@internal/component/ets/stepper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd8bcb01b16330114073ade6e3cc5ccca0a6abe2 --- /dev/null +++ b/build-tools/api/@internal/component/ets/stepper.d.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Declare the stepper. + * @since 8 + */ +interface StepperInterface { + /** + * Called when the stepper component is used. + * @since 8 + */ + (value?: { + index?: number; + }): StepperAttribute; +} +/** + * Defines the stepper attribute functions + * @since 8 + */ +declare class StepperAttribute extends CommonMethod { + /** + * Callback when the finish label is clicked. + * @since 8 + */ + onFinish(callback: () => void): StepperAttribute; + /** + * Callback when the skip label is clicked. + * @since 8 + */ + onSkip(callback: () => void): StepperAttribute; + /** + * Callback when the change label is clicked. + * @since 8 + */ + onChange(callback: (prevIndex?: number, index?: number) => void): StepperAttribute; + /** + * Callback when the next label is clicked. + * @since 8 + */ + onNext(callback: (index?: number, pendingIndex?: number) => void): StepperAttribute; + /** + * Callback when the previous label is clicked. + * @since 8 + */ + onPrevious(callback: (index?: number, pendingIndex?: number) => void): StepperAttribute; +} +declare const Stepper: StepperInterface; +declare const StepperInstance: StepperAttribute; diff --git a/build-tools/api/@internal/component/ets/stepper_item.d.ts b/build-tools/api/@internal/component/ets/stepper_item.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5ca22442bf8058be2013daa3305c03da4d2ebc6 --- /dev/null +++ b/build-tools/api/@internal/component/ets/stepper_item.d.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * ItemState + * @since 8 + */ +declare enum ItemState { + /** + * Default State + * @since 8 + */ + Normal, + /** + * Disabled State + * @since 8 + */ + Disabled, + /** + * Waiting State + * @since 8 + */ + Waiting, + /** + * Skip State + * @since 8 + */ + Skip +} +/** + * Provides an interface for switching the stepperItem view on stepper container. + * @since 8 + */ +interface StepperItemInterface { + /** + * Called when the stepperItem component is used. + * @since 8 + */ + (): StepperItemAttribute; +} +/** + * Defines the stepper item attrbute functions. + * @since 8 + */ +declare class StepperItemAttribute extends CommonMethod { + /** + * Called when the value of stepperItem prevLabel is set + * @since 8 + */ + prevLabel(value: string): StepperItemAttribute; + /** + * Called when the value of stepperItem nextLabel is set + * @since 8 + */ + nextLabel(value: string): StepperItemAttribute; + /** + * Called when the value of stepperItem status is set + * @since 8 + */ + status(value?: ItemState): StepperItemAttribute; +} +declare const StepperItemInstance: StepperItemAttribute; +declare const StepperItem: StepperItemInterface; diff --git a/build-tools/api/@internal/component/ets/swiper.d.ts b/build-tools/api/@internal/component/ets/swiper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f386cab4bd1ac9151d425fa0aa1f28699dc13e5 --- /dev/null +++ b/build-tools/api/@internal/component/ets/swiper.d.ts @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides methods for switching components. + * @since 7 + */ +declare class SwiperController { + /** + * constructor. + * @since 7 + */ + constructor(); + /** + * Called when the next child component is displayed. + * @since 7 + */ + showNext(); + /** + * Called when the previous subcomponent is displayed. + * @since 7 + */ + showPrevious(); + /** + * Called when need to stop the swiper animation. + * @since 7 + */ + finishAnimation(callback?: () => void); +} +/** + * Declare the size of the swiper on the spindle. + * @since 7 + */ +declare enum SwiperDisplayMode { + /** + * Carousel map extension. + * @since 7 + */ + Stretch, + /** + * The rotation chart is self linear. + * @since 7 + */ + AutoLinear +} +/** + * Provides an interface for sliding containers. + * @since 7 + */ +interface SwiperInterface { + /** + * Called when a sliding container is set. + * @since 7 + */ + (controller?: SwiperController): SwiperAttribute; +} +/** + * Setting indicator style navigation. + * @since 8 + */ +declare interface IndicatorStyle { + /** + * Set the indicator to the left. + * @since 8 + */ + left?: Length; + /** + * Set the indicator to the top. + * @since 8 + */ + top?: Length; + /** + * Set the indicator to the right. + * @since 8 + */ + right?: Length; + /** + * Set the indicator to the bottom. + * @since 8 + */ + bottom?: Length; + /** + * Set the indicator size. + * @since 8 + */ + size?: Length; + /** + * Setting indicator style mask. + * @since 8 + */ + mask?: boolean; + /** + * Set the indicator color. + * @since 8 + */ + color?: ResourceColor; + /** + * Set the navigation point color. + * @since 8 + */ + selectedColor?: ResourceColor; +} +/** + * Defines the swiper attibute functions. + * @since 7 + */ +declare class SwiperAttribute extends CommonMethod { + /** + * Called when the index value of the displayed subcomponent is set in the container. + * @since 7 + */ + index(value: number): SwiperAttribute; + /** + * Called when setting whether the subcomponent plays automatically. + * @since 7 + */ + autoPlay(value: boolean): SwiperAttribute; + /** + * Called when the time interval for automatic playback is set. + * @since 7 + */ + interval(value: number): SwiperAttribute; + /** + * Called when you set whether the navigation point indicator is enabled. + * @since 7 + */ + indicator(value: boolean): SwiperAttribute; + /** + * Called when setting whether to turn on cyclic sliding. + * @since 7 + */ + loop(value: boolean): SwiperAttribute; + /** + * Called when the animation duration of the switch is set. + * @since 7 + */ + duration(value: number): SwiperAttribute; + /** + * Called when setting whether to slide vertically. + * @since 7 + */ + vertical(value: boolean): SwiperAttribute; + /** + * Called when the size of the rotation chart is set. + * @since 7 + */ + itemSpace(value: number | string): SwiperAttribute; + /** + * Called when setting the size of the swiper container on the spindle. + * @since 7 + */ + displayMode(value: SwiperDisplayMode): SwiperAttribute; + /** + * Called when setting the cached count of the swiper container one side. + * @since 8 + */ + cachedCount(value: number): SwiperAttribute; + /** + * This command is invoked when the number of subcomponents is set. + * @since 8 + */ + displayCount(value: number | string): SwiperAttribute; + /** + * Invoked when setting the sliding effect + * @since 8 + */ + effectMode(value: EdgeEffect): SwiperAttribute; + /** + * Called when sliding is disableSwipe + * @since 8 + */ + disableSwipe(value: boolean): SwiperAttribute; + /** + * Called when sliding is curve + * @since 8 + */ + curve(value: Curve | string): SwiperAttribute; + /** + * Called when the index value changes. + * @since 7 + */ + onChange(event: (index: number) => void): SwiperAttribute; + /** + * Setting indicator style navigation. + * @since 8 + */ + indicatorStyle(value?: IndicatorStyle): SwiperAttribute; +} +declare const Swiper: SwiperInterface; +declare const SwiperInstance: SwiperAttribute; diff --git a/build-tools/api/@internal/component/ets/tab_content.d.ts b/build-tools/api/@internal/component/ets/tab_content.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..615d2c01bbeed8c6664b75710096c4a944c82117 --- /dev/null +++ b/build-tools/api/@internal/component/ets/tab_content.d.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides an interface for switching the content view on a tab page. + * @since 7 + */ +interface TabContentInterface { + /** + * Called when the content view of the switch tab is set. + * @since 7 + */ + (): TabContentAttribute; +} +/** + * Defines the attribute functions of TabContent. + * @since 7 + */ +declare class TabContentAttribute extends CommonMethod { + /** + * Called when tabbar is entered. + * @since 7 + */ + tabBar(value: string | Resource | CustomBuilder | { + icon?: string | Resource; + text?: string | Resource; + }): TabContentAttribute; +} +declare const TabContent: TabContentInterface; +declare const TabContentInstance: TabContentAttribute; diff --git a/build-tools/api/@internal/component/ets/tabs.d.ts b/build-tools/api/@internal/component/ets/tabs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..32fc0b2e6754379403036a3fc3d432e695f4049a --- /dev/null +++ b/build-tools/api/@internal/component/ets/tabs.d.ts @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Declare the graphic format of the bar chart. + * @since 7 + */ +declare enum BarMode { + /** + * The actual layout width of the TabBar is used. If the width exceeds the total width, you can slide the tabbar. + * @since 7 + */ + Scrollable, + /** + * The width of all TabBars is evenly allocated. + * @since 7 + */ + Fixed +} +/** + * Declare the location of the bar chart. + * @since 7 + */ +declare enum BarPosition { + /** + * When the vertical attribute method is set to true, the tab is on the left of the container. When the vertical property method is set to false, the tab is at the top of the container. + * @since 7 + */ + Start, + /** + * When the vertical attribute method is set to true, the tab is located on the right of the container. When the vertical property method is set to false, the tab is at the bottom of the container. + * @since 7 + */ + End +} +/** + * @since 7 + */ +declare class TabsController { + /** + * constructor. + * @since 7 + */ + constructor(); + /** + * Called when the tab is switched. + * @since 7 + */ + changeIndex(value: number): void; +} +/** + * Provides an interface for switching views. + * @since 7 + */ +interface TabsInterface { + /** + * Called when the view is switched. + * @since 7 + */ + (value?: { + barPosition?: BarPosition; + index?: number; + controller?: TabsController; + }): TabsAttribute; +} +/** + * Defines the tabs attribute functions. + * @since 7 + */ +declare class TabsAttribute extends CommonMethod { + /** + * Called when determining whether the tab is vertical. + * @since 7 + */ + vertical(value: boolean): TabsAttribute; + /** + * Called when judging whether page switching can be performed by sliding left and right. + * @since 7 + */ + scrollable(value: boolean): TabsAttribute; + /** + * Called when the graphic format of the bar chart is selected. + * @since 7 + */ + barMode(value: BarMode): TabsAttribute; + /** + * Called when the width of the bar graph is set. + * Notice: barWidth only supports Number type on 7, supports Length type since 8. + * @since 8 + */ + barWidth(value: Length): TabsAttribute; + /** + * Called when the height of the bar graph is set. + * Notice: barHeight only supports Number type on 7, supports Length type since 8. + * @since 8 + */ + barHeight(value: Length): TabsAttribute; + /** + * Called when the animation duration of the bar graph is set. + * @since 7 + */ + animationDuration(value: number): TabsAttribute; + /** + * Called when the tab is switched. + * @since 7 + */ + onChange(event: (index: number) => void): TabsAttribute; +} +declare const Tabs: TabsInterface; +declare const TabsInstance: TabsAttribute; diff --git a/build-tools/api/@internal/component/ets/text.d.ts b/build-tools/api/@internal/component/ets/text.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9fae993b1942bede0f1a7a3c72acbb05436a2f36 --- /dev/null +++ b/build-tools/api/@internal/component/ets/text.d.ts @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides an interface for writing texts. + * @since 7 + */ +interface TextInterface { + /** + * Called when writing text. + * @since 7 + */ + (content?: string | Resource): TextAttribute; +} +/** + * @since 7 + */ +declare class TextAttribute extends CommonMethod { + /** + * Called when the font color is set. + * @since 7 + */ + fontColor(value: ResourceColor): TextAttribute; + /** + * Called when the font size is set. + * @since 7 + */ + fontSize(value: number | string | Resource): TextAttribute; + /** + * Called when the minimum font size of the font is set. + * @since 7 + */ + minFontSize(value: number | string | Resource): TextAttribute; + /** + * Called when the maximum font size of the font is set. + * @since 7 + */ + maxFontSize(value: number | string | Resource): TextAttribute; + /** + * Called when the font style of a font is set. + * @since 7 + */ + fontStyle(value: FontStyle): TextAttribute; + /** + * Called when the font weight is set. + * @since 7 + */ + fontWeight(value: number | FontWeight | string): TextAttribute; + /** + * Called when the horizontal center mode of the font is set. + * @since 7 + */ + textAlign(value: TextAlign): TextAttribute; + /** + * Called when the vertical center mode of the font is set. + * @since 7 + */ + lineHeight(value: number | string | Resource): TextAttribute; + /** + * Called when the overflow mode of the font is set. + * @since 7 + */ + textOverflow(value: { + overflow: TextOverflow; + }): TextAttribute; + /** + * Called when the font list of text is set. + * @since 7 + */ + fontFamily(value: string | Resource): TextAttribute; + /** + * Called when the maximum number of lines of text is set. + * @since 7 + */ + maxLines(value: number): TextAttribute; + /** + * Called when the text decoration of the text is set. + * @since 7 + */ + decoration(value: { + type: TextDecorationType; + color?: ResourceColor; + }): TextAttribute; + /** + * Called when the distance between text fonts is set. + * @since 7 + */ + letterSpacing(value: number | string): TextAttribute; + /** + * Called when the type of letter in the text font is set. + * @since 7 + */ + textCase(value: TextCase): TextAttribute; + /** + * Called when the baseline offset is set. + * @since 7 + */ + baselineOffset(value: number | string): TextAttribute; + /** + * Allow replication. + * @since 9 + */ + copyOption(value: boolean | CopyOption): TextAttribute; +} +declare const TextInstance: TextAttribute; +declare const Text: TextInterface; diff --git a/build-tools/api/@internal/component/ets/text_area.d.ts b/build-tools/api/@internal/component/ets/text_area.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..99cad12db9192d526235c888b21a17a3094fc8e2 --- /dev/null +++ b/build-tools/api/@internal/component/ets/text_area.d.ts @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides the method of switching the cursor position. + * @since 8 + */ +declare class TextAreaController { + /** + * constructor. + * @since 8 + */ + constructor(); + /** + * Called when the position of the insertion cursor is set. + * @since 8 + */ + caretPosition(value: number): void; +} +/** + * Defines the options of TextArea. + * @since 7 + */ +declare interface TextAreaOptions { + /** + * The place holder text string. + * @since 7 + */ + placeholder?: ResourceStr; + /** + * Sets the current value of TextArea. + * @since 7 + */ + text?: ResourceStr; + /** + * Called when the position of the insertion cursor is set. + * @since 8 + */ + controller?: TextAreaController; +} +/** + * Provides an interface for the multi-line text input component. + * @since 7 + */ +interface TextAreaInterface { + /** + * Called when writing multiple lines of text. + * @since 7 + */ + (value?: TextAreaOptions): TextAreaAttribute; +} +/** + * Defines the attribute functions of TextArea. + * @since 7 + */ +declare class TextAreaAttribute extends CommonMethod { + /** + * Called when the color of the placeholder is set. + * @since 7 + */ + placeholderColor(value: ResourceColor): TextAreaAttribute; + /** + * Called when the font property of the placeholder is set. + * @since 7 + */ + placeholderFont(value: Font): TextAreaAttribute; + /** + * Called when the alignment of the contents of a multiline text box is set. + * @since 7 + */ + textAlign(value: TextAlign): TextAreaAttribute; + /** + * Called when the insertion cursor color is set. + * @since 7 + */ + caretColor(value: ResourceColor): TextAreaAttribute; + /** + * Called when the font color is set. + * @since 7 + */ + fontColor(value: ResourceColor): TextAreaAttribute; + /** + * Called when the font size is set. + * @since 7 + */ + fontSize(value: Length): TextAreaAttribute; + /** + * Called when the font style of a font is set. + * @since 7 + */ + fontStyle(value: FontStyle): TextAreaAttribute; + /** + * Called when the font weight is set. + * @since 7 + */ + fontWeight(value: number | FontWeight | string): TextAreaAttribute; + /** + * Called when the font list of text is set. + * @since 7 + */ + fontFamily(value: ResourceStr): TextAreaAttribute; + /** + * Called when the inputFilter of text is set. + * @since 8 + */ + inputFilter(value: ResourceStr, error?: (value: string) => void): TextAreaAttribute; + /** + * Called when the input changes. + * @since 7 + */ + onChange(callback: (value: string) => void): TextAreaAttribute; + /** + * Called when using the Clipboard menu + * @since 7 + */ + onCopy(callback: (value: string) => void): TextAreaAttribute; + /** + * Called when using the Clipboard menu + * @since 7 + */ + onCut(callback: (value: string) => void): TextAreaAttribute; + /** + * Called when using the Clipboard menu + * @since 7 + */ + onPaste(callback: (value: string) => void): TextAreaAttribute; + /** + * Called when the copy option is set. + * @since 9 + */ + copyOption(value: boolean | CopyOption): TextAreaAttribute; +} +declare const TextArea: TextAreaInterface; +declare const TextAreaInstance: TextAreaAttribute; diff --git a/build-tools/api/@internal/component/ets/text_clock.d.ts b/build-tools/api/@internal/component/ets/text_clock.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf14523a6dbe85f603bdd21fb923060bdd25f485 --- /dev/null +++ b/build-tools/api/@internal/component/ets/text_clock.d.ts @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides a way to control the textclock status. + * @since 8 + */ +declare class TextClockController { + /** + * constructor. + * @since 8 + */ + constructor(); + /** + * Provides a start event for textclock. + * @since 8 + */ + start(); + /** + * Provides a stop event for textclock. + * @since 8 + */ + stop(); +} +/** + * TextClock component, which provides the text clock capability. + * @since 8 + */ +interface TextClockInterface { + /** + * Construct the text clock component. + * Specifies the current time zone. + * The valid value is an integer ranging from - 14 to 12, + * Where a negative value indicates the eastern time zone, for example, -8. + * @since 8 + */ + (options?: { + timeZoneOffset?: number; + controller?: TextClockController; + }): TextClockAttribute; +} +declare class TextClockAttribute extends CommonMethod { + /** + * set display time format,such as "yyyy/mm/dd","yyyy-mm-dd". + * support time format:yyyy,mm,mmm(English month abbreviation),mmmm(Full name of the month in English), + * dd,ddd(English Week abbreviation),dddd(Full name of the week in English), + * HH/hh(24-hour clock/12-hour clock),MM/mm(minute),SS/ss(second). + * @since 8 + */ + format(value: string): TextClockAttribute; + /** + * Provides a date change callback. + * The callback parameter is Unix Time Stamp, + * The number of milliseconds that have elapsed since January 1, 1970 (UTC). + * The minimum callback interval for this event is seconds. + * You can listen to this callback, + * Use the format attribute method to customize data display in the callback. + * @param event Listening date event callback. + * @since 8 + */ + onDateChange(event: (value: number) => void): TextClockAttribute; + /** + * Called when the value of TextClock fontColor is set + * @since 8 + */ + fontColor(value: ResourceColor): TextClockAttribute; + /** + * Called when the value of TextClock fontSize is set + * @since 8 + */ + fontSize(value: Length): TextClockAttribute; + /** + * Called when the value of TextClock fontStyle is set + * @since 8 + */ + fontStyle(value: FontStyle): TextClockAttribute; + /** + * Called when the value of TextClock fontWeight is set + * @since 8 + */ + fontWeight(value: number | FontWeight | string): TextClockAttribute; + /** + * Called when the value of TextClock fontFamily is set + * @since 8 + */ + fontFamily(value: ResourceStr): TextClockAttribute; +} +declare const TextClock: TextClockInterface; +declare const TextClockInstance: TextClockAttribute; diff --git a/build-tools/api/@internal/component/ets/text_input.d.ts b/build-tools/api/@internal/component/ets/text_input.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6cb356502b537efc6bc5cfdd975aefc1907031c --- /dev/null +++ b/build-tools/api/@internal/component/ets/text_input.d.ts @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Declare the type of input box + * @since 7 + */ +declare enum InputType { + /** + * Basic input mode. + * @since 7 + */ + Normal, + /** + * Pure digital input mode. + * @since 7 + */ + Number, + /** + * Phone number entry mode. + * @since 9 + */ + PhoneNumber, + /** + * E-mail address input mode. + * @since 7 + */ + Email, + /** + * Password entry mode. + * @since 7 + */ + Password +} +/** + * Declare the type of soft keyboard. + * @since 7 + */ +declare enum EnterKeyType { + /** + * Go. + * @since 7 + */ + Go, + /** + * Search. + * @since 7 + */ + Search, + /** + * Send. + * @since 7 + */ + Send, + /** + * Next. + * @since 7 + */ + Next, + /** + * Done. + * @since 7 + */ + Done +} +/** + * Provides the method of switching the cursor position. + * @since 8 + */ +declare class TextInputController { + /** + * constructor. + * @since 8 + */ + constructor(); + /** + * Called when the position of the insertion cursor is set. + * @since 8 + */ + caretPosition(value: number): void; +} +/** + * Defines the options of TextInput. + * @since 7 + */ +declare interface TextInputOptions { + /** + * The place holder text string. + * @since 7 + */ + placeholder?: ResourceStr; + /** + * Sets the current value of TextArea. + * @since 7 + */ + text?: ResourceStr; + /** + * Called when the position of the insertion cursor is set. + * @since 8 + */ + controller?: TextInputController; +} +/** + * Provides a single-line text input component interface. + * @since 7 + */ +interface TextInputInterface { + /** + * Called when writing a single line of text. + * @since 7 + */ + (value?: TextInputOptions): TextInputAttribute; +} +/** + * Defines the TextInput attribute functions. + * @since 7 + */ +declare class TextInputAttribute extends CommonMethod { + /** + * Called when the input type is set. + * @since 7 + */ + type(value: InputType): TextInputAttribute; + /** + * Called when the color of the placeholder is set. + * @since 7 + */ + placeholderColor(value: ResourceColor): TextInputAttribute; + /** + * Called when the font property of the placeholder is set. + * @since 7 + */ + placeholderFont(value?: Font): TextInputAttribute; + /** + * Called when the type of soft keyboard input button is set. + * @since 7 + */ + enterKeyType(value: EnterKeyType): TextInputAttribute; + /** + * Called when the color of the insertion cursor is set. + * @since 7 + */ + caretColor(value: ResourceColor): TextInputAttribute; + /** + * Called when judging whether the text editing change finished. + * @since 7 + * @deprecated since 8 + */ + onEditChanged(callback: (isEditing: boolean) => void): TextInputAttribute; + /** + * Called when judging whether the text editing change finished. + * @since 8 + */ + onEditChange(callback: (isEditing: boolean) => void): TextInputAttribute; + /** + * Called when submitted. + * @since 7 + */ + onSubmit(callback: (enterKey: EnterKeyType) => void): TextInputAttribute; + /** + * Called when the input of the input box changes. + * @since 7 + */ + onChange(callback: (value: string) => void): TextInputAttribute; + /** + * Called when the input of maximum text length is set. + * @since 7 + */ + maxLength(value: number): TextInputAttribute; + /** + * Called when the font color is set. + * @since 7 + */ + fontColor(value: ResourceColor): TextInputAttribute; + /** + * Called when the font size is set. + * @since 7 + */ + fontSize(value: Length): TextInputAttribute; + /** + * Called when the font style of a font is set. + * @since 7 + */ + fontStyle(value: FontStyle): TextInputAttribute; + /** + * Called when the font weight is set. + * @since 7 + */ + fontWeight(value: number | FontWeight | string): TextInputAttribute; + /** + * Called when the font list of text is set. + * @since 7 + */ + fontFamily(value: ResourceStr): TextInputAttribute; + /** + * Called when the inputFilter of text is set. + * @since 8 + */ + inputFilter(value: ResourceStr, error?: (value: string) => void): TextInputAttribute; + /** + * Called when using the Clipboard menu + * @since 8 + */ + onCopy(callback: (value: string) => void): TextInputAttribute; + /** + * Called when using the Clipboard menu + * @since 8 + */ + onCut(callback: (value: string) => void): TextInputAttribute; + /** + * Called when using the Clipboard menu + * @since 8 + */ + onPaste(callback: (value: string) => void): TextInputAttribute; + /** + * Called when the copy option is set. + * @since 9 + */ + copyOption(value: boolean | CopyOption): TextInputAttribute; + /** + * Called when the password show/hide icon is set. + * @since 9 + */ + showPasswordIcon(value: boolean): TextInputAttribute; + /** + * Called when the text align is set. + * @since 9 + */ + textAlign(value: TextAlign): TextInputAttribute; +} +declare const TextInput: TextInputInterface; +declare const TextInputInstance: TextInputAttribute; diff --git a/build-tools/api/@internal/component/ets/text_picker.d.ts b/build-tools/api/@internal/component/ets/text_picker.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c7a416c35e7de45b5471f477fae7495ffecc827 --- /dev/null +++ b/build-tools/api/@internal/component/ets/text_picker.d.ts @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the options of TextPicker. + * @since 8 + */ +declare interface TextPickerOptions { + /** + * Specifies the range of the text selector. + */ + range: string[] | Resource; + /** + * Value of the current selection. + */ + value?: string; + /** + * Current selected subscript. + */ + selected?: number; +} +/** + * @since 8 + */ +interface TextPickerInterface { + /** + * Defines the TextPicker constructor. + * @since 8 + */ + (options?: TextPickerOptions): TextPickerAttribute; +} +/** + * Style the text selector. + * @since 8 + */ +declare class TextPickerAttribute extends CommonMethod { + /** + * Called when the default height of the selected element is set. + * @since 8 + */ + defaultPickerItemHeight(value: number | string): TextPickerAttribute; + /** + * Called when the pop-up value is returned. + * @since 8 + */ + onAccept(callback: (value: string, index: number) => void): TextPickerAttribute; + /** + * Called when the Cancel button in the pop-up window is clicked. + * @since 8 + */ + onCancel(callback: () => void): TextPickerAttribute; + /** + * Called when the OK button in the pop-up window is clicked. + * @since 8 + */ + onChange(callback: (value: string, index: number) => void): TextPickerAttribute; +} +/** + * Defines the struct of TextPickerResult. + * @since 8 + */ +declare interface TextPickerResult { + /** + * The currently selected value. + * @since 8 + */ + value: string; + /** + * The subscript of the current selection. + * @since 8 + */ + index: number; +} +/** + * Defines the TextPickerDialogOptions for Text Picker Dialog. + * @since 8 + */ +declare interface TextPickerDialogOptions extends TextPickerOptions { + /** + * Called when the default height of the selected element is set. + * @since 8 + */ + defaultPickerItemHeight?: number | string; + /** + * Called when the OK button in the dialog is clicked. + * @since 8 + */ + onAccept?: (value: TextPickerResult) => void; + /** + * Called when the Cancel button in the dialog is clicked. + * @since 8 + */ + onCancel?: () => void; + /** + * This event is triggered when a TextPicker text is selected in dialog. + * @since 8 + */ + onChange?: (value: TextPickerResult) => void; +} +/** + * Defines TextPickerDialog which uses show method to show TextPicker dialog. + * @since 8 + */ +declare class TextPickerDialog { + /** + * Invoking method display. + * @since 8 + */ + static show(options?: TextPickerDialogOptions); +} +declare const TextPicker: TextPickerInterface; +declare const TextPickerInstance: TextPickerAttribute; diff --git a/build-tools/api/@internal/component/ets/text_timer.d.ts b/build-tools/api/@internal/component/ets/text_timer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc3049b88f9275db7c4cb9f9767ea12eeff7cbba --- /dev/null +++ b/build-tools/api/@internal/component/ets/text_timer.d.ts @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides a way to control the process. + * @since 8 + */ +declare class TextTimerController { + /** + * constructor. + * @since 8 + */ + constructor(); + /** + * Provides a start event for timer. + * @since 8 + */ + start(); + /** + * Provides a pause event for timer. + * @since 8 + */ + pause(); + /** + * Provides an event to reset timer. + * @since 8 + */ + reset(); +} +/** + * Defines the options of TextTimer. + * @since 8 + */ +interface TextTimerOptions { + /** + * Sets whether to countdown.The default value is false. + * @since 8 + */ + isCountDown?: boolean; + /** + * Specifies the timer range. + * In the non-countDown scenario, a negative value indicates that the timer is not limited. + * The unit is millisecond. + * @since 8 + */ + count?: number; + /** + * Controller of Texttimer. + * @since 8 + */ + controller?: TextTimerController; +} +/** + * Provides an interface for texttimer containers. + * @since 8 + */ +interface TextTimerInterface { + /** + * Defines the TextTimer constructor. + * @since 8 + */ + (options?: TextTimerOptions): TextTimerAttribute; +} +/** + * Defines the TextTimer attribute functions. + * @since 8 + */ +declare class TextTimerAttribute extends CommonMethod { + /** + * Set the display time format, for example, now is hh/mm/ss/ms and current: hh-mm-ss-ms. + * The time format string can be hh, mm, ss, or ms. + * @since 8 + */ + format(value: string): TextTimerAttribute; + /** + * Called when the font color is set. + * @since 8 + */ + fontColor(value: ResourceColor): TextTimerAttribute; + /** + * Called when the font size is set. + * @since 8 + */ + fontSize(value: Length): TextTimerAttribute; + /** + * Called when the fontStyle is set + * @since 8 + */ + fontStyle(value: FontStyle): TextTimerAttribute; + /** + * Called when the fontWeight is set + * @since 8 + */ + fontWeight(value: number | FontWeight | string): TextTimerAttribute; + /** + * Called when the fontFamily is set + * @since 8 + */ + fontFamily(value: ResourceStr): TextTimerAttribute; + /** + * Called when the timer value is returned. + * @since 8 + */ + onTimer(event: (utc: number, elapsedTime: number) => void): TextTimerAttribute; +} +declare const TextTimer: TextTimerInterface; +declare const TextTimerInstance: TextTimerAttribute; diff --git a/build-tools/api/@internal/component/ets/time_picker.d.ts b/build-tools/api/@internal/component/ets/time_picker.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6d6cd59055f1af9635077dce4778525ff0e14a4c --- /dev/null +++ b/build-tools/api/@internal/component/ets/time_picker.d.ts @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the struct of TimePickerResult. + * @since 8 + */ +declare interface TimePickerResult { + /** + * Application hour + * @since 8 + */ + hour?: number; + /** + * Application minute + * @since 8 + */ + minute?: number; +} +/** + * Defines the options of TimePicker. + * @since 8 + */ +declare interface TimePickerOptions { + /** + * Specifies the time selector check time. + */ + selected?: Date; +} +/** + * Defines the TimePicker Component. + * @since 8 + */ +interface TimePickerInterface { + /** + * Defines the TimePicker constructor. + * @since 8 + */ + (options?: TimePickerOptions): TimePickerAttribute; +} +/** + * Defines the TimePicker attribute functions. + * @since 8 + */ +declare class TimePickerAttribute extends CommonMethod { + /** + * Time Selector: indicates whether to display the 24-hour clock. + * @since 8 + */ + useMilitaryTime(value: boolean): TimePickerAttribute; + /** + * This event is triggered when a TimePicker time is selected. + * @since 8 + */ + onChange(callback: (value: TimePickerResult) => void): TimePickerAttribute; +} +/** + * Defines the TimePickerDialogOptions for Data Picker Dialog. + * @since 8 + */ +declare interface TimePickerDialogOptions extends TimePickerOptions { + /** + * Time Selector: indicates whether to display the 24-hour clock. + * @since 8 + */ + useMilitaryTime?: boolean; + /** + * Called when the OK button in the dialog is clicked. + * @since 8 + */ + onAccept?: (value: TimePickerResult) => void; + /** + * Called when the Cancel button in the dialog is clicked. + * @since 8 + */ + onCancel?: () => void; + /** + * This event is triggered when a TimePicker Time or time is selected in dialog. + * @since 8 + */ + onChange?: (value: TimePickerResult) => void; +} +/** + * Defines TimePickerDialog which uses show method to show TimePicker dialog. + * @since 8 + */ +declare class TimePickerDialog { + /** + * Invoking method display. + * @since 8 + */ + static show(options?: TimePickerDialogOptions); +} +declare const TimePicker: TimePickerInterface; +declare const TimePickerInstance: TimePickerAttribute; diff --git a/build-tools/api/@internal/component/ets/toggle.d.ts b/build-tools/api/@internal/component/ets/toggle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2d51c6e479d970a151b3b84fed232c0f4dd90004 --- /dev/null +++ b/build-tools/api/@internal/component/ets/toggle.d.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Declare the type of status button + * @since 8 + */ +declare enum ToggleType { + /** + * Checkbox + * @since 8 + */ + Checkbox, + /** + * Switch + * @since 8 + */ + Switch, + /** + * Button + * @since 8 + */ + Button +} +/** + * Defines the toggle interface. + * @since 8 + */ +interface ToggleInterface { + /** + * Set parameters to obtain the toggle. + * @since 8 + */ + (options: { + type: ToggleType; + isOn?: boolean; + }): ToggleAttribute; +} +/** + * Defines the toggle attibute functions + * @since 8 + */ +declare class ToggleAttribute extends CommonMethod { + /** + * Called when the selected state of the component changes. + * @since 8 + */ + onChange(callback: (isOn: boolean) => void): ToggleAttribute; + /** + * Called when the color of the selected button is set. + * @since 8 + */ + selectedColor(value: ResourceColor): ToggleAttribute; + /** + * Called when the color of the selected button is set. + * @since 8 + */ + switchPointColor(color: ResourceColor): ToggleAttribute; +} +declare const Toggle: ToggleInterface; +declare const ToggleInstance: ToggleAttribute; diff --git a/build-tools/api/@internal/component/ets/units.d.ts b/build-tools/api/@internal/component/ets/units.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b0f495f9343b1b4e9a29b73e48840391151062b --- /dev/null +++ b/build-tools/api/@internal/component/ets/units.d.ts @@ -0,0 +1,375 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the data type of the interface restriction. + * @since 7 + */ +declare interface Resource { + /** + * Set id. + * @since 7 + */ + readonly id: number; + /** + * Set type. + * @since 7 + */ + readonly type: number; + /** + * Set params. + * @since 7 + */ + readonly params?: any[]; + /** + * Set bundleName. + * @since 9 + */ + readonly bundleName: string; + /** + * Set moduleName. + * @since 9 + */ + readonly moduleName: string; +} +/** + * Defines the length property with string, number and resource unit. + * @since 7 + */ +declare type Length = string | number | Resource; +/** + * Defines the string which can use resource. + * @since 7 + */ +declare type ResourceStr = string | Resource; +/** + * Defines the padding property. + * @since 7 + */ +declare type Padding = { + /** + * top property. + */ + top?: Length; + /** + * right property. + */ + right?: Length; + /** + * bottom property. + */ + bottom?: Length; + /** + * left property. + */ + left?: Length; +}; +/** + * Defines the margin property. + * @since 7 + */ +declare type Margin = Padding; +/** + * Defines the border width property. + * @since 9 + */ +declare type EdgeWidths = { + /** + * top property. + * @since 9 + */ + top?: Length; + /** + * right property. + * @since 9 + */ + right?: Length; + /** + * bottom property. + * @since 9 + */ + bottom?: Length; + /** + * left property. + * @since 9 + */ + left?: Length; +}; +/** + * Defines the border radius property. + * @since 9 + */ +declare type BorderRadiuses = { + /** + * top-left property. + * @since 9 + */ + topLeft?: Length; + /** + * top-right property. + * @since 9 + */ + topRight?: Length; + /** + * bottom-left property. + * @since 9 + */ + bottomLeft?: Length; + /** + * bottom-right property. + * @since 9 + */ + bottomRight?: Length; +}; +/** + * Defines the border color property. + * @since 9 + */ +declare type EdgeColors = { + /** + * top property. + * @since 9 + */ + top?: ResourceColor; + /** + * right property. + * @since 9 + */ + right?: ResourceColor; + /** + * bottom property. + * @since 9 + */ + bottom?: ResourceColor; + /** + * left property. + * @since 9 + */ + left?: ResourceColor; +}; +/** + * Defines the border style property. + * @since 9 + */ +declare type EdgeStyles = { + /** + * top property. + * @since 9 + */ + top?: BorderStyle; + /** + * right property. + * @since 9 + */ + right?: BorderStyle; + /** + * bottom property. + * @since 9 + */ + bottom?: BorderStyle; + /** + * left property. + * @since 9 + */ + left?: BorderStyle; +}; +/** + * Defines the offset property. + * @since 7 + */ +declare type Offset = { + /** + * dx property. + */ + dx: Length; + /** + * dy property. + */ + dy: Length; +}; +/** + * Defines the color which can use resource. + * @since 7 + */ +declare type ResourceColor = Color | number | string | Resource; +/** + * Defines the length constrain property. + * @since 9 + */ +declare type LengthConstrain = { + /** + * minimum length. + */ + minLength: Length; + /** + * maximum length. + */ + maxLength: Length; +}; +/** + * Defines the font used for text. + * @since 7 + */ +declare interface Font { + /** + * font size. + */ + size?: Length; + /** + * font weight. + */ + weight?: FontWeight | number | string; + /** + * font family. + */ + family?: string | Resource; + /** + * font style. + */ + style?: FontStyle; +} +/** + * Defines the area property. + * @since 8 + */ +declare interface Area { + /** + * Defines the width property. + * @since 8 + */ + width: Length; + /** + * Defines the height property. + * @since 8 + */ + height: Length; + /** + * Defines the local position. + * @since 8 + */ + position: Position; + /** + * Defines the global position. + * @since 8 + */ + globalPosition: Position; +} +/** + * Defines the position. + * @since 7 + */ +declare interface Position { + /** + * Coordinate x of the Position. + * @since 7 + */ + x?: Length; + /** + * Coordinate y of the Position. + * @since 7 + */ + y?: Length; +} +/** + * Defines the constrain size options. + * @since 7 + */ +declare interface ConstraintSizeOptions { + /** + * Defines the min width. + * @since 7 + */ + minWidth?: Length; + /** + * Defines the max width. + * @since 7 + */ + maxWidth?: Length; + /** + * Defines the min height. + * @since 7 + */ + minHeight?: Length; + /** + * Defines the max height. + * @since 7 + */ + maxHeight?: Length; +} +/** + * Defines the size options. + * @since 7 + */ +declare interface SizeOptions { + /** + * Defines the width. + * @since 7 + */ + width?: Length; + /** + * Defines the height. + * @since 7 + */ + height?: Length; +} +/** + * Defines the options of border. + * @since 7 + */ +declare interface BorderOptions { + /** + * Defines the border width. + * @type { Length } + * @since 7 + */ + /** + * Defines the border width. + * @type { EdgeWidths | Length } + * @since 9 + */ + width?: EdgeWidths | Length; + /** + * Defines the border color. + * @type { ResourceColor } + * @since 7 + */ + /** + * Defines the border color. + * @type { EdgeColors | ResourceColor } + * @since 9 + */ + color?: EdgeColors | ResourceColor; + /** + * Defines the border radius. + * @type { Length } + * @since 7 + */ + /** + * Defines the border radius. + * @type { BorderRadiuses | Length } + * @since 9 + */ + radius?: BorderRadiuses | Length; + /** + * Defines the border style. + * @type { BorderStyle } + * @since 7 + */ + /** + * Defines the border style. + * @type { EdgeStyles | BorderStyle } + * @since 9 + */ + style?: EdgeStyles | BorderStyle; +} diff --git a/build-tools/api/@internal/component/ets/video.d.ts b/build-tools/api/@internal/component/ets/video.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f7900f7c9355d1c21ff4f11e7fb03da423ebddb6 --- /dev/null +++ b/build-tools/api/@internal/component/ets/video.d.ts @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Seek mode. + * @since 8 + */ +declare enum SeekMode { + /** + * Sync to keyframes before the time point. + * @since 8 + */ + PreviousKeyframe, + /** + * Sync to keyframes after the time point. + * @since 8 + */ + NextKeyframe, + /** + * Sync to closest keyframes. + * @since 8 + */ + ClosestKeyframe, + /** + * Seek to frames closest the time point. + * @since 8 + */ + Accurate +} +/** + * playback speed. + * @since 8 + */ +declare enum PlaybackSpeed { + /** + * 0.75x speed playback. + * @since 8 + */ + Speed_Forward_0_75_X, + /** + * 1.00x speed playback. + * @since 8 + */ + Speed_Forward_1_00_X, + /** + * 1.25x speed playback. + * @since 8 + */ + Speed_Forward_1_25_X, + /** + * 1.75x speed playback. + * @since 8 + */ + Speed_Forward_1_75_X, + /** + * 2.00x speed playback. + * @since 8 + */ + Speed_Forward_2_00_X +} +/** + * Defines the video options. + * @since 7 + */ +declare interface VideoOptions { + /** + * src of video. + * @since 7 + */ + src?: string | Resource; + /** + * playback rate of video. + * @since 7 + */ + currentProgressRate?: number | string | PlaybackSpeed; + /** + * preview uri of video. + * @since 7 + */ + previewUri?: string | PixelMap | Resource; + /** + * controller of video. + * @since 7 + */ + controller?: VideoController; +} +/** + * Defines the video controller. + * @since 7 + */ +declare class VideoController { + /** + * constructor. + * @since 7 + */ + constructor(); + /** + * Provides events to play. + * @since 7 + */ + start(); + /** + * Provides a pause event for playback. + * @since 7 + */ + pause(); + /** + * Provides an event to stop playback. + * @since 7 + */ + stop(); + /** + * Provide the progress method of video playback. + * @since 7 + */ + setCurrentTime(value: number); + /** + * Provides a full screen playback method. + * @since 7 + */ + requestFullscreen(value: boolean); + /** + * Provides a method to exit full screen playback. + * @since 7 + */ + exitFullscreen(); + /** + * Provide the progress method of video playback. + * @since 8 + */ + setCurrentTime(value: number, seekMode: SeekMode); +} +/** + * Defines the video interface. + * @since 7 + */ +interface VideoInterface { + /** + * Set the value. + * @since 7 + */ + (value: VideoOptions): VideoAttribute; +} +/** + * Defines the video attribute functions. + * @since 7 + */ +declare class VideoAttribute extends CommonMethod { + /** + * Called when judging whether the video is muted. + * @since 7 + */ + muted(value: boolean): VideoAttribute; + /** + * Called when judging whether the video is played automatically. + * @since 7 + */ + autoPlay(value: boolean): VideoAttribute; + /** + * Called when judging whether the control bar is displayed. + * @since 7 + */ + controls(value: boolean): VideoAttribute; + /** + * Called when judging whether the video is played circular. + * @since 6 + */ + loop(value: boolean): VideoAttribute; + /** + * Called when determining the zoom type of the video source. + * @since 7 + */ + objectFit(value: ImageFit): VideoAttribute; + /** + * Called when the video is played. + * @since 7 + */ + onStart(event: () => void): VideoAttribute; + /** + * Called when the video is paused. + * @since 7 + */ + onPause(event: () => void): VideoAttribute; + /** + * Called when the video playback ends. + * @since 7 + */ + onFinish(event: () => void): VideoAttribute; + /** + * Called when the video enters and exits the full screen. + * @since 7 + */ + onFullscreenChange(callback: (event?: { + fullscreen: boolean; + }) => void): VideoAttribute; + /** + * Called when the video preparation is complete. + * @since 7 + */ + onPrepared(callback: (event?: { + duration: number; + }) => void): VideoAttribute; + /** + * Called when the time information is reported when the progress bar process is operated. + * @since 7 + */ + onSeeking(callback: (event?: { + time: number; + }) => void): VideoAttribute; + /** + * Called when the playback time information is reported after the operation progress bar is completed. + * @since 7 + */ + onSeeked(callback: (event?: { + time: number; + }) => void): VideoAttribute; + /** + * Called when the playback progress changes. + * @since 7 + */ + onUpdate(callback: (event?: { + time: number; + }) => void): VideoAttribute; + /** + * Called when playback fails. + * @since 7 + */ + onError(event: () => void): VideoAttribute; +} +declare const Video: VideoInterface; +declare const VideoInstance: VideoAttribute; diff --git a/build-tools/api/@internal/component/ets/web.d.ts b/build-tools/api/@internal/component/ets/web.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c1f86c4259718c2837d9d796b82dd22559f5019 --- /dev/null +++ b/build-tools/api/@internal/component/ets/web.d.ts @@ -0,0 +1,1295 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Enum type supplied to {@link getMessageLevel} for receiving the console log level of JavaScript. + * @since 8 + */ +declare enum MessageLevel { + /** + * Debug level. + * @since 8 + */ + Debug, + /** + * Error level. + * @since 8 + */ + Error, + /** + * Info level. + * @since 8 + */ + Info, + /** + * Log level. + * @since 8 + */ + Log, + /** + * Warn level. + * @since 8 + */ + Warn +} +/** + * The Web's behavior to load from HTTP or HTTPS. Defaults to MixedMode.None. + * @since 8 + */ +declare enum MixedMode { + /** + * Allows all sources. + * @since 8 + */ + All, + /** + * Allows sources Compatibly. + * @since 8 + */ + Compatible, + /** + * Don't allow unsecure sources from a secure origin. + * @since 8 + */ + None +} +/** + * Enum type supplied to {@link getHitTest} for indicating the cursor node HitTest. + * @since 8 + */ +declare enum HitTestType { + /** + * The edit text. + * @since 8 + */ + EditText, + /** + * The email address. + * @since 8 + */ + Email, + /** + * The HTML::a tag with src=http. + * @since 8 + */ + HttpAnchor, + /** + * The HTML::a tag with src=http + HTML::img. + * @since 8 + */ + HttpAnchorImg, + /** + * The HTML::img tag. + * @since 8 + */ + Img, + /** + * The map address. + * @since 8 + */ + Map, + /** + * The phone number. + * @since 8 + */ + Phone, + /** + * Other unknown HitTest. + * @since 8 + */ + Unknown +} +/** + * Enum type supplied to {@link cacheMode} for setting the Web cache mode. + * @since 8 + */ +declare enum CacheMode { + /** + * load cache when they are available and not expired, otherwise load online. + * @since 9 + */ + Default, + /** + * load cache when they are available, otherwise load online. + * @since 8 + */ + None, + /** + * Load cache first, then online. + * @since 8 + */ + Online, + /** + * load cache and not online. + * @since 8 + */ + Only +} +/** + * Enum type supplied to {@link renderExitReason} when onRenderExited being called. + * @since 9 + */ +declare enum RenderExitReason { + /** + * Render process non-zero exit status. + * @since 9 + */ + ProcessAbnormalTermination, + /** + * SIGKILL or task manager kill. + * @since 9 + */ + ProcessWasKilled, + /** + * Segmentation fault. + * @since 9 + */ + ProcessCrashed, + /** + * Out of memory. + * @since 9 + */ + ProcessOom, + /** + * Unknown reason. + * @since 9 + */ + ProcessExitUnknown +} +/** + * Enum type supplied to {@link FileSelectorParam} when onFileSelectorShow being called. + * @since 9 + */ +declare enum FileSelectorMode { + /** + * Allows single file to be selected. + * @since 9 + */ + FileOpenMode, + /** + * Allows multiple files to be selected. + * @since 9 + */ + FileOpenMultipleMode, + /** + * Allows file folders to be selected. + * @since 9 + */ + FileOpenFolderMode, + /** + * Allows select files to save. + * @since 9 + */ + FileSaveMode +} +/** + * Encompassed message information as parameters to {@link onFileSelectorShow} method. + * @since 9 + */ +declare class FileSelectorParam { + /** + * Constructor. + * @since 9 + */ + constructor(); + /** + * Gets the title of this file selector. + * @return Return the title of this file selector. + * + * @since 9 + */ + getTitle(): string; + /** + * Gets the FileSelectorMode of this file selector. + * @return Return the FileSelectorMode of this file selector. + * + * @since 9 + */ + getMode(): FileSelectorMode; + /** + * Gets an array of acceptable MMIE type. + * @return Return an array of acceptable MMIE type. + * + * @since 9 + */ + getAcceptType(): Array; + /** + * Gets whether this file selector use a live media captured value. + * @return Return {@code true} if captured media; return {@code false} otherwise. + * @since 9 + */ + isCapture(): boolean; +} +/** + * Defines the js result. + * @since 8 + */ +declare class JsResult { + /** + * Constructor. + * @since 8 + */ + constructor(); + /** + * Handle the user's JavaScript result if cancel the dialog. + * @since 8 + */ + handleCancel(): void; + /** + * Handle the user's JavaScript result if confirm the dialog. + * @since 8 + */ + handleConfirm(): void; + /** + * Handle the user's JavaScript result if confirm the prompt dialog. + * @since 9 + */ + handlePromptConfirm(result: string): void; +} +/** + * Defines the file selector result, related to {@link onFileSelectorShow} method. + * @since 9 + */ +declare class FileSelectorResult { + /** + * Constructor. + * @since 9 + */ + constructor(); + /** + * select a list of files. + * @since 9 + */ + handleFileList(fileList: Array): void; +} +/** + * Defines the hit test value, related to {@link getHitTestValue} method. + * @since 9 + */ +declare class HitTestValue { + /** + * Constructor. + * @since 9 + */ + constructor(); + /** + * get the hit test type. + * @since 9 + */ + getType(): HitTestType; + /** + * get the hit test extra data. + * @since 9 + */ + getExtra(): string; +} +/** + * Defines the http auth request result, related to {@link onHttpAuthRequest} method. + * @since 9 + */ +declare class HttpAuthHandler { + /** + * Constructor. + * @since 9 + */ + constructor(); + /** + * confirm. + * @since 9 + */ + confirm(userName: string, password: string): boolean; + /** + * cancel. + * @since 9 + */ + cancel(): void; + /** + * isHttpAuthInfoSaved. + * @since 9 + */ + isHttpAuthInfoSaved(): boolean; +} +/** + * Encompassed message information as parameters to {@link onConsole} method. + * @since 8 + */ +declare class ConsoleMessage { + /** + * Constructor. + * @param message The console message. + * @param sourceId The Web source file's path and name. + * @param lineNumber The line number of the console message. + * @param messageLevel The console log level. + * + * @since 8 + */ + constructor(message: string, sourceId: string, lineNumber: number, messageLevel: MessageLevel); + /** + * Gets the message of a console message. + * @return Return the message of a console message. + * + * @since 8 + */ + getMessage(): string; + /** + * Gets the Web source file's path and name of a console message. + * @return Return the Web source file's path and name of a console message. + * + * @since 8 + */ + getSourceId(): string; + /** + * Gets the line number of a console message. + * @return Return the line number of a console message. + * + * @since 8 + */ + getLineNumber(): number; + /** + * Gets the message level of a console message. + * @return Return the message level of a console message, which can be {@link MessageLevel}. + * + * @since 8 + */ + getMessageLevel(): MessageLevel; +} +/** + * Encompassed message information as parameters to {@link onConsole} method. + * @since 8 + */ +/** + * Defines the Web resource request. + * @since 8 + */ +declare class WebResourceRequest { + /** + * Constructor. + * @since 8 + */ + constructor(); + /** + * Gets request headers. + * @return Return the request headers + * + * @since 8 + */ + getRequestHeader(): Array
; + /** + * Gets the request URL. + * @return Return the request URL. + * + * @since 8 + */ + getRequestUrl(): string; + /** + * Check whether the request is associated with gesture. + * @return Return {@code true} if the request is associated with gesture;return {@code false} otherwise. + * + * @since 8 + */ + isRequestGesture(): boolean; + /** + * Check whether the request is for getting the main frame. + * @return Return {@code true} if the request is associated with gesture for getting the main frame; return {@code false} otherwise. + * + * @since 8 + */ + isMainFrame(): boolean; + /** + * Check whether the request redirects. + * @return Return {@code true} if the request redirects; return {@code false} otherwise. + * + * @since 8 + */ + isRedirect(): boolean; +} +/** + * Defines the Web resource response. + * @since 8 + */ +declare class WebResourceResponse { + /** + * Constructor. + * @since 8 + */ + constructor(); + /** + * Gets the response data. + * @return Return the response data. + * + * @since 8 + */ + getResponseData(): string; + /** + * Gets the response encoding. + * @return Return the response encoding. + * + * @since 8 + */ + getResponseEncoding(): string; + /** + * Gets the response MIME type. + * @return Return the response MIME type. + * + * @since 8 + */ + getResponseMimeType(): string; + /** + * Gets the reason message. + * @return Return the reason message. + * + * @since 8 + */ + getReasonMessage(): string; + /** + * Gets the response headers. + * @return Return the response headers. + * + * @since 8 + */ + getResponseHeader(): Array
; + /** + * Gets the response code. + * @return Return the response code. + * + * @since 8 + */ + getResponseCode(): number; + /** + * Sets the response data. + * @param data the response data. + * + * @since 9 + */ + setResponseData(data: string); + /** + * Sets the response encoding. + * @param encoding the response encoding. + * + * @since 9 + */ + setResponseEncoding(encoding: string); + /** + * Sets the response MIME type. + * @param mimeType the response MIME type. + * + * @since 9 + */ + setResponseMimeType(mimeType: string); + /** + * Sets the reason message. + * @param reason the reason message. + * + * @since 9 + */ + setReasonMessage(reason: string); + /** + * Sets the response headers. + * @param header the response headers. + * + * @since 9 + */ + setResponseHeader(header: Array
); + /** + * Sets the response code. + * @param code the response code. + * + * @since 9 + */ + setResponseCode(code: number); +} +/** + * Defines the Web's request/response header. + * @since 8 + */ +declare interface Header { + /** + * Gets the key of the request/response header. + * @since 8 + */ + headerKey: string; + /** + * Gets the value of the request/response header. + * @since 8 + */ + headerValue: string; +} +/** + * Defines the Web resource error. + * @since 8 + */ +declare class WebResourceError { + /** + * Constructor. + * @since 8 + */ + constructor(); + /** + * Gets the info of the Web resource error. + * @return Return the info of the Web resource error. + * + * @since 8 + */ + getErrorInfo(): string; + /** + * Gets the code of the Web resource error. + * @return Return the code of the Web resource error. + * + * @since 8 + */ + getErrorCode(): number; +} +/** + * Defines the js geolocation request. + * @since 8 + */ +declare class JsGeolocation { + /** + * Constructor. + * @since 8 + */ + constructor(); + /** + * Report the geolocation permission status from users. + * @param origin The origin that ask for the geolocation permission. + * @param allow The geolocation permission status. + * @param retain Whether to allow the geolocation permission status to be saved to the system. + * + * @since 8 + */ + invoke(origin: string, allow: boolean, retain: boolean): void; +} +/** + * Defines the Web cookie. + * @since 8 + */ +declare class WebCookie { + /** + * Constructor. + * @since 8 + */ + constructor(); + /** + * Get whether cookies can be send or accepted. + * @return true if can send and accept cookies else false. + * + * @since 9 + */ + isCookieAllowed(): boolean; + /** + * Get whether third party cookies can be send or accepted. + * @return true if can send and accept third party cookies else false. + * + * @since 9 + */ + isThirdPartyCookieAllowed(): boolean; + /** + * Get whether file scheme cookies can be send or accepted. + * @return true if can send and accept else false. + * @since 9 + */ + isFileURICookieAllowed(): boolean; + /** + * Set whether cookies can be send or accepted. + * @param accept whether can send and accept cookies + * + * @since 9 + */ + putAcceptCookieEnabled(accept: boolean): void; + /** + * Set whether third party cookies can be send or accepted. + * @param accept true if can send and accept else false. + * + * @since 9 + */ + putAcceptThirdPartyCookieEnabled(accept: boolean): void; + /** + * Set whether file scheme cookies can be send or accepted. + * @param accept true if can send and accept else false. + * + * @since 9 + */ + putAcceptFileURICookieEnabled(accept: boolean): void; + /** + * Sets the cookie. + * @since 8 + * @deprecated since 9 + */ + setCookie(); + /** + * Sets the cookie. + * @since 9 + */ + setCookie(url: string, value: string): boolean; + /** + * Saves the cookies. + * @since 8 + * @deprecated since 9 + */ + saveCookie(); + /** + * Saves the cookies. + * @since 9 + */ + saveCookieSync(): boolean; + /** + * Gets all cookies for the given URL. + * + * @param url the URL for which the cookies are requested. + * @return the cookie value for the given URL. + * + * @since 9 + */ + getCookie(url: string): string; + /** + * Check whether exists any cookies. + * + * @return true if exists cookies else false; + * @since 9 + */ + existCookie(): boolean; + /** + * Delete all cookies. + * + * @since 9 + */ + deleteEntireCookie(): void; + /** + * Delete session cookies. + * + * @since 9 + */ + deleteSessionCookie(): void; + /** + * Delete all expired cookies. + * + * @since 9 + */ + deleteExpiredCookie(): void; +} +/** + * Defines the Web controller. + * @since 8 + */ +declare class WebController { + /** + * Constructor. + * @since 8 + */ + constructor(); + /** + * Let the Web inactive. + * @since 8 + */ + onInactive(): void; + /** + * Let the Web active. + * @since 8 + */ + onActive(): void; + /** + * Let the Web zoom by. + * @param factor The zoom factor. + * + * @since 8 + */ + zoom(factor: number): void; + /** + * Let the Web zoom in. + * @since 9 + */ + zoomIn(): boolean; + /** + * Let the Web zoom out. + * @since 9 + */ + zoomOut(): boolean; + /** + * Clears the history in the Web. + * @since 8 + */ + clearHistory(): void; + /** + * Loads a piece of code and execute JS code in the context of the currently displayed page. + * @param options The options with a piece of code and a callback. + * + * @since 8 + */ + runJavaScript(options: { + script: string; + callback?: (result: string) => void; + }); + /** + * Loads the data or URL. + * @param options The options with the data or URL and other information. + * + * @since 8 + */ + loadData(options: { + data: string; + mimeType: string; + encoding: string; + baseUrl?: string; + historyUrl?: string; + }); + /** + * Loads the given URL. + * @param options The options with the URL and other information. + * + * @since 8 + */ + loadUrl(options: { + url: string | Resource; + headers?: Array
; + }); + /** + * refreshes the current URL. + * @since 8 + */ + refresh(); + /** + * Stops the current load. + * @since 8 + */ + stop(); + /** + * Registers the JavaScript object and method list. + * @param options The option with the JavaScript object and method list. + * + * @since 8 + */ + registerJavaScriptProxy(options: { + object: object; + name: string; + methodList: Array; + }); + /** + * Deletes a registered JavaScript object with given name. + * @param name The name of a registered JavaScript object to be deleted. + * + * @since 8 + */ + deleteJavaScriptRegister(name: string); + /** + * Gets the type of HitTest. + * @since 8 + */ + getHitTest(): HitTestType; + /** + * Gets the hit test value of HitTest. + * @since 9 + */ + getHitTestValue(): HitTestValue; + /** + * Gets the id for the current Web. + * @since 9 + */ + getWebId(): number; + /** + * Gets the default user agent. + * @since 9 + */ + getDefaultUserAgent(): string; + /** + * Gets the title of current Web page. + * @since 9 + */ + getTitle(): string; + /** + * Gets the content height of current Web page. + * @since 9 + */ + getPageHeight(): number; + /** + * Gets the request focus. + * @since 8 + */ + requestFocus(); + /** + * Checks whether the web page can go back. + * @since 8 + */ + accessBackward(): boolean; + /** + * Checks whether the web page can go forward. + * @since 8 + */ + accessForward(): boolean; + /** + * Checks whether the web page can go back or forward the given number of steps. + * @param step The number of steps. + * + * @since 8 + */ + accessStep(step: number): boolean; + /** + * Goes back in the history of the web page. + * @since 8 + */ + backward(); + /** + * Goes forward in the history of the web page. + * @since 8 + */ + forward(); + /** + * Goes forward or back backOrForward in the history of the web page. + * @since 9 + */ + backOrForward(step: number): void; + /** + * Gets network cookie manager + * @since 9 + */ + getCookieManager(): WebCookie; +} +/** + * Defines the Web options. + * @since 8 + */ +declare interface WebOptions { + /** + * Sets the address of the web page to be displayed. + * @since 8 + */ + src: string | Resource; + /** + * Sets the controller of the Web. + * @since 8 + */ + controller: WebController; +} +/** + * Defines the Web interface. + * @since 8 + */ +interface WebInterface { + /** + * Sets Value. + * @since 8 + */ + (value: WebOptions): WebAttribute; +} +/** + * Defines the Web attribute functions. + * @since 8 + */ +declare class WebAttribute extends CommonMethod { + /** + * Sets whether the Web allows JavaScript scripts to execute. + * @param javaScriptAccess {@code true} means the Web can allows JavaScript scripts to execute; {@code false} otherwise. + * + * @since 8 + */ + javaScriptAccess(javaScriptAccess: boolean): WebAttribute; + /** + * Sets whether enable local file system access in Web. + * @param fileAccess {@code true} means enable local file system access in Web; {@code false} otherwise. + * + * @since 8 + */ + fileAccess(fileAccess: boolean): WebAttribute; + /** + * Sets whether javaScript running in the context of a file URL can access content from other file URLs. + * @param fileFromUrlAccess {@code true} means enable a file URL can access other file URLs; + * {@code false} otherwise. + * + * @since 9 + */ + fileFromUrlAccess(fileFromUrlAccess: boolean): WebAttribute; + /** + * Sets whether to allow image resources to be loaded from the network. + * @param onlineImageAccess {@code true} means the Web can allow image resources to be loaded from the network; + * {@code false} otherwise. + * + * @since 8 + */ + onlineImageAccess(onlineImageAccess: boolean): WebAttribute; + /** + * Sets whether to enable the DOM Storage API permission. + * @param domStorageAccess {@code true} means enable the DOM Storage API permission in Web; {@code false} otherwise. + * + * @since 8 + */ + domStorageAccess(domStorageAccess: boolean): WebAttribute; + /** + * Sets whether the Web can automatically load image resources. + * @param imageAccess {@code true} means the Web can automatically load image resources; {@code false} otherwise. + * + * @since 8 + */ + imageAccess(imageAccess: boolean): WebAttribute; + /** + * Sets how to load HTTP and HTTPS content. + * @param mixedMode The mixed mode, which can be {@link MixedMode}. + * + * @since 8 + */ + mixedMode(mixedMode: MixedMode): WebAttribute; + /** + * Sets whether the Web supports zooming using gestures. + * @param zoomAccess {@code true} means the Web supports zooming using gestures; {@code false} otherwise. + * + * @since 8 + */ + zoomAccess(zoomAccess: boolean): WebAttribute; + /** + * Sets whether to allow access to geographical locations. + * @param geolocationAccess {@code true} means the Web allows access to geographical locations; {@code false} otherwise. + * + * @since 8 + */ + geolocationAccess(geolocationAccess: boolean): WebAttribute; + /** + * Injects the JavaScript object into window and invoke the function in window. + * @param javaScriptProxy The JavaScript object to be injected. + * + * @since 8 + */ + javaScriptProxy(javaScriptProxy: { + object: object; + name: string; + methodList: Array; + controller: WebController; + }): WebAttribute; + /** + * Sets whether the Web should save the password. + * @param password {@code true} means the Web can save the password; {@code false} otherwise. + * + * @since 8 + */ + password(password: boolean): WebAttribute; + /** + * Sets the mode of cache in Web. + * @param cacheMode The cache mode, which can be {@link CacheMode}. + * + * @since 8 + */ + cacheMode(cacheMode: CacheMode): WebAttribute; + /** + * Sets whether the Web should save the table data. + * @param tableData {@code true} means the Web can save the table data; {@code false} otherwise. + * + * @since 8 + */ + tableData(tableData: boolean): WebAttribute; + /** + * Sets whether the Web access meta 'viewport' in HTML. + * @param wideViewModeAccess {@code true} means the Web access meta 'viewport' in HTML; {@code false} otherwise. + * + * @since 8 + */ + wideViewModeAccess(wideViewModeAccess: boolean): WebAttribute; + /** + * Sets whether the Web access overview mode. + * @param overviewModeAccess {@code true} means the Web access overview mode; {@code false} otherwise. + * + * @since 8 + */ + overviewModeAccess(overviewModeAccess: boolean): WebAttribute; + /** + * Sets the atio of the text zoom. + * @param textZoomAtio The atio of the text zoom. + * + * @since 8 + */ + textZoomAtio(textZoomAtio: number): WebAttribute; + /** + * Sets whether the Web access the database. + * @param databaseAccess {@code true} means the Web access the database; {@code false} otherwise. + * + * @since 8 + */ + databaseAccess(databaseAccess: boolean): WebAttribute; + /** + * Sets the initial scale for the Web. + * @param percent the initial scale for the Web. + * + * @since 9 + */ + initialScale(percent: number): WebAttribute; + /** + * Sets the Web's user agent. + * @param userAgent The Web's user agent. + * + * @since 8 + */ + userAgent(userAgent: string): WebAttribute; + /** + * Enables debugging of web contents. + * @param webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise. + * + * @since 9 + */ + webDebuggingAccess(webDebuggingAccess: boolean): WebAttribute; + /** + * Triggered at the end of web page loading. + * @param callback The triggered function at the end of web page loading. + * + * @since 8 + */ + onPageEnd(callback: (event?: { + url: string; + }) => void): WebAttribute; + /** + * Triggered at the begin of web page loading. + * @param callback The triggered function at the begin of web page loading. + * + * @since 8 + */ + onPageBegin(callback: (event?: { + url: string; + }) => void): WebAttribute; + /** + * Triggered when the page loading progress changes. + * @param callback The triggered function when the page loading progress changes. + * + * @since 8 + */ + onProgressChange(callback: (event?: { + newProgress: number; + }) => void): WebAttribute; + /** + * Triggered when the title of the main application document changes. + * @param callback The triggered function when the title of the main application document changes. + * + * @since 8 + */ + onTitleReceive(callback: (event?: { + title: string; + }) => void): WebAttribute; + /** + * Triggered when requesting to hide the geolocation. + * @param callback The triggered function when requesting to hide the geolocation permission. + * + * @since 8 + */ + onGeolocationHide(callback: () => void): WebAttribute; + /** + * Triggered when requesting to show the geolocation permission. + * @param callback The triggered function when requesting to show the geolocation permission. + * + * @since 8 + */ + onGeolocationShow(callback: (event?: { + origin: string; + geolocation: JsGeolocation; + }) => void): WebAttribute; + /** + * Triggered when the Web gets the focus. + * @param callback The triggered function when the Web gets the focus. + * + * @since 8 + */ + onRequestSelected(callback: () => void): WebAttribute; + /** + * Triggered when the Web wants to display a JavaScript alert() dialog. + * @param callback The triggered function when the web page wants to display a JavaScript alert() dialog. + * + * @since 8 + */ + onAlert(callback: (event?: { + url: string; + message: string; + result: JsResult; + }) => boolean): WebAttribute; + /** + * Triggered when the Web wants to confirm navigation from JavaScript onbeforeunload. + * @param callback The triggered function when the web page wants to confirm navigation from JavaScript onbeforeunload. + * + * @since 8 + */ + onBeforeUnload(callback: (event?: { + url: string; + message: string; + result: JsResult; + }) => boolean): WebAttribute; + /** + * Triggered when the web page wants to display a JavaScript confirm() dialog. + * @param callback The Triggered function when the web page wants to display a JavaScript confirm() dialog. + * + * @since 8 + */ + onConfirm(callback: (event?: { + url: string; + message: string; + result: JsResult; + }) => boolean): WebAttribute; + /** + * Triggered when the web page wants to display a JavaScript prompt() dialog. + * @param callback The Triggered function when the web page wants to display a JavaScript prompt() dialog. + * + * @since 9 + */ + onPrompt(callback: (event?: { + url: string; + message: string; + value: string; + result: JsResult; + }) => boolean): WebAttribute; + /** + * Triggered when the web page receives a JavaScript console message. + * @param callback The triggered function when the web page receives a JavaScript console message. + * + * @since 8 + */ + onConsole(callback: (event?: { + message: ConsoleMessage; + }) => boolean): WebAttribute; + /** + * Triggered when the web page receives a web resource loading error. + * @param callback The triggered function when the web page receives a web resource loading error. + * + * @since 8 + */ + onErrorReceive(callback: (event?: { + request: WebResourceRequest; + error: WebResourceError; + }) => void): WebAttribute; + /** + * Triggered when the web page receives a web resource loading HTTP error. + * @param callback The triggered function when the web page receives a web resource loading HTTP error. + * + * @since 8 + */ + onHttpErrorReceive(callback: (event?: { + request: WebResourceRequest; + response: WebResourceResponse; + }) => void): WebAttribute; + /** + * Triggered when starting to download. + * @param callback The triggered function when starting to download. + * + * @since 8 + */ + onDownloadStart(callback: (event?: { + url: string; + userAgent: string; + contentDisposition: string; + mimetype: string; + contentLength: number; + }) => void): WebAttribute; + /** + * Triggered when the Web page refreshes accessed history. + * @param callback The triggered callback when the Web page refreshes accessed history. + * + * @since 8 + */ + onRefreshAccessedHistory(callback: (event?: { + url: string; + isRefreshed: boolean; + }) => void): WebAttribute; + /** + * Triggered when the URL loading is intercepted. + * @param callback The triggered callback when the URL loading is intercepted. + * + * @since 8 + */ + onUrlLoadIntercept(callback: (event?: { + data: string | WebResourceRequest; + }) => boolean): WebAttribute; + /** + * Triggered when the Web page receives an ssl Error. + * @param callback The triggered callback when the Web page receives an ssl Error. + * + * @since 8 + * @deprecated since 9 + */ + onSslErrorReceive(callback: (event?: { + handler: Function; + error: object; + }) => void): WebAttribute; + /** + * Triggered when the render process exits. + * @param callback The triggered when the render process exits. + * + * @since 9 + */ + onRenderExited(callback: (event?: { + renderExitReason: RenderExitReason; + }) => void): WebAttribute; + /** + * Triggered when the file selector shows. + * @param callback The triggered when the file selector shows. + * + * @since 9 + */ + onShowFileSelector(callback: (event?: { + result: FileSelectorResult; + fileSelector: FileSelectorParam; + }) => boolean): WebAttribute; + /** + * Triggered when the render process exits. + * @param callback The triggered when the render process exits. + * + * @since 8 + * @deprecated since 9 + */ + onRenderExited(callback: (event?: { + detail: object; + }) => boolean): WebAttribute; + /** + * Triggered when the file selector shows. + * @param callback The triggered when the file selector shows. + * + * @since 8 + * @deprecated since 9 + */ + onFileSelectorShow(callback: (event?: { + callback: Function; + fileSelector: object; + }) => void): WebAttribute; + /** + * Triggered when the url loading. + * @param callback The triggered when the url loading. + * + * @since 9 + */ + onResourceLoad(callback: (event: { + url: string; + }) => void): WebAttribute; + /** + * Triggered when the scale of WebView changed. + * @param callback The triggered when the scale of WebView changed. + * + * @since 9 + */ + onScaleChange(callback: (event: { + oldScale: number; + newScale: number; + }) => void): WebAttribute; + /** + * Triggered when the browser needs credentials from the user. + * @param callback The triggered when the browser needs credentials from the user. + * + * @since 9 + */ + onHttpAuthRequest(callback: (event?: { + handler: HttpAuthHandler; + host: string; + realm: string; + }) => boolean): WebAttribute; + /** + * Triggered when the resouces loading is intercepted. + * @param callback The triggered callback when the resouces loading is intercepted. + * + * @return If the response value is null, the Web will continue to load the resouces. Otherwise, the response value will be used + * @since 9 + */ + onInterceptRequest(callback: (event?: { + request: WebResourceRequest; + }) => WebResourceResponse): WebAttribute; +} +declare const Web: WebInterface; +declare const WebInstance: WebAttribute; diff --git a/build-tools/api/@internal/component/ets/xcomponent.d.ts b/build-tools/api/@internal/component/ets/xcomponent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b9d3022c59e01555729e555aebae89da92b5e761 --- /dev/null +++ b/build-tools/api/@internal/component/ets/xcomponent.d.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines XComponentController + * @since 8 + */ +declare class XComponentController { + /** + * constructor. + * @since 8 + */ + constructor(); + /** + * get the context of native XComponent. + * @since 8 + */ + getXComponentContext(); +} +/** + * Defines XComponent. + * @since 8 + */ +interface XComponentInterface { + /** + * Constructor parameters + * @since 8 + */ + (value: { + id: string; + type: string; + libraryname?: string; + controller?: XComponentController; + }): XComponentAttribute; +} +/** + * Defines XComponentAttribute. + * @since 8 + */ +declare class XComponentAttribute extends CommonMethod { + /** + * Called when judging whether the xcomponent surface is created. + * @since 8 + */ + onLoad(callback: (event?: object) => void): XComponentAttribute; + /** + * Called when judging whether the xcomponent is destroyed. + * @since 8 + */ + onDestroy(event: () => void): XComponentAttribute; +} +declare const XComponent: XComponentInterface; +declare const XComponentInstance: XComponentAttribute; diff --git a/build-tools/api/@internal/ets/index.d.ts b/build-tools/api/@internal/ets/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f9796d4fa767adc06d1a073ba34f0be4666eb1fd --- /dev/null +++ b/build-tools/api/@internal/ets/index.d.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export * from './featureability'; +export * from './global'; +export * from './lifecycle'; diff --git a/build-tools/api/@internal/ets/lifecycle.d.ts b/build-tools/api/@internal/ets/lifecycle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea0643599df7e8cc7cde8894c204d5b354f8480b --- /dev/null +++ b/build-tools/api/@internal/ets/lifecycle.d.ts @@ -0,0 +1,562 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ResultSet } from "../../data/rdb/resultSet"; +import { AbilityInfo } from "../../bundle/abilityInfo"; +import { DataAbilityResult } from "../../ability/dataAbilityResult"; +import { DataAbilityOperation } from "../../ability/dataAbilityOperation"; +import dataAbility from "../../@ohos.data.dataAbility"; +import formBindingData from "../../@ohos.application.formBindingData"; +import formInfo from "../../@ohos.application.formInfo"; +import rdb from "../../@ohos.data.rdb"; +import rpc from "../../@ohos.rpc"; +import { PacMap } from "../../ability/dataAbilityHelper"; +/** + * interface of form lifecycle. + * + * @name LifecycleForm + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ +export declare interface LifecycleForm { + /** + * Called to return a {@link formBindingData.FormBindingData} object. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param want Indicates the detailed information for creating a {@link formBindingData#FormBindingData}. + * The {@code Want} object must include the form ID, form name, and grid style of the form, + * which can be obtained from {@link formInfo#FormParam#IDENTITY_KEY}, + * {@link formInfo#FormParam#NAME_KEY}, and {@link formInfo#FormParam#DIMENSION_KEY}, + * respectively. Such form information must be managed as persistent data for further form + * acquisition, update, and deletion. + * @return Returns the created {@link formBindingData#FormBindingData} object. + * @FAModelOnly + */ + onCreate?(want: Want): formBindingData.FormBindingData; + /** + * Called when the form provider is notified that a temporary form is successfully converted to a normal form. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param formId Indicates the ID of the form. + * @return - + * @FAModelOnly + */ + onCastToNormal?(formId: string): void; + /** + * Called to notify the form provider to update a specified form. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param formId Indicates the ID of the form to update. + * @return - + * @FAModelOnly + */ + onUpdate?(formId: string): void; + /** + * Called when the form provider receives form events from the system. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param newStatus Indicates the form events occurred. The key in the {@code Map} object indicates the form ID, + * and the value indicates the event type, which can be either {@link formInfo#VisibilityType#FORM_VISIBLE} + * or {@link formInfo#VisibilityType#FORM_INVISIBLE}. {@link formInfo#VisibilityType#FORM_VISIBLE} + * means that the form becomes visible, and {@link formInfo#VisibilityType#FORM_INVISIBLE} + * means that the form becomes invisible. + * @return - + * @FAModelOnly + */ + onVisibilityChange?(newStatus: { + [key: string]: number; + }): void; + /** + * Called when a specified message event defined by the form provider is triggered. This method is valid only for + * JS forms. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param formId Indicates the ID of the form on which the message event is triggered, which is provided by + * the client to the form provider. + * @param message Indicates the value of the {@code params} field of the message event. This parameter is + * used to identify the specific component on which the event is triggered. + * @return - + * @FAModelOnly + */ + onEvent?(formId: string, message: string): void; + /** + * Called to notify the form provider that a specified form has been deleted. Override this method if + * you want your application, as the form provider, to be notified of form deletion. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param formId Indicates the ID of the deleted form. + * @return - + * @FAModelOnly + */ + onDestroy?(formId: string): void; + /** + * Called to return a {@link FormState} object. + * + *

You must override this callback if you want this ability to return the actual form state. Otherwise, + * this method returns {@link FormState#DEFAULT} by default.

+ * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param want Indicates the description of the form for which the {@link formInfo#FormState} is obtained. + * The description covers the bundle name, ability name, module name, form name, and form dimensions. + * @return Returns the {@link formInfo#FormState} object. + * @FAModelOnly + */ + onAcquireFormState?(want: Want): formInfo.FormState; +} +/** + * interface of app lifecycle. + * + * @name LifecycleApp + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ +export declare interface LifecycleApp { + /** + * Called back when the state of an ability changes from BACKGROUND to INACTIVE. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + onShow?(): void; + /** + * Called back when an ability enters the BACKGROUND state. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + onHide?(): void; + /** + * Called back before an ability is destroyed. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + onDestroy?(): void; + /** + * Called back when an ability is started for initialization. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + onCreate?(): void; + /** + * Asks a user whether to start the migration. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return Returns {@code true} if the user allows the migration; returns {@code false} otherwise. + * @FAModelOnly + */ + onStartContinuation?(): boolean; + /** + * Saves the user data of a local ability generated during runtime. + * After the migration is triggered and the local ability is ready, this method is called when the Distributed + * Scheduler Service requests data from the local ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param data Indicates the user data to save. + * @return Returns {@code true} if the data is successfully saved; returns {@code false} otherwise. + * @FAModelOnly + */ + onSaveData?(data: Object): boolean; + /** + * Called back when a local ability migration is complete. + * + *

You can define the processing logic after the migration is complete. For example, you can display a prompt to + * notify the user of the successful migration and then exit the local ability.

+ * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param result Indicates the migration result code. The value {@code 0} indicates that the migration is + * successful, and {@code -1} indicates that the migration fails. + * @return - + * @FAModelOnly + */ + onCompleteContinuation?(result: number): void; + /** + * Restores the user data saved during the migration for an ability on the remote device immediately after the + * ability is created on the remote device. Lifecycle scheduling for the ability starts only after the user data + * is restored. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param data Indicates the user data to restore. + * @return - + * @FAModelOnly + */ + onRestoreData?(data: Object): void; + /** + * Called to notify the local device when a running ability on the remote device is destroyed after a reversible + * migration is performed for the ability from the local device to the remote device. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + onRemoteTerminated?(): void; + /** + * This method is called when the system determines that the ability may be destroyed in an unexpected + * situation, for example, when the screen orientation changes or the user touches the Home key. Generally, + * this method is used only to save temporary states. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param outState Indicates the {@code PacMap} object used for storing user data and states. This + * parameter cannot be null. + * @return - + * @FAModelOnly + */ + onSaveAbilityState?(outState: PacMap): void; + /** + * This method is called if an ability was destroyed at a certain time due to resource reclaim or was + * unexpectedly destroyed and the {@link #onSaveAbilityState(PacMap)} method was called to save its user data and + * states. Generally, this method is called after the {@link #onStart(Want)} method. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param inState Indicates the {@code PacMap} object used for storing data and states. This + * parameter can not be null. + * @return - + * @FAModelOnly + */ + onRestoreAbilityState?(inState: PacMap): void; + /** + * Called back when an ability enters the INACTIVE state (an ability in this state is not interactive and may + * change to the BACKGROUND or ACTIVE state). + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + onInactive?(): void; + /** + * Called back when an ability enters the ACTIVE state. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + onActive?(): void; + /** + * Called when the launch mode of an ability is set to singleton. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param want Indicates the new {@code want} containing information about the ability. + * @return - + * @FAModelOnly + */ + onNewWant?(want: Want): void; + /** + * Called when the system has determined to trim the memory, for example, when the ability is running in the + * background and there is no enough memory for running as many background processes as possible. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param level Indicates the memory trim level, which shows the current memory usage status. + * @return - + * @FAModelOnly + */ + onMemoryLevel?(level: number): void; +} +/** + * interface of service lifecycle. + * + * @name LifecycleService + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ +export declare interface LifecycleService { + /** + * Called back when an ability is started for initialization (it can be called only once in the entire lifecycle of + * an ability). + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + onStart?(): void; + /** + * Called back when Service is started. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param want Indicates the want of Service to start. + * @param startId Indicates the number of times the Service ability has been started. The {@code startId} is + * incremented by 1 every time the ability is started. For example, if the ability has been started + * for six times. + * @return - + * @FAModelOnly + */ + onCommand?(want: Want, startId: number): void; + /** + * Called back before an ability is destroyed. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + onStop?(): void; + /** + * Called back when a Service ability is first connected to an ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param want Indicates connection information about the Service ability. + * @return Returns the proxy of the Service ability. + * @FAModelOnly + */ + onConnect?(want: Want): rpc.RemoteObject; + /** + * Called back when all abilities connected to a Service ability are disconnected. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param want Indicates disconnection information about the Service ability. + * @return - + * @FAModelOnly + */ + onDisconnect?(want: Want): void; + /** + * Called when a new client attempts to connect to a Service ability after all previous client connections to it + * are disconnected. + * + *

The Service ability must have been started but not been destroyed, that is, {@link #startAbility} has been + * called but {@link #terminateSelf} has not.

+ * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param want Indicates the want of the Service ability being connected. + * @return - + * @FAModelOnly + */ + onReconnect?(want: Want): void; +} +/** + * interface of data lifecycle. + * + * @name LifecycleData + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ +export declare interface LifecycleData { + /** + * Updates one or more data records in the database. This method should be implemented by a Data ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the database table storing the data to update. + * @param valueBucket Indicates the data to update. This parameter can be null. + * @param predicates Indicates filter criteria. If this parameter is null, all data records will be updated by + * default. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; + /** + * Queries one or more data records in the database. This method should be implemented by a Data ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the database table storing the data to query. + * @param columns Indicates the columns to be queried, in array, for example, {"name","age"}. You should define + * the processing logic when this parameter is null. + * @param predicates Indicates filter criteria. If this parameter is null, all data records will be queried by + * default. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + query?(uri: string, columns: Array, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; + /** + * Deletes one or more data records. This method should be implemented by a Data ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the database table storing the data to delete. + * @param predicates Indicates filter criteria. If this parameter is null, all data records will be deleted by + * default. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; + /** + * Converts the given {@code uri} that refer to the Data ability into a normalized URI. A normalized URI can be + * used across devices, persisted, backed up, and restored. It can refer to the same item in the Data ability + * even if the context has changed. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the uri to normalize. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + normalizeUri?(uri: string, callback: AsyncCallback): void; + /** + * Inserts multiple data records into the database. This method should be implemented by a Data ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the position where the data is to insert. + * @param valueBuckets Indicates the data to insert. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + batchInsert?(uri: string, valueBuckets: Array, callback: AsyncCallback): void; + /** + * Converts the given normalized {@code uri} generated by {@link #normalizeUri(uri)} into a denormalized one. + * The default implementation of this method returns the original uri passed to it. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the uri to denormalize. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + denormalizeUri?(uri: string, callback: AsyncCallback): void; + /** + * Inserts a data record into the database. This method should be implemented by a Data ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the position where the data is to insert. + * @param valueBucket Indicates the data to insert. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback): void; + /** + * Opens a file. This method should be implemented by a Data ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the file to open. + * @param mode Indicates the open mode, which can be "r" for read-only access, "w" for write-only access (erasing + * whatever data is currently in the file), "wt" for write access that truncates any existing file, + * "wa" for write-only access to append to any existing data, "rw" for read and write access on any + * existing data, or "rwt" for read and write access that truncates any existing file. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + openFile?(uri: string, mode: string, callback: AsyncCallback): void; + /** + * Obtains the MIME type of files. This method should be implemented by a Data ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the files to obtain. + * @param mimeTypeFilter Indicates the MIME type of the files to obtain. This parameter cannot be set to {@code + * null}. + *

1. "*/*": Obtains all types supported by a Data ability. + *

2. "image/*": Obtains files whose main type is image of any subtype. + *

3. "*/jpg": Obtains files whose subtype is JPG of any main type. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void; + /** + * Called to carry {@code AbilityInfo} to this ability after the ability is initialized. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param info Indicates the {@code AbilityInfo} object containing information about this ability. + * @return - + * @FAModelOnly + */ + onInitialized?(info: AbilityInfo): void; + /** + * Obtains the MIME type matching the data specified by the URI of the Data ability. This method should be + * implemented by a Data ability. + * + *

Data abilities supports general data types, including text, HTML, and JPEG.

+ * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the uri of the data. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + getType?(uri: string, callback: AsyncCallback): void; + /** + * Performs batch operations on the database. This method should be implemented by a Data ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param ops Indicates the data operation list, which can contain multiple operations on the database. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + executeBatch?(ops: Array, callback: AsyncCallback>): void; + /** + * Defines a method in this Data ability (implementation depending on child classes). + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param method Indicates the method name. + * @param arg Indicates the parameter transferred by the method. + * @param extras Indicates the parameter transferred by the method. + * @param callback function specified by framework to receive the result, developer should call this function to + * return the result to framework. + * @return - + * @FAModelOnly + */ + call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback): void; +} diff --git a/build-tools/api/@internal/global.d.ts b/build-tools/api/@internal/global.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c4610e85e946dc0f0f0d201c78bb54c124c7725 --- /dev/null +++ b/build-tools/api/@internal/global.d.ts @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the console info. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 7 + */ +export declare class console { + /** + * Prints "debug" logs. + * @param message Text to print. + * @since 7 + */ + static debug(message: string, ...arguments: any[]): void; + /** + * Prints "log" logs. + * @param message Text to print. + * @since 7 + */ + static log(message: string, ...arguments: any[]): void; + /** + * Prints "info" logs. + * @param message Text to print. + * @since 7 + */ + static info(message: string, ...arguments: any[]): void; + /** + * Prints "warn" logs. + * @param message Text to print. + * @since 7 + */ + static warn(message: string, ...arguments: any[]): void; + /** + * Prints "error" logs. + * @param message Text to print. + * @since 7 + */ + static error(message: string, ...arguments: any[]): void; +} +/** + * Sets the interval for repeatedly calling a function. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param handler Indicates the function to be called after the timer goes off. For devices of "tv", "phone, tablet", and "wearable" types, this parameter can be a function or string. For devices of "lite wearable" and "smartVision" types, this parameter must be a function. + * @param delay Indicates the interval between each two calls, in milliseconds. The function will be called after this delay. + * @param arguments Indicates additional arguments to pass to "handler" when the timer goes off. + * @returns Returns the timer ID. + * @since 7 + */ +export declare function setInterval(handler: Function | string, delay: number, ...arguments: any[]): number; +/** + * Sets a timer after which a function will be executed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param handler Indicates the function to be called after the timer goes off. For devices of "tv", "phone, tablet", and "wearable" types, this parameter can be a function or string. For devices of "lite wearable" and "smartVision" types, this parameter must be a function. + * @param delay Indicates the delay (in milliseconds) after which the function will be called. If this parameter is left empty, default value "0" will be used, which means that the function will be called immediately or as soon as possible. + * @param arguments Indicates additional arguments to pass to "handler" when the timer goes off. + * @returns Returns the timer ID. + * @since 7 + */ +export declare function setTimeout(handler: Function | string, delay?: number, ...arguments: any[]): number; +/** + * Cancels the interval set by " setInterval()". + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param intervalID Indicates the timer ID returned by "setInterval()". + * @since 7 + */ +export declare function clearInterval(intervalID?: number): void; +/** + * Cancels the timer set by "setTimeout()". + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param timeoutID Indicates the timer ID returned by "setTimeout()". + * @since 7 + */ +export declare function clearTimeout(timeoutID?: number): void; +/** + * Defining syscap function. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 8 + */ +export declare function canIUse(syscap: string): boolean; +/** + * Obtains all attributes of the component with the specified ID. + * @param id ID of the component whose attributes are to be obtained. + * @since 9 + * @test + */ +export declare function getInspectorByKey(id: string): string; +/** + * Get components tree. + * @since 9 + * @test + */ +export declare function getInspectorTree(): string; +/** + * Sends an event to the component with the specified ID. + * @param id ID of the component for which the event is to be sent. + * @param action Type of the event to be sent. The options are as follows: Click event: 10 LongClick: 11. + * @param params Event parameters. If there is no parameter, pass an empty string "". + * @since 9 + * @test + */ +export declare function sendEventByKey(id: string, action: number, params: string): boolean; +/** + * Send touch event. + * @param event TouchObject to be sent. + * @since 9 + * @test + */ +export declare function sendTouchEvent(event: TouchObject): boolean; +/** + * Send key event. + * @param event KeyEvent to be sent. + * @since 9 + * @test + */ +export declare function sendKeyEvent(event: KeyEvent): boolean; +/** + * Send mouse event. + * @param event MouseEvent to be sent. + * @since 9 + * @test + */ +export declare function sendMouseEvent(event: MouseEvent): boolean; diff --git a/build-tools/api/@ohos.EnterpriseAdminExtensionAbility.d.ts b/build-tools/api/@ohos.EnterpriseAdminExtensionAbility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b4c76ab337dbe3d28f836f68a66f2dd622a20c5b --- /dev/null +++ b/build-tools/api/@ohos.EnterpriseAdminExtensionAbility.d.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class of the enterprise admin extension ability. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @StageModelOnly + */ +export default class EnterpriseAdminExtensionAbility { + /** + * Called back when an application is enabled. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @StageModelOnly + */ + onAdminEnabled(): void; + /** + * Called back when an application is disabled. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @StageModelOnly + */ + onAdminDisabled(): void; +} diff --git a/build-tools/api/@ohos.WorkSchedulerExtensionAbility.d.ts b/build-tools/api/@ohos.WorkSchedulerExtensionAbility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..76b449ee1513c69b6b6b71fa14a29d7b6f795fda --- /dev/null +++ b/build-tools/api/@ohos.WorkSchedulerExtensionAbility.d.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import workScheduler from "./@ohos.workScheduler"; +/** + * Class of the work scheduler extension ability. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + */ +export default class WorkSchedulerExtensionAbility { + /** + * Called back when a work is started. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param work The info of work. + */ + onWorkStart(work: workScheduler.WorkInfo): void; + /** + * Called back when a work is stopped. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param work The info of work. + */ + onWorkStop(work: workScheduler.WorkInfo): void; +} diff --git a/build-tools/api/@ohos.ability.dataUriUtils.d.ts b/build-tools/api/@ohos.ability.dataUriUtils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9d932581ec2527c26e934dafb89f957954a3ad7 --- /dev/null +++ b/build-tools/api/@ohos.ability.dataUriUtils.d.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * A utility class used for handling objects that use the DataAbilityHelper scheme. + * @name dataUriUtils + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + */ +declare namespace dataUriUtils { + /** + * Obtains the ID attached to the end of the path component of the given uri. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param uri Indicates the uri object from which the ID is to be obtained. + * @return Returns the ID attached to the end of the path component; + */ + function getId(uri: string): number; + /** + * Attaches the given ID to the end of the path component of the given uri. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param uri Indicates the uri string from which the ID is to be obtained. + * @param id Indicates the ID to attach. + * @return Returns the uri object with the given ID attached. + */ + function attachId(uri: string, id: number): string; + /** + * Deletes the ID from the end of the path component of the given uri. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param uri Indicates the uri object from which the ID is to be deleted. + * @return Returns the uri object with the ID deleted. + */ + function deleteId(uri: string): string; + /** + * Updates the ID in the specified uri + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param uri Indicates the uri object to be updated. + * @param id Indicates the new ID. + * @return Returns the updated uri object. + */ + function updateId(uri: string, id: number): string; +} +export default dataUriUtils; diff --git a/build-tools/api/@ohos.ability.errorCode.d.ts b/build-tools/api/@ohos.ability.errorCode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e97db3683734bde1ee6793f567fbf414b5afa04a --- /dev/null +++ b/build-tools/api/@ohos.ability.errorCode.d.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines error codes used when starting an ability, for example, featureAbility.ErrorCode.NO_ERROR. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ +export enum ErrorCode { + /** + * Permission denied. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + PERMISSION_DENY = -3, + /** + * Ability not found. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + ABILITY_NOT_FOUND = -2, + /** + * Invalid parameter. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + INVALID_PARAMETER = -1, + /** + * No error. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + NO_ERROR = 0 +} diff --git a/build-tools/api/@ohos.ability.featureAbility.d.ts b/build-tools/api/@ohos.ability.featureAbility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c7edeaf53e7ab8a44c506c2522f1aecd4b4074d --- /dev/null +++ b/build-tools/api/@ohos.ability.featureAbility.d.ts @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import { StartAbilityParameter } from './ability/startAbilityParameter'; +import { AbilityResult } from './ability/abilityResult'; +import { Context as _Context } from './app/context'; +import { DataAbilityHelper } from './ability/dataAbilityHelper'; +import { ConnectOptions } from './ability/connectOptions'; +import window from './@ohos.window'; +/** + * A Feature Ability represents an ability with a UI and is designed to interact with users. + * @name featureAbility + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @permission N/A + * @FAModelOnly + */ +declare namespace featureAbility { + /** + * Obtain the want sended from the source ability. + * + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param parameter Indicates the ability to start. + * @return - + * @FAModelOnly + */ + function getWant(callback: AsyncCallback): void; + function getWant(): Promise; + /** + * Starts a new ability. + * + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param parameter Indicates the ability to start. + * @return - + * @FAModelOnly + */ + function startAbility(parameter: StartAbilityParameter, callback: AsyncCallback): void; + function startAbility(parameter: StartAbilityParameter): Promise; + /** + * Obtains the application context. + * + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return Returns the application context. + * @since 6 + * @FAModelOnly + */ + function getContext(): Context; + /** + * Starts an ability and returns the execution result when the ability is destroyed. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param parameter Indicates the ability to start. + * @return Returns the {@link AbilityResult}. + * @FAModelOnly + */ + function startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback): void; + function startAbilityForResult(parameter: StartAbilityParameter): Promise; + /** + * Sets the result code and data to be returned by this Page ability to the caller + * and destroys this Page ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param parameter Indicates the result to return. + * @return - + * @FAModelOnly + */ + function terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback): void; + function terminateSelfWithResult(parameter: AbilityResult): Promise; + /** + * Destroys this Page ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + function terminateSelf(callback: AsyncCallback): void; + function terminateSelf(): Promise; + /** + * Obtains the dataAbilityHelper. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the file to open. + * @return Returns the dataAbilityHelper. + * @FAModelOnly + */ + function acquireDataAbilityHelper(uri: string): DataAbilityHelper; + /** + * Checks whether the main window of this ability has window focus. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return Returns {@code true} if this ability currently has window focus; returns {@code false} otherwise. + * @FAModelOnly + */ + function hasWindowFocus(callback: AsyncCallback): void; + function hasWindowFocus(): Promise; + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param request The element name of the service ability + * @param options The remote object instance + * @return Returns the number code of the ability connected + * @FAModelOnly + */ + function connectAbility(request: Want, options: ConnectOptions): number; + /** + * The callback interface was connect successfully. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param connection The number code of the ability connected + * @FAModelOnly + */ + function disconnectAbility(connection: number, callback: AsyncCallback): void; + function disconnectAbility(connection: number): Promise; + /** + * Obtains the window corresponding to the current ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return Returns the window corresponding to the current ability. + * @FAModelOnly + */ + function getWindow(callback: AsyncCallback): void; + function getWindow(): Promise; + /** + * Obtain the window configuration. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + export enum AbilityWindowConfiguration { + WINDOW_MODE_UNDEFINED = 0, + WINDOW_MODE_FULLSCREEN = 1, + WINDOW_MODE_SPLIT_PRIMARY = 100, + WINDOW_MODE_SPLIT_SECONDARY = 101, + WINDOW_MODE_FLOATING = 102 + } + /** + * Obtain the window properties. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + export enum AbilityStartSetting { + BOUNDS_KEY = "abilityBounds", + WINDOW_MODE_KEY = "windowMode", + DISPLAY_ID_KEY = "displayId" + } + /** + * Obtain the errorCode. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + export enum ErrorCode { + NO_ERROR = 0, + INVALID_PARAMETER = -1, + ABILITY_NOT_FOUND = -2, + PERMISSION_DENY = -3 + } + /** + * Indicates the operation type of data. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + export enum DataAbilityOperationType { + TYPE_INSERT = 1, + TYPE_UPDATE = 2, + TYPE_DELETE = 3, + TYPE_ASSERT = 4 + } + /** + * The context of an ability or an application. It allows access to + * application-specific resources, request and verification permissions. + * Can only be obtained through the ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import abilityManager from 'app/context' + * @FAModelOnly + */ + export type Context = _Context; +} +export default featureAbility; diff --git a/build-tools/api/@ohos.ability.particleAbility.d.ts b/build-tools/api/@ohos.ability.particleAbility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..017006bfe3524a228ffc90cf92301ce9187fdd0d --- /dev/null +++ b/build-tools/api/@ohos.ability.particleAbility.d.ts @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import { StartAbilityParameter } from './ability/startAbilityParameter'; +import { DataAbilityHelper } from './ability/dataAbilityHelper'; +import { NotificationRequest } from './notification/notificationRequest'; +import { ConnectOptions } from './ability/connectOptions'; +/** + * A Particle Ability represents an ability with service. + * @name particleAbility + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @permission N/A + * @FAModelOnly + */ +declare namespace particleAbility { + /** + * Service ability uses this method to start a specific ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param parameter Indicates the ability to start. + * @return - + * @FAModelOnly + */ + function startAbility(parameter: StartAbilityParameter, callback: AsyncCallback): void; + function startAbility(parameter: StartAbilityParameter): Promise; + /** + * Destroys this service ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @return - + * @FAModelOnly + */ + function terminateSelf(callback: AsyncCallback): void; + function terminateSelf(): Promise; + /** + * Obtains the dataAbilityHelper. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the file to open. + * @return Returns the dataAbilityHelper. + * @FAModelOnly + */ + function acquireDataAbilityHelper(uri: string): DataAbilityHelper; + /** + * Keep this Service ability in the background and display a notification bar. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @permission ohos.permission.KEEP_BACKGROUND_RUNNING + * @param id Identifies the notification bar information. + * @param request Indicates the notificationRequest instance containing information for displaying a notification bar. + * @FAModelOnly + * @deprecated + */ + function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback): void; + function startBackgroundRunning(id: number, request: NotificationRequest): Promise; + /** + * Cancel background running of this ability to free up system memory. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @FAModelOnly + * @deprecated + */ + function cancelBackgroundRunning(callback: AsyncCallback): void; + function cancelBackgroundRunning(): Promise; + /** + * Connects an ability to a Service ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param request Indicates the Service ability to connect. + * @param options Callback object for the client. If this parameter is null, an exception is thrown. + * @return unique identifier of the connection between the client and the service side. + * @FAModelOnly + */ + function connectAbility(request: Want, options: ConnectOptions): number; + /** + * Disconnects ability to a Service ability. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param connection the connection id returned from connectAbility api. + * @FAModelOnly + */ + function disconnectAbility(connection: number, callback: AsyncCallback): void; + function disconnectAbility(connection: number): Promise; + /** + * Obtain the errorCode. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + export enum ErrorCode { + INVALID_PARAMETER = -1 + } +} +export default particleAbility; diff --git a/build-tools/api/@ohos.ability.wantConstant.d.ts b/build-tools/api/@ohos.ability.wantConstant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..448c8148107ad298b20cbeae0f485a19a94e2479 --- /dev/null +++ b/build-tools/api/@ohos.ability.wantConstant.d.ts @@ -0,0 +1,289 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * the constant for action and entity in the want + * @name wantConstant + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ +declare namespace wantConstant { + /** + * the constant for action of the want + * @name Action + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ + export enum Action { + /** + * Indicates the action of backing home. + * + * @since 6 + */ + ACTION_HOME = "ohos.want.action.home", + /** + * Indicates the action of starting a Page ability that displays a keypad. + * + * @since 6 + */ + ACTION_DIAL = "ohos.want.action.dial", + /** + * Indicates the action of starting a Page ability for search. + * + * @since 6 + */ + ACTION_SEARCH = "ohos.want.action.search", + /** + * Indicates the action of starting a Page ability that provides wireless network settings, for example, + * Wi-Fi options. + * + * @since 6 + */ + ACTION_WIRELESS_SETTINGS = "ohos.settings.wireless", + /** + * Indicates the action of starting a Page ability that manages installed applications. + * + * @since 6 + */ + ACTION_MANAGE_APPLICATIONS_SETTINGS = "ohos.settings.manage.applications", + /** + * Indicates the action of starting a Page ability that displays details of a specified application. + * + *

You must specify the application bundle name in the {@code package} attribute of the {@code Intent} + * containing this action. + * + * @since 6 + */ + ACTION_APPLICATION_DETAILS_SETTINGS = "ohos.settings.application.details", + /** + * Indicates the action of starting a Page ability for setting an alarm clock. + * + * @since 6 + */ + ACTION_SET_ALARM = "ohos.want.action.setAlarm", + /** + * Indicates the action of starting a Page ability that displays all alarm + * clocks. + * + * @since 6 + */ + ACTION_SHOW_ALARMS = "ohos.want.action.showAlarms", + /** + * Indicates the action of starting a Page ability for snoozing an alarm clock. + * + * @since 6 + */ + ACTION_SNOOZE_ALARM = "ohos.want.action.snoozeAlarm", + /** + * Indicates the action of starting a Page ability for deleting an alarm clock. + * + * @since 6 + */ + ACTION_DISMISS_ALARM = "ohos.want.action.dismissAlarm", + /** + * Indicates the action of starting a Page ability for dismissing a timer. + * + * @since 6 + */ + ACTION_DISMISS_TIMER = "ohos.want.action.dismissTimer", + /** + * Indicates the action of starting a Page ability for sending a sms. + * + * @since 6 + */ + ACTION_SEND_SMS = "ohos.want.action.sendSms", + /** + * Indicates the action of starting a Page ability for opening contacts or pictures. + * + * @since 6 + */ + ACTION_CHOOSE = "ohos.want.action.choose", + /** + * Indicates the action of starting a Page ability for take a picture. + * + * @since 8 + */ + ACTION_IMAGE_CAPTURE = "ohos.want.action.imageCapture", + /** + * Indicates the action of starting a Page ability for Take a video. + * + * @since 8 + */ + ACTION_VIDEO_CAPTURE = "ohos.want.action.videoCapture", + /** + * Indicates the action of showing the application selection dialog box. + * + * @since 6 + */ + ACTION_SELECT = "ohos.want.action.select", + /** + * Indicates the action of sending a single data record. + * + * @since 6 + */ + ACTION_SEND_DATA = "ohos.want.action.sendData", + /** + * Indicates the action of sending multiple data records. + * + * @since 6 + */ + ACTION_SEND_MULTIPLE_DATA = "ohos.want.action.sendMultipleData", + /** + * Indicates the action of requesting the media scanner to scan files and adding the files to the media library. + * + * @since 6 + */ + ACTION_SCAN_MEDIA_FILE = "ohos.want.action.scanMediaFile", + /** + * Indicates the action of viewing data. + * + * @since 6 + */ + ACTION_VIEW_DATA = "ohos.want.action.viewData", + /** + * Indicates the action of editing data. + * + * @since 6 + */ + ACTION_EDIT_DATA = "ohos.want.action.editData", + /** + * Indicates the choices you will show with {@link #ACTION_PICKER}. + * + * @since 6 + */ + INTENT_PARAMS_INTENT = "ability.want.params.INTENT", + /** + * Indicates the CharSequence dialog title when used with a {@link #ACTION_PICKER}. + * + * @since 6 + */ + INTENT_PARAMS_TITLE = "ability.want.params.TITLE", + /** + * Indicates the action of select file. + * + * @since 7 + */ + ACTION_FILE_SELECT = "ohos.action.fileSelect", + /** + * Indicates the URI holding a stream of data associated with the Intent when used with a {@link #ACTION_SEND_DATA}. + * + * @since 7 + */ + PARAMS_STREAM = "ability.params.stream", + /** + * Indicates the action of providing oauth service. + * + * @since 8 + */ + ACTION_APP_ACCOUNT_OAUTH = "ohos.account.appAccount.action.oauth" + } + /** + * the constant for Entity of the want + * @name Action + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ + export enum Entity { + /** + * Indicates the default entity, which is used if the entity is not specified. + * + * @since 6 + */ + ENTITY_DEFAULT = "entity.system.default", + /** + * Indicates the home screen entity. + * + * @since 6 + */ + ENTITY_HOME = "entity.system.home", + /** + * Indicates the voice interaction entity. + * + * @since 6 + */ + ENTITY_VOICE = "entity.system.voice", + /** + * Indicates the browser category. + * + * @since 6 + */ + ENTITY_BROWSABLE = "entity.system.browsable", + /** + * Indicates the video category. + */ + ENTITY_VIDEO = "entity.system.video" + } + export enum Flags { + /** + * Indicates the grant to perform read operations on the URI. + */ + FLAG_AUTH_READ_URI_PERMISSION = 0x00000001, + /** + * Indicates the grant to perform write operations on the URI. + */ + FLAG_AUTH_WRITE_URI_PERMISSION = 0x00000002, + /** + * Returns the result to the source ability. + */ + FLAG_ABILITY_FORWARD_RESULT = 0x00000004, + /** + * Determines whether an ability on the local device can be migrated to a remote device. + */ + FLAG_ABILITY_CONTINUATION = 0x00000008, + /** + * Specifies whether a component does not belong to OHOS. + */ + FLAG_NOT_OHOS_COMPONENT = 0x00000010, + /** + * Specifies whether an ability is started. + */ + FLAG_ABILITY_FORM_ENABLED = 0x00000020, + /** + * Supports multi-device startup in the distributed scheduling system. + */ + FLAG_ABILITYSLICE_MULTI_DEVICE = 0x00000100, + /** + * Indicates that an ability using the Service template is started regardless of whether the host application has + * been started. + */ + FLAG_START_FOREGROUND_ABILITY = 0x00000200, + /** + * Install the specified ability if it's not installed. + */ + FLAG_INSTALL_ON_DEMAND = 0x00000800, + /** + * Install the specifiedi ability with background mode if it's not installed. + */ + FLAG_INSTALL_WITH_BACKGROUND_MODE = 0x80000000, + /** + * Indicates the operation of clearing other missions. This flag can be set for the {@code Intent} passed to + * {@link ohos.app.Context#startAbility} and must be used together with {@link FLAG_ABILITY_NEW_MISSION}. + */ + FLAG_ABILITY_CLEAR_MISSION = 0x00008000, + /** + * Indicates the operation of creating a task on the historical mission stack. + */ + FLAG_ABILITY_NEW_MISSION = 0x10000000, + /** + * Indicates that the existing instance of the ability to start will be reused if it is already at the top of + * the mission stack. Otherwise, a new ability instance will be created. + * + */ + FLAG_ABILITY_MISSION_TOP = 0x20000000 + } +} +export default wantConstant; diff --git a/build-tools/api/@ohos.abilityAccessCtrl.d.ts b/build-tools/api/@ohos.abilityAccessCtrl.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9606ea7ef4c43a4cdbb98cbfb0c19fd56196e057 --- /dev/null +++ b/build-tools/api/@ohos.abilityAccessCtrl.d.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @syscap SystemCapability.Security.AccessToken + */ +declare namespace abilityAccessCtrl { + /** + * Obtains the AtManager instance. + * @return returns the instance of the AtManager. + * @since 8 + */ + function createAtManager(): AtManager; + /** + * Provides methods for managing access_token. + * @name AtManager + */ + interface AtManager { + /** + * Checks whether a specified application has been granted the given permission. + * @param tokenID The tokenId of specified application. + * @param permissionName The permission name to be verified. + * @return Returns permission verify result + * @since 8 + */ + verifyAccessToken(tokenID: number, permissionName: string): Promise; + /** + * Checks whether a specified application has been granted the given permission synchronously. + * @param tokenID The tokenId of specified application. + * @param permissionName The permission name to be verified. + * @return Returns permission verify result + * @since 9 + */ + verifyAccessTokenSync(tokenID: number, permissionName: string): GrantStatus; + } + /** + * GrantStatus. + * @since 8 + */ + export enum GrantStatus { + /** + * access_token permission check fail + */ + PERMISSION_DENIED = -1, + /** + * access_token permission check success + */ + PERMISSION_GRANTED = 0 + } +} +export default abilityAccessCtrl; diff --git a/build-tools/api/@ohos.accessibility.d.ts b/build-tools/api/@ohos.accessibility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d87b35236b9807f3a7813fc0bf7bbfe0711550d0 --- /dev/null +++ b/build-tools/api/@ohos.accessibility.d.ts @@ -0,0 +1,369 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import { Callback } from './basic'; +/** + * Accessibility + * @name Accessibility + * @since 7 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @import basic,abilityInfo + */ +declare namespace accessibility { + /** + * The type of the Ability app. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @since 7 + */ + type AbilityType = 'audible' | 'generic' | 'haptic' | 'spoken' | 'visual'; + /** + * The action that the ability can execute. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @since 7 + */ + type Action = 'accessibilityFocus' | 'clearAccessibilityFocus' | 'focus' | 'clearFocus' | 'clearSelection' | 'click' | 'longClick' | 'cut' | 'copy' | 'paste' | 'select' | 'setText' | 'delete' | 'scrollForward' | 'scrollBackward' | 'setSelection'; + /** + * The type of the accessibility event. + * @note windowsChange + * @note windowContentChange + * @note windowStateChange + * @note announcement + * @note notificationChange + * @note textTraversedAtMove + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @since 7 + */ + type EventType = 'accessibilityFocus' | 'accessibilityFocusClear' | 'click' | 'longClick' | 'focus' | 'select' | 'hoverEnter' | 'hoverExit' | 'textUpdate' | 'textSelectionUpdate' | 'scroll'; + /** + * The change type of the windowsChange event. + * @note It's used when received the {@code windowsChange} event. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @since 7 + */ + type WindowUpdateType = 'add' | 'remove' | 'bounds' | 'active' | 'focus'; + /** + * The type of the ability state. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @since 7 + */ + type AbilityState = 'enable' | 'disable' | 'install'; + /** + * The ability that accessibility subsystem support. + * @note touchExplorer: Describes the capability to talkback. + * magnification: Describes the capability to request to control the display magnification. + * gesturesSimulation: Describes the capability to request to simulate the gesture. + * windowContent: Describes the capability to search for the content of the active window. + * filterKeyEvents: Describes the capability to request to filter key events. + * fingerprintGesture: Describes the capability to request to fingerprint gesture. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @since 7 + */ + type Capability = 'retrieve' | 'touchGuide' | 'keyEventObserver' | 'zoom' | 'gesture'; + /** + * The granularity of text move. + * @note The granularity of text move. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @since 7 + */ + type TextMoveUnit = 'char' | 'word' | 'line' | 'page' | 'paragraph'; + /** + * Checks whether accessibility ability is enabled. + * @since 7 + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @return Returns {@code true} if the accessibility is enabled; returns {@code false} otherwise. + */ + function isOpenAccessibility(callback: AsyncCallback): void; + function isOpenAccessibility(): Promise; + /** + * Checks touch browser ability (which is used by talkback) is enabled. + * @since 7 + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.BarrierFree.Accessibility.Vision + * @return Returns {@code true} if the touch browser is enabled; returns {@code false} otherwise. + */ + function isOpenTouchGuide(callback: AsyncCallback): void; + function isOpenTouchGuide(): Promise; + /** + * Queries the list of accessibility abilities. + * @since 7 + * @param abilityType The type of the accessibility ability. {@code AbilityType} eg.spoken + * @param stateType The state of the accessibility ability. {@code AbilityState} eg.installed + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @return Returns the list of abilityInfos. + */ + function getAbilityLists(abilityType: AbilityType, stateType: AbilityState, callback: AsyncCallback>): void; + function getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise>; + /** + * Queries the list of accessibility abilities. + * @since 9 + * @param abilityType The all type of the accessibility ability. + * @param stateType The state of the accessibility ability. {@code AbilityState} eg.installed + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @return Returns the list of abilityInfos. + */ + function getAbilityLists(abilityType: 'all', stateType: AbilityState, callback: AsyncCallback>): void; + function getAbilityLists(abilityType: 'all', stateType: AbilityState): Promise>; + /** + * Send accessibility Event. + * @since 7 + * @param event The object of the accessibility {@code EventInfo} . + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @return Returns {@code true} if success ; returns {@code false} otherwise. + */ + function sendEvent(event: EventInfo, callback: AsyncCallback): void; + function sendEvent(event: EventInfo): Promise; + /** + * Register the observe of the accessibility state changed. + * @since 7 + * @param type state event type. + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @return Returns {@code true} if the register is success ; returns {@code false} otherwise. + */ + function on(type: 'accessibilityStateChange', callback: Callback): void; + /** + * Register the observe of the touchGuide state changed. + * @since 7 + * @param type state event type. + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.BarrierFree.Accessibility.Vision + * @return Returns {@code true} if the register is success ; returns {@code false} otherwise. + */ + function on(type: 'touchGuideStateChange', callback: Callback): void; + /** + * Deregister the observe of the accessibility state changed. + * @since 7 + * @param type state event type + * @param callback Asynchronous callback interface. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @return Returns {@code true} if the deregister is success ; returns {@code false} otherwise. + */ + function off(type: 'accessibilityStateChange', callback?: Callback): void; + /** + * Deregister the observe of the touchGuide state changed. + * @since 7 + * @param type state event type + * @param callback Asynchronous callback interface. + * @return Returns {@code true} if the deregister is success ; returns {@code false} otherwise. + */ + function off(type: 'touchGuideStateChange', callback?: Callback): void; + /** + * Get the captions manager. + * @syscap SystemCapability.BarrierFree.Accessibility.Hearing + * @since 8 + * @return Returns the captions manager. + */ + function getCaptionsManager(): CaptionsManager; + /** + * Indicates the captions manager. + * @syscap SystemCapability.BarrierFree.Accessibility.Hearing + * @since 8 + */ + interface CaptionsManager { + /** + * Indicates whether captions are enabled. + */ + enabled: boolean; + /** + * Indicates the style of captions. + */ + style: CaptionsStyle; + /** + * Register the observe of the enable state. + */ + on(type: 'enableChange', callback: Callback): void; + /** + * Register the observer of the style. + */ + on(type: 'styleChange', callback: Callback): void; + /** + * Deregister the observe of the enable state. + */ + off(type: 'enableChange', callback?: Callback): void; + /** + * Deregister the observer of the style. + */ + off(type: 'styleChange', callback?: Callback): void; + } + /** + * Indicates the edge type of the captions font. + * @syscap SystemCapability.BarrierFree.Accessibility.Hearing + * @since 8 + */ + type CaptionsFontEdgeType = 'none' | 'raised' | 'depressed' | 'uniform' | 'dropShadow'; + /** + * Indicates the font family of captions. + * @syscap SystemCapability.BarrierFree.Accessibility.Hearing + * @since 8 + */ + type CaptionsFontFamily = 'default' | 'monospacedSerif' | 'serif' | 'monospacedSansSerif' | 'sansSerif' | 'casual' | 'cursive' | 'smallCapitals'; + /** + * Indicates the style of captions. + * @syscap SystemCapability.BarrierFree.Accessibility.Hearing + * @since 8 + */ + interface CaptionsStyle { + /** + * Indicates the font family of captions. + */ + fontFamily: CaptionsFontFamily; + /** + * Indicates the font scaling of captions. + */ + fontScale: number; + /** + * Indicates the font color of captions. + */ + fontColor: number | string; + /** + * Indicates the edge type of the captions font. + */ + fontEdgeType: CaptionsFontEdgeType; + /** + * Indicates the background color of captions. + */ + backgroundColor: number | string; + /** + * Indicates the window color of captions. + */ + windowColor: number | string; + } + /** + * Indicates the info of accessibility. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @since 7 + */ + interface AccessibilityAbilityInfo { + /** + * The ability id. + * @since 7 + */ + readonly id: string; + /* The ability name. + * @since 7 + */ + readonly name: string; + /* The bundle name of the ability. + * @since 7 + */ + readonly bundleName: string; + /* The target bundle name for the observation. + * @since 9 + */ + readonly targetBundleNames: Array; + /** + * The type of the ability. + * @since 7 + */ + readonly abilityTypes: Array; + /** + * The capabilities of the ability. + * @since 7 + */ + readonly capabilities: Array; + /** + * The description of the ability. + * @since 7 + */ + readonly description: string; + /** + * The events which the accessibility ability wants to observe. + * @since 7 + */ + readonly eventTypes: Array; + } + /** + * Indicates the info of events. + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @since 7 + */ + class EventInfo { + constructor(jsonObject); + /** + * The type of an accessibility event. + * @since 7 + */ + type: EventType; + /** + * The type of the window change event. + * @since 7 + */ + windowUpdateType?: WindowUpdateType; + /** + * The bundle name of the target application. + * @since 7 + */ + bundleName: string; + /** + * The type of the event source component,such as button, chart. + * @since 7 + */ + componentType?: string; + /** The page id of the event source. + * @since 7 + */ + pageId?: number; + /** + * The accessibility event description. + * @since 7 + */ + description?: string; + /** + * The action that triggers the accessibility event, for example, clicking or focusing a view. + * @since 7 + */ + triggerAction: Action; + /** + * The movement step used for reading texts. + * @since 7 + */ + textMoveUnit?: TextMoveUnit; + /** + * The content list. + * @note + * @since 7 + */ + contents?: Array; + /** + * The content changed before. + * @since 7 + */ + lastContent?: string; + /** + * The start index of listed items on the screen. + * @since 7 + */ + beginIndex?: number; + /** + * The index of the current item on the screen. + * @since 7 + */ + currentIndex?: number; + /** + * The end index of listed items on the screen. + * @since 7 + */ + endIndex?: number; + /** + * The total of the items. + * @note talkback used it when scroll. + * @since 7 + */ + itemCount?: number; + } +} +export default accessibility; diff --git a/build-tools/api/@ohos.account.appAccount.d.ts b/build-tools/api/@ohos.account.appAccount.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..616bd8977e8d6ddb26e8be2f5304950ef6e16707 --- /dev/null +++ b/build-tools/api/@ohos.account.appAccount.d.ts @@ -0,0 +1,798 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from "./basic"; +import rpc from "./@ohos.rpc"; +/** + * This module provides the capability to manage application accounts. + * + * @since 7 + * @syscap SystemCapability.Account.AppAccount + */ +declare namespace appAccount { + /** + * Obtains the AppAccountManager instance. + * @since 7 + * @syscap SystemCapability.Account.AppAccount + * @return Returns the instance of the AppAccountManager. + */ + function createAppAccountManager(): AppAccountManager; + /** + * Provides methods for managing application accounts. + * @name AppAccountManager + * @since 7 + * @syscap SystemCapability.Account.AppAccount + */ + interface AppAccountManager { + /** + * Adds the account name and extra information of this application to the account management service. + *

+ * Only the owner of the application account has the permission to call this method. + * + * @since 7 + * @param name Indicates the name of the application account to add. + * @param extraInfo Indicates the extra information of the application account to add. + * The extra information cannot be sensitive information of the application account. + * @return void. + */ + addAccount(name: string, callback: AsyncCallback): void; + addAccount(name: string, extraInfo: string, callback: AsyncCallback): void; + addAccount(name: string, extraInfo?: string): Promise; + /** + * Adds an application account of a specified owner implicitly. + * + * @since 8 + * @param owner Indicates the account owner of your application or third-party applications. + * @param authType Indicates the authentication type. + * @param options Indicates the authenticator-specific options for the request. + * @param callback Indicates the authenticator callback. + * @return void. + */ + addAccountImplicitly(owner: string, authType: string, options: { + [key: string]: any; + }, callback: AuthenticatorCallback): void; + /** + * Deletes an application account from the account management service. + *

+ * Only the owner of the application account has the permission to call this method. + * + * @since 7 + * @param name Indicates the name of the application account to delete. + * @return void. + */ + deleteAccount(name: string, callback: AsyncCallback): void; + deleteAccount(name: string): Promise; + /** + * Disables a third-party application with the specified bundle name from + * accessing the given application account. + * + * @since 7 + * @param name Indicates the name of the application account to disable access from + * the third-party application. + * @param bundleName Indicates the bundle name of the third-party application. + * @return void. + */ + disableAppAccess(name: string, bundleName: string, callback: AsyncCallback): void; + disableAppAccess(name: string, bundleName: string): Promise; + /** + * Enables a third-party application with the specified bundle name to access the given application + * account for data query and listening. + * + * @since 7 + * @param name Indicates the name of the application account. + * @param bundleName Indicates the bundle name of the third-party application. + * @return void. + */ + enableAppAccess(name: string, bundleName: string, callback: AsyncCallback): void; + enableAppAccess(name: string, bundleName: string): Promise; + /** + * Checks whether a third-party application with the specified bundle name is allowed to access + * the given application account for data query and listening. + * + * @since 9 + * @param name Indicates the name of the application account. + * @param bundleName Indicates the bundle name of the third-party application. + * @return void. + */ + checkAppAccess(name: string, bundleName: string, callback: AsyncCallback): void; + checkAppAccess(name: string, bundleName: string): Promise; + /** + * Checks whether a specified application account allows application data synchronization. + *

+ * If the same OHOS account has logged in to multiple devices, these devices constitute a super device + * through the distributed networking. On the networked devices, you can call this method to check + * whether application data can be synchronized. + *

+ * + * @since 7 + * @param name Indicates the name of the application account. + * @return Returns {@code true} if application data synchronization is allowed; returns {@code false} otherwise. + * @permission ohos.permission.DISTRIBUTED_DATASYNC. + */ + checkAppAccountSyncEnable(name: string, callback: AsyncCallback): void; + checkAppAccountSyncEnable(name: string): Promise; + /** + * Sets the credential for this application account. + * + * @since 7 + * @param name Indicates the name of the application account. + * @param credentialType Indicates the type of the credential to set. + * @param credential Indicates the credential to set. + * @return void. + */ + setAccountCredential(name: string, credentialType: string, credential: string, callback: AsyncCallback): void; + setAccountCredential(name: string, credentialType: string, credential: string): Promise; + /** + * Sets extra information for this application account. + *

+ * You can call this method when you forget the extra information of your application account or + * need to modify the extra information. + * + * @since 7 + * @param name Indicates the name of the application account. + * @param extraInfo Indicates the extra information to set. + * @return void. + */ + setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback): void; + setAccountExtraInfo(name: string, extraInfo: string): Promise; + /** + * Sets whether a specified application account allows application data synchronization. + *

+ * If the same OHOS account has logged in to multiple devices, these devices constitute a super device + * through the distributed networking. On the networked devices, you can call this method to set whether to + * allow cross-device data synchronization. If synchronization is allowed, application data can be synchronized + * among these devices in the event of any changes related to the application account. + * If synchronization is not allowed, the application data is stored only on the local device. + *

+ * Application account-related changes: adding or deleting an application account, setting extra + * information (such as updating a token), and setting data associated with this application account + *

+ * Application data that can be synchronized: application account name, token, + * and data associated with this application account + *

+ * + * @since 7 + * @param name Indicates the name of the application account. + * @param isEnable Specifies whether to allow application data synchronization. + * @return void. + * @permission ohos.permission.DISTRIBUTED_DATASYNC. + */ + setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback): void; + setAppAccountSyncEnable(name: string, isEnable: boolean): Promise; + /** + * Sets data associated with this application account. + * + * @since 7 + * @param name Indicates the name of the application account. + * @param key Indicates the key of the data to set. The key can be customized. + * @param value Indicates the value of the data to set. + * @return void. + */ + setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback): void; + setAssociatedData(name: string, key: string, value: string): Promise; + /** + * Obtains information about all accessible accounts. + *

+ * This method applies to the following accounts: + *

    + *
  • Accounts of this application.
  • + *
  • Accounts of third-party applications. To obtain such information, + * your application must have gained authorization from the third-party applications.
  • + *
+ * + * @since 7 + * @return Returns a list of application accounts. + * @permission ohos.permission.GET_ALL_APP_ACCOUNTS. + */ + getAllAccessibleAccounts(callback: AsyncCallback>): void; + getAllAccessibleAccounts(): Promise>; + /** + * Obtains information about all accounts of a specified account owner. + *

+ * This method applies to the following accounts: + *

    + *
  • Accounts of this application.
  • + *
  • Accounts of third-party applications. To obtain such information, + * your application must have gained authorization from the third-party applications.
  • + *
+ * + * @since 7 + * @param owner Indicates the account owner of your application or third-party applications. + * @return Returns a list of application accounts. + * @permission ohos.permission.GET_ALL_APP_ACCOUNTS. + */ + getAllAccounts(owner: string, callback: AsyncCallback>): void; + getAllAccounts(owner: string): Promise>; + /** + * Obtains the credential of this application account. + * + * @since 7 + * @param name Indicates the name of the application account. + * @param credentialType Indicates the type of the credential to obtain. + * @return Returns the credential of the application account. + */ + getAccountCredential(name: string, credentialType: string, callback: AsyncCallback): void; + getAccountCredential(name: string, credentialType: string): Promise; + /** + * Obtains extra information of this application account. + * + * @since 7 + * @param name Indicates the name of the application account. + * @return Returns the extra information of the account; returns {@code null} in other scenarios, + * for example, if the account does not exist. + */ + getAccountExtraInfo(name: string, callback: AsyncCallback): void; + getAccountExtraInfo(name: string): Promise; + /** + * Obtains data associated with this application account. + * + * @since 7 + * @param name Indicates the name of the application account. + * @param key Indicates the key of the data to obtain. + * @return Returns the associated data of the application account. + */ + getAssociatedData(name: string, key: string, callback: AsyncCallback): void; + getAssociatedData(name: string, key: string): Promise; + /** + * Subscribes to the change events of accounts of the specified owners. + *

+ * When the account owner updates the account, the subscriber will receive a notification + * about the account change event. + * + * @since 7 + * @param owners Indicates the account owners, which are specified + * by {@link AppAccount#AppAccount(String name, String owner)}. + * @return void + */ + on(type: 'change', owners: Array, callback: Callback>): void; + /** + * Unsubscribes from account events. + * + * @since 7 + * @return void + */ + off(type: 'change', callback?: Callback>): void; + /** + * Authenticates an application account to get an oauth token. + * + * @since 8 + * @param name Indicates the account name of your application or third-party applications. + * @param owner Indicates the account owner of your application or third-party applications. + * @param authType Indicates the authentication type. + * @param options Indicates the authenticator-specific options for the request. + * @param callback Indicates the authenticator callback. + * @return void. + */ + authenticate(name: string, owner: string, authType: string, options: { + [key: string]: any; + }, callback: AuthenticatorCallback): void; + /** + * Gets an oauth token with the specified authentication type from a particular application account. + * + * @since 8 + * @param name Indicates the account name of your application or third-party applications. + * @param owner Indicates the account owner of your application or third-party applications. + * @param authType Indicates the authentication type. + * @return Returns an oauth token. + */ + getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback): void; + getOAuthToken(name: string, owner: string, authType: string): Promise; + /** + * Sets an oauth token with the specified authentication type for a particular account. + *

+ * Only the owner of the application account has the permission to call this method. + * + * @since 8 + * @param name Indicates the account name of your application. + * @param authType Indicates the authentication type. + * @param token Indicates the oauth token. + * @return void. + */ + setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback): void; + setOAuthToken(name: string, authType: string, token: string): Promise; + /** + * Deletes an oauth token for the specified application account. + *

+ * Only tokens visible to the caller application can be deleted. + * + * @since 8 + * @param name Indicates the account name of your application or third-party applications. + * @param owner Indicates the account owner of your application or third-party applications. + * @param authType Indicates the authentication type. + * @param token Indicates the oauth token. + * @return void. + */ + deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback): void; + deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise; + /** + * Sets the oauth token visibility of the specified authentication type to a third-party application. + *

+ * Only the owner of the application account has the permission to call this method. + * + * @since 8 + * @param name Indicates the account name of your application. + * @param authType Indicates the authentication type. + * @param bundleName Indicates the bundle name of the third-party application. + * @param isVisible Indicates the bool value of visibility. + * @return void. + */ + setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback): void; + setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise; + /** + * Checks the oauth token visibility of the specified authentication type for a third-party application. + *

+ * Only the owner of the application account has the permission to call this method. + * + * @since 8 + * @param name Indicates the account name of your application or third-party applications. + * @param authType Indicates the authentication type. + * @param bundleName Indicates the bundle name of the third-party application. + * @return Returns the bool value of visibility. + */ + checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback): void; + checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise; + /** + * Gets all oauth tokens visible to the caller application. + * + * @since 8 + * @param name Indicates the account name of your application or third-party applications. + * @param owner Indicates the account owner of your application or third-party applications. + * @return Returns a list of oauth tokens visible to the caller application. + */ + getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback>): void; + getAllOAuthTokens(name: string, owner: string): Promise>; + /** + * Gets the open authorization list with a specified authentication type for a paticular application account. + *

+ * Only the owner of the application account has the permission to call this method. + * + * @since 8 + * @param name Indicates the account name of your application. + * @param authType Indicates the authentication type. + * @return Returns the open authorization list of the specified authentication type. + */ + getOAuthList(name: string, authType: string, callback: AsyncCallback>): void; + getOAuthList(name: string, authType: string): Promise>; + /** + * Gets the authenticator callback with the specified session id. + *

+ * Only the owner of the authenticator has the permission to call this method. + * + * @since 8 + * @param sessionId Indicates the id of a authentication session. + * @return Returns the authenticator callback related to the session id. + */ + getAuthenticatorCallback(sessionId: string, callback: AsyncCallback): void; + getAuthenticatorCallback(sessionId: string): Promise; + /** + * Gets the authenticator information of an application account. + * + * @since 8 + * @param owner Indicates the account owner of your application or third-party applications. + * @return Returns the authenticator information of the application account. + */ + getAuthenticatorInfo(owner: string, callback: AsyncCallback): void; + getAuthenticatorInfo(owner: string): Promise; + /** + * Checks whether a paticular account has all specified labels. + * + * @since 9 + * @param name Indicates the account name. + * @param owner Indicates the account owner. + * @param labels Indicates an array of labels to check. + * @return boolean + */ + checkAccountLabels(name: string, owner: string, labels: Array, callback: AsyncCallback): void; + checkAccountLabels(name: string, owner: string, labels: Array): Promise; + /** + * Deletes the credential of the specified application account. + * + * @since 9 + * @param name Indicates the account name. + * @param credentialType Indicates the type of the credential to delete. + * @return void. + */ + deleteAccountCredential(name: string, credentialType: string, callback: AsyncCallback): void; + deleteAccountCredential(name: string, credentialType: string): Promise; + /** + * Selects a list of accounts that satisfied with the specified options. + * + * @since 9 + * @param options Indicates the options for selecting account. + * @return Returns a list of accounts. + */ + selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback>); + selectAccountsByOptions(options: SelectAccountsOptions): Promise>; + /** + * Verifies the credential to ensure the user is the owner of the specified account. + * + * @since 9 + * @param name Indicates the account name. + * @param owner Indicates the account owner. + * @param options Indicates the options for verifying credential. + * @param callback Indicates the authenticator callback. + * @return void. + */ + verifyCredential(name: string, owner: string, callback: AuthenticatorCallback): void; + verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void; + /** + * Sets properties for the specified account authenticator. + *

+ * If the authenticator supports setting its properties, + * the caller will normally be redirected to an Ability specified by Want for property setting. + * + * @since 9 + * @param owner Indicates the owner of authenticator. + * @param callback Indicates the authenticator callback. + * @return void. + */ + setAuthenticatorProperties(owner: string, callback: AuthenticatorCallback): void; + setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callback: AuthenticatorCallback): void; + } + /** + * Provides basic information of an application account, including the account owner and name. + * @name AppAccountInfo + * @since 7 + * @syscap SystemCapability.Account.AppAccount + */ + interface AppAccountInfo { + /** + * The owner an application account. + */ + owner: string; + /** + * The name an application account. + */ + name: string; + } + /** + * Provides basic information of an oauth token, including the authentication type and token value. + * @name OAuthTokenInfo + * @since 8 + * @syscap SystemCapability.Account.AppAccount + */ + interface OAuthTokenInfo { + /** + * The authentication type. + * + * @since 8 + */ + authType: string; + /** + * The token value. + * + * @since 8 + */ + token: string; + /** + * The account to which the token belongs. + * + * @since 9 + */ + account?: AppAccountInfo; + } + /** + * Provides basic information of an authenticator, including the authenticator owner, icon id and label id. + * @name AuthenticatorInfo + * @since 8 + * @syscap SystemCapability.Account.AppAccount + */ + interface AuthenticatorInfo { + /** + * The owner of an authenticator. + */ + owner: string; + /** + * The icon id of an authenticator. + */ + iconId: number; + /** + * The label id of an authenticator. + */ + labelId: number; + } + /** + * Provides the available options for selecting accounts. + * @name SelectAccountsOptions + * @since 9 + * @syscap SystemCapability.Account.AppAccount + */ + interface SelectAccountsOptions { + /** + * The list of accounts allowed to be selected. + */ + allowedAccounts?: Array; + /** + * The list of account owners, whose accounts allowed to be selected. + */ + allowedOwners?: Array; + /** + * The labels required for the selected accounts. + */ + requiredLabels?: Array; + } + /** + * Provides the available options for verifying credential. + * @name VerifyCredentialOptions + * @since 9 + * @syscap SystemCapability.Account.AppAccount + */ + interface VerifyCredentialOptions { + /** + * The credentail type to be verified. + */ + credentialType?: string; + /** + * The credential to be verified. + */ + credential?: string; + /** + * The authenticator-specific parameters. + */ + parameters?: { + [key: string]: Object; + }; + } + /** + * Provides the available options for setting properties. + * @name SetPropertiesOptions + * @since 9 + * @syscap SystemCapability.Account.AppAccount + */ + interface SetPropertiesOptions { + /** + * The properties to be set. + */ + properties?: { + [key: string]: Object; + }; + /** + * The authenticator-specific parameters. + */ + parameters?: { + [key: string]: Object; + }; + } + /** + * Provides constants definition. + * @name Constants + * @since 8 + * @syscap SystemCapability.Account.AppAccount + */ + enum Constants { + /** + * Indicates the action for adding account implicitly. + * + * @since 8 + */ + ACTION_ADD_ACCOUNT_IMPLICITLY = "addAccountImplicitly", + /** + * Indicates the action for authenticating. + * + * @since 8 + */ + ACTION_AUTHENTICATE = "authenticate", + /** + * Indicates the key of name. + * + * @since 8 + */ + KEY_NAME = "name", + /** + * Indicates the key of owner. + * + * @since 8 + */ + KEY_OWNER = "owner", + /** + * Indicates the key of token. + * + * @since 8 + */ + KEY_TOKEN = "token", + /** + * Indicates the key of action. + * + * @since 8 + */ + KEY_ACTION = "action", + /** + * Indicates the key of authentiaction type. + * + * @since 8 + */ + KEY_AUTH_TYPE = "authType", + /** + * Indicates the key of session id. + * + * @since 8 + */ + KEY_SESSION_ID = "sessionId", + /** + * Indicates the key of caller pid. + * + * @since 8 + */ + KEY_CALLER_PID = "callerPid", + /** + * Indicates the key of caller uid. + * + * @since 8 + */ + KEY_CALLER_UID = "callerUid", + /** + * Indicates the key of caller bundle name. + * + * @since 8 + */ + KEY_CALLER_BUNDLE_NAME = "callerBundleName", + /** + * Indicates the key of required labels. + * + * @since 9 + */ + KEY_REQUIRED_LABELS = "requiredLabels", + /** + * Indicates the key of boolean result. + * + * @since 9 + */ + KEY_BOOLEAN_RESULT = "booleanResult" + } + /** + * Provides result code definition. + * @name ResultCode + * @since 8 + * @syscap SystemCapability.Account.AppAccount + */ + enum ResultCode { + SUCCESS = 0, + ERROR_ACCOUNT_NOT_EXIST = 10001, + ERROR_APP_ACCOUNT_SERVICE_EXCEPTION = 10002, + ERROR_INVALID_PASSWORD = 10003, + ERROR_INVALID_REQUEST = 10004, + ERROR_INVALID_RESPONSE = 10005, + ERROR_NETWORK_EXCEPTION = 10006, + ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST = 10007, + ERROR_OAUTH_CANCELED = 10008, + ERROR_OAUTH_LIST_TOO_LARGE = 10009, + ERROR_OAUTH_SERVICE_BUSY = 10010, + ERROR_OAUTH_SERVICE_EXCEPTION = 10011, + ERROR_OAUTH_SESSION_NOT_EXIST = 10012, + ERROR_OAUTH_TIMEOUT = 10013, + ERROR_OAUTH_TOKEN_NOT_EXIST = 10014, + ERROR_OAUTH_TOKEN_TOO_MANY = 10015, + ERROR_OAUTH_UNSUPPORT_ACTION = 10016, + ERROR_OAUTH_UNSUPPORT_AUTH_TYPE = 10017, + ERROR_PERMISSION_DENIED = 10018 + } + /** + * Provides methods for authenticator callback. + * @name AuthenticatorCallback + * @since 8 + * @syscap SystemCapability.Account.AppAccount + */ + interface AuthenticatorCallback { + /** + * Notifies the client of the authentication result. + * + * @since 8 + * @param code Indicates the result code. + * @param result Indicates the authentication result. + * @return void. + */ + onResult: (code: number, result: { + [key: string]: any; + }) => void; + /** + * Notifies the client that the authentication request need to be redirected. + * + * @since 8 + * @param request Indicates the request information to be redirected. + * @return void. + */ + onRequestRedirected: (request: Want) => void; + /** + * Notifies the client that the request is continued. + * + * @since 9 + * @return void. + */ + onRequestContinued?: () => void; + } + /** + * Provides methods for authenticator. + * @name Authenticator + * @since 8 + * @syscap SystemCapability.Account.AppAccount + */ + class Authenticator { + /** + * Adds an application account of a specified owner implicitly. + * + * @since 8 + * @param authType Indicates the authentication type. + * @param callerBundleName Indicates the caller bundle name. + * @param options Indicates the authenticator-specific options for the request. + * @param callback Indicates the authenticator callback. + * @return void. + */ + addAccountImplicitly(authType: string, callerBundleName: string, options: { + [key: string]: any; + }, callback: AuthenticatorCallback): void; + /** + * Authenticates an application account to get an oauth token. + * + * @since 8 + * @param name Indicates the account name. + * @param authType Indicates the authentication type. + * @param callerBundleName Indicates the caller bundle name. + * @param options Indicates the authenticator-specific options for the request. + * @param callback Indicates the authenticator callback. + * @return void. + */ + authenticate(name: string, authType: string, callerBundleName: string, options: { + [key: string]: any; + }, callback: AuthenticatorCallback): void; + /** + * Verifies the credential to ensure the user is the owner of the specified application account. + *

+ * The credential can be provided in the options, otherwise an Ability will normally be returned, + * which can be started by the caller to further verify credential. + * + * @since 9 + * @param name Indicates the name of the application account. + * @param options Indicates the options for verifying credential. + * @param callback Indicates the authenticator callback. + * @return void. + */ + verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void; + /** + * Sets properties for the authenticator. + * + * @since 9 + * @param options Indicates the options for setting properties. + * @param callback Indicates the authenticator callback. + * @return void. + */ + setProperties(options: SetPropertiesOptions, callback: AuthenticatorCallback): void; + /** + * Checks whether a paticular account has all specified labels. + * + * @since 9 + * @param name Indicates the account name. + * @param labels Indicates an array of labels to check. + * @param callback Indicates the authenticator callback. + * @return void. + */ + checkAccountLabels(name: string, labels: Array, callback: AuthenticatorCallback): void; + /** + * Checks whether the specified account can be removed. + * + * @since 9 + * @param name Indicates the account name. + * @param callback Indicates the authenticator callback. + * @return void. + */ + isAccountRemovable(name: string, callback: AuthenticatorCallback): void; + /** + * Gets the remote object of the authenticator for remote procedure call. + * + * @since 9 + * @return Returns a remote object. + */ + getRemoteObject(): rpc.RemoteObject; + } +} +export default appAccount; diff --git a/build-tools/api/@ohos.account.distributedAccount.d.ts b/build-tools/api/@ohos.account.distributedAccount.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c9b5fafaad7d3091138b6032f6828c51a0787657 --- /dev/null +++ b/build-tools/api/@ohos.account.distributedAccount.d.ts @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * This module provides the capability to manage distributed accounts. + * + * @since 7 + * @syscap SystemCapability.Account.OsAccount + */ +declare namespace distributedAccount { + /** + * Get the ability of the distributed account. + * @since 7 + * @syscap SystemCapability.Account.OsAccount + * @permission N/A + * @return Ability to manage operations of distributed account. + */ + function getDistributedAccountAbility(): DistributedAccountAbility; + /** + * Defines distributed account functions and interfaces. + * + * @name DistributedAccountAbility + * @since 7 + * @syscap SystemCapability.Account.OsAccount + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS + */ + interface DistributedAccountAbility { + /** + * Queries the distributed information of the current OS account. + * + * @since 7 + * @return The distributed information of the current OS account. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC + */ + queryOsAccountDistributedInfo(callback: AsyncCallback): void; + queryOsAccountDistributedInfo(): Promise; + /** + * Updates the distributed information of the OS account. + * + * @since 7 + * @param accountInfo Indicates the information of the OS account used for a distributed system. + * @return void + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + */ + updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback): void; + updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise; + } + /** + * Provides the distributed information of the OS account. + * + * @name DistributedInfo + * @since 7 + * @syscap SystemCapability.Account.OsAccount + * @permission N/A + */ + interface DistributedInfo { + /** + * The name in the distributed information of the OS account. + */ + name: string; + /** + * The ID in the distributed information of the OS account. + */ + id: string; + /** + * The event string in the distributed information of the OS account. + */ + event: string; + /** + * The scalable data in the distributed information of the OS account. + */ + scalableData?: object; + } +} +export default distributedAccount; diff --git a/build-tools/api/@ohos.account.osAccount.d.ts b/build-tools/api/@ohos.account.osAccount.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..545f76a95d46ef4a6e70c6406bdf1c69626d4eea --- /dev/null +++ b/build-tools/api/@ohos.account.osAccount.d.ts @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import distributedAccount from './@ohos.account.distributedAccount'; +import { AsyncCallback } from "./basic"; +/** + * This module provides the capability to manage os accounts. + * + * @since 7 + * @syscap SystemCapability.Account.OsAccount + */ +declare namespace osAccount { + /** + * Obtains the AccountManager instance. + * @since 7 + * @syscap SystemCapability.Account.OsAccount + * @return Returns the instance of the AccountManager. + */ + function getAccountManager(): AccountManager; + /** + * Provides abilities for you to manage and perform operations on your OS accounts. + * @name AccountManager + * @since 7 + * @syscap SystemCapability.Account.OsAccount + */ + interface AccountManager { + /** + * Checks whether the function of supporting multiple OS accounts is enabled. + * + * @since 7 + * @return Returns {@code true} if this function is enabled; returns {@code false} otherwise. + */ + isMultiOsAccountEnable(callback: AsyncCallback): void; + isMultiOsAccountEnable(): Promise; + /** + * Checks whether an OS account is activated based on its local ID. + * + * @since 7 + * @param localId Indicates the local ID of the OS account. + * @return Returns {@code true} if the OS account is activated; returns {@code false} otherwise. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + */ + isOsAccountActived(localId: number, callback: AsyncCallback): void; + isOsAccountActived(localId: number): Promise; + /** + * Checks whether a constraint has been enabled for an OS account based on its local ID. + * + * @since 7 + * @param localId Indicates the local ID of the OS account. + * @param constraint Indicates the constraint to check. The value can be: + *

    + *
  • {@code constraint.wifi.set} - Indicates the constraint on configuring the Wi-Fi access point. + *
  • + *
  • {@code constraint.sms.use} - Indicates the constraint on sending and receiving short messages. + *
  • + *
  • {@code constraint.calls.outgoing} - Indicates the constraint on making calls.
  • + *
  • {@code constraint.unknown.sources.install} - Indicates the constraint on installing applications + * from unknown sources.
  • + *
+ * @return Returns {@code true} if the constraint has been enabled for the OS account; + * returns {@code false} otherwise. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + */ + isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback): void; + isOsAccountConstraintEnable(localId: number, constraint: string): Promise; + /** + * Checks whether this OS account is a test OS account. + * + * @since 7 + * @return Returns {@code true} if this OS account is a test OS account; returns {@code false} otherwise. + */ + isTestOsAccount(callback: AsyncCallback): void; + isTestOsAccount(): Promise; + /** + * Checks whether this OS account has been verified. + * + * @since 7 + * @return Returns {@code true} if the OS account has been verified successfully; + * returns {@code false} otherwise. + */ + isOsAccountVerified(callback: AsyncCallback): void; + /** + * Checks whether an OS account has been verified based on its local ID. + * + * @since 7 + * @param localId Indicates the local ID of the OS account. + * @return Returns {@code true} if the OS account has been verified successfully; + * returns {@code false} otherwise. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + */ + isOsAccountVerified(localId: number, callback: AsyncCallback): void; + isOsAccountVerified(localId?: number): Promise; + /** + * Obtains the number of all OS accounts created on a device. + * + * @since 7 + * @return Returns the number of created OS accounts. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + */ + getCreatedOsAccountsCount(callback: AsyncCallback): void; + getCreatedOsAccountsCount(): Promise; + /** + * Obtains the local ID of an OS account from the current process UID. + * + * @since 7 + * @return Returns the local ID of the OS account. + */ + getOsAccountLocalIdFromProcess(callback: AsyncCallback): void; + getOsAccountLocalIdFromProcess(): Promise; + /** + * Queries the local ID of an OS account from the process UID. + * + * @since 7 + * @param uid Indicates the process UID. + * @return Returns the local ID of the OS account. + */ + getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback): void; + getOsAccountLocalIdFromUid(uid: number): Promise; + /** + * Queries the local ID of an OS account which is bound to the specified domain account + * + * @since 8 + * @param domainInfo Indicates the domain account info. + * @return Returns the local ID of the OS account. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + */ + getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback): void; + getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise; + /** + * Obtains all constraints of an OS account based on its local ID. + * + * @since 7 + * @param localId Indicates the local ID of the OS account. + * @return Returns a list of constraints. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + */ + getOsAccountAllConstraints(localId: number, callback: AsyncCallback>): void; + getOsAccountAllConstraints(localId: number): Promise>; + /** + * Queries the id list of all activated OS accounts. + * + * @since 8 + * @return Returns a id list of OS accounts. + */ + queryActivatedOsAccountIds(callback: AsyncCallback>): void; + queryActivatedOsAccountIds(): Promise>; + /** + * Queries information about the current OS account. + * + * @since 7 + * @return Returns information about the current OS account; returns {@code null} if the query fails. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + */ + queryCurrentOsAccount(callback: AsyncCallback): void; + queryCurrentOsAccount(): Promise; + /** + * Obtains the type of this OS account from the current process. + * + * @since 7 + * @return Returns the OS account type. The value can be {@link OsAccountType#ADMIN}, + * {@link OsAccountType#NORMAL}, and {@link OsAccountType#GUEST}. + */ + getOsAccountTypeFromProcess(callback: AsyncCallback): void; + getOsAccountTypeFromProcess(): Promise; + /** + * Obtains the distributed virtual device ID (DVID). + *

+ * If the same OHOS account has logged in to multiple devices, these devices constitute a super device + * through the distributed networking. On the networked devices, you can call this method to obtain the DVIDs. + * The same application running on different devices obtains the same DVID, whereas different applications + * obtain different DVIDs. + *

+ * + * @since 7 + * @return Returns the DVID if obtained; returns an empty string if no OHOS account has logged in. + * @permission ohos.permission.DISTRIBUTED_DATASYNC or ohos.permission.MANAGE_LOCAL_ACCOUNTS + */ + getDistributedVirtualDeviceId(callback: AsyncCallback): void; + getDistributedVirtualDeviceId(): Promise; + /** + * Obtain localId according to serial number + * + * @since 8 + * @param serialNumber Indicates serial number. + * @return localId. + */ + getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback): void; + getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise; + /** + * Obtain serial number according to localId. + * + * @since 8 + * @param localId Indicates the local ID of the OS account. + * @return serial number. + */ + getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback): void; + getSerialNumberByOsAccountLocalId(localId: number): Promise; + } + /** + * Provides information about OS accounts, including the local ID, local name, and type of an OS account. + * @name OsAccountInfo + * @since 7 + * @syscap SystemCapability.Account.OsAccount + */ + interface OsAccountInfo { + /** + * The local ID of an OS account. + * @since 7 + */ + localId: number; + /** + * The local name of an OS account. + * @since 7 + */ + localName: string; + /** + * Include: ADMIN, Normal, GUEST. + * @since 7 + */ + type: OsAccountType; + /** + * Account constraints information. + * @since 7 + */ + constraints: Array; + /** + * The account is verified or not. + * @since 8 + */ + isVerified: boolean; + /** + * OS account photo. + * @since 8 + */ + photo: string; + /** + * Os account create time. + * @since 8 + */ + createTime: number; + /** + * The last time to log in. + * @since 8 + */ + lastLoginTime: number; + /** + * Os account serial number. + * @since 8 + */ + serialNumber: number; + /** + * Os account is activated or not. + * @since 8 + */ + isActived: boolean; + /** + * Os account create completed or not. + * @since 8 + */ + isCreateCompleted: boolean; + /** + * Distributed account info. + * @since 7 + */ + distributedInfo: distributedAccount.DistributedInfo; + /** + * Domain account info. + * @since 8 + */ + domainInfo: DomainAccountInfo; + } + interface DomainAccountInfo { + /** + * The domain name + * @since 8 + */ + domain: string; + /** + * The account name in the domain + * @since 8 + */ + accountName: string; + } + /** + * Enumerates OS account types. + * @name OsAccountType + * @since 7 + * @syscap SystemCapability.Account.OsAccount + */ + enum OsAccountType { + /** + * Indicates the administrator account, which has the permission to manage other OS accounts. + */ + ADMIN = 0, + /** + * Indicates a normal account, which has access to common functions of OS accounts. + */ + NORMAL, + /** + * Indicates a guest account, which is used to temporarily access the device and may be deleted at any time. + */ + GUEST + } +} +export default osAccount; diff --git a/build-tools/api/@ohos.animator.d.ts b/build-tools/api/@ohos.animator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e20aeb9ca5edc23a68f14d1fc16f3240f83e536 --- /dev/null +++ b/build-tools/api/@ohos.animator.d.ts @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the animator options. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ +export interface AnimatorOptions { + /** + * Duration of the animation, in milliseconds. + * The default value is 0. + * @since 6 + */ + duration: number; + /** + * Time curve of the animation. For details about the supported types. + * linear The animation speed keeps unchanged. + * ease The animation starts and ends at a low speed, cubic-bezier(0.25, 0.1, 0.25, 1.0). + * ease-in The animation starts at a low speed, cubic-bezier(0.42, 0.0, 1.0, 1.0). + * ease-out The animation ends at a low speed, cubic-bezier(0.0, 0.0, 0.58, 1.0). + * ease-in-out The animation starts and ends at a low speed, cubic-bezier(0.42, 0.0, 0.58, 1.0). + * fast-out-slow-in Standard curve, cubic-bezier(0.4, 0.0, 0.2, 1.0). + * linear-out-slow-in Deceleration curve, cubic-bezier(0.0, 0.0, 0.2, 1.0). + * fast-out-linear-in Acceleration curve, cubic-bezier(0.4, 0.0, 1.0, 1.0). + * friction Damping curve, cubic-bezier(0.2, 0.0, 0.2, 1.0). + * extreme-deceleration Extreme deceleration curve, cubic-bezier(0.0, 0.0, 0.0, 1.0). + * sharp Sharp curve, cubic-bezier(0.33, 0.0, 0.67, 1.0). + * rhythm Rhythm curve, cubic-bezier(0.7, 0.0, 0.2, 1.0). + * smooth Smooth curve, cubic-bezier(0.4, 0.0, 0.4, 1.0). + * cubic-bezier(x1, y1, x2, y2) You can customize an animation speed curve in the cubic-bezier() function. The x and y values of each input parameter must be between 0 and 1. + * Step curve. The number must be set and only an integer is supported, step-position is optional. It can be set to start or end. The default value is end. + * The default value is ease. + * @since 6 + */ + easing: string; + /** + * Delay for the animation start. The default value indicates no delay. + * The default value is 0. + * @since 6 + */ + delay: number; + /** + * Whether to resume to the initial state after the animation is executed. + * none: The initial state is restored after the animation is executed. + * forwards: The state at the end of the animation (defined in the last key frame) is retained after the animation is executed. + * @since 6 + */ + fill: "none" | "forwards" | "backwards" | "both"; + /** + * The animation playback mode. + * The default value is "normal". + * @since 6 + */ + direction: "normal" | "reverse" | "alternate" | "alternate-reverse"; + /** + * Number of times the animation will be played. number indicates a fixed number of playback operations, and -1 an unlimited number of playback operations. + * The default value is 1. + * @since 6 + */ + iterations: number; + /** + * Starting point of animator interpolation. + * The default value is 0. + * @since 6 + */ + begin: number; + /** + * Ending point of Dynamic Interpolation + * The default value is 1. + * @since 6 + */ + end: number; +} +/** + * Defines the Animator result interface. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ +export interface AnimatorResult { + /** + * Update the options for current animator. + * @param options Options. + * @since 6 + */ + update(options: AnimatorOptions): void; + /** + * Starts the animation. + * @since 6 + */ + play(): void; + /** + * Ends the animation. + * @since 6 + */ + finish(): void; + /** + * Pauses the animation. + * @since 6 + */ + pause(): void; + /** + * Cancels the animation. + * @since 6 + */ + cancel(): void; + /** + * Plays the animation in reverse direction. + * @since 6 + */ + reverse(): void; + /** + * Trigger when vsync callback. + * @param progress The current progress of animtion + * @since 6 + */ + onframe: (progress: number) => void; + /** + * The animation is finished. + * @since 6 + */ + onfinish: () => void; + /** + * The animation is canceled. + * @since 6 + */ + oncancel: () => void; + /** + * The animation is repeated. + * @since 6 + */ + onrepeat: () => void; +} +/** + * Defines the Animator class. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + * @import prompt from '@ohos.animator'; + */ +export default class Animator { + /** + * Create an animator object for custum animation. + * @param options Options. + * @since 6 + */ + static createAnimator(options: AnimatorOptions): AnimatorResult; +} diff --git a/build-tools/api/@ohos.application.Ability.d.ts b/build-tools/api/@ohos.application.Ability.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d456ee731df7e49f8522554f7279a9d309f2f75b --- /dev/null +++ b/build-tools/api/@ohos.application.Ability.d.ts @@ -0,0 +1,282 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityConstant from "./@ohos.application.AbilityConstant"; +import AbilityContext from "./application/AbilityContext"; +import Want from './@ohos.application.Want'; +import window from './@ohos.window'; +import { Configuration } from './@ohos.application.Configuration'; +import rpc from './@ohos.rpc'; +/** + * The prototype of the listener function interface registered by the Caller. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @permission N/A + * @param msg Monitor status notification information. + * @return - + * @StageModelOnly + */ +export interface OnReleaseCallBack { + (msg: string): void; +} +/** + * The prototype of the message listener function interface registered by the Callee. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @permission N/A + * @param indata Notification data notified from the caller. + * @return rpc.Sequenceable + * @StageModelOnly + */ +export interface CalleeCallBack { + (indata: rpc.MessageParcel): rpc.Sequenceable; +} +/** + * The interface of a Caller. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @permission N/A + * @StageModelOnly + */ +export interface Caller { + /** + * Notify the server of Sequenceable type data. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param method The notification event string listened to by the callee. + * @param data Notification data to the callee. + * @return - + * @StageModelOnly + */ + call(method: string, data: rpc.Sequenceable): Promise; + /** + * Notify the server of Sequenceable type data and return the notification result. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param method The notification event string listened to by the callee. + * @param data Notification data to the callee. + * @return Returns the callee's notification result data on success, and returns undefined on failure. + * @StageModelOnly + */ + callWithResult(method: string, data: rpc.Sequenceable): Promise; + /** + * Clear service records. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @return - + * @StageModelOnly + */ + release(): void; + /** + * Register death listener notification callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param callback Register a callback function for listening for notifications. + * @return - + * @StageModelOnly + */ + onRelease(callback: OnReleaseCallBack): void; +} +/** +* The interface of a Callee. +* +* @since 9 +* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore +* @permission N/A +* @StageModelOnly +*/ +export interface Callee { + /** + * Register data listener callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param method A string registered to listen for notification events. + * @param callback Register a callback function that listens for notification events. + * @return - + * @StageModelOnly + */ + on(method: string, callback: CalleeCallBack): void; + /** + * Unregister data listener callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param method A string registered to listen for notification events. + * @return - + * @StageModelOnly + */ + off(method: string): void; +} +/** + * The class of an ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @permission N/A + * @StageModelOnly + */ +export default class Ability { + /** + * Indicates configuration information about an ability context. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + */ + context: AbilityContext; + /** + * Indicates ability launch want. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + */ + launchWant: Want; + /** + * Indicates ability last request want. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + */ + lastRequestWant: Want; + /** + * Call Service Stub Object. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @StageModelOnly + */ + callee: Callee; + /** + * Called back when an ability is started for initialization. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param want Indicates the want info of the created ability. + * @param param Indicates the launch param. + * @return - + * @StageModelOnly + */ + onCreate(want: Want, param: AbilityConstant.LaunchParam): void; + /** + * Called back when an ability window stage is created. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param windowStage Indicates the created WindowStage. + * @return - + * @StageModelOnly + */ + onWindowStageCreate(windowStage: window.WindowStage): void; + /** + * Called back when an ability window stage is destroyed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @return - + * @StageModelOnly + */ + onWindowStageDestroy(): void; + /** + * Called back when an ability window stage is restored. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param windowStage window stage to restore + * @return - + * @StageModelOnly + */ + onWindowStageRestore(windowStage: window.WindowStage): void; + /** + * Called back before an ability is destroyed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @return - + * @StageModelOnly + */ + onDestroy(): void; + /** + * Called back when the state of an ability changes to foreground. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @return - + * @StageModelOnly + */ + onForeground(): void; + /** + * Called back when the state of an ability changes to background. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @return - + * @StageModelOnly + */ + onBackground(): void; + /** + * Called back when an ability prepares to continue. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param wantParam Indicates the want parameter. + * @return 0 if ability agrees to continue and saves data successfully, otherwise errcode. + * @StageModelOnly + */ + onContinue(wantParam: { + [key: string]: any; + }): AbilityConstant.OnContinueResult; + /** + * Called when the launch mode of an ability is set to singleton. + * This happens when you re-launch an ability that has been at the top of the ability stack. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param want Indicates the want info of ability. + * @param launchParams Indicates the launch parameters. + * @return - + * @StageModelOnly + */ + onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void; + /** + * Called when the system configuration is updated. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param config Indicates the updated configuration. + * @return - + * @StageModelOnly + */ + onConfigurationUpdated(config: Configuration): void; + /** + * Called when dump client information is required. + * It is recommended that developers don't DUMP sensitive information. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param params Indicates the params from command. + * @return The dump info array. + * @StageModelOnly + */ + dump(params: Array): Array; +} diff --git a/build-tools/api/@ohos.application.AbilityConstant.d.ts b/build-tools/api/@ohos.application.AbilityConstant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dbbfcabebae0d641bb0cd7c04878664425823644 --- /dev/null +++ b/build-tools/api/@ohos.application.AbilityConstant.d.ts @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The definition of AbilityConstant. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @StageModelOnly + */ +declare namespace AbilityConstant { + /** + * Interface of launch param. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export interface LaunchParam { + /** + * Indicates launch reason. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + launchReason: LaunchReason; + /** + * Indicates last exit reason. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + lastExitReason: LastExitReason; + } + /** + * Type of launch reason. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export enum LaunchReason { + UNKNOWN = 0, + START_ABILITY = 1, + CALL = 2, + CONTINUATION = 3 + } + /** + * Type of last exit reason. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export enum LastExitReason { + UNKNOWN = 0, + ABILITY_NOT_RESPONDING = 1, + NORMAL = 2 + } + /** + * Type of onContinue result. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export enum OnContinueResult { + AGREE = 0, + REJECT = 1, + MISMATCH = 2 + } +} +export default AbilityConstant; diff --git a/build-tools/api/@ohos.application.AbilityLifecycleCallback.d.ts b/build-tools/api/@ohos.application.AbilityLifecycleCallback.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b6c17e018bf64cc88e7ebd34e5776e8ffc82d7b3 --- /dev/null +++ b/build-tools/api/@ohos.application.AbilityLifecycleCallback.d.ts @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from "./@ohos.application.Ability"; +/** + * The ability lifecycle callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + */ +export default class AbilityLifecycleCallback { + /** + * Called back when an ability is started for initialization. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param ability: Indicates the ability to register for listening. + * @StageModelOnly + */ + onAbilityCreate(ability: Ability): void; + /** + * Called back when an ability window stage is created. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param ability: Indicates the ability to register for listening. + * @StageModelOnly + */ + onAbilityWindowStageCreate(ability: Ability): void; + /** + * Called back when an ability window stage is destroyed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param ability: Indicates the ability to register for listening. + * @StageModelOnly + */ + onAbilityWindowStageDestroy(ability: Ability): void; + /** + * Called back when an ability is destroyed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param ability: Indicates the ability to register for listening. + * @StageModelOnly + */ + onAbilityDestroy(ability: Ability): void; + /** + * Called back when the state of an ability changes to foreground. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param ability: Indicates the ability to register for listening. + * @StageModelOnly + */ + onAbilityForeground(ability: Ability): void; + /** + * Called back when the state of an ability changes to background. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param ability: Indicates the ability to register for listening. + * @StageModelOnly + */ + onAbilityBackground(ability: Ability): void; + /** + * Called back when an ability prepares to continue. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param ability: Indicates the ability to register for listening. + * @StageModelOnly + */ + onAbilityContinue(ability: Ability): void; +} diff --git a/build-tools/api/@ohos.application.AbilityStage.d.ts b/build-tools/api/@ohos.application.AbilityStage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..173884f90966954e20ce03e8e4b14d445b015195 --- /dev/null +++ b/build-tools/api/@ohos.application.AbilityStage.d.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityStageContext from "./application/AbilityStageContext"; +import Want from './@ohos.application.Want'; +import { Configuration } from './@ohos.application.Configuration'; +/** + * The class of an ability stage. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @StageModelOnly + */ +export default class AbilityStage { + /** + * Indicates configuration information about context. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + context: AbilityStageContext; + /** + * Called back when an ability stage is started for initialization. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return - + * @StageModelOnly + */ + onCreate(): void; + /** + * Called back when start specified ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want Indicates the want info of startd ability. + * @return The user returns an ability string ID. If the ability of this ID has been started before, + * do not create a new instance and pull it back to the top of the stack. + * Otherwise, create a new instance and start it. + * @StageModelOnly + */ + onAcceptWant(want: Want): string; + /** + * Called when the system configuration is updated. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param config Indicates the updated configuration. + * @return - + * @StageModelOnly + */ + onConfigurationUpdated(config: Configuration): void; +} diff --git a/build-tools/api/@ohos.application.AccessibilityExtensionAbility.d.ts b/build-tools/api/@ohos.application.AccessibilityExtensionAbility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b62b2134d7ddc5dc0cda0496dfdab9ddc4ace76c --- /dev/null +++ b/build-tools/api/@ohos.application.AccessibilityExtensionAbility.d.ts @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import accessibility from './@ohos.accessibility'; +import AccessibilityExtensionContext, { AccessibilityElement } from './application/AccessibilityExtensionContext'; +import inputEventClient from './@ohos.multimodalInput.inputEventClient'; +/** + * class of accessibility extension ability. + * + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +export default class AccessibilityExtensionAbility { + /** + * Indicates accessibility extension ability context. + */ + context: AccessibilityExtensionContext; + /** + * Called when extension ability is connected. + */ + onConnect(): void; + /** + * Called when extension ability is disconnected. + */ + onDisconnect(): void; + /** + * Called when an accessibility event occurs, such as when the user touches the application interface. + * @param event Indicates an accessibility event. + */ + onAccessibilityEvent(event: AccessibilityEvent): void; + /** + * Called when a physical key is pressed, such as when the user presses the volume button . + * @param keyEvent Indicates the physical key event. + */ + onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean; +} +/** + * Indicates the accessibility event. + * + * It provides the event type and the target element of the event if any. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +declare interface AccessibilityEvent { + eventType: accessibility.EventType | accessibility.WindowUpdateType | TouchGuideType | GestureType | PageUpdateType; + target?: AccessibilityElement; + timeStamp?: number; +} +/** + * Indicates the path of the gesture. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +declare interface GesturePath { + /** + * Indicates the position of the points that make up the gesture. + */ + points: Array; + /** + * Indicates the duration of the gesture. + */ + durationTime: number; +} +/** + * Indicates the point of the gesture. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +declare interface GesturePoint { + /** + * Indicates the X coordinate of point. + */ + positionX: number; + /** + * Indicates the Y coordinate of point. + */ + positionY: number; +} +/** + * Indicates the gusture type. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type GestureType = 'left' | 'leftThenRight' | 'leftThenUp' | 'leftThenDown' | 'right' | 'rightThenLeft' | 'rightThenUp' | 'rightThenDown' | 'up' | 'upThenLeft' | 'upThenRight' | 'upThenDown' | 'down' | 'downThenLeft' | 'downThenRight' | 'downThenUp'; +/** + * Indicates the page update type. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type PageUpdateType = 'pageContentUpdate' | 'pageStateUpdate'; +/** + * Indicates the type of touch event during touch browsing. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type TouchGuideType = 'touchBegin' | 'touchEnd'; diff --git a/build-tools/api/@ohos.application.Configuration.d.ts b/build-tools/api/@ohos.application.Configuration.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9a7ed6d729a7f7a71836859ff0d88719ed08e8b --- /dev/null +++ b/build-tools/api/@ohos.application.Configuration.d.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import ConfigurationConstant from "./@ohos.application.ConfigurationConstant"; +/** + * configuration item. + * + * @name Configuration + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ +export interface Configuration { + /** + * Indicates the current language of the application. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + */ + language?: string; + /** + * Indicates the current colorMode of the application. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + */ + colorMode?: ConfigurationConstant.ColorMode; + /** + * Indicates the screen direction of the current device. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityBase + */ + direction?: ConfigurationConstant.Direction; + /** + * Indicates the screen density of the current device. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityBase + */ + screenDensity?: ConfigurationConstant.ScreenDensity; + /** + * Indicates the displayId of the current device. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityBase + */ + displayId?: number; +} diff --git a/build-tools/api/@ohos.application.ConfigurationConstant.d.ts b/build-tools/api/@ohos.application.ConfigurationConstant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..44e8223d555dde6a544fdc323f53e6af817b9d97 --- /dev/null +++ b/build-tools/api/@ohos.application.ConfigurationConstant.d.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The definition of ConfigurationConstant. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ +declare namespace ConfigurationConstant { + /** + * @name ColorMode + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ + export enum ColorMode { + COLOR_MODE_NOT_SET = -1, + COLOR_MODE_DARK = 0, + COLOR_MODE_LIGHT = 1 + } + /** + * @name Direction + * @since 9 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ + export enum Direction { + DIRECTION_NOT_SET = -1, + DIRECTION_VERTICAL = 0, + DIRECTION_HORIZONTAL = 1 + } + /** + * @name ScreenDensity + * @since 9 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ + export enum ScreenDensity { + SCREEN_DENSITY_NOT_SET = 0, + SCREEN_DENSITY_SDPI = 120, + SCREEN_DENSITY_MDPI = 160, + SCREEN_DENSITY_LDPI = 240, + SCREEN_DENSITY_XLDPI = 320, + SCREEN_DENSITY_XXLDPI = 480, + SCREEN_DENSITY_XXXLDPI = 640 + } +} +export default ConfigurationConstant; diff --git a/build-tools/api/@ohos.application.EnvironmentCallback.d.ts b/build-tools/api/@ohos.application.EnvironmentCallback.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c3ac0b75fdd0a90652cca0c5cb74aed35fe3089 --- /dev/null +++ b/build-tools/api/@ohos.application.EnvironmentCallback.d.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Configuration } from './@ohos.application.Configuration'; +/** + * The environment callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + */ +export default class EnvironmentCallback { + /** + * Called when the system configuration is updated. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param config: Indicates the updated configuration. + * @StageModelOnly + */ + onConfigurationUpdated(config: Configuration): void; +} diff --git a/build-tools/api/@ohos.application.FormExtension.d.ts b/build-tools/api/@ohos.application.FormExtension.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..64e98887e3bcaeb8704e3348d690c991d7b12620 --- /dev/null +++ b/build-tools/api/@ohos.application.FormExtension.d.ts @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import formBindingData from './@ohos.application.formBindingData'; +import formInfo from "./@ohos.application.formInfo"; +import FormExtensionContext from "./application/FormExtensionContext"; +import Want from './@ohos.application.Want'; +import { Configuration } from './@ohos.application.Configuration'; +/** + * class of form extension. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @StageModelOnly + */ +export default class FormExtension { + /** + * Indicates form extension context. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @StageModelOnly + */ + context: FormExtensionContext; + /** + * Called to return a {@link formBindingData#FormBindingData} object. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param want Indicates the detailed information for creating a {@link formBindingData#FormBindingData}. + * The {@code Want} object must include the form ID, form name, and grid style of the form. + * Such form information must be managed as persistent data for further form + * acquisition, update, and deletion. + * @return Returns the created {@link formBindingData#FormBindingData} object. + * @StageModelOnly + */ + onCreate(want: Want): formBindingData.FormBindingData; + /** + * Called when the form provider is notified that a temporary form is successfully converted to a normal form. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param formId Indicates the ID of the form. + * @return - + * @StageModelOnly + */ + onCastToNormal(formId: string): void; + /** + * Called to notify the form provider to update a specified form. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param formId Indicates the ID of the form to update. + * @return - + * @StageModelOnly + */ + onUpdate(formId: string): void; + /** + * Called when the form provider receives form events from the system. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param newStatus Indicates the form events occurred. The key in the {@code Map} object indicates the form ID, + * and the value indicates the event type, which can be either {@link formManager#VisibilityType#FORM_VISIBLE} + * or {@link formManager#VisibilityType#FORM_INVISIBLE}. {@link formManager#VisibilityType#FORM_VISIBLE} + * means that the form becomes visible, and {@link formManager#VisibilityType#FORM_INVISIBLE} + * means that the form becomes invisible. + * @return - + * @StageModelOnly + */ + onVisibilityChange(newStatus: { + [key: string]: number; + }): void; + /** + * Called when a specified message event defined by the form provider is triggered. This method is valid only for + * JS forms. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param formId Indicates the ID of the form on which the message event is triggered, which is provided by + * the client to the form provider. + * @param message Indicates the value of the {@code params} field of the message event. This parameter is + * used to identify the specific component on which the event is triggered. + * @return - + * @StageModelOnly + */ + onEvent(formId: string, message: string): void; + /** + * Called to notify the form provider that a specified form has been destroyed. Override this method if + * you want your application, as the form provider, to be notified of form deletion. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param formId Indicates the ID of the destroyed form. + * @return - + * @StageModelOnly + */ + onDestroy(formId: string): void; + /** + * Called when the system configuration is updated. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param configuration Indicates the system configuration, such as language and color mode. + * @return - + * @StageModelOnly + */ + onConfigurationUpdated(config: Configuration): void; + /** + * Called to return a {@link FormState} object. + * + *

You must override this callback if you want this ability to return the actual form state. Otherwise, + * this method returns {@link FormState#DEFAULT} by default.

+ * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param want Indicates the description of the form for which the {@link formInfo#FormState} is obtained. + * The description covers the bundle name, ability name, module name, form name, and form dimensions. + * @return Returns the {@link formInfo#FormState} object. + * @StageModelOnly + */ + onAcquireFormState?(want: Want): formInfo.FormState; +} diff --git a/build-tools/api/@ohos.application.StartOptions.d.ts b/build-tools/api/@ohos.application.StartOptions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a9b2a0d05f346ea64b338cf6cdf78f9e6cc226a --- /dev/null +++ b/build-tools/api/@ohos.application.StartOptions.d.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * StartOptions is the basic communication component of the system. + * + * @name StartOptions + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @StageModelOnly + */ +export default class StartOptions { + /** + * windowMode + * @default - + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + windowMode?: number; + /** + * displayId + * @default - + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + displayId?: number; +} diff --git a/build-tools/api/@ohos.application.Want.d.ts b/build-tools/api/@ohos.application.Want.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6baa0cd93561539cd42f3d1ef4d776aa9fb3d14 --- /dev/null +++ b/build-tools/api/@ohos.application.Want.d.ts @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Want is the basic communication component of the system. + * + * @name Want + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ +export default class Want { + /** + * device id + * @default - + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + */ + deviceId?: string; + /** + * bundle name + * @default - + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + */ + bundleName?: string; + /** + * ability name + * @default - + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + */ + abilityName?: string; + /** + * The description of a URI in a Want. + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + uri?: string; + /** + * The description of the type in this Want. + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + type?: string; + /** + * The options of the flags in this Want. + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + flags?: number; + /** + * The description of an action in an want. + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + action?: string; + /** + * The description of the WantParams object in an Want + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + parameters?: { + [key: string]: any; + }; + /** + * The description of a entities in a Want. + * @since 8 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + entities?: Array; + /** + * The description of an module name in an want. + * @since 9 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + moduleName?: string; +} diff --git a/build-tools/api/@ohos.application.abilityDelegatorRegistry.d.ts b/build-tools/api/@ohos.application.abilityDelegatorRegistry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8321a1d63a561d1ef239b378de3a33d4dc41dd31 --- /dev/null +++ b/build-tools/api/@ohos.application.abilityDelegatorRegistry.d.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityDelegator } from './application/abilityDelegator'; +import { AbilityDelegatorArgs } from './application/abilityDelegatorArgs'; +/** + * A global register used to store the AbilityDelegator and AbilityDelegatorArgs objects registered + * during application startup. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + * @permission N/A + */ +declare namespace abilityDelegatorRegistry { + /** + * Get the AbilityDelegator object of the application. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return the AbilityDelegator object initialized when the application is started. + */ + function getAbilityDelegator(): AbilityDelegator; + /** + * Get unit test parameters stored in the AbilityDelegatorArgs object. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return the previously registered AbilityDelegatorArgs object. + */ + function getArguments(): AbilityDelegatorArgs; + /** + * Describes all lifecycle states of an ability. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + export enum AbilityLifecycleState { + UNINITIALIZED, + CREATE, + FOREGROUND, + BACKGROUND, + DESTROY + } +} +export default abilityDelegatorRegistry; diff --git a/build-tools/api/@ohos.application.appManager.d.ts b/build-tools/api/@ohos.application.appManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed4bc4dcff0657b93d9e067c80214f30d98dd899 --- /dev/null +++ b/build-tools/api/@ohos.application.appManager.d.ts @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import { ProcessRunningInfo } from './application/ProcessRunningInfo'; +import { ProcessRunningInformation as _ProcessRunningInformation } from './application/ProcessRunningInformation'; +/** + * This module provides the function of app manager service. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import appManager from '@ohos.application.appManager' + * @permission N/A + */ +declare namespace appManager { + /** + * Is user running in stability test. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return Returns true if user is running stability test. + */ + function isRunningInStabilityTest(callback: AsyncCallback): void; + function isRunningInStabilityTest(): Promise; + /** + * Get information about running processes + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return Returns the array of {@link ProcessRunningInfo}. + * @permission ohos.permission.GET_RUNNING_INFO + * @deprecated since 9 + * @useinstead getProcessRunningInformation + */ + function getProcessRunningInfos(): Promise>; + function getProcessRunningInfos(callback: AsyncCallback>): void; + /** + * Is it a ram-constrained device + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return whether a ram-constrained device. + */ + function isRamConstrainedDevice(): Promise; + function isRamConstrainedDevice(callback: AsyncCallback): void; + /** + * Get information about running processes + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return Returns the array of {@link ProcessRunningInformation}. + * @permission ohos.permission.GET_RUNNING_INFO + */ + function getProcessRunningInformation(): Promise>; + function getProcessRunningInformation(callback: AsyncCallback>): void; + /** + * Get the memory size of the application + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return application memory size. + */ + function getAppMemorySize(): Promise; + function getAppMemorySize(callback: AsyncCallback): void; + /** + * The class of an process running information. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + export type ProcessRunningInformation = _ProcessRunningInformation; +} +export default appManager; diff --git a/build-tools/api/@ohos.application.context.d.ts b/build-tools/api/@ohos.application.context.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..996bca334fb8bfb8526a0a4d546cf8683fbd2efd --- /dev/null +++ b/build-tools/api/@ohos.application.context.d.ts @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * The context of an application. It allows access to application-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ +declare namespace context { + /** + * The context of an ability. It allows access to ability-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export type AbilityContext = _AbilityContext.default; + /** + * The context of an abilityStage. It allows access to abilityStage-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export type AbilityStageContext = _AbilityStageContext.default; + /** + * The context of an application. It allows access to application-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export type ApplicationContext = _ApplicationContext.default; + /** + * The base context of 'app.Context' for FA Mode or + * 'application.Context' for Stage Mode. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + export type BaseContext = _BaseContext.default; + /** + * The base context of an ability or an application. It allows access to + * application-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export type Context = _Context.default; + /** + * The context of an extension. It allows access to extension-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export type ExtensionContext = _ExtensionContext.default; + /** + * The context of form extension. It allows access to + * formExtension-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @StageModelOnly + */ + export type FormExtensionContext = _FormExtensionContext.default; +} +export default context; diff --git a/build-tools/api/@ohos.application.errorManager.d.ts b/build-tools/api/@ohos.application.errorManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c9563d8c8995ccba725ea6a8611444cdab278a2 --- /dev/null +++ b/build-tools/api/@ohos.application.errorManager.d.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import ErrorObserver from './application/ErrorObserver'; +/** + * This module provides the function of error manager. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import errorManager from '@ohos.application.errorManager' + * @permission N/A + */ +declare namespace errorManager { + /** + * Register error observer. + * + * @default - + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param observer The error observer. + * @return Returns the number code of the observer. + */ + function registerErrorObserver(observer: ErrorObserver): number; + /** + * Unregister error observer. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param observerId Indicates the number code of the observer. + * @return - + */ + function unregisterErrorObserver(observerId: number, callback: AsyncCallback): void; + function unregisterErrorObserver(observerId: number): Promise; +} +export default errorManager; diff --git a/build-tools/api/@ohos.application.formBindingData.d.ts b/build-tools/api/@ohos.application.formBindingData.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..47d51f9ded010a5d756bc48e1790db7213dc49db --- /dev/null +++ b/build-tools/api/@ohos.application.formBindingData.d.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * interface of formBindingData. + * + * @name formBindingData + * @since 8 + * @syscap SystemCapability.Ability.Form + */ +declare namespace formBindingData { + /** + * Create an FormBindingData instance. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + * @param obj Indicates the FormBindingData instance data. + * @return Returns the {@link FormBindingData} instance. + */ + function createFormBindingData(obj?: Object | string): FormBindingData; + /** + * Defines the createFormBindingData result interface. + * @syscap SystemCapability.Ability.Form + * @since 8 + */ + interface FormBindingData { + data: Object; + } +} +export default formBindingData; diff --git a/build-tools/api/@ohos.application.formError.d.ts b/build-tools/api/@ohos.application.formError.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6a2ce8b22b83a90d30486f8fd9234a9ccd4dec20 --- /dev/null +++ b/build-tools/api/@ohos.application.formError.d.ts @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * interface of formError. + * + * @name formError + * @since 8 + * @syscap SystemCapability.Ability.Form + */ +declare namespace formError { + /** + * Error of form. + * + * @name FormError + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + enum FormError { + /** + * A common internal error occurs during form processing. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_COMMON = 1, + /** + * The application does not have permission to use forms. + * Ensure that the application is granted with the ohos.permission.REQUIRE_FORM + * and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED permissions. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_PERMISSION_DENY = 2, + /** + * Failed to obtain the configuration information about the form specified by the + * request parameters. Ensure that the parameters of the form to be added are + * consistent with those provided by the form provider. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_GET_INFO_FAILED = 4, + /** + * Failed to obtain the bundle to which the form belongs based on the request parameters. + * Ensure that the bundle to which the form to be added belongs is available. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_GET_BUNDLE_FAILED = 5, + /** + * Failed to initialize the form layout based on the request parameters. + * Ensure that the grid style of the form is supported by the form provider. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_GET_LAYOUT_FAILED = 6, + /** + * Invalid input parameter during form operation. Ensure that all input + * parameters are valid. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_ADD_INVALID_PARAM = 7, + /** + * The form configuration to be obtained using an existing form ID is + * different from that obtained for the first time. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_CFG_NOT_MATCH_ID = 8, + /** + * The ID of the form to be operated does not exist in the Form Manager Service. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_NOT_EXIST_ID = 9, + /** + * Failed to bind the Form Manager Service to the provider service. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_BIND_PROVIDER_FAILED = 10, + /** + * The total number of added forms exceeds the maximum allowed by the system. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_MAX_SYSTEM_FORMS = 11, + /** + * The number of form instances generated using the same form configuration + * exceeds the maximum allowed by the system. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_MAX_INSTANCES_PER_FORM = 12, + /** + * The form being requested was added by other applications and cannot be + * operated by the current application. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_OPERATION_FORM_NOT_SELF = 13, + /** + * The Form Manager Service failed to instruct the form provider to delete the form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_PROVIDER_DEL_FAIL = 14, + /** + * The total number of added forms exceeds the maximum per client. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_MAX_FORMS_PER_CLIENT = 15, + /** + * The total number of added temp forms exceeds the maximum in system. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_MAX_SYSTEM_TEMP_FORMS = 16, + /** + * The module can not be find in system. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_FORM_NO_SUCH_MODULE = 17, + /** + * The ability can not be find in system. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_FORM_NO_SUCH_ABILITY = 18, + /** + * The dimension is not exist in the form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_FORM_NO_SUCH_DIMENSION = 19, + /** + * The ability is not installed. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_FORM_FA_NOT_INSTALLED = 20, + /** + * Failed to obtain the RPC object of the Form Manager Service because + * the service is not started.Please try again after the service is started. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_SYSTEM_RESPONSES_FAILED = 30, + /** + * Failed to obtain the form requested by the client because another form + * with the same form ID is in use. Forms in use cannot have the same ID. + * To obtain and display a form that has the same configuration as an in-use + * form in the same application, you are advised to set the form ID to 0 in + * the request parameters. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_FORM_DUPLICATE_ADDED = 31, + /** + * The form is being restored. Perform operations on the form only after + * the restoration is complete. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + ERR_IN_RECOVERY = 36 + } +} +export default formError; diff --git a/build-tools/api/@ohos.application.formInfo.d.ts b/build-tools/api/@ohos.application.formInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..37a27e8ef711b858ff84dc319a57e8bd40fab447 --- /dev/null +++ b/build-tools/api/@ohos.application.formInfo.d.ts @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Want from './@ohos.application.Want'; +/** + * interface of formInfo. + * + * @name formInfo + * @since 8 + * @syscap SystemCapability.Ability.Form + */ +declare namespace formInfo { + /** + * Provides information about a form. + * + * @name FormInfo + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + interface FormInfo { + /** + * Obtains the bundle name of the application to which this form belongs. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + bundleName: string; + /** + * Obtains the name of the application module to which this form belongs. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + moduleName: string; + /** + * Obtains the class name of the ability to which this form belongs. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + abilityName: string; + /** + * Obtains the name of this form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + name: string; + /** + * Obtains the name of this form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + description: string; + /** + * Obtains the type of this form. Currently, JS forms are supported. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + type: FormType; + /** + * Obtains the JS component name of this JS form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + jsComponentName: string; + /** + * Obtains the color mode of this form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + colorMode: ColorMode; + /** + * Checks whether this form is a default form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + isDefault: boolean; + /** + * Obtains the updateEnabled. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + updateEnabled: boolean; + /** + * Obtains whether notify visible of this form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + formVisibleNotify: boolean; + /** + * Obtains the bundle relatedBundleName of the application to which this form belongs. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + relatedBundleName: string; + /** + * Obtains the scheduledUpdateTime. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + scheduledUpdateTime: string; + /** + * Obtains the form config ability about this form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + formConfigAbility: string; + /** + * Obtains the updateDuration. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + updateDuration: number; + /** + * Obtains the default grid style of this form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + defaultDimension: number; + /** + * Obtains the grid styles supported by this form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + supportDimensions: Array; + /** + * Obtains the custom data defined in this form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + customizeData: { + [key: string]: [ + value: string + ]; + }; + } + /** + * Type of form. + * + * @name FormType + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + enum FormType { + /** + * JS form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + JS = 1 + } + /** + * Color mode. + * + * @name ColorMode + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + enum ColorMode { + /** + * Automatic mode. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + MODE_AUTO = -1, + /** + * Dark mode. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + MODE_DARK = 0, + /** + * Light mode. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + MODE_LIGHT = 1 + } + /** + * Provides state information about a form. + * + * @name FormStateInfo + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + interface FormStateInfo { + /** + * Obtains the form state. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + formState: FormState; + /** + * Obtains the want form . + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + want: Want; + } + /** + * Provides state about a form. + * + * @name FormState + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + enum FormState { + /** + * Indicates that the form status is unknown due to an internal error. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + UNKNOWN = -1, + /** + * Indicates that the form is in the default state. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + DEFAULT = 0, + /** + * Indicates that the form is ready. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + READY = 1 + } + /** + * Parameter of form. + * + * @name FormParam + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + enum FormParam { + /** + * Indicates the key specifying the grid style of the form to be obtained, which is represented as + * want: { + * "parameters": { + * DIMENSION_KEY: 1 + * } + * }. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + DIMENSION_KEY = "ohos.extra.param.key.form_dimension", + /** + * Indicates the key specifying the name of the form to be obtained, which is represented as + * want: { + * "parameters": { + * NAME_KEY: "formName" + * } + * }. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + NAME_KEY = "ohos.extra.param.key.form_name", + /** + * Indicates the key specifying the name of the module to which the form to be obtained belongs, which is + * represented as + * want: { + * "parameters": { + * MODULE_NAME_KEY: "formEntry" + * } + * } + * This constant is mandatory. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + MODULE_NAME_KEY = "ohos.extra.param.key.module_name", + /** + * Indicates the key specifying the width of the form to be obtained, which is represented as + * want: { + * "parameters": { + * WIDTH_KEY: 800 + * } + * } + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + WIDTH_KEY = "ohos.extra.param.key.form_width", + /** + * Indicates the key specifying the height of the form to be obtained, which is represented as + * want: { + * "parameters": { + * HEIGHT_KEY: 400 + * } + * } + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + HEIGHT_KEY = "ohos.extra.param.key.form_height", + /** + * Indicates the key specifying whether a form is temporary, which is represented as + * want: { + * "parameters": { + * TEMPORARY_KEY: true + * } + * } + * + * @since 8 + * @syscap SystemCapability.Ability.Form + */ + TEMPORARY_KEY = "ohos.extra.param.key.form_temporary" + } + /** + * The optional options used as filters to ask + * getFormsInfo to return formInfos from only forms that match the options. + * + * @name FormInfoFilter + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + interface FormInfoFilter { + /** + * optional moduleName that used to ask getFormsInfo to return + * form infos with the same moduleName. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + moduleName?: string; + } +} +export default formInfo; diff --git a/build-tools/api/@ohos.application.formProvider.d.ts b/build-tools/api/@ohos.application.formProvider.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a918bb5428568bf17c5b4112c30b1ced13c1862 --- /dev/null +++ b/build-tools/api/@ohos.application.formProvider.d.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from "./basic"; +import formBindingData from "./@ohos.application.formBindingData"; +import formInfo from "./@ohos.application.formInfo"; +/** + * interface of formProvider. + * + * @name formProvider + * @since 8 + * @syscap SystemCapability.Ability.Form + */ +declare namespace formProvider { + /** + * Set next update time for a specified form. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + * @param formId Indicates the form ID. + * @param minute Indicates duration minute before next update. + * @return - + */ + function setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback): void; + function setFormNextRefreshTime(formId: string, minute: number): Promise; + /** + * Update a specified form. + * + * Client to communication with FormManagerService. + * + * @since 8 + * @syscap SystemCapability.Ability.Form + * @param formId Indicates the form ID + * @param formBindingData Indicates the form data + * @return - + */ + function updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback): void; + function updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise; + /** + * Get infos of all forms belonging to current bundle. + * + * Client to communication with FormManagerService. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param filter Indicates the requirements the forms that the formInfos belong to have to meet. + * @return Infos of all forms. + */ + function getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback>): void; + function getFormsInfo(callback: AsyncCallback>): void; + function getFormsInfo(filter?: formInfo.FormInfoFilter): Promise>; +} +export default formProvider; diff --git a/build-tools/api/@ohos.application.testRunner.d.ts b/build-tools/api/@ohos.application.testRunner.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4689b380c9f844387ed3f2b870636a6bbaa33e52 --- /dev/null +++ b/build-tools/api/@ohos.application.testRunner.d.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Base class for the test framework. + * If you want to implement your own unit test framework, you must inherit this class and overrides all its methods. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import TestRunner from '@ohos.application.testRunner' + * @permission N/A + */ +export interface TestRunner { + /** + * Prepare the unit testing environment for running test cases. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + onPrepare(): void; + /** + * Run all test cases. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + onRun(): void; +} +export default TestRunner; diff --git a/build-tools/api/@ohos.backgroundTaskManager.d.ts b/build-tools/api/@ohos.backgroundTaskManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c447d902e6d3d0a382b2c85a35cf26606a877d3a --- /dev/null +++ b/build-tools/api/@ohos.backgroundTaskManager.d.ts @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from './basic'; +import { WantAgent } from "./@ohos.wantAgent"; +import Context from './application/BaseContext'; +/** + * Manages background tasks. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + */ +declare namespace backgroundTaskManager { + /** + * The info of delay suspend. + * + * @name DelaySuspendInfo + * @since 7 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + */ + interface DelaySuspendInfo { + /** + * The unique identifier of the delay request. + */ + requestId: number; + /** + * The actual delay duration (ms). + */ + actualDelayTime: number; + } + /** + * Cancels delayed transition to the suspended state. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @param requestId Indicates the identifier of the delay request. + */ + function cancelSuspendDelay(requestId: number): void; + /** + * Obtains the remaining time before an application enters the suspended state. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @param requestId Indicates the identifier of the delay request. + * @return The remaining delay time + */ + function getRemainingDelayTime(requestId: number, callback: AsyncCallback): void; + function getRemainingDelayTime(requestId: number): Promise; + /** + * Requests delayed transition to the suspended state. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @param reason Indicates the reason for delayed transition to the suspended state. + * @param callback The callback delay time expired. + * @return Info of delay request + */ + function requestSuspendDelay(reason: string, callback: Callback): DelaySuspendInfo; + /** + * Service ability uses this method to request start running in background. + * system will publish a notification related to the this service. + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @permission ohos.permission.KEEP_BACKGROUND_RUNNING + * @param context app running context. + * @param bgMode Indicates which background mode to request. + * @param wantAgent Indicates which ability to start when user click the notification bar. + */ + function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback): void; + function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise; + /** + * Service ability uses this method to request stop running in background. + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @param context app running context. + */ + function stopBackgroundRunning(context: Context, callback: AsyncCallback): void; + function stopBackgroundRunning(context: Context): Promise; + /** + * supported background mode. + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + export enum BackgroundMode { + /** + * data transfer mode + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + DATA_TRANSFER = 1, + /** + * audio playback mode + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + AUDIO_PLAYBACK = 2, + /** + * audio recording mode + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + AUDIO_RECORDING = 3, + /** + * location mode + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + LOCATION = 4, + /** + * bluetooth interaction mode + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + BLUETOOTH_INTERACTION = 5, + /** + * multi-device connection mode + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + MULTI_DEVICE_CONNECTION = 6, + /** + * background continuous calculate mode, for example 3D render. + * only supported in particular device + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + TASK_KEEPING = 9 + } +} +export default backgroundTaskManager; diff --git a/build-tools/api/@ohos.batteryinfo.d.ts b/build-tools/api/@ohos.batteryinfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..27a435c69968d90b0593b5960862e874a954f677 --- /dev/null +++ b/build-tools/api/@ohos.batteryinfo.d.ts @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Obtains battery information of a device. + * + *

Battery information includes the remaining battery power, + * voltage, temperature, model, and charger type. + * + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 6 + */ +declare namespace batteryInfo { + /** + * Battery state of charge (SoC) of the current device, in percent. + * @since 6 + */ + const batterySOC: number; + /** + * Battery charging status of the current device. + * @since 6 + */ + const chargingStatus: BatteryChargeState; + /** + * Battery health state of the current device. + * @since 6 + */ + const healthStatus: BatteryHealthState; + /** + * Charger type of the current device. + * @since 6 + */ + const pluggedType: BatteryPluggedType; + /** + * Battery voltage of the current device, in µV. + * @since 6 + */ + const voltage: number; + /** + * Battery technology of the current device. + * @since 6 + */ + const technology: string; + /** + * Battery temperature of the current device, in 0.1℃. + * @since 6 + */ + const batteryTemperature: number; + /** + * Battery present state of the current device. + * @since 7 + */ + const isBatteryPresent: boolean; + /** + * Battery capacity level of the current device. + * @since 9 + */ + const batteryCapacityLevel: BatteryCapacityLevel; + /** + * Estimated remaining time for the current device to be fully charged, in ms. + * @since 9 + */ + const estimatedRemainingChargeTime: number; + /** + * Charger type of a device. + * + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 6 + */ + export enum BatteryPluggedType { + /** + * Unknown type + * @since 6 + */ + NONE, + /** + * AC charger + * @since 6 + */ + AC, + /** + * USB charger + * @since 6 + */ + USB, + /** + * Wireless charger + * @since 6 + */ + WIRELESS + } + /** + * Battery charging status of a device. + * + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 6 + */ + export enum BatteryChargeState { + /** + * Unknown state. + * @since 6 + */ + NONE, + /** + * The battery is being charged. + * @since 6 + */ + ENABLE, + /** + * The battery is not being charged. + * @since 6 + */ + DISABLE, + /** + * The battery is fully charged. + * @since 6 + */ + FULL + } + /** + * Battery health status of a device. + * + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 6 + */ + export enum BatteryHealthState { + /** + * Unknown state. + * @since 6 + */ + UNKNOWN, + /** + * The battery is in healthy state. + * @since 6 + */ + GOOD, + /** + * The battery is overheated. + * @since 6 + */ + OVERHEAT, + /** + * The battery voltage is over high. + * @since 6 + */ + OVERVOLTAGE, + /** + * The battery temperature is low. + * @since 6 + */ + COLD, + /** + * The battery is dead. + * @since 6 + */ + DEAD + } + /** + * Battery capacity level of a device. + * + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 9 + */ + export enum BatteryCapacityLevel { + /** + * The battery is in unknow capacity level. + * @since 9 + */ + LEVEL_NONE, + /** + * The battery is in full capacity level. + * @since 9 + */ + LEVEL_FULL, + /** + * The battery is in high capacity level. + * @since 9 + */ + LEVEL_HIGH, + /** + * The battery is in normal capacity level. + * @since 9 + */ + LEVEL_NORMAL, + /** + * The battery is in low capacity level. + * @since 9 + */ + LEVEL_LOW, + /** + * The battery is in critical low capacity level. + * @since 9 + */ + LEVEL_CRITICAL + } + /** + * Etra key code of common event COMMON_EVENT_BATTERY_CHANGED. + * + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 9 + */ + export enum CommonEventBatteryChangedCode { + /** + * Extra code of state of charge (SoC). + * @since 9 + */ + EXTRA_SOC = 0, + /** + * Extra code of voltage. + * @since 9 + */ + EXTRA_VOLTAGE, + /** + * Extra code of temperature. + * @since 9 + */ + EXTRA_TEMPERATURE, + /** + * Extra code of healthState. + * @since 9 + */ + EXTRA_HEALTH_STATE, + /** + * Extra code of pluggedType. + * @since 9 + */ + EXTRA_PLUGGED_TYPE, + /** + * Extra code of maxCurrent. + * @since 9 + */ + EXTRA_MAX_CURRENT, + /** + * Extra code of maxVoltage. + * @since 9 + */ + EXTRA_MAX_VOLTAGE, + /** + * Extra code of chargeState. + * @since 9 + */ + EXTRA_CHARGE_STATE, + /** + * Extra code of chargeCounter. + * @since 9 + */ + EXTRA_CHARGE_COUNTER, + /** + * Extra code of if battery is present. + * @since 9 + */ + EXTRA_PRESENT, + /** + * Extra code of technology. + * @since 9 + */ + EXTRA_TECHNOLOGY + } +} +export default batteryInfo; diff --git a/build-tools/api/@ohos.bluetooth.d.ts b/build-tools/api/@ohos.bluetooth.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..080665513144a6f2d39c6665db3b099d400a55ce --- /dev/null +++ b/build-tools/api/@ohos.bluetooth.d.ts @@ -0,0 +1,1449 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from "./basic"; +/** + * Provides methods to operate or manage Bluetooth. + * @since 7 + * @import import bluetooth from '@ohos.bluetooth' + * @syscap SystemCapability.Communication.Bluetooth.Core + */ +declare namespace bluetooth { + /** + * Obtains the Bluetooth status of a device. + * + * @return Returns the Bluetooth status, which can be {@link BluetoothState#STATE_OFF}, + * {@link BluetoothState#STATE_TURNING_ON}, {@link BluetoothState#STATE_ON}, {@link BluetoothState#STATE_TURNING_OFF}, + * {@link BluetoothState#STATE_BLE_TURNING_ON}, {@link BluetoothState#STATE_BLE_ON}, + * or {@link BluetoothState#STATE_BLE_TURNING_OFF}. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + function getState(): BluetoothState; + /** + * Get the local device connection state to any profile of any remote device. + * + * @return One of {@link ProfileConnectionState#STATE_DISCONNECTED}, + * {@link ProfileConnectionState#STATE_CONNECTING}, {@link ProfileConnectionState#STATE_CONNECTED}, + * {@link ProfileConnectionState#STATE_DISCONNECTING}. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + function getBtConnectionState(): ProfileConnectionState; + /** + * Starts pairing with a remote Bluetooth device. + * + * @param deviceId The address of the remote device to pair. + * @return Returns {@code true} if the pairing process is started; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.DISCOVER_BLUETOOTH + */ + function pairDevice(deviceId: string): boolean; + /** + * Obtains the name of a peer Bluetooth device. + * + * @param deviceId The address of the remote device. + * @return Returns the device name in character string format. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function getRemoteDeviceName(deviceId: string): string; + /** + * Obtains the class of a peer Bluetooth device. + * + * @param deviceId The address of the remote device. + * @return The class of the remote device, {@link DeviceClass}. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function getRemoteDeviceClass(deviceId: string): DeviceClass; + /** + * Enables Bluetooth on a device. + * + * @return Returns {@code true} if Bluetooth is being enabled; returns {@code false} if an error occurs. + * @since 8 + * @permission ohos.permission.DISCOVER_BLUETOOTH + */ + function enableBluetooth(): boolean; + /** + * Disables Bluetooth on a device. + * + * @return Returns {@code true} if Bluetooth is being disabled; returns {@code false} if an error occurs. + * @since 8 + * @permission ohos.permission.DISCOVER_BLUETOOTH + */ + function disableBluetooth(): boolean; + /** + * Obtains the Bluetooth local name of a device. + * + * @return Returns the name the device. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function getLocalName(): string; + /** + * Obtains the list of Bluetooth devices that have been paired with the current device. + * + * @return Returns a list of paired Bluetooth devices's address. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function getPairedDevices(): Array; + /** + * Obtains the connection state of profile. + * + * @param profileId The profile id. + * @return Returns the connection state. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function getProfileConnState(profileId: ProfileId): ProfileConnectionState; + /** + * Sets the confirmation of pairing with a certain device. + * + * @param device The address of the remote device. + * @param accept Indicates whether to accept the pairing request, {@code true} indicates accept or {@code false} otherwise. + * @return Returns {@code true} if the pairing confirmation is set; returns {@code false} otherwise. + * @since 8 + * @permission ohos.permission.MANAGE_BLUETOOTH + */ + function setDevicePairingConfirmation(device: string, accept: boolean): boolean; + /** + * Sets the Bluetooth friendly name of a device. + * + * @param name Indicates a valid Bluetooth name. + * @return Returns {@code true} if the Bluetooth name is set successfully; returns {@code false} otherwise. + * @since 8 + * @permission ohos.permission.DISCOVER_BLUETOOTH + */ + function setLocalName(name: string): boolean; + /** + * Sets the Bluetooth scan mode for a device. + * + * @param mode Indicates the Bluetooth scan mode to set, {@link ScanMode}. + * @param duration Indicates the duration in seconds, in which the host is discoverable. + * @return Returns {@code true} if the Bluetooth scan mode is set; returns {@code false} otherwise. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function setBluetoothScanMode(mode: ScanMode, duration: number): boolean; + /** + * Obtains the Bluetooth scanning mode of a device. + * + * @return Returns the Bluetooth scanning mode, {@link ScanMode}. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function getBluetoothScanMode(): ScanMode; + /** + * Starts scanning Bluetooth devices. + * + * @return Returns {@code true} if the scan is started successfully; returns {@code false} otherwise. + * @since 8 + * @permission ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION + */ + function startBluetoothDiscovery(): boolean; + /** + * Stops Bluetooth device scanning. + * + * @return Returns {@code true} if scanning is stopped successfully; returns {@code false} otherwise. + * @since 8 + * @permission ohos.permission.DISCOVER_BLUETOOTH + */ + function stopBluetoothDiscovery(): boolean; + /** + * Subscribe the event reported when a remote Bluetooth device is discovered. + * + * @param type Type of the discovering event to listen for. + * @param callback Callback used to listen for the discovering event. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function on(type: "bluetoothDeviceFind", callback: Callback>): void; + /** + * Unsubscribe the event reported when a remote Bluetooth device is discovered. + * + * @param type Type of the discovering event to listen for. + * @param callback Callback used to listen for the discovering event. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function off(type: "bluetoothDeviceFind", callback?: Callback>): void; + /** + * Subscribe the event reported when a remote Bluetooth device is bonded. + * + * @param type Type of the bond state event to listen for. + * @param callback Callback used to listen for the bond state event, {@link BondStateParam}. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function on(type: "bondStateChange", callback: Callback): void; + /** + * Unsubscribe the event reported when a remote Bluetooth device is bonded. + * + * @param type Type of the bond state event to listen for. + * @param callback Callback used to listen for the bond state event. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function off(type: "bondStateChange", callback?: Callback): void; + /** + * Subscribe the event of a pairing request from a remote Bluetooth device. + * + * @param type Type of the pairing request event to listen for. + * @param callback Callback used to listen for the pairing request event. + * @since 8 + * @permission ohos.permission.DISCOVER_BLUETOOTH + */ + function on(type: "pinRequired", callback: Callback): void; + /** + * Unsubscribe the event of a pairing request from a remote Bluetooth device. + * + * @param type Type of the pairing request event to listen for. + * @param callback Callback used to listen for the pairing request event. + * @since 8 + * @permission ohos.permission.DISCOVER_BLUETOOTH + */ + function off(type: "pinRequired", callback?: Callback): void; + /** + * Subscribe the event reported when the Bluetooth state changes. + * + * @param type Type of the Bluetooth state changes event to listen for. + * @param callback Callback used to listen for the Bluetooth state event. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function on(type: "stateChange", callback: Callback): void; + /** + * Unsubscribe the event reported when the Bluetooth state changes. + * + * @param type Type of the Bluetooth state changes event to listen for. + * @param callback Callback used to listen for the Bluetooth state event. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function off(type: "stateChange", callback?: Callback): void; + /** + * Creates a Bluetooth server listening socket. + * + * @param name Indicates the service name. + * @param option Indicates the listen parameters {@link SppOption}. + * @param callback Callback used to return a server socket ID. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function sppListen(name: string, option: SppOption, callback: AsyncCallback): void; + /** + * Waits for a remote device to connect. + * + * @param serverSocket Indicates the server socket ID, returned by {@link sppListen}. + * @param callback Callback used to return a client socket ID. + * @since 8 + */ + function sppAccept(serverSocket: number, callback: AsyncCallback): void; + /** + * Connects to a remote device over the socket. + * + * @param device The address of the remote device to connect. + * @param option Indicates the connect parameters {@link SppOption}. + * @param callback Callback used to return a client socket ID. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + function sppConnect(device: string, option: SppOption, callback: AsyncCallback): void; + /** + * Disables an spp server socket and releases related resources. + * + * @param socket Indicates the server socket ID, returned by {@link sppListen}. + * @since 8 + */ + function sppCloseServerSocket(socket: number): void; + /** + * Disables an spp client socket and releases related resources. + * + * @param socket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}. + * @since 8 + */ + function sppCloseClientSocket(socket: number): void; + /** + * Write data through the socket. + * + * @param clientSocket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}. + * @param data Indicates the data to write. + * @return Returns {@code true} if the data is write successfully; returns {@code false} otherwise. + * @since 8 + */ + function sppWrite(clientSocket: number, data: ArrayBuffer): boolean; + /** + * Subscribe the event reported when data is read from the socket. + * + * @param type Type of the spp read event to listen for. + * @param callback Callback used to listen for the spp read event. + * @since 8 + */ + function on(type: "sppRead", clientSocket: number, callback: Callback): void; + /** + * Unsubscribe the event reported when data is read from the socket. + * + * @param type Type of the spp read event to listen for. + * @param callback Callback used to listen for the spp read event. + * @since 8 + */ + function off(type: "sppRead", clientSocket: number, callback?: Callback): void; + /** + * Obtains the instance of profile. + * + * @param profileId The profile id.. + * @return Returns instance of profile. + * @since 8 + */ + function getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile; + /** + * Obtains the instance of profile. + * + * @param profileId The profile id.. + * @return Returns instance of profile. + * @since 9 + */ + function getProfileInst(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile; + /** + * Base interface of profile. + */ + interface BaseProfile { + /** + * Obtains the connected devices list of profile. + * + * @return Returns the address of connected devices list. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + getConnectionDevices(): Array; + /** + * Obtains the profile state of device. + * + * @param device The address of bluetooth device. + * @return Returns {@link ProfileConnectionState} of device. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + getDeviceState(device: string): ProfileConnectionState; + } + /** + * Manager a2dp source profile. + */ + interface A2dpSourceProfile extends BaseProfile { + /** + * Connect to device with a2dp. + * + * @param device The address of the remote device to connect. + * @return Returns {@code true} if the connect is in process; returns {@code false} otherwise. + * @since 8 + * @permission permission ohos.permission.DISCOVER_BLUETOOTH + */ + connect(device: string): boolean; + /** + * Disconnect to device with a2dp. + * + * @param device The address of the remote device to disconnect. + * @return Returns {@code true} if the disconnect is in process; returns {@code false} otherwise. + * @since 8 + * @permission permission ohos.permission.DISCOVER_BLUETOOTH + */ + disconnect(device: string): boolean; + /** + * Subscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 8 + */ + on(type: "connectionStateChange", callback: Callback): void; + /** + * Unsubscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 8 + */ + off(type: "connectionStateChange", callback?: Callback): void; + /** + * Obtains the playing state of device. + * + * @param device The address of the remote device. + * @return Returns {@link PlayingState} of the remote device. + * @since 8 + */ + getPlayingState(device: string): PlayingState; + } + /** + * Manager handsfree AG profile. + */ + interface HandsFreeAudioGatewayProfile extends BaseProfile { + /** + * Connect to device with hfp. + * + * @param device The address of the remote device to connect. + * @return Returns {@code true} if the connect is in process; returns {@code false} otherwise. + * @since 8 + * @permission permission ohos.permission.DISCOVER_BLUETOOTH + */ + connect(device: string): boolean; + /** + * Disconnect to device with hfp. + * + * @param device The address of the remote device to disconnect. + * @return Returns {@code true} if the disconnect is in process; returns {@code false} otherwise. + * @since 8 + * @permission permission ohos.permission.DISCOVER_BLUETOOTH + */ + disconnect(device: string): boolean; + /** + * Subscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 8 + */ + on(type: "connectionStateChange", callback: Callback): void; + /** + * Unsubscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 8 + */ + off(type: "connectionStateChange", callback?: Callback): void; + } + /** + * Manager hid host profile. + */ + interface HidHostProfile extends BaseProfile { + /** + * Subscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 9 + */ + on(type: "connectionStateChange", callback: Callback): void; + /** + * Unsubscribe the event reported when the profile connection state changes. + * + * @param type Type of the profile connection state changes event to listen for. + * @param callback Callback used to listen for event. + * @since 9 + */ + off(type: "connectionStateChange", callback?: Callback): void; + } + /** + * Manager pan profile. + */ + interface PanProfile extends BaseProfile { + /** + * Subscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 9 + */ + on(type: "connectionStateChange", callback: Callback): void; + /** + * Unsubscribe the event reported when the profile connection state changes. + * + * @param type Type of the profile connection state changes event to listen for. + * @param callback Callback used to listen for event. + * @since 9 + */ + off(type: "connectionStateChange", callback?: Callback): void; + } + namespace BLE { + /** + * create a JavaScript Gatt server instance. + * + * @return Returns a JavaScript Gatt server instance {@code GattServer}. + * @since 7 + */ + function createGattServer(): GattServer; + /** + * create a JavaScript Gatt client device instance. + * + * @param deviceId The address of the remote device. + * @return Returns a JavaScript Gatt client device instance {@code GattClientDevice}. + * @since 7 + */ + function createGattClientDevice(deviceId: string): GattClientDevice; + /** + * Obtains the list of devices in the connected status. + * + * @return Returns the list of device address. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + function getConnectedBLEDevices(): Array; + /** + * Starts scanning for specified BLE devices with filters. + * + * @param filters Indicates the list of filters used to filter out specified devices. + * If you do not want to use filter, set this parameter to {@code null}. + * @param options Indicates the parameters for scanning and if the user does not assign a value, the default value will be used. + * {@link ScanOptions#interval} set to 0, {@link ScanOptions#dutyMode} set to {@link SCAN_MODE_LOW_POWER} + * and {@link ScanOptions#matchMode} set to {@link MATCH_MODE_AGGRESSIVE}. + * @since 7 + * @permission ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH and ohos.permission.LOCATION + */ + function startBLEScan(filters: Array, options?: ScanOptions): void; + /** + * Stops BLE scanning. + * + * @since 7 + * @permission ohos.permission.DISCOVER_BLUETOOTH + */ + function stopBLEScan(): void; + /** + * Subscribe BLE scan result. + * + * @param type Type of the scan result event to listen for. + * @param callback Callback used to listen for the scan result event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + function on(type: "BLEDeviceFind", callback: Callback>): void; + /** + * Unsubscribe BLE scan result. + * + * @param type Type of the scan result event to listen for. + * @param callback Callback used to listen for the scan result event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + function off(type: "BLEDeviceFind", callback?: Callback>): void; + } + /** + * Manages GATT server. Before calling an Gatt server method, you must use {@link createGattServer} to create an GattServer instance. + */ + interface GattServer { + /** + * Starts BLE advertising. + * + * @param setting Indicates the settings for BLE advertising. + * If you need to use the default value, set this parameter to {@code null}. + * @param advData Indicates the advertising data. + * @param advResponse Indicates the scan response associated with the advertising data. + * @since 7 + * @permission ohos.permission.DISCOVER_BLUETOOTH + */ + startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?: AdvertiseData): void; + /** + * Stops BLE advertising. + * + * @since 7 + * @permission ohos.permission.DISCOVER_BLUETOOTH + */ + stopAdvertising(): void; + /** + * Adds a specified service to be hosted. + * + *

The added service and its characteristics are provided by the local device. + * + * @param service Indicates the service to add. + * @return Returns {@code true} if the service is added; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + addService(service: GattService): boolean; + /** + * Removes a specified service from the list of GATT services provided by this device. + * + * @param serviceUuid Indicates the UUID of the service to remove. + * @return Returns {@code true} if the service is removed; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + removeService(serviceUuid: string): boolean; + /** + * Closes this {@code GattServer} object and unregisters its callbacks. + * + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + close(): void; + /** + * Sends a notification of a change in a specified local characteristic. + * + *

This method should be called for every BLE peripheral device that has requested notifications. + * + * @param deviceId Indicates the address of the BLE peripheral device to receive the notification. + * @param notifyCharacteristic Indicates the local characteristic that has changed. + * @return Returns {@code true} if the notification is sent successfully; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharacteristic): boolean; + /** + * Sends a response to a specified read or write request to a given BLE peripheral device. + * + * @param serverResponse Indicates the response parameters {@link ServerResponse}. + * @return Returns {@code true} if the response is sent successfully; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + sendResponse(serverResponse: ServerResponse): boolean; + /** + * Subscribe characteristic read event. + * + * @param type Type of the characteristic read event to listen for. + * @param callback Callback used to listen for the characteristic read event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + on(type: "characteristicRead", callback: Callback): void; + /** + * Unsubscribe characteristic read event. + * + * @param type Type of the characteristic read event to listen for. + * @param callback Callback used to listen for the characteristic read event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + off(type: "characteristicRead", callback?: Callback): void; + /** + * Subscribe characteristic write event. + * + * @param type Type of the characteristic write event to listen for. + * @param callback Callback used to listen for the characteristic write event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + on(type: "characteristicWrite", callback: Callback): void; + /** + * Unsubscribe characteristic write event. + * + * @param type Type of the characteristic write event to listen for. + * @param callback Callback used to listen for the characteristic write event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + off(type: "characteristicWrite", callback?: Callback): void; + /** + * Subscribe descriptor read event. + * + * @param type Type of the descriptor read event to listen for. + * @param callback Callback used to listen for the descriptor read event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + on(type: "descriptorRead", callback: Callback): void; + /** + * Unsubscribe descriptor read event. + * + * @param type Type of the descriptor read event to listen for. + * @param callback Callback used to listen for the descriptor read event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + off(type: "descriptorRead", callback?: Callback): void; + /** + * Subscribe descriptor write event. + * + * @param type Type of the descriptor write event to listen for. + * @param callback Callback used to listen for the descriptor write event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + on(type: "descriptorWrite", callback: Callback): void; + /** + * Unsubscribe descriptor write event. + * + * @param type Type of the descriptor write event to listen for. + * @param callback Callback used to listen for the descriptor write event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + off(type: "descriptorWrite", callback?: Callback): void; + /** + * Subscribe server connection state changed event. + * + * @param type Type of the connection state changed event to listen for. + * @param callback Callback used to listen for the connection state changed event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + on(type: "connectStateChange", callback: Callback): void; + /** + * Unsubscribe server connection state changed event. + * + * @param type Type of the connection state changed event to listen for. + * @param callback Callback used to listen for the connection state changed event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + off(type: "connectStateChange", callback?: Callback): void; + } + /** + * Manages GATT client. Before calling an Gatt client method, you must use {@link createGattClientDevice} to create an GattClientDevice instance. + */ + interface GattClientDevice { + /** + * Connects to a BLE peripheral device. + * + *

The 'BLEConnectionStateChange' event is subscribed to return the connection state. + * + * @return Returns {@code true} if the connection process starts; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + connect(): boolean; + /** + * Disconnects from or stops an ongoing connection to a BLE peripheral device. + * + * @return Returns {@code true} if the disconnection process starts; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + disconnect(): boolean; + /** + * Disables a BLE peripheral device. + * + *

This method unregisters the device and clears the registered callbacks and handles. + * + * @return Returns {@code true} if the the device is disabled; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + close(): boolean; + /** + * Obtains the name of BLE peripheral device. + * + * @return Returns a string representation of the name if obtained; + * returns {@code null} if the name fails to be obtained or the name does not exist. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + getDeviceName(callback: AsyncCallback): void; + getDeviceName(): Promise; + /** + * Starts discovering services. + * + * @return Returns the list of services {@link GattService} of the BLE peripheral device. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + getServices(callback: AsyncCallback>): void; + getServices(): Promise>; + /** + * Reads the characteristic of a BLE peripheral device. + * + * @param characteristic Indicates the characteristic to read. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback): void; + readCharacteristicValue(characteristic: BLECharacteristic): Promise; + /** + * Reads the descriptor of a BLE peripheral device. + * + * @param descriptor Indicates the descriptor to read. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback): void; + readDescriptorValue(descriptor: BLEDescriptor): Promise; + /** + * Writes the characteristic of a BLE peripheral device. + * + * @param characteristic Indicates the characteristic to write. + * @return Returns {@code true} if the characteristic is written successfully; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + writeCharacteristicValue(characteristic: BLECharacteristic): boolean; + /** + * Writes the descriptor of a BLE peripheral device. + * + * @param descriptor Indicates the descriptor to write. + * @return Returns {@code true} if the descriptor is written successfully; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + writeDescriptorValue(descriptor: BLEDescriptor): boolean; + /** + * Get the RSSI value of this BLE peripheral device. + * + * @return Returns the RSSI value. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + getRssiValue(callback: AsyncCallback): void; + getRssiValue(): Promise; + /** + * Set the mtu size of a BLE peripheral device. + * + * @param mtu The maximum transmission unit. + * @return Returns {@code true} if the set mtu is successfully; returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + setBLEMtuSize(mtu: number): boolean; + /** + * Enables or disables notification of a characteristic when value changed. + * + * @param enable Specifies whether to enable notification of the characteristic. The value {@code true} indicates + * that notification is enabled, and the value {@code false} indicates that notification is disabled. + * @return Returns {@code true} if notification of the characteristic is enabled or disabled; + * returns {@code false} otherwise. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): boolean; + /** + * Subscribe characteristic value changed event. + * + * @param type Type of the characteristic value changed event to listen for. + * @param callback Callback used to listen for the characteristic value changed event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + on(type: "BLECharacteristicChange", callback: Callback): void; + /** + * Unsubscribe characteristic value changed event. + * + * @param type Type of the characteristic value changed event to listen for. + * @param callback Callback used to listen for the characteristic value changed event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + off(type: "BLECharacteristicChange", callback?: Callback): void; + /** + * Subscribe client connection state changed event. + * + * @param type Type of the connection state changed event to listen for. + * @param callback Callback used to listen for the connection state changed event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + on(type: "BLEConnectionStateChange", callback: Callback): void; + /** + * Unsubscribe client connection state changed event. + * + * @param type Type of the connection state changed event to listen for. + * @param callback Callback used to listen for the connection state changed event. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ + off(type: "BLEConnectionStateChange", callback?: Callback): void; + } + /** + * Describes the Gatt service. + * + * @since 7 + */ + interface GattService { + /** The UUID of a GattService instance */ + serviceUuid: string; + /** Indicates whether the GattService instance is primary or secondary. */ + isPrimary: boolean; + /** The {@link BLECharacteristic} list belongs to this GattService instance */ + characteristics: Array; + /** The list of GATT services contained in the service */ + includeServices?: Array; + } + /** + * Describes the Gatt characteristic. + * + * @since 7 + */ + interface BLECharacteristic { + /** The UUID of the {@link GattService} instance to which the characteristic belongs */ + serviceUuid: string; + /** The UUID of a BLECharacteristic instance */ + characteristicUuid: string; + /** The value of a BLECharacteristic instance */ + characteristicValue: ArrayBuffer; + /** The list of {@link BLEDescriptor} contained in the characteristic */ + descriptors: Array; + } + /** + * Describes the Gatt descriptor. + * + * @since 7 + */ + interface BLEDescriptor { + /** The UUID of the {@link GattService} instance to which the descriptor belongs */ + serviceUuid: string; + /** The UUID of the {@link BLECharacteristic} instance to which the descriptor belongs */ + characteristicUuid: string; + /** The UUID of the BLEDescriptor instance */ + descriptorUuid: string; + /** The value of the BLEDescriptor instance */ + descriptorValue: ArrayBuffer; + } + /** + * Describes the value of the indication or notification sent by the Gatt server. + * + * @since 7 + */ + interface NotifyCharacteristic { + /** The UUID of the {@link GattService} instance to which the characteristic belongs */ + serviceUuid: string; + /** The UUID of a NotifyCharacteristic instance */ + characteristicUuid: string; + /** The value of a NotifyCharacteristic instance */ + characteristicValue: ArrayBuffer; + /** + * Specifies whether to request confirmation from the BLE peripheral device (indication) or + * send a notification. Value {@code true} indicates the former and {@code false} indicates the latter. + */ + confirm: boolean; + } + /** + * Describes the parameters of the Gatt client's characteristic read request. + * + * @since 7 + */ + interface CharacteristicReadReq { + /** Indicates the address of the client that initiates the read request */ + deviceId: string; + /** The Id of the read request */ + transId: number; + /** Indicates the byte offset of the start position for reading characteristic value */ + offset: number; + /** The UUID of a CharacteristicReadReq instance */ + characteristicUuid: string; + /** The UUID of the service to which the characteristic belongs */ + serviceUuid: string; + } + /** + * Describes the parameters of the of the Gatt client's characteristic write request. + * + * @since 7 + */ + interface CharacteristicWriteReq { + /** Indicates the address of the client that initiates the write request */ + deviceId: string; + /** The Id of the write request */ + transId: number; + /** Indicates the byte offset of the start position for writing characteristic value */ + offset: number; + /** Whether this request should be pending for later operation */ + isPrep: boolean; + /** Whether the remote client need a response */ + needRsp: boolean; + /** Indicates the value to be written */ + value: ArrayBuffer; + /** The UUID of a CharacteristicWriteReq instance */ + characteristicUuid: string; + /** The UUID of the service to which the characteristic belongs */ + serviceUuid: string; + } + /** + * Describes the parameters of the Gatt client's descriptor read request. + * + * @since 7 + */ + interface DescriptorReadReq { + /** Indicates the address of the client that initiates the read request */ + deviceId: string; + /** The Id of the read request */ + transId: number; + /** Indicates the byte offset of the start position for reading characteristic value */ + offset: number; + /** The UUID of a DescriptorReadReq instance */ + descriptorUuid: string; + /** The UUID of the characteristic to which the descriptor belongs */ + characteristicUuid: string; + /** The UUID of the service to which the descriptor belongs */ + serviceUuid: string; + } + /** + * Describes the parameters of the Gatt client's characteristic write request. + * + * @since 7 + */ + interface DescriptorWriteReq { + /** Indicates the address of the client that initiates the write request */ + deviceId: string; + /** The Id of the write request */ + transId: number; + /** Indicates the byte offset of the start position for writing characteristic value */ + offset: number; + /** Whether this request should be pending for later operation */ + isPrep: boolean; + /** Whether the remote client need a response */ + needRsp: boolean; + /** Indicates the value to be written */ + value: ArrayBuffer; + /** The UUID of a DescriptorWriteReq instance */ + descriptorUuid: string; + /** The UUID of the characteristic to which the descriptor belongs */ + characteristicUuid: string; + /** The UUID of the service to which the descriptor belongs */ + serviceUuid: string; + } + /** + * Describes the parameters of a response send by the server to a specified read or write request. + * + * @since 7 + */ + interface ServerResponse { + /** Indicates the address of the client to which to send the response */ + deviceId: string; + /** The Id of the write request */ + transId: number; + /** Indicates the status of the read or write request, set this parameter to '0' in normal cases */ + status: number; + /** Indicates the byte offset of the start position for reading or writing operation */ + offset: number; + /** Indicates the value to be sent */ + value: ArrayBuffer; + } + /** + * Describes the Gatt profile connection state. + * + * @since 7 + */ + interface BLEConnectChangedState { + /** Indicates the peer device address */ + deviceId: string; + /** Connection state of the Gatt profile */ + state: ProfileConnectionState; + } + /** + * Describes the contents of the scan results. + * + * @since 7 + */ + interface ScanResult { + /** Address of the scanned device */ + deviceId: string; + /** RSSI of the remote device */ + rssi: number; + /** The raw data of broadcast packet */ + data: ArrayBuffer; + } + /** + * Describes the settings for BLE advertising. + * + * @since 7 + */ + interface AdvertiseSetting { + /** + * Minimum slot value for the advertising interval, which is {@code 32} (20 ms) + * Maximum slot value for the advertising interval, which is {@code 16777215} (10485.759375s) + * Default slot value for the advertising interval, which is {@code 1600} (1s) + */ + interval?: number; + /** + * Minimum transmission power level for advertising, which is {@code -127} + * Maximum transmission power level for advertising, which is {@code 1} + * Default transmission power level for advertising, which is {@code -7} + */ + txPower?: number; + /** Indicates whether the BLE is connectable, default is {@code true} */ + connectable?: boolean; + } + /** + * Describes the advertising data. + * + * @since 7 + */ + interface AdvertiseData { + /** The specified service UUID list to this advertisement */ + serviceUuids: Array; + /** The specified manufacturer data list to this advertisement */ + manufactureData: Array; + /** The specified service data list to this advertisement */ + serviceData: Array; + } + /** + * Describes the manufacturer data. + * + * @since 7 + */ + interface ManufactureData { + /** Indicates the manufacturer ID assigned by Bluetooth SIG */ + manufactureId: number; + /** Indicates the manufacturer data to add */ + manufactureValue: ArrayBuffer; + } + /** + * Describes the service data. + * + * @since 7 + */ + interface ServiceData { + /** Indicates the UUID of the service data to add */ + serviceUuid: string; + /** Indicates the service data to add */ + serviceValue: ArrayBuffer; + } + /** + * Describes the criteria for filtering scanning results can be set. + * + */ + interface ScanFilter { + /** + * The address of a BLE peripheral device + * @since 7 + */ + deviceId?: string; + /** + * The name of a BLE peripheral device + * @since 7 + */ + name?: string; + /** + * The service UUID of a BLE peripheral device + * @since 7 + */ + serviceUuid?: string; + /** + * Service UUID mask. + * @since 9 + */ + serviceUuidMask?: string; + /** + * Service solicitation UUID mask. + * @since 9 + */ + serviceSolicitationUuid?: string; + /** + * Service solicitation UUID mask. + * @since 9 + */ + serviceSolicitationUuidMask?: string; + /** + * Service data. + * @since 9 + */ + serviceData?: ArrayBuffer; + /** + * Service data mask. + * @since 9 + */ + serviceDataMask?: ArrayBuffer; + /** + * Manufacture id. + * @since 9 + */ + manufactureId?: number; + /** + * Manufacture data. + * @since 9 + */ + manufactureData?: ArrayBuffer; + /** + * Manufacture data mask. + * @since 9 + */ + manufactureDataMask?: ArrayBuffer; + } + /** + * Describes the parameters for scan. + * + * @since 7 + */ + interface ScanOptions { + /** Time of delay for reporting the scan result */ + interval?: number; + /** Bluetooth LE scan mode */ + dutyMode?: ScanDuty; + /** Match mode for Bluetooth LE scan filters hardware match */ + matchMode?: MatchMode; + } + /** + * Describes the spp parameters. + * + * @since 8 + */ + interface SppOption { + /** Indicates the UUID in the SDP record. */ + uuid: string; + /** Indicates secure channel or not */ + secure: boolean; + /** Spp link type {@link SppType}*/ + type: SppType; + } + /** + * Describes the bond key param. + * + * @since 8 + */ + interface PinRequiredParam { + deviceId: string; + pinCode: string; + } + /** + * Describes the class of a bluetooth device. + * + * @since 8 + */ + interface DeviceClass { + majorClass: MajorClass; + majorMinorClass: MajorMinorClass; + classOfDevice: number; + } + /** + * Describes the class of a bluetooth device. + * + * @since 8 + */ + interface BondStateParam { + deviceId: string; + state: BondState; + } + enum ScanDuty { + /** low power mode */ + SCAN_MODE_LOW_POWER = 0, + /** balanced power mode */ + SCAN_MODE_BALANCED = 1, + /** Scan using highest duty cycle */ + SCAN_MODE_LOW_LATENCY = 2 + } + enum MatchMode { + /** aggressive mode */ + MATCH_MODE_AGGRESSIVE = 1, + /** sticky mode */ + MATCH_MODE_STICKY = 2 + } + enum ProfileConnectionState { + /** the current profile is disconnected */ + STATE_DISCONNECTED = 0, + /** the current profile is being connected */ + STATE_CONNECTING = 1, + /** the current profile is connected */ + STATE_CONNECTED = 2, + /** the current profile is being disconnected */ + STATE_DISCONNECTING = 3 + } + enum BluetoothState { + /** Indicates the local Bluetooth is off */ + STATE_OFF = 0, + /** Indicates the local Bluetooth is turning on */ + STATE_TURNING_ON = 1, + /** Indicates the local Bluetooth is on, and ready for use */ + STATE_ON = 2, + /** Indicates the local Bluetooth is turning off */ + STATE_TURNING_OFF = 3, + /** Indicates the local Bluetooth is turning LE mode on */ + STATE_BLE_TURNING_ON = 4, + /** Indicates the local Bluetooth is in LE only mode */ + STATE_BLE_ON = 5, + /** Indicates the local Bluetooth is turning off LE only mode */ + STATE_BLE_TURNING_OFF = 6 + } + /** + * The enum of SPP type. + * + * @since 8 + */ + enum SppType { + /** RFCOMM */ + SPP_RFCOMM + } + /** + * The enum of BR scan mode. + * + * @since 8 + */ + enum ScanMode { + /** Indicates the scan mode is none */ + SCAN_MODE_NONE = 0, + /** Indicates the scan mode is connectable */ + SCAN_MODE_CONNECTABLE = 1, + /** Indicates the scan mode is general discoverable */ + SCAN_MODE_GENERAL_DISCOVERABLE = 2, + /** Indicates the scan mode is limited discoverable */ + SCAN_MODE_LIMITED_DISCOVERABLE = 3, + /** Indicates the scan mode is connectable and general discoverable */ + SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE = 4, + /** Indicates the scan mode is connectable and limited discoverable */ + SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE = 5 + } + /** + * The enum of bond state. + * + * @since 8 + */ + enum BondState { + /** Indicate the bond state is invalid */ + BOND_STATE_INVALID = 0, + /** Indicate the bond state is bonding */ + BOND_STATE_BONDING = 1, + /** Indicate the bond state is bonded*/ + BOND_STATE_BONDED = 2 + } + /** + * The enum of major class of a bluetooth device. + * + * @since 8 + */ + enum MajorClass { + MAJOR_MISC = 0x0000, + MAJOR_COMPUTER = 0x0100, + MAJOR_PHONE = 0x0200, + MAJOR_NETWORKING = 0x0300, + MAJOR_AUDIO_VIDEO = 0x0400, + MAJOR_PERIPHERAL = 0x0500, + MAJOR_IMAGING = 0x0600, + MAJOR_WEARABLE = 0x0700, + MAJOR_TOY = 0x0800, + MAJOR_HEALTH = 0x0900, + MAJOR_UNCATEGORIZED = 0x1F00 + } + /** + * The enum of major minor class of a bluetooth device. + * + * @since 8 + */ + enum MajorMinorClass { + // The Minor Device Class field + // Computer Major Class + COMPUTER_UNCATEGORIZED = 0x0100, + COMPUTER_DESKTOP = 0x0104, + COMPUTER_SERVER = 0x0108, + COMPUTER_LAPTOP = 0x010C, + COMPUTER_HANDHELD_PC_PDA = 0x0110, + COMPUTER_PALM_SIZE_PC_PDA = 0x0114, + COMPUTER_WEARABLE = 0x0118, + COMPUTER_TABLET = 0x011C, + // Phone Major Class + PHONE_UNCATEGORIZED = 0x0200, + PHONE_CELLULAR = 0x0204, + PHONE_CORDLESS = 0x0208, + PHONE_SMART = 0x020C, + PHONE_MODEM_OR_GATEWAY = 0x0210, + PHONE_ISDN = 0x0214, + // LAN/Network Access Point Major Class + NETWORK_FULLY_AVAILABLE = 0x0300, + NETWORK_1_TO_17_UTILIZED = 0x0320, + NETWORK_17_TO_33_UTILIZED = 0x0340, + NETWORK_33_TO_50_UTILIZED = 0x0360, + NETWORK_60_TO_67_UTILIZED = 0x0380, + NETWORK_67_TO_83_UTILIZED = 0x03A0, + NETWORK_83_TO_99_UTILIZED = 0x03C0, + NETWORK_NO_SERVICE = 0x03E0, + // Audio/Video Major Class + AUDIO_VIDEO_UNCATEGORIZED = 0x0400, + AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404, + AUDIO_VIDEO_HANDSFREE = 0x0408, + AUDIO_VIDEO_MICROPHONE = 0x0410, + AUDIO_VIDEO_LOUDSPEAKER = 0x0414, + AUDIO_VIDEO_HEADPHONES = 0x0418, + AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C, + AUDIO_VIDEO_CAR_AUDIO = 0x0420, + AUDIO_VIDEO_SET_TOP_BOX = 0x0424, + AUDIO_VIDEO_HIFI_AUDIO = 0x0428, + AUDIO_VIDEO_VCR = 0x042C, + AUDIO_VIDEO_VIDEO_CAMERA = 0x0430, + AUDIO_VIDEO_CAMCORDER = 0x0434, + AUDIO_VIDEO_VIDEO_MONITOR = 0x0438, + AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C, + AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440, + AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448, + // Peripheral Major Class + PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500, + PERIPHERAL_KEYBOARD = 0x0540, + PERIPHERAL_POINTING_DEVICE = 0x0580, + PERIPHERAL_KEYBOARD_POINTING = 0x05C0, + PERIPHERAL_UNCATEGORIZED = 0x0500, + PERIPHERAL_JOYSTICK = 0x0504, + PERIPHERAL_GAMEPAD = 0x0508, + PERIPHERAL_REMOTE_CONTROL = 0x05C0, + PERIPHERAL_SENSING_DEVICE = 0x0510, + PERIPHERAL_DIGITIZER_TABLET = 0x0514, + PERIPHERAL_CARD_READER = 0x0518, + PERIPHERAL_DIGITAL_PEN = 0x051C, + PERIPHERAL_SCANNER_RFID = 0x0520, + PERIPHERAL_GESTURAL_INPUT = 0x0522, + // Imaging Major Class + IMAGING_UNCATEGORIZED = 0x0600, + IMAGING_DISPLAY = 0x0610, + IMAGING_CAMERA = 0x0620, + IMAGING_SCANNER = 0x0640, + IMAGING_PRINTER = 0x0680, + // Wearable Major Class + WEARABLE_UNCATEGORIZED = 0x0700, + WEARABLE_WRIST_WATCH = 0x0704, + WEARABLE_PAGER = 0x0708, + WEARABLE_JACKET = 0x070C, + WEARABLE_HELMET = 0x0710, + WEARABLE_GLASSES = 0x0714, + // Minor Device Class field - Toy Major Class + TOY_UNCATEGORIZED = 0x0800, + TOY_ROBOT = 0x0804, + TOY_VEHICLE = 0x0808, + TOY_DOLL_ACTION_FIGURE = 0x080C, + TOY_CONTROLLER = 0x0810, + TOY_GAME = 0x0814, + // Minor Device Class field - Health + HEALTH_UNCATEGORIZED = 0x0900, + HEALTH_BLOOD_PRESSURE = 0x0904, + HEALTH_THERMOMETER = 0x0908, + HEALTH_WEIGHING = 0x090C, + HEALTH_GLUCOSE = 0x0910, + HEALTH_PULSE_OXIMETER = 0x0914, + HEALTH_PULSE_RATE = 0x0918, + HEALTH_DATA_DISPLAY = 0x091C, + HEALTH_STEP_COUNTER = 0x0920, + HEALTH_BODY_COMPOSITION_ANALYZER = 0x0924, + HEALTH_PEAK_FLOW_MOITOR = 0x0928, + HEALTH_MEDICATION_MONITOR = 0x092C, + HEALTH_KNEE_PROSTHESIS = 0x0930, + HEALTH_ANKLE_PROSTHESIS = 0x0934, + HEALTH_GENERIC_HEALTH_MANAGER = 0x0938, + HEALTH_PERSONAL_MOBILITY_DEVICE = 0x093C + } + /** + * Profile state change parameters. + * + * @since 8 + */ + interface StateChangeParam { + /** The address of device */ + deviceId: string; + /** Profile state value */ + state: ProfileConnectionState; + } + /** + * The enum of a2dp playing state. + * + * @since 8 + */ + enum PlayingState { + STATE_NOT_PLAYING, + STATE_PLAYING + } + /** + * The enum of profile id. + */ + enum ProfileId { + /** + * @since 8 + */ + PROFILE_A2DP_SOURCE = 1, + /** + * @since 8 + */ + PROFILE_HANDS_FREE_AUDIO_GATEWAY = 4, + /** + * @since 9 + */ + PROFILE_HID_HOST = 6, + /** + * @since 9 + */ + PROFILE_PAN_NETWORK = 7 + } +} +export default bluetooth; diff --git a/build-tools/api/@ohos.bundle.d.ts b/build-tools/api/@ohos.bundle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..94f94f5cb872d5936703d66c0932da2514e1660d --- /dev/null +++ b/build-tools/api/@ohos.bundle.d.ts @@ -0,0 +1,690 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import { ApplicationInfo } from './bundle/applicationInfo'; +import { BundleInfo } from './bundle/bundleInfo'; +import { AbilityInfo } from './bundle/abilityInfo'; +import { ExtensionAbilityInfo } from './bundle/extensionAbilityInfo'; +import image from './@ohos.multimedia.image'; +/** + * bundle. + * @name bundle + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + */ +declare namespace bundle { + /** + * @name BundleFlag + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + enum BundleFlag { + GET_BUNDLE_DEFAULT = 0x00000000, + GET_BUNDLE_WITH_ABILITIES = 0x00000001, + GET_ABILITY_INFO_WITH_PERMISSION = 0x00000002, + GET_ABILITY_INFO_WITH_APPLICATION = 0x00000004, + GET_APPLICATION_INFO_WITH_PERMISSION = 0x00000008, + GET_BUNDLE_WITH_REQUESTED_PERMISSION = 0x00000010, + GET_ALL_APPLICATION_INFO = 0xFFFF0000, + /** + * @since 8 + */ + GET_ABILITY_INFO_WITH_METADATA = 0x00000020, + /** + * @since 9 + */ + GET_BUNDLE_WITH_EXTENSION_ABILITY = 0x00000020, + /** + * @since 9 + */ + GET_BUNDLE_WITH_HASH_VALUE = 0x00000030, + /** + * @since 8 + */ + GET_APPLICATION_INFO_WITH_METADATA = 0x00000040, + /** + * @since 8 + */ + GET_ABILITY_INFO_SYSTEMAPP_ONLY = 0x00000080, + /** + * @since 8 + */ + GET_ABILITY_INFO_WITH_DISABLE = 0x00000100, + /** + * @since 8 + */ + GET_APPLICATION_INFO_WITH_DISABLE = 0x00000200, + /** + * @since 9 + */ + GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT = 0x00000400 + } + /** + * @name ExtensionFlag + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + enum ExtensionFlag { + GET_EXTENSION_INFO_DEFAULT = 0x00000000, + GET_EXTENSION_INFO_WITH_PERMISSION = 0x00000002, + GET_EXTENSION_INFO_WITH_APPLICATION = 0x00000004, + GET_EXTENSION_INFO_WITH_METADATA = 0x00000020 + } + /** + * @name ColorMode + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + export enum ColorMode { + AUTO_MODE = -1, + DARK_MODE = 0, + LIGHT_MODE = 1 + } + /** + * @name GrantStatus + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + export enum GrantStatus { + PERMISSION_DENIED = -1, + PERMISSION_GRANTED = 0 + } + /** + * @name AbilityType + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + export enum AbilityType { + /** + * @default Indicates an unknown ability type + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + UNKNOWN, + /** + * @default Indicates that the ability has a UI + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + PAGE, + /** + * @default Indicates that the ability does not have a UI + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + SERVICE, + /** + * @default Indicates that the ability is used to provide data access services + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + DATA + } + /** + * @name AbilitySubType + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + export enum AbilitySubType { + UNSPECIFIED = 0, + CA = 1 + } + /** + * @name DisplayOrientation + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + export enum DisplayOrientation { + /** + * @default Indicates that the system automatically determines the display orientation + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + UNSPECIFIED, + /** + * @default Indicates the landscape orientation + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + LANDSCAPE, + /** + * @default Indicates the portrait orientation + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + PORTRAIT, + /** + * @default Indicates the page ability orientation is the same as that of the nearest ability in the stack + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + FOLLOW_RECENT, + /** + * @default Indicates the inverted landscape orientation + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + LANDSCAPE_INVERTED, + /** + * @default Indicates the inverted portrait orientation + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + PORTRAIT_INVERTED, + /** + * @default Indicates the orientation can be auto-rotated + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + AUTO_ROTATION, + /** + * @default Indicates the landscape orientation rotated with sensor + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + AUTO_ROTATION_LANDSCAPE, + /** + * @default Indicates the portrait orientation rotated with sensor + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + AUTO_ROTATION_PORTRAIT, + /** + * @default Indicates the sensor restricted mode + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + AUTO_ROTATION_RESTRICTED, + /** + * @default Indicates the sensor landscape restricted mode + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + AUTO_ROTATION_LANDSCAPE_RESTRICTED, + /** + * @default Indicates the sensor portrait restricted mode + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + AUTO_ROTATION_PORTRAIT_RESTRICTED, + /** + * @default Indicates the locked orientation mode + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + LOCKED + } + /** + * @name LaunchMode + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + export enum LaunchMode { + /** + * @default Indicates that the ability has only one instance + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + SINGLETON = 0, + /** + * @default Indicates that the ability can have multiple instances + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + STANDARD = 1 + } + /** + * @name ExtensionAbilityType + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + export enum ExtensionAbilityType { + /** + * @default Indicates extension info with type of form + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + FORM = 0, + /** + * @default Indicates extension info with type of work schedule + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + WORK_SCHEDULER = 1, + /** + * @default Indicates extension info with type of input method + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + INPUT_METHOD = 2, + /** + * @default Indicates extension info with type of service + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + SERVICE = 3, + /** + * @default Indicates extension info with type of accessibility + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + ACCESSIBILITY = 4, + /** + * @default Indicates extension info with type of datashare + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + DATA_SHARE = 5, + /** + * @default Indicates extension info with type of fileshare + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + FILE_SHARE = 6, + /** + * @default Indicates extension info with type of staticsubscriber + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + STATIC_SUBSCRIBER = 7, + /** + * @default Indicates extension info with type of wallpaper + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + WALLPAPER = 8, + /** + * @default Indicates extension info with type of backup + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + BACKUP = 9, + /** + * @default Indicates extension info with type of window + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + WINDOW = 10, + /** + * @default Indicates extension info with type of enterprise admin + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + ENTERPRISE_ADMIN = 11, + /** + * @default Indicates extension info with type of unspecified + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + UNSPECIFIED = 20 + } + /** + * @name BundleOptions + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + export interface BundleOptions { + /** + * @default Indicates the user id + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + userId?: number; + } + /** + * @name InstallErrorCode + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + export enum InstallErrorCode { + SUCCESS = 0, + STATUS_INSTALL_FAILURE = 1, + STATUS_INSTALL_FAILURE_ABORTED = 2, + STATUS_INSTALL_FAILURE_INVALID = 3, + STATUS_INSTALL_FAILURE_CONFLICT = 4, + STATUS_INSTALL_FAILURE_STORAGE = 5, + STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6, + STATUS_UNINSTALL_FAILURE = 7, + STATUS_UNINSTALL_FAILURE_BLOCKED = 8, + STATUS_UNINSTALL_FAILURE_ABORTED = 9, + STATUS_UNINSTALL_FAILURE_CONFLICT = 10, + STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B, + STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C, + /** + * @since 8 + */ + STATUS_RECOVER_FAILURE_INVALID = 0x0D, + /** + * @since 7 + */ + STATUS_ABILITY_NOT_FOUND = 0x40, + /** + * @since 7 + */ + STATUS_BMS_SERVICE_ERROR = 0x41, + /** + * @since 8 + */ + STATUS_FAILED_NO_SPACE_LEFT = 0x42, + /** + * @since 8 + */ + STATUS_GRANT_REQUEST_PERMISSIONS_FAILED = 0x43, + /** + * @since 8 + */ + STATUS_INSTALL_PERMISSION_DENIED = 0x44, + /** + * @since 8 + */ + STATUS_UNINSTALL_PERMISSION_DENIED = 0x45 + } + /** + * @name SupportWindowMode + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @import NA + * @permission NA + */ + export enum SupportWindowMode { + /** + * @default Indicates supported window mode of full screen mode + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + FULL_SCREEN = 0, + /** + * @default Indicates supported window mode of split mode + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + SPLIT = 1, + /** + * @default Indicates supported window mode of floating mode + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + FLOATING = 2 + } + /** + * Obtains bundleInfo based on bundleName, bundleFlags and options. + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the application bundle name to be queried. + * @param bundleFlags Indicates the application bundle flags to be queried. + * @param options Indicates the bundle options object. + * @return Returns the BundleInfo object. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + */ + function getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback): void; + function getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback): void; + function getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise; + /** + * Obtains information about the current ability. + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the application bundle name to be queried. + * @param abilityName Indicates the ability name. + * @return Returns the AbilityInfo object for the current ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + */ + function getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback): void; + function getAbilityInfo(bundleName: string, abilityName: string): Promise; + /** + * Obtains based on a given bundle name. + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the application bundle name to be queried. + * @param bundleFlags Indicates the flag used to specify information contained in the ApplicationInfo object + * that will be returned. + * @param userId Indicates the user ID or do not pass user ID. + * @return Returns the ApplicationInfo object. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + */ + function getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback): void; + function getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback): void; + function getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Promise; + /** + * Query the AbilityInfo by the given Want. + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param want Indicates the Want containing the application bundle name to + * be queried. + * @param bundleFlags Indicates the flag used to specify information contained in the AbilityInfo objects that + * will be returned. + * @param userId Indicates the user ID. + * @return Returns a list of AbilityInfo objects. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + */ + function queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback>): void; + function queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback>): void; + function queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise>; + /** + * Obtains BundleInfo of all bundles available in the system. + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleFlag Indicates the flag used to specify information contained in the BundleInfo that will be + * returned. + * @param userId Indicates the user id. + * @return Returns a list of BundleInfo objects. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + */ + function getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void; + function getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback>): void; + function getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise>; + /** + * Obtains information about all installed applications of a specified user. + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleFlags Indicates the flag used to specify information contained in the ApplicationInfo objects + * that will be returned. + * @param userId Indicates the user ID or do not pass user ID. + * @return Returns a list of ApplicationInfo objects. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + */ + function getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback>): void; + function getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>): void; + function getAllApplicationInfo(bundleFlags: number, userId?: number): Promise>; + /** + * Obtains bundle name by the given uid. + * + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param uid Indicates the UID of an application. + * @return Returns the bundle name. + */ + function getNameForUid(uid: number, callback: AsyncCallback): void; + function getNameForUid(uid: number): Promise; + /** + * Obtains information about an application bundle contained in an ohos Ability Package (HAP). + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param hapFilePath Indicates the path storing the HAP. The path should be the relative path to the data + * directory of the current application. + * @param bundleFlags Indicates the flag used to specify information contained in the BundleInfo object to be + * returned. + * @return Returns the BundleInfo object. + */ + function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback): void; + function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number): Promise; + /** + * Obtains the Want for starting the main ability of an application based on the + * given bundle name. The main ability of an application is the ability that has the + * #ACTION_HOME and #ENTITY_HOME Want + * filters set in the application's config.json file. + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the bundle name of the application. + * @return Returns the Want for starting the application's main ability if any; returns null if + * the given bundle does not exist or does not contain any main ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + */ + function getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void; + function getLaunchWantForBundle(bundleName: string): Promise; + /** + * Query extension info of by utilizing a Want. + * + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param want Indicates the Want containing the application bundle name to be queried. + * @param extensionFlags Indicates the flag used to specify information contained in the ExtensionInfo objects that + * will be returned. + * @param userId Indicates the user ID. + * @return Returns a list of ExtensionInfo objects. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + */ + function queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, userId: number, callback: AsyncCallback>): void; + function queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, callback: AsyncCallback>): void; + function queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, userId?: number): Promise>; + /** + * Obtains the label of a specified ability. + * + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the bundle name of the application to which the ability belongs. + * @param abilityName Indicates the ability name. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @return Returns the label representing the label of the specified ability. + */ + function getAbilityLabel(bundleName: string, abilityName: string, callback: AsyncCallback): void; + function getAbilityLabel(bundleName: string, abilityName: string): Promise; + /** + * Obtains the icon of a specified ability. + * + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the bundle name of the application to which the ability belongs. + * @param abilityName Indicates the ability name. + * @return Returns the PixelMap object representing the icon of the specified ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + */ + function getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback): void; + function getAbilityIcon(bundleName: string, abilityName: string): Promise; + /** + * Checks whether a specified ability is enabled. + * + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param info Indicates information about the ability to check. + * @returns Returns true if the ability is enabled; returns false otherwise. + */ + function isAbilityEnabled(info: AbilityInfo, callback: AsyncCallback): void; + function isAbilityEnabled(info: AbilityInfo): Promise; + /** + * Checks whether a specified application is enabled. + * + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the bundle name of the application. + * @returns Returns true if the application is enabled; returns false otherwise. + */ + function isApplicationEnabled(bundleName: string, callback: AsyncCallback): void; + function isApplicationEnabled(bundleName: string): Promise; + /** + * Obtains information about the current ability. + * + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the application bundle name to be queried. + * @param moduleName Indicates the module name. + * @param abilityName Indicates the ability name. + * @return Returns the AbilityInfo object for the current ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + */ + function getAbilityInfo(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback): void; + function getAbilityInfo(bundleName: string, moduleName: string, abilityName: string): Promise; + /** + * Obtains the label of a specified ability. + * + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the bundle name of the application to which the ability belongs. + * @param moduleName Indicates the module name. + * @param abilityName Indicates the ability name. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @return Returns the label representing the label of the specified ability. + */ + function getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback): void; + function getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise; + /** + * Obtains the icon of a specified ability. + * + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the bundle name of the application to which the ability belongs. + * @param moduleName Indicates the module name. + * @param abilityName Indicates the ability name. + * @return Returns the PixelMap object representing the icon of the specified ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + */ + function getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback): void; + function getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Promise; + /** + * Obtains the profile designated by metadata name, abilityName and moduleName from the current application. + * + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param moduleName Indicates the moduleName of the application. + * @param abilityName Indicates the abilityName of the application. + * @param metadataName Indicates the name of metadata in ability. + * @return Returns string in json-format of the corresponding config file. + */ + function getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback>): void; + function getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise>; + /** + * Obtains the profile designated by metadata name, extensionAbilityName and moduleName from the current application. + * + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param moduleName Indicates the moduleName of the application. + * @param extensionAbilityName Indicates the extensionAbilityName of the application. + * @param metadataName Indicates the name of metadata in ability. + * @return Returns string in json-format of the corresponding config file. + */ + function getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback>): void; + function getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise>; +} +export default bundle; diff --git a/build-tools/api/@ohos.bundle.defaultAppManager.d.ts b/build-tools/api/@ohos.bundle.defaultAppManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..89071408051ec1cc1ff94733fa9cfe35259ee318 --- /dev/null +++ b/build-tools/api/@ohos.bundle.defaultAppManager.d.ts @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * default application manager. + * @name defaultAppManager + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + */ +declare namespace defaultAppManager { + /** + * the constant for application type. + * @name ApplicationType + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission N/A + */ + export enum ApplicationType { + /** + * default browser identifier. + * + * @since 9 + */ + BROWSER = "BROWSER", + /** + * default image identifier. + * + * @since 9 + */ + IMAGE = "IMAGE", + /** + * default audio identifier. + * + * @since 9 + */ + AUDIO = "AUDIO", + /** + * default video identifier. + * + * @since 9 + */ + VIDEO = "VIDEO", + /** + * default pdf identifier. + * + * @since 9 + */ + PDF = "PDF", + /** + * default word identifier. + * + * @since 9 + */ + WORD = "WORD", + /** + * default excel identifier. + * + * @since 9 + */ + EXCEL = "EXCEL", + /** + * default ppt identifier. + * + * @since 9 + */ + PPT = "PPT" + } + /** + * query whether the caller is default application based on type. + * + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param type application type or file type. + * @return return true if caller is default application; return false otherwise. + * @permission N/A + */ + function isDefaultApplication(type: string): Promise; + function isDefaultApplication(type: string, callback: AsyncCallback): void; +} +export default defaultAppManager; diff --git a/build-tools/api/@ohos.bundleState.d.ts b/build-tools/api/@ohos.bundleState.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5c1275ce2a3ba9d629369c0c1397416f68fa45c --- /dev/null +++ b/build-tools/api/@ohos.bundleState.d.ts @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * Provides methods for managing bundle usage statistics, + * including the methods for querying bundle usage information and state data. + * + *

You can use the methods defined in this class to query + * the usage history and states of bundles in a specified period. + * The system stores the query result in a {@link BundleStateInfo} or {@link BundleActiveState} instance and + * then returns it to you. + * + * @since 7 + */ +declare namespace bundleState { + /** + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + */ + interface BundleStateInfo { + /** + * the identifier of BundleStateInfo. + */ + id: number; + /** + * the total duration, in milliseconds. + */ + abilityInFgTotalTime?: number; + /** + * the last time when the application was accessed, in milliseconds. + */ + abilityPrevAccessTime?: number; + /** + * the last time when the application was visible in the foreground, in milliseconds. + */ + abilityPrevSeenTime?: number; + /** + * the total duration, in milliseconds. + */ + abilitySeenTotalTime?: number; + /** + * the bundle name of the application. + */ + bundleName?: string; + /** + * the total duration, in milliseconds. + */ + fgAbilityAccessTotalTime?: number; + /** + * the last time when the foreground application was accessed, in milliseconds. + */ + fgAbilityPrevAccessTime?: number; + /** + * the time of the first bundle usage record in this {@code BundleActiveInfo} object, + * in milliseconds. + */ + infosBeginTime?: number; + /** + * the time of the last bundle usage record in this {@code BundleActiveInfo} object, + * in milliseconds. + */ + infosEndTime?: number; + /** + * Merges a specified {@link BundleActiveInfo} object with this {@link BundleActiveInfo} object. + * The bundle name of both objects must be the same. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @param toMerge Indicates the {@link BundleActiveInfo} object to merge. + * if the bundle names of the two {@link BundleActiveInfo} objects are different. + */ + merge(toMerge: BundleStateInfo): void; + } + /** + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + */ + interface BundleActiveFormInfo { + /** + * the form name. + */ + formName: string; + /** + * the form dimension. + */ + formDimension: number; + /** + * the form id. + */ + formId: number; + /** + * the last time when the form was accessed, in milliseconds.. + */ + formLastUsedTime: number; + /** + * the click count of module. + */ + count: number; + } + /** + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + */ + interface BundleActiveModuleInfo { + /** + * the device id of module. + */ + deviceId?: string; + /** + * the bundle name. + */ + bundleName: string; + /** + * the module name. + */ + moduleName: string; + /** + * the main ability name of module. + */ + abilityName?: string; + /** + * the label id of application. + */ + appLabelId?: number; + /** + * the label id of module. + */ + labelId?: number; + /** + * the description id of application. + */ + descriptionId?: number; + /** + * the ability id of main ability. + */ + abilityLableId?: number; + /** + * the description id of main ability. + */ + abilityDescriptionId?: number; + /** + * the icon id of main ability. + */ + abilityIconId?: number; + /** + * the launch count of module. + */ + launchedCount: number; + /** + * the last time when the module was accessed, in milliseconds. + */ + lastModuleUsedTime: number; + /** + * the form usage record list of current module. + */ + formRecords: Array; + } + /** + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + */ + interface BundleActiveState { + /** + * the usage priority group of the application. + */ + appUsagePriorityGroup?: number; + /** + * the bundle name. + */ + bundleName?: string; + /** + * the shortcut ID. + */ + indexOfLink?: string; + /** + * the class name. + */ + nameOfClass?: string; + /** + * the time when this state occurred, in milliseconds. + */ + stateOccurredTime?: number; + /** + * the state type. + */ + stateType?: number; + } + /** + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + */ + interface BundleActiveGroupCallbackInfo { + /* + * the usage old group of the application + */ + appUsageOldGroup: number; + /* + * the usage new group of the application + */ + appUsageNewGroup: number; + /* + * the use id + */ + userId: number; + /* + * the change reason + */ + changeReason: number; + /* + * the bundle name + */ + bundleName: string; + } + /** + * Checks whether the application with a specified bundle name is in the idle state. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @param bundleName Indicates the bundle name of the application to query. + * @return Returns {@code true} if the application is idle in a particular period; + * returns {@code false} otherwise. The time range of the particular period is defined by the system, + * which may be hours or days. + */ + function isIdleState(bundleName: string, callback: AsyncCallback): void; + function isIdleState(bundleName: string): Promise; + /** + * Queries the usage priority group of the calling application. + * + *

The priority defined in a priority group restricts the resource usage of an application, + * for example, restricting the running of background tasks.

+ * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @return Returns the usage priority group of the calling application. + */ + function queryAppUsagePriorityGroup(callback: AsyncCallback): void; + function queryAppUsagePriorityGroup(): Promise; + /** + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + */ + interface BundleActiveInfoResponse { + [key: string]: BundleStateInfo; + } + /** + * Declares interval type. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + */ + export enum IntervalType { + /** + * Indicates the interval type that will determine the optimal interval based on the start and end time. + */ + BY_OPTIMIZED = 0, + /** + * Indicates the daily interval. + */ + BY_DAILY = 1, + /** + * Indicates the weekly interval. + */ + BY_WEEKLY = 2, + /** + * Indicates the monthly interval. + */ + BY_MONTHLY = 3, + /** + * Indicates the annually interval. + */ + BY_ANNUALLY = 4 + } + /** + * Queries state data of the current bundle within a specified period. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @param begin Indicates the start time of the query period, in milliseconds. + * @param end Indicates the end time of the query period, in milliseconds. + * @return Returns the {@link BundleActiveState} object Array containing the state data of the current bundle. + */ + function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void; + function queryCurrentBundleActiveStates(begin: number, end: number): Promise>; + /** + * Declares group type. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + */ + export enum GroupType { + /** + * Indicates the alive group. + */ + ACTIVE_GROUP_ALIVE = 10, + /** + * Indicates the daily group. + */ + ACTIVE_GROUP_DAILY = 20, + /** + * Indicates the fixed group. + */ + ACTIVE_GROUP_FIXED = 30, + /** + * Indicates the rare group. + */ + ACTIVE_GROUP_RARE = 40, + /** + * Indicates the limit group. + */ + ACTIVE_GROUP_LIMIT = 50, + /** + * Indicates the never group. + */ + ACTIVE_GROUP_NEVER = 60 + } +} +export default bundleState; diff --git a/build-tools/api/@ohos.bytrace.d.ts b/build-tools/api/@ohos.bytrace.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..59af4117290ad71b9b0d8862d3c318deefec0f03 --- /dev/null +++ b/build-tools/api/@ohos.bytrace.d.ts @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides interfaces to trace a task for performance measure, the logs can be capture by the + * bytrace cmdline available on the device. + * + *

This interfaces trace the start, end, and value changes of key processes that last for at least 3 ms. + * + *

Example: + * To trace a name verification that is expected to complete within 5 ms: + *

{@code
+ * bytrace.startTrace("checkName", 111, 5);
+ * //your process
+ * bytrace.finishTrace("checkName", 111);
+ * }
+ * To trace the number of layers, which is 3: + *
{@code
+ * bytrace.traceByValue("curLayer", 3);
+ * }
+ * + *

Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name + * and taskId. + * + * @deprecated + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiTrace + */ +declare namespace bytrace { + /** + * Records a trace marking it as the start of a task, can with the expected completion time between + * startTrace and finishTrace. + * + * This method is invoked at the start of a transaction to indicate that a task has started, whose name + * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by + * {@link #finishTrace}, the name and taskId need to be the same. + * + * @deprecated + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the task name. + * @param taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. + * @param expectedTime Indicates the expected time required for completing the task, in milliseconds. + */ + function startTrace(name: string, taskId: number, expectedTime?: number): void; + /** + * Records a trace and marks it as the end of a task. + * + * This method is invoked at the end of a transaction to indicate that a task has ended, whose name + * is specified by {@code name}. This method must be invoked after the the startTrace. + * + * @deprecated + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the task name. It must be the same whith the {@code name} of startTrace. + * @param taskId The unique id used to distinguish the tasks and must be the same whith the . + * {@code taskId} of startTrace. + */ + function finishTrace(name: string, taskId: number): void; + /** + * Records a trace for generating a count, such as clock pulse and the number of layers. + * + * @deprecated + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the name used to identify the count. + * @param count Indicates the number of the count. + */ + function traceByValue(name: string, count: number): void; +} +export default bytrace; diff --git a/build-tools/api/@ohos.commonEvent.d.ts b/build-tools/api/@ohos.commonEvent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e599288ca209944f0fa8e745b432dd1ba3817ce --- /dev/null +++ b/build-tools/api/@ohos.commonEvent.d.ts @@ -0,0 +1,741 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import { CommonEventData } from './commonEvent/commonEventData'; +import { CommonEventSubscriber } from './commonEvent/commonEventSubscriber'; +import { CommonEventSubscribeInfo } from './commonEvent/commonEventSubscribeInfo'; +import { CommonEventPublishData } from './commonEvent/commonEventPublishData'; +/** + * Common event defination + * @name commonEvent + * @since 7 + * @syscap SystemCapability.Notification.CommonEvent + * @permission N/A + */ +declare namespace commonEvent { + /** + * Publishes an ordered, sticky, or standard common event. + * + * @since 7 + * @param event name of the common event. + * @param callback Specified callback method. + * @return - + */ + function publish(event: string, callback: AsyncCallback): void; + /** + * Publishes an ordered, sticky, or standard common event. + * + * @since 7 + * @param event name of the common event. + * @param options Indicate the CommonEventPublishData containing the common event content and attributes. + * @param callback Specified callback method. + * @return - + */ + function publish(event: string, options: CommonEventPublishData, callback: AsyncCallback): void; + /** + * creates a CommonEventSubscriber for the SubscriberInfo. + * + * @since 7 + * @param subscribeInfo Indicates the information of the subscriber. + * @param callback Specified callback method. + * @return - + */ + function createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback): void; + /** + * create the CommonEventSubscriber for the SubscriberInfo. + * + * @since 7 + * @param subscribeInfo Indicates the information of the subscriber. + * @return Returns common event subscriber object + */ + function createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise; + /** + * subscribe an ordered, sticky, or standard common event. + * + * @since 7 + * @param subscriber Indicate the subscriber of the common event. + * @param callback Specified callback method. + * @return - + */ + function subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback): void; + /** + * unsubscribe from an ordered, sticky, or standard common event. + * + * @since 7 + * @param subscriber Indicate the subscriber of the common event. + * @param callback Specified callback method. + * @return - + */ + function unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback): void; + /** + * the event type that the commonEvent supported + * @name Support + * @since 7 + * @permission N/A + */ + export enum Support { + /** + * this commonEvent means when the device is booted or system upgrade completed, and only be sent by system. + */ + COMMON_EVENT_BOOT_COMPLETED = "usual.event.BOOT_COMPLETED", + /** + * this commonEvent means when the device finnish booting, but still in the locked state. + */ + COMMON_EVENT_LOCKED_BOOT_COMPLETED = "usual.event.LOCKED_BOOT_COMPLETED", + /** + * this commonEvent means when the device is shutting down, note: turn off, not sleeping. + */ + COMMON_EVENT_SHUTDOWN = "usual.event.SHUTDOWN", + /** + * this commonEvent means when the charging state, level and so on about the battery. + */ + COMMON_EVENT_BATTERY_CHANGED = "usual.event.BATTERY_CHANGED", + /** + * this commonEvent means when the device in low battery state.. + */ + COMMON_EVENT_BATTERY_LOW = "usual.event.BATTERY_LOW", + /** + * this commonEvent means when the battery level is an ok state. + */ + COMMON_EVENT_BATTERY_OKAY = "usual.event.BATTERY_OKAY", + /** + * this commonEvent means when the other power is connected to the device. + */ + COMMON_EVENT_POWER_CONNECTED = "usual.event.POWER_CONNECTED", + /** + * this commonEvent means when the other power is removed from the device. + */ + COMMON_EVENT_POWER_DISCONNECTED = "usual.event.POWER_DISCONNECTED", + /** + * this commonEvent means when the screen is turned off. + */ + COMMON_EVENT_SCREEN_OFF = "usual.event.SCREEN_OFF", + /** + * this commonEvent means when the device is waked up and interactive. + */ + COMMON_EVENT_SCREEN_ON = "usual.event.SCREEN_ON", + /** + * this commonEvent means when the thermal state level change + * @since 8 + */ + COMMON_EVENT_THERMAL_LEVEL_CHANGED = "usual.event.THERMAL_LEVEL_CHANGED", + /** + * this commonEvent means when the user is present after the device waked up. + */ + COMMON_EVENT_USER_PRESENT = "usual.event.USER_PRESENT", + /** + * this commonEvent means when the current time is changed. + */ + COMMON_EVENT_TIME_TICK = "usual.event.TIME_TICK", + /** + * this commonEvent means when the time is set. + */ + COMMON_EVENT_TIME_CHANGED = "usual.event.TIME_CHANGED", + /** + * this commonEvent means when the current date is changed. + */ + COMMON_EVENT_DATE_CHANGED = "usual.event.DATE_CHANGED", + /** + * this commonEvent means when the time zone is changed. + */ + COMMON_EVENT_TIMEZONE_CHANGED = "usual.event.TIMEZONE_CHANGED", + /** + * this commonEvent means when the dialog to dismiss. + */ + COMMON_EVENT_CLOSE_SYSTEM_DIALOGS = "usual.event.CLOSE_SYSTEM_DIALOGS", + /** + * this commonEvent means when a new application package is installed on the device. + */ + COMMON_EVENT_PACKAGE_ADDED = "usual.event.PACKAGE_ADDED", + /** + * this commonEvent means when a new version application package is installed on the device and + * replace the old version.the data contains the name of the package. + */ + COMMON_EVENT_PACKAGE_REPLACED = "usual.event.PACKAGE_REPLACED", + /** + * this commonEvent means when a new version application package is installed on the device and + * replace the old version, it does not contain additional data and only be sent to the replaced application. + */ + COMMON_EVENT_MY_PACKAGE_REPLACED = "usual.event.MY_PACKAGE_REPLACED", + /** + * this commonEvent means when an existing application package is removed from the device. + */ + COMMON_EVENT_PACKAGE_REMOVED = "usual.event.PACKAGE_REMOVED", + /** + * this commonEvent means when an existing application package is removed from the device. + */ + COMMON_EVENT_BUNDLE_REMOVED = "usual.event.BUNDLE_REMOVED", + /** + * this commonEvent means when an existing application package is completely removed from the device. + */ + COMMON_EVENT_PACKAGE_FULLY_REMOVED = "usual.event.PACKAGE_FULLY_REMOVED", + /** + * this commonEvent means when an existing application package has been changed. + */ + COMMON_EVENT_PACKAGE_CHANGED = "usual.event.PACKAGE_CHANGED", + /** + * this commonEvent means the user has restarted a package, and all of its processes have been killed. + */ + COMMON_EVENT_PACKAGE_RESTARTED = "usual.event.PACKAGE_RESTARTED", + /** + * this commonEvent means the user has cleared the package data. + */ + COMMON_EVENT_PACKAGE_DATA_CLEARED = "usual.event.PACKAGE_DATA_CLEARED", + /** + * this commonEvent means the packages have been suspended. + */ + COMMON_EVENT_PACKAGES_SUSPENDED = "usual.event.PACKAGES_SUSPENDED", + /** + * this commonEvent means the packages have been un-suspended. + */ + COMMON_EVENT_PACKAGES_UNSUSPENDED = "usual.event.PACKAGES_UNSUSPENDED", + /** + * this commonEvent Sent to a package that has been suspended by the system. + */ + COMMON_EVENT_MY_PACKAGE_SUSPENDED = "usual.event.MY_PACKAGE_SUSPENDED", + /** + * Sent to a package that has been un-suspended. + */ + COMMON_EVENT_MY_PACKAGE_UNSUSPENDED = "usual.event.MY_PACKAGE_UNSUSPENDED", + /** + * a user id has been removed from the system. + */ + COMMON_EVENT_UID_REMOVED = "usual.event.UID_REMOVED", + /** + * the application is first launched after installed. + */ + COMMON_EVENT_PACKAGE_FIRST_LAUNCH = "usual.event.PACKAGE_FIRST_LAUNCH", + /** + * sent by system package verifier when a package need to be verified. + */ + COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION = "usual.event.PACKAGE_NEEDS_VERIFICATION", + /** + * sent by system package verifier when a package is verified. + */ + COMMON_EVENT_PACKAGE_VERIFIED = "usual.event.PACKAGE_VERIFIED", + /** + * Resources for a set of packages (which were previously unavailable) are currently + * available since the media on which they exist is available. + */ + COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE = "usual.event.EXTERNAL_APPLICATIONS_AVAILABLE", + /** + * Resources for a set of packages are currently unavailable since the media on which they exist is unavailable. + */ + COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE = "usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE", + /** + * the device configuration such as orientation,locale have been changed. + */ + COMMON_EVENT_CONFIGURATION_CHANGED = "usual.event.CONFIGURATION_CHANGED", + /** + * The current device's locale has changed. + */ + COMMON_EVENT_LOCALE_CHANGED = "usual.event.LOCALE_CHANGED", + /** + * Indicates low memory condition notification acknowledged by user and package management should be started. + */ + COMMON_EVENT_MANAGE_PACKAGE_STORAGE = "usual.event.MANAGE_PACKAGE_STORAGE", + /** + * sent by the smart function when the system in drive mode. + */ + COMMON_EVENT_DRIVE_MODE = "common.event.DRIVE_MODE", + /** + * sent by the smart function when the system in home mode. + */ + COMMON_EVENT_HOME_MODE = "common.event.HOME_MODE", + /** + * sent by the smart function when the system in office mode. + */ + COMMON_EVENT_OFFICE_MODE = "common.event.OFFICE_MODE", + /** + * remind new user of preparing to start. + */ + COMMON_EVENT_USER_STARTED = "usual.event.USER_STARTED", + /** + * remind previous user of that the service has been the background. + */ + COMMON_EVENT_USER_BACKGROUND = "usual.event.USER_BACKGROUND", + /** + * remind new user of that the service has been the foreground. + */ + COMMON_EVENT_USER_FOREGROUND = "usual.event.USER_FOREGROUND", + /** + * remind new user of that the service has been switched to new user. + */ + COMMON_EVENT_USER_SWITCHED = "usual.event.USER_SWITCHED", + /** + * remind new user of that the service has been starting. + */ + COMMON_EVENT_USER_STARTING = "usual.event.USER_STARTING", + /** + * remind new user of that the service has been unlocked. + */ + COMMON_EVENT_USER_UNLOCKED = "usual.event.USER_UNLOCKED", + /** + * remind new user of that the service has been stopping. + */ + COMMON_EVENT_USER_STOPPING = "usual.event.USER_STOPPING", + /** + * remind new user of that the service has stopped. + */ + COMMON_EVENT_USER_STOPPED = "usual.event.USER_STOPPED", + /** + * HW id login successfully. + */ + COMMON_EVENT_HWID_LOGIN = "common.event.HWID_LOGIN", + /** + * HW id logout successfully. + */ + COMMON_EVENT_HWID_LOGOUT = "common.event.HWID_LOGOUT", + /** + * HW id is invalid. + */ + COMMON_EVENT_HWID_TOKEN_INVALID = "common.event.HWID_TOKEN_INVALID", + /** + * HW id logs off. + */ + COMMON_EVENT_HWID_LOGOFF = "common.event.HWID_LOGOFF", + /** + * WIFI state. + */ + COMMON_EVENT_WIFI_POWER_STATE = "usual.event.wifi.POWER_STATE", + /** + * WIFI scan results. + */ + COMMON_EVENT_WIFI_SCAN_FINISHED = "usual.event.wifi.SCAN_FINISHED", + /** + * WIFI RSSI change. + */ + COMMON_EVENT_WIFI_RSSI_VALUE = "usual.event.wifi.RSSI_VALUE", + /** + * WIFI connect state. + */ + COMMON_EVENT_WIFI_CONN_STATE = "usual.event.wifi.CONN_STATE", + /** + * WIFI hotspot state. + */ + COMMON_EVENT_WIFI_HOTSPOT_STATE = "usual.event.wifi.HOTSPOT_STATE", + /** + * WIFI ap sta join. + */ + COMMON_EVENT_WIFI_AP_STA_JOIN = "usual.event.wifi.WIFI_HS_STA_JOIN", + /** + * WIFI ap sta join. + */ + COMMON_EVENT_WIFI_AP_STA_LEAVE = "usual.event.wifi.WIFI_HS_STA_LEAVE", + /** + * Indicates Wi-Fi MpLink state notification acknowledged by binding or unbinding MpLink. + */ + COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE = "usual.event.wifi.mplink.STATE_CHANGE", + /** + * Indicates Wi-Fi P2P connection state notification acknowledged by connecting or disconnecting P2P. + */ + COMMON_EVENT_WIFI_P2P_CONN_STATE = "usual.event.wifi.p2p.CONN_STATE_CHANGE", + /** + * Indicates that the Wi-Fi P2P state change. + */ + COMMON_EVENT_WIFI_P2P_STATE_CHANGED = "usual.event.wifi.p2p.STATE_CHANGE", + /** + * Indicates that the Wi-Fi P2P peers state change. + */ + COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED = "usual.event.wifi.p2p.DEVICES_CHANGE", + /** + * Indicates that the Wi-Fi P2P discovery state change. + */ + COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED = "usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE", + /** + * Indicates that the Wi-Fi P2P current device state change. + */ + COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED = "usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE", + /** + * Indicates that the Wi-Fi P2P group info is changed. + */ + COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED = "usual.event.wifi.p2p.GROUP_STATE_CHANGED", + /** + * bluetooth.handsfree.ag.connect.state.update. + */ + COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CONNECT_STATE_UPDATE = "usual.event.bluetooth.handsfree.ag.CONNECT_STATE_UPDATE", + /** + * bluetooth.handsfree.ag.current.device.update. + */ + COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CURRENT_DEVICE_UPDATE = "usual.event.bluetooth.handsfree.ag.CURRENT_DEVICE_UPDATE", + /** + * bluetooth.handsfree.ag.audio.state.update. + */ + COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_AUDIO_STATE_UPDATE = "usual.event.bluetooth.handsfree.ag.AUDIO_STATE_UPDATE", + /** + * bluetooth.a2dpsource.connect.state.update. + */ + COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CONNECT_STATE_UPDATE = "usual.event.bluetooth.a2dpsource.CONNECT_STATE_UPDATE", + /** + * bluetooth.a2dpsource.current.device.update. + */ + COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CURRENT_DEVICE_UPDATE = "usual.event.bluetooth.a2dpsource.CURRENT_DEVICE_UPDATE", + /** + * bluetooth.a2dpsource.playing.state.update. + */ + COMMON_EVENT_BLUETOOTH_A2DPSOURCE_PLAYING_STATE_UPDATE = "usual.event.bluetooth.a2dpsource.PLAYING_STATE_UPDATE", + /** + * bluetooth.a2dpsource.avrcp.connect.state.update. + */ + COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE = "usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE", + /** + * bluetooth.a2dpsource.codec.value.update. + */ + COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CODEC_VALUE_UPDATE = "usual.event.bluetooth.a2dpsource.CODEC_VALUE_UPDATE", + /** + * bluetooth.remotedevice.discovered. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_DISCOVERED = "usual.event.bluetooth.remotedevice.DISCOVERED", + /** + * bluetooth.remotedevice.class.value.update. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CLASS_VALUE_UPDATE = "usual.event.bluetooth.remotedevice.CLASS_VALUE_UPDATE", + /** + * bluetooth.remotedevice.acl.connected. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_CONNECTED = "usual.event.bluetooth.remotedevice.ACL_CONNECTED", + /** + * bluetooth.remotedevice.acl.disconnected. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_DISCONNECTED = "usual.event.bluetooth.remotedevice.ACL_DISCONNECTED", + /** + * bluetooth.remotedevice.name.update. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE = "usual.event.bluetooth.remotedevice.NAME_UPDATE", + /** + * bluetooth.remotedevice.pair.state. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIR_STATE = "usual.event.bluetooth.remotedevice.PAIR_STATE", + /** + * bluetooth.remotedevice.battery.value.update. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_BATTERY_VALUE_UPDATE = "usual.event.bluetooth.remotedevice.BATTERY_VALUE_UPDATE", + /** + * bluetooth.remotedevice.sdp.result. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT = "usual.event.bluetooth.remotedevice.SDP_RESULT", + /** + * bluetooth.remotedevice.uuid.value. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_UUID_VALUE = "usual.event.bluetooth.remotedevice.UUID_VALUE", + /** + * bluetooth.remotedevice.pairing.req. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_REQ = "usual.event.bluetooth.remotedevice.PAIRING_REQ", + /** + * bluetooth.remotedevice.pairing.cancel. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL = "usual.event.bluetooth.remotedevice.PAIRING_CANCEL", + /** + * bluetooth.remotedevice.connect.req. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ = "usual.event.bluetooth.remotedevice.CONNECT_REQ", + /** + * bluetooth.remotedevice.connect.reply. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY = "usual.event.bluetooth.remotedevice.CONNECT_REPLY", + /** + * bluetooth.remotedevice.connect.cancel. + */ + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL = "usual.event.bluetooth.remotedevice.CONNECT_CANCEL", + /** + * bluetooth.handsfreeunit.connect.state.update. + */ + COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE = "usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE", + /** + * bluetooth.handsfreeunit.audio.state.update. + */ + COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE = "usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE", + /** + * bluetooth.handsfreeunit.ag.common.event. + */ + COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT = "usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT", + /** + * bluetooth.handsfreeunit.ag.call.state.update. + */ + COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE = "usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE", + /** + * bluetooth.host.state.update. + */ + COMMON_EVENT_BLUETOOTH_HOST_STATE_UPDATE = "usual.event.bluetooth.host.STATE_UPDATE", + /** + * bluetooth.host.req.discoverable. + */ + COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE = "usual.event.bluetooth.host.REQ_DISCOVERABLE", + /** + * bluetooth.host.req.enable. + */ + COMMON_EVENT_BLUETOOTH_HOST_REQ_ENABLE = "usual.event.bluetooth.host.REQ_ENABLE", + /** + * bluetooth.host.req.disable. + */ + COMMON_EVENT_BLUETOOTH_HOST_REQ_DISABLE = "usual.event.bluetooth.host.REQ_DISABLE", + /** + * bluetooth.host.scan.mode.update. + */ + COMMON_EVENT_BLUETOOTH_HOST_SCAN_MODE_UPDATE = "usual.event.bluetooth.host.SCAN_MODE_UPDATE", + /** + * bluetooth.host.discovery.stated. + */ + COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_STARTED = "usual.event.bluetooth.host.DISCOVERY_STARTED", + /** + * bluetooth.host.discovery.finished. + */ + COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_FINISHED = "usual.event.bluetooth.host.DISCOVERY_FINISHED", + /** + * bluetooth.host.name.update. + */ + COMMON_EVENT_BLUETOOTH_HOST_NAME_UPDATE = "usual.event.bluetooth.host.NAME_UPDATE", + /** + * bluetooth.a2dp.connect.state.update. + */ + COMMON_EVENT_BLUETOOTH_A2DPSINK_CONNECT_STATE_UPDATE = "usual.event.bluetooth.a2dpsink.CONNECT_STATE_UPDATE", + /** + * bluetooth.a2dp.playing.state.update. + */ + COMMON_EVENT_BLUETOOTH_A2DPSINK_PLAYING_STATE_UPDATE = "usual.event.bluetooth.a2dpsink.PLAYING_STATE_UPDATE", + /** + * bluetooth.a2dp.audio.state.update. + */ + COMMON_EVENT_BLUETOOTH_A2DPSINK_AUDIO_STATE_UPDATE = "usual.event.bluetooth.a2dpsink.AUDIO_STATE_UPDATE", + /** + * nfc state change. + */ + COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED = "usual.event.nfc.action.ADAPTER_STATE_CHANGED", + /** + * nfc field on detected. + */ + COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED = "usual.event.nfc.action.RF_FIELD_ON_DETECTED", + /** + * nfc field off detected. + */ + COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED = "usual.event.nfc.action.RF_FIELD_OFF_DETECTED", + /** + * Sent when stop charging battery. + */ + COMMON_EVENT_DISCHARGING = "usual.event.DISCHARGING", + /** + * Sent when start charging battery. + */ + COMMON_EVENT_CHARGING = "usual.event.CHARGING", + /** + * Sent when device's idle mode changed + */ + COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED = "usual.event.DEVICE_IDLE_MODE_CHANGED", + /** + * Sent when device's power save mode changed + */ + COMMON_EVENT_POWER_SAVE_MODE_CHANGED = "usual.event.POWER_SAVE_MODE_CHANGED", + /** + * user added. + */ + COMMON_EVENT_USER_ADDED = "usual.event.USER_ADDED", + /** + * user removed. + */ + COMMON_EVENT_USER_REMOVED = "usual.event.USER_REMOVED", + /** + * Sent when ability is added. + */ + COMMON_EVENT_ABILITY_ADDED = "common.event.ABILITY_ADDED", + /** + * Sent when ability is removed. + */ + COMMON_EVENT_ABILITY_REMOVED = "common.event.ABILITY_REMOVED", + /** + * Sent when ability is updated. + */ + COMMON_EVENT_ABILITY_UPDATED = "common.event.ABILITY_UPDATED", + /** + * gps mode state changed. + */ + COMMON_EVENT_LOCATION_MODE_STATE_CHANGED = "usual.event.location.MODE_STATE_CHANGED", + /** + * The ivi is about to go into sleep state when the ivi is turned off power. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_IVI_SLEEP = "common.event.IVI_SLEEP", + /** + * The ivi is slept and notify the app stop playing. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_IVI_PAUSE = "common.event.IVI_PAUSE", + /** + * The ivi is standby and notify the app stop playing. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_IVI_STANDBY = "common.event.IVI_STANDBY", + /** + * The app stop playing and save state. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_IVI_LASTMODE_SAVE = "common.event.IVI_LASTMODE_SAVE", + /** + * The ivi is voltage abnormal. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_IVI_VOLTAGE_ABNORMAL = "common.event.IVI_VOLTAGE_ABNORMAL", + /** + * The ivi temperature is too high. + * This is a protected common event that can only be sent by system.this common event will be delete later, + * please use COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL. + */ + COMMON_EVENT_IVI_HIGH_TEMPERATURE = "common.event.IVI_HIGH_TEMPERATURE", + /** + * The ivi temperature is extreme high. + * This is a protected common event that can only be sent by system.this common event will be delete later, + * please use COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL. + */ + COMMON_EVENT_IVI_EXTREME_TEMPERATURE = "common.event.IVI_EXTREME_TEMPERATURE", + /** + * The ivi temperature is abnormal. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL = "common.event.IVI_TEMPERATURE_ABNORMAL", + /** + * The ivi voltage is recovery. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_IVI_VOLTAGE_RECOVERY = "common.event.IVI_VOLTAGE_RECOVERY", + /** + * The ivi temperature is recovery. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_IVI_TEMPERATURE_RECOVERY = "common.event.IVI_TEMPERATURE_RECOVERY", + /** + * The battery service is active. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_IVI_ACTIVE = "common.event.IVI_ACTIVE", + /** + * The usb device attached. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_USB_DEVICE_ATTACHED = "usual.event.hardware.usb.action.USB_DEVICE_ATTACHED", + /** + * The usb device detached. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_USB_DEVICE_DETACHED = "usual.event.hardware.usb.action.USB_DEVICE_DETACHED", + /** + * The usb accessory attached. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_USB_ACCESSORY_ATTACHED = "usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED", + /** + * The usb accessory detached. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_USB_ACCESSORY_DETACHED = "usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED", + /** + * The external storage was removed. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_DISK_REMOVED = "usual.event.data.DISK_REMOVED", + /** + * The external storage was unmounted. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_DISK_UNMOUNTED = "usual.event.data.DISK_UNMOUNTED", + /** + * The external storage was mounted. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_DISK_MOUNTED = "usual.event.data.DISK_MOUNTED", + /** + * The external storage was bad removal. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_DISK_BAD_REMOVAL = "usual.event.data.DISK_BAD_REMOVAL", + /** + * The external storage was unmountable. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_DISK_UNMOUNTABLE = "usual.event.data.DISK_UNMOUNTABLE", + /** + * The external storage was eject. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_DISK_EJECT = "usual.event.data.DISK_EJECT", + /** + * The external storage was removed. + * This is a protected common event that can only be sent by system. + * @since 9 + */ + COMMON_EVENT_VOLUME_REMOVED = "usual.event.data.VOLUME_REMOVED", + /** + * The external storage was unmounted. + * This is a protected common event that can only be sent by system. + * @since 9 + */ + COMMON_EVENT_VOLUME_UNMOUNTED = "usual.event.data.VOLUME_UNMOUNTED", + /** + * The external storage was mounted. + * This is a protected common event that can only be sent by system. + * @since 9 + */ + COMMON_EVENT_VOLUME_MOUNTED = "usual.event.data.VOLUME_MOUNTED", + /** + * The external storage was bad removal. + * This is a protected common event that can only be sent by system. + * @since 9 + */ + COMMON_EVENT_VOLUME_BAD_REMOVAL = "usual.event.data.VOLUME_BAD_REMOVAL", + /** + * The external storage was eject. + * This is a protected common event that can only be sent by system. + * @since 9 + */ + COMMON_EVENT_VOLUME_EJECT = "usual.event.data.VOLUME_EJECT", + /** + * The visible of account was updated. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED = "usual.event.data.VISIBLE_ACCOUNTS_UPDATED", + /** + * Account was deleted. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_ACCOUNT_DELETED = "usual.event.data.ACCOUNT_DELETED", + /** + * Foundation was ready. + * This is a protected common event that can only be sent by system. + */ + COMMON_EVENT_FOUNDATION_READY = "common.event.FOUNDATION_READY", + /** + * Indicates the common event Action indicating that the airplane mode status of the device changes. + * Users can register this event to listen to the change of the airplane mode status of the device. + */ + COMMON_EVENT_AIRPLANE_MODE_CHANGED = "usual.event.AIRPLANE_MODE", + /** + * sent by the window manager service when the window mode is split. + * @since 8 + */ + COMMON_EVENT_SPLIT_SCREEN = "common.event.SPLIT_SCREEN", + /** + * The notification slot has been updated. + * This is a protected common event that can only be sent by system. + * @since 9 + */ + COMMON_EVENT_SLOT_CHANGE = "usual.event.SLOT_CHANGE", + /** + * Indicate the action of a common event that the spn display information has been updated. + * This common event can be triggered only by system. + * @since 9 + */ + COMMON_EVENT_SPN_INFO_CHANGED = "usual.event.SPN_INFO_CHANGED" + } +} +export default commonEvent; diff --git a/build-tools/api/@ohos.connectedTag.d.ts b/build-tools/api/@ohos.connectedTag.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..28089843fa94cf5913673693a38fa951e4ec5060 --- /dev/null +++ b/build-tools/api/@ohos.connectedTag.d.ts @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from './basic'; +/** + * Provides methods to operate or manage Connected Tag. + * + * @since 8 + * @syscap SystemCapability.Communication.ConnectedTag + * @import import connectedTag from '@ohos.connectedTag'; + */ +declare namespace connectedTag { + /** + * Initializes Connected Tag. + * + * @return Returns true or false. + * @permissions ohos.permission.NFC_TAG + * + * @since 8 + */ + function init(): boolean; + /** + * UnInitializes Connected Tag. + * + * @return Returns true or false. + * @permissions ohos.permission.NFC_TAG + * + * @since 8 + */ + function uninit(): boolean; + /** + * Reads the NDEF Data. + * + * @return Returns the NDEF Data. + * @permissions ohos.permission.NFC_TAG + * + * @since 8 + */ + function readNdefTag(): Promise; + function readNdefTag(callback: AsyncCallback): void; + /** + * Writes the NDEF Data. + * + * @param data The Data to write. + * @return Returns true or false. + * @permissions ohos.permission.NFC_TAG + * + * @since 8 + */ + function writeNdefTag(data: string): Promise; + function writeNdefTag(data: string, callback: AsyncCallback): void; + /** + * Subscribes NFC RF status change events. + * + * @type The callback type. + * @param callback The callback function to be registered. + * @return Returns NFC_RF_LEAVE or NFC_RF_ENTER + * @permissions ohos.permission.NFC_TAG + * + * @since 8 + */ + function on(type: "notify", callback: Callback): void; + /** + * Unsubscribes NFC RF status change events. + * + *

All callback functions will be deregistered If there is no specific callback parameter.

+ * + * @type The callback type. + * @param callback The callback function to be unregistered. + * @permissions ohos.permission.NFC_TAG + * + * @since 8 + */ + function off(type: "notify", callback?: Callback): void; + /** + * Describes the NFC RF type. + * + * @since 8 + */ + enum NfcRfType { + /** NFC RF LEAVE */ + NFC_RF_LEAVE = 0, + /** NFC RF ENTER */ + NFC_RF_ENTER = 1 + } +} +export default connectedTag; diff --git a/build-tools/api/@ohos.contact.d.ts b/build-tools/api/@ohos.contact.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cecba7350ff79cd494d805eda1dcd1c6727c1561 --- /dev/null +++ b/build-tools/api/@ohos.contact.d.ts @@ -0,0 +1,865 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * Contains variety of system contact, provides functions for adding, updating and deleting these system contact + * and provides methods for querying the information of contact. + * + * @since 7 + * @syscap SystemCapability.Applications.ContactsData + */ +declare namespace contact { + /** + * Creates a contact. + * + * @param contact Indicates the contact information. + * @return Returns the contact ID (which can be obtained by {@link Contact#getId()}) if the creation is successful; + * returns {@link Contact#INVALID_CONTACT_ID} if the creation fails. + * @permision ohos.permission.WRITE_CONTACTS + */ + function addContact(contact: Contact, callback: AsyncCallback): void; + function addContact(contact: Contact): Promise; + /** + * Select contact. + * + * @return Returns the contact list which user select; + * returns empty contact list if user not select. + * @syscap SystemCapability.Applications.ContactsData, SystemCapability.Applications.Contacts + * @permission ohos.permission.READ_CONTACTS + */ + function selectContact(callback: AsyncCallback>): void; + function selectContact(): Promise>; + /** + * Deletes a specified contact. + * + * @param key Indicates the unique query key of a contact to delete. + * @return Returns {@code true} if the contact is deleted; returns {@code false} otherwise. + * @permision ohos.permission.WRITE_CONTACTS + */ + function deleteContact(key: string, callback: AsyncCallback): void; + function deleteContact(key: string): Promise; + /** + * Queries a specified contact of specified attributes. + * + * @param key Indicates the unique query key of a contact. + * @param holder Indicates the contact holder. If this parameter is null, the default holder is used for matching. + * @param attrs Indicates the contact attributes. If this parameter is null, all attributes are used for matching. + * @return Returns the specified contact. + * @permission ohos.permission.READ_CONTACTS + */ + function queryContact(key: string, callback: AsyncCallback): void; + function queryContact(key: string, holder: Holder, callback: AsyncCallback): void; + function queryContact(key: string, attrs: ContactAttributes, callback: AsyncCallback): void; + function queryContact(key: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback): void; + function queryContact(key: string, holder?: Holder, attrs?: ContactAttributes): Promise; + /** + * Queries contacts with query conditions. + * + * @param holder Indicates the contact holder. If this parameter is null, the default holder is used for matching. + * @param attrs Indicates the contact attributes. If this parameter is null, all attributes are used for matching. + * @return Returns the {@code Contact} list object. + * @permission ohos.permission.READ_CONTACTS + */ + function queryContacts(callback: AsyncCallback>): void; + function queryContacts(holder: Holder, callback: AsyncCallback>): void; + function queryContacts(attrs: ContactAttributes, callback: AsyncCallback>): void; + function queryContacts(holder: Holder, attrs: ContactAttributes, callback: AsyncCallback>): void; + function queryContacts(holder?: Holder, attrs?: ContactAttributes): Promise>; + /** + * Queries contacts by a specified email address, contact holder, and contact attributes. + * + * @param email Indicates the email address. + * @param holder Indicates the contact holder. If this parameter is null, the default holder is used for matching. + * @param attrs Indicates the contact attributes. If this parameter is null, all attributes are used for matching. + * @return Returns a {@code Contact} list object. + * @permission ohos.permission.READ_CONTACTS + */ + function queryContactsByEmail(email: string, callback: AsyncCallback>): void; + function queryContactsByEmail(email: string, holder: Holder, callback: AsyncCallback>): void; + function queryContactsByEmail(email: string, attrs: ContactAttributes, callback: AsyncCallback>): void; + function queryContactsByEmail(email: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback>): void; + function queryContactsByEmail(email: string, holder?: Holder, attrs?: ContactAttributes): Promise>; + /** + * Queries contacts by a phone number, holder, and contact attribute. + * + * @param phoneNumber Indicates the phone number. Only full match is supported, and wildcards are not supported. + * @param holder Indicates the contact holder. If this parameter is null, the default holder is used for matching. + * @param attrs Indicates the contact attribute. If this parameter is null, + * all attributes will be used for matching. + * @return Returns the {@code Contact} list object. + * @permission ohos.permission.READ_CONTACTS + */ + function queryContactsByPhoneNumber(phoneNumber: string, callback: AsyncCallback>): void; + function queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, callback: AsyncCallback>): void; + function queryContactsByPhoneNumber(phoneNumber: string, attrs: ContactAttributes, callback: AsyncCallback>): void; + function queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback>): void; + function queryContactsByPhoneNumber(phoneNumber: string, holder?: Holder, attrs?: ContactAttributes): Promise>; + /** + * Queries contact groups. + * + * @param holder Indicates the contact holder. If this parameter is null, the default holder is used for matching. + * @return Returns the contact group list. + * @permission ohos.permission.READ_CONTACTS + */ + function queryGroups(callback: AsyncCallback>): void; + function queryGroups(holder: Holder, callback: AsyncCallback>): void; + function queryGroups(holder?: Holder): Promise>; + /** + * Queries contact holders. + * + * @return Returns the {@code Holder} list object. + * @permission ohos.permission.READ_CONTACTS + */ + function queryHolders(callback: AsyncCallback>): void; + function queryHolders(): Promise>; + /** + * Obtains the query key of a contact based on a specified ID and holder. + * + * @param id Indicates the contact ID. + * @param holder Indicates the contact holder. If this parameter is null, the default holder is used for matching. + * @return Returns the query key of the contact. + * @permission ohos.permission.READ_CONTACTS + */ + function queryKey(id: number, callback: AsyncCallback): void; + function queryKey(id: number, holder: Holder, callback: AsyncCallback): void; + function queryKey(id: number, holder?: Holder): Promise; + /** + * Queries information about "my card". + * + * @param attrs Indicates the contact attributes. If this parameter is null, all attributes are used for matching. + * @return Returns information about "my card". + * @permission ohos.permission.READ_CONTACTS + */ + function queryMyCard(callback: AsyncCallback): void; + function queryMyCard(attrs: ContactAttributes, callback: AsyncCallback): void; + function queryMyCard(attrs?: ContactAttributes): Promise; + /** + * Updates specified attributes of a contact. + * + * @param contact Indicates the contact whose information is to update. + * @param attrs Indicates the contact attributes to update. If this parameter is null, + * all available attributes will be updated. + * @return Returns {@code true} if the update is successful; returns {@code false} otherwise. + * @permision ohos.permission.WRITE_CONTACTS + */ + function updateContact(contact: Contact, callback: AsyncCallback): void; + function updateContact(contact: Contact, attrs: ContactAttributes, callback: AsyncCallback): void; + function updateContact(contact: Contact, attrs?: ContactAttributes): Promise; + /** + * Checks whether the contact ID is in the local phone book. + * + * @param id Indicates the contact ID. + * @return Returns {@code true} if the contact ID is in the local phone book; returns {@code false} otherwise. + * @permission ohos.permission.READ_CONTACTS + */ + function isLocalContact(id: number, callback: AsyncCallback): void; + function isLocalContact(id: number): Promise; + /** + * Checks whether the contact ID is of "my card". + * + * @param id Indicates the contact ID. + * @return Returns {@code true} if the contact ID is of "my card"; returns {@code false} otherwise. + * @permission ohos.permission.READ_CONTACTS + */ + function isMyCard(id: number, callback: AsyncCallback): void; + function isMyCard(id: number): Promise; + /** + * Provides methods for contact information + */ + class Contact { + /** + * Indicates the contact ID. + */ + static readonly INVALID_CONTACT_ID: -1; + /** + * Indicates the contact ID. + */ + readonly id: number; + /** + * Indicates the query key that identifies the contact. + */ + readonly key: string; + /** + * Indicates the contact attributes. + */ + contactAttributes: ContactAttributes; + /** + * Indicates an email address of the contact. + */ + emails: Email[]; + /** + * Indicates an event (special date) of the contact. + */ + events: Event[]; + /** + * Indicates a group of the contact. + */ + groups: Group[]; + /** + * Indicates an IM address of the contact. + */ + imAddresses: ImAddress[]; + /** + * Indicates a phone number of the contact. + */ + phoneNumbers: PhoneNumber[]; + /** + * Indicates the contact portrait. + */ + portrait: Portrait; + /** + * Indicates a postal address of the contact. + */ + postalAddresses: PostalAddress[]; + /** + * Indicates a relation of the contact. + */ + relations: Relation[]; + /** + * Indicates a Session Initiation Protocol (SIP) address of the contact. + */ + sipAddresses: SipAddress[]; + /** + * Indicates a website of the contact. + */ + websites: Website[]; + /** + * Indicates the contact name. + */ + name: Name; + /** + * Indicates the contact nickname. + */ + nickName: NickName; + /** + * Indicates the contact note. + */ + note: Note; + /** + * Indicates organization information about the contact. + */ + organization: Organization; + } + /** + * Provides methods for contact attributes information + */ + class ContactAttributes { + /** + * Indicates the contact attributes. + */ + attributes: Attribute[]; + } + /** + * Provides methods for attribute information + */ + enum Attribute { + /** + * Indicates the contact event. + */ + ATTR_CONTACT_EVENT, + /** + * Indicates the email address. + */ + ATTR_EMAIL, + /** + * Indicates the contact group. + */ + ATTR_GROUP_MEMBERSHIP, + /** + * Indicates the instant messaging (IM) address. + */ + ATTR_IM, + /** + * Indicates the name. + */ + ATTR_NAME, + /** + * Indicates the nickname. + */ + ATTR_NICKNAME, + /** + * Indicates the note. + */ + ATTR_NOTE, + /** + * Indicates the organization. + */ + ATTR_ORGANIZATION, + /** + * Indicates the phone number. + */ + ATTR_PHONE, + /** + * Indicates the portrait. + */ + ATTR_PORTRAIT, + /** + * Indicates the postal address. + */ + ATTR_POSTAL_ADDRESS, + /** + * Indicates the relation. + */ + ATTR_RELATION, + /** + * Indicates the Session Initiation Protocol (SIP) address. + */ + ATTR_SIP_ADDRESS, + /** + * Indicates the website. + */ + ATTR_WEBSITE + } + /** + * Provides methods for email information + */ + class Email { + /** + * Indicates a custom label. + */ + static readonly CUSTOM_LABEL: 0; + /** + * Indicates a home email. + */ + static readonly EMAIL_HOME: 1; + /** + * Indicates a work email. + */ + static readonly EMAIL_WORK: 2; + /** + * Indicates an email of the OTHER type. + */ + static readonly EMAIL_OTHER: 3; + /** + * Indicates an invalid label ID. + */ + static readonly INVALID_LABEL_ID: -1; + /** + * Indicates the email address. + */ + email: string; + /** + * Indicates the label name of an attribute. + */ + labelName: string; + /** + * Indicates the displayed email name. + */ + displayName: string; + /** + * Indicates the label id. + */ + labelId: number; + } + /** + * Provides methods for event information + */ + class Event { + /** + * Indicates a custom label. + */ + static readonly CUSTOM_LABEL: 0; + /** + * Indicates an anniversary event. + */ + static readonly EVENT_ANNIVERSARY: 1; + /** + * Indicates an event of the OTHER type. + */ + static readonly EVENT_OTHER: 2; + /** + * Indicates an birthday event. + */ + static readonly EVENT_BIRTHDAY: 3; + /** + * Indicates an invalid label ID. + */ + static readonly INVALID_LABEL_ID: -1; + /** + * Indicates the event date. + */ + eventDate: string; + /** + * Indicates the label name of an attribute. + */ + labelName: string; + /** + * Indicates the label id. + */ + labelId: number; + } + /** + * Provides methods for group information + */ + class Group { + /** + * Indicates the contact group ID. + */ + groupId: number; + /** + * Indicates the contact group title. + */ + title: string; + } + /** + * Provides methods for holder information + */ + class Holder { + /** + * Indicates the bundle name of a contact holder. + */ + readonly bundleName: string; + /** + * Indicates the displayed name of a contact holder. + */ + readonly displayName: string; + /** + * Indicates the holder ID. + */ + holderId: number; + } + /** + * Provides methods for ImAddress information + */ + class ImAddress { + /** + * Indicates a custom label. + */ + static readonly CUSTOM_LABEL: -1; + /** + * Indicates an AIM instant message. + */ + static readonly IM_AIM: 0; + /** + * Indicates a Windows Live instant message. + */ + static readonly IM_MSN: 1; + /** + * Indicates a Yahoo instant message. + */ + static readonly IM_YAHOO: 2; + /** + * Indicates a Skype instant message. + */ + static readonly IM_SKYPE: 3; + /** + * Indicates a QQ instant message. + */ + static readonly IM_QQ: 4; + /** + * Indicates an ICQ instant message. + */ + static readonly IM_ICQ: 6; + /** + * Indicates a Jabber instant message. + */ + static readonly IM_JABBER: 7; + /** + * Indicates an invalid label ID. + */ + static readonly INVALID_LABEL_ID: -2; + /** + * Indicates the IM address. + */ + imAddress: string; + /** + * Indicates the label name of an attribute. + */ + labelName: string; + /** + * Indicates the label id. + */ + labelId: number; + } + /** + * Provides methods for name information + */ + class Name { + /** + * Indicates the family name of the contact. + */ + familyName: string; + /** + * Indicates the phonetic family name of the contact. + */ + familyNamePhonetic: string; + /** + * Indicates the full name of the contact. + */ + fullName: string; + /** + * Indicates the given name of the contact. + */ + givenName: string; + /** + * Indicates the phonetic given name of the contact. + */ + givenNamePhonetic: string; + /** + * Indicates the middle name of the contact. + */ + middleName: string; + /** + * Indicates the phonetic middle name of the contact. + */ + middleNamePhonetic: string; + /** + * Indicates the prefix of the contact name. + */ + namePrefix: string; + /** + * Indicates the suffix of this contact name. + */ + nameSuffix: string; + } + /** + * Provides methods for nick name information + */ + class NickName { + /** + * Indicates the nickname of the contact. + */ + nickName: string; + } + /** + * Provides methods for note information + */ + class Note { + /** + * Indicates the note content. + */ + noteContent: string; + } + /** + * Provides methods for organization information + */ + class Organization { + /** + * Indicates the name of the organization to which the contact belongs. + */ + name: string; + /** + * Indicates the title of the contact. + */ + title: string; + } + /** + * Provides methods for phone number information + */ + class PhoneNumber { + /** + * Indicates a custom label. + */ + static readonly CUSTOM_LABEL: 0; + /** + * Indicates a home number. + */ + static readonly NUM_HOME: 1; + /** + * Indicates a mobile phone number. + */ + static readonly NUM_MOBILE: 2; + /** + * Indicates a work number. + */ + static readonly NUM_WORK: 3; + /** + * Indicates a work fax number. + */ + static readonly NUM_FAX_WORK: 4; + /** + * Indicates a home fax number. + */ + static readonly NUM_FAX_HOME: 5; + /** + * Indicates a pager number. + */ + static readonly NUM_PAGER: 6; + /** + * Indicates a number of the OTHER type. + */ + static readonly NUM_OTHER: 7; + /** + * Indicates a callback number. + */ + static readonly NUM_CALLBACK: 8; + /** + * Indicates a car number. + */ + static readonly NUM_CAR: 9; + /** + * Indicates a company director number. + */ + static readonly NUM_COMPANY_MAIN: 10; + /** + * Indicates an Integrated Services Digital Network (ISDN) number. + */ + static readonly NUM_ISDN: 11; + /** + * Indicates a main number. + */ + static readonly NUM_MAIN: 12; + /** + * Indicates a number of the OTHER_FAX type. + */ + static readonly NUM_OTHER_FAX: 13; + /** + * Indicates a radio number. + */ + static readonly NUM_RADIO: 14; + /** + * Indicates a telex number. + */ + static readonly NUM_TELEX: 15; + /** + * Indicates a teletypewriter (TTY) or test-driven development (TDD) number. + */ + static readonly NUM_TTY_TDD: 16; + /** + * Indicates a work mobile phone number. + */ + static readonly NUM_WORK_MOBILE: 17; + /** + * Indicates a work pager number. + */ + static readonly NUM_WORK_PAGER: 18; + /** + * Indicates an assistant number. + */ + static readonly NUM_ASSISTANT: 19; + /** + * Indicates an MMS number. + */ + static readonly NUM_MMS: 20; + /** + * Indicates an invalid label ID. + */ + static readonly INVALID_LABEL_ID: -1; + /** + * Indicates the label name of an attribute. + */ + labelName: string; + /** + * Indicates the phone number of the contact. + */ + phoneNumber: string; + /** + * Indicates the label id. + */ + labelId: number; + } + /** + * Provides methods for portrait information + */ + class Portrait { + /** + * Indicates the uri of the contact portrait. + */ + uri: string; + } + /** + * Provides methods for postal address information + */ + class PostalAddress { + /** + * Indicates a custom label. + */ + static readonly CUSTOM_LABEL: 0; + /** + * Indicates a home address. + */ + static readonly ADDR_HOME: 1; + /** + * Indicates a work address. + */ + static readonly ADDR_WORK: 2; + /** + * Indicates an address of the OTHER type. + */ + static readonly ADDR_OTHER: 3; + /** + * Indicates an invalid label ID. + */ + static readonly INVALID_LABEL_ID: -1; + /** + * Indicates the city where this contact is located. + */ + city: string; + /** + * Indicates the country/region where this contact is located. + */ + country: string; + /** + * Indicates the label name of an attribute. + */ + labelName: string; + /** + * Indicates the neighborhood where this contact is located. + */ + neighborhood: string; + /** + * Indicates the post box of this contact. + */ + pobox: string; + /** + * Indicates the postal address of this contact. + */ + postalAddress: string; + /** + * Indicates the postal code of this contact. + */ + postcode: string; + /** + * Indicates the area where this contact is located. + */ + region: string; + /** + * Indicates the street where this contact is located. + */ + street: string; + /** + * Indicates the label id. + */ + labelId: number; + } + /** + * Provides methods for relation information + */ + class Relation { + /** + * Indicates a custom label. + */ + static readonly CUSTOM_LABEL: 0; + /** + * Indicates an assistant. + */ + static readonly RELATION_ASSISTANT: 1; + /** + * Indicates a brother. + */ + static readonly RELATION_BROTHER: 2; + /** + * Indicates a child. + */ + static readonly RELATION_CHILD: 3; + /** + * Indicates a domestic partner. + */ + static readonly RELATION_DOMESTIC_PARTNER: 4; + /** + * Indicates a father. + */ + static readonly RELATION_FATHER: 5; + /** + * Indicates a friend. + */ + static readonly RELATION_FRIEND: 6; + /** + * Indicates a manager. + */ + static readonly RELATION_MANAGER: 7; + /** + * Indicates a mother. + */ + static readonly RELATION_MOTHER: 8; + /** + * Indicates a parent. + */ + static readonly RELATION_PARENT: 9; + /** + * Indicates a partner. + */ + static readonly RELATION_PARTNER: 10; + /** + * Indicates a referrer. + */ + static readonly RELATION_REFERRED_BY: 11; + /** + * Indicates a relative. + */ + static readonly RELATION_RELATIVE: 12; + /** + * Indicates a sister. + */ + static readonly RELATION_SISTER: 13; + /** + * Indicates a spouse. + */ + static readonly RELATION_SPOUSE: 14; + /** + * Indicates an invalid label ID. + */ + static readonly INVALID_LABEL_ID: -1; + /** + * Indicates the label name of an attribute. + */ + labelName: string; + /** + * Indicates the relation name. + */ + relationName: string; + /** + * Indicates the label id. + */ + labelId: number; + } + /** + * Provides methods for sip address information + */ + class SipAddress { + /** + * Indicates a custom label. + */ + static readonly CUSTOM_LABEL: 0; + /** + * Indicates a home SIP address. + */ + static readonly SIP_HOME: 1; + /** + * Indicates a work SIP address. + */ + static readonly SIP_WORK: 2; + /** + * Indicates an SIP address of the OTHER type. + */ + static readonly SIP_OTHER: 3; + /** + * Indicates an invalid label ID. + */ + static readonly INVALID_LABEL_ID: -1; + /** + * Indicates the label name of an attribute. + */ + labelName: string; + /** + * Indicates the SIP address. + */ + sipAddress: string; + /** + * Indicates the label id. + */ + labelId: number; + } + /** + * Provides methods for website information + */ + class Website { + /** + * Indicates the website. + */ + website: string; + } +} +export default contact; diff --git a/build-tools/api/@ohos.continuation.continuationManager.d.ts b/build-tools/api/@ohos.continuation.continuationManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..99708e5fc1bbbaf705d08e9d1964f01ce7066f3c --- /dev/null +++ b/build-tools/api/@ohos.continuation.continuationManager.d.ts @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Callback } from './basic'; +import { AsyncCallback } from './basic'; +import { ContinuationResult } from './continuation/continuationResult'; +import { ContinuationExtraParams } from './continuation/continuationExtraParams'; +/** + * Provides methods for interacting with the continuation manager servcie, including methods for registering and + * unregistering the ability to hop, updating the device connection state, and showing the list of devices + * that can be selected for hopping. + * @name continuationManager + * @since 8 + * @syscap SystemCapability.Ability.DistributedAbilityManager + * @permission N/A + */ +declare namespace continuationManager { + /** + * Called when the user selects devices from the candidate device list. + * You can implement your own processing logic in this callback to initiate the hop process. + * + * @since 9 + * @syscap SystemCapability.Ability.DistributedAbilityManager + * @param type deviceConnect. + * @return callback Indicates the information about the selected devices. + */ + function on(type: "deviceConnect", token: number, callback: Callback>): void; + function off(type: "deviceConnect", token: number): void; + /** + * Called when devices is disconnected from the continuation manager servcie. + * You can implement your own processing logic in this callback, such as notifying the user of the disconnection. + * + * @since 9 + * @syscap SystemCapability.Ability.DistributedAbilityManager + * @param type deviceDisconnect. + * @return callback Indicates the ID of the disconnected devices. + */ + function on(type: "deviceDisconnect", token: number, callback: Callback>): void; + function off(type: "deviceDisconnect", token: number): void; + /** + * Called when the user selects a device from the candidate device list. + * You can implement your own processing logic in this callback to initiate the hop process. + * + * @since 8 + * @deprecated since 9 + * @syscap SystemCapability.Ability.DistributedAbilityManager + * @param type deviceConnect. + * @return callback Indicates the information about the selected device. + */ + function on(type: "deviceConnect", callback: Callback): void; + function off(type: "deviceConnect", callback?: Callback): void; + /** + * Called when a device is disconnected from the continuation manager servcie. + * You can implement your own processing logic in this callback, such as notifying the user of the disconnection. + * + * @since 8 + * @deprecated since 9 + * @syscap SystemCapability.Ability.DistributedAbilityManager + * @param type deviceDisconnect. + * @return callback Indicates the ID of the disconnected device. + */ + function on(type: "deviceDisconnect", callback: Callback): void; + function off(type: "deviceDisconnect", callback?: Callback): void; + /** + * Registers an ability to be hopped with the continuation manager servcie and obtains the registration token + * assigned to the ability. + * + * @since 8 + * @syscap SystemCapability.Ability.DistributedAbilityManager + * @param options Indicates the {@link ExtraParams} object containing the extra parameters used to filter + * the list of available devices. + * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected. + */ + function register(callback: AsyncCallback): void; + function register(options: ContinuationExtraParams, callback: AsyncCallback): void; + function register(options?: ContinuationExtraParams): Promise; + /** + * Unregisters a specified ability from the continuation manager servcie based on the token obtained during ability + * registration. + * + * @since 8 + * @syscap SystemCapability.Ability.DistributedAbilityManager + * @param token Indicates the registration token of the ability. + * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected. + */ + function unregister(token: number, callback: AsyncCallback): void; + function unregister(token: number): Promise; + /** + * Updates the connection state of the device where the specified ability is successfully hopped. + * + * @since 8 + * @syscap SystemCapability.Ability.DistributedAbilityManager + * @param token Indicates the registration token of the ability. + * @param deviceId Indicates the ID of the device whose connection state is to be updated. + * @param status Indicates the connection state to update. + * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected. + */ + function updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback): void; + function updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise; + /** + * Start to manage the devices that can be selected for continuation on the distributed network. + * + * @since 8 + * @syscap SystemCapability.Ability.DistributedAbilityManager + * @param token Indicates the registration token of the ability. + * @param options Indicates the extraParams object containing the extra parameters used to filter + * the list of available devices. This parameter can be null. + * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected. + */ + function startDeviceManager(token: number, callback: AsyncCallback): void; + function startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback): void; + function startDeviceManager(token: number, options?: ContinuationExtraParams): Promise; + /** + * Device connection status data structure. + * + * @since 8 + * @syscap SystemCapability.Ability.DistributedAbilityManager + */ + export enum DeviceConnectState { + IDLE = 0, + CONNECTING = 1, + CONNECTED = 2, + DISCONNECTING = 3 + } + /** + * Indicates the description of additional parameters for continuation. + * + * @since 8 + * @syscap SystemCapability.Ability.DistributedAbilityManager + */ + export enum ContinuationMode { + /** + * Collaboration with a single device. + */ + COLLABORATION_SINGLE = 0, + /** + * Collaboration with multiple devices. + */ + COLLABORATION_MULTIPLE = 1 + } +} +export default continuationManager; diff --git a/build-tools/api/@ohos.convertxml.d.ts b/build-tools/api/@ohos.convertxml.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e8d077beae525bf4167467e7c3710d1e6d4d8a07 --- /dev/null +++ b/build-tools/api/@ohos.convertxml.d.ts @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The convertxml module provides utilities for converting XML text to Javascript object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @import import convertXml from '@ohos.convertxml'; + * @permission N/A + */ +declare namespace xml { + interface ConvertOptions { + /** + * Whether to trim whitespace characters that may exist before and after the text, default false. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + trim: boolean; + /** + * Whether to ignore writing declaration directives of xml. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ignoreDeclaration?: boolean; + /** + * Whether to ignore writing processing instruction of xml. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ignoreInstruction?: boolean; + /** + * Whether to print attributes across multiple lines and indent them. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ignoreAttributes?: boolean; + /** + * Whether to ignore writing comments of the elements. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ignoreComment?: boolean; + /** + * Whether to ignore writing CDATA of the elements. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ignoreCDATA?: boolean; + /** + * Whether to ignore writing Doctype of the elements. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ignoreDoctype?: boolean; + /** + * Whether to ignore writing texts of the elements. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ignoreText?: boolean; + /** + * Name of the property key which will be used for the declaration. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + declarationKey: string; + /** + * Name of the property key which will be used for the processing instruction. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + instructionKey: string; + /** + * Name of the property key which will be used for the attributes. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + attributesKey: string; + /** + * Name of the property key which will be used for the text. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + textKey: string; + /** + * Name of the property key which will be used for the cdata. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + cdataKey: string; + /** + * Name of the property key which will be used for the doctype. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + doctypeKey: string; + /** + * Name of the property key which will be used for the comment. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + commentKey: string; + /** + * Name of the property key which will be used for the parent. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + parentKey: string; + /** + * Name of the property key which will be used for the type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + typeKey: string; + /** + * Name of the property key which will be used for the name. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + nameKey: string; + /** + * Name of the property key which will be used for the elements. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + elementsKey: string; + } + class ConvertXML { + /** + * To convert XML text to JavaScript object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param xml The xml text to be converted. + * @param option Option Inputted by user to set. + * @return Returns a JavaScript object converting from XML text. + */ + convert(xml: string, options?: ConvertOptions): Object; + } +} +export default xml; diff --git a/build-tools/api/@ohos.curves.d.ts b/build-tools/api/@ohos.curves.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..48ea75dd6017eff05cc9354ba9ab595f3ecc5f66 --- /dev/null +++ b/build-tools/api/@ohos.curves.d.ts @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2021-2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** + * Contains interpolator functions such as initialization, third-order Bezier curves, and spring curves. + * @import import Curves from '@ohos.curves' + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 7 + */ +declare namespace curves { + /** + * enum Curve. + * @since 7 + */ + enum Curve { + Linear, + Ease, + EaseIn, + EaseOut, + EaseInOut, + FastOutSlowIn, + LinearOutSlowIn, + FastOutLinearIn, + ExtremeDeceleration, + Sharp, + Rhythm, + Smooth, + Friction + } + /** + * Interface for curve object. + * @since 9 + */ + interface ICurve { + /** + * Get curve value by fraction. + * @since 9 + */ + interpolate(fraction: number): number; + } + /** + * Initializes the interpolator curve when called. + * @since 9 + */ + function initCurve(curve?: Curve): ICurve; + /** + * Initializes the interpolator curve when called. + * @since 7 + * @deprecated since 9 + */ + function init(curve?: Curve): string; + /** + * Constructs a step curve when called. + * @since 9 + */ + function stepsCurve(count: number, end: boolean): ICurve; + /** + * Constructs a step curve when called. + * @since 7 + * @deprecated since 9 + */ + function steps(count: number, end: boolean): string; + /** + * Constructs a third-order Bezier curve when called. + * @since 9 + */ + function cubicBezierCurve(x1: number, y1: number, x2: number, y2: number): ICurve; + /** + * Constructs a third-order Bezier curve when called. + * @since 7 + * @deprecated since 9 + */ + function cubicBezier(x1: number, y1: number, x2: number, y2: number): string; + /** + * Constructs a spring curve when called. + * @since 9 + */ + function springCurve(velocity: number, mass: number, stiffness: number, damping: number): ICurve; + /** + * Constructs a spring curve when called. + * @since 7 + * @deprecated since 9 + */ + function spring(velocity: number, mass: number, stiffness: number, damping: number): string; +} +export default curves; diff --git a/build-tools/api/@ohos.data.DataShareResultSet.d.ts b/build-tools/api/@ohos.data.DataShareResultSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..448f54fcb479a51a974f7daf805816e18160e9ea --- /dev/null +++ b/build-tools/api/@ohos.data.DataShareResultSet.d.ts @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Indicates the {@code DataType}. + * + *

{@code DataType} is obtained based on the value. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ +export enum DataType { + /** + * Indicates that the data type is null. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + TYPE_NULL = 0, + /** + * Indicates that the data type is long. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + TYPE_LONG = 1, + /** + * Indicates that the data type is double. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + TYPE_DOUBLE = 2, + /** + * Indicates that the data type is byte string. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * */ + TYPE_STRING = 3, + /** + * Indicates that the data type is blob. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * */ + TYPE_BLOB = 4 +} +/** + * Provides methods for accessing a datashare result set generated by querying the database. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ +export default interface DataShareResultSet { + /** + * Obtains the names of all columns or keys in a result set. + * + * @note The column or key names are returned as a string array, in which the strings are in the same order + * as the columns or keys in the result set. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + columnNames: Array; + /** + * Obtains the number of columns or keys in the result set. + * + * @note The returned number is equal to the length of the string array returned by the columnCount method. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + columnCount: number; + /** + * Obtains the number of rows in the result set. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + rowCount: number; + /** + * Checks whether the current result set is closed. + * + * If the result set is closed by calling the close method, true will be returned. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + isClosed: boolean; + /** + * Go to the first row of the result set. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is empty. + */ + goToFirstRow(): boolean; + /** + * Go to the last row of the result set. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is empty. + */ + goToLastRow(): boolean; + /** + * Go to the next row of the result set. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is already in the last row. + */ + goToNextRow(): boolean; + /** + * Go to the previous row of the result set. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is already in the first row. + */ + goToPreviousRow(): boolean; + /** + * Go to the specified row of the result set forwards or backwards by an offset relative to its current position. + * A positive offset indicates moving backwards, and a negative offset indicates moving forwards. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param offset Indicates the offset relative to the current position. + * @return Returns true if the result set is moved successfully and does not go beyond the range; + * returns false otherwise. + */ + goTo(offset: number): boolean; + /** + * Go to the specified row of the result set. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param position Indicates the index of the specified row, which starts from 1. + * @return Returns true if the result set is moved successfully; returns false otherwise. + */ + goToRow(position: number): boolean; + /** + * Obtains the value of the specified column or key in the current row as a byte array. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null or the specified column or key is not of the Blob type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the value of the specified column or key as a byte array. + */ + getBlob(columnIndex: number): Uint8Array; + /** + * Obtains the value of the specified column or key in the current row as string. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null or the specified column or key is not of the string type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the value of the specified column or key as a string. + */ + getString(columnIndex: number): string; + /** + * Obtains the value of the specified column or key in the current row as long. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null, the specified column or key is not of the long type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the value of the specified column or key as a long. + */ + getLong(columnIndex: number): number; + /** + * Obtains the value of the specified column or key in the current row as double. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null, the specified column or key is not of the double type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the value of the specified column or key as a double. + */ + getDouble(columnIndex: number): number; + /** + * Closes the result set. + * + * @note Calling this method on the result set will release all of its resources and makes it ineffective. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns true if the result set is closed; returns false otherwise. + */ + close(): void; + /** + * Obtains the column index or key index based on the specified column name or key name. + * + * @note The column name or key name is passed as an input parameter. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnName Indicates the name of the specified column or key in the result set. + * @return Returns the index of the specified column or key. + */ + getColumnIndex(columnName: string): number; + /** + * Obtains the column name or key name based on the specified column index or key index. + * + * @note The column index or key index is passed as an input parameter. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnIndex Indicates the index of the specified column or key in the result set. + * @return Returns the name of the specified column or key. + */ + getColumnName(columnIndex: number): string; + /** + * Obtains the dataType of the specified column or key. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null, the specified column or key is not in the data type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the dataType of the specified column or key. + */ + getDataType(columnIndex: number): DataType; +} diff --git a/build-tools/api/@ohos.data.ValuesBucket.d.ts b/build-tools/api/@ohos.data.ValuesBucket.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fb1db8556afaa0f684ca019df7bec80326350ddb --- /dev/null +++ b/build-tools/api/@ohos.data.ValuesBucket.d.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Indicates possible value types + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ +export type ValueType = number | string | boolean; +/** + * Values in buckets are stored in key-value pairs + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ +export type ValuesBucket = { + [key: string]: ValueType | Uint8Array | null; +}; diff --git a/build-tools/api/@ohos.data.dataAbility.d.ts b/build-tools/api/@ohos.data.dataAbility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..264530c4a2e81b88e16c8837fea096907b932a6f --- /dev/null +++ b/build-tools/api/@ohos.data.dataAbility.d.ts @@ -0,0 +1,360 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import rdb from './@ohos.data.rdb'; +/** + * Provides predicates for implementing diverse query methods. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import import data_dataAbility from '@ohos.data.dataAbility'; + */ +declare namespace dataAbility { + /** + * Create an RdbPredicates by table name and DataAbilityPredicates. + * + * @note This method is similar to = of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param name Indicates the table name. + * @param dataAbilityPredicates Indicates the dataAbility predicates. + * @return Returns an RdbPredicates. + */ + function createRdbPredicates(name: string, dataAbilityPredicates: DataAbilityPredicates): rdb.RdbPredicates; + /** + * Manages relational database configurations. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import import data_dataAbility from '@ohos.data.dataAbility'; + */ + class DataAbilityPredicates { + /** + * Configures the DataAbilityPredicates to match the field whose data type is ValueType and value is equal + * to a specified value. + * + * @note This method is similar to = of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataAbilityPredicates. + * @return Returns the DataAbilityPredicates that match the specified field. + */ + equalTo(field: string, value: ValueType): DataAbilityPredicates; + /** + * Configures the DataAbilityPredicates to match the field whose data type is ValueType and value is unequal to + * a specified value. + * + * @note This method is similar to != of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataAbilityPredicates. + * @return Returns the DataAbilityPredicates that match the specified field. + */ + notEqualTo(field: string, value: ValueType): DataAbilityPredicates; + /** + * Adds a left parenthesis to the DataAbilityPredicates. + * + * @note This method is similar to ( of the SQL statement and needs to be used together with endWrap(). + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataAbilityPredicates with the left parenthesis. + */ + beginWrap(): DataAbilityPredicates; + /** + * Adds a right parenthesis to the DataAbilityPredicates. + * + * @note This method is similar to ) of the SQL statement and needs to be used together + * with beginWrap(). + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataAbilityPredicates with the right parenthesis. + */ + endWrap(): DataAbilityPredicates; + /** + * Adds an or condition to the DataAbilityPredicates. + * + * @note This method is similar to or of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataAbilityPredicates with the or condition. + */ + or(): DataAbilityPredicates; + /** + * Adds an and condition to the DataAbilityPredicates. + * + * @note This method is similar to and of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataAbilityPredicates with the and condition. + */ + and(): DataAbilityPredicates; + /** + * Configures the DataAbilityPredicates to match the field whose data type is string and value + * contains a specified value. + * + * @note This method is similar to contains of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataAbilityPredicates. + * @return Returns the DataAbilityPredicates that match the specified field. + */ + contains(field: string, value: string): DataAbilityPredicates; + /** + * Configures the DataAbilityPredicates to match the field whose data type is string and value starts + * with a specified string. + * + * @note This method is similar to value% of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataAbilityPredicates. + * @return Returns the DataAbilityPredicates that match the specified field. + */ + beginsWith(field: string, value: string): DataAbilityPredicates; + /** + * Configures the DataAbilityPredicates to match the field whose data type is string and value + * ends with a specified string. + * + * @note This method is similar to %value of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataAbilityPredicates. + * @return Returns the DataAbilityPredicates that match the specified field. + */ + endsWith(field: string, value: string): DataAbilityPredicates; + /** + * Configures the DataAbilityPredicates to match the fields whose value is null. + * + * @note This method is similar to is null of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @return Returns the DataAbilityPredicates that match the specified field. + */ + isNull(field: string): DataAbilityPredicates; + /** + * Configures the DataAbilityPredicates to match the specified fields whose value is not null. + * + * @note This method is similar to is not null of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @return Returns the DataAbilityPredicates that match the specified field. + */ + isNotNull(field: string): DataAbilityPredicates; + /** + * Configures the DataAbilityPredicates to match the fields whose data type is string and value is + * similar to a specified string. + * + * @note This method is similar to like of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataAbilityPredicates. The percent sign (%) in the value + * is a wildcard (like * in a regular expression). + * @return Returns the DataAbilityPredicates that match the specified field. + */ + like(field: string, value: string): DataAbilityPredicates; + /** + * Configures DataAbilityPredicates to match the specified field whose data type is string and the value contains + * a wildcard. + * + * @note Different from like, the input parameters of this method are case-sensitive. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with DataAbilityPredicates. + * @return Returns the SQL statement with the specified DataAbilityPredicates. + */ + glob(field: string, value: string): DataAbilityPredicates; + /** + * Restricts the value of the field to the range between low value and high value. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param low Indicates the minimum value. + * @param high Indicates the maximum value. + * @return Returns the SQL query statement with the specified DataAbilityPredicates. + */ + between(field: string, low: ValueType, high: ValueType): DataAbilityPredicates; + /** + * Configures DataAbilityPredicates to match the specified field whose data type is int and value is + * out of a given range. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param low Indicates the minimum value to match with DataAbilityPredicates}. + * @param high Indicates the maximum value to match with DataAbilityPredicates}. + * @return Returns the SQL query statement with the specified DataAbilityPredicates. + */ + notBetween(field: string, low: ValueType, high: ValueType): DataAbilityPredicates; + /** + * Restricts the value of the field to be greater than the specified value. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataAbilityPredicates. + */ + greaterThan(field: string, value: ValueType): DataAbilityPredicates; + /** + * Restricts the value of the field to be smaller than the specified value. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataAbilityPredicates. + */ + lessThan(field: string, value: ValueType): DataAbilityPredicates; + /** + * Restricts the value of the field to be greater than or equal to the specified value. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataAbilityPredicates. + */ + greaterThanOrEqualTo(field: string, value: ValueType): DataAbilityPredicates; + /** + * Restricts the value of the field to be smaller than or equal to the specified value. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataAbilityPredicates. + */ + lessThanOrEqualTo(field: string, value: ValueType): DataAbilityPredicates; + /** + * Restricts the ascending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name for sorting the return list. + * @return Returns the SQL query statement with the specified DataAbilityPredicates. + */ + orderByAsc(field: string): DataAbilityPredicates; + /** + * Restricts the descending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name for sorting the return list. + * @return Returns the SQL query statement with the specified DataAbilityPredicates. + */ + orderByDesc(field: string): DataAbilityPredicates; + /** + * Restricts each row of the query result to be unique. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the SQL query statement with the specified DataAbilityPredicates. + */ + distinct(): DataAbilityPredicates; + /** + * Restricts the max number of return records. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param value Indicates the max length of the return list. + * @return Returns the SQL query statement with the specified DataAbilityPredicates. + * @throws IllegalPredicateException Throws this exception if DataAbilityPredicates are added to a wrong position. + */ + limitAs(value: number): DataAbilityPredicates; + /** + * Configures DataAbilityPredicates to specify the start position of the returned result. + * + * @note Use this method together with limit(int). + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param rowOffset Indicates the start position of the returned result. The value is a positive integer. + * @return Returns the SQL query statement with the specified AbsPredicates. + */ + offsetAs(rowOffset: number): DataAbilityPredicates; + /** + * Configures DataAbilityPredicates to group query results by specified columns. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param fields Indicates the specified columns by which query results are grouped. + * @return Returns the DataAbilityPredicates with the specified columns by which query results are grouped. + */ + groupBy(fields: Array): DataAbilityPredicates; + /** + * Configures DataAbilityPredicates to specify the index column. + * + * @note Before using this method, you need to create an index column. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param indexName Indicates the name of the index column. + * @return Returns DataAbilityPredicates with the specified index column. + */ + indexedBy(field: string): DataAbilityPredicates; + /** + * Configures DataAbilityPredicates to match the specified field whose data type is ValueType array and values + * are within a given range. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param values Indicates the values to match with DataAbilityPredicates. + * @return Returns DataAbilityPredicates that matches the specified field. + */ + in(field: string, value: Array): DataAbilityPredicates; + /** + * Configures {@code DataAbilityPredicates} to match the specified field whose data type is String array and values + * are out of a given range. + * + * @note N/A + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param values Indicates the values to match with DataAbilityPredicates. + * @return Returns DataAbilityPredicates that matches the specified field. + */ + notIn(field: string, value: Array): DataAbilityPredicates; + } + /** + * Indicates possible value types + * @since 7 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import import data_rdb from '@ohos.data.rdb'; + */ + type ValueType = number | string | boolean; +} +export default dataAbility; diff --git a/build-tools/api/@ohos.data.dataShare.d.ts b/build-tools/api/@ohos.data.dataShare.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8e02ea840157579dc56fd994d4a2428525e1d06f --- /dev/null +++ b/build-tools/api/@ohos.data.dataShare.d.ts @@ -0,0 +1,202 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback } from './basic'; +import Context from './application/Context'; +import DataShareResultSet from './@ohos.data.DataShareResultSet'; +import dataSharePredicates from './@ohos.data.dataSharePredicates'; +import { ValuesBucket } from './@ohos.data.ValuesBucket'; +declare namespace dataShare { + /** + * Obtains the dataShareHelper. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param context Indicates the application context. + * @param uri Indicates the path of the file to open. + * @return Returns the dataShareHelper. + */ + function createDataShareHelper(context: Context, uri: string, callback: AsyncCallback): void; + function createDataShareHelper(context: Context, uri: string): Promise; + /** + * DataShareHelper + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @StageModelOnly + */ + interface DataShareHelper { + /** + * Opens a file in a specified remote path. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the path of the file to open. + * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access + * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing + * file, "wa" for write-only access to append to any existing data, "rw" for read and write access on + * any existing data, or "rwt" for read and write access that truncates any existing file. + * @param callback Indicates the callback when openfile success + * @return Returns the file descriptor. + * @StageModelOnly + */ + openFile(uri: string, mode: string, callback: AsyncCallback): void; + openFile(uri: string, mode: string): Promise; + /** + * Registers an observer to observe data specified by the given uri. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param type dataChange. + * @param uri Indicates the path of the data to operate. + * @param callback Indicates the callback when dataChange. + * @return - + * @StageModelOnly + */ + on(type: 'dataChange', uri: string, callback: AsyncCallback): void; + /** + * Deregisters an observer used for monitoring data specified by the given uri. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param type dataChange. + * @param uri Indicates the path of the data to operate. + * @param callback Indicates the registered callback. + * @return - + * @StageModelOnly + */ + off(type: 'dataChange', uri: string, callback?: AsyncCallback): void; + /** + * Inserts a single data record into the database. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the path of the data to operate. + * @param value Indicates the data record to insert. If this parameter is null, a blank row will be inserted. + * @return Returns the index of the inserted data record. + * @StageModelOnly + */ + insert(uri: string, value: ValuesBucket, callback: AsyncCallback): void; + insert(uri: string, value: ValuesBucket): Promise; + /** + * Deletes one or more data records from the database. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the path of the data to operate. + * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. + * @return Returns the number of data records deleted. + * @StageModelOnly + */ + delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promise; + /** + * Queries data in the database. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the path of data to query. + * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. + * @param columns Indicates the columns to query. If this parameter is null, all columns are queried. + * @return Returns the query result. + * @StageModelOnly + */ + query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array, callback: AsyncCallback): void; + query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array): Promise; + /** + * Updates data records in the database. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the path of data to update. + * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. + * @param value Indicates the data to update. This parameter can be null. + * @return Returns the number of data records updated. + * @StageModelOnly + */ + update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket, callback: AsyncCallback): void; + update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket): Promise; + /** + * Inserts multiple data records into the database. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the path of the data to operate. + * @param values Indicates the data records to insert. + * @return Returns the number of data records inserted. + * @StageModelOnly + */ + batchInsert(uri: string, values: Array, callback: AsyncCallback): void; + batchInsert(uri: string, values: Array): Promise; + /** + * Obtains the MIME type of the date specified by the given uri. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the path of the data to operate. + * @return Returns the MIME type that matches the data specified by uri. + * @StageModelOnly + */ + getType(uri: string, callback: AsyncCallback): void; + getType(uri: string): Promise; + /** + * Obtains the MIME types of files supported. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the path of the files to obtain. + * @param mimeTypeFilter Indicates the MIME types of the files to obtain. This parameter cannot be null. + *

1. "*/*": Obtains all types supported by Data abilities. + *

2. "image/*": Obtains files whose main type is image of any subtype. + *

3. "*/jpg": Obtains files whose subtype is JPG of any main type. + * @return Returns the matched MIME types. If there is no match, {@code null} is returned. + * @StageModelOnly + */ + getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void; + getFileTypes(uri: string, mimeTypeFilter: string): Promise>; + /** + * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}. + * A normalized uri can be used across devices, persisted, backed up, and restored. + *

To transfer a normalized uri from another environment to the current environment, you should call this + * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)} + * to convert it to a denormalized uri that can be used only in the current environment. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the {@link ohos.utils.net.Uri} object to normalize. + * @return Returns the normalized {@code Uri} object if the DataShare supports uri normalization; + * returns {@code null} otherwise. + * @throws DataShareRemoteException Throws this exception if the remote process exits. + * @throws NullPointerException Throws this exception if {@code uri} is null. + * @see #denormalizeUri + * @StageModelOnly + */ + normalizeUri(uri: string, callback: AsyncCallback): void; + normalizeUri(uri: string): Promise; + /** + * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the {@link ohos.utils.net.Uri} object to denormalize. + * @return Returns the denormalized {@code Uri} object if the denormalization is successful; returns the + * original {@code Uri} passed to this method if there is nothing to do; returns {@code null} if the data + * identified by the normalized {@code Uri} cannot be found in the current environment. + * @throws DataShareRemoteException Throws this exception if the remote process exits. + * @throws NullPointerException Throws this exception if {@code uri} is null. + * @see #normalizeUri + * @StageModelOnly + */ + denormalizeUri(uri: string, callback: AsyncCallback): void; + denormalizeUri(uri: string): Promise; + /** + * Notifies the registered observers of a change to the data resource specified by Uri. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @param uri Indicates the {@link ohos.utils.net.Uri} object to notifyChange. + * @return - + * @StageModelOnly + */ + notifyChange(uri: string, callback: AsyncCallback): void; + notifyChange(uri: string): Promise; + } +} +export default dataShare; diff --git a/build-tools/api/@ohos.data.dataSharePredicates.d.ts b/build-tools/api/@ohos.data.dataSharePredicates.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..93ba31a88ff8a4c6877666da9576224621e9512d --- /dev/null +++ b/build-tools/api/@ohos.data.dataSharePredicates.d.ts @@ -0,0 +1,342 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ValueType } from './@ohos.data.ValuesBucket'; +declare namespace dataSharePredicates { + /** + * Manages relational database configurations. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import import data_dataShare from '@ohos.data.dataShare'; + */ + class DataSharePredicates { + /** + * Configures the DataSharePredicates to match the field whose data type is ValueType and value is equal + * to a specified value. + * + * @note This method is similar to = of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. + * @return Returns the DataSharePredicates that match the specified field. + */ + equalTo(field: string, value: ValueType): DataSharePredicates; + /** + * Configures the DataSharePredicates to match the field whose data type is ValueType and value is unequal to + * a specified value. + * + * @note This method is similar to != of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. + * @return Returns the DataSharePredicates that match the specified field. + */ + notEqualTo(field: string, value: ValueType): DataSharePredicates; + /** + * Adds a left parenthesis to the DataSharePredicates. + * + * @note This method is similar to ( of the SQL statement and needs to be used together with endWrap(). + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataSharePredicates with the left parenthesis. + */ + beginWrap(): DataSharePredicates; + /** + * Adds a right parenthesis to the DataSharePredicates. + * + * @note This method is similar to ) of the SQL statement and needs to be used together + * with beginWrap(). + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataSharePredicates with the right parenthesis. + */ + endWrap(): DataSharePredicates; + /** + * Adds an or condition to the DataSharePredicates. + * + * @note This method is similar to or of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataSharePredicates with the or condition. + */ + or(): DataSharePredicates; + /** + * Adds an and condition to the DataSharePredicates. + * + * @note This method is similar to and of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataSharePredicates with the and condition. + */ + and(): DataSharePredicates; + /** + * Configures the DataSharePredicates to match the field whose data type is string and value + * contains a specified value. + * + * @note This method is similar to contains of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. + * @return Returns the DataSharePredicates that match the specified field. + */ + contains(field: string, value: string): DataSharePredicates; + /** + * Configures the DataSharePredicates to match the field whose data type is string and value starts + * with a specified string. + * + * @note This method is similar to value% of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. + * @return Returns the DataSharePredicates that match the specified field. + */ + beginsWith(field: string, value: string): DataSharePredicates; + /** + * Configures the DataSharePredicates to match the field whose data type is string and value + * ends with a specified string. + * + * @note This method is similar to %value of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. + * @return Returns the DataSharePredicates that match the specified field. + */ + endsWith(field: string, value: string): DataSharePredicates; + /** + * Configures the DataSharePredicates to match the fields whose value is null. + * + * @note This method is similar to is null of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @return Returns the DataSharePredicates that match the specified field. + */ + isNull(field: string): DataSharePredicates; + /** + * Configures the DataSharePredicates to match the specified fields whose value is not null. + * + * @note This method is similar to is not null of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @return Returns the DataSharePredicates that match the specified field. + */ + isNotNull(field: string): DataSharePredicates; + /** + * Configures the DataSharePredicates to match the fields whose data type is string and value is + * similar to a specified string. + * + * @note This method is similar to like of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. The percent sign (%) in the value + * is a wildcard (like * in a regular expression). + * @return Returns the DataSharePredicates that match the specified field. + */ + like(field: string, value: string): DataSharePredicates; + /** + * Configures the DataSharePredicates to match the fields whose data type is string and value is + * similar to a specified string. + * + * @note This method is similar to unlike of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. The percent sign (%) in the value + * is a wildcard (like * in a regular expression). + * @return Returns the DataSharePredicates that match the specified field. + */ + unlike(field: string, value: string): DataSharePredicates; + /** + * Configures DataSharePredicates to match the specified field whose data type is string and the value contains + * a wildcard. + * + * @note Different from like, the input parameters of this method are case-sensitive. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with DataSharePredicates. + * @return Returns the SQL statement with the specified DataSharePredicates. + */ + glob(field: string, value: string): DataSharePredicates; + /** + * Restricts the value of the field to the range between low value and high value. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param low Indicates the minimum value. + * @param high Indicates the maximum value. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + between(field: string, low: ValueType, high: ValueType): DataSharePredicates; + /** + * Configures DataSharePredicates to match the specified field whose data type is int and value is + * out of a given range. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param low Indicates the minimum value to match with DataSharePredicates. + * @param high Indicates the maximum value to match with DataSharePredicates. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates; + /** + * Restricts the value of the field to be greater than the specified value. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + greaterThan(field: string, value: ValueType): DataSharePredicates; + /** + * Restricts the value of the field to be smaller than the specified value. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + lessThan(field: string, value: ValueType): DataSharePredicates; + /** + * Restricts the value of the field to be greater than or equal to the specified value. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates; + /** + * Restricts the value of the field to be smaller than or equal to the specified value. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates; + /** + * Restricts the ascending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name for sorting the return list. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + orderByAsc(field: string): DataSharePredicates; + /** + * Restricts the descending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name for sorting the return list. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + orderByDesc(field: string): DataSharePredicates; + /** + * Restricts each row of the query result to be unique. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + distinct(): DataSharePredicates; + /** + * Construct a query object to specify the number of results and the starting position. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param total Represents the specified number of results. + * @param offset Indicates the starting position. + * @return Returns the query object. + */ + limit(total: number, offset: number): DataSharePredicates; + /** + * Configures {@code DataSharePredicates} to group query results by specified columns. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param fields Indicates the specified columns by which query results are grouped. + * @return Returns the DataSharePredicates with the specified columns by which query results are grouped. + */ + groupBy(fields: Array): DataSharePredicates; + /** + * Configures {@code DataSharePredicates} to specify the index column. + * + * @note Before using this method, you need to create an index column. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the name of the index column. + * @return Returns DataSharePredicates with the specified index column. + */ + indexedBy(field: string): DataSharePredicates; + /** + * Configures {@code DataSharePredicates} to match the specified field whose data type is ValueType array and values + * are within a given range. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param values Indicates the values to match with DataSharePredicates. + * @return Returns DataSharePredicates that matches the specified field. + */ + in(field: string, value: Array): DataSharePredicates; + /** + * Configures {@code DataSharePredicates} to match the specified field whose data type is String array and values + * are out of a given range. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param values Indicates the values to match with DataSharePredicates. + * @return Returns DataSharePredicates that matches the specified field. + */ + notIn(field: string, value: Array): DataSharePredicates; + /** + * Configures {@code DataSharePredicates} Creates a query condition using the specified key prefix. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param prefix Represents the specified key prefix. + * @return Returns the query object. + */ + prefixKey(prefix: string): DataSharePredicates; + /** + * Configures {@code DataSharePredicates} to match the specified value whose key is within a given range. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param keys Represents the key names. + * @return Returns the query object. + */ + inKeys(keys: Array): DataSharePredicates; + } +} +export default dataSharePredicates; diff --git a/build-tools/api/@ohos.data.distributedData.d.ts b/build-tools/api/@ohos.data.distributedData.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..abc8c88f404569a36f2ad61401d788997d53fc6b --- /dev/null +++ b/build-tools/api/@ohos.data.distributedData.d.ts @@ -0,0 +1,1837 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from './basic'; +import { ValuesBucket } from './@ohos.data.ValuesBucket'; +import dataSharePredicates from './@ohos.data.dataSharePredicates'; +import Context from './application/Context'; +/** + * Providers interfaces to creat a {@link KVManager} istances. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @import N/A + */ +declare namespace distributedData { + /** + * Provides configuration information for {@link KVManager} instances, + * including the caller's package name and distributed network type. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + interface KVManagerConfig { + /** + * Indicates the user information + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + userInfo: UserInfo; + /** + * Indicates the bundleName + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + bundleName: string; + /** + * Indicates the ability or hap context + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @Note: if swap the area, you should close all the KV store and use the new Context to create the KVManager + * @StageModelOnly + */ + context: Context; + } + /** + * Manages user information. + * + *

This class provides methods for obtaining the user ID and type, setting the user ID and type, + * and checking whether two users are the same. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + interface UserInfo { + /** + * Indicates the user ID to set + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + userId?: string; + /** + * Indicates the user type to set + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + userType?: UserType; + } + /** + * Enumerates user types. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + enum UserType { + /** + * Indicates a user that logs in to different devices using the same account. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + SAME_USER_ID = 0 + } + /** + * KVStore constants + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + namespace Constants { + /** + * max key length. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + const MAX_KEY_LENGTH = 1024; + /** + * max value length. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + const MAX_VALUE_LENGTH = 4194303; + /** + * max device coordinate key length. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + const MAX_KEY_LENGTH_DEVICE = 896; + /** + * max store id length. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + const MAX_STORE_ID_LENGTH = 128; + /** + * max query length. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + const MAX_QUERY_LENGTH = 512000; + /** + * max batch operation size. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + const MAX_BATCH_SIZE = 128; + } + /** + * Indicates the {@code ValueType}. + * + *

{@code ValueType} is obtained based on the value. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + enum ValueType { + /** + * Indicates that the value type is string. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + STRING = 0, + /** + * Indicates that the value type is int. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + INTEGER = 1, + /** + * Indicates that the value type is float. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + FLOAT = 2, + /** + * Indicates that the value type is byte array. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * */ + BYTE_ARRAY = 3, + /** + * Indicates that the value type is boolean. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * */ + BOOLEAN = 4, + /** + * Indicates that the value type is double. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + DOUBLE = 5 + } + /** + * Obtains {@code Value} objects stored in a {@link KVStore} database. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + interface Value { + /** + * Indicates value type + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @see ValueType + * @type {number} + * @memberof Value + */ + type: ValueType; + /** + * Indicates value + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + value: Uint8Array | string | number | boolean; + } + /** + * Provides key-value pairs stored in the distributed database. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + interface Entry { + /** + * Indicates key + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + key: string; + /** + * Indicates value + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + value: Value; + } + /** + * Receives notifications of all data changes, including data insertion, update, and deletion. + * + *

If you have subscribed to {@code KVStore}, you will receive data change notifications and obtain the changed data + * from the parameters in callback methods upon data insertion, update, or deletion. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + interface ChangeNotification { + /** + * Indicates data addition records. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + insertEntries: Entry[]; + /** + * Indicates data update records. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + updateEntries: Entry[]; + /** + * Indicates data deletion records. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + deleteEntries: Entry[]; + /** + * Indicates from device id. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + deviceId: string; + } + /** + * Indicates the database synchronization mode. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + enum SyncMode { + /** + * Indicates that data is only pulled from the remote end. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + PULL_ONLY = 0, + /** + * Indicates that data is only pushed from the local end. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + PUSH_ONLY = 1, + /** + * Indicates that data is pushed from the local end, and then pulled from the remote end. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + PUSH_PULL = 2 + } + /** + * Describes the subscription type. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + enum SubscribeType { + /** + * Subscription to local data changes + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + SUBSCRIBE_TYPE_LOCAL = 0, + /** + * Subscription to remote data changes + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + SUBSCRIBE_TYPE_REMOTE = 1, + /** + * Subscription to both local and remote data changes + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + SUBSCRIBE_TYPE_ALL = 2 + } + /** + * Describes the {@code KVStore} type. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + enum KVStoreType { + /** + * Device-collaborated database, as specified by {@code DeviceKVStore} + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @import N/A + */ + DEVICE_COLLABORATION = 0, + /** + * Single-version database, as specified by {@code SingleKVStore} + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + SINGLE_VERSION = 1, + /** + * Multi-version database, as specified by {@code MultiKVStore} + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @import N/A + */ + MULTI_VERSION = 2 + } + /** + * Describes the {@code KVStore} type. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + enum SecurityLevel { + /** + * NO_LEVEL: mains not set the security level. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @import N/A + */ + NO_LEVEL = 0, + /** + * S0: mains the db is public. + * There is no impact even if the data is leaked. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + S0 = 1, + /** + * S1: mains the db is low level security + * There are some low impact, when the data is leaked. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + S1 = 2, + /** + * S2: mains the db is middle level security + * There are some major impact, when the data is leaked. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + S2 = 3, + /** + * S3: mains the db is high level security + * There are some severity impact, when the data is leaked. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + S3 = 5, + /** + * S4: mains the db is critical level security + * There are some critical impact, when the data is leaked. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + S4 = 6 + } + /** + * Provides configuration options for creating a {@code KVStore}. + * + *

You can determine whether to create another database if a {@code KVStore} database is missing, + * whether to encrypt the database, and the database type. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + interface Options { + /** + * Indicates whether to createa database when the database file does not exist + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + createIfMissing?: boolean; + /** + * Indicates setting whether database files are encrypted + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + encrypt?: boolean; + /** + * Indicates setting whether to back up database files + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + backup?: boolean; + /** + * Indicates setting whether database files are automatically synchronized + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @import N/A + */ + autoSync?: boolean; + /** + * Indicates setting the databse type + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + kvStoreType?: KVStoreType; + /** + * Indicates setting the database security level + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + securityLevel?: SecurityLevel; + /** + * Indicates schema object + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @import N/A + */ + schema?: Schema; + } + /** + * Represents the database schema. + * + * You can create Schema objects and put them in Options when creating or opening the database. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @import N/A + */ + class Schema { + /** + * A constructor used to create a Schema instance. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + */ + constructor(); + /** + * Indicates the root json object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + */ + root: FieldNode; + /** + * Indicates the string array of json. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + */ + indexes: Array; + /** + * Indicates the mode of schema. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + */ + mode: number; + /** + * Indicates the skipsize of schema. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + */ + skip: number; + } + /** + * Represents a node of a {@link Schema} instance. + * + *

Through the {@link Schema} instance, you can define the fields contained in the values stored in a database. + * + *

A FieldNode of the {@link Schema} instance is either a leaf or a non-leaf node. + * + *

The leaf node must have a value; the non-leaf node must have a child {@code FieldNode}. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @import N/A + */ + class FieldNode { + /** + * A constructor used to create a FieldNode instance with the specified field. + * name Indicates the field node name. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + */ + constructor(name: string); + /** + * Adds a child node to this {@code FieldNode}. + * + *

Adding a child node makes this node a non-leaf node. Field value will be ignored if it has child node. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param child The field node to append. + * @returns Returns true if the child node is successfully added to this {@code FieldNode}; returns false otherwise. + */ + appendChild(child: FieldNode): boolean; + /** + * Indicates the default value of fieldnode. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + */ + default: string; + /** + * Indicates the nullable of database field. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + */ + nullable: boolean; + /** + * Indicates the type of value. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + */ + type: number; + } + /** + * Provide methods to obtain the result set of the {@code KvStore} database. + * + *

The result set is created by using the {@code getResultSet} method in the {@code DeviceKVStore} class. This interface also provides + * methods for moving the data read position in the result set. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + interface KvStoreResultSet { + /** + * Obtains the number of lines in a result set. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns the number of lines. + */ + getCount(): number; + /** + * Obtains the current read position in a result set. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns the current read position. The read position starts with 0. + */ + getPosition(): number; + /** + * Moves the read position to the first line. + * + *

If the result set is empty, false is returned. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns true if the operation succeeds; return false otherwise. + */ + moveToFirst(): boolean; + /** + * Moves the read position to the last line. + * + *

If the result set is empty, false is returned. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns true if the operation succeeds; return false otherwise. + */ + moveToLast(): boolean; + /** + * Moves the read position to the next line. + * + *

If the result set is empty or the data in the last line is being read, false is returned. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns true if the operation succeeds; return false otherwise. + */ + moveToNext(): boolean; + /** + * Moves the read position to the previous line. + * + *

If the result set is empty or the data in the first line is being read, false is returned. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns true if the operation succeeds; return false otherwise. + */ + moveToPrevious(): boolean; + /** + * Moves the read position by a relative offset to the current position. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param offset Indicates the relative offset to the current position. Anegative offset indicates moving backwards, and a + * positive offset indicates moving forewards. Forexample, if the current position is entry 1 and thisoffset is 2, + * the destination position will be entry 3; ifthe current position is entry 3 and this offset is -2, + * the destination position will be entry 1. The valid final position after moving forwards starts with 0. If the + * final position is invalid, false will be returned. + * @returns Returns true if the operation succeeds; return false otherwise. + */ + move(offset: number): boolean; + /** + * Moves the read position from 0 to an absolute position. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param position Indicates the absolute position. + * @returns Returns true if the operation succeeds; return false otherwise. + */ + moveToPosition(position: number): boolean; + /** + * Checks whether the read position is the first line. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + + * @returns Returns true if the read position is the first line; returns false otherwise. + */ + isFirst(): boolean; + /** + * Checks whether the read position is the last line. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns true if the read position is the last line; returns false otherwise. + */ + isLast(): boolean; + /** + * Checks whether the read position is before the last line. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns true if the read position is before the first line; returns false otherwise. + */ + isBeforeFirst(): boolean; + /** + * Checks whether the read position is after the last line. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns true if the read position is after the last line; returns false otherwise. + */ + isAfterLast(): boolean; + /** + * Obtains a key-value pair. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns a key-value pair. + */ + getEntry(): Entry; + } + /** + * Represents a database query using a predicate. + * + *

This class provides a constructor used to create a {@code Query} instance, which is used to query data matching specified + * conditions in the database. + * + *

This class also provides methods for adding predicates to the {@code Query} instance. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + class Query { + /** + * A constructor used to create a Query instance. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + */ + constructor(); + /** + * Resets this {@code Query} object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @returns Returns the reset {@code Query} object. + */ + reset(): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is equal to the specified long value. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param value IIndicates the long value. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + equalTo(field: string, value: number | string | boolean): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is not equal to the specified int value. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param value Indicates the int value. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + notEqualTo(field: string, value: number | string | boolean): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is greater than or equal to the + * specified int value. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param value Indicates the int value. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + greaterThan(field: string, value: number | string | boolean): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is less than the specified int value. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param value Indicates the int value. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + lessThan(field: string, value: number | string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is greater than or equal to the + * specified int value. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param value Indicates the int value. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + greaterThanOrEqualTo(field: string, value: number | string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is less than or equal to the + * specified int value. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param value Indicates the int value. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + lessThanOrEqualTo(field: string, value: number | string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is null. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + isNull(field: string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is within the specified int value list. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param valueList Indicates the int value list. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + inNumber(field: string, valueList: number[]): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is within the specified string value list. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param valueList Indicates the string value list. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + inString(field: string, valueList: string[]): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is not within the specified int value list. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param valueList Indicates the int value list. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + notInNumber(field: string, valueList: number[]): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is not within the specified string value list. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param valueList Indicates the string value list. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + notInString(field: string, valueList: string[]): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is similar to the specified string value. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param value Indicates the string value. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + like(field: string, value: string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is not similar to the specified string value. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @param value Indicates the string value. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + unlike(field: string, value: string): Query; + /** + * Constructs a {@code Query} object with the and condition. + * + *

Multiple predicates should be connected using the and or or condition. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @returns Returns the {@coed Query} object. + */ + and(): Query; + /** + * Constructs a {@code Query} object with the or condition. + * + *

Multiple predicates should be connected using the and or or condition. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @returns Returns the {@coed Query} object. + */ + or(): Query; + /** + * Constructs a {@code Query} object to sort the query results in ascending order. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + orderByAsc(field: string): Query; + /** + * Constructs a {@code Query} object to sort the query results in descending order. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the field, which must start with $. and cannot contain ^. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + orderByDesc(field: string): Query; + /** + * Constructs a {@code Query} object to specify the number of results and the start position. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param total Indicates the number of results. + * @param offset Indicates the start position. + * @returns Returns the {@coed Query} object. + */ + limit(total: number, offset: number): Query; + /** + * Creates a {@code query} condition with a specified field that is not null. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param field Indicates the specified field. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + isNotNull(field: string): Query; + /** + * Creates a query condition group with a left bracket. + * + *

Multiple query conditions in an {@code Query} object can be grouped. The query conditions in a group can be used as a + * whole to combine with other query conditions. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @returns Returns the {@coed Query} object. + */ + beginGroup(): Query; + /** + * Creates a query condition group with a right bracket. + * + *

Multiple query conditions in an {@code Query} object can be grouped. The query conditions in a group can be used as a + * whole to combine with other query conditions. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @returns Returns the {@coed Query} object. + */ + endGroup(): Query; + /** + * Creates a query condition with a specified key prefix. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param prefix Indicates the specified key prefix. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + prefixKey(prefix: string): Query; + /** + * Sets a specified index that will be preferentially used for query. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param index Indicates the index to set. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + */ + setSuggestIndex(index: string): Query; + /** + * Add device ID key prefix.Used by {@code DeviceKVStore}. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param deviceId Specify device id to query from. + * @return Returns the {@code Query} object with device ID prefix added. + * @throw Throws this exception if input is invalid. + */ + deviceId(deviceId: string): Query; + /** + * Get a String that repreaents this {@code Query}. + * + *

The String would be parsed to DB query format. + * The String length should be no longer than 500kb. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @return String representing this {@code Query}. + */ + getSqlLike(): string; + } + /** + * Represents a key-value distributed database and provides methods for adding, deleting, modifying, querying, + * and subscribing to distributed data. + * + *

You can create distributed databases of different types by {@link KVManager#getKVStore (Options, String)} + * with input parameter {@code Options}. Distributed database types are defined in {@code KVStoreType}, + * including {@code SingleKVStore}. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @version 1 + */ + interface KVStore { + /** + * Writes a key-value pair of the string type into the {@code KvStore} database. + * + *

If you do not want to synchronize this key-value pair to other devices, set the write option in the local database. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param key Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @param value Indicates the string value, which must be less than 4 MB as a UTF-8 byte array. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and + * {@code DB_ERROR}. + */ + put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback): void; + put(key: string, value: Uint8Array | string | number | boolean): Promise; + /** + * Writes a value of the valuesbucket type into the {@code KvStore} database. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param value Indicates the data record to put. + * Spaces before and after the key will be cleared. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and + * {@code DB_ERROR}. + */ + putBatch(value: Array, callback: AsyncCallback): void; + putBatch(value: Array): Promise; + /** + * Deletes the key-value pair based on a specified key. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param key Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and + * {@code DB_ERROR}, and {@code KEY_NOT_FOUND}. + */ + delete(key: string, callback: AsyncCallback): void; + delete(key: string): Promise; + /** + * Deletes the key-value pair based on a specified key. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param predicates Indicates the datasharePredicates. + * Spaces before and after the key will be cleared. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and + * {@code DB_ERROR}. + */ + delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback); + delete(predicates: dataSharePredicates.DataSharePredicates): Promise; + /** + * Registers a {@code KvStoreObserver} for the database. When data in the distributed database changes, the callback in + * {@code KvStoreObserver} will be invoked. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param type Indicates the subscription type, which is defined in {@code SubscribeType}. + * @param listener Indicates the observer of data change events in the distributed database. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, + * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + */ + on(event: 'dataChange', type: SubscribeType, listener: Callback): void; + /** + * Subscribes from the {@code KvStore} database based on the specified subscribeType and {@code KvStoreObserver}. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, + * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + */ + on(event: 'syncComplete', syncCallback: Callback>): void; + /** + * Unsubscribes from the {@code KvStore} database based on the specified subscribeType and {@code KvStoreObserver}. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param listener Indicates the data change observer registered by {#subscribe(SubscribeType, KvStoreObserver)}. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, + * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + */ + off(event: 'dataChange', listener?: Callback): void; + /** + * UnRegister Synchronizes {@code KvStore} database callback. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param syncCallback Indicates the callback used to send the synchronization result to caller. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, + * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + */ + off(event: 'syncComplete', syncCallback?: Callback>): void; + /** + * Inserts key-value pairs into the {@code KvStore} database in batches. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param entries Indicates the key-value pairs to be inserted in batches. + * @throws Throws this exception if a database error occurs. + */ + putBatch(entries: Entry[], callback: AsyncCallback): void; + putBatch(entries: Entry[]): Promise; + /** + * Deletes key-value pairs in batches from the {@code KvStore} database. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param keys Indicates the key-value pairs to be deleted in batches. + * @throws Throws this exception if a database error occurs. + */ + deleteBatch(keys: string[], callback: AsyncCallback): void; + deleteBatch(keys: string[]): Promise; + /** + * Starts a transaction operation in the {@code KvStore} database. + * + *

After the database transaction is started, you can submit or roll back the operation. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @throws Throws this exception if a database error occurs. + */ + startTransaction(callback: AsyncCallback): void; + startTransaction(): Promise; + /** + * Submits a transaction operation in the {@code KvStore} database. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param callback + * @throws Throws this exception if a database error occurs. + */ + commit(callback: AsyncCallback): void; + commit(): Promise; + /** + * Rolls back a transaction operation in the {@code KvStore} database. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @throws Throws this exception if a database error occurs. + */ + rollback(callback: AsyncCallback): void; + rollback(): Promise; + /** + * Sets whether to enable synchronization. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param enabled Specifies whether to enable synchronization. The value true means to enable + * synchronization, and false means the opposite. + * @throws Throws this exception if an internal service error occurs. + */ + enableSync(enabled: boolean, callback: AsyncCallback): void; + enableSync(enabled: boolean): Promise; + /** + * Sets synchronization range labels. + * + *

The labels determine the devices with which data will be synchronized. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param localLabels Indicates the synchronization labels of the local device. + * @param remoteSupportLabels Indicates the labels of the devices with which data will be synchronized. + * @throws Throws this exception if an internal service error occurs. + */ + setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback): void; + setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise; + } + /** + * Provides methods related to single-version distributed databases. + * + *

To create a {@code SingleKVStore} database, + * you can use the {@link data.distributed.common.KVManager#getKVStore​(Options, String)} method + * with {@code KVStoreType} set to {@code SINGLE_VERSION} for the input parameter {@code Options}. + * This database synchronizes data to other databases in time sequence. + * The {@code SingleKVStore} database does not support + * synchronous transactions, or data search using snapshots. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @version 1 + */ + interface SingleKVStore extends KVStore { + /** + * Obtains the {@code String} value of a specified key. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param key Indicates the key of the boolean value to be queried. + * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}, and {@code KEY_NOT_FOUND}. + */ + get(key: string, callback: AsyncCallback): void; + get(key: string): Promise; + /** + * Obtains all key-value pairs that match a specified key prefix. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param keyPrefix Indicates the key prefix to match. + * @returns Returns the list of all key-value pairs that match the specified key prefix. + * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + */ + getEntries(keyPrefix: string, callback: AsyncCallback): void; + getEntries(keyPrefix: string): Promise; + /** + * Obtains the list of key-value pairs matching the specified {@code Query} object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param query Indicates the {@code Query} object. + * @returns Returns the list of key-value pairs matching the specified {@code Query} object. + * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + */ + getEntries(query: Query, callback: AsyncCallback): void; + getEntries(query: Query): Promise; + /** + * Obtains the result sets with a specified prefix from a {@code KvStore} database. The {@code KvStoreResultSet} object can be used to + * query all key-value pairs that meet the search criteria. Each {@code KvStore} instance can have a maximum of four + * {@code KvStoreResultSet} objects at the same time. If you have created four objects, calling this method will return a + * failure. Therefore, you are advised to call the closeResultSet method to close unnecessary {@code KvStoreResultSet} objects + * in a timely manner. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param keyPrefix Indicates the key prefix to match. + * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + */ + getResultSet(keyPrefix: string, callback: AsyncCallback): void; + getResultSet(keyPrefix: string): Promise; + /** + * Obtains the {@code KvStoreResultSet} object matching the specified {@code Query} object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param query Indicates the {@code Query} object. + * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + */ + getResultSet(query: Query, callback: AsyncCallback): void; + getResultSet(query: Query): Promise; + /** + * Obtains the KvStoreResultSet object matching the specified Predicate object. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param predicates Indicates the datasharePredicates. + * Spaces before and after the key will be cleared. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and + * {@code DB_ERROR}. + */ + getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise; + /** + * Closes a {@code KvStoreResultSet} object returned by getResultSet. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param resultSet Indicates the {@code KvStoreResultSet} object to close. + * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + */ + closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback): void; + closeResultSet(resultSet: KvStoreResultSet): Promise; + /** + * Obtains the number of results matching the specified {@code Query} object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @param query Indicates the {@code Query} object. + * @returns Returns the number of results matching the specified {@code Query} object. + * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + */ + getResultSize(query: Query, callback: AsyncCallback): void; + getResultSize(query: Query): Promise; + /** + * void removeDeviceData​({@link String} deviceId) throws {@link KvStoreException} + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + */ + removeDeviceData(deviceId: string, callback: AsyncCallback): void; + removeDeviceData(deviceId: string): Promise; + /** + * Synchronizes the database to the specified devices with the specified delay allowed. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param deviceIds Indicates the list of devices to which to synchronize the database. + * @param mode Indicates the synchronization mode. The value can be {@code PUSH}, {@code PULL}, or {@code PUSH_PULL}. + * @param delayMs Indicates the delay allowed for the synchronization, in milliseconds. + * @throws Throws this exception if any of the following errors + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + */ + sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void; + /** + * Synchronizes the database to the specified devices with the specified delay allowed. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param deviceIds Indicates the list of devices to which to synchronize the database. + * @param mode Indicates the synchronization mode. The value can be {@code PUSH}, {@code PULL}, or {@code PUSH_PULL}. + * @param delayMs Indicates the delay allowed for the synchronization, in milliseconds. + * @param query Indicates the {@code Query} object. + * @throws Throws this exception if any of the following errors + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + */ + sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void; + /** + * Registers a {@code KvStoreObserver} for the database. When data in the distributed database changes, the callback in + * {@code KvStoreObserver} will be invoked. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param type Indicates the subscription type, which is defined in {@code SubscribeType}. + * @param listener Indicates the observer of data change events in the distributed database. + * @throws Throws this exception if no {@code SingleKvStore} database is available. + * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + */ + on(event: 'dataChange', type: SubscribeType, listener: Callback): void; + /** + * Register Synchronizes SingleKvStore databases callback. + *

Sync result is returned through asynchronous callback. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param syncCallback Indicates the callback used to send the synchronization result to the caller. + * @throws Throws this exception if no {@code SingleKvStore} database is available. + */ + on(event: 'syncComplete', syncCallback: Callback>): void; + /** + * Unsubscribes from the SingleKvStore database based on the specified subscribeType and {@code KvStoreObserver}. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param listener Indicates the data change observer registered by {#subscribe(SubscribeType, KvStoreObserver)}. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, + * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + */ + off(event: 'dataChange', listener?: Callback): void; + /** + * UnRegister Synchronizes SingleKvStore databases callback. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @throws Throws this exception if no {@code SingleKvStore} database is available. + */ + off(event: 'syncComplete', syncCallback?: Callback>): void; + /** + * Sets the default delay allowed for database synchronization + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param defaultAllowedDelayMs Indicates the default delay allowed for the database synchronization, in milliseconds. + * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + */ + setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback): void; + setSyncParam(defaultAllowedDelayMs: number): Promise; + /** + * Get the security level of the database. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns SecurityLevel {@code SecurityLevel} the security level of the database. + * @throws Throws this exception if any of the following errors occurs:{@code SERVER_UNAVAILABLE}, + * {@code IPC_ERROR}, and {@code DB_ERROR}. + */ + getSecurityLevel(callback: AsyncCallback): void; + getSecurityLevel(): Promise; + } + /** + * Manages distributed data by device in a distributed system. + * + *

To create a {@code DeviceKVStore} database, you can use the {@link data.distributed.common.KVManager.getKvStore(Options, String)} + * method with {@code KvStoreType} set to {@code DEVICE_COLLABORATION} for the input parameter Options. This database manages distributed + * data by device, and cannot modify data synchronized from remote devices. When an application writes a key-value pair entry + * into the database, the system automatically adds the ID of the device running the application to the key. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @import N/A + */ + interface DeviceKVStore extends KVStore { + /** + * Obtains the {@code String} value matching a specified device ID and key. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param deviceId Indicates the device to be queried. + * @param key Indicates the key of the value to be queried. + * @return Returns the value matching the given criteria. + * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}, and {@code KEY_NOT_FOUND}. + */ + get(deviceId: string, key: string, callback: AsyncCallback): void; + get(deviceId: string, key: string): Promise; + /** + * Obtains all key-value pairs matching a specified device ID and key prefix. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param deviceId Identifies the device whose data is to be queried. + * @param keyPrefix Indicates the key prefix to match. + * @returns Returns the list of all key-value pairs meeting the given criteria. + * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + */ + getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback): void; + getEntries(deviceId: string, keyPrefix: string): Promise; + /** + * Obtains the list of key-value pairs matching the specified {@code Query} object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param query Indicates the {@code Query} object. + * @returns Returns the list of key-value pairs matching the specified {@code Query} object. + * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + */ + getEntries(query: Query, callback: AsyncCallback): void; + getEntries(query: Query): Promise; + /** + * Obtains the list of key-value pairs matching a specified device ID and {@code Query} object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param deviceId Indicates the ID of the device to which the key-value pairs belong. + * @param query Indicates the {@code Query} object. + * @returns Returns the list of key-value pairs matching the specified {@code Query} object. + */ + getEntries(deviceId: string, query: Query, callback: AsyncCallback): void; + getEntries(deviceId: string, query: Query): Promise; + /** + * Obtains the {@code KvStoreResultSet} object matching the specified device ID and key prefix. + * + *

The {@code KvStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. Each {@code KvStore} + * instance can have a maximum of four {@code KvStoreResultSet} objects at the same time. If you have created four objects, + * calling this method will return a failure. Therefore, you are advised to call the closeResultSet method to close unnecessary + * {@code KvStoreResultSet} objects in a timely manner. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param deviceId Identifies the device whose data is to be queried. + * @param keyPrefix Indicates the key prefix to match. + * @returns Returns the {@code KvStoreResultSet} objects. + * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + */ + getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback): void; + getResultSet(deviceId: string, keyPrefix: string): Promise; + /** + * Obtains the {@code KvStoreResultSet} object matching the specified {@code Query} object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param query Indicates the {@code Query} object. + * @returns Returns the {@code KvStoreResultSet} object matching the specified {@code Query} object. + * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + */ + getResultSet(query: Query, callback: AsyncCallback): void; + getResultSet(query: Query): Promise; + /** + * Obtains the {@code KvStoreResultSet} object matching a specified device ID and {@code Query} object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param deviceId Indicates the ID of the device to which the {@code KvStoreResultSet} object belongs. + * @param query Indicates the {@code Query} object. + * @returns Returns the {@code KvStoreResultSet} object matching the specified {@code Query} object. + */ + getResultSet(deviceId: string, query: Query, callback: AsyncCallback): void; + getResultSet(deviceId: string, query: Query): Promise; + /** + * Obtains the KvStoreResultSet object matching the specified Predicate object. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param predicates Indicates the datasharePredicates. + * Spaces before and after the key will be cleared. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and + * {@code DB_ERROR}. + */ + getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise; + /** + * Obtains the KvStoreResultSet object matching a specified Device ID and Predicate object. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param predicates Indicates the key. + * @param deviceId Indicates the ID of the device to which the results belong. + * Spaces before and after the key will be cleared. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and + * {@code DB_ERROR}. + */ + getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates): Promise; + /** + * Closes a {@code KvStoreResultSet} object returned by getResultSet. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param resultSet Indicates the {@code KvStoreResultSet} object to close. + * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + */ + closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback): void; + closeResultSet(resultSet: KvStoreResultSet): Promise; + /** + * Obtains the number of results matching the specified {@code Query} object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param query Indicates the {@code Query} object. + * @returns Returns the number of results matching the specified {@code Query} object. + * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + */ + getResultSize(query: Query, callback: AsyncCallback): void; + getResultSize(query: Query): Promise; + /** + * Obtains the number of results matching a specified device ID and {@code Query} object. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param deviceId Indicates the ID of the device to which the results belong. + * @param query Indicates the {@code Query} object. + * @returns Returns the number of results matching the specified {@code Query} object. + */ + getResultSize(deviceId: string, query: Query, callback: AsyncCallback): void; + getResultSize(deviceId: string, query: Query): Promise; + /** + * Removes data of a specified device from the current database. This method is used to remove only the data + * synchronized from remote devices. This operation does not synchronize data to other databases or affect + * subsequent data synchronization. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param deviceId Identifies the device whose data is to be removed. The value cannot be the current device ID. + * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + */ + removeDeviceData(deviceId: string, callback: AsyncCallback): void; + removeDeviceData(deviceId: string): Promise; + /** + * Synchronizes {@code DeviceKVStore} databases. + * + *

This method returns immediately and sync result will be returned through asynchronous callback. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param deviceIds Indicates the list of IDs of devices whose + * @param delayMs Indicates the delay allowed for the synchronization, in milliseconds. + * {@code DeviceKVStore} databases are to be synchronized. + * @param mode Indicates the synchronization mode, {@code PUSH}, {@code PULL}, or + * {@code PUSH_PULL}. + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @throws Throws this exception if no DeviceKVStore database is available. + */ + sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void; + /** + * Synchronizes {@code DeviceKVStore} databases. + * + *

This method returns immediately and sync result will be returned through asynchronous callback. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param deviceIds Indicates the list of IDs of devices whose + * @param delayMs Indicates the delay allowed for the synchronization, in milliseconds. + * {@code DeviceKVStore} databases are to be synchronized. + * @param query Indicates the {@code Query} object. + * @param mode Indicates the synchronization mode, {@code PUSH}, {@code PULL}, or + * {@code PUSH_PULL}. + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @throws Throws this exception if no DeviceKVStore database is available. + */ + sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void; + /** + * Register Synchronizes DeviceKVStore databases callback. + * + *

Sync result is returned through asynchronous callback. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param syncCallback Indicates the callback used to send the synchronization result to the caller. + * @throws Throws this exception if no DeviceKVStore database is available. + */ + on(event: 'syncComplete', syncCallback: Callback>): void; + /** + * Registers a {@code KvStoreObserver} for the database. When data in the distributed database changes, the callback in + * {@code KvStoreObserver} will be invoked. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param type Indicates the subscription type, which is defined in {@code SubscribeType}. + * @param listener Indicates the observer of data change events in the distributed database. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, + * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + */ + on(event: 'dataChange', type: SubscribeType, listener: Callback): void; + /** + * Unsubscribes from the DeviceKVStore database based on the specified subscribeType and {@code KvStoreObserver}. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param listener Indicates the data change observer registered by {#subscribe(SubscribeType, KvStoreObserver)}. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, + * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + */ + off(event: 'dataChange', listener?: Callback): void; + /** + * UnRegister Synchronizes DeviceKVStore databases callback. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @throws Throws this exception if no DeviceKVStore database is available. + */ + off(event: 'syncComplete', syncCallback?: Callback>): void; + } + /** + * Creates a {@link KVManager} instance based on the configuration information. + * + *

You must pass {@link KVManagerConfig} to provide configuration information + * for creating the {@link KVManager} instance. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param config Indicates the {@link KVStore} configuration information, + * including the user information and package name. + * @return Returns the {@code KVManager} instance. + * @throws Throws exception if input is invalid. + */ + function createKVManager(config: KVManagerConfig, callback: AsyncCallback): void; + function createKVManager(config: KVManagerConfig): Promise; + /** + * Provides interfaces to manage a {@code KVStore} database, including obtaining, closing, and deleting the {@code KVStore}. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @import N/A + * @version 1 + */ + interface KVManager { + /** + * Creates and obtains a {@code KVStore} database by specifying {@code Options} and {@code storeId}. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param options Indicates the options used for creating and obtaining the {@code KVStore} database, + * including {@code isCreateIfMissing}, {@code isEncrypt}, and {@code KVStoreType}. + * @param storeId Identifies the {@code KVStore} database. + * The value of this parameter must be unique for the same application, + * and different applications can share the same value. + * @return Returns a {@code KVStore}, or {@code SingleKVStore}. + */ + getKVStore(storeId: string, options: Options): Promise; + getKVStore(storeId: string, options: Options, callback: AsyncCallback): void; + /** + * Closes the {@code KvStore} database. + * + *

Warning: This method is not thread-safe. If you call this method to stop a KvStore database that is running, your + * thread may crash. + * + *

The {@code KvStore} database to close must be an object created by using the {@code getKvStore} method. Before using this + * method, release the resources created for the database, for example, {@code KvStoreResultSet} for {@code SingleKvStore}, + * otherwise closing the database will fail. If you are attempting to close a database that is already closed, an error + * will be returned. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param kvStore Indicates the {@code KvStore} database to close. + * @throws Throws this exception if any of the following errors + * occurs:{@code INVALID_ARGUMENT}, {@code ERVER_UNAVAILABLE}, + * {@code STORE_NOT_OPEN}, {@code STORE_NOT_FOUND}, {@code DB_ERROR}, + * {@code PERMISSION_DENIED}, and {@code IPC_ERROR}. + */ + closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCallback): void; + closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise; + /** + * Deletes the {@code KvStore} database identified by storeId. + * + *

Before using this method, close all {@code KvStore} instances in use that are identified by the same storeId. + * + *

You can use this method to delete a {@code KvStore} database not in use. After the database is deleted, all its data will be + * lost. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @param storeId Identifies the {@code KvStore} database to delete. + * @throws Throws this exception if any of the following errors + * occurs: {@code INVALID_ARGUMENT}, + * {@code SERVER_UNAVAILABLE}, {@code STORE_NOT_FOUND}, + * {@code DB_ERROR}, {@code PERMISSION_DENIED}, and {@code IPC_ERROR}. + */ + deleteKVStore(appId: string, storeId: string, callback: AsyncCallback): void; + deleteKVStore(appId: string, storeId: string): Promise; + /** + * Obtains the storeId of all {@code KvStore} databases that are created by using the {@code getKvStore} method and not deleted by + * calling the {@code deleteKvStore} method. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @returns Returns the storeId of all created {@code KvStore} databases. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code DB_ERROR}, + * {@code PERMISSION_DENIED}, and {@code IPC_ERROR}. + */ + getAllKVStoreId(appId: string, callback: AsyncCallback): void; + getAllKVStoreId(appId: string): Promise; + /** + * register DeviceChangeCallback to get notification when device's status changed + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param deathCallback device change callback {@code DeviceChangeCallback} + * @throws exception maybe occurs. + */ + on(event: 'distributedDataServiceDie', deathCallback: Callback): void; + /** + * unRegister DeviceChangeCallback and can not receive notification + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @param deathCallback device change callback {@code DeviceChangeCallback} which has been registered. + * @throws exception maybe occurs. + */ + off(event: 'distributedDataServiceDie', deathCallback?: Callback): void; + } +} +export default distributedData; diff --git a/build-tools/api/@ohos.data.distributedDataObject.d.ts b/build-tools/api/@ohos.data.distributedDataObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..02489c2dd9d0be2a9951c8b72b6e4b250110ecdd --- /dev/null +++ b/build-tools/api/@ohos.data.distributedDataObject.d.ts @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './basic'; +/** + * Provides interfaces to sync distributed object + * + * @name distributedDataObject + * @since 8 + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + */ +declare namespace distributedDataObject { + /** + * Create distributed object + * + * @param source Init data of distributed object + * @return Returns the distributed object + * @since 8 + */ + function createDistributedObject(source: object): DistributedObject; + /** + * Generate a random sessionId + * + * @return Returns the random sessionId + * @since 8 + */ + function genSessionId(): string; + /** + * @since 9 + */ + interface SaveSuccessResponse { + /** + * sessionId of saved object + * @since 9 + */ + sessionId: string; + /** + * version of saved object, can compare with DistributedObject.__version + * @since 9 + */ + version: number; + /** + * deviceid that data saved + * data is "local", means save in local device + * otherwise, means the networkId of device + * @since 9 + */ + deviceId: string; + } + /** + * @since 9 + */ + interface RevokeSaveSuccessResponse { + /** + * @since 9 + */ + sessionId: string; + } + /** + * Object create by {@link createDistributedObject}. + * + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 8 + */ + interface DistributedObject { + /* + * Change object session + * + * @param sessionId The sessionId to be joined, if empty, leave all session + * @return Operation result, true is success, false is failed + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @since 8 + */ + setSessionId(sessionId?: string): boolean; + /** + * On watch of change + * + * @param callback The callback of change + * @since 8 + */ + on(type: 'change', callback: Callback<{ + sessionId: string; + fields: Array; + }>): void; + /** + * Off watch of change + * + * @param callback If not null, off the callback, if undefined, off all callbacks + * @since 8 + */ + off(type: 'change', callback?: Callback<{ + sessionId: string; + fields: Array; + }>): void; + /** + * On watch of status + * + * @param callback Indicates the observer of object status changed. + * sessionId: The sessionId of the changed object + * networkId: NetworkId of the changed device + * status: 'online' The object became online on the device and data can be synced to the device + * 'offline' The object became offline on the device and the object can not sync any data + * @since 8 + */ + on(type: 'status', callback: Callback<{ + sessionId: string; + networkId: string; + status: 'online' | 'offline'; + }>): void; + /** + * Off watch of status + * + * @param callback If not null, off the callback, if undefined, off all callbacks + * @since 8 + */ + off(type: 'status', callback?: Callback<{ + sessionId: string; + deviceId: string; + status: 'online' | 'offline'; + }>): void; + /** + * Save object, after save object data successfully, the object data will not release when app existed, and resume data on saved device after app existed + * the saved data secure level is S0, it is not safe, can only save public data, if there is privacy data, you should encrypt it + * + * the saved data will be released when + * 1. saved after 24h + * 2. app uninstalled + * 3. after resume data success, system will auto delete the saved data + * + * @param deviceId Indicates the device that will resume the object data + * @since 9 + */ + save(deviceId: string, callback: AsyncCallback): void; + save(deviceId: string): Promise; + /** + * Revoke save object, delete saved object immediately, if object is saved in local device, it will delete saved data on all trusted device + * if object is saved in other device, it will delete data in local device. + * + * @since 9 + */ + revokeSave(callback: AsyncCallback): void; + revokeSave(): Promise; + } +} +export default distributedDataObject; diff --git a/build-tools/api/@ohos.data.preferences.d.ts b/build-tools/api/@ohos.data.preferences.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..42a070ed5a08256f7ad82b668a97c30881b0ddb6 --- /dev/null +++ b/build-tools/api/@ohos.data.preferences.d.ts @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './basic'; +import Context from "./application/Context"; +/** + * Provides interfaces to obtain and modify preferences data. + * + * @name preferences + * @since 9 + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * + */ +declare namespace preferences { + /** + * Obtains a {@link Preferences} instance matching a specified preferences file name. + * + *

The {@link references} instance loads all data of the preferences file and + * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. + * + * @param context Indicates the context of application or capability. + * @param name Indicates the preferences file name. + * @return Returns the {@link Preferences} instance matching the specified preferences file name. + * @throws BusinessError if invoked failed + * @since 9 + */ + function getPreferences(context: Context, name: string, callback: AsyncCallback): void; + function getPreferences(context: Context, name: string): Promise; + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache which is performed by removePreferencesFromCache and deletes the + * preferences file. + * + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param context Indicates the context of application or capability. + * @param name Indicates the preferences file name. + * @throws BusinessError if invoked failed + * @since 9 + */ + function deletePreferences(context: Context, name: string, callback: AsyncCallback): void; + function deletePreferences(context: Context, name: string): Promise; + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache. + * + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param context Indicates the context of application or capability. + * @param name Indicates the preferences file name. + * @throws BusinessError if invoked failed + * @since 9 + */ + function removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback): void; + function removePreferencesFromCache(context: Context, name: string): Promise; + /** + * Provides interfaces to obtain and modify preferences data. + * + *

The preferences data is stored in a file, which matches only one {@link Preferences} instance in the memory. + * You can use getPreferences to obtain the {@link Preferences} instance matching + * the file that stores preferences data, and use emovePreferencesFromCache + * to remove the {@link Preferences} instance from the memory. + * + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * + * @since 9 + */ + interface Preferences { + /** + * Obtains the value of a preferences in the int format. + * + *

If the value is {@code null} or not in the int format, the default value is returned. + * + * @param key Indicates the key of the preferences. It cannot be {@code null} or empty. + * @param defValue Indicates the default value to return. + * @return Returns the value matching the specified key if it is found; returns the default value otherwise. + * @throws BusinessError if invoked failed + * @since 9 + */ + get(key: string, defValue: ValueType, callback: AsyncCallback): void; + get(key: string, defValue: ValueType): Promise; + /** + * Obtains all the keys and values of a preferences in an object. + * + * @return Returns the values and keys in an object. + * @throws BusinessError if invoked failed + * @since 9 + */ + getAll(callback: AsyncCallback): void; + getAll(): Promise; + /** + * Checks whether the {@link Preferences} object contains a preferences matching a specified key. + * + * @param key Indicates the key of the preferences to check for. + * @return Returns {@code true} if the {@link Preferences} object contains a preferences with the specified key; + * returns {@code false} otherwise. + * @throws BusinessError if invoked failed + * @since 9 + */ + has(key: string, callback: AsyncCallback): void; + has(key: string): Promise; + /** + * Sets an int value for the key in the {@link Preferences} object. + * + *

You can call the {@link #flush} method to save the {@link Preferences} object to the + * file. + * + * @param key Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * @param value Indicates the value of the preferences. + * MAX_KEY_LENGTH. + * @throws BusinessError if invoked failed + * @since 9 + */ + put(key: string, value: ValueType, callback: AsyncCallback): void; + put(key: string, value: ValueType): Promise; + /** + * Deletes the preferences with a specified key from the {@link Preferences} object. + * + *

You can call the {@link #flush} method to save the {@link Preferences} object to the + * file. + * + * @param key Indicates the key of the preferences to delete. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @throws BusinessError if invoked failed + * @since 9 + */ + delete(key: string, callback: AsyncCallback): void; + delete(key: string): Promise; + /** + * Clears all preferences from the {@link Preferences} object. + * + *

You can call the {@link #flush} method to save the {@link Preferences} object to the + * file. + * + * @throws BusinessError if invoked failed + * @since 9 + */ + clear(callback: AsyncCallback): void; + clear(): Promise; + /** + * Asynchronously saves the {@link Preferences} object to the file. + * + * @throws BusinessError if invoked failed + * @since 9 + */ + flush(callback: AsyncCallback): void; + flush(): Promise; + /** + * Registers an observer to listen for the change of a {@link Preferences} object. + * + * @param callback Indicates the callback when preferences changes. + * @throws BusinessError if invoked failed + * @since 9 + */ + on(type: 'change', callback: Callback<{ + key: string; + }>): void; + /** + * Unregisters an existing observer. + * + * @param callback Indicates the registered callback. + * @throws BusinessError if invoked failed + * @since 9 + */ + off(type: 'change', callback?: Callback<{ + key: string; + }>): void; + } + /** + * Indicates possible value types + */ + type ValueType = number | string | boolean | Array | Array | Array; + /** + * Indicates the maximum length of a key (80 characters). + */ + const MAX_KEY_LENGTH: 80; + /** + * Indicates the maximum length of a string (8192 characters). + */ + const MAX_VALUE_LENGTH: 8192; +} +export default preferences; diff --git a/build-tools/api/@ohos.data.rdb.d.ts b/build-tools/api/@ohos.data.rdb.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..faad44de4eb4e7fd020d1d87b12947d5b9a1dc8c --- /dev/null +++ b/build-tools/api/@ohos.data.rdb.d.ts @@ -0,0 +1,661 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from './basic'; +import { ResultSet as _ResultSet } from './data/rdb/resultSet'; +import Context from "./application/BaseContext"; +import dataSharePredicates from './@ohos.data.dataSharePredicates'; +/** + * Provides methods for rdbStore create and delete. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @import import data_rdb from '@ohos.data.rdb'; + */ +declare namespace rdb { + /** + * Obtains an RDB store. + * + * You can set parameters of the RDB store as required. In general, this method is recommended + * to obtain a rdb store. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param context Indicates the context of application or capability. + * @param config Indicates the configuration of the database related to this RDB store. The configurations include + * the database path, storage mode, and whether the database is read-only. + * @param version Indicates the database version for upgrade or downgrade. + * @return Returns an RDB store {@link ohos.data.rdb.RdbStore}. + */ + function getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback): void; + function getRdbStore(context: Context, config: StoreConfig, version: number): Promise; + /** + * Deletes the database with a specified name. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param context Indicates the context of application or capability. + * @param name Indicates the database name. + * @return Returns true if the database is deleted; returns false otherwise. + */ + function deleteRdbStore(context: Context, name: string, callback: AsyncCallback): void; + function deleteRdbStore(context: Context, name: string): Promise; + /** + * Indicates the database synchronization mode. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + enum SyncMode { + /** + * Indicates the data is pushed to remote device from local device. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + SYNC_MODE_PUSH = 0, + /** + * Indicates the data is pulled from remote device to local device. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + SYNC_MODE_PULL = 1 + } + /** + * Describes the subscription type. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @permission ohos.permission.DISTRIBUTED_DATASYNC + */ + enum SubscribeType { + /** + * Subscription to remote data changes + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + SUBSCRIBE_TYPE_REMOTE = 0 + } + /** + * Provides methods for managing the relational database (RDB). + * + * This class provides methods for creating, querying, updating, and deleting RDBs. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @import import data_rdb from '@ohos.data.rdb'; + */ + interface RdbStore { + /** + * Inserts a row of data into the target table. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param table Indicates the target table. + * @param values Indicates the row of data to be inserted into the table. + * @return Returns the row ID if the operation is successful; returns -1 otherwise. + */ + insert(table: string, values: ValuesBucket, callback: AsyncCallback): void; + insert(table: string, values: ValuesBucket): Promise; + /** + * Updates data in the database based on a a specified instance object of rdbPredicates. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param values Indicates the row of data to be updated in the database.The key-value pairs are associated with column names of the database table. + * @param predicates Indicates the specified update condition by the instance object of RdbPredicates. + * @return Returns the number of affected rows. + */ + update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback): void; + update(values: ValuesBucket, predicates: RdbPredicates): Promise; + /** + * Updates data in the database based on a a specified instance object of DataSharePredicates. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param table Indicates the target table. + * @param values Indicates the row of data to be updated in the database.The key-value pairs are associated with column names of the database table. + * @param predicates Indicates the specified update condition by the instance object of DataSharePredicates. + * @return Returns the number of affected rows. + */ + update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates): Promise; + /** + * Deletes data from the database based on a specified instance object of rdbPredicates. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param predicates Indicates the specified delete condition by the instance object of RdbPredicates. + * @return Returns the number of affected rows. + */ + delete(predicates: RdbPredicates, callback: AsyncCallback): void; + delete(predicates: RdbPredicates): Promise; + /** + * Deletes data from the database based on a specified instance object of DataSharePredicates. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param table Indicates the target table. + * @param predicates Indicates the specified delete condition by the instance object of DataSharePredicates. + * @return Returns the number of affected rows. + */ + delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + delete(table: string, predicates: dataSharePredicates.DataSharePredicates): Promise; + /** + * Queries data in the database based on specified conditions. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param predicates Indicates the specified query condition by the instance object of RdbPredicates. + * @param columns Indicates the columns to query. If the value is null, the query applies to all columns. + * @return Returns a ResultSet object if the operation is successful; + */ + query(predicates: RdbPredicates, columns: Array, callback: AsyncCallback): void; + query(predicates: RdbPredicates, columns?: Array): Promise; + /** + * Queries data in the database based on specified conditions. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param table Indicates the target table. + * @param predicates Indicates the specified query condition by the instance object of DataSharePredicates. + * @param columns Indicates the columns to query. If the value is null, the query applies to all columns. + * @return Returns a ResultSet object if the operation is successful; + */ + query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array, callback: AsyncCallback): void; + query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array): Promise; + /** + * Queries data in the database based on SQL statement. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param sql Indicates the SQL statement to execute. + * @param bindArgs Indicates the values of the parameters in the SQL statement. The values are strings. + * @return Returns a ResultSet object if the operation is successful; + */ + querySql(sql: string, bindArgs: Array, callback: AsyncCallback): void; + querySql(sql: string, bindArgs?: Array): Promise; + /** + * Executes an SQL statement that contains specified parameters but returns no value. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param sql Indicates the SQL statement to execute. + * @param bindArgs Indicates the values of the parameters in the SQL statement. The values are strings. + */ + executeSql(sql: string, bindArgs: Array, callback: AsyncCallback): void; + executeSql(sql: string, bindArgs?: Array): Promise; + /** + * beginTransaction before excute your sql + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + beginTransaction(): void; + /** + * commit the the sql you have excuted. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + commit(): void; + /** + * roll back the sql you have already excuted + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + rollBack(): void; + /** + * Backs up a database in a specified name. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param destName Indicates the name that saves the database backup. + */ + backup(destName: string, callback: AsyncCallback): void; + backup(destName: string): Promise; + /** + * Restores a database from a specified database file. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param srcName Indicates the name that saves the database file. + */ + restore(srcName: string, callback: AsyncCallback): void; + restore(srcName: string): Promise; + /** + * Set table to be distributed table. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param tables the tables name you want to set + * @permission ohos.permission.DISTRIBUTED_DATASYNC + */ + setDistributedTables(tables: Array, callback: AsyncCallback): void; + setDistributedTables(tables: Array): Promise; + /** + * Obtain distributed table name of specified remote device according to local table name. + * When query remote device database, distributed table name is needed. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param device Indicates the remote device. + * @param table Indicates the local table name. + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @return the distributed table name. + */ + obtainDistributedTableName(device: string, table: string, callback: AsyncCallback): void; + obtainDistributedTableName(device: string, table: string): Promise; + /** + * Sync data between devices + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param mode Indicates the synchronization mode. The value can be PUSH, PULL. + * @param predicates Constraint synchronized data and devices. + * @param callback Indicates the callback used to send the synchronization result to the caller. + * @permission ohos.permission.DISTRIBUTED_DATASYNC + */ + sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback>): void; + sync(mode: SyncMode, predicates: RdbPredicates): Promise>; + /** + * Registers an observer for the database. When data in the distributed database changes, + * the callback will be invoked. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param type Indicates the subscription type, which is defined in {@code SubscribeType}. + * @param observer Indicates the observer of data change events in the distributed database. + * @permission ohos.permission.DISTRIBUTED_DATASYNC + */ + on(event: 'dataChange', type: SubscribeType, observer: Callback>): void; + /** + * Remove specified observer of specified type from the database. + * + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param type Indicates the subscription type, which is defined in {@code SubscribeType}. + * @param observer Indicates the data change observer already registered. + * @permission ohos.permission.DISTRIBUTED_DATASYNC + */ + off(event: 'dataChange', type: SubscribeType, observer: Callback>): void; + } + /** + * Indicates possible value types + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @import import data_rdb from '@ohos.data.rdb'; + */ + type ValueType = number | string | boolean; + /** + * Values in buckets are stored in key-value pairs + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @import import data_rdb from '@ohos.data.rdb'; + */ + type ValuesBucket = { + [key: string]: ValueType | Uint8Array | null; + }; + /** + * Manages relational database configurations. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @import import data_rdb from '@ohos.data.rdb'; + */ + interface StoreConfig { + name: string; + } + /** + * Manages relational database configurations. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @import import data_rdb from '@ohos.data.rdb'; + */ + class RdbPredicates { + /** + * A parameterized constructor used to create an RdbPredicates instance. + * name Indicates the table name of the database. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + constructor(name: string); + /** + * Specify remote devices when syncing distributed database. + * + * @note When query database, this function should not be called. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param devices Indicates specified remote devices. + * @return Returns the RdbPredicates self. + */ + inDevices(devices: Array): RdbPredicates; + /** + * Specify all remote devices which connect to local device when syncing distributed database. + * + * @note When query database, this function should not be called. + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @return Returns the RdbPredicates self. + */ + inAllDevices(): RdbPredicates; + /** + * Configures the RdbPredicates to match the field whose data type is ValueType and value is equal + * to a specified value. + * + * @note This method is similar to = of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the RdbPredicates. + * @return Returns the RdbPredicates that match the specified field. + */ + equalTo(field: string, value: ValueType): RdbPredicates; + /** + * Configures the RdbPredicates to match the field whose data type is ValueType and value is unequal to + * a specified value. + * + * @note This method is similar to != of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the RdbPredicates. + * @return Returns the RdbPredicates that match the specified field. + */ + notEqualTo(field: string, value: ValueType): RdbPredicates; + /** + * Adds a left parenthesis to the RdbPredicates. + * + * @note This method is similar to ( of the SQL statement and needs to be used together with endWrap(). + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @return Returns the RdbPredicates with the left parenthesis. + */ + beginWrap(): RdbPredicates; + /** + * Adds a right parenthesis to the RdbPredicates. + * + * @note This method is similar to ) of the SQL statement and needs to be used together + * with beginWrap(). + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @return Returns the RdbPredicates with the right parenthesis. + */ + endWrap(): RdbPredicates; + /** + * Adds an or condition to the RdbPredicates. + * + * @note This method is similar to or of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @return Returns the RdbPredicates with the or condition. + */ + or(): RdbPredicates; + /** + * Adds an and condition to the RdbPredicates. + * + * @note This method is similar to and of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @return Returns the RdbPredicates with the and condition. + */ + and(): RdbPredicates; + /** + * Configures the RdbPredicates to match the field whose data type is string and value + * contains a specified value. + * + * @note This method is similar to contains of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the RdbPredicates. + * @return Returns the RdbPredicates that match the specified field. + */ + contains(field: string, value: string): RdbPredicates; + /** + * Configures the RdbPredicates to match the field whose data type is string and value starts + * with a specified string. + * + * @note This method is similar to value% of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the RdbPredicates. + * @return Returns the RdbPredicates that match the specified field. + */ + beginsWith(field: string, value: string): RdbPredicates; + /** + * Configures the RdbPredicates to match the field whose data type is string and value + * ends with a specified string. + * + * @note This method is similar to %value of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the RdbPredicates. + * @return Returns the RdbPredicates that match the specified field. + */ + endsWith(field: string, value: string): RdbPredicates; + /** + * Configures the RdbPredicates to match the fields whose value is null. + * + * @note This method is similar to is null of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @return Returns the RdbPredicates that match the specified field. + */ + isNull(field: string): RdbPredicates; + /** + * Configures the RdbPredicates to match the specified fields whose value is not null. + * + * @note This method is similar to is not null of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @return Returns the RdbPredicates that match the specified field. + */ + isNotNull(field: string): RdbPredicates; + /** + * Configures the RdbPredicates to match the fields whose data type is string and value is + * similar to a specified string. + * + * @note This method is similar to like of the SQL statement. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the RdbPredicates. The percent sign (%) in the value + * is a wildcard (like * in a regular expression). + * @return Returns the RdbPredicates that match the specified field. + */ + like(field: string, value: string): RdbPredicates; + /** + * Configures RdbPredicates to match the specified field whose data type is string and the value contains + * a wildcard. + * + * @note Different from like, the input parameters of this method are case-sensitive. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with RdbPredicates. + * @return Returns the SQL statement with the specified RdbPredicates. + */ + glob(field: string, value: string): RdbPredicates; + /** + * Restricts the value of the field to the range between low value and high value. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name. + * @param low Indicates the minimum value. + * @param high Indicates the maximum value. + * @return Returns the SQL query statement with the specified RdbPredicates. + */ + between(field: string, low: ValueType, high: ValueType): RdbPredicates; + /** + * Configures RdbPredicates to match the specified field whose data type is int and value is + * out of a given range. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @param low Indicates the minimum value to match with DataAbilityPredicates. + * @param high Indicates the maximum value to match with DataAbilityPredicates. + * @return Returns the SQL query statement with the specified RdbPredicates. + */ + notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates; + /** + * Restricts the value of the field to be greater than the specified value. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified RdbPredicates. + */ + greaterThan(field: string, value: ValueType): RdbPredicates; + /** + * Restricts the value of the field to be smaller than the specified value. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified RdbPredicates. + */ + lessThan(field: string, value: ValueType): RdbPredicates; + /** + * Restricts the value of the field to be greater than or equal to the specified value. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified RdbPredicates. + */ + greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates; + /** + * Restricts the value of the field to be smaller than or equal to the specified value. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified RdbPredicates. + */ + lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates; + /** + * Restricts the ascending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name for sorting the return list. + * @return Returns the SQL query statement with the specified RdbPredicates. + */ + orderByAsc(field: string): RdbPredicates; + /** + * Restricts the descending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name for sorting the return list. + * @return Returns the SQL query statement with the specified RdbPredicates. + */ + orderByDesc(field: string): RdbPredicates; + /** + * Restricts each row of the query result to be unique. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @return Returns the SQL query statement with the specified RdbPredicates. + */ + distinct(): RdbPredicates; + /** + * Restricts the max number of return records. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param value Indicates the max length of the return list. + * @return Returns the SQL query statement with the specified RdbPredicates. + */ + limitAs(value: number): RdbPredicates; + /** + * Configures RdbPredicates to specify the start position of the returned result. + * + * @note Use this method together with limit(int). + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param rowOffset Indicates the start position of the returned result. The value is a positive integer. + * @return Returns the SQL query statement with the specified AbsPredicates. + */ + offsetAs(rowOffset: number): RdbPredicates; + /** + * Configures RdbPredicates to group query results by specified columns. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param fields Indicates the specified columns by which query results are grouped. + * @return Returns the RdbPredicates with the specified columns by which query results are grouped. + */ + groupBy(fields: Array): RdbPredicates; + /** + * Configures RdbPredicates to specify the index column. + * + * @note Before using this method, you need to create an index column. + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param indexName Indicates the name of the index column. + * @return Returns RdbPredicates with the specified index column. + */ + indexedBy(field: string): RdbPredicates; + /** + * Configures RdbPredicates to match the specified field whose data type is ValueType array and values + * are within a given range. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @param values Indicates the values to match with RdbPredicates. + * @return Returns RdbPredicates that matches the specified field. + */ + in(field: string, value: Array): RdbPredicates; + /** + * Configures RdbPredicates to match the specified field whose data type is ValueType array and values + * are out of a given range. + * + * @since 7 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param field Indicates the column name in the database table. + * @param values Indicates the values to match with RdbPredicates. + * @return Returns RdbPredicates that matches the specified field. + */ + notIn(field: string, value: Array): RdbPredicates; + } + export type ResultSet = _ResultSet; +} +export default rdb; diff --git a/build-tools/api/@ohos.data.storage.d.ts b/build-tools/api/@ohos.data.storage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c34c5492ae138573fa79d34cf7d80d76ca88d8b --- /dev/null +++ b/build-tools/api/@ohos.data.storage.d.ts @@ -0,0 +1,216 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './basic'; +/** + * Provides interfaces to obtain and modify storage data. + * + * @name storage + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * + */ +declare namespace storage { + /** + * Obtains a {@link Storage} instance matching a specified storage file name. + * + *

The {@link references} instance loads all data of the storage file and + * resides in the memory. You can use removeStorageFromCache to remove the instance from the memory. + * + * @param path Indicates the path of storage file stored. + * @return Returns the {@link Storage} instance matching the specified storage file name. + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + function getStorageSync(path: string): Storage; + function getStorage(path: string, callback: AsyncCallback): void; + function getStorage(path: string): Promise; + /** + * Deletes a {@link Storage} instance matching a specified storage file name + * from the cache which is performed by removeStorageFromCache and deletes the + * storage file. + * + *

When deleting the {@link Storage} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param path Indicates the path of storage file + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + function deleteStorageSync(path: string): void; + function deleteStorage(path: string, callback: AsyncCallback): void; + function deleteStorage(path: string): Promise; + /** + * Deletes a {@link Storage} instance matching a specified storage file name + * from the cache. + * + *

When deleting the {@link Storage} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param path Indicates the path of storage file. + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + function removeStorageFromCacheSync(path: string): void; + function removeStorageFromCache(path: string, callback: AsyncCallback): void; + function removeStorageFromCache(path: string): Promise; + /** + * Provides interfaces to obtain and modify storage data. + * + *

The storage data is stored in a file, which matches only one {@link Storage} instance in the memory. + * You can use getStorage to obtain the {@link Storage} instance matching + * the file that stores storage data, and use emoveStorageFromCache + * to remove the {@link Storage} instance from the memory. + * + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + interface Storage { + /** + * Obtains the value of a storage in the int format. + * + *

If the value is {@code null} or not in the int format, the default value is returned. + * + * @param key Indicates the key of the storage. It cannot be {@code null} or empty. + * @param defValue Indicates the default value to return. + * @return Returns the value matching the specified key if it is found; returns the default value otherwise. + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + getSync(key: string, defValue: ValueType): ValueType; + get(key: string, defValue: ValueType, callback: AsyncCallback): void; + get(key: string, defValue: ValueType): Promise; + /** + * Checks whether the {@link Storage} object contains a storage matching a specified key. + * + * @param key Indicates the key of the storage to check for. + * @return Returns {@code true} if the {@link Storage} object contains a storage with the specified key; + * returns {@code false} otherwise. + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + hasSync(key: string): boolean; + has(key: string, callback: AsyncCallback): boolean; + has(key: string): Promise; + /** + * Sets an int value for the key in the {@link Storage} object. + * + *

You can call the {@link #flush} or {@link #flushSync} method to save the {@link Storage} object to the + * file. + * + * @param key Indicates the key of the storage to modify. It cannot be {@code null} or empty. + * @param value Indicates the value of the storage. + * MAX_KEY_LENGTH. + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + putSync(key: string, value: ValueType): void; + put(key: string, value: ValueType, callback: AsyncCallback): void; + put(key: string, value: ValueType): Promise; + /** + * Deletes the storage with a specified key from the {@link Storage} object. + * + *

You can call the {@link #flush} method to save the {@link Storage} object to the + * file. + * + * @param key Indicates the key of the storage to delete. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + deleteSync(key: string): void; + delete(key: string, callback: AsyncCallback): void; + delete(key: string): Promise; + /** + * Clears all storage from the {@link Storage} object. + * + *

You can call the {@link #flush} method to save the {@link Storage} object to the + * file. + * + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + clearSync(): void; + clear(callback: AsyncCallback): void; + clear(): Promise; + /** + * Asynchronously saves the {@link Storage} object to the file. + * + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + flushSync(): void; + flush(callback: AsyncCallback): void; + flush(): Promise; + /** + * Registers an observer to listen for the change of a {@link Storage} object. + * + * @param callback Indicates the callback when storage changes. + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + on(type: 'change', callback: Callback): void; + /** + * Unregisters an existing observer. + * + * @param callback Indicates the registered callback. + * @throws BusinessError if invoked failed + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + off(type: 'change', callback: Callback): void; + } + /** + * Indicates possible value types + */ + type ValueType = number | string | boolean; + /** + * Define the change data information object. + * + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * + * @since 6 + * @deprecated since 9, please use @ohos.data.preferences instead. + */ + interface StorageObserver { + /** + * Indicates which key changes + */ + key: string; + } + /** + * Indicates the maximum length of a key (80 characters). + */ + const MAX_KEY_LENGTH: 80; + /** + * Indicates the maximum length of a string (8192 characters). + */ + const MAX_VALUE_LENGTH: 8192; +} +export default storage; diff --git a/build-tools/api/@ohos.deviceInfo.d.ts b/build-tools/api/@ohos.deviceInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f54fa7394206c189f6107454a6f06a42dcf751c2 --- /dev/null +++ b/build-tools/api/@ohos.deviceInfo.d.ts @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * A static class pertaining to the product information. + * + * @since 6 + * @syscap SystemCapability.Startup.SystemInfo + */ +declare namespace deviceInfo { + /** + * Obtains the device type represented by a string, + * which can be {@code phone} (or {@code default} for phones), {@code wearable}, {@code liteWearable}, + * {@code tablet}, {@code tv}, {@code car}, or {@code smartVision}. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const deviceType: string; + /** + * Obtains the device manufacturer represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const manufacture: string; + /** + * Obtains the device brand represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const brand: string; + /** + * Obtains the external product series represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const marketName: string; + /** + * Obtains the product series represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const productSeries: string; + /** + * Obtains the product model represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const productModel: string; + /** + * Obtains the software model represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const softwareModel: string; + /** + * Obtains the hardware model represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const hardwareModel: string; + /** + * Obtains the hardware profile represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const hardwareProfile: string; + /** + * Obtains the device serial number represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const serial: string; + /** + * Obtains the bootloader version number represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const bootloaderVersion: string; + /** + * Obtains the application binary interface (Abi) list represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const abiList: string; + /** + * Obtains the security patch level represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const securityPatchTag: string; + /** + * Obtains the product version represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const displayVersion: string; + /** + * Obtains the incremental version represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const incrementalVersion: string; + /** + * Obtains the OS release type represented by a string. + * + *

The OS release category can be {@code Release}, {@code Beta}, or {@code Canary}. + * The specific release type may be {@code Release}, {@code Beta1}, or others alike. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const osReleaseType: string; + /** + * Obtains the OS version represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const osFullName: string; + /** + * Obtains the major (M) version number, which increases with any updates to the overall architecture. + *

The M version number monotonically increases from 1 to 99. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const majorVersion: number; + /** + * Obtains the senior (S) version number, which increases with any updates to the partial + * architecture or major features. + *

The S version number monotonically increases from 0 to 99. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const seniorVersion: number; + /** + * Obtains the feature (F) version number, which increases with any planned new features. + *

The F version number monotonically increases from 0 or 1 to 99. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const featureVersion: number; + /** + * Obtains the build (B) version number, which increases with each new development build. + *

The B version number monotonically increases from 0 or 1 to 999. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const buildVersion: number; + /** + * Obtains the SDK API version number. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const sdkApiVersion: number; + /** + * Obtains the first API version number. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const firstApiVersion: number; + /** + * Obtains the version ID by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const versionId: string; + /** + * Obtains the build types of the same baseline code. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const buildType: string; + /** + * Obtains the different build user of the same baseline code. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const buildUser: string; + /** + * Obtains the different build host of the same baseline code. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const buildHost: string; + /** + * Obtains the build time. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const buildTime: string; + /** + * Obtains the version hash. + * @syscap SystemCapability.Startup.SystemInfo + * @since 6 + */ + const buildRootHash: string; + /** + * Obtains the device udid. + * @syscap SystemCapability.Startup.SystemInfo + * @since 7 + */ + const udid: string; +} +export default deviceInfo; diff --git a/build-tools/api/@ohos.display.d.ts b/build-tools/api/@ohos.display.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..badba14c6bc161c9d0efb7f698ad99d6a9326893 --- /dev/null +++ b/build-tools/api/@ohos.display.d.ts @@ -0,0 +1,154 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './basic'; +/** + * Interface of display manager. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ +declare namespace display { + /** + * Obtain the default display. + * @since 7 + */ + function getDefaultDisplay(callback: AsyncCallback): void; + /** + * Obtain the default display. + * @since 7 + */ + function getDefaultDisplay(): Promise; + /** + * Obtain the default display. + * @since 9 + */ + function getDefaultDisplaySync(): Display; + /** + * Obtain all displays. + * @since 7 + */ + function getAllDisplay(callback: AsyncCallback>): void; + /** + * Obtain all displays. + * @since 7 + */ + function getAllDisplay(): Promise>; + /** + * Register the callback for display changes. + * @param type: type of callback + * @since 7 + */ + function on(type: 'add' | 'remove' | 'change', callback: Callback): void; + /** + * Unregister the callback for display changes. + * @param type: type of callback + * @since 7 + */ + function off(type: 'add' | 'remove' | 'change', callback?: Callback): void; + /** + * Enumerates the display states. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + enum DisplayState { + /** + * Unknown. + */ + STATE_UNKNOWN = 0, + /** + * Screen off. + */ + STATE_OFF, + /** + * Screen on. + */ + STATE_ON, + /** + * Doze, but it will update for some important system messages. + */ + STATE_DOZE, + /** + * Doze and not update. + */ + STATE_DOZE_SUSPEND, + /** + * VR node. + */ + STATE_VR, + /** + * Screen on and not update. + */ + STATE_ON_SUSPEND + } + /** + * Define properties of the display. They cannot be updated automatically. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + interface Display { + /** + * Display ID. + */ + id: number; + /** + * Display name. + */ + name: string; + /** + * The display is alive. + */ + alive: boolean; + /** + * The state of display. + */ + state: DisplayState; + /** + * Refresh rate, in Hz. + */ + refreshRate: number; + /** + * Rotation degrees of the display. + */ + rotation: number; + /** + * Display width, in pixels. + */ + width: number; + /** + * Display height, in pixels. + */ + height: number; + /** + * Display resolution. + */ + densityDPI: number; + /** + * Display density, in pixels. The value for a low-resolution display is 1.0. + */ + densityPixels: number; + /** + * Text scale density of the display. + */ + scaledDensity: number; + /** + * DPI on the x-axis. + */ + xDPI: number; + /** + * DPI on the y-axis. + */ + yDPI: number; + } +} +export default display; diff --git a/build-tools/api/@ohos.distributedHardware.deviceManager.d.ts b/build-tools/api/@ohos.distributedHardware.deviceManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e346dce0ca19fc1bada8be52d53c52ab21a2fa65 --- /dev/null +++ b/build-tools/api/@ohos.distributedHardware.deviceManager.d.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Providers interfaces to creat a {@link deviceManager} instances. + * + * @since 7 + * @syscap SystemCapability.DistributedHardware.DeviceManager + * + */ +declare namespace deviceManager { + /** + * Device Type definitions + */ + enum DeviceType { + /** + * Indicates an unknown device type. + */ + UNKNOWN_TYPE = 0, + /** + * Indicates a speaker. + */ + SPEAKER = 0x0A, + /** + * Indicates a smartphone. + */ + PHONE = 0x0E, + /** + * Indicates a tablet. + */ + TABLET = 0x11, + /** + * Indicates a smart watch. + */ + WEARABLE = 0x6D, + /** + * Indicates a car. + */ + CAR = 0x83, + /** + * Indicates a smart TV. + */ + TV = 0x9C + } +} +export default deviceManager; diff --git a/build-tools/api/@ohos.document.d.ts b/build-tools/api/@ohos.document.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a6509d69b3ca8ed32ec2d2754365cdf91d98b45 --- /dev/null +++ b/build-tools/api/@ohos.document.d.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +export default document; +/** + * document + * @syscap SystemCapability.FileManagement.UserFileService + * @since 6 + * @import import document from '@ohos.document'; + * @permission N/A + */ +declare namespace document { + export { choose }; + export { show }; +} +/** + * choose. + * + * @note N/A + * @syscap SystemCapability.FileManagement.UserFileService + * @since 6 + * @permission N/A + * @function choose + * @param {string} type - type. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function choose(types?: string[]): Promise; +declare function choose(callback: AsyncCallback): void; +declare function choose(types: string[], callback: AsyncCallback): void; +/** + * show. + * + * @note N/A + * @syscap SystemCapability.FileManagement.UserFileService + * @since 6 + * @permission N/A + * @function show + * @param {string} uri - uri. + * @param {string} type - type. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function show(uri: string, type: string): Promise; +declare function show(uri: string, type: string, callback: AsyncCallback): void; diff --git a/build-tools/api/@ohos.effectKit.d.ts b/build-tools/api/@ohos.effectKit.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..16bf1de24543c50d6962b606aa0dd41931b99361 --- /dev/null +++ b/build-tools/api/@ohos.effectKit.d.ts @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** + * @name effectKit + * @since 9 + * @import effectKit from '@ohos.effectKit'; + */ +declare namespace effectKit { + /** + * The Filter of FilterChain. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface Filter { + /** + * A blur effect is added to the image. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param radius The degree of blur, the value is measured in pixels. + * @return Filters for the current effect have been added. + */ + blur(radius: number): Filter; + /** + * A Brightness effect is added to the image. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param bright The degree of light and darkness,the value range is 0 to 1. + * @return Filters for the current effect have been added. + */ + brightness(bright: number): Filter; + /** + * A Grayscale effect is added to the image. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @return Filters for the current effect have been added. + */ + grayscale(): Filter; + /** + * Gets the PixelMap where all filter effects have been added to the image. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @return image.PixelMap. + */ + getPixelMap(): image.PixelMap; + } + /** + * The color picker of an image. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface ColorPicker { + /** + * get main color of an image + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + getMainColor(): Promise; + /** + * get main color of an image + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + getMainColorSync(): Color; + } + /** + * The color param. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface Color { + /** + * Red + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + red: number; + /** + * Green + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + green: number; + /** + * Blue + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + blue: number; + /** + * Alpha + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + alpha: number; + } + /** + * Create a FilterChain to add multiple effects to an image. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param image.PixelMap. + * @return Returns the head node of FilterChain. + */ + function createEffect(source: image.PixelMap): Filter; + /** + * Create a color picker to get color of an image. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param image.PixelMap. + * @return Returns the ColorPicker. + */ + function createColorPicker(source: image.PixelMap): Promise; + /** + * Create a color picker to get color of an image. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param image.PixelMap. + * @return Returns the ColorPicker. + */ + function createColorPicker(source: image.PixelMap, callback: AsyncCallback): void; +} +export default effectKit; diff --git a/build-tools/api/@ohos.enterpriseDeviceManager.d.ts b/build-tools/api/@ohos.enterpriseDeviceManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b0438d1735c8092edcc163bad32e1252ff13a11 --- /dev/null +++ b/build-tools/api/@ohos.enterpriseDeviceManager.d.ts @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from "./basic"; +import { DeviceSettingsManager } from "./enterpriseDeviceManager/DeviceSettingsManager"; +/** + * enterprise device manager. + * @name enterpriseDeviceManager + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + */ +declare namespace enterpriseDeviceManager { + /** + * @name EnterpriseInfo + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + */ + export interface EnterpriseInfo { + name: string; + description: string; + } + /** + * @name AdminType + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + */ + export enum AdminType { + ADMIN_TYPE_NORMAL = 0x00, + ADMIN_TYPE_SUPER = 0x01 + } + /** + * Enables the given ability as a administrator of the device. + * + * Only apps with the ohos.permission.MANAGE_ADMIN permission or the shell uid can call this method. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @param enterpriseInfo Indicates the enterprise information of the calling application. + * @param type Indicates the type of administrator to set. + * @param userId Indicates the user ID or do not pass user ID. + * @return {@code true} if enables administrator success. + * @permission ohos.permission.MANAGE_ADMIN + */ + function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback): void; + function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback): void; + function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise; + /** + * Disables a current normal administrator ability. + * + * Only apps with the ohos.permission.MANAGE_ADMIN permission or the shell uid can call this method. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @param userId Indicates the user ID or do not pass user ID. + * @return {@code true} if disables administrator success. + * @permission ohos.permission.MANAGE_ADMIN + */ + function disableAdmin(admin: Want, callback: AsyncCallback): void; + function disableAdmin(admin: Want, userId: number, callback: AsyncCallback): void; + function disableAdmin(admin: Want, userId?: number): Promise; + /** + * Disables a current super administrator ability. + * + * Only the administrator app or apps with the shell uid can call this method. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param bundleName Indicates the administrator bundle information. + * @return {@code true} if disables super administrator success. + */ + function disableSuperAdmin(bundleName: String, callback: AsyncCallback): void; + function disableSuperAdmin(bundleName: String): Promise; + /** + * Get whether the ability is enabled as device administrator. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @param userId Indicates the user ID or do not pass user ID. + * @return {@code true} if the administrator is enabled. + */ + function isAdminEnabled(admin: Want, callback: AsyncCallback): void; + function isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback): void; + function isAdminEnabled(admin: Want, userId?: number): Promise; + /** + * Get information of the administrator's enterprise. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @return Returns the enterprise information of the administrator. + */ + function getEnterpriseInfo(admin: Want, callback: AsyncCallback): void; + function getEnterpriseInfo(admin: Want): Promise; + /** + * Set the information of the administrator's enterprise. + * + * Only the administrator app can call this method. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @param enterpriseInfo Indicates the enterprise information of the calling application. + * @return {@code true} if sets enterprise information success. + */ + function setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback): void; + function setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise; + /** + * Get whether the ability is enabled as super device administrator. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param bundleName Indicates the administrator bundle information. + * @return {@code true} if the administrator is enabled as super device administrator. + */ + function isSuperAdmin(bundleName: String, callback: AsyncCallback): void; + function isSuperAdmin(bundleName: String): Promise; + /** + * Obtains the interface used to set device settings policy. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @return Returns the DeviceSettingsManager interface. + */ + function getDeviceSettingsManager(callback: AsyncCallback): void; + function getDeviceSettingsManager(): Promise; +} +export default enterpriseDeviceManager; diff --git a/build-tools/api/@ohos.events.emitter.d.ts b/build-tools/api/@ohos.events.emitter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d94b7a5d9ad44fdeafa8b3d8968f0aec58e1aa1e --- /dev/null +++ b/build-tools/api/@ohos.events.emitter.d.ts @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Callback } from './basic'; +/** + * Provides methods for sending and processing in-process events. + * + * @since 7 + * @syscap SystemCapability.Notification.Emitter + * @import import events_emitter from '@ohos.emitter'; + * @permission N/A + */ +declare namespace emitter { + /** + * Subscribes to a certain event in persistent manner and receives the event callback. + * + * @since 7 + * @param event indicate event to subscribe to. + * @param callback indicate callback used to receive the event. + * @return - + */ + function on(event: InnerEvent, callback: Callback): void; + /** + * Subscribes to a certain event in one-shot manner and unsubscribes from it + * after the event callback is received. + * + * @since 7 + * @param event indicate event to subscribe to in one shot. + * @param callback indicate callback used to receive the event. + * @return - + */ + function once(event: InnerEvent, callback: Callback): void; + /** + * Unsubscribes from an event. + * + * @since 7 + * @param eventId indicate ID of the event to unsubscribe from. + * @return - + */ + function off(eventId: number): void; + /** + * Emits an event to the event queue. + * + * @since 7 + * @param event indicate event to emit. + * @param data indicate data carried by the event. + * @return - + */ + function emit(event: InnerEvent, data?: EventData): void; + /** + * Describes data passed in the event. + */ + export interface EventData { + /** + * Data carried by the event. + */ + data?: { + [key: string]: any; + }; + } + /** + * Describes an intra-process event. + */ + export interface InnerEvent { + /** + * Event ID, which is used to identify an event. + */ + eventId: number; + /** + * Emit priority of the event. The default priority is {@link EventPriority.LOW}. + */ + priority?: EventPriority; + } + /** + * Indicates the emit priority of the event. + */ + export enum EventPriority { + /** + * Indicates that the event will be emitted immediately. + */ + IMMEDIATE = 0, + /** + * Indicates that the event will be emitted before low-priority events. + */ + HIGH, + /** + * Indicates that the event will be emitted before idle-priority events. By default, an event is in LOW priority. + */ + LOW, + /** + * Indicates that the event will be emitted after all the other events. + */ + IDLE + } +} +export default emitter; diff --git a/build-tools/api/@ohos.faultLogger.d.ts b/build-tools/api/@ohos.faultLogger.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4ba1b6488df7e998a41a218ec9753f9290946a73 --- /dev/null +++ b/build-tools/api/@ohos.faultLogger.d.ts @@ -0,0 +1,127 @@ +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback } from "./basic"; +/** + * This module provides the capability to query faultlog data. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @import import sensor from '@ohos.faultlogger' + */ +declare namespace FaultLogger { + /** + * The type of fault type. + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + enum FaultType { + /** + * NO_SPECIFIC log type not distinguished. + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + NO_SPECIFIC = 0, + /** + * CPP_CRASH CPP crash log type + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + CPP_CRASH = 2, + /** + * JS_CRASH JS crash log type + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + JS_CRASH = 3, + /** + * APP_FREEZE app feeeze log type + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + APP_FREEZE = 4 + } + /** + * Query the result of the current application FaultLog in callback Mode + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @param faultType fault type to query + * @param callback faultlog information data callback function + */ + function querySelfFaultLog(faultType: FaultType, callback: AsyncCallback>): void; + /** + * Query the result of the current application FaultLog in return promise mode. + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @param faultType fault type to query + * @return return faultlog information data by promise + */ + function querySelfFaultLog(faultType: FaultType): Promise>; + /** + * FaultLog information data structure + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + interface FaultLogInfo { + /** + * pid Process id + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + pid: number; + /** + * uid user id + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + uid: number; + /** + * type fault type + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + type: FaultType; + /** + * second level timestamp + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + timestamp: number; + /** + * reason fault reason + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + reason: string; + /** + * module fault module + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + module: string; + /** + * summary fault summary + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + summary: string; + /** + * fullLog fault log + * @since 8 + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + */ + fullLog: string; + } +} +export default FaultLogger; diff --git a/build-tools/api/@ohos.fileio.d.ts b/build-tools/api/@ohos.fileio.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c8a76da6ef65345c79a82082f2fb29458948db3 --- /dev/null +++ b/build-tools/api/@ohos.fileio.d.ts @@ -0,0 +1,1537 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +export default fileIO; +/** + * fileio + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @import import fileio from '@ohos.fileio'; + * @permission N/A + */ +declare namespace fileIO { + export { access }; + export { accessSync }; + export { chmod }; + export { chmodSync }; + export { chown }; + export { chownSync }; + export { close }; + export { closeSync }; + export { copyFile }; + export { copyFileSync }; + export { createStream }; + export { createStreamSync }; + export { createWatcher }; + export { fchmod }; + export { fchmodSync }; + export { fchown }; + export { fchownSync }; + export { fdatasync }; + export { fdatasyncSync }; + export { fdopenStream }; + export { fdopenStreamSync }; + export { fstat }; + export { fstatSync }; + export { fsync }; + export { fsyncSync }; + export { ftruncate }; + export { ftruncateSync }; + export { hash }; + export { lchown }; + export { lchownSync }; + export { lstat }; + export { lstatSync }; + export { mkdir }; + export { mkdirSync }; + export { mkdtemp }; + export { mkdtempSync }; + export { open }; + export { openSync }; + export { opendir }; + export { opendirSync }; + export { read }; + export { readSync }; + export { readText }; + export { readTextSync }; + export { rename }; + export { renameSync }; + export { rmdir }; + export { rmdirSync }; + export { stat }; + export { statSync }; + export { symlink }; + export { symlinkSync }; + export { truncate }; + export { truncateSync }; + export { unlink }; + export { unlinkSync }; + export { write }; + export { writeSync }; + export { Dir }; + export { Dirent }; + export { ReadOut }; + export { Stat }; + export { Stream }; + export { Watcher }; +} +/** + * access. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function access + * @param {string} path - path. + * @param {number} [mode = 0] - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function access(path: string, mode?: number): Promise; +declare function access(path: string, callback: AsyncCallback): void; +declare function access(path: string, mode: number, callback: AsyncCallback): void; +/** + * accessSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function accessSync + * @param {string} path - path. + * @param {number} [mode = 0] - mode. + * @returns {void} access success + * @throws {TypedError | Error} access fail + */ +declare function accessSync(path: string, mode?: number): void; +/** + * close. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function close + * @param {number} fd - fd. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function close(fd: number): Promise; +declare function close(fd: number, callback: AsyncCallback): void; +/** + * closeSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function closeSync + * @param {number} fd - fd. + * @returns {void} close success + * @throws {TypedError | Error} close fail + */ +declare function closeSync(fd: number): void; +/** + * copyFile. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function copyFile + * @param {string | number} src - src. + * @param {string | number} dest - dest. + * @param {number} [mode = 0] - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function copyFile(src: string | number, dest: string | number, mode?: number): Promise; +declare function copyFile(src: string | number, dest: string | number, callback: AsyncCallback): void; +declare function copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback): void; +/** + * copyFileSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function copyFileSync + * @param {string | number} src - src. + * @param {string | number} dest - dest. + * @param {number} [mode = 0] - mode. + * @returns {void} copyFile success + * @throws {TypedError | Error} copyFile fail + */ +declare function copyFileSync(src: string | number, dest: string | number, mode?: number): void; +/** + * createStream. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function createStream + * @param {string} path - path. + * @param {string} mode - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return Stream + * @throws {TypedError} Parameter check failed + */ +declare function createStream(path: string, mode: string): Promise; +declare function createStream(path: string, mode: string, callback: AsyncCallback): void; +/** + * createStreamSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function createStreamSync + * @param {string} path - path. + * @param {string} mode - mode. + * @returns {Stream} createStream + * @throws {TypedError} Parameter check failed + */ +declare function createStreamSync(path: string, mode: string): Stream; +/** + * chown. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function appendFile + * @param {string} path - path. + * @param {number} uid - mode. + * @param {number} gid - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function chown(path: string, uid: number, gid: number): Promise; +declare function chown(path: string, uid: number, gid: number, callback: AsyncCallback): void; +/** + * chownSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function appendFile + * @param {string} path - path. + * @param {number} uid - mode. + * @param {number} gid - mode. + * @returns {void} chown success + * @throws {TypedError | Error} chown fail + */ +declare function chownSync(path: string, uid: number, gid: number): void; +/** + * chmod. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function chmod + * @param {string} path - path. + * @param {number} mode - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function chmod(path: string, mode: number): Promise; +declare function chmod(path: string, mode: number, callback: AsyncCallback): void; +/** + * chmodSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function chmodSync + * @param {string} path - path. + * @param {number} mode - mode. + * @returns {void} chmod success + * @throws {TypedError | Error} chmod fail + */ +declare function chmodSync(path: string, mode: number): void; +/** + * ftruncate. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function ftruncate + * @param {number} fd - fd. + * @param {number} [len = 0] - len. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function ftruncate(fd: number, len?: number): Promise; +declare function ftruncate(fd: number, callback: AsyncCallback): void; +declare function ftruncate(fd: number, len: number, callback: AsyncCallback): void; +/** + * ftruncateSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function ftruncateSync + * @param {number} fd - fd. + * @param {number} [len = 0] - len. + * @returns {void} ftruncate success + * @throws {TypedError | Error} ftruncate fail + */ +declare function ftruncateSync(fd: number, len?: number): void; +/** + * fsync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fsync + * @param {number} fd - fd. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function fsync(fd: number): Promise; +declare function fsync(fd: number, callback: AsyncCallback): void; +/** + * fsyncSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fsyncSync + * @param {number} fd - fd. + * @returns {void} fsync success + * @throws {TypedError | Error} fsync fail + */ +declare function fsyncSync(fd: number): void; +/** + * fstat. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fstat + * @param {number} fd - fd. + * @returns {Stat} + * @throws {TypedError | Error} fstat fail + */ +declare function fstat(fd: number): Promise; +declare function fstat(fd: number, callback: AsyncCallback): void; +/** + * fstatSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fstatSync + * @param {number} fd - fd. + * @returns {Stat} + * @throws {TypedError | Error} fstat fail + */ +declare function fstatSync(fd: number): Stat; +/** + * fdatasync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fdatasync + * @param {number} fd - fd. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function fdatasync(fd: number): Promise; +declare function fdatasync(fd: number, callback: AsyncCallback): void; +/** + * fdatasyncSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fdatasyncSync + * @param {number} fd - fd. + * @returns {void} fdatasync success + * @throws {TypedError | Error} fdatasync fail + */ +declare function fdatasyncSync(fd: number): void; +/** + * fchown. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fchown + * @param {number} fd - fd. + * @param {number} uid - uid. + * @param {number} gid - gid. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function fchown(fd: number, uid: number, gid: number): Promise; +declare function fchown(fd: number, uid: number, gid: number, callback: AsyncCallback): void; +/** + * fchownSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fchownSync + * @param {number} fd - fd. + * @param {number} uid - uid. + * @param {number} gid - gid. + * @returns {void} fchown success + * @throws {TypedError | Error} fchown fail + */ +declare function fchownSync(fd: number, uid: number, gid: number): void; +/** + * fchmod. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fchmod + * @param {number} fd - fd. + * @param {number} mode - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function fchmod(fd: number, mode: number): Promise; +declare function fchmod(fd: number, mode: number, callback: AsyncCallback): void; +/** + * fchmodSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fchmodSync + * @param {number} fd - fd. + * @param {number} mode - mode. + * @returns {void} fchmod success + * @throws {TypedError | Error} fchmod fail + */ +declare function fchmodSync(fd: number, mode: number): void; +/** + * fdopenStream. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fdopenStream + * @param {number} fd - fd. + * @param {string} mode - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function fdopenStream(fd: number, mode: string): Promise; +declare function fdopenStream(fd: number, mode: string, callback: AsyncCallback): void; +/** + * fdopenStreamSync. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fdopenStreamSync + * @param {number} fd - fd. + * @param {string} mode - mode. + * @returns {Stream} open stream from fd + * @throws {TypedError | Error} open fail + */ +declare function fdopenStreamSync(fd: number, mode: string): Stream; +/** +* hash. +* @static +* @note N/A +* @syscap SystemCapability.FileManagement.File.FileIO +* @since 6 +* @permission N/A +* @function hash +* @param {string} path - path. +* @param {string} algorithm - algorithm md5 sha1 sha256. +* @param {AsyncCallback} [callback] - callback. +* @returns {void | Promise} no callback return Promise otherwise return void +* @throws {TypedError} Parameter check failed +*/ +declare function hash(path: string, algorithm: string): Promise; +declare function hash(path: string, algorithm: string, callback: AsyncCallback): void; +/** + * lchown. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function lchown + * @param {string} path - path. + * @param {number} uid - uid. + * @param {number} gid - gid. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function lchown(path: string, uid: number, gid: number): Promise; +declare function lchown(path: string, uid: number, gid: number, callback: AsyncCallback): void; +/** + * lchownSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function lchownSync + * @param {string} path - path. + * @param {number} uid - uid. + * @param {number} gid - gid. + * @returns {void} lchown success + * @throws {TypedError | Error} lchown fail + */ +declare function lchownSync(path: string, uid: number, gid: number): void; +/** + * lstat. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function lstat + * @param {string} path - path. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function lstat(path: string): Promise; +declare function lstat(path: string, callback: AsyncCallback): void; +/** + * lstatSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function lstatSync + * @param {string} path - path. + * @returns {Stat} lstat success + * @throws {TypedError | Error} lstat fail + */ +declare function lstatSync(path: string): Stat; +/** + * mkdir. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function mkdir + * @param {string} path - path. + * @param {number} [mode = 0o775] - path. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function mkdir(path: string, mode?: number): Promise; +declare function mkdir(path: string, callback: AsyncCallback): void; +declare function mkdir(path: string, mode: number, callback: AsyncCallback): void; +/** + * mkdirSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function mkdirSync + * @param {string} path - path. + * @param {number} [mode = 0o775] - path. + * @returns {void} mkdir success + * @throws {TypedError | Error} mkdir fail + */ +declare function mkdirSync(path: string, mode?: number): void; +/** + * mkdtemp. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function mkdtemp + * @param {string} prefix - dir prefix. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function mkdtemp(prefix: string): Promise; +declare function mkdtemp(prefix: string, callback: AsyncCallback): void; +/** + * mkdtempSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function mkdtempSync + * @param {string} prefix - dir prefix. + * @returns {string} directory name + * @throws {TypedError | Error} mkdtemp fail + */ +declare function mkdtempSync(prefix: string): string; +/** + * open. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function open + * @param {string} path - path. + * @param {number} [flags = 0] - flags. + * @param {number} [mode = 0o666] - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function open(path: string, flags?: number, mode?: number): Promise; +declare function open(path: string, callback: AsyncCallback): void; +declare function open(path: string, flags: number, callback: AsyncCallback): void; +declare function open(path: string, flags: number, mode: number, callback: AsyncCallback): void; +/** + * openSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function openSync + * @param {string} path - path. + * @param {number} [flags = 0] - flags. + * @param {number} [mode = 0o666] - mode. + * @returns {number} open fd + * @throws {TypedError | Error} open fail + */ +declare function openSync(path: string, flags?: number, mode?: number): number; +/** + * opendir. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function opendir + * @param {string} path - directory name. + * @param {AsyncCallback

} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function opendir(path: string): Promise; +declare function opendir(path: string, callback: AsyncCallback): void; +/** + * opendirSync. + * + * @param {string} path - directory name. + * @returns {Dir} opendir Dir Object + * @throws {TypedError | Error} opendir fail + */ +declare function opendirSync(path: string): Dir; +/** + * readText. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function readText + * @param {string} filePath - file path. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset in bytes. + * @param {number} [options.length = -1] - length in bytes. + * @param {number} [options.encoding = 'utf-8'] - encoding. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function readText(filePath: string, options?: { + position?: number; + length?: number; + encoding?: string; +}): Promise; +declare function readText(filePath: string, options: { + position?: number; + length?: number; + encoding?: string; +}, callback: AsyncCallback): void; +/** + * readTextSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function readTextSync + * @param {string} filePath - file path. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset in bytes. + * @param {number} [options.length = -1] - length in bytes. + * @param {number} [options.encoding = 'utf-8'] - encoding. + * @returns {string} readout result + * @throws {TypedError} Parameter check failed + */ +declare function readTextSync(filePath: string, options?: { + position?: number; + length?: number; + encoding?: string; +}): string; +/** + * read. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function read + * @param {number} fd - file descriptor. + * @param {ArrayBuffer} buffer - file descriptor. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.length = -1] - length. + * @param {number} [options.position = -1] - position. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function read(fd: number, buffer: ArrayBuffer, options?: { + offset?: number; + length?: number; + position?: number; +}): Promise; +declare function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback): void; +declare function read(fd: number, buffer: ArrayBuffer, options: { + offset?: number; + length?: number; + position?: number; +}, callback: AsyncCallback): void; +/** + * readSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function readSync + * @param {number} fd - file descriptor. + * @param {ArrayBuffer} buffer - file descriptor. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.length = -1] - length. + * @param {number} [options.position = -1] - position. + * @returns {number} number of bytesRead + * @throws {TypedError | Error} read fail + */ +declare function readSync(fd: number, buffer: ArrayBuffer, options?: { + offset?: number; + length?: number; + position?: number; +}): number; +/** + * rename. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function rename + * @param {string} oldPath - oldPath. + * @param {string} newPath - newPath. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function rename(oldPath: string, newPath: string): Promise; +declare function rename(oldPath: string, newPath: string, callback: AsyncCallback): void; +/** + * renameSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function renameSync + * @param {string} oldPath - oldPath. + * @param {string} newPath - newPath. + * @returns {void} rename success + * @throws {TypedError | Error} rename fail + */ +declare function renameSync(oldPath: string, newPath: string): void; +/** + * rmdir. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function rmdir + * @param {string} path - path. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function rmdir(path: string): Promise; +declare function rmdir(path: string, callback: AsyncCallback): void; +/** + * rmdirSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function rmdirSync + * @param {string} path - path. + * @returns {void} rmdir success + * @throws {TypedError | Error} rmdir fail + */ +declare function rmdirSync(path: string): void; +/** + * stat. + * @static + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @param {string} path - path. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function stat(path: string): Promise; +declare function stat(path: string, callback: AsyncCallback): void; +/** + * statSync. + * @static + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @param {string} path - path. + * @returns {Stat} stat success + * @throws {TypedError | Error} stat fail + */ +declare function statSync(path: string): Stat; +/** + * symlink. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function symlink + * @param {string} target - target. + * @param {string} srcPath - srcPath. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function symlink(target: string, srcPath: string): Promise; +declare function symlink(target: string, srcPath: string, callback: AsyncCallback): void; +/** + * symlinkSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function symlinkSync + * @param {string} target - target. + * @param {string} srcPath - srcPath. + * @returns {void} symlink success + * @throws {TypedError | Error} symlink fail + */ +declare function symlinkSync(target: string, srcPath: string): void; +/** +* truncate. +* +* @note N/A +* @syscap SystemCapability.FileManagement.File.FileIO +* @since 7 +* @permission N/A +* @function truncate +* @param {string} path - path. +* @param {number} [len = 0] - len. +* @param {AsyncCallback} [callback] - callback. +* @returns {void | Promise} no callback return Promise otherwise return void +* @throws {TypedError} Parameter check failed +*/ +declare function truncate(path: string, len?: number): Promise; +declare function truncate(path: string, callback: AsyncCallback): void; +declare function truncate(path: string, len: number, callback: AsyncCallback): void; +/** + * truncateSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function truncateSync + * @param {string} path - path. + * @param {number} [len = 0] - len. + * @returns {void} truncate success + * @throws {TypedError | Error} truncate fail + */ +declare function truncateSync(path: string, len?: number): void; +/** + * unlink. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function unlink + * @param {string} path - path. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function unlink(path: string): Promise; +declare function unlink(path: string, callback: AsyncCallback): void; +/** + * unlinkSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function unlinkSync + * @param {string} path - path. + * @returns {void} unlink success + * @throws {TypedError | Error} unlink fail + */ +declare function unlinkSync(path: string): void; +/** + * write. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function write + * @param {number} fd - file descriptor. + * @param {ArrayBuffer | string} buffer - file descriptor. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. + * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. + * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. + * @param {string} [options.encoding = 'utf-8'] - encoding. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError | RangeError} Parameter check failed + */ +declare function write(fd: number, buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + position?: number; + encoding?: string; +}): Promise; +declare function write(fd: number, buffer: ArrayBuffer | string, callback: AsyncCallback): void; +declare function write(fd: number, buffer: ArrayBuffer | string, options: { + offset?: number; + length?: number; + position?: number; + encoding?: string; +}, callback: AsyncCallback): void; +/** + * writeSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function writeSync + * @param {number} fd - file descriptor. + * @param {ArrayBuffer | string} buffer - file descriptor. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. + * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. + * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. + * @param {string} [options.encoding = 'utf-8'] - encoding. + * @returns {number} on success number of bytesRead + * @throws {TypedError | RangeError | Error} write fail + */ +declare function writeSync(fd: number, buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + position?: number; + encoding?: string; +}): number; +/** + * createWatcher. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function createWatcher + * @param {string} filename - filename. + * @param {number} events - events(depends on OS & filesystem) events = 1 rename events =2 change. + * @param {AsyncCallback} [callback] - callback. + * @returns {Watcher} watch success + * @throws {TypedError | Error} watch fail + */ +declare function createWatcher(filename: string, events: number, callback: AsyncCallback): Watcher; +/** + * Dir + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ +declare interface Dir { + /** + * read. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function read + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed if read to end, Error.msg = "NoMore" + */ + read(): Promise; + read(callback: AsyncCallback): void; + /** + * readSync. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function readSync + * @returns {Dirent} Dirent Object + * @throws {TypedError | Error} read fail if read to end, Error.msg = "NoMore" + */ + readSync(): Dirent; + /** + * close. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function close + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} close success + * @throws {TypedError | Error} close fail + */ + close(): Promise; + close(callback: AsyncCallback): void; + /** + * closeSync. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function closeSync + * @returns {void} close success + * @throws {TypedError | Error} close fail + */ + closeSync(): void; +} +/** + * Dirent + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ +declare interface Dirent { + /** + * @type {string} + * @readonly + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ + readonly name: string; + /** + * isBlockDevice. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isBlockDevice(): boolean; + /** + * isCharacterDevice. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isCharacterDevice(): boolean; + /** + * isDirectory. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isDirectory(): boolean; + /** + * isFIFO. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isFIFO(): boolean; + /** + * isFile. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isFile(): boolean; + /** + * isSocket. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isSocket(): boolean; + /** + * isSymbolicLink. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isSymbolicLink(): boolean; +} +/** + * Stat + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ +declare interface Stat { + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly dev: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly ino: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly mode: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly nlink: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly uid: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly gid: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly rdev: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly size: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly blocks: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly atime: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly mtime: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly ctime: number; + /** + * isBlockDevice. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isBlockDevice(): boolean; + /** + * isCharacterDevice. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isCharacterDevice(): boolean; + /** + * isDirectory. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isDirectory(): boolean; + /** + * isFIFO. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isFIFO(): boolean; + /** + * isFile. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isFile(): boolean; + /** + * isSocket. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isSocket(): boolean; + /** + * isSymbolicLink. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isSymbolicLink(): boolean; +} +/** + * Stream + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ +declare interface Stream { + /** + * close. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} close success + * @throws {TypedError | Error} close fail + */ + close(): Promise; + close(callback: AsyncCallback): void; + /** + * closeSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {void} close success + * @throws {TypedError | Error} close fail + */ + closeSync(): void; + /** + * flush. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ + flush(): Promise; + flush(callback: AsyncCallback): void; + /** + * flushSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @returns {void} flush success + * @throws {Error} flush fail + */ + flushSync(): void; + /** + * write. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {ArrayBuffer | string} buffer - file description. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. + * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. + * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. + * @param {string} [options.encoding = 'utf-8'] - encoding. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ + write(buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + position?: number; + encoding?: string; + }): Promise; + write(buffer: ArrayBuffer | string, callback: AsyncCallback): void; + write(buffer: ArrayBuffer | string, options: { + offset?: number; + length?: number; + position?: number; + encoding?: string; + }, callback: AsyncCallback): void; + /** + * writeSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {ArrayBuffer | string} buffer - file description. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. + * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. + * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. + * @param {string} [options.encoding = 'utf-8'] - encoding. + * @returns {number} on success number of bytes written + * @throws {TypedError | Error} write fail + */ + writeSync(buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + position?: number; + encoding?: string; + }): number; + /** + * read. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {ArrayBuffer} buffer - file description. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.length = -1] - length. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ + read(buffer: ArrayBuffer, options?: { + position?: number; + offset?: number; + length?: number; + }): Promise; + read(buffer: ArrayBuffer, callback: AsyncCallback): void; + read(buffer: ArrayBuffer, options: { + position?: number; + offset?: number; + length?: number; + }, callback: AsyncCallback): void; + /** + * readSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {ArrayBuffer} buffer - file description. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.length = -1] - length. + * @returns {number} number of bytesRead + * @throws {TypedError | Error} read fail + */ + readSync(buffer: ArrayBuffer, options?: { + position?: number; + offset?: number; + length?: number; + }): number; +} +/** + * ReadOut + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ +declare interface ReadOut { + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + bytesRead: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + offset: number; + /** + * @type {ArrayBuffer} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + buffer: ArrayBuffer; +} +/** + * Watcher + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + */ +declare interface Watcher { + /** + * stop. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} stop success + * @throws {TypedError | Error} stop fail + */ + stop(): Promise; + stop(callback: AsyncCallback): void; +} diff --git a/build-tools/api/@ohos.geolocation.d.ts b/build-tools/api/@ohos.geolocation.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d473b82debeb38d6467ffcfaa598c72b2247df2f --- /dev/null +++ b/build-tools/api/@ohos.geolocation.d.ts @@ -0,0 +1,679 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import WantAgent from '@ohos.wantAgent'; +/** +* Provides interfaces for initiating location requests, ending the location service, +* and obtaining the location result cached by the system. +* +* @since 7 +* @syscap SystemCapability.Location.Location.Core +* @import import geolocation from '@ohos.geolocation' +* @permission ohos.permission.LOCATION +*/ +declare namespace geolocation { + /** + * subscribe location changed + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param request Indicates the location request parameters. + * @param callback Indicates the callback for reporting the location result. + */ + function on(type: 'locationChange', request: LocationRequest, callback: Callback): void; + /** + * unsubscribe location changed + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the location result. + */ + function off(type: 'locationChange', callback?: Callback): void; + /** + * subscribe location switch changed + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the location result. + */ + function on(type: 'locationServiceState', callback: Callback): void; + /** + * unsubscribe location switch changed + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the location result. + */ + function off(type: 'locationServiceState', callback?: Callback): void; + /** + * subscribe to cache GNSS locations update messages + * + * @since 8 + * @syscap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param request Indicates the cached GNSS locations request parameters. + * @param callback Indicates the callback for reporting the cached GNSS locations. + */ + function on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback>): void; + /** + * unsubscribe to cache GNSS locations update messages + * + * @since 8 + * @syscap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the cached gnss locations. + */ + function off(type: 'cachedGnssLocationsReporting', callback?: Callback>): void; + /** + * subscribe gnss status changed + * + * @since 8 + * @syscap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the gnss status change. + */ + function on(type: 'gnssStatusChange', callback: Callback): void; + /** + * unsubscribe gnss status changed + * + * @since 8 + * @syscap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the gnss status change. + */ + function off(type: 'gnssStatusChange', callback?: Callback): void; + /** + * subscribe nmea message changed + * + * @since 8 + * @syscap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the nmea message. + */ + function on(type: 'nmeaMessageChange', callback: Callback): void; + /** + * unsubscribe nmea message changed + * + * @since 8 + * @syscap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the nmea message. + */ + function off(type: 'nmeaMessageChange', callback?: Callback): void; + /** + * add a geofence and subscribe geo fence status changed + * + * @since 8 + * @syscap SystemCapability.Location.Location.Geofence + * @permission ohos.permission.LOCATION + * @param request Indicates the Geo-fence configuration parameters. + * @param callback Indicates the callback for reporting the fence status. + */ + function on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; + /** + * remove a geofence and unsubscribe geo fence status changed + * + * @since 8 + * @syscap SystemCapability.Location.Location.Geofence + * @permission ohos.permission.LOCATION + * @param request Indicates the Geo-fence configuration parameters. + * @param callback Indicates the callback for reporting the remove fence result. + */ + function off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; + /** + * registering the callback function for listening to country code changes. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @param callback Indicates the callback for reporting country code changes. + */ + function on(type: 'countryCodeChange', callback: Callback): void; + /** + * unregistering the callback function for listening to country code changes. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @param callback Indicates the callback for reporting country code changes. + */ + function off(type: 'countryCodeChange', callback?: Callback): void; + /** + * obtain current location + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the location result. + */ + function getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback): void; + function getCurrentLocation(callback: AsyncCallback): void; + function getCurrentLocation(request?: CurrentLocationRequest): Promise; + /** + * obtain last known location + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the location result. + */ + function getLastLocation(callback: AsyncCallback): void; + function getLastLocation(): Promise; + /** + * obtain current location switch status + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the location switch result. + */ + function isLocationEnabled(callback: AsyncCallback): void; + function isLocationEnabled(): Promise; + /** + * request enable location + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the location switch status. + */ + function requestEnableLocation(callback: AsyncCallback): void; + function requestEnableLocation(): Promise; + /** + * obtain address info from location + * + * @since 7 + * @syscap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the address info. + */ + function getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback>): void; + function getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise>; + /** + * obtain latitude and longitude info from location address + * + * @since 7 + * @syscap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the latitude and longitude result. + */ + function getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback>): void; + function getAddressesFromLocationName(request: GeoCodeRequest): Promise>; + /** + * obtain geocode service status + * + * @since 7 + * @syscap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the geocode service status. + */ + function isGeoServiceAvailable(callback: AsyncCallback): void; + function isGeoServiceAvailable(): Promise; + /** + * obtain the number of cached GNSS locations reported at a time + * + * @since 8 + * @syscap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the cached GNSS locations size. + */ + function getCachedGnssLocationsSize(callback: AsyncCallback): void; + function getCachedGnssLocationsSize(): Promise; + /** + * all prepared GNSS locations are returned to the application through the callback function, + * and the bottom-layer buffer is cleared. + * + * @since 8 + * @syscap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + * @param callback Indicates the callback for reporting the result. + */ + function flushCachedGnssLocations(callback: AsyncCallback): void; + function flushCachedGnssLocations(): Promise; + /** + * send extended commands to location subsystem. + * + * @since 8 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + * @param command Indicates the extended Command Message Body. + * @param callback Indicates the callback for reporting the send command result. + */ + function sendCommand(command: LocationCommand, callback: AsyncCallback): void; + function sendCommand(command: LocationCommand): Promise; + /** + * obtain the current country code. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @param callback Indicates the callback for reporting the country code. + */ + function getCountryCode(callback: AsyncCallback): void; + function getCountryCode(): Promise; + /** + * satellite status information + * + * @since 8 + * @syscap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + */ + export interface SatelliteStatusInfo { + satellitesNumber: number; + satelliteIds: Array; + carrierToNoiseDensitys: Array; + altitudes: Array; + azimuths: Array; + carrierFrequencies: Array; + } + /** + * parameters for requesting to report cache location information + * + * @since 8 + * @syscap SystemCapability.Location.Location.Gnss + * @permission ohos.permission.LOCATION + */ + export interface CachedGnssLocationsRequest { + reportingPeriodSec: number; + wakeUpCacheQueueFull: boolean; + } + /** + * configuring parameters in geo fence requests + * + * @since 8 + * @syscap SystemCapability.Location.Location.Geofence + * @permission ohos.permission.LOCATION + */ + export interface GeofenceRequest { + priority: LocationRequestPriority; + scenario: LocationRequestScenario; + geofence: Geofence; + } + /** + * configuring parameters in geo fence requests + * + * @since 8 + * @syscap SystemCapability.Location.Location.Geofence + * @permission ohos.permission.LOCATION + */ + export interface Geofence { + latitude: number; + longitude: number; + radius: number; + expiration: number; + } + /** + * configuring parameters in reverse geocode requests + * + * @since 7 + * @syscap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION + */ + export interface ReverseGeoCodeRequest { + locale?: string; + latitude: number; + longitude: number; + maxItems?: number; + } + /** + * configuring parameters in geocode requests + * + * @since 7 + * @syscap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION + */ + export interface GeoCodeRequest { + locale?: string; + description: string; + maxItems?: number; + minLatitude?: number; + minLongitude?: number; + maxLatitude?: number; + maxLongitude?: number; + } + /** + * data struct describes geographic locations. + * + * @since 7 + * @syscap SystemCapability.Location.Location.Geocoder + * @permission ohos.permission.LOCATION + */ + export interface GeoAddress { + /** + * Indicates latitude information. + * A positive value indicates north latitude, + * and a negative value indicates south latitude. + * @since 7 + */ + latitude?: number; + /** + * Indicates longitude information. + * A positive value indicates east longitude , + * and a negative value indicates west longitude . + * @since 7 + */ + longitude?: number; + /** + * Indicates language used for the location description. + * zh indicates Chinese, and en indicates English. + * @since 7 + */ + locale?: string; + /** + * Indicates landmark of the location. + * @since 7 + */ + placeName?: string; + /** + * Indicates country code. + * @since 7 + */ + countryCode?: string; + /** + * Indicates country name. + * @since 7 + */ + countryName?: string; + /** + * Indicates administrative region name. + * @since 7 + */ + administrativeArea?: string; + /** + * Indicates sub-administrative region name. + * @since 7 + */ + subAdministrativeArea?: string; + /** + * Indicates locality information. + * @since 7 + */ + locality?: string; + /** + * Indicates sub-locality information. + * @since 7 + */ + subLocality?: string; + /** + * Indicates road name. + * @since 7 + */ + roadName?: string; + /** + * Indicates auxiliary road information. + * @since 7 + */ + subRoadName?: string; + /** + * Indicates house information. + * @since 7 + */ + premises?: string; + /** + * Indicates postal code. + * @since 7 + */ + postalCode?: string; + /** + * Indicates phone number. + * @since 7 + */ + phoneNumber?: string; + /** + * Indicates website URL. + * @since 7 + */ + addressUrl?: string; + /** + * Indicates additional information. + * @since 7 + */ + descriptions?: Array; + /** + * Indicates the amount of additional descriptive information. + * @since 7 + */ + descriptionsSize?: number; + /** + * Indicates whether it is an mock GeoAddress + * @since 9 + */ + isFromMock: Boolean; + } + /** + * configuring parameters in location requests + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + */ + export interface LocationRequest { + priority?: LocationRequestPriority; + scenario?: LocationRequestScenario; + timeInterval?: number; + distanceInterval?: number; + maxAccuracy?: number; + } + /** + * configuring parameters in current location requests + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + */ + export interface CurrentLocationRequest { + priority?: LocationRequestPriority; + scenario?: LocationRequestScenario; + maxAccuracy?: number; + timeoutMs?: number; + } + /** + * provides information about geographic locations + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + */ + export interface Location { + /** + * Indicates latitude information. + * A positive value indicates north latitude, + * and a negative value indicates south latitude. + * @since 7 + */ + latitude: number; + /** + * Indicates Longitude information. + * A positive value indicates east longitude , + * and a negative value indicates west longitude . + * @since 7 + */ + longitude: number; + /** + * Indicates location altitude, in meters. + * @since 7 + */ + altitude: number; + /** + * Indicates location accuracy, in meters. + * @since 7 + */ + accuracy: number; + /** + * Indicates speed, in m/s. + * @since 7 + */ + speed: number; + /** + * Indicates location timestamp in the UTC format. + * @since 7 + */ + timeStamp: number; + /** + * Indicates direction information. + * @since 7 + */ + direction: number; + /** + * Indicates location timestamp since boot. + * @since 7 + */ + timeSinceBoot: number; + /** + * Indicates additional information. + * @since 7 + */ + additions?: Array; + /** + * Indicates the amount of additional descriptive information. + * @since 7 + */ + additionSize?: number; + /** + * Indicates whether it is an mock location. + * @since 9 + */ + isFromMock: Boolean; + } + /** + * enum for location priority + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + */ + export enum LocationRequestPriority { + UNSET = 0x200, + ACCURACY, + LOW_POWER, + FIRST_FIX + } + /** + * enum for location scenario + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + */ + export enum LocationRequestScenario { + UNSET = 0x300, + NAVIGATION, + TRAJECTORY_TRACKING, + CAR_HAILING, + DAILY_LIFE_SERVICE, + NO_POWER + } + /** + * enum for error code + * + * @since 7 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + */ + export enum GeoLocationErrorCode { + /** + * Indicates function not supported. + * @since 9 + */ + NOT_SUPPORTED = 100, + /** + * Indicates input parameter error. + * @since 7 + */ + INPUT_PARAMS_ERROR, + /** + * Indicates reverse geocode query failed. + * @since 7 + */ + REVERSE_GEOCODE_ERROR, + /** + * Indicates geocode query failed. + * @since 7 + */ + GEOCODE_ERROR, + /** + * Indicates positioning failed. + * @since 7 + */ + LOCATOR_ERROR, + /** + * Indicates operation failure caused by abnormal location switch. + * @since 7 + */ + LOCATION_SWITCH_ERROR, + /** + * Indicates failed to get the last known location. + * @since 7 + */ + LAST_KNOWN_LOCATION_ERROR, + /** + * Indicates location request timeout. + * @since 7 + */ + LOCATION_REQUEST_TIMEOUT_ERROR, + /** + * Indicates country code query failed. + * @since 9 + */ + QUERY_COUNTRY_CODE_ERROR + } + /** + * enum for location privacy type + * + * @since 8 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + */ + export enum LocationPrivacyType { + OTHERS = 0, + STARTUP, + CORE_LOCATION + } + /** + * Location subsystem command structure + * + * @since 8 + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.LOCATION + */ + export interface LocationCommand { + scenario: LocationRequestScenario; + command: string; + } + /** + * country code structure + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + export interface CountryCode { + country: string; + type: CountryCodeType; + } + /** + * enum for country code type + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + export enum CountryCodeType { + COUNTRY_CODE_FROM_LOCALE = 1, + COUNTRY_CODE_FROM_SIM, + COUNTRY_CODE_FROM_LOCATION, + COUNTRY_CODE_FROM_NETWORK + } +} +export default geolocation; diff --git a/build-tools/api/@ohos.hiAppEvent.d.ts b/build-tools/api/@ohos.hiAppEvent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a6e7cb72b6eed3c481e3423c8257e9d18e0236d2 --- /dev/null +++ b/build-tools/api/@ohos.hiAppEvent.d.ts @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * Provides the event logging function for applications to log the fault, statistical, security, + * and user behavior events reported during running. Based on event information, + * you will be able to analyze the running status of applications. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ +declare namespace hiAppEvent { + /** + * Enumerate application event types. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + enum EventType { + /** + * Fault event. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + FAULT = 1, + /** + * Statistic event. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + STATISTIC = 2, + /** + * Security event. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + SECURITY = 3, + /** + * User behavior event. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + BEHAVIOR = 4 + } + /** + * Preset event. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + namespace Event { + /** + * user login event. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const USER_LOGIN: string; + /** + * user logout event. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const USER_LOGOUT: string; + /** + * distributed service event. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const DISTRIBUTED_SERVICE_START: string; + } + /** + * Preset param. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + namespace Param { + /** + * user id. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const USER_ID: string; + /** + * distributed service name. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const DISTRIBUTED_SERVICE_NAME: string; + /** + * distributed service instance id. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const DISTRIBUTED_SERVICE_INSTANCE_ID: string; + } + /** + * write application event. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + * @param {string} eventName application event name. + * @param {EventType} eventType application event type. + * @param {object} keyValues application event key-value pair params. + * @param {AsyncCallback} [callback] callback function. + * @return {void | Promise} no callback return Promise otherwise return void. + */ + function write(eventName: string, eventType: EventType, keyValues: object): Promise; + function write(eventName: string, eventType: EventType, keyValues: object, callback: AsyncCallback): void; + /** + * application event logging configuration interface. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + * @param {ConfigOption} config application event logging configuration item object. + * @return {boolean} configuration result. + */ + function configure(config: ConfigOption): boolean; + /** + * Describe the options for the configuration. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface ConfigOption { + /** + * configuration item: application event logging switch. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + disable?: boolean; + /** + * configuration item: event file directory storage quota size. + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + maxStorage?: string; + } +} +export default hiAppEvent; diff --git a/build-tools/api/@ohos.hiTraceChain.d.ts b/build-tools/api/@ohos.hiTraceChain.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d1e398da5878022bfe5d95bbefbd3f934e08c2b7 --- /dev/null +++ b/build-tools/api/@ohos.hiTraceChain.d.ts @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides APIs to implement call chain tracing throughout a service process. + * With HiTrace, you can quickly obtain the run log for the call chain of a + * specified service process and locate faults in cross-device, cross-process, + * or cross-thread communications. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + */ +declare namespace hiTraceChain { + /** + * Enumerate trace flag + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + */ + enum HiTraceFlag { + /** + * default value + */ + DEFAULT = 0, + /** + * trace sync and async call. default: trace sync call only. + */ + INCLUDE_ASYNC = 1, + /** + * do not create child span. default: create child span. + */ + DONOT_CREATE_SPAN = 1 << 1, + /** + * output tracepoint info in span. default: do not output tracepoint info. + */ + TP_INFO = 1 << 2, + /** + * do not output begin and end info. default: output begin and end info. + */ + NO_BE_INFO = 1 << 3, + /** + * do not add id to log. default: add id to log. + */ + DISABLE_LOG = 1 << 4, + /** + * the trace is triggered by fault. + */ + FAILURE_TRIGGER = 1 << 5, + /** + * output device-to-device tracepoint info in span only. default: do not output device-to-device tracepoint info. + */ + D2D_TP_INFO = 1 << 6 + } + /** + * Enumerate trace point type + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + */ + enum HiTraceTracepointType { + /** + * client send + */ + CS = 0, + /** + * client receive + */ + CR = 1, + /** + * server send + */ + SS = 2, + /** + * server receive + */ + SR = 3, + /** + * general info + */ + GENERAL = 4 + } + /** + * Enumerate trace communication mode + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + */ + enum HiTraceCommunicationMode { + /** + * unspecified + */ + DEFAULT = 0, + /** + * thread-to-thread + */ + THREAD = 1, + /** + * process-to-process + */ + PROCESS = 2, + /** + * device-to-device + */ + DEVICE = 3 + } + /** + * Trace id, for tracing process. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + */ + interface HiTraceId { + chainId: bigint; /* 0n: invalid */ + spanId?: number; + parentSpanId?: number; + flags?: number; + } + /** + * Start tracing a process impl. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param {string} name Process name. + * @param {number} flags Trace function flag. + * @return {HiTraceId} Valid if first call, otherwise invalid. + */ + function begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId; + /** + * Stop process tracing and clear trace id of current thread if the given trace + * id is valid, otherwise do nothing. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceId} id The trace id that need to stop. + */ + function end(id: HiTraceId): void; + /** + * Get trace id of current thread, and return a invalid trace id if no + * trace id belong to current thread + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @return {HiTraceId} Valid if current thread have a trace id, otherwise invalid. + */ + function getId(): HiTraceId; + /** + * Set id as trace id of current thread. Do nothing if id is invalid. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceId} id Set id as trace id of current thread. + */ + function setId(id: HiTraceId): void; + /** + * Clear trace id of current thread and set it invalid. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + */ + function clearId(): void; + /** + * Create a new span id according to the trace id of current thread. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @return {HiTraceId} A valid span trace id. Otherwise trace id of current thread if do not allow create span. + */ + function createSpan(): HiTraceId; + /** + * Print hitrace info, include trace id info. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceCommunicationMode} mode Trace communication mode. + * @param {HiTraceTracepointType} type Trace info type. + * @param {HiTraceId} id Trace id that need to print. + * @param {string} msg Customized info that need to print. + */ + function tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTraceId, msg?: string): void; + /** + * Judge whether the trace id is valid or not. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceId} id Trace id that need to judge. + * @return {boolean} True for a valid trace id, otherwise false. + */ + function isValid(id: HiTraceId): boolean; + /** + * Judge whether the trace id has enabled a trace flag or not. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceId} id Trace id that need to judge. + * @param {HiTraceFlag} flag Trace flag that need to judge. + * @return {boolean} true if the trace id has enabled the flag. + */ + function isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean; + /** + * Enable the designative trace flag for the trace id. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param {HiTraceId} id Trace id that need to enable a flag. + * @param {HiTraceFlag} flag the designative trace flag that need to be enabled in the trace id. + */ + function enableFlag(id: HiTraceId, flag: HiTraceFlag): void; +} +export default hiTraceChain; diff --git a/build-tools/api/@ohos.hiTraceMeter.d.ts b/build-tools/api/@ohos.hiTraceMeter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..80a942c4dd83c1b046ff75be5d4c460268ba1821 --- /dev/null +++ b/build-tools/api/@ohos.hiTraceMeter.d.ts @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides interfaces to trace a task for performance measure, the logs can be capture by the + * bytrace cmdline available on the device. + * + *

This interfaces trace the start, end, and value changes of key processes that last for at least 3 ms. + * + *

Example: + * To trace a name verification that is expected to complete within 5 ms: + *

{@code
+ * hiTraceMeter.startTrace("checkName", 111, 5);
+ * //your process
+ * hiTraceMeter.finishTrace("checkName", 111);
+ * }
+ * To trace the number of layers, which is 3: + *
{@code
+ * hiTraceMeter.traceByValue("curLayer", 3);
+ * }
+ * + *

Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name + * and taskId. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + */ +declare namespace hiTraceMeter { + /** + * Records a trace marking it as the start of a task, can with the expected completion time between + * startTrace and finishTrace. + * + * This method is invoked at the start of a transaction to indicate that a task has started, whose name + * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by + * {@link #finishTrace}, the name and taskId need to be the same. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the task name. + * @param taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. + */ + function startTrace(name: string, taskId: number): void; + /** + * Records a trace and marks it as the end of a task. + * + * This method is invoked at the end of a transaction to indicate that a task has ended, whose name + * is specified by {@code name}. This method must be invoked after the the startTrace. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the task name. It must be the same whith the {@code name} of startTrace. + * @param taskId The unique id used to distinguish the tasks and must be the same whith the . + * {@code taskId} of startTrace. + */ + function finishTrace(name: string, taskId: number): void; + /** + * Records a trace for generating a count, such as clock pulse and the number of layers. + * + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the name used to identify the count. + * @param count Indicates the number of the count. + */ + function traceByValue(name: string, count: number): void; +} +export default hiTraceMeter; diff --git a/build-tools/api/@ohos.hichecker.d.ts b/build-tools/api/@ohos.hichecker.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..16b15ec4cc5dafee8b5ff3b1a64bbb2ad0f17544 --- /dev/null +++ b/build-tools/api/@ohos.hichecker.d.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** +* This module provides the capability to check bad code usage. +* + *@import import hichecker from '@ohos.hichecker'; +* @since 8 +* @syscap SystemCapability.HiviewDFX.HiChecker +*/ +declare namespace hichecker { + /** + * The caution rule print log. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiChecker + */ + const RULE_CAUTION_PRINT_LOG: 9223372036854775808n; // 1 << 63 + /** + * The caution rule trigger crash. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiChecker + */ + const RULE_CAUTION_TRIGGER_CRASH: 4611686018427387904n; // 1 << 62 + /** + * The thread rule check slow process. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiChecker + */ + const RULE_THREAD_CHECK_SLOW_PROCESS: 1n; + /** + * The process rule check ability connection leak. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiChecker + */ + const RULE_CHECK_ABILITY_CONNECTION_LEAK: 8589934592n; // 1 << 33 + /** + * add one or more rule. + * @param rule + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiChecker + */ + function addRule(rule: bigint): void; + /** + * remove one or more rule. + * @param rule + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiChecker + */ + function removeRule(rule: bigint): void; + /** + * get added rule + * @return all added thread rule and process rule. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiChecker + */ + function getRule(): bigint; + /** + * whether the query rule is added + * @param rule + * @return the result of whether the query rule is added. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiChecker + */ + function contains(rule: bigint): boolean; +} +export default hichecker; diff --git a/build-tools/api/@ohos.hidebug.d.ts b/build-tools/api/@ohos.hidebug.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8bc56cb794c844e98100a718a81abd4379686d48 --- /dev/null +++ b/build-tools/api/@ohos.hidebug.d.ts @@ -0,0 +1,125 @@ +/* +* Copyright (C) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** + * Provide interfaces related to debugger access and obtaining CPU, + * memory and other virtual machine information during runtime for JS programs + * + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + * @import import hidebug from '@ohos.hidebug' + * @since 8 + */ +declare namespace hidebug { + /** + * Get total native heap memory size + * @param - + * @return Returns total native heap memory size. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function getNativeHeapSize(): bigint; + /** + * Get Native heap memory allocation size. + * @param - + * @return Returns native heap memory allocation size. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function getNativeHeapAllocatedSize(): bigint; + /** + * Get Native heap memory free size + * @param - + * @return Returns native heap memory free size. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function getNativeHeapFreeSize(): bigint; + /** + * Get application process proportional set size memory information + * @param - + * @return Returns application process proportional set size memory information. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function getPss(): bigint; + /** + * Obtains the size of the shared dirty memory of a process. + * @param - + * @return Returns the size of the shared dirty memory. + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function getSharedDirty(): bigint; + /** + * Obtains the size of the private dirty memory of a process. + * @param - + * @return Returns the size of the private dirty memory. + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function getPrivateDirty(): bigint; + /** + * Obtains the cpu usage percent of a process. + * @param - + * @return Returns the cpu usage of a process. + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function getCpuUsage(): number; + /** + * Start CPU Profiling. + * The input parameter is a user-defined file name, excluding the file suffix. + * The generated file is in the files folder under the application directory. + * such as "/data/accounts/account_0/appdata/[package name]/files/cpuprofiler-xxx.json" + * + * @param filename Indicates the user-defined file name, excluding the file suffix. + * @return - + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function startProfiling(filename: string): void; + /** + * Stop CPU Profiling. + * It takes effect only when the CPU profiler is turned on + * + * @param - + * @return - + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function stopProfiling(): void; + /** + * Dump JS Virtual Machine Heap Snapshot. + * The input parameter is a user-defined file name, excluding the file suffix. + * The generated file is in the files folder under the application directory. + * such as "/data/accounts/account_0/appdata/[package name]/files/xxx.heapsnapshot" + * + * @param filename Indicates the user-defined file name, excluding the file suffix. + * @return - + * @since 8 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function dumpHeapData(filename: string): void; + /** + * Get a debugging dump of a system service by service id. + * Not for use by third-party applications for permission. + * + * @param serviceid Indicates the id of the service ability. + * @return - sa dumped file name return. + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function getServiceDump(serviceid: number): string; +} +export default hidebug; diff --git a/build-tools/api/@ohos.hilog.d.ts b/build-tools/api/@ohos.hilog.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cdc21aa4f37a2be3a4ad01bc0d882dba6ad24e47 --- /dev/null +++ b/build-tools/api/@ohos.hilog.d.ts @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** +* Provides interfaces to generate system logs. +* +* @since 7 +* @syscap SystemCapability.HiviewDFX.HiLog +*/ +declare namespace hilog { + /** + * Outputs debug-level logs. + * + * @param domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF + * @param tag Identifies the log tag. + * @param format Indicates the log format string. + * @param args Indicates the log parameters. + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiLog + */ + function debug(domain: number, tag: string, format: string, ...args: any[]): void; + /** + * Outputs info-level logs. + * + * @param domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF + * @param tag Identifies the log tag. + * @param format Indicates the log format string. + * @param args Indicates the log parameters. + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiLog + */ + function info(domain: number, tag: string, format: string, ...args: any[]): void; + /** + * Outputs warning-level logs. + * + * @param domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF + * @param tag Identifies the log tag. + * @param format Indicates the log format string. + * @param args Indicates the log parameters. + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiLog + */ + function warn(domain: number, tag: string, format: string, ...args: any[]): void; + /** + * Outputs error-level logs. + * + * @param domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF + * @param tag Identifies the log tag. + * @param format Indicates the log format string. + * @param args Indicates the log parameters. + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiLog + */ + function error(domain: number, tag: string, format: string, ...args: any[]): void; + /** + * Outputs fatal-level logs. + * + * @param domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF + * @param tag Identifies the log tag. + * @param format Indicates the log format string. + * @param args Indicates the log parameters. + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiLog + */ + function fatal(domain: number, tag: string, format: string, ...args: any[]): void; + /** + * Checks whether logs of the specified tag, and level can be printed. + * + * @param domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF + * @param tag Identifies the log tag. + * @param level log level + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiLog + */ + function isLoggable(domain: number, tag: string, level: LogLevel): boolean; + /** + * Log level define + * + * @since 7 + * @syscap SystemCapability.HiviewDFX.HiLog + */ + enum LogLevel { + DEBUG = 3, + INFO = 4, + WARN = 5, + ERROR = 6, + FATAL = 7 + } +} +export default hilog; diff --git a/build-tools/api/@ohos.i18n.d.ts b/build-tools/api/@ohos.i18n.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c8e36c12e1e1c0ace086c14e9a0cdcbbefcd1792 --- /dev/null +++ b/build-tools/api/@ohos.i18n.d.ts @@ -0,0 +1,714 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides international settings related APIs. + * + * @syscap SystemCapability.Global.I18n + * @since 7 + */ +declare namespace i18n { + /** + * Obtains the country or region name localized for display on a given locale. + * + * @syscap SystemCapability.Global.I18n + * @param country The locale whose country or region name will be displayed. + * @param locale The locale used to display the country or region. + * @param sentenceCase Specifies whether the country or region name is displayed in sentence case. + * @return Returns the country or region name localized for display on a given locale. + * @since 7 + */ + export function getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string; + /** + * Obtains the language name localized for display on a given locale. + * + * @syscap SystemCapability.Global.I18n + * @param language The locale whose language name will be displayed. + * @param locale The locale used to display the language. + * @param sentenceCase Specifies whether the language name is displayed in sentence case. + * @return Returns the language name localized for display on a given locale. + * @since 7 + */ + export function getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string; + /** + * Obtain the language currently used by the system. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the language currently used by the system. + * @since 7 + */ + export function getSystemLanguage(): string; + /** + * Obtain the region currently used by the system. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the region currently used by the system. + * @since 7 + */ + export function getSystemRegion(): string; + /** + * Obtain the locale currently used by the system. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the locale currently used by the system. + * @since 7 + */ + export function getSystemLocale(): string; + /** + * Provides util functions. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export interface Util { + /** + * Convert from unit to to unit and format according to the locale. + * + * @syscap SystemCapability.Global.I18n + * @param fromUnit Information of the unit to be converted. + * @param toUnit Information about the unit to be converted to. + * @param value Indicates the number to be formatted. + * @param locale The locale to be used. + * @param style The style of format. + * @since 8 + */ + unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; + /** + * Get the order of year, month, day in the specified locale. Year, month, day are separated by '-'. + * 'y' stands for year, 'L' stands for month, d stands for day. + * + * @syscap SystemCapability.Global.I18n + * @param locale Information of the locale + * @return Returns the string of 'y', 'L', 'd' joined by '-'. + * @since 9 + */ + getDateOrder(locale: string): string; + } + /** + * Provides the options of unit. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export interface UnitInfo { + /** + * Unit name. + */ + unit: string; + /** + * The measurement system of the unit. + */ + measureSystem: string; + } + /** + * Provides the options of PhoneNumberFormat. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export interface PhoneNumberFormatOptions { + /** + * Indicates the type to format phone number. + */ + type: string; + } + /** + * Provides the API for formatting phone number strings + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export class PhoneNumberFormat { + /** + * A constructor used to create a PhoneNumberFormat object. + * + * @syscap SystemCapability.Global.I18n + * @param country Indicates a character string containing the country information for the PhoneNumberFormat object. + * @param type Indicates the type used to format the phone number, includes: "E164", "RFC3966", "INTERNATIONAL", "NATIONAL". + * @since 8 + */ + constructor(country: string, options?: PhoneNumberFormatOptions); + /** + * Judges whether phone number is valid. + * + * @syscap SystemCapability.Global.I18n + * @param number Indicates the input phone number to be judged. + * @return Returns a boolean indicates whether the input phone number is valid. + * @since 8 + */ + isValidNumber(number: string): boolean; + /** + * Obtains the formatted phone number strings of number. + * + * @syscap SystemCapability.Global.I18n + * @param number Indicates the input phone number to be formatted. + * @return Returns the formatted phone number. + * @since 8 + */ + format(number: string): string; + /** + * Determine the location by phone number, and return it according to the specified regional language. + * + * @syscap SystemCapability.Global.I18n + * @param number input phone number. + * @param locale locale ID. + * @return Returns a string represents phone number's location. + * @since 9 + */ + getLocationName(number: string, locale: string): string; + } + /** + * Get a Calendar instance specified by locale and type. + * + * @syscap SystemCapability.Global.I18n + * @param locale The locale used to get calendar. + * @param type If type is not specified, get locale's default Calendar, else get the specified type of Calendar. + * such as buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, + * japanese, persion. + * @since 8 + */ + export function getCalendar(locale: string, type?: string): Calendar; + export class Calendar { + /** + * set the date. + * + * @syscap SystemCapability.Global.I18n + * @param date Date object used to set the time and date. + * @since 8 + */ + setTime(date: Date): void; + /** + * set the time. + * + * @syscap SystemCapability.Global.I18n + * @param time Indicates the elapsed milliseconds from 1970.1.1 00:00:00 GMT. + * @since 8 + */ + setTime(time: number): void; + /** + * Set the time + * + * @syscap SystemCapability.Global.I18n + * @param year The year field of the calendar, ranges from 0 to 9999. + * @param month The month field of the calendar, ranges from 0 to 11. + * @param date The day field of the calendar, ranges from 1 to 31. + * @param hour The hour field of the calendar, ranges from 0 to 23. + * @param minute The minute field of the calendar, ranges from 0 to 59. + * @param second the second field of the calendar, ranges from 0 to 59. + * @since 8 + */ + set(year: number, month: number, date: number, hour?: number, minute?: number, second?: number): void; + /** + * Set the timezone of this calendar. + * + * @syscap SystemCapability.Global.I18n + * @param timezone The id of a timezone. + * @since 8 + */ + setTimeZone(timezone: string): void; + /** + * Get the timezone id of this calendar instance. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the timezone id of this calendar. + * @since 8 + */ + getTimeZone(): string; + /** + * Get the start day of a week. 1 indicates Sunday, 7 indicates Saturday. + * + * @syscap SystemCapability.Global.I18n + * @return Returns start day of a week. + * @since 8 + */ + getFirstDayOfWeek(): number; + /** + * Set the start day of a week. 1 indicates Sunday, 7 indicates Saturday. + * + * @syscap SystemCapability.Global.I18n + * @param value Indicates the start day of a week. 1 indicates Sunday, 7 indicates Saturday. + * @since 8 + */ + setFirstDayOfWeek(value: number): void; + /** + * Get the minimal days of a week, which is needed for the first day of a year. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the minimal days of a week. + * @since 8 + */ + getMinimalDaysInFirstWeek(): number; + /** + * Set the minimal days of a week, which is needed for the first week of a year. + * + * @syscap SystemCapability.Global.I18n + * @param value The value to be set. + * @since 8 + */ + setMinimalDaysInFirstWeek(value: number): void; + /** + * Get the associated value with the field. + * + * @syscap SystemCapability.Global.I18n + * @param field Field values such as era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week + * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, + * dow_local, extended_year, julian_day, milliseconds_in_day, is_leap_month. + * @return Return the associated value. + * @since 8 + */ + get(field: string): number; + /** + * Get calendar's name localized for display in the given locale. + * + * @syscap SystemCapability.Global.I18n + * @param locale Locale used to get the localized name for this calendar. + * @return Returns the localized name of this calendar. + * @since 8 + */ + getDisplayName(locale: string): string; + /** + * Returns true if the given date is a weekend day. If the date is not given, + * the date object of this calendar is used. + * + * @syscap SystemCapability.Global.I18n + * @param date Date object whose attribute is desired. + * @return Returns whether the date is a weekend day. + * @since 8 + */ + isWeekend(date?: Date): boolean; + } + /** + * Judge whether the locale is RTL locale. + * + * @syscap SystemCapability.Global.I18n + * @param locale The locale to be used. + * @return Returns true representing the locale is an RTL locale + * + * @since 7 + */ + export function isRTL(locale: string): boolean; + /** + * Obtains a BreakIterator object for finding the location of break point in text. + * + * @syscap SystemCapability.Global.I18n + * @param locale the returned BreakIterator will adapt the rule, specified by the locale, to break text. + * @return Returns a newly constructed BreakIterator object. + * @since 8 + */ + export function getLineInstance(locale: string): BreakIterator; + /** + * The BreakIterator class is used for finding the location of break point in text. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export class BreakIterator { + /** + * Obtains the current position of the BreakIterator instance. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the current position of the BreakIterator instance. + * @since 8 + */ + current(): number; + /** + * Set the BreakIterator's position to the first break point, the first break point is always the beginning of the + * processed text. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the index of the first break point. + * @since 8 + */ + first(): number; + /** + * Set the BreakIterator's position to the last break point. the last break point is always the index beyond the + * last character of the processed text. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the index of the last break point. + * @since 8 + */ + last(): number; + /** + * Set the BreakItertor's position to the nth break point from the current break point. + * + * @syscap SystemCapability.Global.I18n + * @param index indicates the number of break points to advance. If index is not given, n is treated as 1. + * @return Returns the index of the BreakIterator after moving. If there is not enough break points, returns -1. + * @since 8 + */ + next(index?: number): number; + /** + * Set the BreakItertor's position to the break point preceding the current break point. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the index of the BreakIterator after moving. If there is not enough break points, returns -1. + * @since 8 + */ + previous(): number; + /** + * Set the text to be processed. + * + * @syscap SystemCapability.Global.I18n + * @param text Indicates the text to be processed by the BreakIterator. + * @since 8 + */ + setLineBreakText(text: string): void; + /** + * Set the BreakIterator's position to the first break point following the specified offset. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the index of the BreakIterator after moving. If there is not enough break points, returns -1. + * @since 8 + */ + following(offset: number): number; + /** + * Obtains the text being processed. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the text that is processed by the BreakIterator. + * @since 8 + */ + getLineBreakText(): string; + /** + * Returns true if the position indicated by the offset is a break point, otherwise false. The BreakIterator's + * position will be set to the position indicated by the offset if it returns true, otherwise the BreakIterator + * will be moved to the break point following the offset. + * + * @syscap SystemCapability.Global.I18n + * @param offset The offset to be checked. + * @return Returns true if the offset is a break point. + * @since 8 + */ + isBoundary(offset: number): boolean; + } + /** + * Get IndexUtil object. + * + * @syscap SystemCapability.Global.I18n + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region, for the NumberFormat object. + * @return Returns IndexUtil object. + * @since 8 + */ + export function getInstance(locale?: string): IndexUtil; + /** + * Sequence text can be grouped under the specified area, + * and grouping index with different lengths can be specified. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export class IndexUtil { + /** + * Get a list of labels for use as a UI index + * + * @syscap SystemCapability.Global.I18n + * @return Returns a list of labels + * @since 8 + */ + getIndexList(): Array; + /** + * Add the index characters from a Locale to the index. + * + * @syscap SystemCapability.Global.I18n + * @param locale The locale whose index characters are to be added. + * @since 8 + */ + addLocale(locale: string): void; + /** + * Get corresponding index of the input text. + * + * @syscap SystemCapability.Global.I18n + * @param text input text + * @since 8 + */ + getIndex(text: string): string; + } + /** + * Provides the API for accessing unicode character properties, sunch as whether a character is a digit. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export class Character { + /** + * Determines whether the specified code point is a digit character + * + * @syscap SystemCapability.Global.I18n + * @param char the character to be tested + * @return Returns true if the character is a digit character + */ + isDigit(char: string): boolean; + /** + * Determines if the specified character is a space character or not. + * + * @syscap SystemCapability.Global.I18n + * @param char the character to be tested + * @return Returns true if the character is a space character + */ + isSpaceChar(char: string): boolean; + /** + * Determines if the specified character is a whitespace character + * + * @syscap SystemCapability.Global.I18n + * @param char the character to be tested + * @return Returns true if the character is a whitespace character + */ + isWhitespace(char: string): boolean; + /** + * Determines if the specified character is a RTL character or not. + * + * @syscap SystemCapability.Global.I18n + * @param char the character to be tested + * @return Returns true if the character is a RTL character + */ + isRTL(char: string): boolean; + /** + * Determines if the specified character is a Ideographic character or not. + * + * @syscap SystemCapability.Global.I18n + * @param char the character to be tested + * @return Returns true if the character is a Ideographic character + */ + isIdeograph(char: string): boolean; + /** + * Determines if the specified character is a Letter or not. + * + * @syscap SystemCapability.Global.I18n + * @param char the character to be tested + * @return Returns true if the character is a Letter + */ + isLetter(char: string): boolean; + /** + * Determines if the specified character is a LowerCase character or not. + * + * @syscap SystemCapability.Global.I18n + * @param char the character to be tested + * @return Returns true if the character is a LowerCase character + */ + isLowerCase(char: string): boolean; + /** + * Determines if the specified character is a UpperCase character or not. + * + * @syscap SystemCapability.Global.I18n + * @param char the character to be tested + * @return Returns true if the character is a UpperCase character + */ + isUpperCase(char: string): boolean; + /** + * Get the general category value of the specified character. + * + * @syscap SystemCapability.Global.I18n + * @param char the character to be tested + * @return Returns the general category of the specified character. + */ + getType(char: string): string; + } + /** + * check out whether system is 24-hour system. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a boolean represent whether system is 24-hour system. + * @since 7 + */ + export function is24HourClock(): boolean; + /** + * set 24-hour system. + * + * @permission ohos.permission.UPDATE_CONFIGURATION + * @syscap SystemCapability.Global.I18n + * @param option represent the boolean to be set. + * @return Returns a boolean represent whether setting 24-hour system success. + * @since 7 + */ + export function set24HourClock(option: boolean): boolean; + /** + * Add one language to preferred language List. + * + * @permission ohos.permission.UPDATE_CONFIGURATION + * @syscap SystemCapability.Global.I18n + * @param language the language to be added. + * @param index the position of preferred language list to be inserted. + * @return Returns a boolean represent whether language added success. + * @since 8 + */ + export function addPreferredLanguage(language: string, index?: number): boolean; + /** + * Remove one language from preferred language list. + * + * @permission ohos.permission.UPDATE_CONFIGURATION + * @syscap SystemCapability.Global.I18n + * @param index the position of removed language in preferred language list. + * @return Returns a boolean represent whether removed success. + * @since 8 + */ + export function removePreferredLanguage(index: number): boolean; + /** + * Access the system preferred language list. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a string Array represent the preferred language list. + * @since 8 + */ + export function getPreferredLanguageList(): Array; + /** + * Get the first preferred language of system. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a string represent the first preferred language of system. + * @since 8 + */ + export function getFirstPreferredLanguage(): string; + /** + * Get the preferred language of App. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a string represent the preferred language of App. + * @since 9 + */ + export function getAppPreferredLanguage(): string; + /** + * Get the default TimeZone object or the TimeZone object corresponds to zoneID. + * + * @syscap SystemCapability.Global.I18n + * @param zoneID TimeZone ID used to create TimeZone Object. + * @return Returns a TimeZone object corresponds to zoneID. + * @since 7 + */ + export function getTimeZone(zoneID?: string): TimeZone; + /** + * Provides the API for accessing TimeZone name, rawOffset and offset information. + * + * @syscap SystemCapability.Global.I18n + * @since 7 + */ + export class TimeZone { + /** + * Get the id of the TimeZone object. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a string represents the timezone id. + * @since 7 + */ + getID(): string; + /** + * Get the displayName of the TimeZone Object under the locale. + * + * @syscap SystemCapability.Global.I18n + * @param locale the locale tag use to display timezone object's name. + * @param isDST wether conside daylight saving time when display timezone object's name. + * @return Returns a string represents the display name. + * @since 7 + */ + getDisplayName(locale?: string, isDST?: boolean): string; + /** + * Get the raw offset of the TimeZone object. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a number represents the raw offset. + * @since 7 + */ + getRawOffset(): number; + /** + * Get the offset of the TimeZone object. + * + * @syscap SystemCapability.Global.I18n + * @date Indicates a date use to compute offset. + * @return Returns a number represents the offset with date. + * @since 7 + */ + getOffset(date?: number): number; + /** + * Get available TimeZone ID list. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a string array represents the available TimeZone ID list. + * @since 9 + */ + static getAvailableIDs(): Array; + /** + * Get available Zone City ID list. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a string array represents the available Zone City ID list. + * @since 9 + */ + static getAvailableZoneCityIDs(): Array; + /** + * Get City display name in a certain locale. + * + * @syscap SystemCapability.Global.I18n + * @param cityID Zone City ID. + * @param locale locale used to display city name. + * @return Returns a string represents the display name of City in locale. + * @since 9 + */ + static getCityDisplayName(cityID: string, locale: string): string; + /** + * Get TimeZone Object from city ID. + * + * @syscap SystemCapability.Global.I18n + * @param cityID Zone City ID. + * @return Returns a TimeZone Object from city ID. + * @since 9 + */ + static getTimezoneFromCity(cityID: string): TimeZone; + } + /** + * Provides the API for transliterate text from one format to another. + * + * @syscap SystemCapability.Global.I18n + * @since 9 + */ + export class Transliterator { + /** + * Get a string array of all available transliterator ids. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a string array of all available transliterator ids. + * @since 9 + */ + static getAvailableIDs(): string[]; + /** + * Get a Transliterator that is specified by id name. + * + * @syscap SystemCapability.Global.I18n + * @param id specified the type of Transliterator. id is formed by source and dest. Transliterator will tranliste + * the input string from source format to the dest format. For example, a Simplified Chinese to Latn + * Transliterator will transform the text written in Chinese to Latn characters. + * @return Returns Transliterator that is specified by id name. + * @since 9 + */ + static getInstance(id: string): Transliterator; + /** + * Transform the input text. + * + * @syscap SystemCapability.Global.I18n + * @param id text to be transliterated. + * @return Returns the output text that is tranlisterated from source format to the dest format. + * @since 9 + */ + transform(text: string): string; + } + /** + * Get whether to use local digit. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a boolean represents whether to use local digit. + * @since 9 + */ + export function getUsingLocalDigit(): boolean; +} +export default i18n; diff --git a/build-tools/api/@ohos.inputmethod.d.ts b/build-tools/api/@ohos.inputmethod.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4aa2a81552a7be1cf551d4da2beeb8871e1c6d97 --- /dev/null +++ b/build-tools/api/@ohos.inputmethod.d.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * inputmethod + * + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ +declare namespace inputMethod { + /** + * keyboard max number + * @since 8 + */ + const MAX_TYPE_NUM: number; + /** + * input method setting + * @since 8 + */ + function getInputMethodSetting(): InputMethodSetting; + /** + * input method controller + * @since 6 + */ + function getInputMethodController(): InputMethodController; + /** + * Switch input method + * @since 9 + * @param target Indicates the input method which will replace the current one + * @return - + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function switchInputMethod(target: InputMethodProperty, callback: AsyncCallback): void; + /** + * Switch input method + * @since 9 + * @param target Indicates the input method which will replace the current one + * @return - + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function switchInputMethod(target: InputMethodProperty): Promise; + /** + * @since 8 + */ + interface InputMethodSetting { + /** + * @since 8 + */ + listInputMethod(callback: AsyncCallback>): void; + /** + * @since 8 + */ + listInputMethod(): Promise>; + displayOptionalInputMethod(callback: AsyncCallback): void; + displayOptionalInputMethod(): Promise; + } + /** + * @since 6 + */ + interface InputMethodController { + stopInput(callback: AsyncCallback): void; + stopInput(): Promise; + } + /** + * input method info + * @since 8 + */ + interface InputMethodProperty { + readonly packageName: string; + readonly methodId: string; + } +} +export default inputMethod; diff --git a/build-tools/api/@ohos.inputmethodengine.d.ts b/build-tools/api/@ohos.inputmethodengine.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..771b8d43aa235e65e62f971b568082c5b3b37fb6 --- /dev/null +++ b/build-tools/api/@ohos.inputmethodengine.d.ts @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * inputmethodengine + * + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ +declare namespace inputMethodEngine { + const ENTER_KEY_TYPE_UNSPECIFIED: number; + const ENTER_KEY_TYPE_GO: number; + const ENTER_KEY_TYPE_SEARCH: number; + const ENTER_KEY_TYPE_SEND: number; + const ENTER_KEY_TYPE_NEXT: number; + const ENTER_KEY_TYPE_DONE: number; + const ENTER_KEY_TYPE_PREVIOUS: number; + const PATTERN_NULL: number; + const PATTERN_TEXT: number; + const PATTERN_NUMBER: number; + const PATTERN_PHONE: number; + const PATTERN_DATETIME: number; + const PATTERN_EMAIL: number; + const PATTERN_URI: number; + const PATTERN_PASSWORD: number; + const FLAG_SELECTING: number; + const FLAG_SINGLE_LINE: number; + const DISPLAY_MODE_PART: number; + const DISPLAY_MODE_FULL: number; + const OPTION_ASCII: number; + const OPTION_NONE: number; + const OPTION_AUTO_CAP_CHARACTERS: number; + const OPTION_AUTO_CAP_SENTENCES: number; + const OPTION_AUTO_WORDS: number; + const OPTION_MULTI_LINE: number; + const OPTION_NO_FULLSCREEN: number; + function getInputMethodEngine(): InputMethodEngine; + function createKeyboardDelegate(): KeyboardDelegate; + interface KeyboardController { + hideKeyboard(callback: AsyncCallback): void; + hideKeyboard(): Promise; + } + interface InputMethodEngine { + on(type: 'inputStart', callback: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; + off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; + on(type: 'keyboardShow' | 'keyboardHide', callback: () => void): void; + off(type: 'keyboardShow' | 'keyboardHide', callback?: () => void): void; + } + interface TextInputClient { + sendKeyFunction(action: number, callback: AsyncCallback): void; + sendKeyFunction(action: number): Promise; + deleteForward(length: number, callback: AsyncCallback): void; + deleteForward(length: number): Promise; + deleteBackward(length: number, callback: AsyncCallback): void; + deleteBackward(length: number): Promise; + insertText(text: string, callback: AsyncCallback): void; + insertText(text: string): Promise; + getForward(length: number, callback: AsyncCallback): void; + getForward(length: number): Promise; + getBackward(length: number, callback: AsyncCallback): void; + getBackward(length: number): Promise; + getEditorAttribute(callback: AsyncCallback): void; + getEditorAttribute(): Promise; + } + interface KeyboardDelegate { + on(type: 'keyDown' | 'keyUp', callback: (event: KeyEvent) => boolean): void; + off(type: 'keyDown' | 'keyUp', callback?: (event: KeyEvent) => boolean): void; + on(type: 'cursorContextChange', callback: (x: number, y: number, height: number) => void): void; + off(type: 'cursorContextChange', callback?: (x: number, y: number, height: number) => void): void; + on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void; + off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void; + on(type: 'textChange', callback: (text: string) => void): void; + off(type: 'textChange', callback?: (text: string) => void): void; + } + interface EditorAttribute { + readonly inputPattern: number; + readonly enterKeyType: number; + } + interface KeyEvent { + readonly keyCode: number; + readonly keyAction: number; + } +} +export default inputMethodEngine; diff --git a/build-tools/api/@ohos.intl.d.ts b/build-tools/api/@ohos.intl.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7788413d28b389084f8f3b5ce9fad561f7a6875e --- /dev/null +++ b/build-tools/api/@ohos.intl.d.ts @@ -0,0 +1,899 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Provides internationalization related APIs. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ +declare namespace intl { + /** + * Provides the options of Locale. + * + * @since 6 + * @syscap SystemCapability.Global.I18n + */ + export interface LocaleOptions { + /** + * Indicates the calendar. + * + * @since 6 + */ + calendar: string; + /** + * Indicates the collation. + * + * @since 6 + */ + collation: string; + /** + * Indicates the hourCycle. + * + * @since 6 + */ + hourCycle: string; + /** + * Indicates the numberingSystem. + * + * @since 6 + */ + numberingSystem: string; + /** + * Indicates the numeric. + * + * @since 6 + */ + numeric: boolean; + /** + * Indicates the caseFirst. + * + * @since 6 + */ + caseFirst: string; + } + /** + * Provides APIs for obtaining locale information. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + export class Locale { + /** + * A constructor used to create a Locale object. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + constructor(); + /** + * A constructor used to create a Locale object. + * + * @syscap SystemCapability.Global.I18n + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region. + * @param options Indicates Locale option object use to initialize the Locale object. + * @since 6 + */ + constructor(locale: string, options?: LocaleOptions); + /** + * Indicates the language of the locale. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + language: string; + /** + * Indicates the script of the locale. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + script: string; + /** + * Indicates the region of the locale. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + region: string; + /** + * Indicates the basic locale information, which is returned as a substring of + * a complete locale string. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + baseName: string; + /** + * Indicates the case first style of the locale. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + caseFirst: string; + /** + * Indicates the calendar. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + calendar: string; + /** + * Indicates the collation. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + collation: string; + /** + * Indicates the hour cycle. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + hourCycle: string; + /** + * Indicates the numbering system. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + numberingSystem: string; + /** + * Indicates whether it is numeric. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + numeric: boolean; + /** + * Convert the locale information to string. + * + * @syscap SystemCapability.Global.I18n + * @return Returns locale information in string form. + * @since 6 + */ + toString(): string; + /** + * Maximize the locale's base information. + * + * @syscap SystemCapability.Global.I18n + * @return Returns maximized locale. + * @since 6 + */ + maximize(): Locale; + /** + * Minimize the locale's base information. + * + * @syscap SystemCapability.Global.I18n + * @return Returns minimized locale. + * @since 6 + */ + minimize(): Locale; + } + /** + * Provides the options of date time format. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + export interface DateTimeOptions { + /** + * Indicates the locale. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + locale: string; + /** + * Indicates the date style. + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + dateStyle: string; + /** + * Indicates the time style. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + timeStyle: string; + /** + * Indicates the hour cycle. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + hourCycle: string; + /** + * Indicates the timezone. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + timeZone: string; + /** + * Indicates the numbering system. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + numberingSystem: string; + /** + * Indicates whether is 12 hour or not. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + hour12: boolean; + /** + * Indicates the weekday style. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + weekday: string; + /** + * Indicates the era style. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + era: string; + /** + * Indicates the year style. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + year: string; + /** + * Indicates the month style. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + month: string; + /** + * Indicates the day style. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + day: string; + /** + * Indicates the hour style. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + hour: string; + /** + * Indicates the minute style. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + minute: string; + /** + * Indicates the second style. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + second: string; + /** + * Indicates the timezone name. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + timeZoneName: string; + /** + * Indicates the day period format. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + dayPeriod: string; + /** + * Indicates the locale matching algorithm. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + localeMatcher: string; + /** + * Indicates the format matching algorithm. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + formatMatcher: string; + } + /** + * Provides the API for formatting date strings. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + export class DateTimeFormat { + /** + * A constructor used to create a DateTimeFormat object. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + constructor(); + /** + * A constructor used to create a DateTimeFormat object. + * + * @syscap SystemCapability.Global.I18n + * @param locale Indicates character string containing the locale information, including + * the language and optionally the script and region, for the DateTimeFormat object. + * @param options Indicates the options used to format the date. + * @since 6 + */ + constructor(locale: string | Array, options?: DateTimeOptions); + /** + * Obtains the formatted date strings. + * + * @syscap SystemCapability.Global.I18n + * @param date Indicates the Date object to be formatted. + * @return Returns a date string formatted based on the specified locale. + * @since 6 + */ + format(date: Date): string; + /** + * Obtains the formatted date strings of a date range. + * + * @syscap SystemCapability.Global.I18n + * @param startDate Indicates the start date of the date range. + * @param endDate Indicates the end date of the date range. + * @return Returns a date string formatted based on the specified locale. + * @since 6 + */ + formatRange(startDate: Date, endDate: Date): string; + /** + * Obtains the options of the DateTimeFormat object. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the options of the DateTimeFormat object. + * @since 6 + */ + resolvedOptions(): DateTimeOptions; + } + /** + * Provides the options of number format. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + export interface NumberOptions { + /** + * Indicates the locale. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + locale: string; + /** + * Indicates the currency. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + currency: string; + /** + * Indicates the currency sign. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + currencySign: string; + /** + * Indicates the currency display format. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + currencyDisplay: string; + /** + * Indicates the unit. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + unit: string; + /** + * Indicates the unit display format. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + unitDisplay: string; + /** + * Indicates the unit display format. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + unitUsage: string; + /** + * Indicates the sign display format. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + signDisplay: string; + /** + * Indicates the compact display format. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + compactDisplay: string; + /** + * Indicates the notation. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + notation: string; + /** + * Indicates the locale matching algorithm. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + localeMatcher: string; + /** + * Indicates the style. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + style: string; + /** + * Indicates the numbering system. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + numberingSystem: string; + /** + * Indicates whether using grouping or not. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + useGrouping: boolean; + /** + * Indicates the minimum integer digits. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + minimumIntegerDigits: number; + /** + * Indicates the minimum fraction digits. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + minimumFractionDigits: number; + /** + * Indicates the maximum fraction digits. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + maximumFractionDigits: number; + /** + * Indicates the minimum significant digits. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + minimumSignificantDigits: number; + /** + * Indicates the maximum significant digits. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + maximumSignificantDigits: number; + } + /** + * Provides the API for formatting number strings. + * + * @syscap SystemCapability.Global.I18n + * @since 6 + */ + export class NumberFormat { + /** + * A constructor used to create a NumberFormat object. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + constructor(); + /** + * A constructor used to create a NumberFormat object. + * + * @syscap SystemCapability.Global.I18n + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region, for the NumberFormat object. + * @param options Indicates the options used to format the number. + * @since 6 + */ + constructor(locale: string | Array, options?: NumberOptions); + /** + * Obtains the formatted number string. + * + * @syscap SystemCapability.Global.I18n + * @param number Indicates the number to be formatted. + * @return Returns a number string formatted based on the specified locale. + * @since 6 + */ + format(number: number): string; + /** + * Obtains the options of the NumberFormat object. + * + * @syscap SystemCapability.Global.I18n + * @return Returns the options of the NumberFormat object. + * @since 6 + */ + resolvedOptions(): NumberOptions; + } + /** + * Provides the options of Collator + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export interface CollatorOptions { + /** + * The locale matching algorithm to use. + * Possible values are "lookup" and "best fit"; the default is "best fit". + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + localeMatcher: string; + /** + * Whether the comparison is for sorting or for searching for matching strings. + * Possible values are "sort" and "search"; the default is "sort". + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + usage: string; + /** + * Which differences in the strings should lead to non-zero result values. + * Possible values are "base", "accent", "case", "variant". + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + sensitivity: string; + /** + * Whether punctuation should be ignored. + * Possible values are true and false; the default is false. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + ignorePunctuation: boolean; + /** + * Variant collations for certain locales. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + collation: string; + /** + * Whether numeric collation should be used. + * Possible values are true and false; the default is false. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + numeric: boolean; + /** + * Whether upper case or lower case should sort first. + * Possible values are "upper", "lower", or "false" (use the locale's default). + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + caseFirst: string; + } + /** + * Enable language-sensitive string comparison. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export class Collator { + /** + * A constructor used to create Collator object. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + constructor(); + /** + * A constructor used to create Collator Object; + * + * @syscap SystemCapability.Global.I18n + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region, for the Collator object. + * @param options Indicates the options used to initialize Collator object. + * @since 8 + */ + constructor(locale: string | Array, options?: CollatorOptions); + /** + * compares two strings according to the sort order of this Collator object + * + * @syscap SystemCapability.Global.I18n + * @param first The first string to compare. + * @param second The second string to compare. + * @return Returns a number indicating how first compare to second: + * a negative value if string1 comes before string2; + * a positive value if string1 comes after string2; + * 0 if they are considered equal. + * @since 8 + */ + compare(first: string, second: string): number; + /** + * Returns a new object with properties reflecting the locale and collation options computed + * during initialization of the object. + * + * @syscap SystemCapability.Global.I18n + * @return Returns a CollatorOptions object reflecting the properties of this object. + * @since 8 + */ + resolvedOptions(): CollatorOptions; + } + /** + * Provides the options of PluralRules + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export interface PluralRulesOptions { + /** + * The locale matching algorithm to use. + * Possible values are "lookup" and "best fit"; the default is "best fit". + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + localeMatcher: string; + /** + * The type to use. Possible values are: "cardinal", "ordinal" + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + type: string; + /** + * The minimum number of integer digits to use. + * Possible values are from 1 to 21; the default is 1. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + minimumIntegerDigits: number; + /** + * The minimum number of fraction digits to use. + * Possible values are from 0 to 20; the default for plain number and percent formatting is 0; + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + minimumFractionDigits: number; + /** + * The maximum number of fraction digits to use. + * Possible values are from 0 to 20; + * the default for plain number formatting is the larger of minimumFractionDigits and 3; + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + maximumFractionDigits: number; + /** + * The minimum number of significant digits to use. + * Possible values are from 1 to 21; the default is 1. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + minimumSignificantDigits: number; + /** + * The maximum number of significant digits to use. + * Possible values are from 1 to 21; the default is 21. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + maximumSignificantDigits: number; + } + /** + * Enables plural-sensitive formatting and plural-related language rules. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export class PluralRules { + /** + * A constructor used to create PluralRules object. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + constructor(); + /** + * A constructor used to create PluralRules object. + * + * @syscap SystemCapability.Global.I18n + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region, for the PluralRules object. + * @param options Indicates the options used to initialize PluralRules object. + * @since 8 + */ + constructor(locale: string | Array, options?: PluralRulesOptions); + /** + * Returns a string indicating which plural rule to use for locale-aware formatting. + * + * @syscap SystemCapability.Global.I18n + * @param n The number to get a plural rule for. + * @return A string representing the pluralization category of the number, + * can be one of zero, one, two, few, many or other. + * @since 8 + */ + select(n: number): string; + } + /** + * Provides the input options of RelativeTimeFormat. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export interface RelativeTimeFormatInputOptions { + /** + * The locale matching algorithm to use. + * Possible values are: lookup, best fit + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + localeMatcher: string; + /** + * The format of output message. + * Possible values are: always, auto + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + numeric: string; + /** + * The length of the internationalized message. + * Possible values are: long, short, narrow + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + style: string; + } + /** + * Provides the resolved options of RelativeTimeFormat. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export interface RelativeTimeFormatResolvedOptions { + /** + * The BCP 47 language tag for the locale actually used. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + locale: string; + /** + * The length of the internationalized message. + * Possible values are: long, short, narrow + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + style: string; + /** + * The format of output message. + * Possible values are: always, auto + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + numeric: string; + /** + * The value requested using the Unicode extension key "nu" or filled in as a default. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + numberingSystem: string; + } + /** + * Given a Time period length value and a unit, RelativeTimeFormat object enables + * language-sensitive relative time formatting. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + export class RelativeTimeFormat { + /** + * A constructor used to create RelativeTimeFormat object. + * + * @syscap SystemCapability.Global.I18n + * @since 8 + */ + constructor(); + /** + * A constructor used to create RelativeTimeFormat object. + * + * @syscap SystemCapability.Global.I18n + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region, for the RelativeTimeFormat object. + * @param options Indicates the options used to initialize RelativeTimeFormat object. + * @since 8 + */ + constructor(locale: string | Array, options?: RelativeTimeFormatInputOptions); + /** + * formats a value and unit according to the locale and formatting options of this object. + * + * @syscap SystemCapability.Global.I18n + * @param value Numeric value to use in the internationalized relative time message. + * @param unit Unit to use in the relative time internationalized message. + * Possible values are: year, quarter, month, week, day, hour, minute, second. + * @returns formatted language-sensitive relative time. + * @since 8 + */ + format(value: number, unit: string): string; + /** + * returns an Array of objects representing the relative time format in parts that can be used for + * custom locale-aware formatting + * + * @syscap SystemCapability.Global.I18n + * @param value Numeric value to use in the internationalized relative time message. + * @param unit to use in the relative time internationalized message. + * Possible values are: year, quarter, month, week, day, hour, minute, second. + * @returns an Array of objects representing the relative time format in parts + * @since 8 + */ + formatToParts(value: number, unit: string): Array; + /** + * Returns a new object with properties reflecting the locale and formatting options computed during + * initialization of the object. + * + * @syscap SystemCapability.Global.I18n + * @returns RelativeTimeFormatOptions which reflecting the locale and formatting options of the object. + * @since 8 + */ + resolvedOptions(): RelativeTimeFormatResolvedOptions; + } +} +export default intl; diff --git a/build-tools/api/@ohos.matrix4.d.ts b/build-tools/api/@ohos.matrix4.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e92095bc38331803ed910be8a0158a102372341c --- /dev/null +++ b/build-tools/api/@ohos.matrix4.d.ts @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Used to do matrix operations + * @import import Matrix4 from '@ohos.matrix4' + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 7 + */ +declare namespace matrix4 { + /** + * Set translation parameters + * @since 7 + */ + interface TranslateOption { + /** + * Indicates the translation distance of the x-axis, in px. + * @since 7 + */ + x?: number; + /** + * Indicates the translation distance of the y-axis, in px. + * @since 7 + */ + y?: number; + /** + * Indicates the translation distance of the z-axis, in px. + * @since 7 + */ + z?: number; + } + /** + * Set scaling parameters + * @since 7 + */ + interface ScaleOption { + /** + * Zoom factor of the x-axis. + * @since 7 + */ + x?: number; + /** + * Zoom factor of the y-axis. + * @since 7 + */ + y?: number; + /** + * Zoom factor of the z-axis. + * @since 7 + */ + z?: number; + /** + * Transform the x-axis coordinate of the center point. + * @since 7 + */ + centerX?: number; + /** + * Transform the y-axis coordinate of the center point. + * @since 7 + */ + centerY?: number; + } + /** + * Set Rotation Parameters. + * @since 7 + */ + interface RotateOption { + /** + * Axis of rotation vector x coordinate. + * @since 7 + */ + x?: number; + /** + * Axis of rotation vector y coordinate. + * @since 7 + */ + y?: number; + /** + * Axis of rotation vector z coordinate. + * @since 7 + */ + z?: number; + /** + * Transform the x-axis coordinate of the center point. + * @since 7 + */ + centerX?: number; + /** + * Transform the y-axis coordinate of the center point. + * @since 7 + */ + centerY?: number; + /** + * Rotation angle. + * @since 7 + */ + angle?: number; + } + /** + * Matrix4Transit. + * @since 7 + */ + interface Matrix4Transit { + /** + * Copy function of Matrix, which can copy a copy of the current matrix object. + * @since 7 + * @return Return to Matrix4Transit + */ + copy(): Matrix4Transit; + /** + * The inverse function of Matrix returns an inverse matrix of the current matrix object, that is, the effect is exactly the opposite. + * @since 7 + * @return Return to Matrix4Transit + */ + invert(): Matrix4Transit; + /** + * Matrix superposition function, which can superpose the effects of two matrices to generate a new matrix object. + * @since 7 + * @return Return to Matrix4Transit + */ + combine(options: Matrix4Transit): Matrix4Transit; + /** + * Matrix translation function, which can add the x-axis, Y-axis, or Z-axis translation effect to the current matrix. + * @since 7 + * @return Return to Matrix4Transit + */ + translate(options: TranslateOption): Matrix4Transit; + /** + * Scaling function of the Matrix, which can add the x-axis, Y-axis, or Z-axis scaling effect to the current matrix. + * @since 7 + * @return Return to Matrix4Transit + */ + scale(options: ScaleOption): Matrix4Transit; + /** + * Rotation function of the Matrix. You can add the x-axis, Y-axis, or Z-axis rotation effect to the current matrix. + * @since 7 + * @return Return to Matrix4Transit + */ + rotate(options: RotateOption): Matrix4Transit; + /** + * Matrix coordinate point conversion function, which can apply the current transformation effect to a coordinate point. + * @since 7 + * @return Return to Matrix4Transit + */ + transformPoint(options: [ + number, + number + ]): [ + number, + number + ]; + } + /** + * Constructor of Matrix, which can create a fourth-order matrix based on the input parameters. The matrix is column-first. + * @since 7 + * @return Return to Matrix4Transit + */ + function init(options: [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number + ]): Matrix4Transit; + /** + * Matrix initialization function, which can return an identity matrix object. + * @since 7 + * @return Return to Matrix4Transit + */ + function identity(): Matrix4Transit; + /** + * Copy function of Matrix, which can copy a copy of the current matrix object. + * @since 7 + * @return Return to Matrix4Transit + */ + function copy(): Matrix4Transit; + /** + * The inverse function of Matrix returns an inverse matrix of the current matrix object, that is, the effect is exactly the opposite. + * @since 7 + * @return Return to Matrix4Transit + */ + function invert(): Matrix4Transit; + /** + * Matrix superposition function, which can superpose the effects of two matrices to generate a new matrix object. + * @since 7 + * @return Return to Matrix4Transit + */ + function combine(options: Matrix4Transit): Matrix4Transit; + /** + * Matrix translation function, which can add the x-axis, Y-axis, or Z-axis translation effect to the current matrix. + * @since 7 + * @return Return to Matrix4Transit + */ + function translate(options: TranslateOption): Matrix4Transit; + /** + * Scaling function of the Matrix, which can add the x-axis, Y-axis, or Z-axis scaling effect to the current matrix. + * @since 7 + * @return Return to Matrix4Transit + */ + function scale(options: ScaleOption): Matrix4Transit; + /** + * Rotation function of the Matrix. You can add the x-axis, Y-axis, or Z-axis rotation effect to the current matrix. + * @since 7 + * @return Return to Matrix4Transit + */ + function rotate(options: RotateOption): Matrix4Transit; + /** + * Matrix coordinate point conversion function, which can apply the current transformation effect to a coordinate point. + * @since 7 + * @return Return to Matrix4Transit + */ + function transformPoint(options: [ + number, + number + ]): [ + number, + number + ]; +} +export default matrix4; diff --git a/build-tools/api/@ohos.mediaquery.d.ts b/build-tools/api/@ohos.mediaquery.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b50565a1d0030ae12e12958b065266f8ded2fec8 --- /dev/null +++ b/build-tools/api/@ohos.mediaquery.d.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Callback } from './basic'; +/** + * Used to do mediaquery operations. + * @import import mediaquery from '@ohos.mediaquery' + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 7 + */ +declare namespace mediaquery { + interface MediaQueryResult { + /** + * Whether the match condition is met. + * This parameter is read-only. + * @since 7 + */ + readonly matches: boolean; + /** + * Matching condition of a media event. + * This parameter is read-only. + * @since 7 + */ + readonly media: string; + } + interface MediaQueryListener extends MediaQueryResult { + /** + * Registers a callback with the corresponding query condition by using the handle. + * This callback is triggered when the media attributes change. + * @since 7 + */ + on(type: 'change', callback: Callback): void; + /** + * Deregisters a callback with the corresponding query condition by using the handle. + * This callback is not triggered when the media attributes chang. + * @since 7 + */ + off(type: 'change', callback?: Callback): void; + } + /** + * Sets the media query criteria and returns the corresponding listening handle + * @since 7 + */ + function matchMediaSync(condition: string): MediaQueryListener; +} +export default mediaquery; diff --git a/build-tools/api/@ohos.multimedia.audio.d.ts b/build-tools/api/@ohos.multimedia.audio.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..55cabcb8c86e6ebf4ec5ef62aa3e88e785148731 --- /dev/null +++ b/build-tools/api/@ohos.multimedia.audio.d.ts @@ -0,0 +1,1904 @@ +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './basic'; +/** + * @name audio + * @since 7 + * @import import audio from '@ohos.multimedia.audio' + */ +declare namespace audio { + /** + * Obtains an AudioManager instance. + * @return AudioManager object. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + function getAudioManager(): AudioManager; + /** + * Obtains an AudioCapturer instance. This method uses an asynchronous callback to return the capturer instance. + * @param options Capturer configurations. + * @param callback Callback used to return the audio capturer instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + function createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback): void; + /** + * Obtains an AudioCapturer instance. This method uses a promise to return the capturer instance. + * @param options Capturer configurations. + * @return Promise used to return the audio capturer instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + function createAudioCapturer(options: AudioCapturerOptions): Promise; + /** + * Obtains an AudioRenderer instance. This method uses an asynchronous callback to return the renderer instance. + * @param options Renderer configurations. + * @param callback Callback used to return the audio renderer instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + function createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback): void; + /** + * Obtains an AudioRenderer instance. This method uses a promise to return the renderer instance. + * @param options Renderer configurations. + * @return Promise used to return the audio renderer instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + function createAudioRenderer(options: AudioRendererOptions): Promise; + /** + * Enumerates the audio states. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum AudioState { + /** + * Invalid state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STATE_INVALID = -1, + /** + * Create new instance state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STATE_NEW, + /** + * Prepared state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STATE_PREPARED, + /** + * Running state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STATE_RUNNING, + /** + * Stopped state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STATE_STOPPED, + /** + * Released state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STATE_RELEASED, + /** + * Paused state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STATE_PAUSED + } + /** + * Enumerates audio stream types. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + enum AudioVolumeType { + /** + * Audio streams for voice calls. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + VOICE_CALL = 0, + /** + * Audio streams for ringtones. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + RINGTONE = 2, + /** + * Audio streams for media purpose. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + MEDIA = 3, + /** + * Audio stream for voice assistant. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + VOICE_ASSISTANT = 9 + } + /** + * Enumerates audio device flags. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + enum DeviceFlag { + /** + * Output devices. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + OUTPUT_DEVICES_FLAG = 1, + /** + * Input devices. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + INPUT_DEVICES_FLAG = 2, + /** + * All devices. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + ALL_DEVICES_FLAG = 3 + } + /** + * Enumerates device roles. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + enum DeviceRole { + /** + * Input role. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + INPUT_DEVICE = 1, + /** + * Output role. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + OUTPUT_DEVICE = 2 + } + /** + * Enumerates device types. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + enum DeviceType { + /** + * Invalid device. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + INVALID = 0, + /** + * Built-in earpiece. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + EARPIECE = 1, + /** + * Built-in speaker. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + SPEAKER = 2, + /** + * Wired headset, which is a combination of a pair of earpieces and a microphone. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + WIRED_HEADSET = 3, + /** + * A pair of wired headphones. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + WIRED_HEADPHONES = 4, + /** + * Bluetooth device using the synchronous connection oriented link (SCO). + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + BLUETOOTH_SCO = 7, + /** + * Bluetooth device using advanced audio distribution profile (A2DP). + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + BLUETOOTH_A2DP = 8, + /** + * Built-in microphone. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + MIC = 15, + /** + * USB audio headset. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + USB_HEADSET = 22 + } + /** + * Enumerates the active device types. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + enum ActiveDeviceType { + /** + * Speaker. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + SPEAKER = 2, + /** + * Bluetooth device using the SCO link. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + BLUETOOTH_SCO = 7 + } + /** + * Enumerates ringer modes. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + enum AudioRingMode { + /** + * Silent mode. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + RINGER_MODE_SILENT = 0, + /** + * Vibration mode. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + RINGER_MODE_VIBRATE = 1, + /** + * Normal mode. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + RINGER_MODE_NORMAL = 2 + } + /** + * Enumerates the audio sample formats. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum AudioSampleFormat { + /** + * Invalid format. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_FORMAT_INVALID = -1, + /** + * Unsigned 8 format. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_FORMAT_U8 = 0, + /** + * Signed 16 bit integer, little endian. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_FORMAT_S16LE = 1, + /** + * Signed 24 bit integer, little endian. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_FORMAT_S24LE = 2, + /** + * Signed 32 bit integer, little endian. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_FORMAT_S32LE = 3, + /** + * Signed 32 bit float, little endian. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_FORMAT_F32LE = 4 + } + /** + * Enumerates the audio channel. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum AudioChannel { + /** + * Channel 1. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + CHANNEL_1 = 0x1 << 0, + /** + * Channel 2. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + CHANNEL_2 = 0x1 << 1 + } + /** + * Enumerates the audio sampling rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum AudioSamplingRate { + /** + * 8kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_8000 = 8000, + /** + * 11.025kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_11025 = 11025, + /** + * 12kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_12000 = 12000, + /** + * 16kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_16000 = 16000, + /** + * 22.05kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_22050 = 22050, + /** + * 24kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_24000 = 24000, + /** + * 32kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_32000 = 32000, + /** + * 44.1kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_44100 = 44100, + /** + * 48kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_48000 = 48000, + /** + * 64kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_64000 = 64000, + /** + * 96kHz sample rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SAMPLE_RATE_96000 = 96000 + } + /** + * Enumerates the audio encoding type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum AudioEncodingType { + /** + * Invalid type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + ENCODING_TYPE_INVALID = -1, + /** + * PCM encoding. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + ENCODING_TYPE_RAW = 0 + } + /** + * Enumerates the audio content type. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum ContentType { + /** + * Unknown content. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + CONTENT_TYPE_UNKNOWN = 0, + /** + * Speech content. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + CONTENT_TYPE_SPEECH = 1, + /** + * Music content. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + CONTENT_TYPE_MUSIC = 2, + /** + * Movie content. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + CONTENT_TYPE_MOVIE = 3, + /** + * Notification content. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + CONTENT_TYPE_SONIFICATION = 4, + /** + * Ringtone content. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + CONTENT_TYPE_RINGTONE = 5 + } + /** + * Enumerates the stream usage. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum StreamUsage { + /** + * Unkown usage. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STREAM_USAGE_UNKNOWN = 0, + /** + * Media usage. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STREAM_USAGE_MEDIA = 1, + /** + * Voice communication usage. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STREAM_USAGE_VOICE_COMMUNICATION = 2, + /** + * Notification or ringtone usage. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + STREAM_USAGE_NOTIFICATION_RINGTONE = 6 + } + /** + * Enumerates the focus type. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum FocusType { + /** + * Recording type. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + FOCUS_TYPE_RECORDING = 0 + } + /** + * Describes audio stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + interface AudioStreamInfo { + /** + * Sampling rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + samplingRate: AudioSamplingRate; + /** + * Audio channels. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + channels: AudioChannel; + /** + * Audio sample format. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + sampleFormat: AudioSampleFormat; + /** + * Audio encoding type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + encodingType: AudioEncodingType; + } + /** + * Describes audio renderer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + interface AudioRendererInfo { + /** + * Content type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + content: ContentType; + /** + * Stream usage. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + usage: StreamUsage; + /** + * Audio renderer flags. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + rendererFlags: number; + } + /** + * Describes audio renderer configuration options. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface AudioRendererOptions { + /** + * Stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + streamInfo: AudioStreamInfo; + /** + * Renderer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + rendererInfo: AudioRendererInfo; + } + /** + * Enumerates the interrupt modes. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum InterruptMode { + SHARE_MODE = 0, + INDEPENDENT_MODE = 1 + } + /** + * Enumerates the audio renderer rates. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + enum AudioRendererRate { + /** + * Normal rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + RENDER_RATE_NORMAL = 0, + /** + * Double rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + RENDER_RATE_DOUBLE = 1, + /** + * Half rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + RENDER_RATE_HALF = 2 + } + /** + * Enumerates the interrupt types. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + enum InterruptType { + /** + * Audio playback interruption started. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + INTERRUPT_TYPE_BEGIN = 1, + /** + * Audio playback interruption ended. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + INTERRUPT_TYPE_END = 2 + } + /** + * Enumerates the interrupt hints. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + enum InterruptHint { + /** + * None. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + INTERRUPT_HINT_NONE = 0, + /** + * Resume the playback. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + INTERRUPT_HINT_RESUME = 1, + /** + * Paused/Pause the playback. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + INTERRUPT_HINT_PAUSE = 2, + /** + * Stopped/Stop the playback. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + INTERRUPT_HINT_STOP = 3, + /** + * Ducked the playback. (In ducking, the audio volume is reduced, but not silenced.) + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + INTERRUPT_HINT_DUCK = 4, + /** + * Unducked the playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + INTERRUPT_HINT_UNDUCK = 5 + } + /** + * Enumerates the interrupt force types. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + enum InterruptForceType { + /** + * Forced action taken by system. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + INTERRUPT_FORCE = 0, + /** + * Share type, application can choose to take action or ignore. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + INTERRUPT_SHARE + } + /** + * Describes the interrupt event received by the app when playback is interrupted. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface InterruptEvent { + /** + * Indicates whether the interruption has started or finished. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + eventType: InterruptType; + /** + * Indicates whether the action is taken by system or to be taken by the app. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + forceType: InterruptForceType; + /** + * Indicates the kind of action. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + hintType: InterruptHint; + } + /** + * Enumerates interrupt action types. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + enum InterruptActionType { + /** + * Focus gain event. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + TYPE_ACTIVATED = 0, + /** + * Audio interruption event. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + TYPE_INTERRUPT = 1 + } + /** + * Enumerates device change types. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + enum DeviceChangeType { + /** + * Device connection. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + CONNECT = 0, + /** + * Device disconnection. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + DISCONNECT = 1 + } + /** + * Enumerates audio scenes. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + enum AudioScene { + /** + * Default audio scene + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + AUDIO_SCENE_DEFAULT = 0, + /** + * Voice chat audio scene + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + AUDIO_SCENE_VOICE_CHAT + } + /** + * Implements audio volume and audio device management. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + interface AudioManager { + /** + * Sets the volume for a stream. This method uses an asynchronous callback to return the result. + * @param volumeType Audio stream type. + * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. + * @param callback Callback used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + */ + setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback): void; + /** + * Sets the volume for a stream. This method uses a promise to return the result. + * @param volumeType Audio stream type. + * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. + * @return Promise used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + */ + setVolume(volumeType: AudioVolumeType, volume: number): Promise; + /** + * Obtains the volume of a stream. This method uses an asynchronous callback to return the query result. + * @param volumeType Audio stream type. + * @param callback Callback used to return the volume. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getVolume(volumeType: AudioVolumeType, callback: AsyncCallback): void; + /** + * Obtains the volume of a stream. This method uses a promise to return the query result. + * @param volumeType Audio stream type. + * @return Promise used to return the volume. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getVolume(volumeType: AudioVolumeType): Promise; + /** + * Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result. + * @param volumeType Audio stream type. + * @param callback Callback used to return the minimum volume. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback): void; + /** + * Obtains the minimum volume allowed for a stream. This method uses a promise to return the query result. + * @param volumeType Audio stream type. + * @return Promise used to return the minimum volume. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getMinVolume(volumeType: AudioVolumeType): Promise; + /** + * Obtains the maximum volume allowed for a stream. This method uses an asynchronous callback to return the query result. + * @param volumeType Audio stream type. + * @param callback Callback used to return the maximum volume. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback): void; + /** + * Obtains the maximum volume allowed for a stream. This method uses a promise to return the query result. + * @param volumeType Audio stream type. + * @return Promise used to return the maximum volume. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getMaxVolume(volumeType: AudioVolumeType): Promise; + /** + * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. + * @param deviceFlag Audio device flag. + * @param callback Callback used to return the device list. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback): void; + /** + * Obtains the audio devices with a specific flag. This method uses a promise to return the query result. + * @param deviceFlag Audio device flag. + * @return Promise used to return the device list. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + getDevices(deviceFlag: DeviceFlag): Promise; + /** + * Mutes a stream. This method uses an asynchronous callback to return the result. + * @param volumeType Audio stream type. + * @param mute Mute status to set. The value true means to mute the stream, and false means the opposite. + * @param callback Callback used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback): void; + /** + * Mutes a stream. This method uses a promise to return the result. + * @param volumeType Audio stream type. + * @param mute Mute status to set. The value true means to mute the stream, and false means the opposite. + * @return Promise used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + mute(volumeType: AudioVolumeType, mute: boolean): Promise; + /** + * Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. + * @param volumeType Audio stream type. + * @param callback Callback used to return the mute status of the stream. The value true means that the stream is + * muted, and false means the opposite. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + isMute(volumeType: AudioVolumeType, callback: AsyncCallback): void; + /** + * Checks whether a stream is muted. This method uses a promise to return the result. + * @param volumeType Audio stream type. + * @return Promise used to return the mute status of the stream. The value true means that the stream is muted, + * and false means the opposite. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + isMute(volumeType: AudioVolumeType): Promise; + /** + * Checks whether a stream is active. This method uses an asynchronous callback to return the query result. + * @param volumeType Audio stream type. + * @param callback Callback used to return the active status of the stream. The value true means that the stream is + * active, and false means the opposite. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + isActive(volumeType: AudioVolumeType, callback: AsyncCallback): void; + /** + * Checks whether a stream is active. This method uses a promise to return the query result. + * @param volumeType Audio stream type. + * @return Promise used to return the active status of the stream. The value true means that the stream is active, + * and false means the opposite. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + isActive(volumeType: AudioVolumeType): Promise; + /** + * Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. + * @param mute Mute status to set. The value true means to mute the microphone, and false means the opposite. + * @param callback Callback used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + * @permission ohos.permission.MICROPHONE + */ + setMicrophoneMute(mute: boolean, callback: AsyncCallback): void; + /** + * Mutes or unmutes the microphone. This method uses a promise to return the result. + * @param mute Mute status to set. The value true means to mute the microphone, and false means the opposite. + * @return Promise used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + * @permission ohos.permission.MICROPHONE + */ + setMicrophoneMute(mute: boolean): Promise; + /** + * Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. + * @param Callback used to return the mute status of the microphone. The value true means that the microphone is + * muted, and false means the opposite. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + * @permission ohos.permission.MICROPHONE + */ + isMicrophoneMute(callback: AsyncCallback): void; + /** + * Checks whether the microphone is muted. This method uses a promise to return the query result. + * @return Promise used to return the mute status of the microphone. The value true means that the microphone is + * muted, and false means the opposite. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + * @permission ohos.permission.MICROPHONE + */ + isMicrophoneMute(): Promise; + /** + * Sets the ringer mode. This method uses an asynchronous callback to return the result. + * @param mode Ringer mode. + * @param callback Callback used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Communication + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + */ + setRingerMode(mode: AudioRingMode, callback: AsyncCallback): void; + /** + * Sets the ringer mode. This method uses a promise to return the result. + * @param mode Ringer mode. + * @return Promise used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Communication + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + */ + setRingerMode(mode: AudioRingMode): Promise; + /** + * Obtains the ringer mode. This method uses an asynchronous callback to return the query result. + * @param callback Callback used to return the ringer mode. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + getRingerMode(callback: AsyncCallback): void; + /** + * Obtains the ringer mode. This method uses a promise to return the query result. + * @return Promise used to return the ringer mode. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + getRingerMode(): Promise; + /** + * Sets an audio parameter. This method uses an asynchronous callback to return the result. + * @param key Key of the audio parameter to set. + * @param value Value of the audio parameter to set. + * @param callback Callback used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + * @permission ohos.permission.MODIFY_AUDIO_SETTINGS + */ + setAudioParameter(key: string, value: string, callback: AsyncCallback): void; + /** + * Sets an audio parameter. This method uses a promise to return the result. + * @param key Key of the audio parameter to set. + * @param value Value of the audio parameter to set. + * @return Promise used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + * @permission ohos.permission.MODIFY_AUDIO_SETTINGS + */ + setAudioParameter(key: string, value: string): Promise; + /** + * Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result. + * @param key Key of the audio parameter whose value is to be obtained. + * @param callback Callback used to return the value of the audio parameter. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + getAudioParameter(key: string, callback: AsyncCallback): void; + /** + * Obtains the value of an audio parameter. This method uses a promise to return the query result. + * @param key Key of the audio parameter whose value is to be obtained. + * @return Promise used to return the value of the audio parameter. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + getAudioParameter(key: string): Promise; + /** + * Sets a device to the active state. This method uses an asynchronous callback to return the result. + * @param deviceType Audio device type. + * @param active Active status to set. The value true means to set the device to the active status, and false + * means the opposite. + * @param callback Callback used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback): void; + /** + * Sets a device to the active state. This method uses a promise to return the result. + * @param deviceType Audio device type. + * @param active Active status to set. The value true means to set the device to the active status, and false + * means the opposite. + * @return Promise used to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise; + /** + * Checks whether a device is active. This method uses an asynchronous callback to return the query result. + * @param deviceType Audio device type. + * @param callback Callback used to return the active status of the device. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback): void; + /** + * Checks whether a device is active. This method uses a promise to return the query result. + * @param deviceType Audio device type. + * @return Promise used to return the active status of the device. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + isDeviceActive(deviceType: ActiveDeviceType): Promise; + /** + * Obtains the audio scene mode. This method uses an asynchronous callback to return the query result. + * @param callback Callback used to return the audio scene mode. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + getAudioScene(callback: AsyncCallback): void; + /** + * Obtains the audio scene mode. This method uses a promise to return the query result. + * @return Promise used to return the audio scene mode. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + getAudioScene(): Promise; + /** + * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive + * the callback. + * @param callback Callback used to obtain the device update details. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + on(type: 'deviceChange', callback: Callback): void; + /** + * UnSubscribes to device change events. + * @param callback Callback used to obtain the device update details. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + off(type: 'deviceChange', callback?: Callback): void; + /** + * Listens for audio interruption events. When the audio of an application is interrupted by another application, + * the callback is invoked to notify the former application. + * @param type Type of the event to listen for. Only the interrupt event is supported. + * @param interrupt Parameters of the audio interruption event type. + * @param callback Callback invoked for the audio interruption event. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback): void; + /** + * Cancels the listening of audio interruption events. + * @param type Type of the event to listen for. Only the interrupt event is supported. + * @param interrupt Input parameters of the audio interruption event. + * @param callback Callback invoked for the audio interruption event. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback): void; + /** + * Obtains an AudioStreamManager instance. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + getStreamManager(callback: AsyncCallback): void; + /** + * Obtains an AudioStreamManager instance. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + getStreamManager(): Promise; + } + /** + * Implements audio stream management. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + interface AudioStreamManager { + /** + * Get information of current existing audio renderers. + * @param callback Callback used to return the information of current existing audio renderers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioRendererInfoArray(callback: AsyncCallback): void; + /** + * Get information of current existing audio renderers. + * @return Promise used to return the information of current existing audio renderers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioRendererInfoArray(): Promise; + /** + * Get information of current existing audio capturers. + * @param callback Callback used to return the information of current existing audio capturers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioCapturerInfoArray(callback: AsyncCallback): void; + /** + * Get information of current existing audio capturers. + * @return Promise used to return the information of current existing audio capturers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioCapturerInfoArray(): Promise; + /** + * Listens for audio renderer change events. When there is any audio renderer change, + * registered clients will receive the callback. + * @param type Type of the event to listen for. Only the audioRendererChange event is supported. + * @param callback Callback invoked for the audio renderer change event. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: "audioRendererChange", callback: Callback): void; + /** + * UnSubscribes to audio renderer change events. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + off(type: "audioRendererChange"); + /** + * Listens for audio capturer change events. When there is any audio capturer change, + * registered clients will receive the callback. + * @param type Type of the event to listen for. Only the audioCapturerChange event is supported. + * @param callback Callback invoked for the audio capturer change event. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + on(type: "audioCapturerChange", callback: Callback): void; + /** + * UnSubscribes to audio capturer change events. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + off(type: "audioCapturerChange"); + } + /** + * Array of AudioRendererChangeInfo, which is read-only. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + type AudioRendererChangeInfoArray = Array>; + /** + * Describes audio renderer change information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface AudioRendererChangeInfo { + /** + * Audio stream unique id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly streamId: number; + /** + * Audio renderer information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly rendererInfo: AudioRendererInfo; + /** + * Audio output devices. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly deviceDescriptors: AudioDeviceDescriptors; + } + /** + * Array of AudioCapturerChangeInfo, which is read-only. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + type AudioCapturerChangeInfoArray = Array>; + /** + * Describes audio capturer change information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + interface AudioCapturerChangeInfo { + /** + * Audio stream unique id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly streamId: number; + /** + * Audio capturer information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly capturerInfo: AudioCapturerInfo; + /** + * Audio input devices. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly deviceDescriptors: AudioDeviceDescriptors; + } + /** + * Describes an audio device. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + interface AudioDeviceDescriptor { + /** + * Audio device role. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + readonly deviceRole: DeviceRole; + /** + * Audio device type. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + readonly deviceType: DeviceType; + /** + * Audio device id. + * @since 9 + * @SysCap SystemCapability.Multimedia.Audio.Device + */ + readonly id: number; + /** + * Audio device name. + * @since 9 + * @SysCap SystemCapability.Multimedia.Audio.Device + */ + readonly name: string; + /** + * Audio device address. + * @since 9 + * @SysCap SystemCapability.Multimedia.Audio.Device + */ + readonly address: string; + /** + * Supported sampling rates. + * @since 9 + * @SysCap SystemCapability.Multimedia.Audio.Device + */ + readonly sampleRates: Array; + /** + * Supported channel counts. + * @since 9 + * @SysCap SystemCapability.Multimedia.Audio.Device + */ + readonly channelCounts: Array; + /** + * Supported channel masks. + * @since 9 + * @SysCap SystemCapability.Multimedia.Audio.Device + */ + readonly channelMasks: Array; + } + /** + * Array of AudioDeviceDescriptors, which is read-only. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + type AudioDeviceDescriptors = Array>; + /** + * Describes the callback invoked for audio interruption or focus gain events.When the audio of an application + * is interrupted by another application, the callback is invoked to notify the former application. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface InterruptAction { + /** + * Event type. + * The value TYPE_ACTIVATED means the focus gain event, and TYPE_INTERRUPT means the audio interruption event. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + actionType: InterruptActionType; + /** + * Type of the audio interruption event. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + type?: InterruptType; + /** + * Hint for the audio interruption event. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + hint?: InterruptHint; + /** + * Whether the focus is gained or released. The value true means that the focus is gained or released, + * and false means that the focus fails to be gained or released. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + activated?: boolean; + } + /** + * Describes input parameters of audio listening events. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface AudioInterrupt { + /** + * Audio stream usage type. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + streamUsage: StreamUsage; + /** + * Type of the media interrupted. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + contentType: ContentType; + /** + * Whether audio playback can be paused when it is interrupted. + * The value true means that audio playback can be paused when it is interrupted, and false means the opposite. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + pauseWhenDucked: boolean; + } + /** + * Describes the device change type and device information. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + interface DeviceChangeAction { + /** + * Device change type. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + type: DeviceChangeType; + /** + * Device information. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + deviceDescriptors: AudioDeviceDescriptors; + } + /** + * Provides audio playback APIs. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface AudioRenderer { + /** + * Defines the current render state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly state: AudioState; + /** + * Obtains the renderer information provided while creating a renderer instance. This method uses an asynchronous + * callback to return the result. + * @param callback Callback used to return the renderer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getRendererInfo(callback: AsyncCallback): void; + /** + * Obtains the renderer information provided while creating a renderer instance. This method uses a promise to + * return the result. + * @return Promise used to return the renderer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getRendererInfo(): Promise; + /** + * Obtains the renderer stream information. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getStreamInfo(callback: AsyncCallback): void; + /** + * Obtains the renderer stream information. This method uses a promise to return the result. + * @return Promise used to return the stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getStreamInfo(): Promise; + /** + * Starts the renderer. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + start(callback: AsyncCallback): void; + /** + * Starts the renderer. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + start(): Promise; + /** + * Writes the buffer. This method uses an asynchronous callback to return the result. + * @param buffer Buffer to be written. + * @param callback Returns the number of bytes written if the operation is successful; returns an error code + * otherwise. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + write(buffer: ArrayBuffer, callback: AsyncCallback): void; + /** + * Writes the buffer. This method uses a promise to return the result. + * @param buffer Buffer to be written. + * @return Returns the number of bytes written if the operation is successful; returns an error code otherwise. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + write(buffer: ArrayBuffer): Promise; + /** + * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an + * asynchronous callback to return the result. + * @param callback Callback used to return the timestamp. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getAudioTime(callback: AsyncCallback): void; + /** + * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a + * promise to return the result. + * @return Promise used to return the timestamp. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getAudioTime(): Promise; + /** + * Drains the playback buffer. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + drain(callback: AsyncCallback): void; + /** + * Drains the playback buffer. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + drain(): Promise; + /** + * Pauses rendering. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + pause(callback: AsyncCallback): void; + /** + * Pauses rendering. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + pause(): Promise; + /** + * Stops rendering. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + stop(callback: AsyncCallback): void; + /** + * Stops rendering. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + stop(): Promise; + /** + * Releases the renderer. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + release(callback: AsyncCallback): void; + /** + * Releases the renderer. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + release(): Promise; + /** + * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses an asynchronous callback to + * return the result. + * @param callback Callback used to return the buffer size. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getBufferSize(callback: AsyncCallback): void; + /** + * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses a promise to return the result. + * @return Promise used to return the buffer size. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getBufferSize(): Promise; + /** + * Sets the render rate. This method uses an asynchronous callback to return the result. + * @param rate Audio render rate. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + setRenderRate(rate: AudioRendererRate, callback: AsyncCallback): void; + /** + * Sets the render rate. This method uses a promise to return the result. + * @param rate Audio render rate. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + setRenderRate(rate: AudioRendererRate): Promise; + /** + * Obtains the current render rate. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the audio render rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getRenderRate(callback: AsyncCallback): void; + /** + * Obtains the current render rate. This method uses a promise to return the result. + * @return Promise used to return the audio render rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getRenderRate(): Promise; + /** + * Set interrupt mode. + * @param mode The interrupt mode. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + setInterruptMode(mode: InterruptMode, callback: AsyncCallback): void; + /** + * Set interrupt mode. + * @param mode The interrupt mode. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + setInterruptMode(mode: InterruptMode): Promise; + /** + * Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is + * triggered when audio playback is interrupted. + * @param callback Callback used to listen for interrupt callback. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: 'interrupt', callback: Callback): void; + /** + * Subscribes to mark reached events. When the number of frames rendered reaches the value of the frame parameter, + * the callback is invoked. + * @param frame Number of frames to trigger the event. The value must be greater than 0. + * @param callback Callback invoked when the event is triggered. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: "markReach", frame: number, callback: (position: number) => {}): void; + /** + * Unsubscribes from mark reached events. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + off(type: "markReach"): void; + /** + * Subscribes to period reached events. When the period of frame rendering reaches the value of frame parameter, + * the callback is invoked. + * @param frame Period during which frame rendering is listened. The value must be greater than 0. + * @param callback Callback invoked when the event is triggered. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: "periodReach", frame: number, callback: (position: number) => {}): void; + /** + * Unsubscribes from period reached events. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + off(type: "periodReach"): void; + /** + * Subscribes audio state change event callback. + * @param callback Callback invoked when state change. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: "stateChange", callback: Callback): void; + } + /** + * Enumerates source types. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum SourceType { + /** + * Invalid source type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SOURCE_TYPE_INVALID = -1, + /** + * Mic source type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SOURCE_TYPE_MIC = 0, + /** + * Voice communication source type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SOURCE_TYPE_VOICE_COMMUNICATION = 7 + } + /** + * Describes audio capturer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + interface AudioCapturerInfo { + /** + * Audio source type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + source: SourceType; + /** + * Audio capturer flags. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + capturerFlags: number; + } + /** + * Describes audio capturer configuration options. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + interface AudioCapturerOptions { + /** + * Stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + streamInfo: AudioStreamInfo; + /** + * Capturer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + capturerInfo: AudioCapturerInfo; + } + /** + * Provides APIs for audio recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + interface AudioCapturer { + /** + * Defines the current capture state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly state: AudioState; + /** + * Obtains the capturer information provided while creating a capturer instance. This method uses an asynchronous + * callback to return the result. + * @param callback Callback used to return the capturer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getCapturerInfo(callback: AsyncCallback): void; + /** + * Obtains the capturer information provided while creating a capturer instance. This method uses a promise to + * return the result. + * @return Promise used to return the capturer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getCapturerInfo(): Promise; + /** + * Obtains the capturer stream information. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getStreamInfo(callback: AsyncCallback): void; + /** + * Obtains the capturer stream information. This method uses a promise to return the result. + * @return Promise used to return the stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getStreamInfo(): Promise; + /** + * Starts capturing. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + start(callback: AsyncCallback): void; + /** + * Starts capturing. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + start(): Promise; + /** + * Reads the buffer from the audio capturer. This method uses an asynchronous callback to return the result. + * @param size Number of bytes to read. + * @param isBlockingRead Whether the read operation should be blocked. + * @param callback Callback used to return the buffer. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + read(size: number, isBlockingRead: boolean, callback: AsyncCallback): void; + /** + * Reads the buffer from the audio capturer. This method uses a promise to return the result. + * @param size Number of bytes to read. + * @param isBlockingRead Whether the read operation should be blocked. + * @return Returns the buffer data read if the operation is successful; returns an error code otherwise. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + read(size: number, isBlockingRead: boolean): Promise; + /** + * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an + * asynchronous callback to return the result. + * @param callback Callback used to return the timestamp. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getAudioTime(callback: AsyncCallback): void; + /** + * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a + * promise to return the result. + * @return Promise used to return the timestamp. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getAudioTime(): Promise; + /** + * Stops capturing. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + stop(callback: AsyncCallback): void; + /** + * Stops capturing. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + stop(): Promise; + /** + * Releases the capturer. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + release(callback: AsyncCallback): void; + /** + * Releases the capturer. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + release(): Promise; + /** + * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses an asynchronous callback to + * return the result. + * @param callback Callback used to return the buffer size. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getBufferSize(callback: AsyncCallback): void; + /** + * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses a promise to return the result. + * @return Promise used to return the buffer size. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getBufferSize(): Promise; + /** + * Subscribes to mark reached events. When the number of frames captured reaches the value of the frame parameter, + * the callback is invoked. + * @param frame Number of frames to trigger the event. The value must be greater than 0. + * @param callback Callback invoked when the event is triggered. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + on(type: "markReach", frame: number, callback: (position: number) => {}): void; + /** + * Unsubscribes from the mark reached events. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + off(type: "markReach"): void; + /** + * Subscribes to period reached events. When the period of frame capturing reaches the value of frame parameter, + * the callback is invoked. + * @param frame Period during which frame capturing is listened. The value must be greater than 0. + * @param callback Callback invoked when the event is triggered. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + on(type: "periodReach", frame: number, callback: (position: number) => {}): void; + /** + * Unsubscribes from period reached events. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + off(type: "periodReach"): void; + /** + * Subscribes audio state change event callback. + * @param callback Callback used to listen for the audio state change event. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + on(type: "stateChange", callback: Callback): void; + } +} +export default audio; diff --git a/build-tools/api/@ohos.multimedia.camera.d.ts b/build-tools/api/@ohos.multimedia.camera.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6cbd01a5cce7c4d86efd04ca45081edab70941d --- /dev/null +++ b/build-tools/api/@ohos.multimedia.camera.d.ts @@ -0,0 +1,1250 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ErrorCallback, AsyncCallback } from './basic'; +import { Context } from './app/context'; +/** + * @name camera + * @syscap SystemCapability.Multimedia.Camera.Core + * @import import camera from '@ohos.multimedia.camera'; + * @since 9 + */ +declare namespace camera { + /** + * Creates a CameraManager instance. + * @param context Current application context. + * @param callback Callback used to return the CameraManager instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + function getCameraManager(context: Context, callback: AsyncCallback): void; + /** + * Creates a CameraManager instance. + * @param context Current application context. + * @return Promise used to return the CameraManager instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + function getCameraManager(context: Context): Promise; + /** + * Enum for camera status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum CameraStatus { + /** + * Appear status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_STATUS_APPEAR = 0, + /** + * Disappear status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_STATUS_DISAPPEAR, + /** + * Available status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_STATUS_AVAILABLE, + /** + * Unavailable status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_STATUS_UNAVAILABLE + } + /** + * Camera manager object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraManager { + /** + * Gets all camera descriptions. + * @param callback Callback used to return the array of supported cameras. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getCameras(callback: AsyncCallback>): void; + /** + * Gets all camera descriptions. + * @return Promise used to return an array of supported cameras. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getCameras(): Promise>; + /** + * Creates a CameraInput instance by camera id. + * @param cameraId Camera ID used to create the instance. + * @param callback Callback used to return the CameraInput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @permission ohos.permission.CAMERA + */ + createCameraInput(cameraId: string, callback: AsyncCallback): void; + /** + * Creates a CameraInput instance by camera id. + * @param cameraId Camera ID used to create the instance. + * @return Promise used to return the CameraInput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @permission ohos.permission.CAMERA + */ + createCameraInput(cameraId: string): Promise; + /** + * Creates a CameraInput instance by camera position and type. + * @param position Target camera position. + * @param type Target camera type. + * @param callback Callback used to return the CameraInput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @permission ohos.permission.CAMERA + */ + createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; + /** + * Creates a CameraInput instance by camera position and type. + * @param position Target camera position. + * @param type Target camera type. + * @return Promise used to return the CameraInput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @permission ohos.permission.CAMERA + */ + createCameraInput(position: CameraPosition, type: CameraType): Promise; + /** + * Subscribes camera status change event callback. + * @param type Event type. + * @param callback Callback used to get the camera status change. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'cameraStatus', callback: AsyncCallback): void; + } + /** + * Camera status info. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraStatusInfo { + /** + * Camera instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + camera: Camera; + /** + * Current camera status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + status: CameraStatus; + } + /** + * Enum for camera position. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum CameraPosition { + /** + * Unspecified position. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_POSITION_UNSPECIFIED = 0, + /** + * Back position. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_POSITION_BACK, + /** + * Front position. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_POSITION_FRONT + } + /** + * Enum for camera type. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum CameraType { + /** + * Unspecified camera type + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_TYPE_UNSPECIFIED = 0, + /** + * Wide camera + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_TYPE_WIDE_ANGLE, + /** + * Ultra wide camera + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_TYPE_ULTRA_WIDE, + /** + * Telephoto camera + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_TYPE_TELEPHOTO, + /** + * True depth camera + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_TYPE_TRUE_DEPTH + } + /** + * Enum for camera connection type. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum ConnectionType { + /** + * Built-in camera. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_CONNECTION_BUILT_IN = 0, + /** + * Camera connected using USB + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_CONNECTION_USB_PLUGIN, + /** + * Remote camera + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_CONNECTION_REMOTE + } + /** + * Camera object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface Camera { + /** + * Camera id attribute. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly cameraId: string; + /** + * Camera position attribute. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly cameraPosition: CameraPosition; + /** + * Camera type attribute. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly cameraType: CameraType; + /** + * Camera connection type attribute. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly connectionType: ConnectionType; + } + /** + * Size parameter. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface Size { + /** + * Height. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + height: number; + /** + * Width. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + width: number; + } + /** + * Camera input object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraInput { + /** + * Gets camera id. + * @param callback Callback used to return the camera ID. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getCameraId(callback: AsyncCallback): void; + /** + * Gets camera id. + * @return Promise used to return the camera ID. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getCameraId(): Promise; + /** + * Check if device has flash light. + * @param callback Callback used to return the flash light support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + hasFlash(callback: AsyncCallback): void; + /** + * Check if device has flash light. + * @return Promise used to return the flash light support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + hasFlash(): Promise; + /** + * Checks whether a specified flash mode is supported. + * @param flashMode Flash mode. + * @param callback Callback used to return the flash light support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; + /** + * Checks whether a specified flash mode is supported. + * @param flashMode Flash mode + * @return Promise used to return flash mode support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isFlashModeSupported(flashMode: FlashMode): Promise; + /** + * Gets current flash mode. + * @param callback Callback used to return the current flash mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFlashMode(callback: AsyncCallback): void; + /** + * Gets current flash mode. + * @return Promise used to return the flash mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFlashMode(): Promise; + /** + * Sets flash mode. + * @param flashMode Target flash mode. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; + /** + * Sets flash mode. + * @param flashMode Target flash mode. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setFlashMode(flashMode: FlashMode): Promise; + /** + * Checks whether a specified focus mode is supported. + * @param afMode Focus mode. + * @param callback Callback used to return the device focus support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; + /** + * Checks whether a specified focus mode is supported. + * @param afMode Focus mode. + * @return Promise used to return the focus mode support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isFocusModeSupported(afMode: FocusMode): Promise; + /** + * Gets current focus mode. + * @param callback Callback used to return the current focus mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFocusMode(callback: AsyncCallback): void; + /** + * Gets current focus mode. + * @return Promise used to return the focus mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFocusMode(): Promise; + /** + * Sets focus mode. + * @param afMode Target focus mode. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; + /** + * Sets focus mode. + * @param afMode Target focus mode. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setFocusMode(afMode: FocusMode): Promise; + /** + * Gets all supported zoom ratio range. + * @param callback Callback used to return the zoom ratio range. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getZoomRatioRange(callback: AsyncCallback>): void; + /** + * Gets all supported zoom ratio range. + * @return Promise used to return the zoom ratio range. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getZoomRatioRange(): Promise>; + /** + * Gets zoom ratio. + * @param callback Callback used to return the current zoom ratio value. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getZoomRatio(callback: AsyncCallback): void; + /** + * Gets zoom ratio. + * @return Promise used to return the zoom ratio value. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getZoomRatio(): Promise; + /** + * Sets zoom ratio. + * @param zoomRatio Target zoom ratio. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; + /** + * Sets zoom ratio. + * @param zoomRatio Target zoom ratio. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setZoomRatio(zoomRatio: number): Promise; + /** + * Releases instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(callback: AsyncCallback): void; + /** + * Releases instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(): Promise; + /** + * Subscribes focus status change event callback. + * @param type Event type. + * @param callback Callback used to get the focus state change. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'focusStateChange', callback: AsyncCallback): void; + /** + * Subscribes error event callback. + * @param type Event type. + * @param callback Callback used to get the camera input errors. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'error', callback: ErrorCallback): void; + } + /** + * Enum for CameraInput error code. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum CameraInputErrorCode { + /** + * Unknown error. + * @since 9 + */ + ERROR_UNKNOWN = -1 + } + /** + * Camera input error object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraInputError extends Error { + code: CameraInputErrorCode; + } + /** + * Enum for flash mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum FlashMode { + /** + * Close mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FLASH_MODE_CLOSE = 0, + /** + * Open mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FLASH_MODE_OPEN, + /** + * Auto mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FLASH_MODE_AUTO, + /** + * Always open mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FLASH_MODE_ALWAYS_OPEN + } + /** + * Enum for focus mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum FocusMode { + /** + * Manual mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FOCUS_MODE_MANUAL = 0, + /** + * Continuous auto mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FOCUS_MODE_CONTINUOUS_AUTO, + /** + * Auto mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FOCUS_MODE_AUTO, + /** + * Locked mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FOCUS_MODE_LOCKED + } + /** + * Enum for focus state. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum FocusState { + /** + * Scan state. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FOCUS_STATE_SCAN = 0, + /** + * Focused state. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FOCUS_STATE_FOCUSED, + /** + * Unfocused state. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + FOCUS_STATE_UNFOCUSED + } + /** + * Gets a CaptureSession instance. + * @param context Current application context. + * @param callback Callback used to return the CaptureSession instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + function createCaptureSession(context: Context, callback: AsyncCallback): void; + /** + * Gets a CaptureSession instance. + * @param context Current application context. + * @return Promise used to return the CaptureSession instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + function createCaptureSession(context: Context): Promise; + /** + * Capture session object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CaptureSession { + /** + * Begin capture session config. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + beginConfig(callback: AsyncCallback): void; + /** + * Begin capture session config. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + beginConfig(): Promise; + /** + * Commit capture session config. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + commitConfig(callback: AsyncCallback): void; + /** + * Commit capture session config. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + commitConfig(): Promise; + /** + * Adds a camera input. + * @param cameraInput Target camera input to add. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + addInput(cameraInput: CameraInput, callback: AsyncCallback): void; + /** + * Adds a camera input. + * @param cameraInput Target camera input to add. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + addInput(cameraInput: CameraInput): Promise; + /** + * Adds a camera preview output. + * @param previewOutput Target camera preview output to add. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + addOutput(previewOutput: PreviewOutput, callback: AsyncCallback): void; + /** + * Adds a camera preview output. + * @param previewOutput Target camera preview output to add. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + addOutput(previewOutput: PreviewOutput): Promise; + /** + * Adds a camera photo output. + * @param photoOutput Target camera photo output to add. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + addOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; + /** + * Adds a camera photo output. + * @param photoOutput Target camera photo output to add. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + addOutput(photoOutput: PhotoOutput): Promise; + /** + * Adds a camera video output. + * @param videoOutput Target camera video output to add. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + addOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; + /** + * Adds a camera video output. + * @param videoOutput Target camera video output to add. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + addOutput(videoOutput: VideoOutput): Promise; + /** + * Removes a camera input. + * @param cameraInput Target camera input to remove. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + removeInput(cameraInput: CameraInput, callback: AsyncCallback): void; + /** + * Removes a camera input. + * @param cameraInput Target camera input to remove. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + removeInput(cameraInput: CameraInput): Promise; + /** + * Removes a camera preview output. + * @param previewOutput Target camera preview output to remove. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback): void; + /** + * Removes a camera preview output. + * @param previewOutput Target camera preview output to remove. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + removeOutput(previewOutput: PreviewOutput): Promise; + /** + * Removes a camera photo output. + * @param photoOutput Target camera photo output to remove. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; + /** + * Removes a camera photo output. + * @param photoOutput Target camera photo output to remove. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + removeOutput(photoOutput: PhotoOutput): Promise; + /** + * Removes a camera video output. + * @param videoOutput Target camera video output to remove. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; + /** + * Removes a camera video output. + * @param videoOutput Target camera video output to remove. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + removeOutput(videoOutput: VideoOutput): Promise; + /** + * Starts capture session. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + start(callback: AsyncCallback): void; + /** + * Starts capture session. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + start(): Promise; + /** + * Stops capture session. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + stop(callback: AsyncCallback): void; + /** + * Stops capture session. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + stop(): Promise; + /** + * Release capture session instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(callback: AsyncCallback): void; + /** + * Release capture session instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(): Promise; + /** + * Subscribes error event callback. + * @param type Event type. + * @param callback Callback used to get the capture session errors. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'error', callback: ErrorCallback): void; + } + /** + * Enum for CaptureSession error code. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum CaptureSessionErrorCode { + ERROR_UNKNOWN = -1 + } + /** + * Capture session error object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CaptureSessionError extends Error { + code: CaptureSessionErrorCode; + } + /** + * Creates a PreviewOutput instance. + * @param surfaceId Surface object id used in camera preview output. + * @param callback Callback used to return the PreviewOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + function createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; + /** + * Creates a PreviewOutput instance. + * @param surfaceId Surface object id used in camera preview output. + * @return Promise used to return the PreviewOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + function createPreviewOutput(surfaceId: string): Promise; + /** + * Preview output object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface PreviewOutput { + /** + * Release output instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(callback: AsyncCallback): void; + /** + * Release output instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(): Promise; + /** + * Subscribes frame start event callback. + * @param type Event type. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'frameStart', callback: AsyncCallback): void; + /** + * Subscribes frame end event callback. + * @param type Event type. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'frameEnd', callback: AsyncCallback): void; + /** + * Subscribes error event callback. + * @param type Event type. + * @param callback Callback used to get the preview output errors. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'error', callback: ErrorCallback): void; + } + /** + * Enum for preview output error code. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum PreviewOutputErrorCode { + ERROR_UNKNOWN = -1 + } + /** + * Preview output error object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface PreviewOutputError extends Error { + code: PreviewOutputErrorCode; + } + /** + * Creates a PhotoOutput instance. + * @param surfaceId Surface object id used in camera photo output. + * @param callback Callback used to return the PhotoOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + function createPhotoOutput(surfaceId: string, callback: AsyncCallback): void; + /** + * Creates a PhotoOutput instance. + * @param surfaceId Surface object id used in camera photo output. + * @return Promise used to return the PhotoOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + function createPhotoOutput(surfaceId: string): Promise; + /** + * Enumerates the image rotation angles. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum ImageRotation { + /** + * The capture image rotates 0 degrees. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + ROTATION_0 = 0, + /** + * The capture image rotates 90 degrees. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + ROTATION_90 = 90, + /** + * The capture image rotates 180 degrees. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + ROTATION_180 = 180, + /** + * The capture image rotates 270 degrees. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + ROTATION_270 = 270 + } + /** + * Enumerates the image quality levels. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum QualityLevel { + /** + * High image quality. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + QUALITY_LEVEL_HIGH = 0, + /** + * Medium image quality. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + QUALITY_LEVEL_MEDIUM, + /** + * Low image quality. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + QUALITY_LEVEL_LOW + } + /** + * Photo capture options to set. + * @since 9 + */ + interface PhotoCaptureSetting { + /** + * Photo image quality. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + quality?: QualityLevel; + /** + * Photo rotation. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + rotation?: ImageRotation; + } + /** + * Photo output object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface PhotoOutput { + /** + * Start capture output. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + capture(callback: AsyncCallback): void; + /** + * Start capture output. + * @param setting Photo capture settings. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; + /** + * Start capture output. + * @param setting Photo capture settings. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + capture(setting?: PhotoCaptureSetting): Promise; + /** + * Release output instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(callback: AsyncCallback): void; + /** + * Release output instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(): Promise; + /** + * Subscribes capture start event callback. + * @param type Event type. + * @param callback Callback used to get the capture ID. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'captureStart', callback: AsyncCallback): void; + /** + * Subscribes frame shutter event callback. + * @param type Event type. + * @param callback Callback used to get the frame shutter information. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'frameShutter', callback: AsyncCallback): void; + /** + * Subscribes capture end event callback. + * @param type Event type. + * @param callback Callback used to get the capture end information. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'captureEnd', callback: AsyncCallback): void; + /** + * Subscribes error event callback. + * @param type Event type. + * @param callback Callback used to get the photo output errors. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'error', callback: ErrorCallback): void; + } + /** + * Frame shutter callback info. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface FrameShutterInfo { + /** + * Capture id. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + captureId: number; + /** + * Timestamp for frame. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + timestamp: number; + } + /** + * Capture end info. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CaptureEndInfo { + /** + * Capture id. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + captureId: number; + /** + * Frame count. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + frameCount: number; + } + /** + * Enum for photo output error code. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum PhotoOutputErrorCode { + ERROR_UNKNOWN = -1 + } + /** + * Photo output error object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface PhotoOutputError extends Error { + code: PhotoOutputErrorCode; + } + /** + * Creates a VideoOutput instance. + * @param surfaceId Surface object id used in camera video output. + * @param callback Callback used to return the VideoOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + function createVideoOutput(surfaceId: string, callback: AsyncCallback): void; + /** + * Creates a VideoOutput instance. + * @param surfaceId Surface object id used in camera video output. + * @return Promise used to return the VideoOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + function createVideoOutput(surfaceId: string): Promise; + /** + * Video output object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface VideoOutput { + /** + * Start video output. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + start(callback: AsyncCallback): void; + /** + * Start video output. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + start(): Promise; + /** + * Stop video output. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + stop(callback: AsyncCallback): void; + /** + * Stop video output. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + stop(): Promise; + /** + * Release output instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(callback: AsyncCallback): void; + /** + * Release output instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(): Promise; + /** + * Subscribes frame start event callback. + * @param type Event type. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'frameStart', callback: AsyncCallback): void; + /** + * Subscribes frame end event callback. + * @param type Event type. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'frameEnd', callback: AsyncCallback): void; + /** + * Subscribes error event callback. + * @param type Event type. + * @param callback Callback used to get the video output errors. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'error', callback: ErrorCallback): void; + } + /** + * Enum for video output error code. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum VideoOutputErrorCode { + ERROR_UNKNOWN = -1 + } + /** + * Video output error object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface VideoOutputError extends Error { + code: VideoOutputErrorCode; + } +} +export default camera; diff --git a/build-tools/api/@ohos.multimedia.image.d.ts b/build-tools/api/@ohos.multimedia.image.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1676bd3374d84faabfb2fe28599a878643a90b4d --- /dev/null +++ b/build-tools/api/@ohos.multimedia.image.d.ts @@ -0,0 +1,1179 @@ +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback } from './basic'; +/** + * @name image + * @since 6 + * @import import image from '@ohos.multimedia.image'; + */ +declare namespace image { + /** + * Enumerates pixel map formats. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + enum PixelMapFormat { + /** + * Indicates an unknown format. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + UNKNOWN = 0, + /** + * Indicates that each pixel is stored on 16 bits. Only the R, G, and B components are encoded + * from the higher-order to the lower-order bits: red is stored with 5 bits of precision, + * green is stored with 6 bits of precision, and blue is stored with 5 bits of precision. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + RGB_565 = 2, + /** + * Indicates that each pixel is stored on 32 bits. Components R, G, B, and A each occupies 8 bits + * and are stored from the higher-order to the lower-order bits. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + RGBA_8888 = 3 + } + /** + * Describes the size of an image. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface Size { + /** + * Height + * @since 6 + * @syscap SystemCapability.Multimedia.Image.Core + */ + height: number; + /** + * Width + * @since 6 + * @syscap SystemCapability.Multimedia.Image.Core + */ + width: number; + } + /** + * Enumerates exchangeable image file format (Exif) information types of an image. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + enum PropertyKey { + /** + * Number of bits in each pixel of an image. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + BITS_PER_SAMPLE = "BitsPerSample", + /** + * Image rotation mode. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + ORIENTATION = "Orientation", + /** + * Image length. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + IMAGE_LENGTH = "ImageLength", + /** + * Image width. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + IMAGE_WIDTH = "ImageWidth", + /** + * GPS latitude. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + GPS_LATITUDE = "GPSLatitude", + /** + * GPS longitude. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + GPS_LONGITUDE = "GPSLongitude", + /** + * GPS latitude reference. For example, N indicates north latitude and S indicates south latitude. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + GPS_LATITUDE_REF = "GPSLatitudeRef", + /** + * GPS longitude reference. For example, E indicates east longitude and W indicates west longitude. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + GPS_LONGITUDE_REF = "GPSLongitudeRef" + } + /** + * Enum for image formats. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + enum ImageFormat { + /** + * YCBCR422 semi-planar format. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + YCBCR_422_SP = 1000, + /** + * JPEG encoding format. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + JPEG = 2000 + } + /** + * Enumerates alpha types. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + enum AlphaType { + /** + * Indicates an unknown alpha type. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + UNKNOWN = 0, + /** + * Indicates that the image has no alpha channel, or all pixels in the image are fully opaque. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + OPAQUE = 1, + /** + * Indicates that RGB components of each pixel in the image are premultiplied by alpha. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + PREMUL = 2, + /** + * Indicates that RGB components of each pixel in the image are independent of alpha and are not premultiplied by alpha. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + UNPREMUL = 3 + } + /** + * Enum for image scale mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + enum ScaleMode { + /** + * Indicates the effect that fits the image into the target size. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + FIT_TARGET_SIZE = 0, + /** + * Indicates the effect that scales an image to fill the target image area and center-crops the part outside the area. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + CENTER_CROP = 1 + } + /** + * The componet type of image. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + */ + enum ComponentType { + /** + * Luma info. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + */ + YUV_Y = 1, + /** + * Chrominance info. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + */ + YUV_U = 2, + /** + * Chroma info. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + */ + YUV_V = 3, + /** + * Jpeg type. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + */ + JPEG = 4 + } + /** + * Describes region information. + * @since 8 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface Region { + /** + * Image size. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + size: Size; + /** + * x-coordinate at the upper left corner of the image. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + x: number; + /** + * y-coordinate at the upper left corner of the image. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + y: number; + } + /** + * Describes area information in an image. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface PositionArea { + /** + * Image data that will be read or written. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + pixels: ArrayBuffer; + /** + * Offset for data reading. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + offset: number; + /** + * Number of bytes to read. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + stride: number; + /** + * Region to read. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + region: Region; + } + /** + * Describes image information. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface ImageInfo { + /** + * Indicates image dimensions specified by a {@link Size} interface. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.Core + */ + size: Size; + } + /** + * Describes the option for image packing. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + */ + interface PackingOption { + /** + * Multipurpose Internet Mail Extensions (MIME) format of the target image, for example, image/jpeg. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + */ + format: string; + /** + * Quality of the target image. The value is an integer ranging from 0 to 100. A larger value indicates better + * image quality but larger space occupied. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + */ + quality: number; + } + /** + * Describes image properties. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + interface GetImagePropertyOptions { + /** + * Index of an image. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + index?: number; + /** + * Default property value. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + defaultValue?: string; + } + /** + * Describes image decoding parameters. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + interface DecodingOptions { + /** + * Number of image frames. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + index?: number; + /** + * Sampling ratio of the image pixel map. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + sampleSize?: number; + /** + * Rotation angle of the image pixel map. The value ranges from 0 to 360. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + rotate?: number; + /** + * Whether the image pixel map is editable. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + editable?: boolean; + /** + * Width and height of the image pixel map. The value (0, 0) indicates that the pixels are decoded + * based on the original image size. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + desiredSize?: Size; + /** + * Cropping region of the image pixel map. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + desiredRegion?: Region; + /** + * Data format of the image pixel map. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + desiredPixelFormat?: PixelMapFormat; + } + /** + * Describes image color components. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface Component { + /** + * Component type. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + readonly componentType: ComponentType; + /** + * Row stride. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + readonly rowStride: number; + /** + * Pixel stride. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + readonly pixelStride: number; + /** + * Component buffer. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + readonly byteBuffer: ArrayBuffer; + } + /** + * Initialization options for pixelmap. + * @since 8 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface InitializationOptions { + /** + * PixelMap size. + * @since 8 + * @syscap SystemCapability.Multimedia.Image.Core + */ + size: Size; + /** + * PixelMap expected format. + * @since 8 + * @syscap SystemCapability.Multimedia.Image.Core + */ + pixelFormat?: PixelMapFormat; + /** + * Editable or not. + * @since 8 + * @syscap SystemCapability.Multimedia.Image.Core + */ + editable?: boolean; + /** + * PixelMap expected alpha type. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + alphaType?: AlphaType; + /** + * PixelMap expected scaling effect. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + scaleMode?: ScaleMode; + } + /** + * Initialization options for ImageSource. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface SourceOptions { + /** + * The density for ImageSource. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + sourceDensity: number; + /** + * PixelMap expected format. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + sourcePixelFormat?: PixelMapFormat; + /** + * PixelMap size. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + sourceSize?: Size; + } + /** + * Create pixelmap by data buffer. + * @since 8 + * @syscap SystemCapability.Multimedia.Image.Core + */ + function createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: AsyncCallback): void; + /** + * Create pixelmap by data buffer. + * @since 8 + * @syscap SystemCapability.Multimedia.Image.Core + */ + function createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise; + /** + * Creates an ImageSource instance based on the URI. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param uri Image source URI. + * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. + */ + function createImageSource(uri: string): ImageSource; + /** + * Creates an ImageSource instance based on the URI. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param uri Image source URI. + * @param options The config of Image source. + * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. + */ + function createImageSource(uri: string, options: SourceOptions): ImageSource; + /** + * Creates an ImageSource instance based on the file descriptor. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param fd ID of a file descriptor. + * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. + */ + function createImageSource(fd: number): ImageSource; + /** + * Creates an ImageSource instance based on the file descriptor. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param fd ID of a file descriptor. + * @param options The config of Image source. + * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. + */ + function createImageSource(fd: number, options: SourceOptions): ImageSource; + /** + * Creates an ImageSource instance based on the buffer. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param buf The buffer of the iamge. + * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. + */ + function createImageSource(buf: ArrayBuffer): ImageSource; + /** + * Creates an ImageSource instance based on the buffer. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param buf The buffer of the iamge. + * @param options The config of Image source. + * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. + */ + function createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource; + /** + * Creates an ImageSource instance based on the buffer in incremental. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param buf The buffer of the iamge. + * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. + */ + function CreateIncrementalSource(buf: ArrayBuffer): ImageSource; + /** + * Creates an ImageSource instance based on the buffer in incremental. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param buf The buffer of the iamge. + * @param options The config of source. + * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. + */ + function CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource; + /** + * Creates an ImagePacker instance. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + * @return Returns the ImagePacker instance if the operation is successful; returns null otherwise. + */ + function createImagePacker(): ImagePacker; + /** + * Creates an ImageReceiver instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @param width The default width in pixels of the Images that this receiver will produce. + * @param height The default height in pixels of the Images that this receiver will produce. + * @param format The format of the Image that this receiver will produce. This must be one of the + * {@link ImageFormat} constants. Note that not all formats are supported, like ImageFormat.NV21. + * @param capacity The maximum number of images the user will want to access simultaneously. + * @return Returns the ImageReceiver instance if the operation is successful; returns null otherwise. + */ + function createImageReceiver(width: number, height: number, format: number, capacity: number): ImageReceiver; + /** + * PixelMap instance. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface PixelMap { + /** + * Whether the image pixel map can be edited. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + */ + readonly isEditable: boolean; + /** + * Reads image pixel map data and writes the data to an ArrayBuffer. This method uses + * a promise to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @param dst A buffer to which the image pixel map data will be written. + * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. + */ + readPixelsToBuffer(dst: ArrayBuffer): Promise; + /** + * Reads image pixel map data and writes the data to an ArrayBuffer. This method uses + * a callback to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @param dst A buffer to which the image pixel map data will be written. + * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. + */ + readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback): void; + /** + * Reads image pixel map data in an area. This method uses a promise to return the data read. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @param area Area from which the image pixel map data will be read. + * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. + */ + readPixels(area: PositionArea): Promise; + /** + * Reads image pixel map data in an area. This method uses a callback to return the data read. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @param area Area from which the image pixel map data will be read. + * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. + */ + readPixels(area: PositionArea, callback: AsyncCallback): void; + /** + * Writes image pixel map data to the specified area. This method uses a promise to return + * the operation result. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @param area Area to which the image pixel map data will be written. + * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. + */ + writePixels(area: PositionArea): Promise; + /** + * Writes image pixel map data to the specified area. This method uses a callback to return + * the operation result. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @param area Area to which the image pixel map data will be written. + * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. + */ + writePixels(area: PositionArea, callback: AsyncCallback): void; + /** + * Reads image data in an ArrayBuffer and writes the data to a PixelMap object. This method + * uses a promise to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @param src A buffer from which the image data will be read. + * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. + */ + writeBufferToPixels(src: ArrayBuffer): Promise; + /** + * Reads image data in an ArrayBuffer and writes the data to a PixelMap object. This method + * uses a callback to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @param src A buffer from which the image data will be read. + * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. + */ + writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback): void; + /** + * Obtains pixel map information about this image. This method uses a promise to return the information. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @return A Promise instance used to return the image pixel map information. If the operation fails, an error message is returned. + */ + getImageInfo(): Promise; + /** + * Obtains pixel map information about this image. This method uses a callback to return the information. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @param callback Callback used to return the image pixel map information. If the operation fails, an error message is returned. + */ + getImageInfo(callback: AsyncCallback): void; + /** + * Obtains the number of bytes in each line of the image pixel map. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @return Number of bytes in each line. + */ + getBytesNumberPerRow(): number; + /** + * Obtains the total number of bytes of the image pixel map. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @return Total number of bytes. + */ + getPixelBytesNumber(): number; + /** + * Obtains the density of the image pixel map. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @return The number of density. + */ + getDensity(): number; + /** + * Set the transparent rate of pixel map. This method uses a callback to return the operation result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param rate The value of transparent rate. + * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. + */ + opacity(rate: number, callback: AsyncCallback): void; + /** + * Set the transparent rate of pixel map. This method uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param rate The value of transparent rate. + * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. + */ + opacity(rate: number): Promise; + /** + * Obtains new pixel map with allpha information. This method uses a promise to return the information. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @return A Promise instance used to return the new image pixel map. If the operation fails, an error message is returned. + */ + createAlphaPixelmap(): Promise; + /** + * Obtains new pixel map with allpha information. This method uses a callback to return the information. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param callback Callback used to return the new image pixel map. If the operation fails, an error message is returned. + */ + createAlphaPixelmap(callback: AsyncCallback): void; + /** + * Image zoom in width and height. This method uses a callback to return the operation result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param x The zoom value of width. + * @param y The zoom value of height. + * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. + */ + scale(x: number, y: number, callback: AsyncCallback): void; + /** + * Image zoom in width and height. This method uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param x The zoom value of width. + * @param y The zoom value of height. + * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. + */ + scale(x: number, y: number): Promise; + /** + * Image position transformation. This method uses a callback to return the operation result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param x The position value of width. + * @param y The position value of height. + * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. + */ + translate(x: number, y: number, callback: AsyncCallback): void; + /** + * Image position transformation. This method uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param x The position value of width. + * @param y The position value of height. + * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. + */ + translate(x: number, y: number): Promise; + /** + * Image rotation. This method uses a callback to return the operation result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param angle The rotation angle. + * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. + */ + rotate(angle: number, callback: AsyncCallback): void; + /** + * Image rotation. This method uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param angle The rotation angle. + * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. + */ + rotate(angle: number): Promise; + /** + * Image flipping. This method uses a callback to return the operation result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param horizontal Is flip in horizontal. + * @param vertical Is flip in vertical. + * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. + */ + flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback): void; + /** + * Image flipping. This method uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param horizontal Is flip in horizontal. + * @param vertical Is flip in vertical. + * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. + */ + flip(horizontal: boolean, vertical: boolean): Promise; + /** + * Crop the image. This method uses a callback to return the operation result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param region The region to crop. + * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. + */ + crop(region: Region, callback: AsyncCallback): void; + /** + * Crop the image. This method uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param region The region to crop. + * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. + */ + crop(region: Region): Promise; + /** + * Releases this PixelMap object. This method uses a callback to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @param callback Callback invoked for instance release. If the operation fails, an error message is returned. + */ + release(callback: AsyncCallback): void; + /** + * Releases this PixelMap object. This method uses a promise to return the result. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.Core + * @return A Promise instance used to return the instance release result. If the operation fails, an error message is returned. + */ + release(): Promise; + } + /** + * ImageSource instance. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + interface ImageSource { + /** + * Obtains information about an image with the specified sequence number and uses a callback + * to return the result. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param index Sequence number of an image. + * @param callback Callback used to return the image information. + */ + getImageInfo(index: number, callback: AsyncCallback): void; + /** + * Obtains information about this image and uses a callback to return the result. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param callback Callback used to return the image information. + */ + getImageInfo(callback: AsyncCallback): void; + /** + * Get image information from image source. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param index Sequence number of an image. If this parameter is not specified, the default value 0 is used. + * @return A Promise instance used to return the image information. + */ + getImageInfo(index?: number): Promise; + /** + * Creates a PixelMap object based on image decoding parameters. This method uses a promise to + * return the object. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param options Image decoding parameters. + * @return A Promise instance used to return the PixelMap object. + */ + createPixelMap(options?: DecodingOptions): Promise; + /** + * Creates a PixelMap object. This method uses a callback to return the object. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param callback Callback used to return the PixelMap object. + */ + createPixelMap(callback: AsyncCallback): void; + /** + * Creates a PixelMap object based on image decoding parameters. This method uses a callback to + * return the object. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param options Image decoding parameters. + * @param callback Callback used to return the PixelMap object. + */ + createPixelMap(options: DecodingOptions, callback: AsyncCallback): void; + /** + * Obtains the value of a property in an image with the specified index. This method uses a + * promise to return the property value in a string. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param key Name of the property whose value is to be obtained. + * @param options Index of the image. + * @return A Promise instance used to return the property value. If the operation fails, the default value is returned. + */ + getImageProperty(key: string, options?: GetImagePropertyOptions): Promise; + /** + * Obtains the value of a property in this image. This method uses a callback to return the + * property value in a string. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param key Name of the property whose value is to be obtained. + * @param callback Callback used to return the property value. If the operation fails, an error message is returned. + */ + getImageProperty(key: string, callback: AsyncCallback): void; + /** + * Obtains the value of a property in an image with the specified index. This method uses + * a callback to return the property value in a string. + * @since 7 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param key Name of the property whose value is to be obtained. + * @param options Index of the image. + * @param callback Callback used to return the property value. If the operation fails, the default value is returned. + */ + getImageProperty(key: string, options: GetImagePropertyOptions, callback: AsyncCallback): void; + /** + * Modify the value of a property in an image with the specified key. This method uses a + * promise to return the property value in a string. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param key Name of the property whose value is to be modified. + * @param value The value to be set to property. + * @return A Promise instance used to return the property value. + */ + modifyImageProperty(key: string, value: string): Promise; + /** + * Modify the value of a property in an image with the specified key. This method uses a callback to return the + * property value in a string. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param key Name of the property whose value is to be obtained. + * @param value The value to be set to property. + * @param callback Callback to return the operation result. + */ + modifyImageProperty(key: string, value: string, callback: AsyncCallback): void; + /** + * Update the data in the incremental ImageSource. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param buf The data to be updated. + * @param isFinished If is it finished. + * @param value The offset of data. + * @param length The lenght fo buf. + * @return A Promise instance used to return the property value. + */ + updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number): Promise; + /** + * Update the data in the incremental ImageSource. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param buf The data to be updated. + * @param isFinished If is it finished. + * @param value The offset of data. + * @param length The lenght fo buf. + * @param callback Callback to return the operation result. + */ + updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback): void; + /** + * Releases an ImageSource instance and uses a callback to return the result. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param callback Callback to return the operation result. + */ + release(callback: AsyncCallback): void; + /** + * Releases an ImageSource instance and uses a promise to return the result. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @return A Promise instance used to return the operation result. + */ + release(): Promise; + /** + * Supported image formats. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImageSource + */ + readonly supportedFormats: Array; + } + /** + * ImagePacker instance. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + */ + interface ImagePacker { + /** + * Compresses or packs an image and uses a callback to return the result. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + * @param source Image to be processed. + * @param option Option for image packing. + * @param callback Callback used to return the packed data. + */ + packing(source: ImageSource, option: PackingOption, callback: AsyncCallback): void; + /** + * Compresses or packs an image and uses a promise to return the result. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + * @param source Image to be processed. + * @param option Option for image packing. + * @return A Promise instance used to return the compressed or packed data. + */ + packing(source: ImageSource, option: PackingOption): Promise; + /** + * Compresses or packs an image and uses a callback to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + * @param source PixelMap to be processed. + * @param option Option for image packing. + * @param callback Callback used to return the packed data. + */ + packing(source: PixelMap, option: PackingOption, callback: AsyncCallback): void; + /** + * Compresses or packs an image and uses a promise to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + * @param source PixelMap to be processed. + * @param option Option for image packing. + * @return A Promise instance used to return the compressed or packed data. + */ + packing(source: PixelMap, option: PackingOption): Promise; + /** + * Releases an ImagePacker instance and uses a callback to return the result. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + * @param callback Callback to return the operation result. + */ + release(callback: AsyncCallback): void; + /** + * Releases an ImagePacker instance and uses a promise to return the result. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + * @return A Promise instance used to return the operation result. + */ + release(): Promise; + /** + * Supported image formats. + * @since 6 + * @syscap SystemCapability.Multimedia.Image.ImagePacker + */ + readonly supportedFormats: Array; + } + /** + * Provides basic image operations, including obtaining image information, and reading and writing image data. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + interface Image { + /** + * Sets or gets the image area to crop, default is size. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + clipRect: Region; + /** + * Image size. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + readonly size: Size; + /** + * Image format. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + readonly format: number; + /** + * Get component buffer from image and uses a callback to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param componentType The componet type of image. + * @param callback Callback used to return the component buffer. + */ + getComponent(componentType: ComponentType, callback: AsyncCallback): void; + /** + * Get component buffer from image and uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param componentType The componet type of image. + * @return A Promise instance used to return the component buffer. + */ + getComponent(componentType: ComponentType): Promise; + /** + * Release current image to receive another and uses a callback to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @param callback Callback to return the operation result. + */ + release(callback: AsyncCallback): void; + /** + * Release current image to receive another and uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + * @return A Promise instance used to return the operation result. + */ + release(): Promise; + } + /** + * Image receiver object. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + */ + interface ImageReceiver { + /** + * Image size. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + */ + readonly size: Size; + /** + * Image capacity. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + */ + readonly capacity: number; + /** + * Image format. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + */ + readonly format: ImageFormat; + /** + * get an id which indicates a surface and can be used to set to Camera or other component can receive a surface + * and uses a callback to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @param callback Callback used to return the surface id. + */ + getReceivingSurfaceId(callback: AsyncCallback): void; + /** + * get an id which indicates a surface and can be used to set to Camera or other component can receive a surface + * and uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @return A Promise instance used to return the surface id. + */ + getReceivingSurfaceId(): Promise; + /** + * Get lasted image from receiver and uses a callback to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @param callback Callback used to return the latest image. + */ + readLatestImage(callback: AsyncCallback): void; + /** + * Get lasted image from receiver and uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @return A Promise instance used to return the latest image. + */ + readLatestImage(): Promise; + /** + * Get next image from receiver and uses a callback to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @param callback Callback used to return the next image. + */ + readNextImage(callback: AsyncCallback): void; + /** + * Get next image from receiver and uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @return A Promise instance used to return the next image. + */ + readNextImage(): Promise; + /** + * Subscribe callback when receiving an image + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @param type Callback used to return the next image. + * @param callback Callback used to return image. + */ + on(type: 'imageArrival', callback: AsyncCallback): void; + /** + * Release image receiver instance and uses a callback to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @param callback Callback to return the operation result. + */ + release(callback: AsyncCallback): void; + /** + * Release image receiver instance and uses a promise to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @return A Promise instance used to return the operation result. + */ + release(): Promise; + } +} +export default image; diff --git a/build-tools/api/@ohos.multimedia.media.d.ts b/build-tools/api/@ohos.multimedia.media.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4b4ad589d76d9f4e322ac745a26ef79716cc3c1b --- /dev/null +++ b/build-tools/api/@ohos.multimedia.media.d.ts @@ -0,0 +1,1485 @@ +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { ErrorCallback, AsyncCallback, Callback } from './basic'; +import audio from "./@ohos.multimedia.audio"; +/** + * @name media + * @since 6 + * @import import media from '@ohos.multimedia.media' + */ +declare namespace media { + /** + * Creates an AudioPlayer instance. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @import import media from '@ohos.multimedia.media' + * @return Returns an AudioPlayer instance if the operation is successful; returns null otherwise. + */ + function createAudioPlayer(): AudioPlayer; + /** + * Creates an AudioRecorder instance. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @import import media from '@ohos.multimedia.media' + * @return Returns an AudioRecorder instance if the operation is successful; returns null otherwise. + */ + function createAudioRecorder(): AudioRecorder; + /** + * Creates an VideoPlayer instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @import import media from '@ohos.multimedia.media' + * @param callback Callback used to return AudioPlayer instance if the operation is successful; returns null otherwise. + */ + function createVideoPlayer(callback: AsyncCallback): void; + /** + * Creates an VideoPlayer instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @import import media from '@ohos.multimedia.media' + * @return A Promise instance used to return VideoPlayer instance if the operation is successful; returns null otherwise. + */ + function createVideoPlayer(): Promise; + /** + * Creates an VideoRecorder instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @import import media from '@ohos.multimedia.media' + * @param callback Callback used to return AudioPlayer instance if the operation is successful; returns null otherwise. + */ + function createVideoRecorder(callback: AsyncCallback): void; + /** + * Creates an VideoRecorder instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @import import media from '@ohos.multimedia.media' + * @return A Promise instance used to return VideoRecorder instance if the operation is successful; returns null otherwise. + */ + function createVideoRecorder(): Promise; + /** + * Enumerates ErrorCode types, return in BusinessError::code + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum MediaErrorCode { + /** + * operation success. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_OK = 0, + /** + * malloc or new memory failed. maybe system have no memory. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_NO_MEMORY = 1, + /** + * no permission for the operation. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_OPERATION_NOT_PERMIT = 2, + /** + * invalid argument. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_INVALID_VAL = 3, + /** + * an IO error occurred. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_IO = 4, + /** + * operation time out. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_TIMEOUT = 5, + /** + * unknown error. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_UNKNOWN = 6, + /** + * media service died. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_SERVICE_DIED = 7, + /** + * operation is not permit in current state. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_INVALID_STATE = 8, + /** + * operation is not supported in current version. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MSERR_UNSUPPORTED = 9 + } + /** + * Enumerates buffering info type, for network playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum BufferingInfoType { + /** + * begin to buffering + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + BUFFERING_START = 1, + /** + * end to buffering + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + BUFFERING_END = 2, + /** + * buffering percent + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + BUFFERING_PERCENT = 3, + /** + * cached duration in milliseconds + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + CACHED_DURATION = 4 + } + interface AVFileDescriptor { + /** + * The file descriptor of audio or video source from file system. The caller + * is responsible to close the file descriptor. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.Core + */ + fd: number; + /** + * The offset into the file where the data to be readed, in bytes. Defaultly, + * the offset is zero. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.Core + */ + offset?: number; + /** + * The length in bytes of the data to be readed. Defaultly, the length is the + * rest of bytes in the file from the offset. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.Core + */ + length?: number; + } + /** + * Describes audio playback states. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @import import media from '@ohos.multimedia.media' + */ + type AudioState = 'idle' | 'playing' | 'paused' | 'stopped' | 'error'; + /** + * Manages and plays audio. Before calling an AudioPlayer method, you must use createAudioPlayer() + * to create an AudioPlayer instance. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + interface AudioPlayer { + /** + * Starts audio playback. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + play(): void; + /** + * Pauses audio playback. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + pause(): void; + /** + * Stops audio playback. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + stop(): void; + /** + * Resets audio playback. + * @since 7 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + reset(): void; + /** + * Jumps to the specified playback position. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param timeMs Playback position to jump + */ + seek(timeMs: number): void; + /** + * Sets the volume. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param vol Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). + */ + setVolume(vol: number): void; + /** + * Releases resources used for audio playback. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + release(): void; + /** + * get all track infos in MediaDescription, should be called after data loaded callback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param callback async callback return track info in MediaDescription. + */ + getTrackDescription(callback: AsyncCallback>): void; + /** + * get all track infos in MediaDescription, should be called after data loaded callback.. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @return A Promise instance used to return the track info in MediaDescription. + */ + getTrackDescription(): Promise>; + /** + * Listens for audio playback buffering events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param type Type of the playback buffering update event to listen for. + * @param callback Callback used to listen for the buffering update event, return BufferingInfoType and the value. + */ + on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void; + /** + * Audio media URI. Mainstream audio formats are supported. + * local:fd://XXX, file://XXX. network:http://xxx + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @permission ohos.permission.READ_MEDIA or ohos.permission.INTERNET + */ + src: string; + /** + * Audio file descriptor. Mainstream audio formats are supported. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + fdSrc: AVFileDescriptor; + /** + * Whether to loop audio playback. The value true means to loop playback. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + loop: boolean; + /** + * Describes audio interrupt mode, refer to {@link #audio.InterruptMode}. If it is not + * set, the default mode will be used. Set it before calling the {@link #play()} in the + * first time in order for the interrupt mode to become effective thereafter. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + audioInterruptMode?: audio.InterruptMode; + /** + * Current playback position. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + readonly currentTime: number; + /** + * Playback duration, When the data source does not support seek, it returns - 1, such as a live broadcast scenario. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + readonly duration: number; + /** + * Playback state. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + readonly state: AudioState; + /** + * Listens for audio playback events. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event. + */ + on(type: 'play' | 'pause' | 'stop' | 'reset' | 'dataLoad' | 'finish' | 'volumeChange', callback: () => void): void; + /** + * Listens for audio playback events. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event. + */ + on(type: 'timeUpdate', callback: Callback): void; + /** + * Listens for audio interrupt event, refer to {@link #audio.InterruptEvent} + * @since 9 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event return audio interrupt info. + */ + on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void; + /** + * Listens for playback error events. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param type Type of the playback error event to listen for. + * @param callback Callback used to listen for the playback error event. + */ + on(type: 'error', callback: ErrorCallback): void; + } + /** + * Enumerates audio encoding formats, it will be deprecated after API8, use @CodecMimeType to replace. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @import import media from '@ohos.multimedia.media' + * @deprecated since 8 + */ + enum AudioEncoder { + /** + * Default audio encoding format, which is AMR-NB. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + DEFAULT = 0, + /** + * Indicates the AMR-NB audio encoding format. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + AMR_NB = 1, + /** + * Indicates the AMR-WB audio encoding format. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + AMR_WB = 2, + /** + * Advanced Audio Coding Low Complexity (AAC-LC). + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + AAC_LC = 3, + /** + * High-Efficiency Advanced Audio Coding (HE-AAC). + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + HE_AAC = 4 + } + /** + * Enumerates audio output formats, it will be deprecated after API8, use @ContainerFormatType to replace. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @import import media from '@ohos.multimedia.media' + * @deprecated since 8 + */ + enum AudioOutputFormat { + /** + * Default audio output format, which is Moving Pictures Expert Group 4 (MPEG-4). + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + DEFAULT = 0, + /** + * Indicates the Moving Picture Experts Group-4 (MPEG4) media format. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + MPEG_4 = 2, + /** + * Indicates the Adaptive Multi-Rate Narrowband (AMR-NB) media format. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + AMR_NB = 3, + /** + * Indicates the Adaptive Multi-Rate Wideband (AMR-WB) media format. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + AMR_WB = 4, + /** + * Audio Data Transport Stream (ADTS), a transmission stream format of Advanced Audio Coding (AAC) audio. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + AAC_ADTS = 6 + } + /** + * Provides the geographical location definitions for media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.Core + */ + interface Location { + /** + * Latitude. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.Core + */ + latitude: number; + /** + * Longitude. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.Core + */ + longitude: number; + } + /** + * Provides the audio recorder configuration definitions. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + interface AudioRecorderConfig { + /** + * Audio encoding format. The default value is DEFAULT, it will be deprecated after API8. + * use "audioEncoderMime" instead. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @deprecated since 8 + */ + audioEncoder?: AudioEncoder; + /** + * Audio encoding bit rate. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + audioEncodeBitRate?: number; + /** + * Audio sampling rate. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + audioSampleRate?: number; + /** + * Number of audio channels. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + numberOfChannels?: number; + /** + * Audio output format. The default value is DEFAULT, it will be deprecated after API8. + * it will be replaced with "fileFormat". + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @deprecated since 8 + */ + format?: AudioOutputFormat; + /** + * Audio output uri.support two kind of uri now. + * format like: scheme + "://" + "context". + * file: file://path + * fd: fd://fd + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + uri: string; + /** + * Geographical location information. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + location?: Location; + /** + * audio encoding format MIME. it used to replace audioEncoder. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + audioEncoderMime?: CodecMimeType; + /** + * output file format. see @ContainerFormatType , it used to replace "format". + * @since 8 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + fileFormat?: ContainerFormatType; + } + /** + * Manages and record audio. Before calling an AudioRecorder method, you must use createAudioRecorder() + * to create an AudioRecorder instance. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + interface AudioRecorder { + /** + * Prepares for recording. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @param config Recording parameters. + * @permission ohos.permission.MICROPHONE + */ + prepare(config: AudioRecorderConfig): void; + /** + * Starts audio recording. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + start(): void; + /** + * Pauses audio recording. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + pause(): void; + /** + * Resumes audio recording. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + resume(): void; + /** + * Stops audio recording. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + stop(): void; + /** + * Releases resources used for audio recording. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + release(): void; + /** + * Resets audio recording. + * Before resetting audio recording, you must call stop() to stop recording. After audio recording is reset, + * you must call prepare() to set the recording configurations for another recording. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + */ + reset(): void; + /** + * Listens for audio recording events. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @param type Type of the audio recording event to listen for. + * @param callback Callback used to listen for the audio recording event. + */ + on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset', callback: () => void): void; + /** + * Listens for audio recording error events. + * @since 6 + * @syscap SystemCapability.Multimedia.Media.AudioRecorder + * @param type Type of the audio recording error event to listen for. + * @param callback Callback used to listen for the audio recording error event. + */ + on(type: 'error', callback: ErrorCallback): void; + } + /** + * Describes video recorder states. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + type VideoRecordState = 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error'; + /** + * Manages and record video. Before calling an VideoRecorder method, you must use createVideoRecorder() + * to create an VideoRecorder instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + interface VideoRecorder { + /** + * Prepares for recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param config Recording parameters. + * @param callback A callback instance used to return when prepare completed. + * @permission ohos.permission.MICROPHONE + */ + prepare(config: VideoRecorderConfig, callback: AsyncCallback): void; + /** + * Prepares for recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param config Recording parameters. + * @return A Promise instance used to return when prepare completed. + * @permission ohos.permission.MICROPHONE + */ + prepare(config: VideoRecorderConfig): Promise; + /** + * get input surface.it must be called between prepare completed and start. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback Callback used to return the input surface id in string. + */ + getInputSurface(callback: AsyncCallback): void; + /** + * get input surface. it must be called between prepare completed and start. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return the input surface id in string. + */ + getInputSurface(): Promise; + /** + * Starts video recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when start completed. + */ + start(callback: AsyncCallback): void; + /** + * Starts video recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when start completed. + */ + start(): Promise; + /** + * Pauses video recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when pause completed. + */ + pause(callback: AsyncCallback): void; + /** + * Pauses video recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when pause completed. + */ + pause(): Promise; + /** + * Resumes video recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when resume completed. + */ + resume(callback: AsyncCallback): void; + /** + * Resumes video recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when resume completed. + */ + resume(): Promise; + /** + * Stops video recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when stop completed. + */ + stop(callback: AsyncCallback): void; + /** + * Stops video recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when stop completed. + */ + stop(): Promise; + /** + * Releases resources used for video recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when release completed. + */ + release(callback: AsyncCallback): void; + /** + * Releases resources used for video recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when release completed. + */ + release(): Promise; + /** + * Resets video recording. + * Before resetting video recording, you must call stop() to stop recording. After video recording is reset, + * you must call prepare() to set the recording configurations for another recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param callback A callback instance used to return when reset completed. + */ + reset(callback: AsyncCallback): void; + /** + * Resets video recording. + * Before resetting video recording, you must call stop() to stop recording. After video recording is reset, + * you must call prepare() to set the recording configurations for another recording. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @return A Promise instance used to return when reset completed. + */ + reset(): Promise; + /** + * Listens for video recording error events. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @param type Type of the video recording error event to listen for. + * @param callback Callback used to listen for the video recording error event. + */ + on(type: 'error', callback: ErrorCallback): void; + /** + * video recorder state. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly state: VideoRecordState; + } + /** + * Describes video playback states. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + type VideoPlayState = 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error'; + /** + * Enumerates playback speed. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + enum PlaybackSpeed { + /** + * playback at 0.75x normal speed + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + SPEED_FORWARD_0_75_X = 0, + /** + * playback at normal speed + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + SPEED_FORWARD_1_00_X = 1, + /** + * playback at 1.25x normal speed + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + SPEED_FORWARD_1_25_X = 2, + /** + * playback at 1.75x normal speed + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + SPEED_FORWARD_1_75_X = 3, + /** + * playback at 2.0x normal speed + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + SPEED_FORWARD_2_00_X = 4 + } + /** + * Manages and plays video. Before calling an video method, you must use createVideoPlayer() to create an VideoPlayer + * instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @import import media from '@ohos.multimedia.media' + */ + interface VideoPlayer { + /** + * set display surface. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param surfaceId surface id, video player will use this id get a surface instance. + * @return A Promise instance used to return when release output buffer completed. + */ + setDisplaySurface(surfaceId: string, callback: AsyncCallback): void; + /** + * set display surface. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param surfaceId surface id, video player will use this id get a surface instance. + * @return A Promise instance used to return when release output buffer completed. + */ + setDisplaySurface(surfaceId: string): Promise; + /** + * prepare video playback, it will request resource for playing. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when prepare completed. + */ + prepare(callback: AsyncCallback): void; + /** + * prepare video playback, it will request resource for playing. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when prepare completed. + */ + prepare(): Promise; + /** + * Starts video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when start completed. + */ + play(callback: AsyncCallback): void; + /** + * Starts video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when start completed. + */ + play(): Promise; + /** + * Pauses video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when pause completed. + */ + pause(callback: AsyncCallback): void; + /** + * Pauses video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when pause completed. + */ + pause(): Promise; + /** + * Stops video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when stop completed. + */ + stop(callback: AsyncCallback): void; + /** + * Stops video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when stop completed. + */ + stop(): Promise; + /** + * Resets video playback, it will release the resource. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when reset completed. + */ + reset(callback: AsyncCallback): void; + /** + * Resets video playback, it will release the resource. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when reset completed. + */ + reset(): Promise; + /** + * Jumps to the specified playback position by default SeekMode(SEEK_CLOSEST), + * the performance may be not the best. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param timeMs Playback position to jump + * @param callback A callback instance used to return when seek completed + * and return the seeking position result. + */ + seek(timeMs: number, callback: AsyncCallback): void; + /** + * Jumps to the specified playback position. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param timeMs Playback position to jump + * @param mode seek mode, see @SeekMode . + * @param callback A callback instance used to return when seek completed + * and return the seeking position result. + */ + seek(timeMs: number, mode: SeekMode, callback: AsyncCallback): void; + /** + * Jumps to the specified playback position. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param timeMs Playback position to jump + * @param mode seek mode, see @SeekMode . + * @return A Promise instance used to return when seek completed + * and return the seeking position result. + */ + seek(timeMs: number, mode?: SeekMode): Promise; + /** + * Sets the volume. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param vol Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). + * @param callback A callback instance used to return when set volume completed. + */ + setVolume(vol: number, callback: AsyncCallback): void; + /** + * Sets the volume. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param vol Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%). + * @return A Promise instance used to return when set volume completed. + */ + setVolume(vol: number): Promise; + /** + * Releases resources used for video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback A callback instance used to return when release completed. + */ + release(callback: AsyncCallback): void; + /** + * Releases resources used for video playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return when release completed. + */ + release(): Promise; + /** + * get all track infos in MediaDescription, should be called after data loaded callback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback async callback return track info in MediaDescription. + */ + getTrackDescription(callback: AsyncCallback>): void; + /** + * get all track infos in MediaDescription, should be called after data loaded callback.. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return A Promise instance used to return the track info in MediaDescription. + */ + getTrackDescription(): Promise>; + /** + * media url. Mainstream video formats are supported. + * local:fd://XXX, file://XXX. network:http://xxx + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + url: string; + /** + * Video file descriptor. Mainstream video formats are supported. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + fdSrc: AVFileDescriptor; + /** + * Whether to loop video playback. The value true means to loop playback. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + loop: boolean; + /** + * Current playback position. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + readonly currentTime: number; + /** + * Playback duration, if -1 means cannot seek. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + readonly duration: number; + /** + * Playback state. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + readonly state: VideoPlayState; + /** + * video width, valid after prepared. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + readonly width: number; + /** + * video height, valid after prepared. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + readonly height: number; + /** + * Describes audio interrupt mode, refer to {@link #audio.InterruptMode}. If it is not + * set, the default mode will be used. Set it before calling the {@link #play()} in the + * first time in order for the interrupt mode to become effective thereafter. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + audioInterruptMode?: audio.InterruptMode; + /** + * video scale type. Defaultly, the {@link #VIDEO_SCALE_TYPE_FIT} will be used, for more + * information, refer to {@link #VideoScaleType} + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + videoScaleType?: VideoScaleType; + /** + * set payback speed. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param speed playback speed, see @PlaybackSpeed . + * @param callback Callback used to return actually speed. + */ + setSpeed(speed: number, callback: AsyncCallback): void; + /** + * set output surface. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param speed playback speed, see @PlaybackSpeed . + * @return A Promise instance used to return actually speed. + */ + setSpeed(speed: number): Promise; + /** + * select a specified bitrate to playback, only valid for HLS protocal network stream. Defaulty, the + * player will select the appropriate bitrate according to the network connection speed. The + * available bitrates list reported by {@link #on('availablebitratesCollected')}. Set it to select + * a specified bitrate. If the specified bitrate is not in the list of available bitrates, the player + * will select the minimal and closest one from the available bitrates list. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param bitrate the playback bitrate must be expressed in bits per second. + * @return A Promise instance used to return actually selected bitrate. + */ + selectBitrate(bitrate: number): Promise; + /** + * select a specified bitrate to playback, only valid for HLS protocal network stream. Defaulty, the + * player will select the appropriate bitrate according to the network connection speed. The + * available bitrates list reported by {@link #on('availablebitratesCollected')}. Set it to select + * a specified bitrate. If the specified bitrate is not in the list of available bitrates, the player + * will select the minimal and closest one from the available bitrates list. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param bitrate the playback bitrate must be expressed in bits per second. + * @param callback Callback used to return actually selected bitrate. + */ + selectBitrate(bitrate: number, callback: AsyncCallback): void; + /** + * Listens for video playback completed events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event return . + */ + on(type: 'playbackCompleted', callback: Callback): void; + /** + * Listens for video playback buffering events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback buffering update event to listen for. + * @param callback Callback used to listen for the buffering update event, return BufferingInfoType and the value. + */ + on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void; + /** + * Listens for start render video frame events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event return . + */ + on(type: 'startRenderFrame', callback: Callback): void; + /** + * Listens for video size changed event. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event return video size. + */ + on(type: 'videoSizeChanged', callback: (width: number, height: number) => void): void; + /** + * Listens for audio interrupt event, refer to {@link #audio.InterruptEvent} + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event return audio interrupt info. + */ + on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void; + /** + * Listens for available bitrates collect completed events for HLS protocal stream playback. + * This event will be reported after the {@link #prepare} called. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback event to listen for. + * @param callback Callback used to listen for the playback event return available bitrates. + */ + on(type: 'availableBitratesCollected', callback: (bitrates: Array) => void): void; + /** + * Listens for playback error events. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param type Type of the playback error event to listen for. + * @param callback Callback used to listen for the playback error event. + */ + on(type: 'error', callback: ErrorCallback): void; + } + /** + * Enumerates video scale type. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @import import media from '@ohos.multimedia.media' + */ + enum VideoScaleType { + /** + * The content is stretched to the fit the display surface rendering area. When + * the aspect ratio of the content is not same as the display surface, the aspect + * of the content is not maintained. This is the default scale type. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + VIDEO_SCALE_TYPE_FIT = 0, + /** + * The content is stretched to the fit the display surface rendering area. When + * the aspect ratio of the content is not the same as the display surface, content's + * aspect ratio is maintained and the content is cropped to fit the display surface. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + VIDEO_SCALE_TYPE_FIT_CROP + } + /** + * Enumerates container format type(The abbreviation for 'container format type' is CFT). + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum ContainerFormatType { + /** + * A video container format type mp4. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + CFT_MPEG_4 = "mp4", + /** + * A audio container format type m4a. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + CFT_MPEG_4A = "m4a" + } + /** + * Enumerates media data type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum MediaType { + /** + * track is audio. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MEDIA_TYPE_AUD = 0, + /** + * track is video. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MEDIA_TYPE_VID = 1 + } + /** + * Enumerates media description key. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum MediaDescriptionKey { + /** + * key for track index, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_TRACK_INDEX = "track_index", + /** + * key for track type, value type is number, see @MediaType. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_TRACK_TYPE = "track_type", + /** + * key for codec mime type, value type is string. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_CODEC_MIME = "codec_mime", + /** + * key for duration, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_DURATION = "duration", + /** + * key for bitrate, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_BITRATE = "bitrate", + /** + * key for video width, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_WIDTH = "width", + /** + * key for video height, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_HEIGHT = "height", + /** + * key for video frame rate, value type is number. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_FRAME_RATE = "frame_rate", + /** + * key for audio channel count, value type is number + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_AUD_CHANNEL_COUNT = "channel_count", + /** + * key for audio sample rate, value type is number + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + MD_KEY_AUD_SAMPLE_RATE = "sample_rate" + } + /** + * Provides the video recorder profile definitions. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + interface VideoRecorderProfile { + /** + * Indicates the audio bit rate. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly audioBitrate: number; + /** + * Indicates the number of audio channels. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly audioChannels: number; + /** + * Indicates the audio encoding format. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly audioCodec: CodecMimeType; + /** + * Indicates the audio sampling rate. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly audioSampleRate: number; + /** + * Indicates the output file format. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly fileFormat: ContainerFormatType; + /** + * Indicates the video bit rate. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly videoBitrate: number; + /** + * Indicates the video encoding format. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly videoCodec: CodecMimeType; + /** + * Indicates the video width. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly videoFrameWidth: number; + /** + * Indicates the video height. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly videoFrameHeight: number; + /** + * Indicates the video frame rate. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + readonly videoFrameRate: number; + } + /** + * Enumerates audio source type for recorder. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @import import media from '@ohos.multimedia.media' + */ + enum AudioSourceType { + /** + * default audio source type. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + AUDIO_SOURCE_TYPE_DEFAULT = 0, + /** + * source type mic. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + AUDIO_SOURCE_TYPE_MIC = 1 + } + /** + * Enumerates video source type for recorder. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @import import media from '@ohos.multimedia.media' + */ + enum VideoSourceType { + /** + * surface raw data. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + VIDEO_SOURCE_TYPE_SURFACE_YUV = 0, + /** + * surface ES data. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + VIDEO_SOURCE_TYPE_SURFACE_ES = 1 + } + /** + * Provides the video recorder configuration definitions. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + interface VideoRecorderConfig { + /** + * audio source type, details see @AudioSourceType . + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + audioSourceType: AudioSourceType; + /** + * video source type, details see @VideoSourceType . + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + videoSourceType: VideoSourceType; + /** + * video recorder profile, can get by "getVideoRecorderProfile", details see @VideoRecorderProfile . + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + profile: VideoRecorderProfile; + /** + * video output uri.support two kind of uri now. + * format like: scheme + "://" + "context". + * file: file://path + * fd: fd://fd + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + url: string; + /** + * Sets the video rotation angle in output file, and for the file to playback. mp4 support. + * the range of rotation angle should be {0, 90, 180, 270}, default is 0. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + rotation?: number; + /** + * geographical location information. + * @since 9 + * @syscap SystemCapability.Multimedia.Media.VideoRecorder + */ + location?: Location; + } + /** + * Provides the container definition for media description key-value pairs. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + interface MediaDescription { + /** + * key:value pair, key see @MediaDescriptionKey . + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + [key: string]: Object; + } + /** + * Enumerates seek mode. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum SeekMode { + /** + * seek to the next sync frame of the given timestamp + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + SEEK_NEXT_SYNC = 0, + /** + * seek to the previous sync frame of the given timestamp + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + SEEK_PREV_SYNC = 1 + } + /** + * Enumerates Codec MIME types. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + * @import import media from '@ohos.multimedia.media' + */ + enum CodecMimeType { + /** + * H.263 codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + VIDEO_H263 = 'video/h263', + /** + * H.264 codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + VIDEO_AVC = 'video/avc', + /** + * MPEG2 codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + VIDEO_MPEG2 = 'video/mpeg2', + /** + * MPEG4 codec MIME type + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + VIDEO_MPEG4 = 'video/mp4v-es', + /** + * VP8 codec MIME type + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + VIDEO_VP8 = 'video/x-vnd.on2.vp8', + /** + * AAC codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + AUDIO_AAC = 'audio/mp4a-latm', + /** + * vorbis codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + AUDIO_VORBIS = 'audio/vorbis', + /** + * flac codec MIME type. + * @since 8 + * @syscap SystemCapability.Multimedia.Media.Core + */ + AUDIO_FLAC = 'audio/flac' + } +} +export default media; diff --git a/build-tools/api/@ohos.multimedia.mediaLibrary.d.ts b/build-tools/api/@ohos.multimedia.mediaLibrary.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6878c45451d7514a00cf7f9858958966e4baf6da --- /dev/null +++ b/build-tools/api/@ohos.multimedia.mediaLibrary.d.ts @@ -0,0 +1,1032 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from './basic'; +import { Context } from './application/Context'; +import image from './@ohos.multimedia.image'; +/** + * @name mediaLibrary + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import media from '@ohos.multimedia.mediaLibrary' + */ +declare namespace mediaLibrary { + /** + * Obtains a MediaLibrary instance. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' + * @FAModelOnly + * @return Returns a MediaLibrary instance if the operation is successful; returns null otherwise. + */ + function getMediaLibrary(): MediaLibrary; + /** + * Returns an instance of MediaLibrary + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @StageModelOnly + * @param context hap context information + * @return Instance of MediaLibrary + */ + function getMediaLibrary(context: Context): MediaLibrary; + /** + * Enumeration types for different kind of Media Files + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + enum MediaType { + /** + * File media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + FILE = 0, + /** + * Image media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + IMAGE, + /** + * Video media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + VIDEO, + /** + * Audio media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + AUDIO + } + /** + * Describes media resource options. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' + * @deprecated since 9 + */ + interface MediaAssetOption { + /** + * URI of the media source. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @deprecated since 9 + */ + src: string; + /** + * Multipurpose Internet Mail Extensions (MIME) type of the media. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @deprecated since 9 + */ + mimeType: string; + /** + * Relative path for storing media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @deprecated since 9 + */ + relativePath?: string; + } + /** + * Describes media selection options. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' + * @deprecated since 9 + */ + interface MediaSelectOption { + /** + * Media type, which can be image, video, or media (indicating both image and video). + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @deprecated since 9 + */ + type: 'image' | 'video' | 'media'; + /** + * Maximum number of media items that can be selected + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @deprecated since 9 + */ + count: number; + } + /** + * Provides methods to encapsulate file attributes. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' + */ + interface FileAsset { + /** + * File ID. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly id: number; + /** + * URI of the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly uri: string; + /** + * MIME type, for example, video/mp4, audio/mp4, or audio/amr-wb. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly mimeType: string; + /** + * Media type, for example, IMAGE, VIDEO, FILE, AUDIO + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly mediaType: MediaType; + /** + * Display name (with a file name extension) of the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + displayName: string; + /** + * File name title (without the file name extension). + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + title: string; + /** + * Relative Path of the file. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + relativePath: string; + /** + * Parent folder's file_id of the file. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly parent: number; + /** + * Data size of the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly size: number; + /** + * Date (timestamp) when the file was added. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly dateAdded: number; + /** + * Date (timestamp) when the file was modified. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly dateModified: number; + /** + * Date (timestamp) when the file was taken. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly dateTaken: number; + /** + * Artist of the audio file. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly artist: string; + /** + * audioAlbum of the audio file. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly audioAlbum: string; + /** + * Display width of the file. This is valid only for videos and images. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly width: number; + /** + * Display height of the file. This is valid only for videos and images. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly height: number; + /** + * Rotation angle of the file, in degrees. + * The rotation angle can be 0, 90, 180, or 270 degrees. This is valid only for videos. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + orientation: number; + /** + * duration of the audio and video file. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly duration: number; + /** + * ID of the album where the file is located. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly albumId: number; + /** + * URI of the album where the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly albumUri: string; + /** + * Name of the album where the file is located. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly albumName: string; + /** + * If it is a directory where the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param callback Callback return the result of isDerectory. + */ + isDirectory(callback: AsyncCallback): void; + /** + * If it is a directory where the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + */ + isDirectory(): Promise; + /** + * Modify meta data where the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + * @param callback no value will be returned. + */ + commitModify(callback: AsyncCallback): void; + /** + * Modify meta data where the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + */ + commitModify(): Promise; + /** + * Open the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA + * @param mode mode for open, for example: rw, r, w. + * @param callback Callback return the fd of the file. + */ + open(mode: string, callback: AsyncCallback): void; + /** + * Open the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA + * @param mode mode for open, for example: rw, r, w. + */ + open(mode: string): Promise; + /** + * Close the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA + * @param fd fd of the file which had been opened + * @param callback no value will be returned. + */ + close(fd: number, callback: AsyncCallback): void; + /** + * Close the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA + * @param fd fd of the file which had been opened + */ + close(fd: number): Promise; + /** + * Get thumbnail of the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param callback Callback used to return the thumbnail's pixelmap. + */ + getThumbnail(callback: AsyncCallback): void; + /** + * Get thumbnail of the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param size thumbnail's size + * @param callback Callback used to return the thumbnail's pixelmap. + */ + getThumbnail(size: Size, callback: AsyncCallback): void; + /** + * Get thumbnail of the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param size thumbnail's size + */ + getThumbnail(size?: Size): Promise; + /** + * Set favorite for the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + * @param isFavorite ture is favorite file, false is not favorite file + * @param callback Callback used to return, No value is returned. + */ + favorite(isFavorite: boolean, callback: AsyncCallback): void; + /** + * Set favorite for the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + * @param isFavorite ture is favorite file, false is not favorite file + */ + favorite(isFavorite: boolean): Promise; + /** + * If the file is favorite when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param callback Callback used to return true or false. + */ + isFavorite(callback: AsyncCallback): void; + /** + * If the file is favorite when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + */ + isFavorite(): Promise; + /** + * Set trash for the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + * @param isTrash true is trashed file, false is not trashed file + * @param callback Callback used to return, No value is returned. + */ + trash(isTrash: boolean, callback: AsyncCallback): void; + /** + * Set trash for the file when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + * @param isTrash true is trashed file, false is not trashed file + */ + trash(isTrash: boolean): Promise; + /** + * If the file is in trash when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param callback Callback used to return true or false. + */ + isTrash(callback: AsyncCallback): void; + /** + * If the file is in trash when the file is located. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + */ + isTrash(): Promise; + } + /** + * Describes MediaFetchOptions's selection + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + enum FileKey { + /** + * File ID + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + ID = "file_id", + /** + * Relative Path + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + RELATIVE_PATH = "relative_path", + /** + * File name + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DISPLAY_NAME = "display_name", + /** + * Parent folder file id + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + PARENT = "parent", + /** + * Mime type of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + MIME_TYPE = "mime_type", + /** + * Media type of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + MEDIA_TYPE = "media_type", + /** + * Size of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + SIZE = "size", + /** + * Date of the file creation + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DATE_ADDED = "date_added", + /** + * Modify date of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DATE_MODIFIED = "date_modified", + /** + * Date taken of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DATE_TAKEN = "date_taken", + /** + * Title of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + TITLE = "title", + /** + * Artist of the audio file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + ARTIST = "artist", + /** + * Audio album of the audio file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + AUDIOALBUM = "audio_album", + /** + * Duration of the audio and video file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DURATION = "duration", + /** + * Width of the image file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + WIDTH = "width", + /** + * Height of the image file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + HEIGHT = "height", + /** + * Orientation of the image file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + ORIENTATION = "orientation", + /** + * Album id of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + ALBUM_ID = "bucket_id", + /** + * Album name of the file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + ALBUM_NAME = "bucket_display_name" + } + /** + * Fetch parameters applicable on images, videos, audios, albums and other media + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + interface MediaFetchOptions { + /** + * Fields to retrieve, for example, selections: "media_type =? OR media_type =?". + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + selections: string; + /** + * Conditions for retrieval, for example, selectionArgs: [IMAGE, VIDEO]. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + selectionArgs: Array; + /** + * Sorting criterion of the retrieval results, for example, order: "datetaken DESC,display_name DESC, file_id DESC". + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + order?: string; + /** + * uri for retrieval + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + uri?: string; + /** + * networkId for retrieval + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + networkId?: string; + /** + * extendArgs for retrieval + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + extendArgs?: string; + } + /** + * Implements file retrieval. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' + */ + interface FetchFileResult { + /** + * Obtains the total number of files in the file retrieval result. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return Total number of files. + */ + getCount(): number; + /** + * Checks whether the result set points to the last row. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return Whether the file is the last one. + * You need to check whether the file is the last one before calling getNextObject, + * which returns the next file only when True is returned for this method. + */ + isAfterLast(): boolean; + /** + * Releases the FetchFileResult instance and invalidates it. Other methods cannot be called. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + close(): void; + /** + * Obtains the first FileAsset in the file retrieval result. This method uses a callback to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return the file in the format of a FileAsset instance. + */ + getFirstObject(callback: AsyncCallback): void; + /** + * Obtains the first FileAsset in the file retrieval result. This method uses a promise to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return A Promise instance used to return the file in the format of a FileAsset instance. + */ + getFirstObject(): Promise; + /** + * Obtains the next FileAsset in the file retrieval result. + * This method uses a callback to return the file. + * Before calling this method, you must use isAfterLast() to check whether the result set points to the last row. + * This method returns the next file only when True is returned for isAfterLast(). + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return the file in the format of a FileAsset instance. + */ + getNextObject(callback: AsyncCallback): void; + /** + * Obtains the next FileAsset in the file retrieval result. + * This method uses a promise to return the file. + * Before calling this method, you must use isAfterLast() to check whether the result set points to the last row. + * This method returns the next file only when True is returned for isAfterLast(). + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return A Promise instance used to return the file in the format of a FileAsset instance. + */ + getNextObject(): Promise; + /** + * Obtains the last FileAsset in the file retrieval result. This method uses a callback to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return the file in the format of a FileAsset instance. + */ + getLastObject(callback: AsyncCallback): void; + /** + * Obtains the last FileAsset in the file retrieval result. This method uses a promise to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return A Promise instance used to return the file in the format of a FileAsset instance. + */ + getLastObject(): Promise; + /** + * Obtains the FileAsset with the specified index in the file retrieval result. + * This method uses a callback to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param index Index of the file to obtain. + * @param callback Callback used to return the file in the format of a FileAsset instance. + */ + getPositionObject(index: number, callback: AsyncCallback): void; + /** + * Obtains the FileAsset with the specified index in the file retrieval result. + * This method uses a promise to return the file. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param index Index of the file to obtain. + * @return A Promise instance used to return the file in the format of a FileAsset instance. + */ + getPositionObject(index: number): Promise; + /** + * Obtains all FileAssets in the file retrieval result. + * This method uses a callback to return the result. After this method is called, + * close() is automatically called to release the FetchFileResult instance and invalidate it. + * In this case, other methods cannot be called. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback Callback used to return a FileAsset array. + */ + getAllObject(callback: AsyncCallback>): void; + /** + * Obtains all FileAssets in the file retrieval result. + * This method uses a promise to return the result. that store the selected media resources. + * close() is automatically called to release the FetchFileResult instance and invalidate it. + * In this case, other methods cannot be called. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @return A Promise instance used to return a FileAsset array. + */ + getAllObject(): Promise>; + } + /** + * Defines the album. + * + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @since 7 + */ + interface Album { + /** + * Album ID. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly albumId: number; + /** + * Album name. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + albumName: string; + /** + * Album uri. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly albumUri: string; + /** + * Date (timestamp) when the album was last modified. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly dateModified: number; + /** + * File count for the album + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly count: number; + /** + * Relative path for the album + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly relativePath: string; + /** + * coverUri for the album + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + readonly coverUri: string; + /** + * Modify the meta data for the album + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + * @param callback, no value will be returned. + */ + commitModify(callback: AsyncCallback): void; + /** + * Modify the meta data for the album + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + */ + commitModify(): Promise; + /** + * SObtains files in an album. This method uses an asynchronous callback to return the files. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param callback Callback used to return the files in the format of a FetchFileResult instance. + */ + getFileAssets(callback: AsyncCallback): void; + /** + * SObtains files in an album. This method uses an asynchronous callback to return the files. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param option Media retrieval options. + * @param callback Callback used to return the files in the format of a FetchFileResult instance. + */ + getFileAssets(options: MediaFetchOptions, callback: AsyncCallback): void; + /** + * Obtains files in an album. This method uses a promise to return the files. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param option Media retrieval options. + * @return A Promise instance used to return the files in the format of a FetchFileResult instance. + */ + getFileAssets(options?: MediaFetchOptions): Promise; + } + /** + * Enumeration public directory that predefined + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + enum DirectoryType { + /** + * predefined public directory for files token by Camera. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_CAMERA = 0, + /** + * predefined public directory for VIDEO files. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_VIDEO, + /** + * predefined public directory for IMAGE files. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_IMAGE, + /** + * predefined public directory for AUDIO files. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_AUDIO, + /** + * predefined public directory for DOCUMENTS files. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_DOCUMENTS, + /** + * predefined public directory for DOWNLOAD files. + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + DIR_DOWNLOAD + } + /** + * Defines the MediaLibrary class and provides functions to access the data in media storage. + * + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @since 6 + */ + interface MediaLibrary { + /** + * get system predefined root dir, use to create file asset by relative path + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param type, public directory predefined in DirectoryType. + * @param callback Callback return the FetchFileResult. + */ + getPublicDirectory(type: DirectoryType, callback: AsyncCallback): void; + /** + * get system predefined root dir, use to create file asset by relative path + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param type public directory predefined in DirectoryType. + * @return A promise instance used to return the public directory in the format of string + */ + getPublicDirectory(type: DirectoryType): Promise; + /** + * query all assets just for count & first cover + * if need all data, getAllObject from FetchFileResult + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param options, Media retrieval options. + * @param callback, Callback return the FetchFileResult. + */ + getFileAssets(options: MediaFetchOptions, callback: AsyncCallback): void; + /** + * query all assets just for count & first cover + * if need all data, getAllObject from FetchFileResult + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param options Media retrieval options. + * @return A promise instance used to return the files in the format of a FetchFileResult instance + */ + getFileAssets(options: MediaFetchOptions): Promise; + /** + * Turn on mornitor the data changes by media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param type one of 'deviceChange','albumChange','imageChange','audioChange','videoChange','fileChange','remoteFileChange' + * @param callback no value returned + */ + on(type: 'deviceChange' | 'albumChange' | 'imageChange' | 'audioChange' | 'videoChange' | 'fileChange' | 'remoteFileChange', callback: Callback): void; + /** + * Turn off mornitor the data changes by media type + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param type one of 'deviceChange','albumChange','imageChange','audioChange','videoChange','fileChange','remoteFileChange' + * @param callback no value returned + */ + off(type: 'deviceChange' | 'albumChange' | 'imageChange' | 'audioChange' | 'videoChange' | 'fileChange' | 'remoteFileChange', callback?: Callback): void; + /** + * Create File Asset + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + * @param mediaType mediaType for example:IMAGE, VIDEO, AUDIO, FILE + * @param displayName file name + * @param relativePath relative path + * @param callback Callback used to return the FileAsset + */ + createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback): void; + /** + * Create File Asset + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + * @param mediaType mediaType for example:IMAGE, VIDEO, AUDIO, FILE + * @param displayName file name + * @param relativePath relative path + * @return A Promise instance used to return the FileAsset + */ + createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise; + /** + * Obtains albums based on the media retrieval options. This method uses an asynchronous callback to return. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param option Media retrieval options. + * @param callback Callback used to return an album array. + */ + getAlbums(options: MediaFetchOptions, callback: AsyncCallback>): void; + /** + * Obtains albums based on the media retrieval options. This method uses a promise to return the albums. + * @since 7 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @permission ohos.permission.READ_MEDIA + * @param option Media retrieval options. + * @return A Promise instance used to return an album array. + */ + getAlbums(options: MediaFetchOptions): Promise>; + /** + * Stores media resources. This method uses an asynchronous callback to return the URI that stores + * the media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media resource option. + * @param callback Callback used to return the URI that stores the media resources. + * @deprecated since 9 + */ + storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback): void; + /** + * Stores media resources. This method uses a promise to return the URI that stores the media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media resource option. + * @return Promise used to return the URI that stores the media resources. + * @deprecated since 9 + */ + storeMediaAsset(option: MediaAssetOption): Promise; + /** + * Starts image preview, with the first image to preview specified. This method uses an asynchronous callback + * to receive the execution result. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param images List of images to preview. + * @param index Sequence number of the first image to preview. + * @param callback Callback used for image preview. No value is returned. + * @deprecated since 9 + */ + startImagePreview(images: Array, index: number, callback: AsyncCallback): void; + /** + * Starts image preview. This method uses an asynchronous callback to receive the execution result. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param images List of images to preview. + * @param callback Callback used for image preview. No value is returned. + * @deprecated since 9 + */ + startImagePreview(images: Array, callback: AsyncCallback): void; + /** + * Starts image preview, with the first image to preview specified. + * This method uses a promise to return the execution result. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param images List of images to preview. + * @param index Sequence number of the first image to preview. + * @return Promise used to return whether the operation is successful. + * @deprecated since 9 + */ + startImagePreview(images: Array, index?: number): Promise; + /** + * Starts media selection. This method uses an asynchronous callback to + * return the list of URIs that store the selected media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media selection option. + * @param callback Callback used to return the list of URIs that store the selected media resources. + * @deprecated since 9 + */ + startMediaSelect(option: MediaSelectOption, callback: AsyncCallback>): void; + /** + * Starts media selection. This method uses a promise to return the list of URIs + * that store the selected media resources. + * @since 6 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param option Media selection option. + * @return Promise used to return the list of URIs that store the selected media resources. + * @deprecated since 9 + */ + startMediaSelect(option: MediaSelectOption): Promise>; + /** + * Release MediaLibrary instance + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @param callback no value returned + */ + release(callback: AsyncCallback): void; + /** + * Release MediaLibrary instance + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + release(): Promise; + } + /** + * thumbnail's size which have width and heigh + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + * @since 8 + */ + interface Size { + /** + * Width of image file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + width: number; + /** + * Height of image file + * @since 8 + * @syscap SystemCapability.Multimedia.MediaLibrary.Core + */ + height: number; + } +} +export default mediaLibrary; diff --git a/build-tools/api/@ohos.multimodalInput.inputDevice.d.ts b/build-tools/api/@ohos.multimodalInput.inputDevice.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..14bdb80d48f1fdcb39f4770eba8e5e1b6d4e2432 --- /dev/null +++ b/build-tools/api/@ohos.multimodalInput.inputDevice.d.ts @@ -0,0 +1,231 @@ +/* +* Copyright (c) 2021-2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { Callback, AsyncCallback } from "./basic"; +import { KeyCode } from "./@ohos.multimodalInput.keyCode"; +/** +* The input device management module is configured to obtain an ID and device information of an input device. +* +* @since 8 +* @syscap SystemCapability.MultimodalInput.Input.InputDevice +* @import import inputDevice from '@ohos.multimodalInput.inputDevice'; +*/ +declare namespace inputDevice { + type ChangedType = 'add' | 'remove'; + type SourceType = 'keyboard' | 'mouse' | 'touchpad' | 'touchscreen' | 'joystick' | 'trackball'; + /** + * @since 9 + */ + type AxisType = 'touchMajor' | 'touchMinor' | 'orientation' | 'x' | 'y' | 'pressure' | 'toolMinor' | 'toolMajor' | 'NULL'; + /** + * @since 9 + */ + enum KeyboardType { + /** + * None + */ + NONE = 0, + /** + * Unknown key + */ + UNKNOWN = 1, + /** + * Alphabetical keyboard + */ + ALPHABETIC_KEYBOARD = 2, + /** + * Digital keyboard + */ + DIGITAL_KEYBOARD = 3, + /** + * Stylus + */ + HANDWRITING_PEN = 4, + /** + * Remote control + */ + REMOTE_CONTROL = 5 + } + /** + * Defines the listener for input device events. + * + * @since 9 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param type Type of the input device event. The options are add and remove. + * @param deviceId ID of the input device for the reported input device event. + */ + interface DeviceListener { + type: ChangedType; + deviceId: number; + } + /** + * Starts listening for an input device event. + * + * @since 9 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param type Type of the input device event, which is **change**. + * @return Callback for the input device event. + */ + function on(type: "change", listener: Callback): void; + /** + * Stops listening for an input device event. + * + * @since 9 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param type Type of the input device event, which is **change**. + * @return Callback for the input device event. + */ + function off(type: "change", listener?: Callback): void; + /** + * Defines axis information about events that can be reported by an input device. + * For example, a touchscreen may report information such as x, y, and pressure, + * which indicate the x-axis coordinate, y-axis coordinate, and pressure, respectively. + * + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param source Input source type of the axis. For example, if a mouse reports an x-axis event, the source of the x-axis is the mouse. + * @param axis Type of the axis. for example, the x-axis, y-axis, and pressure axis. + * @param max Maximum value of the data reported on this axis. + * @param min Minimum value of the data reported on this axis. + * @param fuzz Fuzz value of the data reported on this axis. + * @param flat Flat value of the data reported on this axis. + * @param resolution Resolution value of the data reported on this axis. + */ + interface AxisRange { + /** + * @since 8 + */ + source: SourceType; + /** + * @since 8 + */ + axis: AxisType; + /** + * @since 8 + */ + max: number; + /** + * @since 8 + */ + min: number; + /** + * @since 9 + */ + fuzz: number; + /** + * @since 9 + */ + flat: number; + /** + * @since 9 + */ + resolution: number; + } + /** + * Defines the information about an input device. + * + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param name Name of the input device. + * @param sources Source type supported by the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad. + * @param axisRanges Axis range of the input device. + * @param bus Bus of the input device. + * @param product Product of the input device. + * @param vendor Vendor of the input device. + * @param version Version of the input device. + * @param phys Physical path of the input device. + * @param uniq Unique identifier of the input device. + */ + interface InputDeviceData { + /** + * @since 8 + */ + id: number; + /** + * @since 8 + */ + name: string; + /** + * @since 8 + */ + sources: Array; + /** + * @since 8 + */ + axisRanges: Array; + /** + * @since 9 + */ + bus: number; + /** + * @since 9 + */ + product: number; + /** + * @since 9 + */ + vendor: number; + /** + * @since 9 + */ + version: number; + /** + * @since 9 + */ + phys: string; + /** + * @since 9 + */ + uniq: string; + } + /** + * Obtains the IDs of all input devices. + * + * @since 8 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param callback callback function, receive reported data + */ + function getDeviceIds(callback: AsyncCallback>): void; + function getDeviceIds(): Promise>; + /** + * Obtain the information about an input device. + * + * @since 8 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param deviceId ID of the input device whose information is to be obtained. + * @param callback callback function, receive reported data + */ + function getDevice(deviceId: number, callback: AsyncCallback): void; + function getDevice(deviceId: number): Promise; + /** + * Checks whether the specified key codes of an input device are supported. + * + * @since 9 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param deviceId ID of the input device. + * @param keys Key codes of the input device, You can query a maximum of five key codes at a time. + * @return Returns a result indicating whether the specified key codes are supported. + */ + function supportKeys(deviceId: number, keys: Array, callback: Callback>): void; + function supportKeys(deviceId: number, keys: Array): Promise>; + /** + * Query the keyboard type of the input device. + * + * @since 9 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param deviceId ID of the specified input device. + * @return Returns the keyboard type. + */ + function getKeyboardType(deviceId: number, callback: AsyncCallback): void; + function getKeyboardType(deviceId: number): Promise; +} +export default inputDevice; diff --git a/build-tools/api/@ohos.multimodalInput.inputEvent.d.ts b/build-tools/api/@ohos.multimodalInput.inputEvent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f348169ed95fcaf3f7001522e66e765f7e53f75 --- /dev/null +++ b/build-tools/api/@ohos.multimodalInput.inputEvent.d.ts @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* InputEvent +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import InputEvent from '@ohos.multimodalInput.inputEvent'; +*/ +export declare interface InputEvent { + /** + * Unique event ID generated by the server + */ + id: number; + /** + * ID of the device that reports the input event + */ + deviceId: number; + /** + * Occurrence time of the input event + */ + actionTime: number; + /** + * ID of the target screen + */ + screenId: number; + /** + * ID of the target window + */ + windowId: number; +} diff --git a/build-tools/api/@ohos.multimodalInput.keyCode.d.ts b/build-tools/api/@ohos.multimodalInput.keyCode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6e7824991a546ebe596ac7b60174cb61484aeac --- /dev/null +++ b/build-tools/api/@ohos.multimodalInput.keyCode.d.ts @@ -0,0 +1,353 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS; +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* KeyCode +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {KeyCode} from '@ohos.multimodalInput.keyCode', +*/ +export declare enum KeyCode { + KEYCODE_FN = 0, + KEYCODE_UNKNOWN = -1, + KEYCODE_HOME = 1, + KEYCODE_BACK = 2, + KEYCODE_MEDIA_PLAY_PAUSE = 10, + KEYCODE_MEDIA_STOP = 11, + KEYCODE_MEDIA_NEXT = 12, + KEYCODE_MEDIA_PREVIOUS = 13, + KEYCODE_MEDIA_REWIND = 14, + KEYCODE_MEDIA_FAST_FORWARD = 15, + KEYCODE_VOLUME_UP = 16, + KEYCODE_VOLUME_DOWN = 17, + KEYCODE_POWER = 18, + KEYCODE_CAMERA = 19, + KEYCODE_VOLUME_MUTE = 22, + KEYCODE_MUTE = 23, + KEYCODE_BRIGHTNESS_UP = 40, + KEYCODE_BRIGHTNESS_DOWN = 41, + KEYCODE_0 = 2000, + KEYCODE_1 = 2001, + KEYCODE_2 = 2002, + KEYCODE_3 = 2003, + KEYCODE_4 = 2004, + KEYCODE_5 = 2005, + KEYCODE_6 = 2006, + KEYCODE_7 = 2007, + KEYCODE_8 = 2008, + KEYCODE_9 = 2009, + KEYCODE_STAR = 2010, + KEYCODE_POUND = 2011, + KEYCODE_DPAD_UP = 2012, + KEYCODE_DPAD_DOWN = 2013, + KEYCODE_DPAD_LEFT = 2014, + KEYCODE_DPAD_RIGHT = 2015, + KEYCODE_DPAD_CENTER = 2016, + KEYCODE_A = 2017, + KEYCODE_B = 2018, + KEYCODE_C = 2019, + KEYCODE_D = 2020, + KEYCODE_E = 2021, + KEYCODE_F = 2022, + KEYCODE_G = 2023, + KEYCODE_H = 2024, + KEYCODE_I = 2025, + KEYCODE_J = 2026, + KEYCODE_K = 2027, + KEYCODE_L = 2028, + KEYCODE_M = 2029, + KEYCODE_N = 2030, + KEYCODE_O = 2031, + KEYCODE_P = 2032, + KEYCODE_Q = 2033, + KEYCODE_R = 2034, + KEYCODE_S = 2035, + KEYCODE_T = 2036, + KEYCODE_U = 2037, + KEYCODE_V = 2038, + KEYCODE_W = 2039, + KEYCODE_X = 2040, + KEYCODE_Y = 2041, + KEYCODE_Z = 2042, + KEYCODE_COMMA = 2043, + KEYCODE_PERIOD = 2044, + KEYCODE_ALT_LEFT = 2045, + KEYCODE_ALT_RIGHT = 2046, + KEYCODE_SHIFT_LEFT = 2047, + KEYCODE_SHIFT_RIGHT = 2048, + KEYCODE_TAB = 2049, + KEYCODE_SPACE = 2050, + KEYCODE_SYM = 2051, + KEYCODE_EXPLORER = 2052, + KEYCODE_ENVELOPE = 2053, + KEYCODE_ENTER = 2054, + KEYCODE_DEL = 2055, + KEYCODE_GRAVE = 2056, + KEYCODE_MINUS = 2057, + KEYCODE_EQUALS = 2058, + KEYCODE_LEFT_BRACKET = 2059, + KEYCODE_RIGHT_BRACKET = 2060, + KEYCODE_BACKSLASH = 2061, + KEYCODE_SEMICOLON = 2062, + KEYCODE_APOSTROPHE = 2063, + KEYCODE_SLASH = 2064, + KEYCODE_AT = 2065, + KEYCODE_PLUS = 2066, + KEYCODE_MENU = 2067, + KEYCODE_PAGE_UP = 2068, + KEYCODE_PAGE_DOWN = 2069, + KEYCODE_ESCAPE = 2070, + KEYCODE_FORWARD_DEL = 2071, + KEYCODE_CTRL_LEFT = 2072, + KEYCODE_CTRL_RIGHT = 2073, + KEYCODE_CAPS_LOCK = 2074, + KEYCODE_SCROLL_LOCK = 2075, + KEYCODE_META_LEFT = 2076, + KEYCODE_META_RIGHT = 2077, + KEYCODE_FUNCTION = 2078, + KEYCODE_SYSRQ = 2079, + KEYCODE_BREAK = 2080, + KEYCODE_MOVE_HOME = 2081, + KEYCODE_MOVE_END = 2082, + KEYCODE_INSERT = 2083, + KEYCODE_FORWARD = 2084, + KEYCODE_MEDIA_PLAY = 2085, + KEYCODE_MEDIA_PAUSE = 2086, + KEYCODE_MEDIA_CLOSE = 2087, + KEYCODE_MEDIA_EJECT = 2088, + KEYCODE_MEDIA_RECORD = 2089, + KEYCODE_F1 = 2090, + KEYCODE_F2 = 2091, + KEYCODE_F3 = 2092, + KEYCODE_F4 = 2093, + KEYCODE_F5 = 2094, + KEYCODE_F6 = 2095, + KEYCODE_F7 = 2096, + KEYCODE_F8 = 2097, + KEYCODE_F9 = 2098, + KEYCODE_F10 = 2099, + KEYCODE_F11 = 2100, + KEYCODE_F12 = 2101, + KEYCODE_NUM_LOCK = 2102, + KEYCODE_NUMPAD_0 = 2103, + KEYCODE_NUMPAD_1 = 2104, + KEYCODE_NUMPAD_2 = 2105, + KEYCODE_NUMPAD_3 = 2106, + KEYCODE_NUMPAD_4 = 2107, + KEYCODE_NUMPAD_5 = 2108, + KEYCODE_NUMPAD_6 = 2109, + KEYCODE_NUMPAD_7 = 2110, + KEYCODE_NUMPAD_8 = 2111, + KEYCODE_NUMPAD_9 = 2112, + KEYCODE_NUMPAD_DIVIDE = 2113, + KEYCODE_NUMPAD_MULTIPLY = 2114, + KEYCODE_NUMPAD_SUBTRACT = 2115, + KEYCODE_NUMPAD_ADD = 2116, + KEYCODE_NUMPAD_DOT = 2117, + KEYCODE_NUMPAD_COMMA = 2118, + KEYCODE_NUMPAD_ENTER = 2119, + KEYCODE_NUMPAD_EQUALS = 2120, + KEYCODE_NUMPAD_LEFT_PAREN = 2121, + KEYCODE_NUMPAD_RIGHT_PAREN = 2122, + KEYCODE_VIRTUAL_MULTITASK = 2210, + KEYCODE_SLEEP = 2600, + KEYCODE_ZENKAKU_HANKAKU = 2601, + KEYCODE_102ND = 2602, + KEYCODE_RO = 2603, + KEYCODE_KATAKANA = 2604, + KEYCODE_HIRAGANA = 2605, + KEYCODE_HENKAN = 2606, + KEYCODE_KATAKANA_HIRAGANA = 2607, + KEYCODE_MUHENKAN = 2608, + KEYCODE_LINEFEED = 2609, + KEYCODE_MACRO = 2610, + KEYCODE_NUMPAD_PLUSMINUS = 2611, + KEYCODE_SCALE = 2612, + KEYCODE_HANGUEL = 2613, + KEYCODE_HANJA = 2614, + KEYCODE_YEN = 2615, + KEYCODE_STOP = 2616, + KEYCODE_AGAIN = 2617, + KEYCODE_PROPS = 2618, + KEYCODE_UNDO = 2619, + KEYCODE_COPY = 2620, + KEYCODE_OPEN = 2621, + KEYCODE_PASTE = 2622, + KEYCODE_FIND = 2623, + KEYCODE_CUT = 2624, + KEYCODE_HELP = 2625, + KEYCODE_CALC = 2626, + KEYCODE_FILE = 2627, + KEYCODE_BOOKMARKS = 2628, + KEYCODE_NEXT = 2629, + KEYCODE_PLAYPAUSE = 2630, + KEYCODE_PREVIOUS = 2631, + KEYCODE_STOPCD = 2632, + KEYCODE_CONFIG = 2634, + KEYCODE_REFRESH = 2635, + KEYCODE_EXIT = 2636, + KEYCODE_EDIT = 2637, + KEYCODE_SCROLLUP = 2638, + KEYCODE_SCROLLDOWN = 2639, + KEYCODE_NEW = 2640, + KEYCODE_REDO = 2641, + KEYCODE_CLOSE = 2642, + KEYCODE_PLAY = 2643, + KEYCODE_BASSBOOST = 2644, + KEYCODE_PRINT = 2645, + KEYCODE_CHAT = 2646, + KEYCODE_FINANCE = 2647, + KEYCODE_CANCEL = 2648, + KEYCODE_KBDILLUM_TOGGLE = 2649, + KEYCODE_KBDILLUM_DOWN = 2650, + KEYCODE_KBDILLUM_UP = 2651, + KEYCODE_SEND = 2652, + KEYCODE_REPLY = 2653, + KEYCODE_FORWARDMAIL = 2654, + KEYCODE_SAVE = 2655, + KEYCODE_DOCUMENTS = 2656, + KEYCODE_VIDEO_NEXT = 2657, + KEYCODE_VIDEO_PREV = 2658, + KEYCODE_BRIGHTNESS_CYCLE = 2659, + KEYCODE_BRIGHTNESS_ZERO = 2660, + KEYCODE_DISPLAY_OFF = 2661, + KEYCODE_BTN_MISC = 2662, + KEYCODE_GOTO = 2663, + KEYCODE_INFO = 2664, + KEYCODE_PROGRAM = 2665, + KEYCODE_PVR = 2666, + KEYCODE_SUBTITLE = 2667, + KEYCODE_FULL_SCREEN = 2668, + KEYCODE_KEYBOARD = 2669, + KEYCODE_ASPECT_RATIO = 2670, + KEYCODE_PC = 2671, + KEYCODE_TV = 2672, + KEYCODE_TV2 = 2673, + KEYCODE_VCR = 2674, + KEYCODE_VCR2 = 2675, + KEYCODE_SAT = 2676, + KEYCODE_CD = 2677, + KEYCODE_TAPE = 2678, + KEYCODE_TUNER = 2679, + KEYCODE_PLAYER = 2680, + KEYCODE_DVD = 2681, + KEYCODE_AUDIO = 2682, + KEYCODE_VIDEO = 2683, + KEYCODE_MEMO = 2684, + KEYCODE_CALENDAR = 2685, + KEYCODE_RED = 2686, + KEYCODE_GREEN = 2687, + KEYCODE_YELLOW = 2688, + KEYCODE_BLUE = 2689, + KEYCODE_CHANNELUP = 2690, + KEYCODE_CHANNELDOWN = 2691, + KEYCODE_LAST = 2692, + KEYCODE_RESTART = 2693, + KEYCODE_SLOW = 2694, + KEYCODE_SHUFFLE = 2695, + KEYCODE_VIDEOPHONE = 2696, + KEYCODE_GAMES = 2697, + KEYCODE_ZOOMIN = 2698, + KEYCODE_ZOOMOUT = 2699, + KEYCODE_ZOOMRESET = 2700, + KEYCODE_WORDPROCESSOR = 2701, + KEYCODE_EDITOR = 2702, + KEYCODE_SPREADSHEET = 2703, + KEYCODE_GRAPHICSEDITOR = 2704, + KEYCODE_PRESENTATION = 2705, + KEYCODE_DATABASE = 2706, + KEYCODE_NEWS = 2707, + KEYCODE_VOICEMAIL = 2708, + KEYCODE_ADDRESSBOOK = 2709, + KEYCODE_MESSENGER = 2710, + KEYCODE_BRIGHTNESS_TOGGLE = 2711, + KEYCODE_SPELLCHECK = 2712, + KEYCODE_COFFEE = 2713, + KEYCODE_MEDIA_REPEAT = 2714, + KEYCODE_IMAGES = 2715, + KEYCODE_BUTTONCONFIG = 2716, + KEYCODE_TASKMANAGER = 2717, + KEYCODE_JOURNAL = 2718, + KEYCODE_CONTROLPANEL = 2719, + KEYCODE_APPSELECT = 2720, + KEYCODE_SCREENSAVER = 2721, + KEYCODE_ASSISTANT = 2722, + KEYCODE_KBD_LAYOUT_NEXT = 2723, + KEYCODE_BRIGHTNESS_MIN = 2724, + KEYCODE_BRIGHTNESS_MAX = 2725, + KEYCODE_KBDINPUTASSIST_PREV = 2726, + KEYCODE_KBDINPUTASSIST_NEXT = 2727, + KEYCODE_KBDINPUTASSIST_PREVGROUP = 2728, + KEYCODE_KBDINPUTASSIST_NEXTGROUP = 2729, + KEYCODE_KBDINPUTASSIST_ACCEPT = 2730, + KEYCODE_KBDINPUTASSIST_CANCEL = 2731, + KEYCODE_FRONT = 2800, + KEYCODE_SETUP = 2801, + KEYCODE_WAKEUP = 2802, + KEYCODE_SENDFILE = 2803, + KEYCODE_DELETEFILE = 2804, + KEYCODE_XFER = 2805, + KEYCODE_PROG1 = 2806, + KEYCODE_PROG2 = 2807, + KEYCODE_MSDOS = 2808, + KEYCODE_SCREENLOCK = 2809, + KEYCODE_DIRECTION_ROTATE_DISPLAY = 2810, + KEYCODE_CYCLEWINDOWS = 2811, + KEYCODE_COMPUTER = 2812, + KEYCODE_EJECTCLOSECD = 2813, + KEYCODE_ISO = 2814, + KEYCODE_MOVE = 2815, + KEYCODE_F13 = 2816, + KEYCODE_F14 = 2817, + KEYCODE_F15 = 2818, + KEYCODE_F16 = 2819, + KEYCODE_F17 = 2820, + KEYCODE_F18 = 2821, + KEYCODE_F19 = 2822, + KEYCODE_F20 = 2823, + KEYCODE_F21 = 2824, + KEYCODE_F22 = 2825, + KEYCODE_F23 = 2826, + KEYCODE_F24 = 2827, + KEYCODE_PROG3 = 2828, + KEYCODE_PROG4 = 2829, + KEYCODE_DASHBOARD = 2830, + KEYCODE_SUSPEND = 2831, + KEYCODE_HP = 2832, + KEYCODE_SOUND = 2833, + KEYCODE_QUESTION = 2834, + KEYCODE_CONNECT = 2836, + KEYCODE_SPORT = 2837, + KEYCODE_SHOP = 2838, + KEYCODE_ALTERASE = 2839, + KEYCODE_SWITCHVIDEOMODE = 2841, + KEYCODE_BATTERY = 2842, + KEYCODE_BLUETOOTH = 2843, + KEYCODE_WLAN = 2844, + KEYCODE_UWB = 2845, + KEYCODE_WWAN_WIMAX = 2846, + KEYCODE_RFKILL = 2847, + KEYCODE_CHANNEL = 3001, + KEYCODE_BTN_0 = 3100, + KEYCODE_BTN_1 = 3101, + KEYCODE_BTN_2 = 3102, + KEYCODE_BTN_3 = 3103, + KEYCODE_BTN_4 = 3104, + KEYCODE_BTN_5 = 3105, + KEYCODE_BTN_6 = 3106, + KEYCODE_BTN_7 = 3107, + KEYCODE_BTN_8 = 3108, + KEYCODE_BTN_9 = 3109 +} diff --git a/build-tools/api/@ohos.multimodalInput.keyEvent.d.ts b/build-tools/api/@ohos.multimodalInput.keyEvent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..add010ad29386773b2df42951de7041a5706a77e --- /dev/null +++ b/build-tools/api/@ohos.multimodalInput.keyEvent.d.ts @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { InputEvent } from "./@ohos.multimodalInput.inputEvent"; +import { KeyCode } from "./@ohos.multimodalInput.keyCode"; +/** +* Action +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {Action} from '@ohos.multimodalInput.keyEvent'; +*/ +export declare enum Action { + /** + * Cancel key + */ + CANCEL = 0, + /** + * Down key + */ + DOWN = 1, + /** + * Up key + */ + UP = 2 +} +/** +* Key +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {Key} from '@ohos.multimodalInput.keyEvent'; +*/ +export declare interface Key { + /** + * Key code + */ + code: KeyCode; + /** + * Time when the key is pressed + */ + pressedTime: number; + /** + * Device to which the key belongs + */ + deviceId: number; +} +/** +* KeyEvent +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {KeyEvent} from '@ohos.multimodalInput.keyEvent'; +*/ +export declare interface KeyEvent extends InputEvent { + /** + * Key action + */ + action: Action; + /** + * Key that has changed + */ + key: Key; + /** + * Unicode character corresponding to the key + */ + unicodeChar: number; + /** + * List of pressed keys + */ + keys: Key[]; + /** + * Whether ctrlKey is being pressed + */ + ctrlKey: boolean; + /** + * Whether altKey is being pressed + */ + altKey: boolean; + /** + * Whether shiftKey is being pressed + */ + shiftKey: boolean; + /** + * Whether logoKey is being pressed + */ + logoKey: boolean; + /** + * Whether fnKey is being pressed + */ + fnKey: boolean; + /** + * Whether capsLock is active + */ + capsLock: boolean; + /** + * Whether numLock is active + */ + numLock: boolean; + /** + * Whether scrollLock is active + */ + scrollLock: boolean; +} diff --git a/build-tools/api/@ohos.multimodalInput.mouseEvent.d.ts b/build-tools/api/@ohos.multimodalInput.mouseEvent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b52f54cf88d1cdc0ac2038f2c2e97bbc578e4369 --- /dev/null +++ b/build-tools/api/@ohos.multimodalInput.mouseEvent.d.ts @@ -0,0 +1,217 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { InputEvent } from "./@ohos.multimodalInput.inputEvent"; +import { KeyCode } from "./@ohos.multimodalInput.keyCode"; +/** +* Action +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {Action} from '@ohos.multimodalInput.mouseEvent'; +*/ +export declare enum Action { + /** + * Cancel + */ + CANCEL = 0, + /** + * Moving of the mouse pointer + */ + MOVE = 1, + /** + * Pressing down of the mouse + */ + BUTTON_DOWN = 2, + /** + * Lifting of the mouse button + */ + BUTTON_UP = 3, + /** + * Beginning of the axis event associated with the mouse + */ + AXIS_BEGIN = 4, + /** + * Updating of the axis event associated with the mouse + */ + AXIS_UPDATE = 5, + /** + * Ending of the axis event associated with the mouse + */ + AXIS_END = 6 +} +/** +* Button +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {Button} from '@ohos.multimodalInput.mouseEvent'; +*/ +export declare enum Button { + /** + * Left button on the mouse + */ + LEFT = 0, + /** + * Middle button on the mouse + */ + MIDDLE = 1, + /** + * Right button on the mouse + */ + RIGHT = 2, + /** + * Side button on the mouse + */ + SIDE = 3, + /** + * Extended button on the mouse + */ + EXTRA = 4, + /** + * Forward button on the mouse + */ + FORWARD = 5, + /** + * Back button on the mouse + */ + BACK = 6, + /** + * Task key on the mouse + */ + TASK = 7 +} +/** +* Axis +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {Axis} from '@ohos.multimodalInput.mouseEvent'; +*/ +export declare enum Axis { + /** + * Vertical scroll axis + */ + SCROLL_VERTICAL = 0, + /** + * Horizontal scroll axis + */ + SCROLL_HORIZONTAL = 1, + /** + * Pinch axis + */ + PINCH = 2 +} +/** +* AxisValue +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {AxisValue} from '@ohos.multimodalInput.mouseEvent'; +*/ +export declare interface AxisValue { + /** + * Axis type + */ + axis: Axis; + /** + * Axis value + */ + value: number; +} +/** +* MouseEvent +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {MouseEvent} from '@ohos.multimodalInput.mouseEvent'; +*/ +export declare interface MouseEvent extends InputEvent { + /** + * Mouse event action + */ + action: Action; + /** + * X coordinate of the mouse pointer on the screen + */ + screenX: number; + /** + * Y coordinate of the mouse pointer on the screen + */ + screenY: number; + /** + * X coordinate of the mouse pointer in the window + */ + windowX: number; + /** + * Y coordinate of the mouse pointer in the window + */ + windowY: number; + /** + * X axis offset relative to the previous reported mouse pointer position. When the mouse pointer is at the edge of the screen, the value may be less than the difference of the X coordinate reported twice. + */ + rawDeltaX: number; + /** + * Y axis offset relative to the previous reported mouse pointer position + */ + rawDeltaY: number; + /** + * Button that is currently pressed or released + */ + button: Button; + /** + * Button that is being pressed + */ + pressedButtons: Button[]; + /** + * All axis data contained in the event + */ + axes: AxisValue[]; + /** + * List of pressed keys + */ + pressedKeys: KeyCode[]; + /** + * Whether ctrlKey is being pressed + */ + ctrlKey: boolean; + /** + * Whether altKey is being pressed + */ + altKey: boolean; + /** + * Whether shiftKey is being pressed + */ + shiftKey: boolean; + /** + * Whether logoKey is being pressed + */ + logoKey: boolean; + /** + * Whether fnKey is being pressed + */ + fnKey: boolean; + /** + * Whether capsLock is active + */ + capsLock: boolean; + /** + * Whether numLock is active + */ + numLock: boolean; + /** + * Whether scrollLock is active + */ + scrollLock: boolean; +} diff --git a/build-tools/api/@ohos.multimodalInput.touchEvent.d.ts b/build-tools/api/@ohos.multimodalInput.touchEvent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3288c559dda08d6b32a7a12042e9883aae76a4f --- /dev/null +++ b/build-tools/api/@ohos.multimodalInput.touchEvent.d.ts @@ -0,0 +1,205 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { InputEvent } from './@ohos.multimodalInput.inputEvent'; +/** +* Action +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {Action} from '@ohos.multimodalInput.touchEvent'; +*/ +export declare enum Action { + /** + * Touch cancelled + */ + CANCEL = 0, + /** + * Touch pressed + */ + DOWN = 1, + /** + * Touch moved + */ + MOVE = 2, + /** + * Touch lifted + */ + UP = 3 +} +/** +* ToolType +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {ToolType} from '@ohos.multimodalInput.touchEvent'; +*/ +export declare enum ToolType { + /** + * Finger + */ + FINGER = 0, + /** + * Stylus + */ + PEN = 1, + /** + * Rubber + */ + RUBBER = 2, + /** + * Brush + */ + BRUSH = 3, + /** + * Pencil + */ + PENCIL = 4, + /** + * Air brush + */ + AIRBRUSH = 5, + /** + * Mouse + */ + MOUSE = 6, + LENS = 7 +} +/** +* SourceType +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {SourceType} from '@ohos.multimodalInput.touchEvent'; +*/ +export declare enum SourceType { + /** + * Touchscreen + */ + TOUCH_SCREEN = 0, + /** + * Stylus + */ + PEN = 1, + /** + * Touchpad + */ + TOUCH_PAD = 2 +} +/** +* Touch +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {Touch} from '@ohos.multimodalInput.touchEvent'; +*/ +export declare interface Touch { + /** + * Pointer identifier + */ + id: number; + /** + * Time stamp when touch is pressed + */ + pressedTime: number; + /** + * X coordinate of the touch position on the screen + */ + screenX: number; + /** + * Y coordinate of the touch position on the screen + */ + screenY: number; + /** + * X coordinate of the touch position in the window + */ + windowX: number; + /** + * Y coordinate of the touch position in the window + */ + windowY: number; + /** + * Pressure value. The value range is [0.0, 1.0]. The value 0.0 indicates that the pressure is not supported. + */ + pressure: number; + /** + * Width of the contact area when touch is pressed + */ + width: number; + /** + * Height of the contact area when touch is pressed + */ + height: number; + /** + * Angle relative to the YZ plane. The value range is [-90, 90]. A positive value indicates a rightward tilt. + */ + tiltX: number; + /** + * Angle relative to the XZ plane. The value range is [-90, 90]. A positive value indicates a downward tilt. + */ + tiltY: number; + /** + * Center point X of the tool area + */ + toolX: number; + /** + * Center point Y of the tool area + */ + toolY: number; + /** + * Width of the tool area + */ + toolWidth: number; + /** + * Height of the tool area + */ + toolHeight: number; + /** + * X coordinate of the input device + */ + rawX: number; + /** + * Y coordinate of the input device + */ + rawY: number; + /** + * Tool type + */ + toolType: ToolType; +} +/** +* TouchEvent +* +* @since 9 +* @syscap SystemCapability.MultimodalInput.Input.Core +* @import import {TouchEvent} from '@ohos.multimodalInput.touchEvent'; +*/ +export declare interface TouchEvent extends InputEvent { + /** + * Touch action + */ + action: Action; + /** + * Current touch point + */ + touch: Touch; + /** + * All touch points + */ + touches: Touch[]; + /** + * Device type of the touch source + */ + sourceType: SourceType; +} diff --git a/build-tools/api/@ohos.net.connection.d.ts b/build-tools/api/@ohos.net.connection.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2d7b1571e053d89994e1b25245492a9cc0214061 --- /dev/null +++ b/build-tools/api/@ohos.net.connection.d.ts @@ -0,0 +1,222 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from "./basic"; +import http from "./@ohos.net.http"; +import socket from "./@ohos.net.socket"; +/** + * Provides interfaces to manage and use data networks. + * + * @since 8 + * @syscap SystemCapability.Communication.NetManager.Core + */ +declare namespace connection { + type HttpRequest = http.HttpRequest; + type TCPSocket = socket.TCPSocket; + type UDPSocket = socket.UDPSocket; + /** + * Create a network connection with optional netSpefifier and timeout. + * + * @param netSpecifier Indicates the network specifier. See {@link NetSpecifier}. + * @param timeout The time in milliseconds to attempt looking for a suitable network before + * {@link NetConnection#netUnavailable} is called. + */ + function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection; + /** + * Obtains the data network that is activated by default. + * + * @param callback Returns the {@link NetHandle} object; + * returns {@code null} if the default network is not activated. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getDefaultNet(callback: AsyncCallback): void; + function getDefaultNet(): Promise; + /** + * Obtains the list of data networks that are activated. + * + * @param callback Returns the {@link NetHandle} object; returns {@code null} if no network is activated. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getAllNets(callback: AsyncCallback>): void; + function getAllNets(): Promise>; + /** + * Queries the connection properties of a network. + * + * @param netHandle Indicates the network to be queried. + * @param callback Returns the {@link ConnectionProperties} object. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback): void; + function getConnectionProperties(netHandle: NetHandle): Promise; + /** + * Obtains {@link NetCapabilities} of a {@link NetHandle} object. + * + * @param netHandle Indicates the handle. See {@link NetHandle}. + * @param callback Returns {@link NetCapabilities}; returns {@code null} if {@code handle} is invalid. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback): void; + function getNetCapabilities(netHandle: NetHandle): Promise; + /** + * Checks whether the default data network is activated. + * + * @param callback Returns {@code true} if the default data network is activated; returns {@code false} otherwise. + */ + function hasDefaultNet(callback: AsyncCallback): void; + function hasDefaultNet(): Promise; + /** + * Reports the network state is connected. + * + * @param netHandle Indicates the network whose state is to be reported. + * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET + */ + function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback): void; + function reportNetConnected(netHandle: NetHandle): Promise; + /** + * Reports the network state is disconnected. + * + * @param netHandle Indicates the network whose state is to be reported. + * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET + */ + function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback): void; + function reportNetDisconnected(netHandle: NetHandle): Promise; + /** + * Resolves the host name to obtain all IP addresses based on the default data network. + * + * @param host Indicates the host name or the domain. + * @param callback Returns the NetAddress list. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getAddressesByName(host: string, callback: AsyncCallback>): void; + function getAddressesByName(host: string): Promise>; + export interface NetConnection { + on(type: 'netAvailable', callback: Callback): void; + on(type: 'netBlockStatusChange', callback: Callback<{ + netHandle: NetHandle; + blocked: boolean; + }>): void; + on(type: 'netCapabilitiesChange', callback: Callback<{ + netHandle: NetHandle; + netCap: NetCapabilities; + }>): void; + on(type: 'netConnectionPropertiesChange', callback: Callback<{ + netHandle: NetHandle; + connectionProperties: ConnectionProperties; + }>): void; + on(type: 'netLost', callback: Callback): void; + on(type: 'netUnavailable', callback: Callback): void; + /** + * Receives status change notifications of a specified network. + * + * @permission ohos.permission.GET_NETWORK_INFO + */ + register(callback: AsyncCallback): void; + /** + * Cancels listening for network status changes. + */ + unregister(callback: AsyncCallback): void; + } + export interface NetSpecifier { + netCapabilities: NetCapabilities; + bearerPrivateIdentifier?: string; + } + export interface NetHandle { + netId: number; + /** + * Resolves a host name to obtain all IP addresses based on the specified NetHandle. + * + * @param host Indicates the host name or the domain. + * @param callback Returns the NetAddress list. + * @permission ohos.permission.GET_NETWORK_INFO + */ + getAddressesByName(host: string, callback: AsyncCallback>): void; + getAddressesByName(host: string): Promise>; + /** + * Resolves a host name to obtain the first IP address based on the specified NetHandle. + * + * @param host Indicates the host name or the domain. + * @return Returns the first NetAddress. + * @permission ohos.permission.GET_NETWORK_INFO + */ + getAddressByName(host: string, callback: AsyncCallback): void; + getAddressByName(host: string): Promise; + } + export interface NetCapabilities { + linkUpBandwidthKbps?: number; + linkDownBandwidthKbps?: number; + networkCap?: Array; + bearerTypes: Array; + } + export enum NetCap { + /** + * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages. + */ + NET_CAPABILITY_MMS = 0, + /** + * Indicates that the network traffic is not metered. + */ + NET_CAPABILITY_NOT_METERED = 11, + /** + * Indicates that the network can access the Internet. + */ + NET_CAPABILITY_INTERNET = 12, + /** + * Indicates that the network does not use a VPN. + */ + NET_CAPABILITY_NOT_VPN = 15, + /** + * Indicates that the network is available. + */ + NET_CAPABILITY_VALIDATED = 16 + } + export enum NetBearType { + /** + * Indicates that the network is based on a cellular network. + */ + BEARER_CELLULAR = 0, + /** + * Indicates that the network is based on a Wi-Fi network. + */ + BEARER_WIFI = 1, + /** + * Indicates that the network is an Ethernet network. + */ + BEARER_ETHERNET = 3 + } + export interface ConnectionProperties { + interfaceName: string; + domains: string; + linkAddresses: Array; + dnses: Array; + routes: Array; + mtu: number; + } + export interface RouteInfo { + interface: string; + destination: LinkAddress; + gateway: NetAddress; + hasGateway: boolean; + isDefaultRoute: boolean; + } + export interface LinkAddress { + address: NetAddress; + prefixLength: number; + } + export interface NetAddress { + address: string; + family?: number; // IPv4 = 1; IPv6 = 2, default is IPv4 + port?: number; // [0, 65535] + } +} +export default connection; diff --git a/build-tools/api/@ohos.net.http.d.ts b/build-tools/api/@ohos.net.http.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b098ec231d4e279e15efb947f638db8555fa7205 --- /dev/null +++ b/build-tools/api/@ohos.net.http.d.ts @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from "./basic"; +/** + * Provides http related APIs. + * + * @since 6 + * @syscap SystemCapability.Communication.NetStack + */ +declare namespace http { + /** + * Creates an HTTP request task. + */ + function createHttp(): HttpRequest; + export interface HttpRequestOptions { + /** + * Request method. + */ + method?: RequestMethod; // default is GET + /** + * Additional data of the request. + * extraData can be a string or an Object (API 6) or an ArrayBuffer(API 8). + */ + extraData?: string | Object | ArrayBuffer; + /** + * HTTP request header. + */ + header?: Object; // default is 'content-type': 'application/json' + /** + * Read timeout period. The default value is 60,000, in ms. + */ + readTimeout?: number; // default is 60s + /** + * Connection timeout interval. The default value is 60,000, in ms. + */ + connectTimeout?: number; // default is 60s. + } + export interface HttpRequest { + /** + * Initiates an HTTP request to a given URL. + * + * @param url URL for initiating an HTTP request. + * @param options Optional parameters {@link HttpRequestOptions}. + * @param callback Returns {@link HttpResponse}. + * @permission ohos.permission.INTERNET + */ + request(url: string, callback: AsyncCallback): void; + request(url: string, options: HttpRequestOptions, callback: AsyncCallback): void; + request(url: string, options?: HttpRequestOptions): Promise; + /** + * Destroys an HTTP request. + */ + destroy(): void; + /** + * Registers an observer for HTTP Response Header events. + * + * @deprecated use on_headersReceive instead since 8. + */ + on(type: "headerReceive", callback: AsyncCallback): void; + /** + * Unregisters the observer for HTTP Response Header events. + * + * @deprecated use off_headersReceive instead since 8. + */ + off(type: "headerReceive", callback?: AsyncCallback): void; + /** + * Registers an observer for HTTP Response Header events. + * + * @since 8 + */ + on(type: "headersReceive", callback: Callback): void; + /** + * Unregisters the observer for HTTP Response Header events. + * + * @since 8 + */ + off(type: "headersReceive", callback?: Callback): void; + /** + * Registers a one-time observer for HTTP Response Header events. + * + * @since 8 + */ + once(type: "headersReceive", callback: Callback): void; + } + export enum RequestMethod { + OPTIONS = "OPTIONS", + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + TRACE = "TRACE", + CONNECT = "CONNECT" + } + export enum ResponseCode { + OK = 200, + CREATED, + ACCEPTED, + NOT_AUTHORITATIVE, + NO_CONTENT, + RESET, + PARTIAL, + MULT_CHOICE = 300, + MOVED_PERM, + MOVED_TEMP, + SEE_OTHER, + NOT_MODIFIED, + USE_PROXY, + BAD_REQUEST = 400, + UNAUTHORIZED, + PAYMENT_REQUIRED, + FORBIDDEN, + NOT_FOUND, + BAD_METHOD, + NOT_ACCEPTABLE, + PROXY_AUTH, + CLIENT_TIMEOUT, + CONFLICT, + GONE, + LENGTH_REQUIRED, + PRECON_FAILED, + ENTITY_TOO_LARGE, + REQ_TOO_LONG, + UNSUPPORTED_TYPE, + INTERNAL_ERROR = 500, + NOT_IMPLEMENTED, + BAD_GATEWAY, + UNAVAILABLE, + GATEWAY_TIMEOUT, + VERSION + } + export interface HttpResponse { + /** + * result can be a string (API 6) or an ArrayBuffer(API 8). Object is deprecated from API 8. + */ + result: string | Object | ArrayBuffer; + /** + * Server status code. + */ + responseCode: ResponseCode | number; + /** + * All headers in the response from the server. + */ + header: Object; + /** + * @since 8 + */ + cookies: string; + } +} +export default http; diff --git a/build-tools/api/@ohos.net.socket.d.ts b/build-tools/api/@ohos.net.socket.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..42a68fbf9465eae8b7028b072b22b784f8d31d47 --- /dev/null +++ b/build-tools/api/@ohos.net.socket.d.ts @@ -0,0 +1,297 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback, ErrorCallback } from "./basic"; +import connection from "./@ohos.net.connection"; +/** + * Provides TCP and UDP Socket APIs. + * + * @since 7 + * @syscap SystemCapability.Communication.NetStack + */ +declare namespace socket { + export import NetAddress = connection.NetAddress; + /** + * Creates a UDPSocket object. + */ + function constructUDPSocketInstance(): UDPSocket; + /** + * Creates a TCPSocket object. + */ + function constructTCPSocketInstance(): TCPSocket; + export interface UDPSendOptions { + /** + * Data to send. + */ + data: string | ArrayBuffer; + /** + * Destination address. + */ + address: NetAddress; + } + export interface ExtraOptionsBase { + /** + * Size of the receive buffer, in MBS. + */ + receiveBufferSize?: number; + /** + * Size of the send buffer, in MBS. + */ + sendBufferSize?: number; + /** + * Whether to reuse addresses. The default value is false. + */ + reuseAddress?: boolean; + /** + * Timeout duration of the UDPSocket connection, in milliseconds. + */ + socketTimeout?: number; + } + export interface UDPExtraOptions extends ExtraOptionsBase { + /** + * Whether to send broadcast messages. The default value is false. + */ + broadcast?: boolean; + } + export interface SocketStateBase { + /** + * Whether the connection is in the bound state. + */ + isBound: boolean; + /** + * Whether the connection is in the closed state. + */ + isClose: boolean; + /** + * Whether the connection is in the connected state. + */ + isConnected: boolean; + } + export interface SocketRemoteInfo { + /** + * Bound IP address. + */ + address: string; + /** + * Network protocol type. The options are as follows: IPv4, IPv6. + */ + family: 'IPv4' | 'IPv6'; + /** + * Port number. The value ranges from 0 to 65535. + */ + port: number; + /** + * Length of the server response message, in bytes. + */ + size: number; + } + export interface UDPSocket { + /** + * Binds the IP address and port number. The port number can be specified or randomly allocated by the system. + * + * @param address Destination address. {@link NetAddress} + * @permission ohos.permission.INTERNET + */ + bind(address: NetAddress, callback: AsyncCallback): void; + bind(address: NetAddress): Promise; + /** + * Sends data over a UDPSocket connection. + * + * @param options Optional parameters {@link UDPSendOptions}. + * @permission ohos.permission.INTERNET + */ + send(options: UDPSendOptions, callback: AsyncCallback): void; + send(options: UDPSendOptions): Promise; + /** + * Closes a UDPSocket connection. + * @permission ohos.permission.INTERNET + */ + close(callback: AsyncCallback): void; + close(): Promise; + /** + * Obtains the status of the UDPSocket connection. + * + * @param callback Callback used to return the result. {@link SocketStateBase}. + * @permission ohos.permission.INTERNET + */ + getState(callback: AsyncCallback): void; + getState(): Promise; + /** + * Sets other attributes of the UDPSocket connection. + * + * @param options Optional parameters {@link UDPExtraOptions}. + * @permission ohos.permission.INTERNET + */ + setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback): void; + setExtraOptions(options: UDPExtraOptions): Promise; + /** + * Listens for message receiving events of the UDPSocket connection. + */ + on(type: 'message', callback: Callback<{ + message: ArrayBuffer; + remoteInfo: SocketRemoteInfo; + }>): void; + /** + * Cancels listening for message receiving events of the UDPSocket connection. + */ + off(type: 'message', callback?: Callback<{ + message: ArrayBuffer; + remoteInfo: SocketRemoteInfo; + }>): void; + /** + * Listens for data packet message events or close events of the UDPSocket connection. + */ + on(type: 'listening' | 'close', callback: Callback): void; + /** + * Cancels listening for data packet message events or close events of the UDPSocket connection. + */ + off(type: 'listening' | 'close', callback?: Callback): void; + /** + * Listens for error events of the UDPSocket connection. + */ + on(type: 'error', callback: ErrorCallback): void; + /** + * Cancels listening for error events of the UDPSocket connection. + */ + off(type: 'error', callback?: ErrorCallback): void; + } + export interface TCPConnectOptions { + /** + * Bound IP address and port number. + */ + address: NetAddress; + /** + * Timeout duration of the TCPSocket connection, in milliseconds. + */ + timeout?: number; + } + export interface TCPSendOptions { + /** + * Data to send. + */ + data: string | ArrayBuffer; + /** + * Character encoding format. + */ + encoding?: string; + } + export interface TCPExtraOptions extends ExtraOptionsBase { + /** + * Whether to keep the connection alive. The default value is false. + */ + keepAlive?: boolean; + /** + * Whether to enable OOBInline. The default value is false. + */ + OOBInline?: boolean; + /** + * Whether to enable no-delay on the TCPSocket connection. The default value is false. + */ + TCPNoDelay?: boolean; + /** + * Socket linger. + */ + socketLinger: { + on: boolean; + linger: number; + }; + } + export interface TCPSocket { + /** + * Binds the IP address and port number. The port number can be specified or randomly allocated by the system. + * + * @param address Destination address. {@link NetAddress} + * @permission ohos.permission.INTERNET + */ + bind(address: NetAddress, callback: AsyncCallback): void; + bind(address: NetAddress): Promise; + /** + * Sets up a connection to the specified IP address and port number. + * + * @param options Optional parameters {@link TCPConnectOptions}. + * @permission ohos.permission.INTERNET + */ + connect(options: TCPConnectOptions, callback: AsyncCallback): void; + connect(options: TCPConnectOptions): Promise; + /** + * Sends data over a TCPSocket connection. + * + * @param options Optional parameters {@link TCPSendOptions}. + * @permission ohos.permission.INTERNET + */ + send(options: TCPSendOptions, callback: AsyncCallback): void; + send(options: TCPSendOptions): Promise; + /** + * Closes a TCPSocket connection. + * @permission ohos.permission.INTERNET + */ + close(callback: AsyncCallback): void; + close(): Promise; + /** + * Obtains the peer address of a TCPSocket connection. + * + * @param callback Callback used to return the result. {@link NetAddress} + * @permission ohos.permission.INTERNET + */ + getRemoteAddress(callback: AsyncCallback): void; + getRemoteAddress(): Promise; + /** + * Obtains the status of the TCPSocket connection. + * + * @param callback Callback used to return the result. {@link SocketStateBase} + * @permission ohos.permission.INTERNET + */ + getState(callback: AsyncCallback): void; + getState(): Promise; + /** + * Sets other attributes of the TCPSocket connection. + * + * @param options Optional parameters {@link TCPExtraOptions}. + * @permission ohos.permission.INTERNET + */ + setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback): void; + setExtraOptions(options: TCPExtraOptions): Promise; + /** + * Listens for message receiving events of the TCPSocket connection. + */ + on(type: 'message', callback: Callback<{ + message: ArrayBuffer; + remoteInfo: SocketRemoteInfo; + }>): void; + /** + * Cancels listening for message receiving events of the TCPSocket connection. + */ + off(type: 'message', callback?: Callback<{ + message: ArrayBuffer; + remoteInfo: SocketRemoteInfo; + }>): void; + /** + * Listens for connection or close events of the TCPSocket connection. + */ + on(type: 'connect' | 'close', callback: Callback): void; + /** + * Cancels listening for connection or close events of the TCPSocket connection. + */ + off(type: 'connect' | 'close', callback?: Callback): void; + /** + * Listens for error events of the TCPSocket connection. + */ + on(type: 'error', callback: ErrorCallback): void; + /** + * Cancels listening for error events of the TCPSocket connection. + */ + off(type: 'error', callback?: ErrorCallback): void; + } +} +export default socket; diff --git a/build-tools/api/@ohos.net.webSocket.d.ts b/build-tools/api/@ohos.net.webSocket.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..48b1f92bab269028758bd9e2a4c1a911861f2a5c --- /dev/null +++ b/build-tools/api/@ohos.net.webSocket.d.ts @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, ErrorCallback } from "./basic"; +/** + * Provides WebSocket APIs. + * + * @since 6 + * @syscap SystemCapability.Communication.NetStack + */ +declare namespace webSocket { + /** + * Creates a web socket connection. + */ + function createWebSocket(): WebSocket; + export interface WebSocketRequestOptions { + /** + * HTTP request header. + */ + header?: Object; + } + export interface WebSocketCloseOptions { + /** + * Error code. + */ + code?: number; + /** + * Error cause. + */ + reason?: string; + } + export interface WebSocket { + /** + * Initiates a WebSocket request to establish a WebSocket connection to a given URL. + * + * @param url URL for establishing a WebSocket connection. + * @param options Optional parameters {@link WebSocketRequestOptions}. + * @param callback Returns callback used to return the execution result. + * @permission ohos.permission.INTERNET + */ + connect(url: string, callback: AsyncCallback): void; + connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback): void; + connect(url: string, options?: WebSocketRequestOptions): Promise; + /** + * Sends data through a WebSocket connection. + * + * @param data Data to send. It can be a string(API 6) or an ArrayBuffer(API 8). + * @param callback Returns callback used to return the execution result. + * @permission ohos.permission.INTERNET + */ + send(data: string | ArrayBuffer, callback: AsyncCallback): void; + send(data: string | ArrayBuffer): Promise; + /** + * Closes a WebSocket connection. + * + * @param options Optional parameters {@link WebSocketCloseOptions}. + * @param callback Returns callback used to return the execution result. + * @permission ohos.permission.INTERNET + */ + close(callback: AsyncCallback): void; + close(options: WebSocketCloseOptions, callback: AsyncCallback): void; + close(options?: WebSocketCloseOptions): Promise; + /** + * Enables listening for the open events of a WebSocket connection. + */ + on(type: 'open', callback: AsyncCallback): void; + /** + * Cancels listening for the open events of a WebSocket connection. + */ + off(type: 'open', callback?: AsyncCallback): void; + /** + * Enables listening for the message events of a WebSocket connection. + * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8). + */ + on(type: 'message', callback: AsyncCallback): void; + /** + * Cancels listening for the message events of a WebSocket connection. + * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8). + */ + off(type: 'message', callback?: AsyncCallback): void; + /** + * Enables listening for the close events of a WebSocket connection. + */ + on(type: 'close', callback: AsyncCallback<{ + code: number; + reason: string; + }>): void; + /** + * Cancels listening for the close events of a WebSocket connection. + */ + off(type: 'close', callback?: AsyncCallback<{ + code: number; + reason: string; + }>): void; + /** + * Enables listening for the error events of a WebSocket connection. + */ + on(type: 'error', callback: ErrorCallback): void; + /** + * Cancels listening for the error events of a WebSocket connection. + */ + off(type: 'error', callback?: ErrorCallback): void; + } +} +export default webSocket; diff --git a/build-tools/api/@ohos.nfc.cardEmulation.d.ts b/build-tools/api/@ohos.nfc.cardEmulation.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..41f556b9828370b614778f14dd28d73702ec9b5e --- /dev/null +++ b/build-tools/api/@ohos.nfc.cardEmulation.d.ts @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * Provides methods to operate or manage NFC card emulation. + * + * @import import cardEmulation from '@ohos.nfc.cardEmulation'; + * + * @since 6 + * @syscap SystemCapability.Communication.NFC.Core + */ +declare namespace cardEmulation { + enum FeatureType { + /** This constant is used to check whether HCE card emulation is supported. */ + HCE = 0, + /** This constant is used to check whether SIM card emulation is supported. */ + UICC = 1, + /** This constant is used to check whether eSE card emulation is supported. */ + ESE = 2 + } + /** + * Checks whether a specified type of card emulation is supported. + * + *

This method is used to check Whether the host or secure element supports card emulation. + * + * @param feature Indicates the card emulation type, {@code HCE}, {@code UICC}, or {@code ESE}. + * @return Returns {@code true} if the specified type of card emulation is supported; returns + * {@code false} otherwise. + * + * @since 6 + */ + function isSupported(feature: number): boolean; + /** + * A class for NFC host application. + * + *

The NFC host application use this class, then Nfc service can access the application + * installation information and connect to services of the application. + * + * @since 8 + * @syscap SystemCapability.Communication.NFC.Core + */ + export class HceService { + /** + * start HCE + * + * @return Returns {@code true} if HCE is enabled or has been enabled; returns {@code false} otherwise. + * @permission ohos.permission.NFC_CARD_EMULATION + * + * @since 8 + */ + startHCE(aidList: string[]): boolean; + /** + * stop HCE + * + * @return Returns {@code true} if HCE is disabled or has been disabled; returns {@code false} otherwise. + * @permission ohos.permission.NFC_CARD_EMULATION + * + * @since 8 + */ + stopHCE(): boolean; + /** + * register HCE event to receive the APDU data. + * + * @param type the type to register. + * @param callback Callback used to listen for HCE data device received. + * @permission ohos.permission.NFC_CARD_EMULATION + * + * @since 8 + */ + on(type: "hceCmd", callback: AsyncCallback): void; + /** + * Sends a response APDU to the remote device. + * + *

This method is used by a host application when swiping card. + * + * @param responseApdu Indicates the response, which is a byte array. + * @permission ohos.permission.NFC_CARD_EMULATION + * + * @since 8 + */ + sendResponse(responseApdu: number[]): void; + } +} +export default cardEmulation; diff --git a/build-tools/api/@ohos.nfc.controller.d.ts b/build-tools/api/@ohos.nfc.controller.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7aba1cdec6f27f001c7f6831262b9de172e3e35b --- /dev/null +++ b/build-tools/api/@ohos.nfc.controller.d.ts @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Callback } from './basic'; +/** + * Provides methods to operate or manage NFC. + * + * @import import controller from '@ohos.nfc.controller'; + * + * @since 7 + * @syscap SystemCapability.Communication.NFC.Core + */ +declare namespace nfcController { + enum NfcState { + /** Indicates that NFC is disabled. */ + STATE_OFF = 1, + /** Indicates that NFC is being enabled. */ + STATE_TURNING_ON = 2, + /** Indicates that NFC is enabled. */ + STATE_ON = 3, + /** Indicates that NFC is being disabled. */ + STATE_TURNING_OFF = 4 + } + /** + * Checks whether a device supports NFC. + * + * @return Returns {@code true} if the device supports NFC; returns {@code false} otherwise. + * + * @since 7 + */ + function isNfcAvailable(): boolean; + /** + * register nfc state changed event. + * + * @param type the type to register. + * @param callback Callback used to listen for the nfc state changed event. + * + * @since 7 + */ + function on(type: "nfcStateChange", callback: Callback): void; + /** + * unregister nfc state changed event. + * + * @param type the type to unregister. + * @param callback Callback used to listen for the nfc state changed event. + * + * @since 7 + */ + function off(type: "nfcStateChange", callback?: Callback): void; + /** + * Enables NFC. + * + * @return Returns {@code true} if NFC is enabled or has been enabled; returns {@code false} otherwise. + * @permission ohos.permission.MANAGE_SECURE_SETTINGS + * + * @since 7 + */ + function openNfc(): boolean; + /** + * Disables NFC. + * + * @return Returns {@code true} if NFC is disabled or has been disabled; returns {@code false} otherwise. + * @permission ohos.permission.MANAGE_SECURE_SETTINGS + * + * @since 7 + */ + function closeNfc(): boolean; + /** + * Checks whether NFC is enabled. + * + * @return Returns {@code true} if NFC is enabled; returns {@code false} otherwise. + * + * @since 7 + */ + function isNfcOpen(): boolean; + /** + * Obtains the NFC status. + * + *

The NFC status can be any of the following:

  • {@link #STATE_OFF}: Indicates that NFC + * is disabled.
  • {@link #STATE_TURNING_ON}: Indicates that NFC is being enabled. + *
  • {@link #STATE_ON}: Indicates that NFC is enabled.
  • {@link #STATE_TURNING_OFF}: Indicates + * that NFC is being disabled.
+ * + * @return Returns the NFC status. + * + * @since 7 + */ + function getNfcState(): NfcState; +} +export default nfcController; diff --git a/build-tools/api/@ohos.nfc.tag.d.ts b/build-tools/api/@ohos.nfc.tag.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..826662c479cc4db7d935c33f08388cb65716c988 --- /dev/null +++ b/build-tools/api/@ohos.nfc.tag.d.ts @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { NfcATag, NfcBTag, NfcFTag, NfcVTag } from './tag/nfctech'; +import { IsoDepTag, NdefTag, MifareClassicTag, MifareUltralightTag, NdefFormatableTag } from './tag/nfctech'; +/** + * Provides methods to operate or manage NFC tag. + * + * @import import tag from '@ohos.nfc.tag'; + * + * @since 7 + * @syscap SystemCapability.Communication.NFC.Core + */ +declare namespace tag { + /** Indicates a NFC-A tag. */ + const NFC_A = 1; + /** Indicates a NFC-B tag. */ + const NFC_B = 2; + /** Indicates a ISO-DEP tag. */ + const ISO_DEP = 3; + /** Indicates a NFC-F tag. */ + const NFC_F = 4; + /** Indicates a NFC-V tag. */ + const NFC_V = 5; + /** Indicates a NDEF tag. */ + const NDEF = 6; + /** Indicates a MifareClassic tag. */ + const MIFARE_CLASSIC = 8; + /** Indicates a MifareUltralight tag. */ + const MIFARE_ULTRALIGHT = 9; + /** + * Indicates a NdefFormatable tag. + * + * @since 9 + */ + const NDEF_FORMATABLE = 10; + /** + * Obtains an {@link NfcATag} object based on the tag information. + * + *

During tag reading, if the tag supports the NFC-A technology, an {@link NfcATag} object + * will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 7 + */ + function getNfcATag(tagInfo: TagInfo): NfcATag; + /** + * Obtains an {@link NfcBTag} object based on the tag information. + * + *

During tag reading, if the tag supports the NFC-B technology, an {@link NfcBTag} object + * will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 7 + */ + function getNfcBTag(tagInfo: TagInfo): NfcBTag; + /** + * Obtains an {@link NfcFTag} object based on the tag information. + * + *

During tag reading, if the tag supports the NFC-F technology, an {@link NfcFTag} object + * will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 7 + */ + function getNfcFTag(tagInfo: TagInfo): NfcFTag; + /** + * Obtains an {@link NfcVTag} object based on the tag information. + * + *

During tag reading, if the tag supports the NFC-V technology, an {@link NfcVTag} object + * will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 7 + */ + function getNfcVTag(tagInfo: TagInfo): NfcVTag; + /** + * Obtains an {@link IsoDepTag} object based on the tag information. + * + *

During tag reading, if the tag supports the IsoDep technology, an {@link IsoDepTag} object + * will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 9 + */ + function getIsoDepTag(tagInfo: TagInfo): IsoDepTag; + /** + * Obtains an {@link NdefTag} object based on the tag information. + * + *

During tag reading, if the tag supports the NDEF technology, an {@link NdefTag} object + * will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 9 + */ + function getNdefTag(tagInfo: TagInfo): NdefTag; + /** + * Obtains an {@link MifareClassicTag} object based on the tag information. + * + *

During tag reading, if the tag supports the MifareClassic technology, + * an {@link MifareClassicTag} object will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 9 + */ + function getMifareClassicTag(tagInfo: TagInfo): MifareClassicTag; + /** + * Obtains an {@link MifareUltralightTag} object based on the tag information. + * + *

During tag reading, if the tag supports the MifareUltralight technology, + * an {@link MifareUltralightTag} object will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 9 + */ + function getMifareUltralightTag(tagInfo: TagInfo): MifareUltralightTag; + /** + * Obtains an {@link NdefFormatableTag} object based on the tag information. + * + *

During tag reading, if the tag supports the NdefFormatable technology, + * an {@link NdefFormatableTag} object will be created based on the tag information. + * + * @param tagInfo Indicates the tag information. + * @permission ohos.permission.NFC_TAG + * + * @since 9 + */ + function getNdefFormatableTag(tagInfo: TagInfo): NdefFormatableTag; + /** + * Provides tag information. + * + *

This class provides the technology a tag supports, for example, NFC-A. Applications can create + * different tags based on the supported technology. + * + * @since 7 + * @syscap SystemCapability.Communication.NFC.Core + * @permission ohos.permission.NFC_TAG + */ + export interface TagInfo { + /** + * The uid of this tag, it. + * + * @since 9 + */ + uid: string; + /** + * The supported technology list of this tag. + * + * @since 9 + */ + technology: number[]; + /** + * The supported technology list of this tag. + * + * @since 7 + * @deprecated since 9 + */ + supportedProfiles: number[]; + } +} +export default tag; diff --git a/build-tools/api/@ohos.notification.d.ts b/build-tools/api/@ohos.notification.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..93db361cc3dbc44efcb4e48f25445bc66ec8e731 --- /dev/null +++ b/build-tools/api/@ohos.notification.d.ts @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import { NotificationSlot } from './notification/notificationSlot'; +import { NotificationRequest } from './notification/notificationRequest'; +/** + * Manages notifications. + * + *

Generally, only system applications have permissions on notification subscription and unsubscription. + * You can specify the content of a notification to be published and the content is carried by + * {@link NotificationRequest}. A notification ID is unique in an application and must be specified + * when using {@link NotificationRequest} to carry the notification content. If a notification + * with this ID has been published and you need to use this ID to publish another notification, + * the original notification will be updated. In addition, the notification ID can be used to cancel + * a notification by calling the {@link #cancel(int)} method. + * + * @name notification + * @since 7 + * @syscap SystemCapability.Notification.Notification + * @import import notification from '@ohos.notification'; + * @permission N/A + */ +declare namespace notification { + /** + * Publishes a notification. + * + *

If a notification with the same ID has been published by the current application and has not been deleted, + * this method will update the notification. + * + * @param request notification request + * @param callback callback function + */ + function publish(request: NotificationRequest, callback: AsyncCallback): void; + function publish(request: NotificationRequest): Promise; + /** + * Cancels a notification with the specified ID. + * + * @param id of the notification to cancel, which must be unique in the application. + * @param callback callback function + */ + function cancel(id: number, callback: AsyncCallback): void; + /** + * Cancels a notification with the specified label and ID. + * + * @param id ID of the notification to cancel, which must be unique in the application. + * @param label Label of the notification to cancel. + * @param callback callback function + */ + function cancel(id: number, label: string, callback: AsyncCallback): void; + function cancel(id: number, label?: string): Promise; + /** + * Cancels a representative notification. + * + * @since 9 + * @param id ID of the notification to cancel, which must be unique in the application. + * @param representativeBundle bundle name of the representative + * @param userId userid of the representative + * @param callback callback function + * @permission ohos.permission.NOTIFICATION_CONTROLLER + * @permission ohos.permission.NOTIFICATION_AGENT_CONTROLLER + */ + function cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback): void; + function cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise; + /** + * Cancels all notifications of the current application. + */ + function cancelAll(callback: AsyncCallback): void; + function cancelAll(): Promise; + /** + * Adds a slot type. + * + * @param type Slot type to add. + * @param callback callback function + */ + function addSlot(type: SlotType, callback: AsyncCallback): void; + function addSlot(type: SlotType): Promise; + /** + * Obtains a notification slot of the specified slot type. + * + * @param slotType Type of the notification slot to obtain. + * @param callback callback function + * @return Returns the created {@link NotificationSlot}. + */ + function getSlot(slotType: SlotType, callback: AsyncCallback): void; + function getSlot(slotType: SlotType): Promise; + /** + * Obtains all NotificationSlot objects created by the current application. + * + * @return Returns all notification slots of this application. + */ + function getSlots(callback: AsyncCallback>): void; + function getSlots(): Promise>; + /** + * Removes a NotificationSlot of the specified SlotType created by the current application. + * + * @param slotType Type of the NotificationSlot to remove. + * @param callback callback function + */ + function removeSlot(slotType: SlotType, callback: AsyncCallback): void; + function removeSlot(slotType: SlotType): Promise; + /** + * Removes all NotificationSlot objects created by the current application. + */ + function removeAllSlots(callback: AsyncCallback): void; + function removeAllSlots(): Promise; + /** + * Describes NotificationSlot types. + */ + export enum SlotType { + /** + * NotificationSlot of an unknown type. + */ + UNKNOWN_TYPE = 0, + /** + * NotificationSlot for social communication. + */ + SOCIAL_COMMUNICATION = 1, + /** + * NotificationSlot for service information. + */ + SERVICE_INFORMATION = 2, + /** + * NotificationSlot for service information. + */ + CONTENT_INFORMATION = 3, + /** + * NotificationSlot for other purposes. + */ + OTHER_TYPES = 0xFFFF + } + /** + * Describes notification content types. + * + * @name ContentType + * @since 7 + * @syscap SystemCapability.Notification.Notification + * @permission N/A + */ + export enum ContentType { + /** + * Normal text notification. + */ + NOTIFICATION_CONTENT_BASIC_TEXT, + /** + * Long text notification. + */ + NOTIFICATION_CONTENT_LONG_TEXT, + /** + * Picture-attached notification. + */ + NOTIFICATION_CONTENT_PICTURE, + /** + * Conversation notification. + */ + NOTIFICATION_CONTENT_CONVERSATION, + /** + * Multi-line text notification. + */ + NOTIFICATION_CONTENT_MULTILINE + } + /** + * Indicates the level of the slot + */ + export enum SlotLevel { + /** + * Indicates that the notification function is disabled. + */ + LEVEL_NONE = 0, + /** + * Indicates that the notification function is enabled but notification + * icons are not displayed in the status bar, with no banner or prompt tone. + */ + LEVEL_MIN = 1, + /** + * Indicates that the notification function is enabled and notification + * icons are displayed in the status bar, with no banner or prompt tone. + */ + LEVEL_LOW = 2, + /** + * Indicates that the notification function is enabled and notification + * icons are displayed in the status bar, with no banner but with a prompt tone. + */ + LEVEL_DEFAULT = 3, + /** + * Indicates that the notification function is enabled and notification + * icons are displayed in the status bar, with a banner and a prompt tone. + */ + LEVEL_HIGH = 4 + } + /** + * Obtains the number of all active notifications. + */ + function getActiveNotificationCount(callback: AsyncCallback): void; + function getActiveNotificationCount(): Promise; + /** + * Obtains an array of active notifications. + */ + function getActiveNotifications(callback: AsyncCallback>): void; + function getActiveNotifications(): Promise>; + /** + * Cancel the notification of a specified group for this application. + * + * @since 8 + */ + function cancelGroup(groupName: string, callback: AsyncCallback): void; + function cancelGroup(groupName: string): Promise; + /** + * Obtains whether the template is supported by the system. + * + * @since 8 + * @param templateName Name of template to be Obtained + * @param callback callback function + */ + function isSupportTemplate(templateName: string, callback: AsyncCallback): void; + function isSupportTemplate(templateName: string): Promise; + /** + * Request permission to send notification. + * + * @since 8 + */ + function requestEnableNotification(callback: AsyncCallback): void; + function requestEnableNotification(): Promise; + /** + * Obtains whether the device supports distributed notification. + * + * @since 8 + */ + function isDistributedEnabled(callback: AsyncCallback): void; + function isDistributedEnabled(): Promise; + /** + * Describes a BundleOption. + */ + export interface BundleOption { + bundle: string; + uid?: number; + } + /** + * Describes a NotificationKey, which can be used to identify a notification. + */ + export interface NotificationKey { + id: number; + label?: string; + } +} +export default notification; diff --git a/build-tools/api/@ohos.pasteboard.d.ts b/build-tools/api/@ohos.pasteboard.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..62acf0fe6c253a372d23853353f9b8eacef9817f --- /dev/null +++ b/build-tools/api/@ohos.pasteboard.d.ts @@ -0,0 +1,328 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * systemPasteboard + * @syscap SystemCapability.MiscServices.Pasteboard + * @import import pasteboard from '@ohos.pasteboard'; + */ +declare namespace pasteboard { + /** + * Indicates the maximum number of records allowed in a PasteData object. + * @since 7 + */ + const MAX_RECORD_NUM: number; + /** + * Indicates MIME types of HTML text. + * @since 7 + */ + const MIMETYPE_TEXT_HTML: string; + /** + * Indicates MIME types of wants. + * @since 7 + */ + const MIMETYPE_TEXT_WANT: string; + /** + * Indicates MIME types of plain text. + * @since 7 + */ + const MIMETYPE_TEXT_PLAIN: string; + /** + * Indicates MIME types of URIs. + * @since 7 + */ + const MIMETYPE_TEXT_URI: string; + /** + * Creates a PasteData object for PasteData#MIMETYPE_TEXT_HTML. + * @param htmlText To save the Html text content. + * @return Containing the contents of the clipboard content object. + * @since 7 + */ + function createHtmlData(htmlText: string): PasteData; + /** + * Creates a PasteData object for PasteData#MIMETYPE_TEXT_WANT. + * @param want To save the want of content. + * @return Containing the contents of the clipboard content object. + * @since 7 + */ + function createWantData(want: Want): PasteData; + /** + * Creates a PasteData object for PasteData#MIMETYPE_TEXT_PLAIN. + * @param text To save the text of content. + * @return Containing the contents of the clipboard content object. + * @since 6 + */ + function createPlainTextData(text: string): PasteData; + /** + * Creates a PasteData object for PasteData#MIMETYPE_TEXT_URI. + * @param uri To save the uri of content. + * @return Containing the contents of the clipboard content object. + * @since 7 + */ + function createUriData(uri: string): PasteData; + /** + * Creates a Record object for PasteData#MIMETYPE_TEXT_HTML. + * @param htmlText To save the Html text content. + * @return The content of a new record + * @since 7 + */ + function createHtmlTextRecord(htmlText: string): PasteDataRecord; + /** + * Creates a Record object for PasteData#MIMETYPE_TEXT_WANT. + * @param want To save the want of content. + * @return The content of a new record + * @since 7 + */ + function createWantRecord(want: Want): PasteDataRecord; + /** + * Creates a Record object for PasteData#MIMETYPE_TEXT_PLAIN. + * @param text To save the text of content. + * @return The content of a new record + * @since 7 + */ + function createPlainTextRecord(text: string): PasteDataRecord; + /** + * Creates a Record object for PasteData#MIMETYPE_TEXT_URI. + * @param uri To save the uri of content. + * @return The content of a new record + * @since 7 + */ + function createUriRecord(uri: string): PasteDataRecord; + /** + * get SystemPasteboard + * @return The system clipboard object + * @since 6 + */ + function getSystemPasteboard(): SystemPasteboard; + interface PasteDataProperty { + /** + * additional property data. key-value pairs. + * @since 7 + */ + additions: { + [key: string]: object; + }; + /** + * non-repeating MIME types of all records in PasteData. + * @since 7 + */ + readonly mimeTypes: Array; + /** + * the user-defined tag of a PasteData object. + * @since 7 + */ + tag: string; + /** + * a timestamp, which indicates when data is written to the system pasteboard. + * @since 7 + */ + readonly timestamp: number; + /** + * Checks whether PasteData is set for local access only. + * @since 7 + */ + localOnly: boolean; + } + interface PasteDataRecord { + /** + * HTML text in a record. + * @since 7 + */ + htmlText: string; + /** + * an want in a record. + * @since 7 + */ + want: Want; + /** + * MIME types of a record. + * @since 7 + */ + mimeType: string; + /** + * plain text in a record. + * @since 7 + */ + plainText: string; + /** + * an URI in a record. + * @since 7 + */ + uri: string; + /** + * Will a PasteData cast to the content of text content + * @return callback Type string callback function + * @since 7 + */ + convertToText(callback: AsyncCallback): void; + convertToText(): Promise; + } + interface PasteData { + /** + * Adds a Record for HTML text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_HTML in DataProperty. + * @param htmlText To save the Html text content. + * @since 7 + */ + addHtmlRecord(htmlText: string): void; + /** + * Adds an want Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_WANT in DataProperty. + * @param want To save the want content. + * @since 7 + */ + addWantRecord(want: Want): void; + /** + * Adds a PasteRecord to a PasteData object and updates MIME types in DataProperty. + * @param record The content of a new record. + * @since 7 + */ + addRecord(record: PasteDataRecord): void; + /** + * Adds a Record for plain text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_PLAIN in DataProperty. + * @param text To save the text of content. + * @since 7 + */ + addTextRecord(text: string): void; + /** + * Adds a URI Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_URI in DataProperty. + * @param uri To save the uri of content. + * @since 7 + */ + addUriRecord(uri: string): void; + /** + * MIME types of all content on the pasteboard. + * @return string type of array + * @since 7 + */ + getMimeTypes(): Array; + /** + * HTML text of the primary record in a PasteData object. + * @return string type of htmltext + * @since 7 + */ + getPrimaryHtml(): string; + /** + * the want of the primary record in a PasteData object. + * @return want type of want + * @since 7 + */ + getPrimaryWant(): Want; + /** + * the MIME type of the primary record in a PasteData object. + * @return string type of mimetype + * @since 7 + */ + getPrimaryMimeType(): string; + /** + * the plain text of the primary record in a PasteData object. + * @return string type of text + * @since 6 + */ + getPrimaryText(): string; + /** + * the URI of the primary record in a PasteData object. + * @return string type of uri + * @since 7 + */ + getPrimaryUri(): string; + /** + * DataProperty of a PasteData object. + * @return PasteDataProperty type of PasteDataProperty + * @since 7 + */ + getProperty(): PasteDataProperty; + /** + * a Record based on a specified index. + * @param index The index to specify the content item + * @return PasteDataRecord type of PasteDataRecord + * @since 7 + */ + getRecordAt(index: number): PasteDataRecord; + /** + * the number of records in a PasteData object. + * @return The number of the clipboard contents + * @since 7 + */ + getRecordCount(): number; + /** + * the user-defined tag of a PasteData object. + * @return string type of tag + * @since 7 + */ + getTag(): string; + /** + * Checks whether there is a specified MIME type of data in DataProperty. + * @param mimeType To query data types. + * @return The query returns True on success, or False on failure. + * @since 7 + */ + hasMimeType(mimeType: string): boolean; + /** + * Removes a Record based on a specified index. + * @param index The index to specify the content item. + * @return The query returns True on success, or False on failure. + * @since 7 + */ + removeRecordAt(index: number): boolean; + /** + * Replaces a specified record with a new one. + * @param index The index to specify the content item. record record The content of a new record. + * @return The query returns True on success, or False on failure. + * @since 7 + */ + replaceRecordAt(index: number, record: PasteDataRecord): boolean; + } + interface SystemPasteboard { + /** + * Callback invoked when pasteboard content changes. + * @param type 'update' + * @since 7 + */ + on(type: 'update', callback: () => void): void; + /** + * Callback invoked when pasteboard content changes. + * @param type 'update' + * @since 7 + */ + off(type: 'update', callback?: () => void): void; + /** + * Clears the pasteboard. + * @since 7 + */ + clear(callback: AsyncCallback): void; + clear(): Promise; + /** + * data in a PasteData object. + * @return PasteData callback data in a PasteData object. + * @since 6 + */ + getPasteData(callback: AsyncCallback): void; + getPasteData(): Promise; + /** + * Checks whether there is content in the pasteboard. + * @return boolean The callback success to true to false failure + * @since 7 + */ + hasPasteData(callback: AsyncCallback): void; + hasPasteData(): Promise; + /** + * Writes PasteData to the pasteboard. + * @param data Containing the contents of the clipboard content object. + * @since 6 + */ + setPasteData(data: PasteData, callback: AsyncCallback): void; + setPasteData(data: PasteData): Promise; + } +} +export default pasteboard; diff --git a/build-tools/api/@ohos.pluginComponent.d.ts b/build-tools/api/@ohos.pluginComponent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ee53cea8b4e9518a5bd441674ebeb0080b3758f --- /dev/null +++ b/build-tools/api/@ohos.pluginComponent.d.ts @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * Plugin component template property. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 8 + */ +interface PluginComponentTemplate { + source: string; + ability: string; +} +/** + * Plugin component manager interface. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 8 + */ +declare namespace pluginComponentManager { + type KVObject = { + [key: string]: number | string | boolean | [ + ] | KVObject; + }; + /** + * Plugin component push parameters. + * @since 8 + */ + interface PushParameters { + want: Want; + name: string; + data: KVObject; + extraData: KVObject; + jsonPath?: string; + } + /** + * Plugin component request parameters. + * @since 8 + */ + interface RequestParameters { + want: Want; + name: string; + data: KVObject; + jsonPath?: string; + } + /** + * Plugin component request callback parameters. + * @since 8 + */ + interface RequestCallbackParameters { + componentTemplate: PluginComponentTemplate; + data: KVObject; + extraData: KVObject; + } + /** + * Plugin component request event result value. + * @since 8 + */ + interface RequestEventResult { + template?: string; + data?: KVObject; + extraData?: KVObject; + } + /** + * Plugin component push event callback. + * @since 8 + */ + type OnPushEventCallback = (source: Want, template: PluginComponentTemplate, data: KVObject, extraData: KVObject) => void; + /** + * Plugin component request event callback. + * @since 8 + */ + type OnRequestEventCallback = (source: Want, name: string, data: KVObject) => RequestEventResult; + /** + * Plugin component push method. + * @since 8 + */ + function push(param: PushParameters, callback: AsyncCallback): void; + /** + * Plugin component request method. + * @since 8 + */ + function request(param: RequestParameters, callback: AsyncCallback): void; + /** + * Plugin component event listener. + * @since 8 + */ + function on(eventType: string, callback: OnPushEventCallback | OnRequestEventCallback): void; +} +export default pluginComponentManager; diff --git a/build-tools/api/@ohos.power.d.ts b/build-tools/api/@ohos.power.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..163db749ae049092cd80d12fc3146366b21d9bc9 --- /dev/null +++ b/build-tools/api/@ohos.power.d.ts @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * Provides interfaces to manage power. + * + * @syscap SystemCapability.PowerManager.PowerManager.Core + * @since 7 + */ +declare namespace power { + /** + * Restarts the system. + * + *

This method requires the ohos.permission.REBOOT permission. + * + * @param reason Indicates the restart reason. For example, "updater" means to enter the updater mode + * after the restart. If the parameter is not specified, the system enters the normal mode after the restart. + * @permission ohos.permission.REBOOT + * @since 7 + */ + function rebootDevice(reason: string): void; + /** + * Checks whether the screen of a device is on or off. + * + * @return Returns true if the screen is on; returns false otherwise. + * @since 7 + */ + function isScreenOn(callback: AsyncCallback): void; + function isScreenOn(): Promise; + /** + * Obtains the power mode of the current device. For details, see {@link DevicePowerMode}. + * + * @return Returns the power mode of current device . + * @permission ohos.permission.POWER_OPTIMIZATION + * @since 9 + */ + function getPowerMode(callback: AsyncCallback): void; + function getPowerMode(): Promise; + /** + * Power mode of a device. + * @syscap SystemCapability.PowerManager.PowerManager.Core + * @since 9 + */ + export enum DevicePowerMode { + /** + * Normal power mode + * @since 9 + */ + MODE_NORMAL = 600, + /** + * Power save mode + * @since 9 + */ + MODE_POWER_SAVE, + /** + * Performance power mode + * @since 9 + */ + MODE_PERFORMANCE, + /** + * Extreme power save mode + * @since 9 + */ + MODE_EXTREME_POWER_SAVE + } +} +export default power; diff --git a/build-tools/api/@ohos.process.d.ts b/build-tools/api/@ohos.process.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..91e141615092455b00328de108edbd0d1a47b0c2 --- /dev/null +++ b/build-tools/api/@ohos.process.d.ts @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** +* The process is mainly used to obtain the relevant ID of the process, obtain and modify +* the working directory of the process, exit and close the process. +* @since 7 +* @syscap SystemCapability.Utils.Lang +* @import import url from '@ohos.process'; +*/ +declare namespace process { + /** + * returns the digital user id of the process + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @return return the digital user id of the process. + */ + const uid: number; + /** + * return pid is The pid of the current process + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @return return The pid of the current process. + */ + const pid: number; + /** + * Returns the tid of the current thread. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return return the tid of the current thread. + */ + const tid: number; + /** + * Returns a boolean whether the process is isolated. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return return boolean whether the process is isolated. + */ + function isIsolatedProcess(): boolean; + /** + * Returns a boolean whether the specified uid belongs to a particular application. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param v An id. + * @return return a boolean whether the specified uid belongs to a particular application. + */ + function isAppUid(v: number): boolean; + /** + * Returns a boolean whether the process is running in a 64-bit environment. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return return a boolean whether the process is running in a 64-bit environment. + */ + function is64Bit(): boolean; + /** + * Returns the uid based on the specified user name. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param v Process name. + * @return return the uid based on the specified user name. + */ + function getUidForName(v: string): number; + /** + * Returns the thread priority based on the specified tid. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param v The tid of the process. + * @return Return the thread priority based on the specified tid. + */ + function getThreadPriority(v: number): number; + /** + * Returns the elapsed real time (in milliseconds) taken from the start of the system to the start of the process. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Return the start of the system to the start of the process. + */ + function getStartRealtime(): number; + /** + * Returns the cpu time (in milliseconds) from the time when the process starts to the current time. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Return the cpu time (in milliseconds) from the time when the process starts to the current time. + */ + function getPastCpuTime(): number; + /** + * Returns the system configuration at runtime. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param name Parameters defined by the system configuration. + * @return Return the system configuration at runtime. + */ + function getSystemConfig(name: number): number; + /** + * Returns the system value for environment variables. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param name Parameters defined by the system environment variables. + * @Returns the system value for environment variables. + */ + function getEnvironmentVar(name: string): string; + type EventListener = (evt: Object) => void; + /** + * Abort current process + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + function abort(): void; + /** + * Process exit + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param code Process exit code. + */ + function exit(code: number): void; + /** + * Returns the running time of the system + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @return Return the running time of the system. + */ + function uptime(): number; + /** + * Return whether the signal was sent successfully + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param signal Signal sent. + * @param pid Send signal to target pid. + * @return Return the result of the signal. + */ + function kill(signal: number, pid: number): boolean; +} +export default process; diff --git a/build-tools/api/@ohos.prompt.d.ts b/build-tools/api/@ohos.prompt.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..830a9a34133c4376d69a082f97e1d243a78d6667 --- /dev/null +++ b/build-tools/api/@ohos.prompt.d.ts @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 8 + * @import prompt from '@ohos.prompt'; + */ +declare namespace prompt { + /** + * @since 8 + */ + interface ShowToastOptions { + /** + * Text to display. + * @type { string } + * @since 8 + */ + /** + * Text to display. + * @type { string | Resource } + * @since 9 + */ + message: string | Resource; + /** + * Duration of toast dialog box. The default value is 1500. + * The recommended value ranges from 1500 ms to 10000ms. + * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000 ms. + * @since 8 + */ + duration?: number; + /** + * The distance between toast dialog box and the bottom of screen. + * @since 8 + */ + bottom?: string | number; + } + /** + * @since 8 + */ + interface Button { + /** + * @type { string } + * @since 8 + */ + /** + * @type { string | Resource } + * @since 9 + */ + text: string | Resource; + /** + * @type { string } + * @since 8 + */ + /** + * @type { string | Resource } + * @since 9 + */ + color: string | Resource; + } + /** + * @since 8 + */ + interface ShowDialogSuccessResponse { + /** + * @since 8 + */ + index: number; + } + /** + * @since 8 + */ + interface ShowDialogOptions { + /** + * Title of the text to display. + * @type { string } + * @since 8 + */ + /** + * Title of the text to display. + * @type { string | Resource } + * @since 9 + */ + title?: string | Resource; + /** + * Text body. + * @type { string } + * @since 8 + */ + /** + * Text body. + * @type { string | Resource } + * @since 9 + */ + message?: string | Resource; + /** + * Array of buttons in the dialog box. + * The array structure is {text:'button', color: '#666666'}. + * One to three buttons are supported. The first button is of the positiveButton type, the second is of the negativeButton type, and the third is of the neutralButton type. + * @since 8 + */ + buttons?: [ + Button, + Button?, + Button? + ]; + } + /** + * @since 8 + */ + interface ActionMenuSuccessResponse { + /** + * @since 8 + */ + index: number; + } + /** + * @since 8 + */ + interface ActionMenuOptions { + /** + * Title of the text to display. + * @type { string } + * @since 8 + */ + /** + * Title of the text to display. + * @type { string | Resource } + * @since 9 + */ + title?: string | Resource; + /** + * Array of buttons in the dialog box. + * The array structure is {text:'button', color: '#666666'}. + * One to six buttons are supported. + * @since 8 + */ + buttons: [ + Button, + Button?, + Button?, + Button?, + Button?, + Button? + ]; + } + /** + * Displays the notification text. + * @param options Options. + * @since 8 + */ + function showToast(options: ShowToastOptions): void; + /** + * Displays the dialog box. + * @param options Options. + * @since 8 + */ + function showDialog(options: ShowDialogOptions, callback: AsyncCallback): void; + function showDialog(options: ShowDialogOptions): Promise; + /** + * Displays the menu. + * @param options Options. + * @since 8 + */ + function showActionMenu(options: ActionMenuOptions, callback: AsyncCallback): void; + function showActionMenu(options: ActionMenuOptions): Promise; +} +export default prompt; diff --git a/build-tools/api/@ohos.reminderAgent.d.ts b/build-tools/api/@ohos.reminderAgent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e1965ecf5f4a7dd69e68513cce5842a98c869d0d --- /dev/null +++ b/build-tools/api/@ohos.reminderAgent.d.ts @@ -0,0 +1,379 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import notification from './@ohos.notification'; +import { NotificationSlot } from './notification/notificationSlot'; +/** + * Providers static methods for managing reminders, including publishing or canceling a reminder. + * adding or removing a notification slot, and obtaining or cancelling all reminders of the current application. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + * @import reminderAgent from '@ohos.reminderAgent'; + */ +declare namespace reminderAgent { + /** + * Publishes a scheduled reminder. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + * @permission ohos.permission.PUBLISH_AGENT_REMINDER + * @param reminderReq Indicates the reminder instance to publish. + * @param callback Indicates the callback function. + * @returns reminder id. + */ + function publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback): void; + function publishReminder(reminderReq: ReminderRequest): Promise; + /** + * Cancels a reminder. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + * @param reminderId Indicates the reminder id. + * @param callback Indicates the callback function. + */ + function cancelReminder(reminderId: number, callback: AsyncCallback): void; + function cancelReminder(reminderId: number): Promise; + /** + * Obtains all the valid reminders of current application. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + * @param callback Indicates the callback function. + */ + function getValidReminders(callback: AsyncCallback>): void; + function getValidReminders(): Promise>; + /** + * Cancels all the reminders of current application. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + * @param callback Indicates the callback function. + */ + function cancelAllReminders(callback: AsyncCallback): void; + function cancelAllReminders(): Promise; + /** + * Add notification slot. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + * @param slot Indicates the slot. + * @param callback Indicates the callback function. + */ + function addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback): void; + function addNotificationSlot(slot: NotificationSlot): Promise; + /** + * Deletes a created notification slot based on the slot type. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + * @param slotType Indicates the type of the slot. + * @param callback Indicates the callback function. + */ + function removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback): void; + function removeNotificationSlot(slotType: notification.SlotType): Promise; + /** + * Declares action button type. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + export enum ActionButtonType { + /** + * Button for closing the reminder. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + ACTION_BUTTON_TYPE_CLOSE = 0, + /** + * Button for snoozing the reminder. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + ACTION_BUTTON_TYPE_SNOOZE = 1 + } + /** + * Declares reminder type. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + export enum ReminderType { + /** + * Countdown reminder. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + REMINDER_TYPE_TIMER = 0, + /** + * Calendar reminder. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + REMINDER_TYPE_CALENDAR = 1, + /** + * Alarm reminder. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + REMINDER_TYPE_ALARM = 2 + } + /** + * Action button information. The button will show on displayed reminder. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + interface ActionButton { + /** + * Text on the button. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + title: string; + /** + * Button type. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + type: ActionButtonType; + } + /** + * Want agent information. + * It will switch to target ability when you click the displayed reminder. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + interface WantAgent { + /** + * Name of the package redirected to when the reminder notification is clicked. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + pkgName: string; + /** + * Name of the ability that is redirected to when the reminder notification is clicked. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + abilityName: string; + } + /** + * Max screen want agent information. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + interface MaxScreenWantAgent { + /** + * Name of the package that is automatically started when the reminder arrives and the device is not in use. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + pkgName: string; + /** + * Name of the ability that is automatically started when the reminder arrives and the device is not in use. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + abilityName: string; + } + /** + * Reminder Common information. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + interface ReminderRequest { + /** + * Type of the reminder. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + reminderType: ReminderType; + /** + * Action button displayed on the reminder notification. + * (The parameter is optional. Up to two buttons are supported). + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + actionButton?: [ + ActionButton?, + ActionButton? + ]; + /** + * Information about the ability that is redirected to when the notification is clicked. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + wantAgent?: WantAgent; + /** + * Information about the ability that is automatically started when the reminder arrives. + * If the device is in use, a notification will be displayed. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + maxScreenWantAgent?: MaxScreenWantAgent; + /** + * Ringing duration. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + ringDuration?: number; + /** + * Number of reminder snooze times. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + snoozeTimes?: number; + /** + * Reminder snooze interval. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + timeInterval?: number; + /** + * Reminder title. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + title?: string; + /** + * Reminder content. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + content?: string; + /** + * Content to be displayed when the reminder is expired. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + expiredContent?: string; + /** + * Content to be displayed when the reminder is snoozing. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + snoozeContent?: string; + /** + * notification id. If there are reminders with the same ID, the later one will overwrite the earlier one. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + notificationId?: number; + /** + * Type of the slot used by the reminder. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + slotType?: notification.SlotType; + } + interface ReminderRequestCalendar extends ReminderRequest { + /** + * Reminder time. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + dateTime: LocalDateTime; + /** + * Month in which the reminder repeats. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + repeatMonths?: Array; + /** + * Date on which the reminder repeats. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + repeatDays?: Array; + } + /** + * Alarm reminder information. + * + * @since 7 + * @syscap Define alarm reminder object. + */ + interface ReminderRequestAlarm extends ReminderRequest { + /** + * Hour portion of the reminder time. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + hour: number; + /** + * minute portion of the remidner time. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + minute: number; + /** + * Days of a week when the reminder repeates. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + daysOfWeek?: Array; + } + /** + * CountDown reminder information. + * + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + interface ReminderRequestTimer extends ReminderRequest { + triggerTimeInSeconds: number; + } + interface LocalDateTime { + /** + * value of year. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + year: number; + /** + * value of month. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + month: number; + /** + * value of day. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + day: number; + /** + * value of hour. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + hour: number; + /** + * value of minute. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + minute: number; + /** + * value of second. + * @since 7 + * @syscap SystemCapability.Notification.ReminderAgent + */ + second?: number; + } +} +export default reminderAgent; diff --git a/build-tools/api/@ohos.request.d.ts b/build-tools/api/@ohos.request.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fdb9ac0fefb1d4ae03b4f1fd4e78df7b365f4ea4 --- /dev/null +++ b/build-tools/api/@ohos.request.d.ts @@ -0,0 +1,733 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import BaseContext from './application/BaseContext'; +/** + * upload and download + * + * @import request from '@ohos.request'; + * @permission ohos.permission.INTERNET + */ +declare namespace request { + /** + * Bit flag indicating download is allowed when using the cellular network. + * @syscap SystemCapability.MiscServices.Download + * @since 6 + * @permission ohos.permission.INTERNET + */ + const NETWORK_MOBILE: number; + /** + * Bit flag indicating download is allowed when using the WLAN. + * @syscap SystemCapability.MiscServices.Download + * @since 6 + * @permission ohos.permission.INTERNET + */ + const NETWORK_WIFI: number; + /** + * Indicates that the download cannot be resumed for some temporary errors. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const ERROR_CANNOT_RESUME: number; + /** + * Indicates that no storage device, such as an SD card, is found. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const ERROR_DEVICE_NOT_FOUND: number; + /** + * Indicates that files to be downloaded already exist, and that the download session cannot overwrite the existing files. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const ERROR_FILE_ALREADY_EXISTS: number; + /** + * Indicates that a file operation fails. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const ERROR_FILE_ERROR: number; + /** + * Indicates that the HTTP transmission fails. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const ERROR_HTTP_DATA_ERROR: number; + /** + * Indicates insufficient storage space. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const ERROR_INSUFFICIENT_SPACE: number; + /** + * Indicates an error caused by too many network redirections. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const ERROR_TOO_MANY_REDIRECTS: number; + /** + * Indicates an HTTP code that cannot be identified. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const ERROR_UNHANDLED_HTTP_CODE: number; + /** + * Indicates an undefined error. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const ERROR_UNKNOWN: number; + /** + * Indicates that the download is paused and waiting for a WLAN connection, because the file size exceeds the maximum allowed for a session using the cellular network. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const PAUSED_QUEUED_FOR_WIFI: number; + /** + * Indicates that the download is paused for some reasons. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const PAUSED_UNKNOWN: number; + /** + * Indicates that the download is paused due to a network problem, for example, network disconnection. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const PAUSED_WAITING_FOR_NETWORK: number; + /** + * Indicates that a network error occurs, and the download session will be retried. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const PAUSED_WAITING_TO_RETRY: number; + /** + * Indicates that the download session has failed and will not be retried. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const SESSION_FAILED: number; + /** + * Indicates that the download session has been paused. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const SESSION_PAUSED: number; + /** + * Indicates that the download session is being scheduled. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const SESSION_PENDING: number; + /** + * Indicates that the download session is in progress. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const SESSION_RUNNING: number; + /** + * Indicates that the download session is completed. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + const SESSION_SUCCESSFUL: number; + /** + * Starts a download session. + * @syscap SystemCapability.MiscServices.Download + * @since 6 + * @param config download config + * @param callback Indicate the callback function to receive DownloadTask. + * @permission ohos.permission.INTERNET + * @return - + * @FAModelOnly + */ + function download(config: DownloadConfig, callback: AsyncCallback): void; + /** + * Starts a download session. + * @syscap SystemCapability.MiscServices.Download + * @since 9 + * @param BaseContext Indicates the application BaseContext. + * @param config download config + * @param callback Indicate the callback function to receive DownloadTask. + * @permission ohos.permission.INTERNET + * @return - + */ + function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void; + /** + * Starts a download session. + * @syscap SystemCapability.MiscServices.Download + * @since 6 + * @param config download config + * @permission ohos.permission.INTERNET + * @return - + * @FAModelOnly + */ + function download(config: DownloadConfig): Promise; + /** + * Starts a download session. + * @syscap SystemCapability.MiscServices.Download + * @since 9 + * @param BaseContext Indicates the application BaseContext. + * @param config download config + * @permission ohos.permission.INTERNET + * @return - + */ + function download(context: BaseContext, config: DownloadConfig): Promise; + /** + * Starts a upload session. + * @syscap SystemCapability.MiscServices.Upload + * @since 6 + * @param config upload config + * @param callback Indicate the callback function to receive UploadTask. + * @permission ohos.permission.INTERNET + * @return - + * @FAModelOnly + */ + function upload(config: UploadConfig, callback: AsyncCallback): void; + /** + * Starts a upload session. + * @syscap SystemCapability.MiscServices.Upload + * @since 9 + * @param BaseContext Indicates the application BaseContext. + * @param config upload config + * @param callback Indicate the callback function to receive UploadTask. + * @permission ohos.permission.INTERNET + * @return - + */ + function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void; + /** + * Starts a upload session. + * @syscap SystemCapability.MiscServices.Upload + * @since 6 + * @param config upload config + * @permission ohos.permission.INTERNET + * @return - + * @FAModelOnly + */ + function upload(config: UploadConfig): Promise; + /** + * Starts a upload session. + * @syscap SystemCapability.MiscServices.Upload + * @since 9 + * @param BaseContext Indicates the application BaseContext. + * @param config upload config + * @permission ohos.permission.INTERNET + * @return - + */ + function upload(context: BaseContext, config: UploadConfig): Promise; + /** + * DownloadConfig data Structure + * + * @name DownloadConfig + * @since 6 + * @syscap SystemCapability.MiscServices.Download + * @permission ohos.permission.INTERNET + */ + interface DownloadConfig { + /** + * Resource address. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + url: string; + /** + * Adds an HTTP or HTTPS header to be included with the download request. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + header?: Object; + /** + * Allows download under a metered connection. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + enableMetered?: boolean; + /** + * Allows download in a roaming network. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + enableRoaming?: boolean; + /** + * Sets the description of a download session. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + description?: string; + /** + * Sets the network type allowed for download. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + networkType?: number; + /** + * Sets the path for downloads. + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + filePath?: string; + /** + * Sets a download session title. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + title?: string; + } + /** + * DownloadInfo data Structure + * + * @name DownloadInfo + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + */ + interface DownloadInfo { + /** + * the description of a file to be downloaded. + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + description: string; + /** + * the real-time downloads size (in bytes). + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + downloadedBytes: number; + /** + * the ID of a file to be downloaded. + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + downloadId: number; + /** + * a download failure cause, which can be any DownloadSession.ERROR_* constant. + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + failedReason: number; + /** + * the name of a file to be downloaded. + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + fileName: string; + /** + * the URI of a stored file. + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + filePath: string; + /** + * the reason why a session is paused, which can be any DownloadSession.PAUSED_* constant. + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + pausedReason: number; + /** + * the download status code, which can be any DownloadSession.SESSION_* constant. + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + status: number; + /** + * the URI of files to be downloaded. + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + targetURI: string; + /** + * the title of a file to be downloaded. + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + downloadTitle: string; + /** + * the total size of files to be downloaded (in bytes). + * + * @since 7 + * @permission ohos.permission.INTERNET + */ + downloadTotalBytes: number; + } + interface DownloadTask { + /** + * Called when the current download session is in process. + * @syscap SystemCapability.MiscServices.Download + * @since 6 + * @param type progress Indicates the download task progress. + * @param callback The callback function for the download progress change event + * receivedSize the length of downloaded data, in bytes + * totalSize he length of data expected to be downloaded, in bytes. + * @permission ohos.permission.INTERNET + * @return - + */ + on(type: 'progress', callback: (receivedSize: number, totalSize: number) => void): void; + /** + * Called when the current download session is in process. + * @syscap SystemCapability.MiscServices.Download + * @since 6 + * @param type progress Indicates the download task progress. + * @param callback The callback function for the download progress change event + * receivedSize the length of downloaded data, in bytes + * totalSize he length of data expected to be downloaded, in bytes. + * @permission ohos.permission.INTERNET + * @return - + */ + off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => void): void; + /** + * Called when the current download session complete、pause or remove. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @param type Indicates the download session event type + * complete: download task completed, + * pause: download task stopped, + * remove: download task deleted. + * @param callback The callback function for the download complete、pause or remove change event. + * @permission ohos.permission.INTERNET + * @return - + */ + on(type: 'complete' | 'pause' | 'remove', callback: () => void): void; + /** + * Called when the current download session complete、pause or remove. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @param type Indicates the download session event type + * complete: download task completed, + * pause: download task stopped, + * remove: download task deleted. + * @param callback The callback function for the download complete、pause or remove change event. + * @permission ohos.permission.INTERNET + * @return - + */ + off(type: 'complete' | 'pause' | 'remove', callback?: () => void): void; + /** + * Called when the current download session fails. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @param type Indicates the download session type, fail: download task has failed. + * @param callback The callback function for the download fail change event + * err The error code for download task. + * @permission ohos.permission.INTERNET + * @return - + */ + on(type: 'fail', callback: (err: number) => void): void; + /** + * Called when the current download session fails. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @param type Indicates the download session type, fail: download task has failed. + * @param callback Indicate the callback function to receive err. + * err The error code for download task. + * @permission ohos.permission.INTERNET + * @return - + */ + off(type: 'fail', callback?: (err: number) => void): void; + /** + * Deletes a download session and the downloaded files. + * @syscap SystemCapability.MiscServices.Download + * @since 6 + * @param callback Indicates asynchronous invoking Result. + * @permission ohos.permission.INTERNET + * @return - + */ + remove(callback: AsyncCallback): void; + /** + * Deletes a download session and the downloaded files. + * @syscap SystemCapability.MiscServices.Download + * @since 6 + * @permission ohos.permission.INTERNET + * @return - + */ + remove(): Promise; + /** + * Pause a download session. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @param callback Indicates asynchronous invoking Result. + * @permission ohos.permission.INTERNET + * @return - + */ + pause(callback: AsyncCallback): void; + /** + * Pause a download session. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + * @return - + */ + pause(): Promise; + /** + * Resume a paused download session. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @param callback Indicates asynchronous invoking Result. + * @permission ohos.permission.INTERNET + * @return - + */ + resume(callback: AsyncCallback): void; + /** + * Resume a paused download session. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + * @return - + */ + resume(): Promise; + /** + * Queries download information of a session, which is defined in DownloadSession.DownloadInfo. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @param callback Indicate the callback function to receive download info. + * @permission ohos.permission.INTERNET + * @return - + */ + query(callback: AsyncCallback): void; + /** + * Queries download information of a session, which is defined in DownloadSession.DownloadInfo. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + * @return - + */ + query(): Promise; + /** + * Queries the MIME type of the download file. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @param callback Indicate the callback function to receive download file MIME type. + * @permission ohos.permission.INTERNET + * @return - + */ + queryMimeType(callback: AsyncCallback): void; + /** + * Queries the MIME type of the download file. + * @syscap SystemCapability.MiscServices.Download + * @since 7 + * @permission ohos.permission.INTERNET + * @return - + */ + queryMimeType(): Promise; + } + /** + * File data Structure + * + * @name File + * @since 6 + * @syscap SystemCapability.MiscServices.Download + * @permission ohos.permission.INTERNET + */ + interface File { + /** + * When multipart is submitted, the file name in the request header. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + filename: string; + /** + * When multipart is submitted, the name of the form item. The default is file. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + name: string; + /** + * The local storage path of the file (please refer to the storage directory definition for path usage). + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + uri: string; + /** + * The content type of the file is obtained by default according to the suffix of the file name or path. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + type: string; + } + /** + * RequestData data Structure + * + * @name RequestData + * @since 6 + * @syscap SystemCapability.MiscServices.Download + * @permission ohos.permission.INTERNET + */ + interface RequestData { + /** + * Represents the name of the form element. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + name: string; + /** + * Represents the value of the form element. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + value: string; + } + /** + * UploadConfig data Structure + * + * @name UploadConfig + * @since 6 + * @syscap SystemCapability.MiscServices.Upload + * @permission ohos.permission.INTERNET + */ + interface UploadConfig { + /** + * Resource address. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + url: string; + /** + * Adds an HTTP or HTTPS header to be included with the upload request. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + header: Object; + /** + * Request method: POST, PUT. The default POST. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + method: string; + /** + * A list of files to be uploaded. Please use multipart/form-data to submit. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + files: Array; + /** + * The requested form data. + * + * @since 6 + * @permission ohos.permission.INTERNET + */ + data: Array; + } + interface UploadTask { + /** + * Called when the current upload session is in process. + * @syscap SystemCapability.MiscServices.Upload + * @since 6 + * @param type progress Indicates the upload task progress. + * @param callback The callback function for the upload progress change event + * uploadedSize The length of uploaded data, in bytes + * totalSize The length of data expected to be uploaded, in bytes. + * @permission ohos.permission.INTERNET + * @return - + */ + on(type: 'progress', callback: (uploadedSize: number, totalSize: number) => void): void; + /** + * Called when the current upload session is in process. + * @syscap SystemCapability.MiscServices.Upload + * @since 6 + * @param type progress Indicates the upload task progress. + * @param callback The callback function for the upload progress change event + * uploadedSize The length of uploaded data, in bytes + * totalSize The length of data expected to be uploaded, in bytes. + * @permission ohos.permission.INTERNET + * @return - + */ + off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) => void): void; + /** + * Called when the header of the current upload session has been received. + * @syscap SystemCapability.MiscServices.Upload + * @since 7 + * @param type headerReceive Indicates the upload task headed receive. + * @param callback The callback function for the HTTP Response Header event + * header HTTP Response Header returned by the developer server. + * @permission ohos.permission.INTERNET + * @return - + */ + on(type: 'headerReceive', callback: (header: object) => void): void; + /** + * Called when the header of the current upload session has been received. + * @syscap SystemCapability.MiscServices.Upload + * @since 7 + * @param type headerReceive Indicates the upload task headed receive. + * @param callback The callback function for the HTTP Response Header event + * header HTTP Response Header returned by the developer server. + * @permission ohos.permission.INTERNET + * @return - + */ + off(type: 'headerReceive', callback?: (header: object) => void): void; + /** + * Deletes a upload session. + * @syscap SystemCapability.MiscServices.Upload + * @since 6 + * @param callback Indicates asynchronous invoking Result. + * @permission ohos.permission.INTERNET + * @return - + */ + remove(callback: AsyncCallback): void; + /** + * Deletes a upload session. + * @syscap SystemCapability.MiscServices.Upload + * @since 6 + * @permission ohos.permission.INTERNET + * @return - + */ + remove(): Promise; + } +} +export default request; diff --git a/build-tools/api/@ohos.resourceManager.d.ts b/build-tools/api/@ohos.resourceManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8d0f51d56ef062e9f4860f05e6ca78132956045a --- /dev/null +++ b/build-tools/api/@ohos.resourceManager.d.ts @@ -0,0 +1,632 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { RawFileDescriptor } from './global/rawFileDescriptor'; +import { Resource } from './global/resource'; +/** + * Provides resource related APIs. + * + * @since 6 + * @syscap SystemCapability.Global.ResourceManager + */ +declare namespace resourceManager { + /** + * Enumerates screen directions. + * + * @since 6 + */ + export enum Direction { + /** + * Indicates the vertical direction. + * + * @since 6 + */ + DIRECTION_VERTICAL = 0, + /** + * Indicates the horizontal direction. + * + * @since 6 + */ + DIRECTION_HORIZONTAL = 1 + } + /** + * Enumerates device types. + * + * @since 6 + */ + export enum DeviceType { + /** + * Indicates a phone. + * + * @since 6 + */ + DEVICE_TYPE_PHONE = 0x00, + /** + * Indicates a tablet. + * + * @since 6 + */ + DEVICE_TYPE_TABLET = 0x01, + /** + * Indicates a car. + * + * @since 6 + */ + DEVICE_TYPE_CAR = 0x02, + /** + * Indicates a PC. + * + * @since 6 + */ + DEVICE_TYPE_PC = 0x03, + /** + * Indicates a smart TV. + * + * @since 6 + */ + DEVICE_TYPE_TV = 0x04, + /** + * Indicates a wearable device. + * + * @since 6 + */ + DEVICE_TYPE_WEARABLE = 0x06 + } + /** + * Enumerates screen density types. + * + * @since 6 + */ + export enum ScreenDensity { + /** + * Indicates small screen density. + * + * @since 6 + */ + SCREEN_SDPI = 120, + /** + * Indicates medium screen density. + * + * @since 6 + */ + SCREEN_MDPI = 160, + /** + * Indicates large screen density. + * + * @since 6 + */ + SCREEN_LDPI = 240, + /** + * Indicates extra-large screen density. + * + * @since 6 + */ + SCREEN_XLDPI = 320, + /** + * Indicates extra-extra-large screen density. + * + * @since 6 + */ + SCREEN_XXLDPI = 480, + /** + * Indicates extra-extra-extra-large screen density. + * + * @since 6 + */ + SCREEN_XXXLDPI = 640 + } + /** + * Provides the device configuration. + * + * @since 6 + */ + export class Configuration { + /** + * Indicates the screen direction of the current device. + * + * @since 6 + */ + direction: Direction; + /** + * Indicates the current system language, for example, zh-Hans-CN. + * + * @since 6 + */ + locale: string; + } + /** + * Provides the device capability. + * + * @since 6 + */ + export class DeviceCapability { + /** + * Indicates the screen density of the current device. + * + * @since 6 + */ + screenDensity: ScreenDensity; + /** + * Indicates the type of the current device. + * + * @since 6 + */ + deviceType: DeviceType; + } + /** + * The ResourceManager callback. + * @since 6 + */ + export interface AsyncCallback { + (err: Error, data: T): void; + } + /** + * Obtains the ResourceManager object of the current application. + * + * @param callback Indicates the callback containing the ResourceManager object. + * @since 6 + * @FAModelOnly + */ + export function getResourceManager(callback: AsyncCallback): void; + /** + * Obtains the ResourceManager object of the specified application. + * + * @param bundleName Indicates the bundle name of the specified application. + * @param callback Indicates the callback containing the ResourceManager object. + * @since 6 + * @FAModelOnly + */ + export function getResourceManager(bundleName: string, callback: AsyncCallback): void; + /** + * Obtains the ResourceManager object of the current application. + * + * @return Returns that the ResourceManager object is returned in Promise mode. + * @since 6 + * @FAModelOnly + */ + export function getResourceManager(): Promise; + /** + * Obtains the ResourceManager object of the specified application. + * + * @param bundleName Indicates the bundle name of the specified application. + * @return Returns that the ResourceManager object is returned in Promise mode. + * @since 6 + * @FAModelOnly + */ + export function getResourceManager(bundleName: string): Promise; + /** + * Provides the capability of accessing application resources. + * + * @since 6 + */ + export interface ResourceManager { + /** + * Obtains the character string corresponding to a specified resource ID in callback mode. + * + * @param resId Indicates the resource ID. + * @param callback Indicates the asynchronous callback used to return the obtained character string. + * @since 6 + */ + getString(resId: number, callback: AsyncCallback): void; + /** + * Obtains string resources associated with a specified resource ID in Promise mode. + * + * @param resId Indicates the resource ID. + * @return Returns the character string corresponding to the resource ID. + * @since 6 + */ + getString(resId: number): Promise; + /** + * Obtains the character string corresponding to a specified resource object in callback mode. + * + * @param resource Indicates the resource object. + * @param callback Indicates the asynchronous callback used to return the obtained character string. + * @since 9 + */ + getString(resource: Resource, callback: AsyncCallback): void; + /** + * Obtains string resources associated with a specified resource object in Promise mode. + * + * @param resource Indicates the resource object. + * @return Returns the character string corresponding to the resource object. + * @since 9 + */ + getString(resource: Resource): Promise; + /** + * Obtains the array of character strings corresponding to a specified resource ID in callback mode. + * + * @param resId Indicates the resource ID. + * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. + * @since 6 + */ + getStringArray(resId: number, callback: AsyncCallback>): void; + /** + * Obtains the array of character strings corresponding to a specified resource ID in Promise mode. + * + * @param resId Indicates the resource ID. + * @return Returns the array of character strings corresponding to the specified resource ID. + * @since 6 + */ + getStringArray(resId: number): Promise>; + /** + * Obtains the array of character strings corresponding to a specified resource object in callback mode. + * + * @param resource Indicates the resource object. + * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. + * @since 9 + */ + getStringArray(resource: Resource, callback: AsyncCallback>): void; + /** + * Obtains the array of character strings corresponding to a specified resource object in Promise mode. + * + * @param resource Indicates the resource object. + * @return Returns the array of character strings corresponding to the specified resource object. + * @since 9 + */ + getStringArray(resource: Resource): Promise>; + /** + * Obtains the content of the media file corresponding to a specified resource ID in callback mode. + * + * @param resId Indicates the resource ID. + * @param callback Indicates the asynchronous callback used to return the obtained media file content. + * @since 6 + */ + getMedia(resId: number, callback: AsyncCallback): void; + /** + * Obtains the content of the media file corresponding to a specified resource ID in Promise mode. + * + * @param resId Indicates the resource ID. + * @return Returns the content of the media file corresponding to the specified resource ID. + * @since 6 + */ + getMedia(resId: number): Promise; + /** + * Obtains the content of the media file corresponding to a specified resource object in callback mode. + * + * @param resource Indicates the resource object. + * @param callback Indicates the asynchronous callback used to return the obtained media file content. + * @since 9 + */ + getMedia(resource: Resource, callback: AsyncCallback): void; + /** + * Obtains the content of the media file corresponding to a specified resource object in Promise mode. + * + * @param resource Indicates the resource object. + * @return Returns the content of the media file corresponding to the specified resource object. + * @since 9 + */ + getMedia(resource: Resource): Promise; + /** + * Obtains the Base64 code of the image resource corresponding to the specified resource ID in callback mode. + * + * @param resId Indicates the resource ID. + * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image + * resource. + * @since 6 + */ + getMediaBase64(resId: number, callback: AsyncCallback): void; + /** + * Obtains the Base64 code of the image resource corresponding to the specified resource ID in Promise mode. + * + * @param resId Indicates the resource ID. + * @return Returns the Base64 code of the image resource corresponding to the specified resource ID. + * @since 6 + */ + getMediaBase64(resId: number): Promise; + /** + * Obtains the Base64 code of the image resource corresponding to the specified resource object in callback mode. + * + * @param resource Indicates the resource object. + * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image + * resource. + * @since 9 + */ + getMediaBase64(resource: Resource, callback: AsyncCallback): void; + /** + * Obtains the Base64 code of the image resource corresponding to the specified resource object in Promise mode. + * + * @param resource Indicates the resource object. + * @return Returns the Base64 code of the image resource corresponding to the specified resource object. + * @since 9 + */ + getMediaBase64(resource: Resource): Promise; + /** + * Obtains the device capability in callback mode. + * + * @param callback Indicates the asynchronous callback used to return the obtained device capability. + * @since 6 + */ + getDeviceCapability(callback: AsyncCallback): void; + /** + * Obtains the device capability in Promise mode. + * + * @return Returns the device capability. + * @since 6 + */ + getDeviceCapability(): Promise; + /** + * Obtains the device configuration in callback mode. + * + * @param callback Indicates the asynchronous callback used to return the obtained device + * configuration. + * @since 6 + */ + getConfiguration(callback: AsyncCallback): void; + /** + * Obtains the device configuration in Promise mode. + * + * @return Returns the device configuration. + * @since 6 + */ + getConfiguration(): Promise; + /** + * Obtains the singular-plural character string represented by the ID string corresponding to the + * specified number in callback mode. + * + * @param resId Indicates the resource ID. + * @param num Indicates the number. + * @param callback Indicates the asynchronous callback used to return the singular-plural character + * string represented by the ID string corresponding to the specified number. + * @since 6 + */ + getPluralString(resId: number, num: number, callback: AsyncCallback): void; + /** + * Obtains the singular-plural character string represented by the ID string corresponding to + * the specified number in Promise mode. + * + * @param resId Indicates the resource ID. + * @param num Indicates the number. + * @return Returns the singular-plural character string represented by the ID string + * corresponding to the specified number. + * @since 6 + */ + getPluralString(resId: number, num: number): Promise; + /** + * Obtains the singular-plural character string represented by the resource object string corresponding to the + * specified number in callback mode. + * + * @param resource Indicates the resource object. + * @param num Indicates the number. + * @param callback Indicates the asynchronous callback used to return the singular-plural character + * string represented by the resource object string corresponding to the specified number. + * @since 9 + */ + getPluralString(resource: Resource, num: number, callback: AsyncCallback): void; + /** + * Obtains the singular-plural character string represented by the resource object string corresponding to + * the specified number in Promise mode. + * + * @param resource Indicates the resource object. + * @param num Indicates the number. + * @return Returns the singular-plural character string represented by the resource object string + * corresponding to the specified number. + * @since 9 + */ + getPluralString(resource: Resource, num: number): Promise; + /** + * Obtains the raw file resource corresponding to the specified resource path in callback mode. + * + * @param path Indicates the resource relative path. + * @param callback Indicates the asynchronous callback used to return the raw file resource. + * @since 8 + */ + getRawFile(path: string, callback: AsyncCallback): void; + /** + * Obtains the raw file resource corresponding to the specified resource path in Promise mode. + * + * @param path Indicates the resource relative path. + * @return Returns the raw file resource corresponding to the specified resource path. + * @since 8 + */ + getRawFile(path: string): Promise; + /** + * Obtains the raw file resource descriptor corresponding to the specified resource path in callback mode. + * + * @param path Indicates the resource relative path. + * @param callback Indicates the asynchronous callback used to return the raw file resource descriptor. + * @since 8 + */ + getRawFileDescriptor(path: string, callback: AsyncCallback): void; + /** + * Obtains the raw file resource descriptor corresponding to the specified resource path in Promise mode. + * + * @param path Indicates the resource relative path. + * @return Returns the raw file resource descriptor corresponding to the specified resource path. + * @since 8 + */ + getRawFileDescriptor(path: string): Promise; + /** + * Obtains close raw file resource descriptor corresponding to the specified resource path in callback mode. + * + * @param path Indicates the resource relative path. + * @param callback Indicates the asynchronous callback used to return result close raw file resource descriptor. + * @since 8 + */ + closeRawFileDescriptor(path: string, callback: AsyncCallback): void; + /** + * Obtains close raw file resource descriptor corresponding to the specified resource path in Promise mode. + * + * @param path Indicates the resource relative path. + * @return Returns result close raw file resource descriptor corresponding to the specified resource path. + * @since 8 + */ + closeRawFileDescriptor(path: string): Promise; + /** + * Obtains the character string corresponding to a specified resource name in callback mode. + * + * @param resName Indicates the resource name. + * @param callback Indicates the asynchronous callback used to return the obtained character string. + * @since 9 + */ + getStringByName(resName: string, callback: AsyncCallback): void; + /** + * Obtains string resources associated with a specified resource name in Promise mode. + * + * @param resName Indicates the resource name. + * @return Returns the character string corresponding to the resource name. + * @since 9 + */ + getStringByName(resName: string): Promise; + /** + * Obtains the array of character strings corresponding to a specified resource name in callback mode. + * + * @param resName Indicates the resource name. + * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. + * @since 9 + */ + getStringArrayByName(resName: string, callback: AsyncCallback>): void; + /** + * Obtains the array of character strings corresponding to a specified resource name in Promise mode. + * + * @param resName Indicates the resource name. + * @return Returns the array of character strings corresponding to the specified resource name. + * @since 9 + */ + getStringArrayByName(resName: string): Promise>; + /** + * Obtains the content of the media file corresponding to a specified resource name in callback mode. + * + * @param resName Indicates the resource name. + * @param callback Indicates the asynchronous callback used to return the obtained media file content. + * @since 9 + */ + getMediaByName(resName: string, callback: AsyncCallback): void; + /** + * Obtains the content of the media file corresponding to a specified resource name in Promise mode. + * + * @param resName Indicates the resource name. + * @return Returns the content of the media file corresponding to the specified resource name. + * @since 9 + */ + getMediaByName(resName: string): Promise; + /** + * Obtains the Base64 code of the image resource corresponding to the specified resource name in callback mode. + * + * @param resName Indicates the resource name. + * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image + * resource. + * @since 9 + */ + getMediaBase64ByName(resName: string, callback: AsyncCallback): void; + /** + * Obtains the Base64 code of the image resource corresponding to the specified resource name in Promise mode. + * + * @param resName Indicates the resource name. + * @return Returns the Base64 code of the image resource corresponding to the specified resource name. + * @since 9 + */ + getMediaBase64ByName(resName: string): Promise; + /** + * Obtains the singular-plural character string represented by the name string corresponding to the + * specified number in callback mode. + * + * @param resName Indicates the resource name. + * @param num Indicates the number. + * @param callback Indicates the asynchronous callback used to return the singular-plural character + * string represented by the name string corresponding to the specified number. + * @since 9 + */ + getPluralStringByName(resName: string, num: number, callback: AsyncCallback): void; + /** + * Obtains the singular-plural character string represented by the name string corresponding to + * the specified number in Promise mode. + * + * @param resName Indicates the resource name. + * @param num Indicates the number. + * @return Returns the singular-plural character string represented by the name string + * corresponding to the specified number. + * @since 9 + */ + getPluralStringByName(resName: string, num: number): Promise; + /** + * Obtains string resources associated with a specified resource ID. + * + * @param resId Indicates the resource ID. + * @return Returns the character string corresponding to the resource ID. + * @since 9 + */ + getStringSync(resId: number): string; + /** + * Obtains string resources associated with a specified resource object. + * + * @param resource Indicates the resource object. + * @return Returns the character string corresponding to the resource object. + * @since 9 + */ + getStringSync(resource: Resource): string; + /** + * Obtains string resources associated with a specified resource name. + * + * @param resName Indicates the resource name. + * @return Returns the character string corresponding to the resource name. + * @since 9 + */ + getStringByNameSync(resName: string): string; + /** + * Obtains the boolean result with a specified resource ID. + * + * @param resId Indicates the resource ID. + * @return Returns the boolean resource corresponding to the resource ID. + * @since 9 + */ + getBoolean(resId: number): boolean; + /** + * Obtains the boolean result with a specified resource object. + * + * @param resource Indicates the resource object. + * @return Returns the boolean resource corresponding to the resource object. + * @since 9 + */ + getBoolean(resource: Resource): boolean; + /** + * Obtains the boolean result with a specified resource name. + * + * @param resName Indicates the resource name. + * @return Returns the boolean resource corresponding to the resource name. + * @since 9 + */ + getBooleanByName(resName: string): boolean; + /** + * Obtains the number result with a specified resource ID. + * + * @param resId Indicates the resource ID. + * @return Returns the number resource corresponding to the resource ID. + * @since 9 + */ + getNumber(resId: number): number; + /** + * Obtains the number result with a specified resource object. + * + * @param resource Indicates the resource object. + * @return Returns the number resource corresponding to the resource object. + * @since 9 + */ + getNumber(resource: Resource): number; + /** + * Obtains the number result with a specified resource name. + * + * @param resName Indicates the resource name. + * @return Returns the number resource corresponding to the resource name. + * @since 9 + */ + getNumberByName(resName: string): number; + /** + * Obtains release resourceManager. + * + * @since 7 + */ + release(); + } +} +export default resourceManager; diff --git a/build-tools/api/@ohos.router.d.ts b/build-tools/api/@ohos.router.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d7121b390c0f83c381f1fb927c31802a04842d58 --- /dev/null +++ b/build-tools/api/@ohos.router.d.ts @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 8 + * @import router from '@ohos.router'; + */ +declare namespace router { + /** + * Router Mode + * @since 9 + */ + export enum RouterMode { + /** + * Default route mode. + * @since 9 + */ + Standard, + /** + * single mode. + * @since 9 + */ + Single + } + /** + * @since 8 + */ + interface RouterOptions { + /** + * URI of the destination page, which supports the following formats: + * 1. Absolute path of the page, which is provided by the pages list in the config.json file. + * Example: + * pages/index/index + * pages/detail/detail + * 2. Particular path. If the URI is a slash (/), the home page is displayed. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 8 + */ + url: string; + /** + * Data that needs to be passed to the destination page during navigation. + * After the destination page is displayed, the parameter can be directly used for the page. + * For example, this.data1 (data1 is the key value of the params used for page navigation.) + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 8 + */ + params?: Object; + } + /** + * @since 8 + */ + interface RouterState { + /** + * Index of the current page in the stack. + * NOTE: The index starts from 1 from the bottom to the top of the stack. + * @since 8 + */ + index: number; + /** + * Name of the current page, that is, the file name. + * @since 8 + */ + name: string; + /** + * Path of the current page. + * @since 8 + */ + path: string; + } + /** + * @since 8 + */ + interface EnableAlertOptions { + /** + * dialog context. + * @since 8 + */ + message: string; + } + /** + * Navigates to a specified page in the application based on the page URL and parameters. + * @param options Options. + * @since 8 + */ + function push(options: RouterOptions): void; + /** + * Navigates to a specified page in the application based on the page URL and parameters. + * @param options Options. + * @param mode RouterMode + * @since 9 + */ + function push(options: RouterOptions, mode: RouterMode): void; + /** + * Replaces the current page with another one in the application. The current page is destroyed after replacement. + * @param options Options. + * @since 8 + */ + function replace(options: RouterOptions): void; + /** + * Replaces the current page with another one in the application. The current page is destroyed after replacement. + * @param options Options. + * @param mode RouterMode + * @since 9 + */ + function replace(options: RouterOptions, mode: RouterMode): void; + /** + * Returns to the previous page or a specified page. + * @param options Options. + * @since 8 + */ + function back(options?: RouterOptions): void; + /** + * Clears all historical pages and retains only the current page at the top of the stack. + * @since 8 + */ + function clear(): void; + /** + * Obtains the number of pages in the current stack. + * @returns Number of pages in the stack. The maximum value is 32. + * @since 8 + */ + function getLength(): string; + /** + * Obtains information about the current page state. + * @returns Page state. + * @since 8 + */ + function getState(): RouterState; + /** + * Pop up dialog to ask whether to back + * @param options Options. + * @since 8 + */ + function enableAlertBeforeBackPage(options: EnableAlertOptions): void; + /** + * cancel enableAlertBeforeBackPage + * @since 8 + */ + function disableAlertBeforeBackPage(): void; + /** + * Obtains information about the current page params. + * @returns Page params. + * @since 8 + */ + function getParams(): Object; +} +export default router; diff --git a/build-tools/api/@ohos.rpc.d.ts b/build-tools/api/@ohos.rpc.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7dab2b267d402eae27bc12a9dd9daa64d140c28c --- /dev/null +++ b/build-tools/api/@ohos.rpc.d.ts @@ -0,0 +1,1431 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +declare namespace rpc { + /** + * A data object used for reomote procedure call (RPC). + *

+ * During RPC, the sender can use the write methods provided by {@link MessageParcel} to + * write the to-be-sent data into a {@link MessageParcel} object in a specific format, and the receiver can use the + * read methods provided by {@link MessageParcel} to read data of the specific format from the {@link MessageParcel} object. + *

+ *

+ * The default capacity of a {@link MessageParcel} instance is 200KB. If you want more or less, use {@link #setCapacity(int)} + * to change it. + *

+ * Note: Only data of the following data types can be written into or read from a {@link MessageParcel}: byte, + * byteArray, short, shortArray, int, intArray, long, longArray, float, floatArray, double, doubleArray, boolean, + * booleanArray, char, charArray, String, StringArray, {@link IRemoteObject}, IRemoteObjectArray, + * {@link Sequenceable}, and SequenceableArray. + * + * @since 7 + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + */ + class MessageParcel { + /** + * Creates an empty {@link MessageParcel} object. + * @return Returns the object created. + * @since 7 + */ + static create(): MessageParcel; + /** + * Reclaims the {@link MessageParcel} object. + * @since 7 + */ + reclaim(): void; + /** + * Serializes a remote object and writes it to the {@link MessageParcel} object. + * @param object Remote object to serialize. + * @return Returns true if it is successful; returns false otherwise. + * @since 7 + */ + writeRemoteObject(object: IRemoteObject): boolean; + /** + * Reads a remote object from {@link MessageParcel} object. + * @return Returns the remote object. + * @since 7 + */ + readRemoteObject(): IRemoteObject; + /** + * Writes an interface token into the {@link MessageParcel} object. + * @param token Interface descriptor to write. + * @return Returns {@code true} if the interface token has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @since 7 + */ + writeInterfaceToken(token: string): boolean; + /** + * Reads an interface token from the {@link MessageParcel} object. + * @return Returns a string value. + * @since 7 + */ + readInterfaceToken(): string; + /** + * Obtains the size of data (in bytes) contained in the {@link MessageParcel} object. + * @return Returns the size of data contained in the {@link MessageParcel} object. + * @since 7 + */ + getSize(): number; + /** + * Obtains the storage capacity (in bytes) of the {@link MessageParcel} object. + * @return Returns the storage capacity of the {@link MessageParcel} object. + * @since 7 + */ + getCapacity(): number; + /** + * Sets the size of data (in bytes) contained in the {@link MessageParcel} object. + *

{@code false} is returned if the data size set in this method is greater + * than the storage capacity of the {@link MessageParcel}. + * + * @param size Indicates the data size of the {@link MessageParcel} object. + * @return Returns {@code true} if the setting is successful; returns {@code false} otherwise. + * @since 7 + */ + setSize(size: number): boolean; + /** + * Sets the storage capacity (in bytes) of the {@link MessageParcel} object. + *

{@code false} is returned if the capacity set in this method is less than + * the size of data contained in the {@link MessageParcel}. + * + * @param size Indicates the storage capacity of the {@link MessageParcel} object. + * @return Returns {@code true} if the setting is successful; returns {@code false} otherwise. + * @since 7 + */ + setCapacity(size: number): boolean; + /** + * Obtains the writable data space (in bytes) in the {@link MessageParcel} object. + *

Writable data space = Storage capacity of the {@link MessageParcel} – Size of data contained in the {@link MessageParcel}. + * + * @return Returns the writable data space of the {@link MessageParcel} object. + * @since 7 + */ + getWritableBytes(): number; + /** + * Obtains the readable data space (in bytes) in the {@link MessageParcel} object. + *

Readable data space = Size of data contained in the {@link MessageParcel} – Size of data that has been read. + * + * @return Returns the readable data space of the {@link MessageParcel} object. + * @since 7 + */ + getReadableBytes(): number; + /** + * Obtains the current read position in the {@link MessageParcel} object. + * @return Returns the current read position in the {@link MessageParcel} object. + * @since 7 + */ + getReadPosition(): number; + /** + * Obtains the current write position in the {@link MessageParcel} object. + * @return Returns the current write position in the {@link MessageParcel} object. + * @since 7 + */ + getWritePosition(): number; + /** + * Changes the current read position in the {@link MessageParcel} object. + *

Generally, you are advised not to change the current read position. If you must + * change it, change it to an accurate position. Otherwise, the read data may be incorrect. + * + * @param pos Indicates the target position to start data reading. + * @return Returns {@code true} if the read position is changed; returns {@code false} otherwise. + * @since 7 + */ + rewindRead(pos: number): boolean; + /** + * Changes the current write position in the {@link MessageParcel} object. + *

Generally, you are advised not to change the current write position. If you must + * change it, change it to an accurate position. Otherwise, the data to be read may be incorrect. + * + * @param pos Indicates the target position to start data writing. + * @return Returns {@code true} if the write position is changed; returns {@code false} otherwise. + * @since 7 + */ + rewindWrite(pos: number): boolean; + /** + * Writes information to this MessageParcel object indicating that no exception occurred. + *

After handling requests, you should call this method before writing any data to reply {@link MessageParcel}. + * @since 8 + */ + writeNoException(): void; + /** + * Reads the exception information from this MessageParcel object. + *

If exception was thrown in server side, it will be thrown here. + * This method should be called before reading any data from reply {@link MessageParcel} + * if {@link writeNoException} was invoked in server side. + * @throws Throws an exception if it thrown in server side. + * @since 8 + */ + readException(): void; + /** + * Writes a byte value into the {@link MessageParcel} object. + * @param val Indicates the byte value to write. + * @return Returns {@code true} if the value has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeByte(val: number): boolean; + /** + * Writes a short integer value into the {@link MessageParcel} object. + * @param val Indicates the short integer value to write. + * @return Returns {@code true} if the value has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeShort(val: number): boolean; + /** + * Writes an integer value into the {@link MessageParcel} object. + * @param val Indicates the integer value to write. + * @return Returns {@code true} if the value has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeInt(val: number): boolean; + /** + * Writes a long integer value into the {@link MessageParcel} object. + * @param val Indicates the long integer value to write. + * @return Returns {@code true} if the value has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeLong(val: number): boolean; + /** + * Writes a floating point value into the {@link MessageParcel} object. + * @param val Indicates the floating point value to write. + * @return Returns {@code true} if the value has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeFloat(val: number): boolean; + /** + * Writes a double-precision floating point value into the {@link MessageParcel} object. + * @param val Indicates the double-precision floating point value to write. + * @return Returns {@code true} if the value has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeDouble(val: number): boolean; + /** + * Writes a boolean value into the {@link MessageParcel} object. + * @param val Indicates the boolean value to write. + * @return Returns {@code true} if the value has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeBoolean(val: boolean): boolean; + /** + * Writes a single character value into the {@link MessageParcel} object. + * @param val Indicates the single character value to write. + * @return Returns {@code true} if the value has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeChar(val: number): boolean; + /** + * Writes a string value into the {@link MessageParcel} object. + * @param val Indicates the string value to write. + * @return Returns {@code true} if the value has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeString(val: string): boolean; + /** + * Writes a {@link Sequenceable} object into the {@link MessageParcel} object. + * @param val Indicates the {@link Sequenceable} object to write. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeSequenceable(val: Sequenceable): boolean; + /** + * Writes a byte array into the {@link MessageParcel} object. + * @param byteArray Indicates the byte array to write. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeByteArray(byteArray: number[]): boolean; + /** + * Writes a short integer array into the {@link MessageParcel} object. + * @param shortArray Indicates the short integer array to write. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @Note Ensure that the data type and size comply with the interface definition. + * Otherwise,data may be truncated. + * @since 7 + */ + writeShortArray(shortArray: number[]): boolean; + /** + * Writes an integer array into the {@link MessageParcel} object. + * @param intArray Indicates the integer array to write. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @Note Ensure that the data type and size comply with the interface definition. + * Otherwise,data may be truncated. + * @since 7 + */ + writeIntArray(intArray: number[]): boolean; + /** + * Writes a long integer array into the {@link MessageParcel} object. + * @param longArray Indicates the long integer array to write. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @Note Ensure that the data type and size comply with the interface definition. + * Otherwise,data may be truncated. + * @since 7 + */ + writeLongArray(longArray: number[]): boolean; + /** + * Writes a floating point array into the {@link MessageParcel} object. + * @param floatArray Indicates the floating point array to write. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @Note Ensure that the data type and size comply with the interface definition. + * Otherwise,data may be truncated. + * @since 7 + */ + writeFloatArray(floatArray: number[]): boolean; + /** + * Writes a double-precision floating point array into the {@link MessageParcel} object. + * @param doubleArray Indicates the double-precision floating point array to write. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @Note Ensure that the data type and size comply with the interface definition. + * Otherwise,data may be truncated. + * @since 7 + */ + writeDoubleArray(doubleArray: number[]): boolean; + /** + * Writes a boolean array into the {@link MessageParcel} object. + * @param booleanArray Indicates the boolean array to write. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @Note Ensure that the data type and size comply with the interface definition. + * Otherwise,data may be truncated. + * @since 7 + */ + writeBooleanArray(booleanArray: boolean[]): boolean; + /** + * Writes a single character array into the {@link MessageParcel} object. + * @param charArray Indicates the single character array to write. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @Note Ensure that the data type and size comply with the interface definition. + * Otherwise,data may be truncated. + * @since 7 + */ + writeCharArray(charArray: number[]): boolean; + /** + * Writes a string array into the {@link MessageParcel} object. + * @param stringArray Indicates the string array to write. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @Note Ensure that the data type and size comply with the interface definition. + * Otherwise,data may be truncated. + * @since 7 + */ + writeStringArray(stringArray: string[]): boolean; + /** + * Writes a {@link Sequenceable} object array into the {@link MessageParcel} object. + * @param sequenceableArray Indicates the {@link Sequenceable} object array to write. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this parcel is insufficient, + * exception message: {@link ParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean; + /** + * Writes an array of {@link IRemoteObject} objects to this {@link MessageParcel} object. + * @param objectArray Array of {@link IRemoteObject} objects to write. + * @return Returns {@code true} if the {@link IRemoteObject} array is successfully written to the {@link MessageParcel}; + * returns false if the {@link IRemoteObject} array is null or fails to be written to the {@lini MessageParcel}. + * @since 8 + */ + writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean; + /** + * Reads a byte value from the {@link MessageParcel} object. + * @return Returns a byte value. + * @since 7 + */ + readByte(): number; + /** + * Reads a short integer value from the {@link MessageParcel} object. + * @return Returns a short integer value. + * @since 7 + */ + readShort(): number; + /** + * Reads an integer value from the {@link MessageParcel} object. + * @return Returns an integer value. + * @since 7 + */ + readInt(): number; + /** + * Reads a long integer value from the {@link MessageParcel} object. + * @return Returns a long integer value. + * @since 7 + */ + readLong(): number; + /** + * Reads a floating point value from the {@link MessageParcel} object. + * @return Returns a floating point value. + * @since 7 + */ + readFloat(): number; + /** + * Reads a double-precision floating point value from the {@link MessageParcel} object. + * @return Returns a double-precision floating point value. + * @since 7 + */ + readDouble(): number; + /** + * Reads a boolean value from the {@link MessageParcel} object. + * @return Returns a boolean value. + * @since 7 + */ + readBoolean(): boolean; + /** + * Reads a single character value from the {@link MessageParcel} object. + * @return Returns a single character value. + * @since 7 + */ + readChar(): number; + /** + * Reads a string value from the {@link MessageParcel} object. + * @return Returns a string value. + * @since 7 + */ + readString(): string; + /** + * Reads a {@link Sequenceable} object from the {@link MessageParcel} instance. + * @param dataIn Indicates the {@link Sequenceable} object that needs to perform the {@code unmarshalling} operation + * using the {@link MessageParcel}. + * @return Returns {@code true} if the unmarshalling is successful; returns {@code false} otherwise. + * @since 7 + */ + readSequenceable(dataIn: Sequenceable): boolean; + /** + * Writes a byte array into the {@link MessageParcel} object. + * @param dataIn Indicates the byte array read from MessageParcel. + * @return Returns {@code true} if the array has been written into the {@link MessageParcel}; + * returns {@code false} otherwise. + * @throws ParcelException When capacity in this MessageParcel is insufficient, + * exception message: {@link *MessageParcelException#NO_CAPACITY_ERROR}. + * @since 7 + */ + readByteArray(dataIn: number[]): void; + /** + * Reads a byte array from the {@link MessageParcel} object. + * @return Returns a byte array. + * @since 7 + */ + readByteArray(): number[]; + /** + * Reads a short integer array from the {@link MessageParcel} object. + * @param dataIn Indicates the short integer array read from MessageParcel. + * @since 7 + */ + readShortArray(dataIn: number[]): void; + /** + * Reads a short integer array from the {@link MessageParcel} object. + * @return Returns a short integer array. + * @since 7 + */ + readShortArray(): number[]; + /** + * Reads an integer array from the {@link MessageParcel} object. + * @param dataIn Indicates the integer array to read. + * @throws ParcelException Throws this exception if reading the integer array fails. + * @since 7 + */ + readIntArray(dataIn: number[]): void; + /** + * Reads an integer array from the {@link MessageParcel} object. + * @return Returns an integer array. + * @since 7 + */ + readIntArray(): number[]; + /** + * Reads a long integer array from the {@link MessageParcel} object. + * @param dataIn Indicates the long integer array to read. + * @throws ParcelException Throws this exception if reading the long array fails. + * @since 7 + */ + readLongArray(dataIn: number[]): void; + /** + * Reads a long integer array from the {@link MessageParcel} object. + * @return Returns a long integer array. + * @since 7 + */ + readLongArray(): number[]; + /** + * Reads a floating point array from the {@link MessageParcel} object. + * @param dataIn Indicates the floating point array to read. + * @throws ParcelException Throws this exception if reading the float array fails. + * @since 7 + */ + readFloatArray(dataIn: number[]): void; + /** + * Reads a floating point array from the {@link MessageParcel} object. + * @return Returns a floating point array. + * @since 7 + */ + readFloatArray(): number[]; + /** + * Reads a double-precision floating point array from the {@link MessageParcel} object. + * @param dataIn Indicates the double-precision floating point array to read. + * @throws ParcelException Throws this exception if reading the double array fails. + * @since 7 + */ + readDoubleArray(dataIn: number[]): void; + /** + * Reads a double-precision floating point array from the {@link MessageParcel} object. + * @return Returns a double-precision floating point array. + * @since 7 + */ + readDoubleArray(): number[]; + /** + * Reads a boolean array from the {@link MessageParcel} object. + * @param dataIn Indicates the boolean array to read. + * @throws ParcelException Throws this exception if reading the boolean array fails. + * @since 7 + */ + readBooleanArray(dataIn: boolean[]): void; + /** + * Reads a boolean array from the {@link MessageParcel} object. + * @return Returns a boolean array. + * @since 7 + */ + readBooleanArray(): boolean[]; + /** + * Reads a single character array from the {@link MessageParcel} object. + * @param dataIn Indicates the single character array to read. + * @throws ParcelException Throws this exception if reading the char array fails. + * @since 7 + */ + readCharArray(dataIn: number[]): void; + /** + * Reads a single character array from the {@link MessageParcel} object. + * @return Returns a single character array. + * @since 7 + */ + readCharArray(): number[]; + /** + * Reads a string array from the {@link MessageParcel} object. + * @param dataIn Indicates the string array to read. + * @throws ParcelException Throws this exception if reading the string array fails. + * @since 7 + */ + readStringArray(dataIn: string[]): void; + /** + * Reads a string array from the {@link MessageParcel} object. + * @return Returns a string array. + * @since 7 + */ + readStringArray(): string[]; + /** + * Reads the specified {@link Sequenceable} array from this {@link MessageParcel} object. + * @param sequenceableArray Sequenceable array to read. + * @since 8 + */ + readSequenceableArray(sequenceableArray: Sequenceable[]): void; + /** + * Reads the specified {@link IRemoteObject} array from this {@link MessageParcel} object. + * @param objects Reads data from this {@link MessageParcel} object to the specified {@link IRemoteObject} array. + * @since 8 + */ + readRemoteObjectArray(objects: IRemoteObject[]): void; + /** + * Reads {@link IRemoteObject} objects from this {@link MessageParcel} object. + * @return An array of {@link IRemoteObject} objects obtained. + * @since 8 + */ + readRemoteObjectArray(): IRemoteObject[]; + /** + * Closes the specified file descriptor. + * @param fd File descriptor to be closed. + * @since 8 + */ + static closeFileDescriptor(fd: number): void; + /** + * Duplicates the specified file descriptor. + * @param fd File descriptor to be duplicated. + * @return A duplicated file descriptor. + * @since 8 + */ + static dupFileDescriptor(fd: number): number; + /** + * Checks whether this {@link MessageParcel} object contains a file descriptor. + * @return Returns true if the {@link MessageParcel} object contains a file descriptor; + * returns false otherwise. + * @since 8 + */ + containFileDescriptors(): boolean; + /** + * Writes a file descriptor to this {@link MessageParcel} object. + * @param fd File descriptor to wrote. + * @return Returns true if the operation is successful; returns false otherwise. + * @since 8 + */ + writeFileDescriptor(fd: number): boolean; + /** + * Reads a file descriptor from this {@link MessageParcel} object. + * @return File descriptor obtained. + * @since 8 + */ + readFileDescriptor(): number; + /** + * Writes an anonymous shared memory object to this {@link MessageParcel} object. + * @param ashmem Anonymous shared memory object to wrote. + * @return Returns true if the operation is successful; returns false otherwise. + * @since 8 + */ + writeAshmem(ashmem: Ashmem): boolean; + /** + * Reads the anonymous shared memory object from this {@link MessageParcel} object. + * @return Anonymous share object obtained. + * @since 8 + */ + readAshmem(): Ashmem; + /** + * Obtains the maximum amount of raw data that can be sent in a time. + * @return 128 MB. + * @since 8 + */ + getRawDataCapacity(): number; + /** + * Writes raw data to this {@link MessageParcel} object. + * @param rawData Raw data to wrote. + * @param size Size of the raw data, in bytes. + * @return Returns true if the operation is successful; returns false otherwise. + * @since 8 + */ + writeRawData(rawData: number[], size: number): boolean; + /** + * Reads raw data from this {@link MessageParcel} object. + * @param size Size of the raw data to read. + * @return Raw data obtained, in bytes. + * @since 8 + */ + readRawData(size: number): number[]; + } + /** + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + * @since 7 + */ + interface Sequenceable { + /** + * Marshals this {@code Sequenceable} object into a {@link MessageParcel}. + * + * @param dataOut Indicates the {@link MessageParcel} object to which the {@code Sequenceable} + * object will be marshaled.. + * @return Returns {@code true} if the marshalling is successful; returns {@code false} otherwise. + * @throws ParcelException Throws this exception if the operation fails. + * @since 7 + */ + marshalling(dataOut: MessageParcel): boolean; + /** + * Unmarshals this {@code Sequenceable} object from a {@link MessageParcel}. + * + * @param dataIn Indicates the {@link MessageParcel} object into which the {@code Sequenceable} + * object has been marshaled. + * @return Returns {@code true} if the unmarshalling is successful; returns {@code false} otherwise. + * @throws ParcelException Throws this exception if the operation fails. + * @since 7 + */ + unmarshalling(dataIn: MessageParcel): boolean; + } + /** + * Defines the response to the request. + *

SendRequestResult object contains four members, + * namely error code of this operation, request code, data parcel + * and reply parcel. + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + * @since 8 + */ + interface SendRequestResult { + /** + * Error code. 0 indicates successful, otherwise it is failed. + * @since 8 + */ + errCode: number; + /** + * Message code. It is same as the code in {@link SendRequest} method. + * @since 8 + */ + code: number; + /** + * MessageParcel object sent to the peer process. + * It is the same object in {@link SendRequest} method. + * @since 8 + */ + data: MessageParcel; + /** + * MessageParcel object returned by the peer process. + * It is the same object in {@link SendRequest} method. + * @since 8 + */ + reply: MessageParcel; + } + /** + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + * @since 7 + */ + interface IRemoteObject { + /** + * Queries the description of an interface. + * + *

A valid {@link IRemoteBroker} object is returned for an interface used by the service provider; + * {@code null} is returned for an interface used by the service user, + * indicating that the interface is not a local one. + * + * @param descriptor Indicates the interface descriptor. + * @return Returns the {@link IRemoteBroker} object bound to the specified interface descriptor. + * @since 7 + */ + queryLocalInterface(descriptor: string): IRemoteBroker; + /** + * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. + * + *

If asynchronous mode is set for {@code option}, a response is returned immediately. + * If synchronous mode is set for {@code option}, the interface will wait for a response from the peer process + * until the request times out. The user must prepare {@code reply} for receiving the execution result + * given by the peer process. + * + * @param code Indicates the message code, which is determined by both sides of the communication. + * If the interface is generated by the IDL tool, the message code is automatically generated by IDL. + * @param data Indicates the {@link MessageParcel} object sent to the peer process. + * @param reply Indicates the {@link MessageParcel} object returned by the peer process. + * @param options Indicates the synchronous or asynchronous mode to send messages. + * @return Returns {@code true} if the method is called successfully; returns {@code false} otherwise. + * @throws RemoteException Throws this exception if the method fails to be called. + * @deprecated since 8 + * @since 7 + */ + sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean; + /** + * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. + * + *

If options indicates the asynchronous mode, a promise will be fulfilled immediately + * and the reply message does not contain any content. If options indicates the synchronous mode, + * a promise will be fulfilled when the response to sendRequest is returned, + * and the reply message contains the returned information. + * param code Message code called by the request, which is determined by the client and server. + * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. + * param data {@link MessageParcel} object holding the data to send. + * param reply {@link MessageParcel} object that receives the response. + * param operations Indicates the synchronous or asynchronous mode to send messages. + * @returns Promise used to return the {@link SendRequestResult} instance. + * @throws Throws an exception if the method fails to be called. + * @deprecated since 9 + * @since 8 + */ + sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise; + /** + * Sends a {@link MessageParcel} message to the peer process asynchronously. + * + *

If options indicates the asynchronous mode, a promise will be fulfilled immediately + * and the reply message does not contain any content. If options indicates the synchronous mode, + * a promise will be fulfilled when the response to sendRequest is returned, + * and the reply message contains the returned information. + * param code Message code called by the request, which is determined by the client and server. + * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. + * param data {@link MessageParcel} object holding the data to send. + * param reply {@link MessageParcel} object that receives the response. + * param operations Indicates the synchronous or asynchronous mode to send messages. + * @returns Promise used to return the {@link SendRequestResult} instance. + * @throws Throws an exception if the method fails to be called. + * @since 9 + */ + sendRequestAsync(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise; + /** + * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. + * + *

If options indicates the asynchronous mode, a callback will be invoked immediately + * and the reply message does not contain any content. If options indicates the synchronous mode, + * a callback will be invoked when the response to sendRequest is returned, + * and the reply message contains the returned information. + * param code Message code called by the request, which is determined by the client and server. + * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. + * param data {@link MessageParcel} object holding the data to send. + * param reply {@link MessageParcel} object that receives the response. + * param operations Indicates the synchronous or asynchronous mode to send messages. + * param callback Callback for receiving the sending result. + * @since 8 + */ + sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback): void; + /** + * Registers a callback used to receive notifications of the death of a remote object. + * + * @param recipient Indicates the callback to be registered. + * @param flags Indicates the flag of the death notification. + * @return Returns {@code true} if the callback is registered successfully; returns {@code false} otherwise. + * @since 7 + */ + addDeathRecipient(recipient: DeathRecipient, flags: number): boolean; + /** + * Deregisters a callback used to receive notifications of the death of a remote object. + * + * @param recipient Indicates the callback to be deregistered. + * @param flags Indicates the flag of the death notification. + * @return Returns {@code true} if the callback is deregistered successfully; returns {@code false} otherwise. + * @since 7 + */ + removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean; + /** + * Obtains the interface descriptor of an object. + * + *

The interface descriptor is a character string. + * + * @return Returns the interface descriptor. + * @since 7 + */ + getInterfaceDescriptor(): string; + /** + * Checks whether an object is dead. + * + * @return Returns {@code true} if the object is dead; returns {@code false} otherwise. + * @since 7 + */ + isObjectDead(): boolean; + } + /** + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + * @since 7 + */ + interface IRemoteBroker { + /** + * Obtains a proxy or remote object. This method must be implemented by its derived classes. + * + * @return Returns the RemoteObject if the caller is a RemoteObject; returns the IRemoteObject, + * that is, the holder of this RemoteProxy object, if the caller is a RemoteProxy object. + * @since 7 + */ + asObject(): IRemoteObject; + } + /** + * @since 7 + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + */ + interface DeathRecipient { + /** + * Called to perform subsequent operations when a death notification of the remote object is received. + * + * @since 7 + */ + onRemoteDied(): void; + } + /** + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + * @since 7 + */ + class MessageOption { + /** + * Indicates synchronous call. + * @since 7 + */ + TF_SYNC = 0; + /** + * Indicates asynchronous call. + * @since 7 + */ + TF_ASYNC = 1; + /** + * Indicates the sendRequest API for returning the file descriptor. + * @since 7 + */ + TF_ACCEPT_FDS = 0x10; + /** + * Indicates the wait time for RPC, in seconds. It is NOT used in IPC case. + * @since 7 + */ + TF_WAIT_TIME = 4; + /** + * A constructor used to create a MessageOption instance. + * + * @param syncFlags Specifies whether the SendRequest is called synchronously (default) or asynchronously. + * @param waitTime Maximum wait time for a RPC call. The default value is TF_WAIT_TIME. + * @since 7 + */ + constructor(syncFlags?: number, waitTime = TF_WAIT_TIME); + /** + * Obtains the SendRequest call flag, which can be synchronous or asynchronous. + * + * @return Returns whether the SendRequest is called synchronously or asynchronously. + * @since 7 + */ + getFlags(): number; + /** + * Sets the SendRequest call flag, which can be synchronous or asynchronous. + * + * @param flags Indicates the call flag, which can be synchronous or asynchronous. + * @since 7 + */ + setFlags(flags: number): void; + /** + * Obtains the maximum wait time for this RPC call. + * + * @return Returns maximum wait time obtained. + * @since 7 + */ + getWaitTime(): number; + /** + * Sets the maximum wait time for this RPC call. + * + * @param waitTime Indicates maximum wait time to set. + * @since 7 + */ + setWaitTime(waitTime: number): void; + } + /** + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + * @since 7 + */ + class RemoteObject implements IRemoteObject { + /** + * A constructor to create a RemoteObject instance. + * + * @param descriptor Specifies interface descriptor. + * @since 7 + */ + constructor(descriptor: string); + /** + * Queries a remote object using an interface descriptor. + * + * @param descriptor Indicates the interface descriptor used to query the remote object. + * @return Returns the remote object matching the interface descriptor; returns null + * if no such remote object is found. + * @since 7 + */ + queryLocalInterface(descriptor: string): IRemoteBroker; + /** + * Queries an interface descriptor. + * + * @return Returns the interface descriptor. + * @since 7 + */ + getInterfaceDescriptor(): string; + /** + * Sets an entry for receiving requests. + * + *

This method is implemented by the remote service provider. You need to override this method with + * your own service logic when you are using IPC. + * + * @param code Indicates the service request code sent from the peer end. + * @param data Indicates the {@link MessageParcel} object sent from the peer end. + * @param reply Indicates the response message object sent from the remote service. + * The local service writes the response data to the {@link MessageParcel} object. + * @param options Indicates whether the operation is synchronous or asynchronous. + * @return Returns {@code true} if the operation succeeds; returns {@code false} otherwise. + * @throws RemoteException Throws this exception if a remote service error occurs. + * @since 7 + */ + onRemoteRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean; + /** + * Sends a request to the peer object. + * + *

If the peer object and {@code RemoteObject} are on the same device, the request is sent by the IPC driver. + * If they are on different devices, the request is sent by the socket driver. + * + * @param code Indicates the message code of the request. + * @param data Indicates the {@link MessageParcel} object storing the data to be sent. + * @param reply Indicates the {@link MessageParcel} object receiving the response data. + * @param options Indicates a synchronous (default) or asynchronous request. + * @return Returns {@code true} if the operation succeeds; returns {@code false} otherwise. + * @deprecated since 8 + * @since 7 + */ + sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean; + /** + * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. + * + *

If options indicates the asynchronous mode, a promise will be fulfilled immediately + * and the reply message does not contain any content. If options indicates the synchronous mode, + * a promise will be fulfilled when the response to sendRequest is returned, + * and the reply message contains the returned information. + * param code Message code called by the request, which is determined by the client and server. + * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. + * param data {@link MessageParcel} object holding the data to send. + * param reply {@link MessageParcel} object that receives the response. + * param operations Indicates the synchronous or asynchronous mode to send messages. + * @returns Promise used to return the {@link SendRequestResult} instance. + * @throws Throws an exception if the method fails to be called. + * @deprecated since 9 + * @since 8 + */ + sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise; + /** + * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. + * + *

If options indicates the asynchronous mode, a promise will be fulfilled immediately + * and the reply message does not contain any content. If options indicates the synchronous mode, + * a promise will be fulfilled when the response to sendRequest is returned, + * and the reply message contains the returned information. + * param code Message code called by the request, which is determined by the client and server. + * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. + * param data {@link MessageParcel} object holding the data to send. + * param reply {@link MessageParcel} object that receives the response. + * param operations Indicates the synchronous or asynchronous mode to send messages. + * @returns Promise used to return the {@link SendRequestResult} instance. + * @throws Throws an exception if the method fails to be called. + * @since 9 + */ + sendRequestAsync(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise; + /** + * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. + * + *

If options indicates the asynchronous mode, a callback will be invoked immediately + * and the reply message does not contain any content. If options indicates the synchronous mode, + * a callback will be invoked when the response to sendRequest is returned, + * and the reply message contains the returned information. + * param code Message code called by the request, which is determined by the client and server. + * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. + * param data {@link MessageParcel} object holding the data to send. + * param reply {@link MessageParcel} object that receives the response. + * param operations Indicates the synchronous or asynchronous mode to send messages. + * param callback Callback for receiving the sending result. + * @since 8 + */ + sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback): void; + /** + * Obtains the PID of the {@link RemoteProxy} object. + * + * @return Returns the PID of the {@link RemoteProxy} object. + * @since 7 + */ + getCallingPid(): number; + /** + * Obtains the UID of the {@link RemoteProxy} object. + * + * @return Returns the UID of the {@link RemoteProxy} object. + * @since 7 + */ + getCallingUid(): number; + /** + * Modifies the description of the current {@code RemoteObject}. + * + *

This method is used to change the default descriptor specified during the creation of {@code RemoteObject}. + * + * @param localInterface Indicates the {@code RemoteObject} whose descriptor is to be changed. + * @param descriptor Indicates the new descriptor of the {@code RemoteObject}. + * @since 7 + */ + attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void; + } + /** + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + * @since 7 + */ + class RemoteProxy implements IRemoteObject { + /** + * Indicates the message code for a Ping operation. + * @since 7 + */ + PING_TRANSACTION = ('_' << 24) | ('P' << 16) | ('N' << 8) | 'G'; + /** + * Indicates the message code for a dump operation. + * @since 7 + */ + DUMP_TRANSACTION = ('_' << 24) | ('D' << 16) | ('M' << 8) | 'P'; + /** + * Indicates the message code for a transmission. + * @since 7 + */ + INTERFACE_TRANSACTION = ('_' << 24) | ('N' << 16) | ('T' << 8) | 'F'; + /** + * Indicates the minimum value of a valid message code. + * + *

This constant is used to check the validity of an operation. + * @since 7 + */ + MIN_TRANSACTION_ID = 0x1; + /** + * Indicates the maximum value of a valid message code. + * + *

This constant is used to check the validity of an operation. + * @since 7 + */ + MAX_TRANSACTION_ID = 0x00FFFFFF; + /** + * Queries a local interface with a specified descriptor. + * + * @param descriptor Indicates the descriptor of the interface to query. + * @return Returns null by default, indicating a proxy interface. + * @since 7 + */ + queryLocalInterface(interface: string): IRemoteBroker; + /** + * Registers a callback used to receive death notifications of a remote object. + * + * @param recipient Indicates the callback to be registered. + * @param flags Indicates the flag of the death notification. This is a reserved parameter. Set it to {@code 0}. + * @return Returns {@code true} if the callback is registered successfully; returns {@code false} otherwise. + * @since 7 + */ + addDeathRecipient(recipient: DeathRecipient, flags: number): boolean; + /** + * Deregisters a callback used to receive death notifications of a remote object. + * + * @param recipient Indicates the callback to be deregistered. + * @param flags Indicates the flag of the death notification. This is a reserved parameter. Set it to {@code 0}. + * @return Returns {@code true} if the callback is deregistered successfully; returns {@code false} otherwise. + * @since 7 + */ + removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean; + /** + * Queries the interface descriptor of remote object. + * + * @return Returns the interface descriptor. + * @since 7 + */ + getInterfaceDescriptor(): string; + /** + * Sends a request to the peer object. + * + *

If the peer object and {@code RemoteProxy} are on the same device, the request is sent by the IPC driver. + * If they are on different devices, the request is sent by the socket driver. + * + * @param code Indicates the message code of the request. + * @param data Indicates the {@link MessageParcel} object storing the data to be sent. + * @param reply Indicates the {@link MessageParcel} object receiving the response data. + * @param options Indicates a synchronous (default) or asynchronous request. + * @return Returns {@code true} if the operation succeeds; returns {@code false} otherwise. + * @throws RemoteException Throws this exception if a remote object exception occurs. + * @deprecated since 8 + * @since 7 + */ + sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean; + /** + * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. + * + *

If options indicates the asynchronous mode, a promise will be fulfilled immediately + * and the reply message does not contain any content. If options indicates the synchronous mode, + * a promise will be fulfilled when the response to sendRequest is returned, + * and the reply message contains the returned information. + * param code Message code called by the request, which is determined by the client and server. + * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. + * param data {@link MessageParcel} object holding the data to send. + * param reply {@link MessageParcel} object that receives the response. + * param operations Indicates the synchronous or asynchronous mode to send messages. + * @returns Promise used to return the {@link sendRequestResult} instance. + * @throws Throws an exception if the method fails to be called. + * @deprecated since 9 + * @since 8 + */ + sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise; + /** + * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. + * + *

If options indicates the asynchronous mode, a promise will be fulfilled immediately + * and the reply message does not contain any content. If options indicates the synchronous mode, + * a promise will be fulfilled when the response to sendRequest is returned, + * and the reply message contains the returned information. + * param code Message code called by the request, which is determined by the client and server. + * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. + * param data {@link MessageParcel} object holding the data to send. + * param reply {@link MessageParcel} object that receives the response. + * param operations Indicates the synchronous or asynchronous mode to send messages. + * @returns Promise used to return the {@link SendRequestResult} instance. + * @throws Throws an exception if the method fails to be called. + * @since 9 + */ + sendRequestAsync(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise; + /** + * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. + * + *

If options indicates the asynchronous mode, a callback will be invoked immediately + * and the reply message does not contain any content. If options indicates the synchronous mode, + * a callback will be invoked when the response to sendRequest is returned, + * and the reply message contains the returned information. + * param code Message code called by the request, which is determined by the client and server. + * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. + * param data {@link MessageParcel} object holding the data to send. + * param reply {@link MessageParcel} object that receives the response. + * param operations Indicates the synchronous or asynchronous mode to send messages. + * param callback Callback for receiving the sending result. + * @since 8 + */ + sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback): void; + /** + * Checks whether the {@code RemoteObject} corresponding to a {@code RemoteProxy} is dead. + * + * @return Returns {@code true} if the {@code RemoteObject} is dead; returns {@code false} otherwise. + * @since 7 + */ + isObjectDead(): boolean; + } + /** + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + * @since 7 + */ + class IPCSkeleton { + /** + * Obtains a local {@link IRemoteObject} reference of a registered service. + * + *

This method is static. + * + * @return Returns an {@link IRemoteObject} reference of the registered service. + * @since 7 + */ + static getContextObject(): IRemoteObject; + /** + * Obtains the PID of a proxy. + * + *

This method is static. The PID is a positive integer during the communication between + * the {@link RemoteProxy} object and {@link RemoteObject} object, and resumes to {@code 0} + * when the communication ends. If this method is called from the {@link RemoteProxy} object, + * {@code 0} is returned; if this method is called from the {@link RemoteObject} object, + * the PID of the corresponding {@link RemoteProxy} object is returned. + * + * @return Returns the PID of the proxy. + * @since 7 + */ + static getCallingPid(): number; + /** + * Obtains the UID of a proxy. + * + *

This method is static. The UID is a positive integer during the communication between + * the {@link RemoteProxy} object and {@link RemoteObject} object, and resumes to {@code 0} + * when the communication ends. If this method is called from the {@link RemoteProxy} object, + * {@code 0} is returned; if this method is called from the {@link RemoteObject} object, + * the UID of the corresponding {@link RemoteProxy} object is returned. + * + * @return Returns the UID of the proxy. + * @since 7 + */ + static getCallingUid(): number; + /** + * Obtains the TOKENID. + * + *

This method is static. + * + * @return Returns the TOKENID. + * @since 8 + */ + static getCallingTokenId(): number; + /** + * Obtains the ID of the device where the peer process resides. + * + *

This method is static. + * + * @return Returns the ID of the device where the peer process resides. + * @since 7 + */ + static getCallingDeviceID(): string; + /** + * Obtains the ID of the local device. + * + *

This method is static. + * + * @return Returns the ID of the local device. + * @since 7 + */ + static getLocalDeviceID(): string; + /** + * Checks whether a call is made on the same device. + * + *

This method is static. + * + * @return Returns {@code true} if the call is made on the same device; returns {@code false} otherwise. + * @since 7 + */ + static isLocalCalling(): boolean; + /** + * Flushes all pending commands from a specified {@link RemoteProxy} to the corresponding {@link RemoteObject}. + * + *

This method is static. You are advised to call this method before performing any time-sensitive operations. + * + * @param object Indicates the specified {@link RemoteProxy}. + * @return Returns {@code 0} if the operation succeeds; returns an error code if the input object is empty + * or {@link RemoteObject}, or the operation fails. + * @since 7 + */ + static flushCommands(object: IRemoteObject): number; + /** + * Replaces the UID and PID of the remote user with those of the local user. + * + *

This method is static. It can be used in scenarios like authentication. + * + * @return Returns a string containing the UID and PID of the remote user. + * @since 7 + */ + static resetCallingIdentity(): string; + /** + * Restores the UID and PID to those of the remote user. + * + *

This method is static. It is usually called after {@code resetCallingIdentity} is used + * and requires the UID and PID of the remote user returned by {@code resetCallingIdentity}. + * + * @param identity Indicates the string containing the UID and PID of the remote user, + * which is returned by {@code resetCallingIdentity}. + * @return Returns {@code true} if the operation succeeds; returns {@code false} otherwise. + * @since 7 + */ + static setCallingIdentity(identity: string): boolean; + } + /** + * Provides methods related to anonymous shared memory objects, + * including creating, closing, mapping, and unmapping an Ashmem object, + * reading data from and writing data to an Ashmem object, + * obtaining the Ashmem size, and setting Ashmem protection. + * @syscap SystemCapability.Communication.IPC.Core + * @import import rpc from '@ohos.rpc' + * @since 8 + */ + class Ashmem { + /** + * The mapped memory is executable. + * @since 8 + */ + PROT_EXEC = 4; + /** + * The mapped memory is inaccessible. + * @since 8 + */ + PROT_NONE = 0; + /** + * The mapped memory is readable. + * @since 8 + */ + PROT_READ = 1; + /** + * The mapped memory is writable. + * @since 8 + */ + PROT_WRITE = 2; + /** + * Creates an Ashmem object with the specified name and size. + * @param name Name of the Ashmem object to create. + * @param size Size (in bytes) of the Ashmem object to create. + * @return Returns the Ashmem object if it is created successfully; returns null otherwise. + * @since 8 + */ + static createAshmem(name: string, size: number): Ashmem; + /** + * Creates an Ashmem object by copying the file descriptor (FD) of an existing Ashmem object. + * The two Ashmem objects point to the same shared memory region. + * @param ashmem Existing Ashmem object. + * @return Ashmem object created. + * @since 8 + */ + static createAshmemFromExisting(ashmem: Ashmem): Ashmem; + /** + * Closes this Ashmem object. + * @since 8 + */ + closeAshmem(): void; + /** + * Deletes the mappings for the specified address range of this Ashmem object. + * @since 8 + */ + unmapAshmem(): void; + /** + * Obtains the mapped memory size of this Ashmem object. + * @return Memory size mapped. + * @since 8 + */ + getAshmemSize(): number; + /** + * Creates the shared file mapping on the virtual address space of this process. + * The size of the mapping region is specified by this Ashmem object. + * @param mapType Protection level of the memory region to which the shared file is mapped. + * @return Returns true if the operation is successful; returns false otherwise. + * @since 8 + */ + mapAshmem(mapType: number): boolean; + /** + * Maps the shared file to the readable and writable virtual address space of the process. + * @return Returns true if the operation is successful; returns false otherwise. + * @since 8 + */ + mapReadAndWriteAshmem(): boolean; + /** + * Maps the shared file to the read-only virtual address space of the process. + * @return Returns true if the operation is successful; returns false otherwise. + * @since 8 + */ + mapReadOnlyAshmem(): boolean; + /** + * Sets the protection level of the memory region to which the shared file is mapped. + * @param protectionType Protection type to set. + * @return Returns true if the operation is successful; returns false otherwise. + * @since 8 + */ + setProtection(protectionType: number): boolean; + /** + * Writes data to the shared file associated with this Ashmem object. + * @param buf Data to write + * @param size Size of the data to write + * @param offset Start position of the data to write in the memory region associated with this Ashmem object. + * @return Returns true is the data is written successfully; returns false otherwise. + * @since 8 + */ + writeToAshmem(buf: number[], size: number, offset: number): boolean; + /** + * Reads data from the shared file associated with this Ashmem object. + * @param size Size of the data to read. + * @param offset Start position of the data to read in the memory region associated with this Ashmem object. + * @return Data read. + * @since 8 + */ + readFromAshmem(size: number, offset: number): number[]; + } +} +export default rpc; diff --git a/build-tools/api/@ohos.runninglock.d.ts b/build-tools/api/@ohos.runninglock.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..181ea22c6b19cead68e28e9ef4bf08349b86a4eb --- /dev/null +++ b/build-tools/api/@ohos.runninglock.d.ts @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Provides a mechanism to prevent the system from hibernating so that the applications can run in the background or + * when the screen is off. + * + *

{@link createRunningLock} can be called to obtain a {@link RunningLock}. + *

{@link lock} can be called to set the lock duration, during which the system will not hibernate. After the + * lock duration times out, the lock is automatically released and the system hibernates if no other {@link + * RunningLock} is set. + * + * @syscap SystemCapability.PowerManager.PowerManager.Core + * @since 7 + */ +declare namespace runningLock { + class RunningLock { + /** + * Prevents the system from hibernating and sets the lock duration. + * This method requires the ohos.permission.RUNNING_LOCK permission. + * + * @param timeout Indicates the lock duration (ms). After the lock duration times out, the lock is automatically + * released and the system hibernates if no other {@link RunningLock} is set. + * @permission ohos.permission.RUNNING_LOCK + * @since 7 + */ + lock(timeout: number): void; + /** + * Checks whether a lock is held or in use. + * + * @return Returns true if the lock is held or in use; returns false if the lock has been released. + * @since 7 + */ + isUsed(): boolean; + /** + * Release the {@link RunningLock} that prevents the system from hibernating. + * This method requires the ohos.permission.RUNNING_LOCK permission. + * + * @since 7 + * @permission ohos.permission.RUNNING_LOCK + */ + unlock(): void; + } + /** + * Enumerates the {@link RunningLock} types. + * + *

Two {@link RunningLock} types are available: {@link BACKGROUND}, and {@link PROXIMITY_SCREEN_CONTROL}. + * {@link BACKGROUND} ensures that applications can run in the background. + * {@link PROXIMITY_SCREEN_CONTROL} determines whether to turn on or off the screen based on the proximity sensor. + * + * @since 7 + */ + export enum RunningLockType { + /** + * Indicates the lock that prevents the system from hibernating. + */ + BACKGROUND = 1, + /** + * Indicates the lock that determines whether to turn on or off the screen based on the proximity sensor. + * For example, during a call, if the proximity sensor detects that the device is moving close to + * the user's ear, the screen turns off; if the proximity sensor detects that the device is moving away + * from the user's ear, the screen turns on. + */ + PROXIMITY_SCREEN_CONTROL + } + /** + * Checks whether the specified {@link RunningLockType} is supported. + * + * @param type Indicates the specified {@link RunningLockType}. + * @return Returns true if the specified {@link RunningLockType} is supported; + * returns false otherwise. + * @since 7 + */ + function isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback): void; + function isRunningLockTypeSupported(type: RunningLockType): Promise; + /** + * Creates a {@link RunningLock} object. + * + *

This method requires the ohos.permission.RUNNING_LOCK permission. + * + *

The {@link RunningLock} object can be used to perform a lock operation to prevent the system from hibernating. + * + * @param name Indicates the {@link RunningLock} name. A recommended name consists of the package or class name and + * a suffix. + * @param type Indicates the {@link RunningLockType}. + * @return Returns the {@link RunningLock} object. + * @permission ohos.permission.RUNNING_LOCK + * @since 7 + */ + function createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback): void; + function createRunningLock(name: string, type: RunningLockType): Promise; +} +export default runningLock; diff --git a/build-tools/api/@ohos.screenLock.d.ts b/build-tools/api/@ohos.screenLock.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae31fd5d5e857b2eda51906f4e367a111cd85080 --- /dev/null +++ b/build-tools/api/@ohos.screenLock.d.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * systemScreenLock + * @syscap SystemCapability.MiscServices.ScreenLock + * @since 7 + */ +declare namespace screenLock { + /** + * Checks whether the screen is currently locked. + * + * @return Returns {@code true} if the screen is currently locked; returns {@code false} + * otherwise. + * @since 7 + */ + function isScreenLocked(callback: AsyncCallback): void; + function isScreenLocked(): Promise; + /** + * Checks whether the screen lock of the current device is secure. + * + * @return Returns {@code true} if the screen lock of the current device is secure; returns {@code false} + * otherwise. + * @since 7 + */ + function isSecureMode(callback: AsyncCallback): void; + function isSecureMode(): Promise; + /** + * Unlocks the screen. + * return - + * @since 7 + */ + function unlockScreen(callback: AsyncCallback): void; + function unlockScreen(): Promise; +} +export default screenLock; diff --git a/build-tools/api/@ohos.security.huks.d.ts b/build-tools/api/@ohos.security.huks.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..de457d791d58d7ba1e6bf08d44901c2322a8f8dd --- /dev/null +++ b/build-tools/api/@ohos.security.huks.d.ts @@ -0,0 +1,596 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback } from './basic'; +/** + * OpenHarmony Universal KeyStore + * @since 8 + * @syscap SystemCapability.Security.Huks + */ +declare namespace huks { + /** + * Generate Key. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param keyAlias Indicates the key's name. + * @param options Indicates the properties of the key. + */ + function generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback): void; + function generateKey(keyAlias: string, options: HuksOptions): Promise; + /** + * Delete Key. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param keyAlias Indicates the key's name. + * @param options Indicates the properties of the key. + */ + function deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback): void; + function deleteKey(keyAlias: string, options: HuksOptions): Promise; + /** + * Import Key. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param keyAlias Indicates the key's name. + * @param options Indicates the properties of the key. + */ + function importKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback): void; + function importKey(keyAlias: string, options: HuksOptions): Promise; + /** + * Import Wrapped Key. + * @since 9 + * @syscap SystemCapability.Security.Huks + * @param keyAlias Indicates the name of key to be imported. + * @param wrappingKeyAlias Indicates the name of key for wrapping the key to be imported + * @param options Indicates the properties of the key. + */ + function importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions, callback: AsyncCallback): void; + function importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions): Promise; + /** + * Export Key. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param keyAlias Indicates the key's name. + * @param options Indicates the properties of the key. + */ + function exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback): void; + function exportKey(keyAlias: string, options: HuksOptions): Promise; + /** + * Get properties of the key. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param keyAlias Indicates the key's name. + * @param options Indicates the properties of the key. + */ + function getKeyProperties(keyAlias: string, options: HuksOptions, callback: AsyncCallback): void; + function getKeyProperties(keyAlias: string, options: HuksOptions): Promise; + /** + * Check whether the key exists. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param keyAlias Indicates the key's name. + * @param options Indicates the properties of the key. + */ + function isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback): void; + function isKeyExist(keyAlias: string, options: HuksOptions): Promise; + /** + * Init Operation. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param keyAlias Indicates the key's name. + * @param options Indicates the properties of the key. + * @return The handle of the init Operation. + */ + function init(keyAlias: string, options: HuksOptions, callback: AsyncCallback): void; + function init(keyAlias: string, options: HuksOptions): Promise; + /** + * Update Operation. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param handle Indicates the handle of the init operation. + * @param token Indicates the value of token. + * @param options Indicates the properties of the update operation. + */ + function update(handle: number, token?: Uint8Array, options: HuksOptions, callback: AsyncCallback): void; + function update(handle: number, token?: Uint8Array, options: HuksOptions): Promise; + /** + * Update Operation. + * @since 9 + * @syscap SystemCapability.Security.Huks + * @param handle Indicates the handle of the init operation. + * @param options Indicates the properties of the update operation. + * @param token Indicates the value of token. + */ + function update(handle: number, options: HuksOptions, callback: AsyncCallback): void; + function update(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback): void; + function update(handle: number, options: HuksOptions, token?: Uint8Array): Promise; + /** + * Finish Operation. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param handle Indicates the handle of the init operation. + * @param options Indicates the properties of the finish operation. + */ + function finish(handle: number, options: HuksOptions, callback: AsyncCallback): void; + function finish(handle: number, options: HuksOptions): Promise; + /** + * Abort Operation. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param handle Indicates the handle of the init operation. + * @param options Indicates the properties of the abort operation. + */ + function abort(handle: number, options: HuksOptions, callback: AsyncCallback): void; + function abort(handle: number, options: HuksOptions): Promise; + /** + * Get the sdk version. + * @since 8 + * @syscap SystemCapability.Security.Huks + * @param options Indicates the properties of the key. + * @return Return the character string of the sdk version. + */ + function getSdkVersion(options: HuksOptions): string; + /** + * Interface of huks param. + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export interface HuksParam { + tag: HuksTag; + value: boolean | number | bigint | Uint8Array; + } + /** + * Interface of huks handle. + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export interface HuksHandle { + errorCode: number; + handle: number; + token?: Uint8Array; + } + /** + * Interface of huks option. + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export interface HuksOptions { + properties?: Array; + inData?: Uint8Array; + } + /** + * Interface of huks result. + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export interface HuksResult { + errorCode: number; + outData?: Uint8Array; + properties?: Array; + certChains?: Array; + } + /** + * @name HuksErrorCode + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksErrorCode { + HUKS_SUCCESS = 0, + HUKS_FAILURE = -1, + HUKS_ERROR_BAD_STATE = -2, + HUKS_ERROR_INVALID_ARGUMENT = -3, + HUKS_ERROR_NOT_SUPPORTED = -4, + HUKS_ERROR_NO_PERMISSION = -5, + HUKS_ERROR_INSUFFICIENT_DATA = -6, + HUKS_ERROR_BUFFER_TOO_SMALL = -7, + HUKS_ERROR_INSUFFICIENT_MEMORY = -8, + HUKS_ERROR_COMMUNICATION_FAILURE = -9, + HUKS_ERROR_STORAGE_FAILURE = -10, + HUKS_ERROR_HARDWARE_FAILURE = -11, + HUKS_ERROR_ALREADY_EXISTS = -12, + HUKS_ERROR_NOT_EXIST = -13, + HUKS_ERROR_NULL_POINTER = -14, + HUKS_ERROR_FILE_SIZE_FAIL = -15, + HUKS_ERROR_READ_FILE_FAIL = -16, + HUKS_ERROR_INVALID_PUBLIC_KEY = -17, + HUKS_ERROR_INVALID_PRIVATE_KEY = -18, + HUKS_ERROR_INVALID_KEY_INFO = -19, + HUKS_ERROR_HASH_NOT_EQUAL = -20, + HUKS_ERROR_MALLOC_FAIL = -21, + HUKS_ERROR_WRITE_FILE_FAIL = -22, + HUKS_ERROR_REMOVE_FILE_FAIL = -23, + HUKS_ERROR_OPEN_FILE_FAIL = -24, + HUKS_ERROR_CLOSE_FILE_FAIL = -25, + HUKS_ERROR_MAKE_DIR_FAIL = -26, + HUKS_ERROR_INVALID_KEY_FILE = -27, + HUKS_ERROR_IPC_MSG_FAIL = -28, + HUKS_ERROR_REQUEST_OVERFLOWS = -29, + HUKS_ERROR_PARAM_NOT_EXIST = -30, + HUKS_ERROR_CRYPTO_ENGINE_ERROR = -31, + HUKS_ERROR_COMMUNICATION_TIMEOUT = -32, + HUKS_ERROR_IPC_INIT_FAIL = -33, + HUKS_ERROR_IPC_DLOPEN_FAIL = -34, + HUKS_ERROR_EFUSE_READ_FAIL = -35, + HUKS_ERROR_NEW_ROOT_KEY_MATERIAL_EXIST = -36, + HUKS_ERROR_UPDATE_ROOT_KEY_MATERIAL_FAIL = -37, + HUKS_ERROR_VERIFICATION_FAILED = -38, + HUKS_ERROR_CHECK_GET_ALG_FAIL = -100, + HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL = -101, + HUKS_ERROR_CHECK_GET_PADDING_FAIL = -102, + HUKS_ERROR_CHECK_GET_PURPOSE_FAIL = -103, + HUKS_ERROR_CHECK_GET_DIGEST_FAIL = -104, + HUKS_ERROR_CHECK_GET_MODE_FAIL = -105, + HUKS_ERROR_CHECK_GET_NONCE_FAIL = -106, + HUKS_ERROR_CHECK_GET_AAD_FAIL = -107, + HUKS_ERROR_CHECK_GET_IV_FAIL = -108, + HUKS_ERROR_CHECK_GET_AE_TAG_FAIL = -109, + HUKS_ERROR_CHECK_GET_SALT_FAIL = -110, + HUKS_ERROR_CHECK_GET_ITERATION_FAIL = -111, + HUKS_ERROR_INVALID_ALGORITHM = -112, + HUKS_ERROR_INVALID_KEY_SIZE = -113, + HUKS_ERROR_INVALID_PADDING = -114, + HUKS_ERROR_INVALID_PURPOSE = -115, + HUKS_ERROR_INVALID_MODE = -116, + HUKS_ERROR_INVALID_DIGEST = -117, + HUKS_ERROR_INVALID_SIGNATURE_SIZE = -118, + HUKS_ERROR_INVALID_IV = -119, + HUKS_ERROR_INVALID_AAD = -120, + HUKS_ERROR_INVALID_NONCE = -121, + HUKS_ERROR_INVALID_AE_TAG = -122, + HUKS_ERROR_INVALID_SALT = -123, + HUKS_ERROR_INVALID_ITERATION = -124, + HUKS_ERROR_INVALID_OPERATION = -125, + /** + * @name HUKS_ERROR_INVALID_WRAPPED_FORMAT + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + HUKS_ERROR_INVALID_WRAPPED_FORMAT = -126, + /** + * @name HUKS_ERROR_INVALID_USAGE_OF_KEY + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + HUKS_ERROR_INVALID_USAGE_OF_KEY = -127, + HUKS_ERROR_INTERNAL_ERROR = -999, + HUKS_ERROR_UNKNOWN_ERROR = -1000 + } + /** + * @name HuksKeyPurpose + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksKeyPurpose { + HUKS_KEY_PURPOSE_ENCRYPT = 1, + HUKS_KEY_PURPOSE_DECRYPT = 2, + HUKS_KEY_PURPOSE_SIGN = 4, + HUKS_KEY_PURPOSE_VERIFY = 8, + HUKS_KEY_PURPOSE_DERIVE = 16, + HUKS_KEY_PURPOSE_WRAP = 32, + HUKS_KEY_PURPOSE_UNWRAP = 64, + HUKS_KEY_PURPOSE_MAC = 128, + HUKS_KEY_PURPOSE_AGREE = 256 + } + /** + * @name HuksKeyDigest + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksKeyDigest { + HUKS_DIGEST_NONE = 0, + HUKS_DIGEST_MD5 = 1, + /** + * @name HUKS_DIGEST_SM3 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + HUKS_DIGEST_SM3 = 2, + HUKS_DIGEST_SHA1 = 10, + HUKS_DIGEST_SHA224 = 11, + HUKS_DIGEST_SHA256 = 12, + HUKS_DIGEST_SHA384 = 13, + HUKS_DIGEST_SHA512 = 14 + } + /** + * @name HuksKeyPadding + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksKeyPadding { + HUKS_PADDING_NONE = 0, + HUKS_PADDING_OAEP = 1, + HUKS_PADDING_PSS = 2, + HUKS_PADDING_PKCS1_V1_5 = 3, + HUKS_PADDING_PKCS5 = 4, + HUKS_PADDING_PKCS7 = 5 + } + /** + * @name HuksCipherMode + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksCipherMode { + HUKS_MODE_ECB = 1, + HUKS_MODE_CBC = 2, + HUKS_MODE_CTR = 3, + HUKS_MODE_OFB = 4, + HUKS_MODE_CCM = 31, + HUKS_MODE_GCM = 32 + } + /** + * @name HuksKeySize + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksKeySize { + HUKS_RSA_KEY_SIZE_512 = 512, + HUKS_RSA_KEY_SIZE_768 = 768, + HUKS_RSA_KEY_SIZE_1024 = 1024, + HUKS_RSA_KEY_SIZE_2048 = 2048, + HUKS_RSA_KEY_SIZE_3072 = 3072, + HUKS_RSA_KEY_SIZE_4096 = 4096, + HUKS_ECC_KEY_SIZE_224 = 224, + HUKS_ECC_KEY_SIZE_256 = 256, + HUKS_ECC_KEY_SIZE_384 = 384, + HUKS_ECC_KEY_SIZE_521 = 521, + HUKS_AES_KEY_SIZE_128 = 128, + HUKS_AES_KEY_SIZE_192 = 192, + HUKS_AES_KEY_SIZE_256 = 256, + HUKS_AES_KEY_SIZE_512 = 512, + HUKS_CURVE25519_KEY_SIZE_256 = 256, + HUKS_DH_KEY_SIZE_2048 = 2048, + HUKS_DH_KEY_SIZE_3072 = 3072, + HUKS_DH_KEY_SIZE_4096 = 4096, + /** + * @name HUKS_SM2_KEY_SIZE_256 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + HUKS_SM2_KEY_SIZE_256 = 256, + /** + * @name HUKS_SM4_KEY_SIZE_128 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + HUKS_SM4_KEY_SIZE_128 = 128 + } + /** + * @name HuksKeyAlg + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksKeyAlg { + HUKS_ALG_RSA = 1, + HUKS_ALG_ECC = 2, + HUKS_ALG_DSA = 3, + HUKS_ALG_AES = 20, + HUKS_ALG_HMAC = 50, + HUKS_ALG_HKDF = 51, + HUKS_ALG_PBKDF2 = 52, + HUKS_ALG_ECDH = 100, + HUKS_ALG_X25519 = 101, + HUKS_ALG_ED25519 = 102, + HUKS_ALG_DH = 103, + /** + * @name HUKS_ALG_SM2 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + HUKS_ALG_SM2 = 150, + /** + * @name HUKS_ALG_SM3 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + HUKS_ALG_SM3 = 151, + /** + * @name HUKS_ALG_SM4 + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + HUKS_ALG_SM4 = 152 + } + /** + * @name HuksUnwrapSuite + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksUnwrapSuite { + HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING = 1, + HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING = 2 + } + /** + * @name HuksKeyGenerateType + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksKeyGenerateType { + HUKS_KEY_GENERATE_TYPE_DEFAULT = 0, + HUKS_KEY_GENERATE_TYPE_DERIVE = 1, + HUKS_KEY_GENERATE_TYPE_AGREE = 2 + } + /** + * @name HuksKeyFlag + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksKeyFlag { + HUKS_KEY_FLAG_IMPORT_KEY = 1, + HUKS_KEY_FLAG_GENERATE_KEY = 2, + HUKS_KEY_FLAG_AGREE_KEY = 3, + HUKS_KEY_FLAG_DERIVE_KEY = 4 + } + /** + * @name HuksKeyStorageType + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksKeyStorageType { + HUKS_STORAGE_TEMP = 0, + HUKS_STORAGE_PERSISTENT = 1 + } + /** + * @name HuksImportKeyType + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksImportKeyType { + HUKS_KEY_TYPE_PUBLIC_KEY = 0, + HUKS_KEY_TYPE_PRIVATE_KEY = 1, + HUKS_KEY_TYPE_KEY_PAIR = 2 + } + /** + * @name HuksSendType + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksSendType { + HUKS_SEND_TYPE_ASYNC = 0, + HUKS_SEND_TYPE_SYNC = 1 + } + /** + * @name HuksTagType + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + declare enum HuksTagType { + HUKS_TAG_TYPE_INVALID = 0 << 28, + HUKS_TAG_TYPE_INT = 1 << 28, + HUKS_TAG_TYPE_UINT = 2 << 28, + HUKS_TAG_TYPE_ULONG = 3 << 28, + HUKS_TAG_TYPE_BOOL = 4 << 28, + HUKS_TAG_TYPE_BYTES = 5 << 28 + } + /** + * @name HuksTag + * @since 8 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksTag { + /* Invalid TAG */ + HUKS_TAG_INVALID = HuksTagType.HUKS_TAG_TYPE_INVALID | 0, + /* Base algrithom TAG: 1 - 200 */ + HUKS_TAG_ALGORITHM = HuksTagType.HUKS_TAG_TYPE_UINT | 1, + HUKS_TAG_PURPOSE = HuksTagType.HUKS_TAG_TYPE_UINT | 2, + HUKS_TAG_KEY_SIZE = HuksTagType.HUKS_TAG_TYPE_UINT | 3, + HUKS_TAG_DIGEST = HuksTagType.HUKS_TAG_TYPE_UINT | 4, + HUKS_TAG_PADDING = HuksTagType.HUKS_TAG_TYPE_UINT | 5, + HUKS_TAG_BLOCK_MODE = HuksTagType.HUKS_TAG_TYPE_UINT | 6, + HUKS_TAG_KEY_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 7, + HUKS_TAG_ASSOCIATED_DATA = HuksTagType.HUKS_TAG_TYPE_BYTES | 8, + HUKS_TAG_NONCE = HuksTagType.HUKS_TAG_TYPE_BYTES | 9, + HUKS_TAG_IV = HuksTagType.HUKS_TAG_TYPE_BYTES | 10, + /* Key derivation TAG */ + HUKS_TAG_INFO = HuksTagType.HUKS_TAG_TYPE_BYTES | 11, + HUKS_TAG_SALT = HuksTagType.HUKS_TAG_TYPE_BYTES | 12, + HUKS_TAG_PWD = HuksTagType.HUKS_TAG_TYPE_BYTES | 13, + HUKS_TAG_ITERATION = HuksTagType.HUKS_TAG_TYPE_UINT | 14, + HUKS_TAG_KEY_GENERATE_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 15, + HUKS_TAG_DERIVE_MAIN_KEY = HuksTagType.HUKS_TAG_TYPE_BYTES | 16, + HUKS_TAG_DERIVE_FACTOR = HuksTagType.HUKS_TAG_TYPE_BYTES | 17, + HUKS_TAG_DERIVE_ALG = HuksTagType.HUKS_TAG_TYPE_UINT | 18, + HUKS_TAG_AGREE_ALG = HuksTagType.HUKS_TAG_TYPE_UINT | 19, + HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS = HuksTagType.HUKS_TAG_TYPE_BOOL | 20, + HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS = HuksTagType.HUKS_TAG_TYPE_BYTES | 21, + HUKS_TAG_AGREE_PUBLIC_KEY = HuksTagType.HUKS_TAG_TYPE_BYTES | 22, + HUKS_TAG_KEY_ALIAS = HuksTagType.HUKS_TAG_TYPE_BYTES | 23, + HUKS_TAG_DERIVE_KEY_SIZE = HuksTagType.HUKS_TAG_TYPE_UINT | 24, + /** + * @name HUKS_TAG_IMPORT_KEY_TYPE + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + HUKS_TAG_IMPORT_KEY_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 25, + /** + * @name HUKS_TAG_UNWRAP_ALGORITHM_SUITE + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + HUKS_TAG_UNWRAP_ALGORITHM_SUITE = HuksTagType.HUKS_TAG_TYPE_UINT | 26, + /* + * Key authentication related TAG: 201 - 300 + * + * Start of validity + */ + HUKS_TAG_ACTIVE_DATETIME = HuksTagType.HUKS_TAG_TYPE_ULONG | 201, + /* Date when new "messages" should not be created. */ + HUKS_TAG_ORIGINATION_EXPIRE_DATETIME = HuksTagType.HUKS_TAG_TYPE_ULONG | 202, + /* Date when existing "messages" should not be used. */ + HUKS_TAG_USAGE_EXPIRE_DATETIME = HuksTagType.HUKS_TAG_TYPE_ULONG | 203, + /* Key creation time */ + HUKS_TAG_CREATION_DATETIME = HuksTagType.HUKS_TAG_TYPE_ULONG | 204, + /* Other authentication related TAG: 301 - 500 */ + HUKS_TAG_ALL_USERS = HuksTagType.HUKS_TAG_TYPE_BOOL | 301, + HUKS_TAG_USER_ID = HuksTagType.HUKS_TAG_TYPE_UINT | 302, + HUKS_TAG_NO_AUTH_REQUIRED = HuksTagType.HUKS_TAG_TYPE_BOOL | 303, + HUKS_TAG_USER_AUTH_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 304, + HUKS_TAG_AUTH_TIMEOUT = HuksTagType.HUKS_TAG_TYPE_UINT | 305, + HUKS_TAG_AUTH_TOKEN = HuksTagType.HUKS_TAG_TYPE_BYTES | 306, + /* Attestation related TAG: 501 - 600 */ + HUKS_TAG_ATTESTATION_CHALLENGE = HuksTagType.HUKS_TAG_TYPE_BYTES | 501, + HUKS_TAG_ATTESTATION_APPLICATION_ID = HuksTagType.HUKS_TAG_TYPE_BYTES | 502, + HUKS_TAG_ATTESTATION_ID_BRAND = HuksTagType.HUKS_TAG_TYPE_BYTES | 503, + HUKS_TAG_ATTESTATION_ID_DEVICE = HuksTagType.HUKS_TAG_TYPE_BYTES | 504, + HUKS_TAG_ATTESTATION_ID_PRODUCT = HuksTagType.HUKS_TAG_TYPE_BYTES | 505, + HUKS_TAG_ATTESTATION_ID_SERIAL = HuksTagType.HUKS_TAG_TYPE_BYTES | 506, + HUKS_TAG_ATTESTATION_ID_IMEI = HuksTagType.HUKS_TAG_TYPE_BYTES | 507, + HUKS_TAG_ATTESTATION_ID_MEID = HuksTagType.HUKS_TAG_TYPE_BYTES | 508, + HUKS_TAG_ATTESTATION_ID_MANUFACTURER = HuksTagType.HUKS_TAG_TYPE_BYTES | 509, + HUKS_TAG_ATTESTATION_ID_MODEL = HuksTagType.HUKS_TAG_TYPE_BYTES | 510, + HUKS_TAG_ATTESTATION_ID_ALIAS = HuksTagType.HUKS_TAG_TYPE_BYTES | 511, + HUKS_TAG_ATTESTATION_ID_SOCID = HuksTagType.HUKS_TAG_TYPE_BYTES | 512, + HUKS_TAG_ATTESTATION_ID_UDID = HuksTagType.HUKS_TAG_TYPE_BYTES | 513, + HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO = HuksTagType.HUKS_TAG_TYPE_BYTES | 514, + HUKS_TAG_ATTESTATION_ID_VERSION_INFO = HuksTagType.HUKS_TAG_TYPE_BYTES | 515, + /* + * Other reserved TAG: 601 - 1000 + * + * Extention TAG: 1001 - 9999 + */ + HUKS_TAG_IS_KEY_ALIAS = HuksTagType.HUKS_TAG_TYPE_BOOL | 1001, + HUKS_TAG_KEY_STORAGE_FLAG = HuksTagType.HUKS_TAG_TYPE_UINT | 1002, + HUKS_TAG_IS_ALLOWED_WRAP = HuksTagType.HUKS_TAG_TYPE_BOOL | 1003, + HUKS_TAG_KEY_WRAP_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 1004, + HUKS_TAG_KEY_AUTH_ID = HuksTagType.HUKS_TAG_TYPE_BYTES | 1005, + HUKS_TAG_KEY_ROLE = HuksTagType.HUKS_TAG_TYPE_UINT | 1006, + HUKS_TAG_KEY_FLAG = HuksTagType.HUKS_TAG_TYPE_UINT | 1007, + HUKS_TAG_IS_ASYNCHRONIZED = HuksTagType.HUKS_TAG_TYPE_UINT | 1008, + HUKS_TAG_SECURE_KEY_ALIAS = HuksTagType.HUKS_TAG_TYPE_BOOL | 1009, + HUKS_TAG_SECURE_KEY_UUID = HuksTagType.HUKS_TAG_TYPE_BYTES | 1010, + HUKS_TAG_KEY_DOMAIN = HuksTagType.HUKS_TAG_TYPE_UINT | 1011, + /* Inner-use TAG: 10001 - 10999 */ + HUKS_TAG_PROCESS_NAME = HuksTagType.HUKS_TAG_TYPE_BYTES | 10001, + HUKS_TAG_PACKAGE_NAME = HuksTagType.HUKS_TAG_TYPE_BYTES | 10002, + HUKS_TAG_ACCESS_TIME = HuksTagType.HUKS_TAG_TYPE_UINT | 10003, + HUKS_TAG_USES_TIME = HuksTagType.HUKS_TAG_TYPE_UINT | 10004, + HUKS_TAG_CRYPTO_CTX = HuksTagType.HUKS_TAG_TYPE_ULONG | 10005, + HUKS_TAG_KEY = HuksTagType.HUKS_TAG_TYPE_BYTES | 10006, + HUKS_TAG_KEY_VERSION = HuksTagType.HUKS_TAG_TYPE_UINT | 10007, + HUKS_TAG_PAYLOAD_LEN = HuksTagType.HUKS_TAG_TYPE_UINT | 10008, + HUKS_TAG_AE_TAG = HuksTagType.HUKS_TAG_TYPE_BYTES | 10009, + HUKS_TAG_IS_KEY_HANDLE = HuksTagType.HUKS_TAG_TYPE_ULONG | 10010, + /* Os version related TAG */ + HUKS_TAG_OS_VERSION = HuksTagType.HUKS_TAG_TYPE_UINT | 10101, + HUKS_TAG_OS_PATCHLEVEL = HuksTagType.HUKS_TAG_TYPE_UINT | 10102, + /* + * Reversed TAGs for SOTER: 11000 - 12000 + * + * Other TAGs: 20001 - N + * TAGs used for paramSetOut + */ + HUKS_TAG_SYMMETRIC_KEY_DATA = HuksTagType.HUKS_TAG_TYPE_BYTES | 20001, + HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA = HuksTagType.HUKS_TAG_TYPE_BYTES | 20002, + HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA = HuksTagType.HUKS_TAG_TYPE_BYTES | 20003 + } +} +export default huks; diff --git a/build-tools/api/@ohos.securityLabel.d.ts b/build-tools/api/@ohos.securityLabel.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..854db2bfdc18e03392f54267949175362b490c1f --- /dev/null +++ b/build-tools/api/@ohos.securityLabel.d.ts @@ -0,0 +1,51 @@ +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback } from "./basic"; +/** + * Provides securityLabel APIs + * + * @since 9 + * @syscap SystemCapability.FileManagement.File.FileIO + */ +declare namespace securityLabel { + type dataLevel = 's0' | 's1' | 's2' | 's3' | 's4'; + /** + * set the SecurityLabel. + * + * @since 9 + */ + function setSecurityLabel(path: string, type: dataLevel, callback: AsyncCallback): void; + function setSecurityLabel(path: string, type: dataLevel): Promise; + /** + * set the SecurityLabelSync. + * + * @since 9 + */ + function setSecurityLabelSync(path: string, type: dataLevel): void; + /** + * get the SecurityLabel. + * + * @since 9 + */ + function getSecurityLabel(path: string, callback: AsyncCallback): void; + function getSecurityLabel(path: string): Promise; + /** + * get the SecurityLabelSync. + * + * @since 9 + */ + function getSecurityLabelSync(path: string): string; +} +export default securityLabel; diff --git a/build-tools/api/@ohos.sensor.d.ts b/build-tools/api/@ohos.sensor.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1475cfc5b84f7ba3abaa31710e559272c2a1085c --- /dev/null +++ b/build-tools/api/@ohos.sensor.d.ts @@ -0,0 +1,1015 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from "./basic"; +/** + * This module provides the capability to subscribe to sensor data. + * + * @since 8 + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@ohos.sensor' + */ +declare namespace sensor { + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ACCELEROMETER}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_BAROMETER}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_GRAVITY}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_GYROSCOPE}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GYROSCOPE + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GYROSCOPE + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HALL}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HEART_RATE}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.HEALTH_DATA + * @since 8 + * @deprecated since 9 + * @useinstead SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE + */ + function on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback, options?: Options): void; + /** + * Subscribe to heart rate sensor data. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.READ_HEALTH_DATA + * @since 9 + */ + function on(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HUMIDITY}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 8 + * @deprecated since 9 + * @useinstead SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER + */ + function on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback: Callback, options?: Options): void; + /** + * Subscribe to linear accelerometer data. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 9 + */ + function on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ORIENTATION}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_PEDOMETER}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_PROXIMITY}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_WEAR_DETECTION}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback, options?: Options): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ACCELEROMETER}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_BAROMETER}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_GRAVITY}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_GYROSCOPE}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GYROSCOPE + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GYROSCOPE + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HALL}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HEART_RATE}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.HEART_RATE + * @since 8 + * @deprecated since 9 + * @useinstead SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE + */ + function once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback): void; + /** + * Subscribe to heart rate sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.READ_HEALTH_DATA + * @since 9 + */ + function once(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HUMIDITY}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELERATION + * @since 8 + * @deprecated since 9 + * @useinstead SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER + */ + function once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 9 + */ + function once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ORIENTATION}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_PEDOMETER}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_PROXIMITY}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback): void; + /** + * Subscribe to sensor data once. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_WEAR_DETECTION}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_ACCELEROMETER}. + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED}. + * @permission ohos.permission.ACCELEROMETER + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_BAROMETER}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_GRAVITY}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_GYROSCOPE}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GYROSCOPE + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GYROSCOPE + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_HALL}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_HEART_RATE}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.HEALTH_DATA + * @since 8 + * @deprecated since 9 + * @useinstead SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE + */ + function off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback): void; + /** + * Subscribe to sensor data, If the API is called multiple times, the last call takes effect. + * @param type Indicate the sensor type to listen for, {@code SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE}. + * @param options Optional parameters specifying the interval at which sensor data is reported, {@code Options}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.READ_HEALTH_DATA + * @since 9 + */ + function off(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_HUMIDITY}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 8 + * @deprecated since 9 + * @useinstead SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER + */ + function off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 9 + */ + function off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_ORIENTATION}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_PEDOMETER}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION}. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_PROXIMITY}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback): void; + /** + * Unsubscribe to sensor data. + * @param type Indicate the sensor type to unsubscribe, {@code SensorType.SENSOR_TYPE_ID_WEAR_DETECTION}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback): void; + /** + * Indicates sensor information. + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + interface Sensor { + sensorName: string; /**< Sensor name */ + venderName: string; /**< Sensor vendor */ + firmwareVersion: string; /**< Sensor firmware version */ + hardwareVersion: string; /**< Sensor hardware version */ + sensorTypeId: number; /**< Sensor type ID, {@code SensorType} */ + maxRange: number; /**< Maximum measurement range of the sensor */ + precision: number; /**< Sensor accuracy */ + power: number; /**< Sensor power */ + } + /** + * Obtains the sensor information of a specified type. + * @param type Indicate the sensor type, {@code SensorType}. + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function getSingleSensor(type: SensorType, callback: AsyncCallback): void; + function getSingleSensor(type: SensorType): Promise; + /** + * Obtains all sensor information on the device. + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + function getSensorLists(callback: AsyncCallback>): void; + function getSensorLists(): Promise>; + /** + * Indicates geomagnetic field data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface GeomagneticResponse { + x: number; + y: number; + z: number; + geomagneticDip: number; + deflectionAngle: number; + levelIntensity: number; + totalIntensity: number; + } + /** + * Indicates geographic location. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface LocationOptions { + latitude: number; + longitude: number; + altitude: number; + } + /** + * Implements the calculation of the geomagnetic field at a specific location on Earth. + * + * @param LocationOptions Indicates geographic location, {@code LocationOptions}. + * @param timeMillis Indicates the time at which the magnetic declination is to be obtained, in milliseconds + * since the Unix epoch. + * @return Returns the geomagnetic field data, {@code GeomagneticResponse}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback): void; + function getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise; + /** + * Obtains the altitude at which the device is located based on the current atmospheric pressure. + * + * @param seaPressure Indicates the sea level pressure, in hPa. + * @param currentPressure Indicates the atmospheric pressure measured by the barometer, in hPa. + * @return Returns the altitude in meters at which the device is located. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback): void; + function getAltitude(seaPressure: number, currentPressure: number): Promise; + /** + * Computes the geomagnetic inclination angle in radians from the inclination matrix. + * + * @param inclinationMatrix Indicates the inclination matrix. + * @return Returns the geomagnetic inclination angle in radians. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function getGeomagneticDip(inclinationMatrix: Array, callback: AsyncCallback): void; + function getGeomagneticDip(inclinationMatrix: Array): Promise; + /** + * Get the angle change between two rotation matrices + * + * @param currentRotationMatrix Indicates the current rotation matrix. + * @param preRotationMatrix Indicates the current rotation matrix. + * @return Returns the array of number(z, x and y) in which the angle variety. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function getAngleModify(currentRotationMatrix: Array, preRotationMatrix: Array, callback: AsyncCallback>): void; + function getAngleModify(currentRotationMatrix: Array, preRotationMatrix: Array): Promise>; + /** + * Convert rotation vector to rotation matrix. + * + * @param rotationVector Indicates the rotation vector. + * @return Returns the rotation matrix. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function createRotationMatrix(rotationVector: Array, callback: AsyncCallback>): void; + function createRotationMatrix(rotationVector: Array): Promise>; + /** + * Indicates the axis of the new coordinate system that coincides with the XY axis of the + * original coordinate system. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface CoordinatesOptions { + /** Indicates the axis of the new coordinate system that coincides with the X axis of + * the original coordinate system. + */ + x: number; + /** Indicates the axis of the new coordinate system that coincides with the Z axis of + * the original coordinate system. + */ + y: number; + } + /** + * Rotate the provided rotation matrix so that it can be represented in a different way + * Coordinate System + * @param inRotationVector Indicates the rotation matrix to be transformed. + * @param coordinates Indicates coordinate system guidance, {@code CoordinatesOptions}. + * @return Returns the transformed rotation matrix. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function transformCoordinateSystem(inRotationVector: Array, coordinates: CoordinatesOptions, callback: AsyncCallback>): void; + function transformCoordinateSystem(inRotationVector: Array, coordinates: CoordinatesOptions): Promise>; + /** + * convert a rotation vector to a normalized quaternion. + * + * @param rotationVector Indicates the rotation vector. + * @return Returns the normalized quaternion. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function createQuaternion(rotationVector: Array, callback: AsyncCallback>): void; + function createQuaternion(rotationVector: Array): Promise>; + /** + * Computes the device's orientation based on the rotation matrix. + * + * @param rotationMatrix Indicates the rotation matrix. + * @return Returns the array is the angle of rotation around the z, x, y axis. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function getDirection(rotationMatrix: Array, callback: AsyncCallback>): void; + function getDirection(rotationMatrix: Array): Promise>; + /** + * Indicates the response of rotation matrix. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface RotationMatrixResponse { + rotation: Array; + inclination: Array; + } + /** + * Calculate rotation matrix based on gravity vector and geomagnetic vector. + * + * @param gravity Indicates the gravity vector. + * @param geomagnetic Indicates the geomagnetic vector. + * @return Returns the rotation matrix, {@code RotationMatrixResponse}. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + function createRotationMatrix(gravity: Array, geomagnetic: Array, callback: AsyncCallback): void; + function createRotationMatrix(gravity: Array, geomagnetic: Array): Promise; + /** + * Subscribe to the sensor's optional parameters. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface Options { + interval?: number; /**< Sensor event reporting event interval */ + } + /** + * The type of number. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + enum SensorType { + SENSOR_TYPE_ID_ACCELEROMETER = 1, + SENSOR_TYPE_ID_GYROSCOPE = 2, + SENSOR_TYPE_ID_AMBIENT_LIGHT = 5, + SENSOR_TYPE_ID_MAGNETIC_FIELD = 6, + SENSOR_TYPE_ID_BAROMETER = 8, + SENSOR_TYPE_ID_HALL = 10, + SENSOR_TYPE_ID_PROXIMITY = 12, + SENSOR_TYPE_ID_HUMIDITY = 13, + SENSOR_TYPE_ID_ORIENTATION = 256, + SENSOR_TYPE_ID_GRAVITY = 257, + /** + * The type of number. + * @syscap SystemCapability.Sensors.Sensor + * @deprecated since 9 + * @useinstead SENSOR_TYPE_ID_LINEAR_ACCELEROMETER + */ + SENSOR_TYPE_ID_LINEAR_ACCELERATION = 258, + /** + * The type of number. + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + SENSOR_TYPE_ID_LINEAR_ACCELEROMETER = 258, + SENSOR_TYPE_ID_ROTATION_VECTOR = 259, + SENSOR_TYPE_ID_AMBIENT_TEMPERATURE = 260, + SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED = 261, + SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED = 263, + SENSOR_TYPE_ID_SIGNIFICANT_MOTION = 264, + SENSOR_TYPE_ID_PEDOMETER_DETECTION = 265, + SENSOR_TYPE_ID_PEDOMETER = 266, + /** + * The type of number. + * @syscap SystemCapability.Sensors.Sensor + * @deprecated since 9 + * @useinstead SENSOR_TYPE_ID_HEART_BEAT_RATE + */ + SENSOR_TYPE_ID_HEART_RATE = 278, + /** + * The type of number. + * @syscap SystemCapability.Sensors.Sensor + * @since 9 + */ + SENSOR_TYPE_ID_HEART_BEAT_RATE = 278, + SENSOR_TYPE_ID_WEAR_DETECTION = 280, + SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED = 281 /**< Uncalibrated acceleration sensor */ + } + /** + * The basic data structure of the sensor event. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface Response { + timestamp: number; /**< The timestamp of the reported sensor data */ + } + /** + * Acceleration sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface AccelerometerResponse extends Response { + x: number; /**< Acceleration x-axis component */ + y: number; /**< Acceleration y-axis component */ + z: number; /**< Acceleration z-axis component */ + } + /** + * Linear acceleration sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface LinearAccelerometerResponse extends Response { + x: number; /**< Linear acceleration x-axis component */ + y: number; /**< Linear acceleration y-axis component */ + z: number; /**< Linear acceleration z-axis component */ + } + /** + * Acceleration uncalibrated sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface AccelerometerUncalibratedResponse extends Response { + x: number; /**< Acceleration uncalibrated x-axis component */ + y: number; /**< Acceleration uncalibrated y-axis component */ + z: number; /**< Acceleration uncalibrated z-axis component */ + biasX: number; /**< Acceleration uncalibrated x-axis offset */ + biasY: number; /**< Acceleration uncalibrated y-axis offset */ + biasZ: number; /**< Acceleration uncalibrated z-axis offset */ + } + /** + * Gravity sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface GravityResponse extends Response { + x: number; /**< Gravity x-axis component */ + y: number; /**< Gravity y-axis component */ + z: number; /**< Gravity z-axis component */ + } + /** + * Orientation sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface OrientationResponse extends Response { + alpha: number; /**< The device rotates at an angle around the Z axis */ + beta: number; /**< The device rotates at an angle around the X axis */ + gamma: number; /**< The device rotates at an angle around the Y axis */ + } + /** + * Rotation vector sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface RotationVectorResponse extends Response { + x: number; /**< Rotation vector x-axis component */ + y: number; /**< Rotation vector y-axis component */ + z: number; /**< Rotation vector z-axis component */ + w: number; /**< Scalar quantity */ + } + /** + * Gyroscope sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface GyroscopeResponse extends Response { + x: number; /**< Gyroscope x-axis component */ + y: number; /**< Gyroscope y-axis component */ + z: number; /**< Gyroscope z-axis component */ + } + /** + * Gyroscope uncalibrated sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface GyroscopeUncalibratedResponse extends Response { + x: number; /**< Gyroscope uncalibrated x-axis component */ + y: number; /**< Gyroscope uncalibrated y-axis component */ + z: number; /**< Gyroscope uncalibrated z-axis component */ + biasX: number; /**< Gyroscope uncalibrated x-axis offset */ + biasY: number; /**< Gyroscope uncalibrated y-axis offset */ + biasZ: number; /**< Gyroscope uncalibrated z-axis offset */ + } + /** + * Significant motion sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface SignificantMotionResponse extends Response { + scalar: number; /**< The degree of significant motion */ + } + /** + * Proximity sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface ProximityResponse extends Response { + distance: number; /**< Indicates the degree of proximity, event 0 indicates proximity, while 1 indicates distance */ + } + /** + * Light sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface LightResponse extends Response { + intensity: number; /**< Indicates light intensity, in lux */ + } + /** + * Hall sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface HallResponse extends Response { + status: number; /**< Indicates hall status, event 0 indicates open, while 1 indicates close*/ + } + /** + * Magnetic field sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface MagneticFieldResponse extends Response { + x: number; /**< Magnetic field x-axis component */ + y: number; /**< Magnetic field y-axis component */ + z: number; /**< Magnetic field z-axis component */ + } + /** + * Magnetic field uncalibrated sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface MagneticFieldUncalibratedResponse extends Response { + x: number; /**< Magnetic field uncalibrated x-axis component */ + y: number; /**< Magnetic field uncalibrated y-axis component */ + z: number; /**< Magnetic field uncalibrated z-axis component */ + biasX: number; /**< Magnetic field uncalibrated x-axis offset */ + biasY: number; /**< Magnetic field uncalibrated y-axis offset */ + biasZ: number; /**< Magnetic field uncalibrated z-axis offset */ + } + /** + * Pedometer sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface PedometerResponse extends Response { + steps: number; /**< Indicates the number of steps */ + } + /** + * Humidity sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface HumidityResponse extends Response { + humidity: number; /**< Indicates the number of humidity */ + } + /** + * Pedometer detection sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface PedometerDetectionResponse extends Response { + scalar: number; /**< Indicates the pedometer detection status, 1 indicates that a walking action has occurred, and 0 indicates that no movement has occurred */ + } + /** + * Ambient temperature sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface AmbientTemperatureResponse extends Response { + temperature: number; /**< Indicates ambient temperature, in celsius */ + } + /** + * Barometer sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface BarometerResponse extends Response { + pressure: number; /**< Indicates the number of barometer, in pascal */ + } + /** + * Heart rate sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface HeartRateResponse extends Response { + heartRate: number; /**< Indicates the number of heart rate */ + } + /** + * Wear detection sensor event data. + * @syscap SystemCapability.Sensors.Sensor + * @since 8 + */ + interface WearDetectionResponse extends Response { + value: number; /**< Indicates the status of wear detection, 1 for wearing, 0 for wearing not */ + } +} +export default sensor; diff --git a/build-tools/api/@ohos.settings.d.ts b/build-tools/api/@ohos.settings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..33ce5583cf9b17e119601d1df6a2cebec4600f94 --- /dev/null +++ b/build-tools/api/@ohos.settings.d.ts @@ -0,0 +1,769 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import { DataAbilityHelper } from './ability/dataAbilityHelper'; +/** + * This module provides settings data access abilities. + * + * @since 7 + * @syscap SystemCapability.Applications.settings.Core + * @import import settings from '@ohos.settings' + * @permission N/A + */ +declare namespace settings { + /** + * Provides methods for setting time and date formats. + * + * @since 7 + */ + namespace date { + /** + * Indicates the date format. + * + *

The formats {@code mm/dd/yyyy}, {@code dd/mm/yyyy}, and {@code yyyy/mm/dd} are available. + * + * @since 7 + */ + const DATE_FORMAT: string; + /** + * Specifies whether the time is displayed in 12-hour or 24-hour format. + * + *

If the value is {@code 12}, the 12-hour format is used. If the value is {@code 24}, the 24-hour format + * is used. + * + * @since 7 + */ + const TIME_FORMAT: string; + /** + * Specifies whether the date, time, and time zone are automatically obtained from the Network + * Identity and Time Zone (NITZ). + * + *

If the value is {@code true}, the information is automatically obtained from NITZ. + * If the value is {@code false}, the information is not obtained from NITZ. + * + * @since 7 + */ + const AUTO_GAIN_TIME: string; + /** + * Specifies whether the time zone is automatically obtained from NITZ. + * + *

If the value is {@code true}, the information is automatically obtained from NITZ. If the value + * is {@code false}, the information is not obtained from NITZ. + * + * @since 7 + */ + const AUTO_GAIN_TIME_ZONE: string; + } + /** + * Provides methods for setting the display effect, including the font size, screen brightness, screen rotation, + * animation factor, and display color. + * + * @since 7 + */ + namespace display { + /** + * Indicates the scaling factor of fonts, which is a float number. + * + * @since 7 + */ + const FONT_SCALE: string; + /** + * Indicates the screen brightness. The value ranges from 0 to 255. + * + * @since 7 + */ + const SCREEN_BRIGHTNESS_STATUS: string; + /** + * Specifies whether automatic screen brightness adjustment is enabled. + * + *

If the value is {@code 1}, automatic adjustment is enabled. If the value is {@code 0}, automatic + * adjustment is disabled. + * + * @since 7 + */ + const AUTO_SCREEN_BRIGHTNESS: string; + /** + * Indicates the value of {@code AUTO_SCREEN_BRIGHTNESS} when automatic screen brightness adjustment is used. + * + * @since 7 + */ + const AUTO_SCREEN_BRIGHTNESS_MODE: number; + /** + * Indicates the value of {@code AUTO_SCREEN_BRIGHTNESS} when manual screen brightness adjustment is used. + * + * @since 7 + */ + const MANUAL_SCREEN_BRIGHTNESS_MODE: number; + /** + * Indicates the duration that the device waits before going to sleep after a period of inactivity, in + * milliseconds. + * + * @since 7 + */ + const SCREEN_OFF_TIMEOUT: string; + /** + * Indicates the screen rotation when no other policy is available. + * + *

This constant is invalid when auto-rotation is enabled. When auto-rotation is disabled, the following + * values are available: + * + *

    + *
  • {@code 0} - The screen rotates 0 degrees. + *
  • {@code 1} - The screen rotates 90 degrees. + *
  • {@code 2} - The screen rotates 180 degrees. + *
  • {@code 3} - The screen rotates 270 degrees. + *
+ * + * @since 7 + */ + const DEFAULT_SCREEN_ROTATION: string; + /** + * Indicates the scaling factor for the animation duration. + * + *

This affects the start delay and duration of all such animations. If the value is {@code 0}, + * the animation ends immediately. The default value is {@code 1}. + * + * @since 7 + */ + const ANIMATOR_DURATION_SCALE: string; + /** + * Indicates the scaling factor for transition animations. + * If the value is {@code 0}, transition animations are disabled. + * + * @since 7 + */ + const TRANSITION_ANIMATION_SCALE: string; + /** + * Indicates the scaling factor for normal window animations. + * If the value is {@code 0}, window animations are disabled. + * + * @since 7 + */ + const WINDOW_ANIMATION_SCALE: string; + /** + * Specifies whether display color inversion is enabled. + * + *

If the value is {@code 1}, display color inversion is enabled. If the value is {@code 0}, display color + * inversion is disabled. + * + * @since 7 + */ + const DISPLAY_INVERSION_STATUS: string; + } + /** + * Provides methods for setting general information about devices, including the device name, startup wizard, + * airplane mode, debugging information, accessibility feature switch, and touch exploration status. + * + * @since 7 + */ + namespace general { + /** + * Specifies whether the startup wizard has been run. + * + *

If the value is {@code 0}, the startup wizard has not been run. If the value is not {@code 0}, the startup + * wizard has been run. + * + * @since 7 + */ + const SETUP_WIZARD_FINISHED: string; + /** + * Specifies what happens after the user presses the call end button if the user is not in a call. + * + *

    + *
  • {@code 0} - Nothing happens. + *
  • {@code 1} - The home screen is displayed. + *
  • {@code 2} - The device enters the sleep state and the screen is locked. + *
  • {@code 3} - The home screen is displayed. If the user is already on the home screen, the device enters + * the sleep state. + *
+ * + * @since 7 + */ + const END_BUTTON_ACTION: string; + /** + * Specifies whether the accelerometer is used to change screen orientation, that is, whether auto-rotation is + * enabled. + * + *

The value {@code 1} indicates that the accelerometer is enabled by default, and {@code 0} indicates that + * the accelerometer is disabled by default. + * + * @since 7 + */ + const ACCELEROMETER_ROTATION_STATUS: string; + /** + * Specifies whether airplane mode is enabled. + * + *

If the value is {@code 1}, airplane mode is enabled. If the value is {@code 0}, airplane mode is disabled. + * + * @since 7 + */ + const AIRPLANE_MODE_STATUS: string; + /** + * Specifies whether the device is provisioned. + * + *

On a multi-user device with a single system user, the screen may be locked when the value is {@code true}. + * In addition, other abilities cannot be started on the system user unless they are marked to display over + * the screen lock. + * + * @since 7 + */ + const DEVICE_PROVISION_STATUS: string; + /** + * Specifies whether the hard disk controller (HDC) on USB devices is enabled. + * + *

If the value is {@code true}, the HDC is enabled. If the value is {@code false}, the HDC is disabled. + * + * @since 7 + */ + const HDC_STATUS: string; + /** + * Indicates the number of boot operations after the device is powered on. + * + * @since 7 + */ + const BOOT_COUNTING: string; + /** + * Specifies whether contact metadata synchronization is enabled. + * + *

If the value is {@code true}, synchronization is enabled. If the value is {@code false}, + * synchronization is disabled. + * + * @since 7 + */ + const CONTACT_METADATA_SYNC_STATUS: string; + /** + * Specifies whether developer options are enabled. + * + *

If the value is {@code true}, developer options are enabled. + * If the value is {@code false}, developer options are disabled. + * + * @since 7 + */ + const DEVELOPMENT_SETTINGS_STATUS: string; + /** + * Indicates the device name. + * + * @since 7 + */ + const DEVICE_NAME: string; + /** + * Specifies whether USB mass storage is enabled. + * + *

If the value is {@code true}, USB mass storage is enabled. + * If the value is {@code false}, USB mass storage is disabled. + * + * @since 7 + */ + const USB_STORAGE_STATUS: string; + /** + * Specifies whether the device waits for the debugger when starting an application to debug. + * + *

If the value is {@code 1}, the device waits for the debugger. + * If the value is {@code 0}, the system does not wait for the debugger, and so the application runs normally. + * + * @since 7 + */ + const DEBUGGER_WAITING: string; + /** + * Indicates the bundle name of the application to debug. + * + * @since 7 + */ + const DEBUG_APP_PACKAGE: string; + /** + * Specifies whether any accessibility feature is enabled. + * + *

If the value is {@code 1}, the accessibility feature is enabled. If the value is {@code 0}, the + * accessibility feature is disabled. + * + * @since 7 + */ + const ACCESSIBILITY_STATUS: string; + /** + * Indicates the list of accessibility features that have been activated. + * + * @since 7 + */ + const ACTIVATED_ACCESSIBILITY_SERVICES: string; + /** + * Indicates the default geographical location that can be used by the browser. Multiple geographical locations + * are separated by spaces. + * + * @since 7 + */ + const GEOLOCATION_ORIGINS_ALLOWED: string; + /** + * Specifies whether an application should attempt to skip all introductory hints at the first startup. This is + * intended for temporary users or users who are familiar with the environment. + * + *

If the value is {@code 1}, the application attempts to skip all introductory hints at the first startup. + * If the value is {@code 0}, the application does not skip introductory hints at the first startup. + * + * @since 7 + */ + const SKIP_USE_HINTS: string; + /** + * Indicates whether touch exploration is enabled. + * + *

If the value is {@code 1}, touch exploration is enabled. If the value is {@code 0}, touch exploration is + * disabled. + * + * @since 7 + */ + const TOUCH_EXPLORATION_STATUS: string; + } + /** + * Provides methods for setting information about input methods, including automatic capitalization, automatic + * punctuation, autocorrect, password presentation, input method engine, and input method subtypes. + * + * @since 7 + */ + namespace input { + /** + * Indicates the default input method and its ID. + * + * @since 7 + */ + const DEFAULT_INPUT_METHOD: string; + /** + * Indicates the default input method keyboard type and its ID. + * + * @since 7 + */ + const ACTIVATED_INPUT_METHOD_SUB_MODE: string; + /** + * Indicates the list of input methods that have been activated. + * + *

The list is a string that contains the IDs of activated input methods. The IDs are separated by colons + * (:), and keyboardTypes of an input method are separated by semicolons (;). An example format is + * {@code ima0:keyboardType0;keyboardType1;ima1:ima2:keyboardTypes0}. The type of imaID is ElementName, + * and the type of keyboard is int. + * + * @since 7 + */ + const ACTIVATED_INPUT_METHODS: string; + /** + * Specifies whether the input method selector is visible. + * + *

If the value is {@code 1}, the input method selector is visible. If the value is {@code 0}, the input + * method selector is invisible. + * + * @since 7 + */ + const SELECTOR_VISIBILITY_FOR_INPUT_METHOD: string; + /** + * Specifies whether automatic capitalization is enabled for the text editor. + * + *

If the value is {@code 0}, automatic capitalization is disabled. If the value {@code 1}, automatic + * capitalization is enabled. + * + * @since 7 + */ + const AUTO_CAPS_TEXT_INPUT: string; + /** + * Specifies whether automatic punctuation is enabled for the text editor. Automatic punctuation enables the + * text editor to convert two spaces into a period (.) and a space. + * + *

If the value is {@code 0}, automatic punctuation is disabled. If the value {@code 1}, automatic + * punctuation is enabled. + * + * @since 7 + */ + const AUTO_PUNCTUATE_TEXT_INPUT: string; + /** + * Specifies whether autocorrect is enabled for the text editor. Autocorrect enables the text editor to correct + * typos. + * + *

If the value is {@code 0}, autocorrect is disabled. If the value {@code 1}, autocorrect is enabled. + * + * @since 7 + */ + const AUTO_REPLACE_TEXT_INPUT: string; + /** + * Specifies whether password presentation is enabled in the text editor. Password presentation enables the + * text editor to show password characters when the user types them. + * + *

If the value is {@code 0}, password presentation is disabled. If the value {@code 1}, password + * presentation is enabled. + * + * @since 7 + */ + const SHOW_PASSWORD_TEXT_INPUT: string; + } + /** + * Provides methods for setting network information, including the data roaming status, HTTP proxy configurations, + * and preferred networks. + * + * @since 7 + */ + namespace network { + /** + * Specifies whether data roaming is enabled. + * + *

If the value is {@code true}, data roaming is enabled. If the value is {@code false}, + * data roaming is disabled. + * + * @since 7 + */ + const DATA_ROAMING_STATUS: string; + /** + * Indicates the host name and port number of the global HTTP proxy. + * The host name and port number are separated by a colon (:). + * + * @since 7 + */ + const HTTP_PROXY_CFG: string; + /** + * Indicates the user preferences of the network to use. + * + * @since 7 + */ + const NETWORK_PREFERENCE_USAGE: string; + } + /** + * Provides methods for setting the answering mode of incoming and outgoing calls. + * + * @since 7 + */ + namespace phone { + /** + * Specifies whether real-time text (RTT) calling is enabled. If enabled, incoming and outgoing calls are + * answered as RTT calls when supported by the device and carrier. If the value is {@code 1}, RTT calling is + * enabled. If the value is {@code 0}, RTT calling is disabled. + * + * @since 7 + */ + const RTT_CALLING_STATUS: string; + } + /** + * Provides methods for setting the sound effect, including the ringtone, dial tone, alarm sound, notification tone, + * and haptic feedback. + * + * @since 7 + */ + namespace sound { + /** + * Indicates whether the device vibrates when it is ringing for an incoming call. + * + *

This constant will be used by Phone and Settings applications. The value is of the boolean type. + * This constant affects only the scenario where the device rings for an incoming call. It does not affect + * any other application or scenario. + * + * @since 7 + */ + const VIBRATE_WHILE_RINGING: string; + /** + * Indicates the storage area of the system default alarm. + * + *

You can obtain the URI of the system default alarm. + * + * @since 7 + */ + const DEFAULT_ALARM_ALERT: string; + /** + * Indicates the type of the dual-tone multifrequency (DTMF) tone played when dialing. + * + *

The value {@code 0} indicates the normal short sound effect, and {@code 1} indicates the long sound + * effect. + * + * @since 7 + */ + const DTMF_TONE_TYPE_WHILE_DIALING: string; + /** + * Specifies whether the DTMF tone is played when dialing. + * + *

If the value is {@code 1}, the DTMF tone is played. If the value is {@code 0}, the DTMF tone is not + * played. + * + * @since 7 + */ + const DTMF_TONE_WHILE_DIALING: string; + /** + * Specifies which audio streams are affected by changes on the ringing mode and Do Not Disturb (DND) mode. + * + *

If you want a specific audio stream to be affected by changes of the ringing mode and DDN mode, set the + * corresponding bit to {@code 1}. + * + * @since 7 + */ + const AFFECTED_MODE_RINGER_STREAMS: string; + /** + * Specifies which audio streams are affected by the mute mode. + * + *

If you want a specific audio stream to remain muted in mute mode, set the corresponding bit to {@code 1}. + * + * @since 7 + */ + const AFFECTED_MUTE_STREAMS: string; + /** + * Indicates the storage area of the system default notification tone. + * + *

You can obtain the URI of the system default notification tone. + * + * @since 7 + */ + const DEFAULT_NOTIFICATION_SOUND: string; + /** + * Indicates the storage area of the system default ringtone. + * + *

You can obtain the URI of the system default ringtone. + * + * @since 7 + */ + const DEFAULT_RINGTONE: string; + /** + * Specifies whether the sound effects are enabled. + * + *

If the value is {@code 0}, the sound effects are disabled. If the value is {@code 1}, the sound effects + * are enabled. + * + * @since 7 + */ + const SOUND_EFFECTS_STATUS: string; + /** + * Specifies whether the device vibrates for an event. This parameter is used inside the system. + * + *

If the value is {@code 1}, the device vibrates for an event. If the value is {@code 0}, the device does + * not vibrate for an event. + * + * @since 7 + */ + const VIBRATE_STATUS: string; + /** + * Indicates whether the device enables haptic feedback. + * + *

The value is of the boolean type. + * + * @since 7 + */ + const HAPTIC_FEEDBACK_STATUS: string; + } + /** + * Provides methods for setting information about text-to-speech (TTS) conversion, including the pitch, speech rate, + * engine, and plug-ins. + * + * @since 7 + */ + namespace TTS { + /** + * Indicates the default pitch of the text-to-speech (TTS) engine. + * + *

100 = 1x. If the value is set to {@code 200}, the frequency is twice the normal sound frequency. + * + * @since 7 + */ + const DEFAULT_TTS_PITCH: string; + /** + * Indicates the default speech rate of the TTS engine. 100 = 1x. + * + * @since 7 + */ + const DEFAULT_TTS_RATE: string; + /** + * Indicates the default TTS engine. + * + * @since 7 + */ + const DEFAULT_TTS_SYNTH: string; + /** + * Indicates the list of activated plug-in packages used for TTS. Multiple plug-in packages are separated by + * spaces. + * + * @since 7 + */ + const ENABLED_TTS_PLUGINS: string; + } + /** + * Provides methods for setting radio network information, including information about Bluetooth, Wi-Fi, Near Field + * Communication (NFC), and the airplane mode. + * + * @since 7 + */ + namespace wireless { + /** + * Specifies whether the device can be discovered or connected by other devices through Bluetooth. + * + * If the value is {@code 0}, the device cannot be connected or discovered. If the value is {@code 1}, the + * device can be connected but cannot be discovered. If the value is {@code 2}, the device can be connected + * and discovered. + * + * @since 7 + */ + const BLUETOOTH_DISCOVER_ABILITY_STATUS: string; + /** + * Indicates the duration (in seconds) that the device can be discovered through Bluetooth. + * + *

After the duration expires, the device cannot be discovered through Bluetooth. + * + * @since 7 + */ + const BLUETOOTH_DISCOVER_TIMEOUT: string; + /** + * Indicates the list of radio signals to be disabled when airplane mode is enabled. Multiple radio + * signals are separated by commas (,). + * + *

    + *
  • {@code BLUETOOTH_RADIO} - Bluetooth is disabled in airplane mode. + *
  • {@code CELL_RADIO} - Cellular radio is disabled in airplane mode. + *
  • {@code NFC_RADIO} - NFC is disabled in airplane mode. + *
  • {@code WIFI_RADIO} - Wi-Fi is disabled in airplane mode. + *
+ * + * @since 7 + */ + const AIRPLANE_MODE_RADIOS: string; + /** + * Specifies whether Bluetooth is enabled. + * + *

If the value is {@code true}, Bluetooth is enabled. If the value is {@code false}, Bluetooth is disabled. + * + * @since 7 + */ + const BLUETOOTH_STATUS: string; + /** + * A constant of {@code AIRPLANE_MODE_RADIOS} to indicate that Bluetooth is disabled in airplane mode. + * + * @since 7 + */ + const BLUETOOTH_RADIO: string; + /** + * A constant of {@code AIRPLANE_MODE_RADIOS} to indicate that cellular radio is disabled in airplane mode. + * + * @since 7 + */ + const CELL_RADIO: string; + /** + * A constant of {@code AIRPLANE_MODE_RADIOS} to indicate that NFC is disabled in airplane mode. + * + * @since 7 + */ + const NFC_RADIO: string; + /** + * A constant of {@code AIRPLANE_MODE_RADIOS} to indicate that Wi-Fi is disabled in airplane mode. + * + * @since 7 + */ + const WIFI_RADIO: string; + /** + * Specifies whether the Wi-Fi configuration created by the application of the device owner should be + * locked down. + * + *

If the value is {@code true}, the Wi-Fi configuration should be locked down. + * If the value is {@code false}, the Wi-Fi configuration should not be locked down. + * + * @since 7 + */ + const OWNER_LOCKDOWN_WIFI_CFG: string; + /** + * Indicates the maximum number of attempts to obtain an IP address from the DHCP server. + * + * @since 7 + */ + const WIFI_DHCP_MAX_RETRY_COUNT: string; + /** + * Indicates the maximum duration to hold a wake lock when waiting for the mobile data connection to + * establish after the Wi-Fi connection is disconnected. + * + * @since 7 + */ + const WIFI_TO_MOBILE_DATA_AWAKE_TIMEOUT: string; + /** + * Specifies whether Wi-Fi is enabled. + * + *

If the value is {@code true}, Wi-Fi is enabled. If the value is {@code false}, Wi-Fi is disabled. + * + * @since 7 + */ + const WIFI_STATUS: string; + /** + * Specifies whether Wi-Fi watchdog is enabled. + * + *

If the value is {@code true}, Wi-Fi watchdog is enabled. + * If the value is {@code false}, Wi-Fi watchdog is disabled. + * + * @since 7 + */ + const WIFI_WATCHDOG_STATUS: string; + } + /** + * Constructs a URI for a specific name-value pair for monitoring data of the ability that uses the Data + * template. + * + * @param name Indicates the name of the setting to set. + * @return Returns the corresponding URI; returns {@code null} if the URI does not exist. + * @since 7 + */ + function getURI(name: string, callback: AsyncCallback): void; + function getURI(name: string): Promise; + /** + * Obtains the value of a specified character string in the database. + * + * @param dataAbilityHelper Indicates the {@link ohos.aafwk.ability.DataAbilityHelper} used to access + * the database. + * @param name Indicates the name of the character string. + * @return Returns the value of the character string in the table if any is found; returns {@code null} + * otherwise. + * @since 7 + */ + function getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback): void; + function getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise; + /** + * Enables or disables airplane mode. + * + * @param enable Specifies whether to enable airplane mode. The value {@code true} means to enable airplane + * mode, and {@code false} means to disable airplane mode. + * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. + * @since 7 + */ + function enableAirplaneMode(enable: boolean, callback: AsyncCallback): void; + function enableAirplaneMode(enable: boolean): Promise; + /** + * Checks whether a specified application can show as float window. + * + * @param context Indicates the application context. + * @return Returns {@code true} if the application can draw over other applications; returns {@code false} + * otherwise. + * @since 7 + */ + function canShowFloating(callback: AsyncCallback): void; + function canShowFloating(): Promise; + /** + * get settingsdata uri(synchronization method) + * @since 8 + * @param name Indicates the name of the setting to set. + * @return Return settingsdata uri. + */ + function getUriSync(name: string): string; + /** + * get value from settingsdata(synchronization method) + * @since 8 + * @param dataAbilityHelper Indicates dataAbilityHelper instance + * @param name Indicates the name of the character string. + * @param defValue Indicates the default value of the character string. + * @return settingsdata value + */ + function getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string; + /** + * set settingsdata value(synchronization method) + * @need permission ohos.permission.WRITE_SYSTEM_SETTING + * @since 8 + * @param dataAbilityHelper Indicates dataAbilityHelper instance + * @param name Indicates the name of the character string. + * @param value Indicates the value of the character string. + * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. + */ + function setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean; +} +export default settings; diff --git a/build-tools/api/@ohos.statfs.d.ts b/build-tools/api/@ohos.statfs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e999e3fd2b4b020f6a2928ad31590ef78c575ec7 --- /dev/null +++ b/build-tools/api/@ohos.statfs.d.ts @@ -0,0 +1,38 @@ +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback } from "./basic"; +/** + * Provides filesystem statistics APIs + * + * @since 8 + * @syscap SystemCapability.FileManagement.File.FileIO + */ +declare namespace Statfs { + /** + * Get the number of free bytes on the specified path. + * + * @since 8 + */ + function getFreeBytes(path: string, callback: AsyncCallback): void; + function getFreeBytes(path: string): Promise; + /** + * Get the total number of bytes of the specified path. + * + * @since 8 + */ + function getTotalBytes(path: string, callback: AsyncCallback): void; + function getTotalBytes(path: string): Promise; +} +export default Statfs; diff --git a/build-tools/api/@ohos.systemTime.d.ts b/build-tools/api/@ohos.systemTime.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cde6b3b8dcf727db3790bf6f5614f731d9362d48 --- /dev/null +++ b/build-tools/api/@ohos.systemTime.d.ts @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * System time and timezone. + * @since 7 + * @syscap SystemCapability.MiscServices.Time + * @import systemTime from '@ohos.systemTime'; + */ +declare namespace systemTime { + /** + * Sets the system time. + * @permission ohos.permission.SET_TIME + * @param time Target time stamp (ms) + * @since 7 + */ + function setTime(time: number, callback: AsyncCallback): void; + function setTime(time: number): Promise; + /** + * Obtains the number of milliseconds that have elapsed since the Unix epoch. + * @since 8 + */ + function getCurrentTime(isNano?: boolean, callback: AsyncCallback): void; + function getCurrentTime(isNano?: boolean): Promise; + /** + * Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. + * @since 8 + */ + function getRealActiveTime(isNano?: boolean, callback: AsyncCallback): void; + function getRealActiveTime(isNano?: boolean): Promise; + /** + * Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time. + * @since 8 + */ + function getRealTime(isNano?: boolean, callback: AsyncCallback): void; + function getRealTime(isNano?: boolean): Promise; + /** + * Sets the system time. + * @permission ohos.permission.SET_TIME + * @param date The target date + * @since 7 + */ + function setDate(date: Date, callback: AsyncCallback): void; + function setDate(date: Date): Promise; + /** + * Obtains the system date. + * @since 8 + */ + function getDate(callback: AsyncCallback): void; + function getDate(): Promise; + /** + * Sets the system time zone. + * @permission ohos.permission.SET_TIME_ZONE + * @param timezone The system time zone + * @since 7 + */ + function setTimezone(timezone: string, callback: AsyncCallback): void; + function setTimezone(timezone: string): Promise; + /** + * Obtains the system time zone. + * @since 8 + */ + function getTimezone(callback: AsyncCallback): void; + function getTimezone(): Promise; +} +export default systemTime; diff --git a/build-tools/api/@ohos.telephony.call.d.ts b/build-tools/api/@ohos.telephony.call.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3ed160b552df7f8a1a8c8f5cd354efc2a7122b7 --- /dev/null +++ b/build-tools/api/@ohos.telephony.call.d.ts @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from "./basic"; +/** + * Provides methods related to call management. + * + * @since 6 + * @syscap SystemCapability.Telephony.CallManager + */ +declare namespace call { + /** + * Makes a call. + * + * @param phoneNumber Indicates the called number. + * @param options Indicates additional information carried in the call. + * @param callback Returns {@code true} if the call request is successful; returns {@code false} otherwise. + * Note that the value {@code true} indicates only the successful processing of the request; it does not mean + * that the call is or can be connected. + * @permission ohos.permission.PLACE_CALL + */ + function dial(phoneNumber: string, callback: AsyncCallback): void; + function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback): void; + function dial(phoneNumber: string, options?: DialOptions): Promise; + /** + * Go to the dial screen and the called number is displayed. + * + * @param phoneNumber Indicates the called number. + * @syscap SystemCapability.Applications.Contacts + * @since 7 + */ + function makeCall(phoneNumber: string, callback: AsyncCallback): void; + function makeCall(phoneNumber: string): Promise; + /** + * Checks whether a call is ongoing. + * + * @param callback Returns {@code true} if at least one call is not in the {@link CallState#CALL_STATE_IDLE} + * state; returns {@code false} otherwise. + */ + function hasCall(callback: AsyncCallback): void; + function hasCall(): Promise; + /** + * Obtains the call state. + * + *

If an incoming call is ringing or waiting, the system returns {@code CallState#CALL_STATE_RINGING}. + * If at least one call is in the active, hold, or dialing state, the system returns + * {@code CallState#CALL_STATE_OFFHOOK}. + * In other cases, the system returns {@code CallState#CALL_STATE_IDLE}. + * + * @param callback Returns the call state. + */ + function getCallState(callback: AsyncCallback): void; + function getCallState(): Promise; + /** + * Checks whether a device supports voice calls. + * + *

The system checks whether the device has the capability to initiate a circuit switching (CS) or IP multimedia + * subsystem domain (IMS) call on a telephone service network. If the device supports only packet switching + * (even if the device supports OTT calls), {@code false} is returned. + * + * @return Returns {@code true} if the device supports voice calls; returns {@code false} otherwise. + * @since 7 + */ + function hasVoiceCapability(): boolean; + /** + * Checks whether a phone number is on the emergency number list. + * + * @param phoneNumber Indicates the phone number to check. + * @param callback Returns {@code true} if the phone number is on the emergency number list; + * returns {@code false} otherwise. + * @since 7 + */ + function isEmergencyPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; + function isEmergencyPhoneNumber(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback): void; + function isEmergencyPhoneNumber(phoneNumber: string, options?: EmergencyNumberOptions): Promise; + /** + * Formats a phone number according to the Chinese Telephone Code Plan. Before the formatting, + * a phone number is in the format of country code (if any) + 3-digit service provider code + * + 4-digit area code + 4-digit subscriber number. After the formatting, + * each part is separated by a space. + * + * @param phoneNumber Indicates the phone number to format. + * @param callback Returns the phone number after being formatted; returns an empty string + * if the input phone number is invalid. + * @since 7 + */ + function formatPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; + function formatPhoneNumber(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback): void; + function formatPhoneNumber(phoneNumber: string, options?: NumberFormatOptions): Promise; + /** + * Formats a phone number into an E.164 representation. + * + * @param phoneNumber Indicates the phone number to format. + * @param countryCode Indicates a two-digit country code defined in ISO 3166-1. + * @param callback Returns an E.164 number; returns an empty string if the input phone number is invalid. + * @since 7 + */ + function formatPhoneNumberToE164(phoneNumber: string, countryCode: string, callback: AsyncCallback): void; + function formatPhoneNumberToE164(phoneNumber: string, countryCode: string): Promise; + export enum CallState { + /** + * Indicates an invalid state, which is used when the call state fails to be obtained. + */ + CALL_STATE_UNKNOWN = -1, + /** + * Indicates that there is no ongoing call. + */ + CALL_STATE_IDLE = 0, + /** + * Indicates that an incoming call is ringing or waiting. + */ + CALL_STATE_RINGING = 1, + /** + * Indicates that a least one call is in the dialing, active, or hold state, and there is no new incoming call + * ringing or waiting. + */ + CALL_STATE_OFFHOOK = 2 + } + export interface DialOptions { + /** + * boolean means whether the call to be made is a video call. The value {@code false} indicates a voice call. + */ + extras?: boolean; + } + /** + * @since 7 + */ + export interface EmergencyNumberOptions { + slotId?: number; + } + /** + * @since 7 + */ + export interface NumberFormatOptions { + countryCode?: string; + } +} +export default call; diff --git a/build-tools/api/@ohos.telephony.data.d.ts b/build-tools/api/@ohos.telephony.data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..029e2713d1565bac1fb27ffbecafecdd1ec28373 --- /dev/null +++ b/build-tools/api/@ohos.telephony.data.d.ts @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from "./basic"; +/** + * Provides methods related to cellular data services. + * + * @since 7 + * @syscap SystemCapability.Telephony.CellularData + */ +declare namespace data { + /** + * Checks whether cellular data services are enabled. + * + * @return Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getDefaultCellularDataSlotId(callback: AsyncCallback): void; + function getDefaultCellularDataSlotId(): Promise; + /** + * Indicates that there is no uplink or downlink data. + * + *

It is a return value of service state query of cellular data services. + */ + function getCellularDataFlowType(callback: AsyncCallback): void; + function getCellularDataFlowType(): Promise; + /** + * Obtains the connection state of the PS domain. + * + * @param slotId Indicates the ID of a card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback Returns the connection state, which can be any of the following: + *

    + *
  • {@code DataConnectState#DATA_STATE_UNKNOWN} + *
  • {@code DataConnectState#DATA_STATE_DISCONNECTED} + *
  • {@code DataConnectState#DATA_STATE_CONNECTING} + *
  • {@code DataConnectState#DATA_STATE_CONNECTED} + *
  • {@code DataConnectState#DATA_STATE_SUSPENDED} + *
+ */ + function getCellularDataState(callback: AsyncCallback): void; + function getCellularDataState(): Promise; + /** + * Checks whether cellular data services are enabled. + * + * @param callback Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function isCellularDataEnabled(callback: AsyncCallback): void; + function isCellularDataEnabled(): Promise; + /** + * Checks whether roaming is enabled for cellular data services. + * + * @param slotId Indicates the ID of a card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback Returns {@code true} if roaming is enabled for cellular data services; returns {@code false} otherwise. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback): void; + function isCellularDataRoamingEnabled(slotId: number): Promise; + /** + * Describes the cellular data flow type. + */ + export enum DataFlowType { + /** + * Indicates that there is no uplink or downlink data. + */ + DATA_FLOW_TYPE_NONE = 0, + /** + * Indicates that there is only downlink data. + */ + DATA_FLOW_TYPE_DOWN = 1, + /** + * Indicates that there is only uplink data. + */ + DATA_FLOW_TYPE_UP = 2, + /** + * Indicates that there is uplink and downlink data. + */ + DATA_FLOW_TYPE_UP_DOWN = 3, + /** + * Indicates that there is no uplink or downlink data, and the bottom-layer link is in the dormant state. + */ + DATA_FLOW_TYPE_DORMANT = 4 + } + /** + * Describes the cellular data link connection state. + */ + export enum DataConnectState { + /** + * Indicates that a cellular data link is unknown. + */ + DATA_STATE_UNKNOWN = -1, + /** + * Indicates that a cellular data link is disconnected. + */ + DATA_STATE_DISCONNECTED = 0, + /** + * Indicates that a cellular data link is being connected. + */ + DATA_STATE_CONNECTING = 1, + /** + * Indicates that a cellular data link is connected. + */ + DATA_STATE_CONNECTED = 2, + /** + * Indicates that a cellular data link is suspended. + */ + DATA_STATE_SUSPENDED = 3 + } +} +export default data; diff --git a/build-tools/api/@ohos.telephony.observer.d.ts b/build-tools/api/@ohos.telephony.observer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b7a6d6cd116fd645494366c6c6a4bc8735b073d --- /dev/null +++ b/build-tools/api/@ohos.telephony.observer.d.ts @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Callback } from "./basic"; +import radio from "./@ohos.telephony.radio"; +import data from "./@ohos.telephony.data"; +import call from "./@ohos.telephony.call"; +import sim from "./@ohos.telephony.sim"; +/** + * Monitors telephony state updates of a device, including updates of the network state, + * signal strength, call state, the data link connection state and others. + * + * @since 6 + * @syscap SystemCapability.Telephony.StateRegistry + */ +declare namespace observer { + type NetworkState = radio.NetworkState; + type SignalInformation = radio.SignalInformation; + type DataConnectState = data.DataConnectState; + type RatType = radio.RadioTechnology; + type DataFlowType = data.DataFlowType; + type CallState = call.CallState; + type CardType = sim.CardType; + type SimState = sim.SimState; + /** + * Called when the network state corresponding to a monitored {@code slotId} updates. + * + * @param type networkStateChange + * @param options including slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback including an instance of the {@code NetworkState} class. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function on(type: 'networkStateChange', callback: Callback): void; + function on(type: 'networkStateChange', options: { + slotId: number; + }, callback: Callback): void; + function off(type: 'networkStateChange', callback?: Callback): void; + /** + * Called when the signal strength corresponding to a monitored {@code slotId} updates. + * + * @param type signalInfoChange + * @param options including slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback including an array of instances of the classes derived from {@link SignalInformation}. + */ + function on(type: 'signalInfoChange', callback: Callback>): void; + function on(type: 'signalInfoChange', options: { + slotId: number; + }, callback: Callback>): void; + function off(type: 'signalInfoChange', callback?: Callback>): void; + /** + * Called when the cellular data link connection state updates. + * + * @param type cellularDataConnectionStateChange + * @param options including slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback including state Indicates the cellular data link connection state, + * and networkType Indicates the radio access technology for cellular data services. + * @since 7 + */ + function on(type: 'cellularDataConnectionStateChange', callback: Callback<{ + state: DataConnectState; + network: RatType; + }>): void; + function on(type: 'cellularDataConnectionStateChange', options: { + slotId: number; + }, callback: Callback<{ + state: DataConnectState; + network: RatType; + }>): void; + /** + * @since 7 + */ + function off(type: 'cellularDataConnectionStateChange', callback?: Callback<{ + state: DataConnectState; + network: RatType; + }>): void; + /** + * Called when the uplink and downlink data flow state of cellular data services updates. + * + * @param type cellularDataFlowChange + * @param options including slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback including the cellular data flow state. + * @since 7 + */ + function on(type: 'cellularDataFlowChange', callback: Callback): void; + function on(type: 'cellularDataFlowChange', options: { + slotId: number; + }, callback: Callback): void; + /** + * @since 7 + */ + function off(type: 'cellularDataFlowChange', callback?: Callback): void; + /** + * Receives a call state change. This callback is invoked when the call state of a specified card updates + * and the observer is added to monitor the updates. + * + * @param type callStateChange + * @param options including slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback including state Indicates the call state, and number Indicates the called number. + * The value of number is an empty string if the application does not have + * the ohos.permission.READ_CALL_LOG permission. + */ + function on(type: 'callStateChange', callback: Callback<{ + state: CallState; + number: string; + }>): void; + function on(type: 'callStateChange', options: { + slotId: number; + }, callback: Callback<{ + state: CallState; + number: string; + }>): void; + function off(type: 'callStateChange', callback?: Callback<{ + state: CallState; + number: string; + }>): void; + /** + * Receives a sim state change. This callback is invoked when the sim state of a specified card updates + * and the observer is added to monitor the updates. + * + * @param type simStateChange + * @param options including slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback including state Indicates the sim state, and reason Indicates the cause of the change. + * The value of reason is an empty string if the application does not have + * @since 7 + */ + function on(type: 'simStateChange', callback: Callback): void; + function on(type: 'simStateChange', options: { + slotId: number; + }, callback: Callback): void; + /** + * @since 7 + */ + function off(type: 'simStateChange', callback?: Callback): void; + /** + * @since 7 + */ + export interface SimStateData { + type: CardType; + state: SimState; + /** + * @since 8 + */ + reason: LockReason; + } + /** + * @since 8 + */ + export enum LockReason { + SIM_NONE, + SIM_PIN, + SIM_PUK, + SIM_PN_PIN, + SIM_PN_PUK, + SIM_PU_PIN, + SIM_PU_PUK, + SIM_PP_PIN, + SIM_PP_PUK, + SIM_PC_PIN, + SIM_PC_PUK, + SIM_SIM_PIN, + SIM_SIM_PUK + } +} +export default observer; diff --git a/build-tools/api/@ohos.telephony.radio.d.ts b/build-tools/api/@ohos.telephony.radio.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf13a6f6a0d66db364f829988232bb6c33c63f91 --- /dev/null +++ b/build-tools/api/@ohos.telephony.radio.d.ts @@ -0,0 +1,372 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from "./basic"; +/** + * Provides interfaces for applications to obtain the network state, cell information, signal information, + * and device ID of the wireless cellular network (WCN), and provides a callback registration mechanism to + * listen for changes of the network, cell, and signal status of the WCN. + * + * @since 6 + * @syscap SystemCapability.Telephony.CoreService + */ +declare namespace radio { + /** + * Obtains radio access technology (RAT) of the registered network. The system + * returns RAT of the packet service (PS) and circuit service (CS) domain. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns an integer indicating the RAT in use. The values are as follows: + *
    + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_UNKNOWN} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_GSM} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_1XRTT} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_WCDMA} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_HSPA} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_HSPAP} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_TD_SCDMA} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_EVDO} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_EHRPD} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_LTE} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_LTE_CA} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_IWLAN} + *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_NR} + *
+ * @permission ohos.permission.GET_NETWORK_INFO + */ + function getRadioTech(slotId: number, callback: AsyncCallback<{ + psRadioTech: RadioTechnology; + csRadioTech: RadioTechnology; + }>): void; + function getRadioTech(slotId: number): Promise<{ + psRadioTech: RadioTechnology; + csRadioTech: RadioTechnology; + }>; + /** + * Obtains the network state of the registered network. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns a {@code NetworkState} object. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getNetworkState(callback: AsyncCallback): void; + function getNetworkState(slotId: number, callback: AsyncCallback): void; + function getNetworkState(slotId?: number): Promise; + /** + * Obtains the network search mode of the SIM card in a specified slot. + * + * @param slotId Indicates the ID of the SIM card slot. + * @param callback Returns the network search mode of the SIM card. Available values are as follows: + *
    + *
  • {@link NetworkSelectionMode#NETWORK_SELECTION_UNKNOWN} + *
  • {@link NetworkSelectionMode#NETWORK_SELECTION_AUTOMATIC} + *
  • {@link NetworkSelectionMode#NETWORK_SELECTION_MANUAL} + *
      + */ + function getNetworkSelectionMode(slotId: number, callback: AsyncCallback): void; + function getNetworkSelectionMode(slotId: number): Promise; + /** + * Obtains the ISO-defined country code of the country where the registered network is deployed. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the country code defined in ISO 3166-2; + * returns an empty string if the device is not registered with any network. + * @since 7 + */ + function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback): void; + function getISOCountryCodeForNetwork(slotId: number): Promise; + /** + * Obtains the index number of the card slot where the primary card is located if multiple SIM cards are inserted. + * + *

      The primary card is the SIM card inserted in the card slot that uses data services by default. + * + * @param callback Returns the index number of the primary card slot. + * @since 7 + */ + function getPrimarySlotId(callback: AsyncCallback): void; + function getPrimarySlotId(): Promise; + /** + * Obtains the list of signal strength information of the registered network corresponding to a specified SIM card. + * + * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number + * supported by the device. + * @param callback Returns the instance list of the child classes derived from {@link SignalInformation}. + * @since 7 + */ + function getSignalInformation(slotId: number, callback: AsyncCallback>): void; + function getSignalInformation(slotId: number): Promise>; + /** + * Checks whether the device supports 5G New Radio (NR). + * + * @return Returns {@code true} if the device supports 5G NR; returns {@code false} otherwise. + * @deprecated Advised to use isNrSupported(slotId: number) instead. + * @since 7 + */ + function isNrSupported(): boolean; + /** + * Checks whether the device supports 5G New Radio (NR) by according card slot. + * + * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number + * supported by the device. + * @return Returns {@code true} if the device supports 5G NR; returns {@code false} otherwise. + * @since 8 + */ + function isNrSupported(slotId: number): boolean; + /** + * Checks whether the radio service is enabled. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @permission ohos.permission.GET_NETWORK_INFO + * @since 7 + */ + function isRadioOn(callback: AsyncCallback): void; + function isRadioOn(slotId: number, callback: AsyncCallback): void; + function isRadioOn(slotId?: number): Promise; + /** + * @since 7 + */ + function getOperatorName(slotId: number, callback: AsyncCallback): void; + function getOperatorName(slotId: number): Promise; + /** + * Describes the radio access technology. + */ + export enum RadioTechnology { + /** + * Indicates unknown radio access technology (RAT). + */ + RADIO_TECHNOLOGY_UNKNOWN = 0, + /** + * Indicates that RAT is global system for mobile communications (GSM), including GSM, general packet + * radio system (GPRS), and enhanced data rates for GSM evolution (EDGE). + */ + RADIO_TECHNOLOGY_GSM = 1, + /** + * Indicates that RAT is code division multiple access (CDMA), including Interim Standard 95 (IS95) and + * Single-Carrier Radio Transmission Technology (1xRTT). + */ + RADIO_TECHNOLOGY_1XRTT = 2, + /** + * Indicates that RAT is wideband code division multiple address (WCDMA). + */ + RADIO_TECHNOLOGY_WCDMA = 3, + /** + * Indicates that RAT is high-speed packet access (HSPA), including HSPA, high-speed downlink packet + * access (HSDPA), and high-speed uplink packet access (HSUPA). + */ + RADIO_TECHNOLOGY_HSPA = 4, + /** + * Indicates that RAT is evolved high-speed packet access (HSPA+), including HSPA+ and dual-carrier + * HSPA+ (DC-HSPA+). + */ + RADIO_TECHNOLOGY_HSPAP = 5, + /** + * Indicates that RAT is time division-synchronous code division multiple access (TD-SCDMA). + */ + RADIO_TECHNOLOGY_TD_SCDMA = 6, + /** + * Indicates that RAT is evolution data only (EVDO), including EVDO Rev.0, EVDO Rev.A, and EVDO Rev.B. + */ + RADIO_TECHNOLOGY_EVDO = 7, + /** + * Indicates that RAT is evolved high rate packet data (EHRPD). + */ + RADIO_TECHNOLOGY_EHRPD = 8, + /** + * Indicates that RAT is long term evolution (LTE). + */ + RADIO_TECHNOLOGY_LTE = 9, + /** + * Indicates that RAT is LTE carrier aggregation (LTE-CA). + */ + RADIO_TECHNOLOGY_LTE_CA = 10, + /** + * Indicates that RAT is interworking WLAN (I-WLAN). + */ + RADIO_TECHNOLOGY_IWLAN = 11, + /** + * Indicates that RAT is 5G new radio (NR). + */ + RADIO_TECHNOLOGY_NR = 12 + } + export interface SignalInformation { + /** + * Obtains the network type corresponding to the signal. + */ + signalType: NetworkType; + /** + * Obtains the signal level of the current network. + */ + signalLevel: number; + } + /** + * Describes the network type. + */ + export enum NetworkType { + /** + * Indicates unknown network type. + */ + NETWORK_TYPE_UNKNOWN, + /** + * Indicates that the network type is GSM. + */ + NETWORK_TYPE_GSM, + /** + * Indicates that the network type is CDMA. + */ + NETWORK_TYPE_CDMA, + /** + * Indicates that the network type is WCDMA. + */ + NETWORK_TYPE_WCDMA, + /** + * Indicates that the network type is TD-SCDMA. + */ + NETWORK_TYPE_TDSCDMA, + /** + * Indicates that the network type is LTE. + */ + NETWORK_TYPE_LTE, + /** + * Indicates that the network type is 5G NR. + */ + NETWORK_TYPE_NR + } + /** + * Describes the network registration state. + */ + export interface NetworkState { + /** + * Obtains the operator name in the long alphanumeric format of the registered network. + * + * @return Returns the operator name in the long alphanumeric format as a string; + * returns an empty string if no operator name is obtained. + */ + longOperatorName: string; + /** + * Obtains the operator name in the short alphanumeric format of the registered network. + * + * @return Returns the operator name in the short alphanumeric format as a string; + * returns an empty string if no operator name is obtained. + */ + shortOperatorName: string; + /** + * Obtains the PLMN code of the registered network. + * + * @return Returns the PLMN code as a string; returns an empty string if no operator name is obtained. + */ + plmnNumeric: string; + /** + * Checks whether the device is roaming. + * + * @return Returns {@code true} if the device is roaming; returns {@code false} otherwise. + */ + isRoaming: boolean; + /** + * Obtains the network registration status of the device. + * + * @return Returns the network registration status {@code RegState}. + */ + regState: RegState; + /** + * Obtains the radio Access technology after config conversion. + * + * @return Returns the radio Access technology {@code RadioTechnology}. + * @since 8 + */ + cfgTech: RadioTechnology; + /** + * Obtains the NSA network registration status of the device. + * + * @return Returns the NSA network registration status {@code NsaState}. + */ + nsaState: NsaState; + /** + * Obtains the status of CA. + * + * @return Returns {@code true} if CA is actived; returns {@code false} otherwise. + */ + isCaActive: boolean; + /** + * Checks whether this device is allowed to make emergency calls only. + * + * @return Returns {@code true} if this device is allowed to make emergency calls only; + * returns {@code false} otherwise. + */ + isEmergency: boolean; + } + /** + * Describes the network registration state. + */ + export enum RegState { + /** + * Indicates a state in which a device cannot use any service. + */ + REG_STATE_NO_SERVICE = 0, + /** + * Indicates a state in which a device can use services properly. + */ + REG_STATE_IN_SERVICE = 1, + /** + * Indicates a state in which a device can use only the emergency call service. + */ + REG_STATE_EMERGENCY_CALL_ONLY = 2, + /** + * Indicates that the cellular radio is powered off. + */ + REG_STATE_POWER_OFF = 3 + } + /** + * Describes the nsa state. + */ + export enum NsaState { + /** + * Indicates that a device is idle under or is connected to an LTE cell that does not support NSA. + */ + NSA_STATE_NOT_SUPPORT = 1, + /** + * Indicates that a device is idle under an LTE cell supporting NSA but not NR coverage detection. + */ + NSA_STATE_NO_DETECT = 2, + /** + * Indicates that a device is connected to an LTE network under an LTE cell + * that supports NSA and NR coverage detection. + */ + NSA_STATE_CONNECTED_DETECT = 3, + /** + * Indicates that a device is idle under an LTE cell supporting NSA and NR coverage detection. + */ + NSA_STATE_IDLE_DETECT = 4, + /** + * Indicates that a device is connected to an LTE + NR network under an LTE cell that supports NSA. + */ + NSA_STATE_DUAL_CONNECTED = 5, + /** + * Indicates that a device is idle under or is connected to an NG-RAN cell while being attached to 5GC. + */ + NSA_STATE_SA_ATTACHED = 6 + } + export enum NetworkSelectionMode { + /** Unknown network selection modes. */ + NETWORK_SELECTION_UNKNOWN, + /** Automatic network selection modes. */ + NETWORK_SELECTION_AUTOMATIC, + /** Manual network selection modes. */ + NETWORK_SELECTION_MANUAL + } +} +export default radio; diff --git a/build-tools/api/@ohos.telephony.sim.d.ts b/build-tools/api/@ohos.telephony.sim.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..92420747ffe6424da2a6121a2ac095ca1d4c31d7 --- /dev/null +++ b/build-tools/api/@ohos.telephony.sim.d.ts @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from "./basic"; +/** + * Provides applications with APIs for obtaining SIM card status, card file information, and card specifications. + * SIM cards include SIM, USIM, and CSIM cards. + * + * @since 6 + * @syscap SystemCapability.Telephony.CoreService + */ +declare namespace sim { + /** + * Checks whether the SIM card in a specified slot is activated. + * + * @param slotId Indicates the card slot index number, + * ranging from {@code 0} to the maximum card slot index number supported by the device. + * @param callback Returns {@code true} if the SIM card is activated; returns {@code false} otherwise. + * @since 7 + */ + function isSimActive(slotId: number, callback: AsyncCallback): void; + function isSimActive(slotId: number): Promise; + /** + * Obtains the default card slot for the voice service. + * + * @param callback Returns {@code 0} if card 1 is used as the default card slot for the voice service; + * returns {@code 1} if card 2 is used as the default card slot for the voice service; + * returns {@code -1} if no card is available for the voice service. + * @since 7 + */ + function getDefaultVoiceSlotId(callback: AsyncCallback): void; + function getDefaultVoiceSlotId(): Promise; + /** + * Checks whether your application (the caller) has been granted the operator permissions. + * + * @param slotId Indicates the ID of the SIM card slot. + * @param callback Returns {@code true} if your application has been granted the operator permissions; + * returns {@code false} otherwise. + * @since 7 + */ + function hasOperatorPrivileges(slotId: number, callback: AsyncCallback): void; + function hasOperatorPrivileges(slotId: number): Promise; + /** + * Obtains the ISO country code of the SIM card in a specified slot. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the country code defined in ISO 3166-2; returns an empty string if no SIM card is inserted. + */ + function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback): void; + function getISOCountryCodeForSim(slotId: number): Promise; + /** + * Obtains the home PLMN number of the SIM card in a specified slot. + * + *

      The value is recorded in the SIM card and is irrelevant to the network + * with which the SIM card is currently registered. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the PLMN number; returns an empty string if no SIM card is inserted. + */ + function getSimOperatorNumeric(slotId: number, callback: AsyncCallback): void; + function getSimOperatorNumeric(slotId: number): Promise; + /** + * Obtains the service provider name (SPN) of the SIM card in a specified slot. + * + *

      The value is recorded in the EFSPN file of the SIM card and is irrelevant to the network + * with which the SIM card is currently registered. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the SPN; returns an empty string if no SIM card is inserted or + * no EFSPN file in the SIM card. + */ + function getSimSpn(slotId: number, callback: AsyncCallback): void; + function getSimSpn(slotId: number): Promise; + /** + * Obtains the state of the SIM card in a specified slot. + * + * @param slotId Indicates the card slot index number, + * ranging from {@code 0} to the maximum card slot index number supported by the device. + * @param callback Returns one of the following SIM card states: + *

        + *
      • {@code SimState#SIM_STATE_UNKNOWN} + *
      • {@code SimState#SIM_STATE_NOT_PRESENT} + *
      • {@code SimState#SIM_STATE_LOCKED} + *
      • {@code SimState#SIM_STATE_NOT_READY} + *
      • {@code SimState#SIM_STATE_READY} + *
      • {@code SimState#SIM_STATE_LOADED} + *
      + */ + function getSimState(slotId: number, callback: AsyncCallback): void; + function getSimState(slotId: number): Promise; + /** + * Obtains the type of the SIM card installed in a specified slot. + * + * @param slotId Indicates the ID of the specified slot. + * @param callback Returns the SIM card type. + * @since 7 + */ + function getCardType(slotId: number, callback: AsyncCallback): void; + function getCardType(slotId: number): Promise; + /** + * Obtains the maximum number of SIM cards that can be used simultaneously on the device, + * that is, the maximum number of SIM card slots. + * + * @return Returns the maximum number of SIM card slots. + * @since 7 + */ + function getMaxSimCount(): number; + /** + * Checks whether a SIM card is inserted in a specified slot. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns true if a SIM card is inserted; return false otherwise. + * @since 7 + */ + function hasSimCard(slotId: number, callback: AsyncCallback): void; + function hasSimCard(slotId: number): Promise; + /** + * @since 7 + */ + export enum CardType { + /** Icc card type: Unknow type Card. */ + UNKNOWN_CARD = -1, + /** Icc card type: Single sim card type. */ + SINGLE_MODE_SIM_CARD = 10, + /** Icc card type: Single usim card type. */ + SINGLE_MODE_USIM_CARD = 20, + /** Icc card type: Single ruim card type. */ + SINGLE_MODE_RUIM_CARD = 30, + /** Icc card type: Double card C+G. */ + DUAL_MODE_CG_CARD = 40, + /** Icc card type: China Telecom Internal Roaming Card (Dual Mode). */ + CT_NATIONAL_ROAMING_CARD = 41, + /** Icc card type: China Unicom Dual Mode Card. */ + CU_DUAL_MODE_CARD = 42, + /** Icc card type: China Telecom LTE Card (Dual Mode). */ + DUAL_MODE_TELECOM_LTE_CARD = 43, + /** Icc card type: Double card U+G. */ + DUAL_MODE_UG_CARD = 50, + /** + * Icc card type: Single isim card type. + * @since 8 + */ + SINGLE_MODE_ISIM_CARD = 60 + } + export enum SimState { + /** + * Indicates unknown SIM card state, that is, the accurate status cannot be obtained. + */ + SIM_STATE_UNKNOWN, + /** + * Indicates that the SIM card is in the not present state, that is, no SIM card is inserted + * into the card slot. + */ + SIM_STATE_NOT_PRESENT, + /** + * Indicates that the SIM card is in the locked state, that is, the SIM card is locked by the + * personal identification number (PIN)/PIN unblocking key (PUK) or network. + */ + SIM_STATE_LOCKED, + /** + * Indicates that the SIM card is in the not ready state, that is, the SIM card is in position + * but cannot work properly. + */ + SIM_STATE_NOT_READY, + /** + * Indicates that the SIM card is in the ready state, that is, the SIM card is in position and + * is working properly. + */ + SIM_STATE_READY, + /** + * Indicates that the SIM card is in the loaded state, that is, the SIM card is in position and + * is working properly. + */ + SIM_STATE_LOADED + } +} +export default sim; diff --git a/build-tools/api/@ohos.telephony.sms.d.ts b/build-tools/api/@ohos.telephony.sms.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea39f1270e1cb2b3c6208ebcdf231f14df0205b6 --- /dev/null +++ b/build-tools/api/@ohos.telephony.sms.d.ts @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from "./basic"; +/** + * Provides the capabilities and methods for obtaining Short Message Service (SMS) management objects. + * + * @since 6 + * @syscap SystemCapability.Telephony.SmsMms + */ +declare namespace sms { + /** + * Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. + * + *

      After receiving the original PDU data, the system creates an SMS message instance according to the specified + * SMS protocol. + * + * @param pdu Indicates the original data, which is obtained from the received SMS. + * @param specification Indicates the SMS protocol type. The value {@code 3gpp} indicates GSM/UMTS/LTE SMS, + * and the value {@code 3gpp2} indicates CDMA/LTE SMS. + * @param callback Returns an SMS message instance; returns {@code null} if {@code pdu} is empty or + * {@code specification} is not supported. + */ + function createMessage(pdu: Array, specification: string, callback: AsyncCallback): void; + function createMessage(pdu: Array, specification: string): Promise; + /** + * Sends a text or data SMS message. + * + *

      This method checks whether the length of an SMS message exceeds the maximum length. If the + * maximum length is exceeded, the SMS message is split into multiple parts and sent separately. + * + * @param options Indicates the parameters and callback for sending the SMS message. + * @permission ohos.permission.SEND_MESSAGES + */ + function sendMessage(options: SendMessageOptions): void; + /** + * Obtains the default SIM card for sending SMS messages. + * + * @param callback Returns {@code 0} if the default SIM card for sending SMS messages is in card slot 1; + * returns {@code 1} if the default SIM card for sending SMS messages is in card slot 2. + * @since 7 + */ + function getDefaultSmsSlotId(callback: AsyncCallback): void; + function getDefaultSmsSlotId(): Promise; + /** + * Returns whether a device is capable of sending and receiving SMS messages. + * + * @return Returns {@code true} if the device is capable of sending and receiving SMS messages; + * returns {@code false} otherwise. + * @since 7 + */ + function hasSmsCapability(): boolean; + export interface ShortMessage { + /** Indicates the SMS message body. */ + visibleMessageBody: string; + /** Indicates the address of the sender, which is to be displayed on the UI. */ + visibleRawAddress: string; + /** Indicates the SMS type. */ + messageClass: ShortMessageClass; + /** Indicates the protocol identifier. */ + protocolId: number; + /** Indicates the short message service center (SMSC) address. */ + scAddress: string; + /** Indicates the SMSC timestamp. */ + scTimestamp: number; + /** Indicates whether the received SMS is a "replace short message". */ + isReplaceMessage: boolean; + /** Indicates whether the received SMS contains "TP-Reply-Path". */ + hasReplyPath: boolean; + /** Indicates Protocol Data Units (PDUs) from an SMS message. */ + pdu: Array; + /** + * Indicates the SMS message status from the SMS-STATUS-REPORT message sent by the + * Short Message Service Center (SMSC). + */ + status: number; + /** Indicates whether the current message is SMS-STATUS-REPORT. */ + isSmsStatusReportMessage: boolean; + } + export enum ShortMessageClass { + /** Indicates an unknown type. */ + UNKNOWN, + /** Indicates an instant message, which is displayed immediately after being received. */ + INSTANT_MESSAGE, + /** Indicates an SMS message that can be stored on the device or SIM card based on the storage status. */ + OPTIONAL_MESSAGE, + /** Indicates an SMS message containing SIM card information, which is to be stored in a SIM card. */ + SIM_MESSAGE, + /** Indicates an SMS message to be forwarded to another device. */ + FORWARD_MESSAGE + } + export interface SendMessageOptions { + /** Indicates the ID of the SIM card slot used for sending the SMS message. */ + slotId: number; + /** Indicates the address to which the SMS message is sent. */ + destinationHost: string; + /** Indicates the SMSC address. If the value is {@code null}, the default SMSC address of the SIM card*/ + serviceCenter?: string; + /** If the content is a string, this is a short message. If the content is a byte array, this is a data message. */ + content: string | Array; + /** If send data message, destinationPort is mandatory. Otherwise is optional. */ + destinationPort?: number; + /** Indicates the callback invoked after the SMS message is sent. */ + sendCallback?: AsyncCallback; + /** Indicates the callback invoked after the SMS message is delivered. */ + deliveryCallback?: AsyncCallback; + } + export interface ISendShortMessageCallback { + /** Indicates the SMS message sending result. */ + result: SendSmsResult; + /** Indicates the URI to store the sent SMS message. */ + url: string; + /** Specifies whether this is the last part of a multi-part SMS message. */ + isLastPart: boolean; + } + export interface IDeliveryShortMessageCallback { + /** Indicates the SMS delivery report. */ + pdu: Array; + } + export enum SendSmsResult { + /** + * Indicates that the SMS message is successfully sent. + */ + SEND_SMS_SUCCESS = 0, + /** + * Indicates that sending the SMS message fails due to an unknown reason. + */ + SEND_SMS_FAILURE_UNKNOWN = 1, + /** + * Indicates that sending the SMS fails because the modem is powered off. + */ + SEND_SMS_FAILURE_RADIO_OFF = 2, + /** + * Indicates that sending the SMS message fails because the network is unavailable + * or does not support sending or reception of SMS messages. + */ + SEND_SMS_FAILURE_SERVICE_UNAVAILABLE = 3 + } +} +export default sms; diff --git a/build-tools/api/@ohos.thermal.d.ts b/build-tools/api/@ohos.thermal.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..989d275789e60033713c24ac72c86e2b17da7824 --- /dev/null +++ b/build-tools/api/@ohos.thermal.d.ts @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * Provides thermal level-related callback and query APIs to obtain the information required for + * temperature control. The APIs are as follows: + * {@link subscribeThermalLevel}: subscribes to callbacks of thermal level changes. + * {@link getThermalLevel}: obtains the thermal level of the system in real time. + * + * @syscap SystemCapability.PowerManager.ThermalManager + * @since 8 + */ +declare namespace thermal { + /** + * Enumerates the {@link ThermalLevel} types. + * + * @since 8 + */ + export enum ThermalLevel { + /** + * The device is cool, and services are not restricted. + */ + COOL = 0, + /** + * The device is operational but is not cool. You need to pay attention to its heating. + */ + NORMAL = 1, + /** + * The device is warm. You need to stop or delay some imperceptible services. + */ + WARM = 2, + /** + * The device is heating up. You need to stop all imperceptible services and downgrade + * or reduce the load of other services. + */ + HOT = 3, + /** + * The device is overheated. You need to stop all imperceptible services and downgrade + * or reduce the load of major services. + */ + OVERHEATED = 4, + /** + * The device is overheated and is about to enter the emergency state. You need to stop + * all imperceptible services and downgrade major services to the maximum extent. + */ + WARNING = 5, + /** + * The device has entered the emergency state. You need to stop all services except those + * for the emergency help purposes. + */ + EMERGENCY = 6 + } + /** + * Subscribes to callbacks of thermal level changes. + * + * @param callback Callback of thermal level changes. + * @return Returns the thermal level. + * @since 8 + */ + function subscribeThermalLevel(callback: AsyncCallback): void; + /** + * Unsubscribes from the callbacks of thermal level changes. + * + * @param callback Callback of thermal level changes. + + * @since 8 + */ + function unsubscribeThermalLevel(callback?: AsyncCallback): void; + /** + * Obtains the current thermal level. + * + * @return Returns the thermal level. + * @since 8 + */ + function getThermalLevel(): ThermalLevel; +} +export default thermal; diff --git a/build-tools/api/@ohos.uiAppearance.d.ts b/build-tools/api/@ohos.uiAppearance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..feb1c5334e716a0663aaf9c60e4973104d99234c --- /dev/null +++ b/build-tools/api/@ohos.uiAppearance.d.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Provide APIs to set system uiAppearance. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @import import uiAppearance from '@ohos.uiAppearance'; + * @since 9 + */ +declare namespace uiAppearance { + /** + * Enumerates dark-mode. + */ + enum DarkMode { + /** + * Always display with dark mode. + */ + ALWAYS_DARK = 0, + /** + * Always display with light mode. + */ + ALWAYS_LIGHT = 1 + } +} +export default uiAppearance; diff --git a/build-tools/api/@ohos.uitest.d.ts b/build-tools/api/@ohos.uitest.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..829ddf4929066492b60c4bc331b522892377736f --- /dev/null +++ b/build-tools/api/@ohos.uitest.d.ts @@ -0,0 +1,746 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing,software + * distributed under the License is distributed on an "ASIS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Resize direction for the window. + * + * @since 9 + */ +enum ResizeDirection { + LEFT, + RIGHT, + UP, + DOWN, + LEFT_UP, + LEFT_DOWN, + RIGHT_UP, + RIGHT_DOWN +} +/** + * Enumerates the string value match pattern. + * + * @since 8 + */ +enum MatchPattern { + /** + * Equals to a string. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + EQUALS = 0, + /** + * Contains a substring. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + CONTAINS = 1, + /** + * StartsWith a substring. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + STARTS_WITH = 2, + /** + * EndsWith a substring. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + ENDS_WITH = 3 +} +/** + * Describes the window mode of the tested window + * + * @since 9 + */ +enum WindowMode { + FULLSCREEN, + PRIMARY, + SECONDARY, + FLOATING +} +/** + * Represents the point on the device screen. + * + * @since 9 + */ +declare interface Point { + readonly X: number; + readonly Y: number; +} +/** + * Represents the rectangle area on the device screen. + * + * @since 9 + */ +declare interface Rect { + readonly leftX: number; + readonly topY: number; + readonly rightX: number; + readonly bottomY: number; +} +/** + * Represents filer condition to get the window . + * + * @since 9 + */ +declare interface WindowFilter { + readonly bundleName?: string; + readonly title?: string; + readonly focused?: bool; + readonly actived?: bool; +} +/** + * Describes the attribute requirements for the target UiComponents. + * + * @since 8 + * @syscap SystemCapability.Test.UiTest + */ +class By { + /** + * Specifies the text for the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param txt the text value. + * @param pattern the {@link MatchPattern} of the text value,default to {@link MatchPattern.EQUALS} + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + text(txt: string, pattern?: MatchPattern): By; + /** + * Specifies the inspectorKey of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param key the inspectorKey value. + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + key(key: string): By; + /** + * Specifies the id of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param id the id value. + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + id(id: number): By; + /** + * Specifies the type of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param tp the type value. + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + type(tp: string): By; + /** + * Specifies the clickable status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b the clickable status,default to true. + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + clickable(b?: bool): By; + /** + * Specifies the longClickable status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b the clickable status,default to true. + * @return Returns this {@link By} object. + * @since 9 + * @test + */ + longClickable(b?: bool): By; + /** + * Specifies the scrollable status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b the scrollable status,default to true. + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + scrollable(b?: bool): By; + /** + * Specifies the enabled status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b the enabled status,default to true. + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + enabled(b?: bool): By; + /** + * Specifies the focused status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b the focused status,default to true. + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + focused(b?: bool): By; + /** + * Specifies the selected status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b the selected status,default to true. + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + selected(b?: bool): By; + /** + * Specifies the checked status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b the checked status,default to false. + * @return Returns this {@link By} object. + * @since 9 + * @test + */ + checked(b?: bool): By; + /** + * Specifies the checkable status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b the checkable status,default to false. + * @return Returns this {@link By} object. + * @since 9 + * @test + */ + checkable(b?: bool): By; + /** + * Requires that the target UiComponent which is before another UiComponent that specified by the given {@link By} + * object,used to locate UiComponent relatively. + * @syscap SystemCapability.Test.UiTest + * @param by describes the attribute requirements of UiComponent which the target one is in front of. + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + isBefore(by: By): By; + /** + * Requires that the target UiComponent which is after another UiComponent that specified by the given {@link By} + * object,used to locate UiComponent relatively. + * @syscap SystemCapability.Test.UiTest + * @param by describes the attribute requirements of UiComponent which the target one is in back of. + * @return Returns this {@link By} object. + * @since 8 + * @test + */ + isAfter(by: By): By; +} +/** + * Represents a UiComponent of the ohos application,user can perform operations or query attributes on it. + * + * @since 8 + * @test + * @syscap SystemCapability.Test.UiTest + */ +class UiComponent { + /** + * Click this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + click(): Promise; + /** + * Double click this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + doubleClick(): Promise; + /** + * Long click this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + longClick(): Promise; + /** + * Get the id attribute value. + * @syscap SystemCapability.Test.UiTest + * @returns the id value. + * @since 8 + * @test + */ + getId(): Promise; + /** + * Get the inspectorKey attribute value. + * @syscap SystemCapability.Test.UiTest + * @returns the inspectorKey value. + * @since 8 + * @test + */ + getKey(): Promise; + /** + * Get the text attribute value. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + getText(): Promise; + /** + * Get the type name. + * @syscap SystemCapability.Test.UiTest + * @returns the type name. + * @since 8 + * @test + */ + getType(): Promise; + /** + * Get the clickable status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the clickable status. + * @since 8 + * @test + */ + isClickable(): Promise; + /** + * Get the longClickable status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the longClickable status. + * @since 9 + * @test + */ + isLongClickable(): Promise; + /** + * Get the scrollable status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the scrollable status. + * @since 8 + * @test + */ + isScrollable(): Promise; + /** + * Get the enabled status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the enabled status. + * @since 8 + * @test + */ + isEnabled(): Promise; + /** + * Get the focused status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the focused status. + * @since 8 + * @test + */ + isFocused(): Promise; + /** + * Get the selected status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the selected status. + * @since 8 + * @test + */ + isSelected(): Promise; + /** + * Get the checked status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the checked status. + * @since 9 + * @test + */ + isChecked(): Promise; + /** + * Get the checkable status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the checkable status. + * @since 9 + * @test + */ + isCheckable(): Promise; + /** + * Inject text to this {@link UiComponent},applicable to TextInput. + * @syscap SystemCapability.Test.UiTest + * @param text the text to inject. + * @since 8 + * @test + */ + inputText(text: string): Promise; + /** + * Clear text of this {@link UiComponent},applicable to TextInput. + * @syscap SystemCapability.Test.UiTest + * @since 9 + * @test + */ + clearText(): Promise; + /** + * Scroll on this {@link UiComponent} to the top,applicable to scrollable one. + * @syscap SystemCapability.Test.UiTest + * @param speed the speed of swipe (pixels per second),default is 600,the value ranges from 0 to 3000,set it 3000 if greater than 3000. + * @since 9 + * @test + */ + scrollToTop(speed?: number): Promise; + /** + * Scroll on this {@link UiComponent} to the bottom,applicable to scrollable one. + * @syscap SystemCapability.Test.UiTest + * @param speed the speed of swipe (pixels per second),default is 600,the value ranges from 0 to 3000,set it 3000 if greater than 3000. + * @since 9 + * @test + */ + scrollToBottom(speed?: number): Promise; + /** + * Scroll on this {@link UiComponent}to find matched {@link UiComponent},applicable to scrollable one. + * @syscap SystemCapability.Test.UiTest + * @param by the attribute requirements of the target {@link UiComponent}. + * @return the found result,or undefined if not found. + * @since 8 + * @test + */ + scrollSearch(by: By): Promise; + /** + * Get the bounds rect of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @return the bounds rect object. + * @since 9 + * @test + */ + getBounds(): Promise; + /** + * Get the boundsCenter of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @return the boundsCenter object. + * @since 9 + * @test + */ + getBoundsCenter(): Promise; + /** + * Drag this {@link UiComponent} to the bounds rect of target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param target the target {@link UiComponent}. + * @since 9 + * @test + */ + dragTo(target: UiComponent): Promise; + /** + * Pinch enlarge this {@link UiComponent} to the target scale. + * @syscap SystemCapability.Test.UiTest + * @param scale the scale of the pinch enlarge this {@link UiComponent}'s size. + * @since 9 + * @test + */ + pinchOut(scale: number): Promise; + /** + * Pinch shrink this {@link UiComponent} to the target scale. + * @syscap SystemCapability.Test.UiTest + * @param scale the scale of the pinch shrink this {@link UiComponent}'s size. + * @since 9 + * @test + */ + pinchIn(scale: number): Promise; +} +/** + * The unified facade of UiTest framework,can be used to find {@link UiComponent},trigger keyEvents,perform + * coordinates-based UI actions,capture screen and so on. + * + * @since 8 + * @test + * @syscap SystemCapability.Test.UiTest + */ +class UiDriver { + /** + * Create an {@link UiDriver} object. + * @syscap SystemCapability.Test.UiTest + * @returns the {@link UiDriver} object. + * @since 8 + * @test + */ + static create(): UiDriver; + /** + * Delay with specified duration. + * @syscap SystemCapability.Test.UiTest + * @param duration the delay duration in milliseconds. + * @since 8 + * @test + */ + delayMs(duration: number): Promise; + /** + * Find the first matched {@link UiComponent} on current UI. + * @syscap SystemCapability.Test.UiTest + * @param by the attribute requirements of the target {@link UiComponent}. + * @returns the first matched {@link UiComponent} or undefined. + * @since 8 + * @test + */ + findComponent(by: By): Promise; + /** + * Find the first matched {@link UiWindow} window. + * @syscap SystemCapability.Test.UiTest + * @param filter the filer condition of the target {@link UiWindow}. + * @returns the first matched {@link UiWindow} or undefined. + * @since 9 + * @test + */ + findWindow(filter: WindowFilter): Promise; + /** + * Find the first matched {@link UiComponent} on current UI during the time given. + * @syscap SystemCapability.Test.UiTest + * @param by the attribute requirements of the target {@link UiComponent}. + * @param time duration of finding in milliseconds + * @returns the first matched {@link UiComponent} or undefined. + * @since 9 + * @test + */ + waitForComponent(by: By, time: number): Promise; + /** + * Find all the matched {@link UiComponent}s on current UI. + * @syscap SystemCapability.Test.UiTest + * @param by the attribute requirements of the target {@link UiComponent}. + * @returns the matched {@link UiComponent}s list. + * @since 8 + * @test + */ + findComponents(by: By): Promise>; + /** + * Assert t the matched {@link UiComponent}s exists on current UI;if not,assertError will be raised. + * @syscap SystemCapability.Test.UiTest + * @param by the attribute requirements of the target {@link UiComponent}. + * @throws Throws this exception if following error occurs:{@code ComponentExistAssertion Failure}. + * @since 8 + * @test + */ + assertComponentExist(by: By): Promise; + /** + * Press the BACK key. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + pressBack(): Promise; + /** + * Press the specified key. + * @syscap SystemCapability.Test.UiTest + * @param keyCode the target keyCode. + * @since 8 + * @test + */ + triggerKey(keyCode: number): Promise; + /** + * Press two or three key combinations + * @syscap SystemCapability.Test.UiTest + * @param key0 the first keyCode. + * @param key1 the second keyCode. + * @param key2 the third keyCode. + * @since 9 + * @test + */ + triggerCombineKeys(key0: number, key1: number, key2?: number): Promise; + /** + * Click on the specified location on the screen. + * @syscap SystemCapability.Test.UiTest + * @param x the x-coordinate. + * @param y the y-coordinate. + * @since 8 + * @test + */ + click(x: number, y: number): Promise; + /** + * DoubleClick on the specified location on the screen. + * @syscap SystemCapability.Test.UiTest + * @param x the x-coordinate. + * @param y the y-coordinate. + * @since 8 + * @test + */ + doubleClick(x: number, y: number): Promise; + /** + * LongClick on the specified location on the screen. + * @syscap SystemCapability.Test.UiTest + * @param x the x-coordinate. + * @param y the y-coordinate. + * @since 8 + * @test + */ + longClick(x: number, y: number): Promise; + /** + * Swipe on the screen between the specified points. + * @syscap SystemCapability.Test.UiTest + * @param startx the x-coordinate of the starting point. + * @param starty the y-coordinate of the starting point. + * @param endx the x-coordinate of the ending point. + * @param endy the y-coordinate of the ending point. + * @deprecated since 9 + * @since 8 + * @test + */ + swipe(startx: number, starty: number, endx: number, endy: number): Promise; + /** + * Swipe on the screen between the specified points. + * @syscap SystemCapability.Test.UiTest + * @param startx the x-coordinate of the starting point. + * @param starty the y-coordinate of the starting point. + * @param endx the x-coordinate of the ending point. + * @param endy the y-coordinate of the ending point. + * @param speed the speed of swipe (pixels per second),default is 600,the value ranges from 0 to 3000,set it 3000 if greater than 3000. + * @since 9 + * @test + */ + swipe(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise; + /** + * Drag on the screen between the specified points. + * @syscap SystemCapability.Test.UiTest + * @param startx the x-coordinate of the starting point. + * @param starty the y-coordinate of the starting point. + * @param endx the x-coordinate of the ending point. + * @param endy the y-coordinate of the ending point. + * @param speed the speed of swipe (pixels per second),default is 600,the value ranges from 0 to 3000,set it 3000 if greater than 3000. + * @since 9 + * @test + */ + drag(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise; + /** + * Capture current screen and save as picture which PNG format. + * @syscap SystemCapability.Test.UiTest + * @param savePath the path where to store the picture. + * @returns true if screen-capturing and file-storing are completed successfully,false otherwise. + * @since 8 + * @test + */ + screenCap(savePath: string): Promise; +} +/** + * + * + * @since 9 + * @test + * @syscap SystemCapability.Test.UiTest + */ +class UiWindow { + /** + * Get the bundle name of this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @returns the bundle name. + * @since 9 + * @test + */ + getBundleName(): Promise; + /** + * Get the bounds rect of this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @return the bounds rect object. + * @since 9 + * @test + */ + getBounds(): Promise; + /** + * Get the title of this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @returns the title value. + * @since 9 + * @test + */ + getTitle(): Promise; + /** + * Get the windoe mode of this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @returns the {@link WindowMode} object. + * @since 9 + * @test + */ + getWindowMode(): Promise; + /** + * Get the focused status of this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @returns the focused status + * @since 9 + * @test + */ + isFocused(): Promise; + /** + * Get the actived status of this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @returns the actived status + * @since 9 + * @test + */ + isActived(): Promise; + /** + * Set the focused status of this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @returns the result of focus action + * @since 9 + * @test + */ + focus(): Promise; + /** + * Move this {@link UiWindow} to the specified points. + * @syscap SystemCapability.Test.UiTest + * @returns the result of move action + * @since 9 + * @test + */ + moveTo(x: number, y: number): Promise; + /** + * Resize this {@link UiWindow} to the specified size for the specified direction. + * @syscap SystemCapability.Test.UiTest + * @returns the result of resize action + * @since 9 + * @test + */ + resize(wide: number, height: number, direction: ResizeDirection): Promise; + /** + * Change this {@link UiWindow} into split screen mode. + * @syscap SystemCapability.Test.UiTest + * @returns the result of split action + * @since 9 + * @test + */ + split(): Promise; + /** + * Maximize this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @returns the result of maximize action + * @since 9 + * @test + */ + maximize(): Promise; + /** + * Minimize this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @returns the result of minimize action + * @since 9 + * @test + */ + minimize(): Promise; + /** + * Resume this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @returns the result of resume action + * @since 9 + * @test + */ + resume(): Promise; + /** + * Close this {@link UiWindow}. + * @syscap SystemCapability.Test.UiTest + * @returns the result of close action + * @since 9 + * @test + */ + close(): Promise; +} +/** + * The static builder for building {@link By}object conveniently,usage example:BY.text('txt').enabled(true). + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ +const BY: By; +export { UiComponent, UiDriver, UiWindow, BY, MatchPattern, ResizeDirection, WindowMode }; diff --git a/build-tools/api/@ohos.uri.d.ts b/build-tools/api/@ohos.uri.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e52237f16a7cc6eeb2ff0f07c38f61b2a7fc310 --- /dev/null +++ b/build-tools/api/@ohos.uri.d.ts @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/** + * The uri module provides utilities for URI resolution and parsing. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @import import uri from '@ohos.uri'; + * @permission N/A + */ +declare namespace uri { + class URI { + /** + * URI constructor, which is used to instantiate a URI object. + * uri: Constructs a URI by parsing a given string. + */ + constructor(uri: string); + /** + * Returns the serialized URI as a string. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the serialized URI as a string. + */ + toString(): string; + /** + * Tests whether this URI is equivalent to other URI objects. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param other URI object to be compared + * @return boolean Tests whether this URI is equivalent to other URI objects. + */ + equals(other: URI): boolean; + /** + * Indicates whether this URI is an absolute URI. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return boolean Indicates whether the URI is an absolute URI (whether the scheme component is defined). + */ + checkIsAbsolute(): boolean; + /** + * Normalize the path of this URI. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return URI Used to normalize the path of this URI and return a URI object whose path has been normalized. + */ + normalize(): URI; + /** + * Gets the protocol part of the URI. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + scheme: string; + /** + * Obtains the user information part of the URI. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + userInfo: string; + /** + * Gets the hostname portion of the URI without a port. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + host: string; + /** + * Gets the port portion of the URI. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + port: string; + /** + * Gets the path portion of the URI. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + path: string; + /** + * Gets the query portion of the URI + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + query: string; + /** + * Gets the fragment part of the URI. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + fragment: string; + /** + * Gets the decoding permission component part of this URI. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + authority: string; + /** + * Gets the decoding scheme-specific part of the URI. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ssp: string; + } +} +export default uri; diff --git a/build-tools/api/@ohos.url.d.ts b/build-tools/api/@ohos.url.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ec4ea324717d8ffbb6cef3869a5d04e78ab11507 --- /dev/null +++ b/build-tools/api/@ohos.url.d.ts @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The url module provides utilities for URL resolution and parsing. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @import import url from '@ohos.url'; + * @permission N/A + */ +declare namespace url { + class URLSearchParams { + /** + * A parameterized constructor used to create an URLSearchParams instance. + * As the input parameter of the constructor function, init supports four types. + * The input parameter is a character string two-dimensional array. + * The input parameter is the object list. + * The input parameter is a character string. + * The input parameter is the URLSearchParams object. + */ + constructor(init?: string[][] | Record | string | URLSearchParams); + /** + * Appends a specified key/value pair as a new search parameter. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param name Key name of the search parameter to be inserted. + * @param value Values of search parameters to be inserted. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter and its associated value,from the list of all search parameters. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param Name of the key-value pair to be deleted. + */ + delete(name: string): void; + /** + * Returns all key-value pairs associated with a given search parameter as an array. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param Name Specifies the name of a key value. + * @return string[] Returns all key-value pairs with the specified name. + */ + getAll(name: string): string[]; + /** + * Returns an ES6 iterator. Each item of the iterator is a JavaScript Array. + * The first item of Array is name, and the second item of Array is value. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @return Returns an iterator for ES6. + */ + entries(): IterableIterator<[ + string, + string + ]>; + /** + * Callback functions are used to traverse key-value pairs on the URLSearchParams instance object. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param value Current traversal key value. + * @param key Indicates the name of the key that is traversed. + * @param searchParams The instance object that is currently calling the forEach method. + * @param thisArg to be used as this value for when callbackfn is called + */ + forEach(callbackfn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void; + /** + * Returns the first value associated to the given search parameter. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param name Specifies the name of a key-value pair. + * @return Returns the first value found by name. If no value is found, null is returned. + */ + get(name: string): string | null; + /** + * Returns a Boolean that indicates whether a parameter with the specified name exists. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param name Specifies the name of a key-value pair. + * @return Returns a Boolean value that indicates whether a found + */ + has(name: string): boolean; + /** + * Sets the value associated with a given search parameter to the + * given value. If there were several matching values, this method + * deletes the others. If the search parameter doesn't exist, this + * method creates it. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param name Key name of the parameter to be set. + * @param value Indicates the parameter value to be set. + */ + set(name: string, value: string): void; + /** + * Sort all key/value pairs contained in this object in place and return undefined. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + sort(): void; + /** + * Returns an iterator allowing to go through all keys contained in this object. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @return Returns an ES6 Iterator over the names of each name-value pair. + */ + keys(): IterableIterator; + /** + * Returns an iterator allowing to go through all values contained in this object. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @return Returns an ES6 Iterator over the values of each name-value pair. + */ + values(): IterableIterator; + /** + * Returns an iterator allowing to go through all key/value + * pairs contained in this object. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @return Returns an ES6 iterator. Each item of the iterator is a JavaScript Array. + * The first item of Array is name, and the second item of Array is value. + */ + [Symbol.iterator](): IterableIterator<[ + string, + string + ]>; + /** + * Returns a query string suitable for use in a URL. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @return Returns a search parameter serialized as a string, percent-encoded if necessary. + */ + toString(): string; + } + class URL { + /** + * URL constructor, which is used to instantiate a URL object. + * url: Absolute or relative input URL to resolve. Base is required if input is relative. + * If input is an absolute value, base ignores the value. + * base: Base URL to parse if input is not absolute. + */ + constructor(url: string, base?: string | URL); + /** + * Returns the serialized URL as a string. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @return Returns the serialized URL as a string. + */ + toString(): string; + /** + * Returns the serialized URL as a string. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @return Returns the serialized URL as a string. + */ + toJSON(): string; + /** + * Gets and sets the fragment portion of the URL. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + hash: string; + /** + * Gets and sets the host portion of the URL. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + host: string; + /** + * Gets and sets the host name portion of the URL,not include the port. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + hostname: string; + /** + * Gets and sets the serialized URL. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + href: string; + /** + * Gets the read-only serialization of the URL's origin. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly origin: string; + /** + * Gets and sets the password portion of the URL. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + password: string; + /** + * Gets and sets the path portion of the URL. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + pathname: string; + /** + * Gets and sets the port portion of the URL. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + port: string; + /** + * Gets and sets the protocol portion of the URL. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + protocol: string; + /** + * Gets and sets the serialized query portion of the URL. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + search: string; + /** + * Gets the URLSearchParams object that represents the URL query parameter. + * This property is read-only, but URLSearchParams provides an object that can be used to change + * the URL instance. To replace the entire query parameter for a URL, use url.searchsetter. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @note Be careful when modifying with .searchParams, because the URLSearchParams + * object uses different rules to determine which characters to + * percent-encode according to the WHATWG specification. + */ + readonly searchParams: URLSearchParams; + /** + * Gets and sets the username portion of the URL. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + username: string; + } +} +export default url; diff --git a/build-tools/api/@ohos.usb.d.ts b/build-tools/api/@ohos.usb.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..058811a5f2aff3879e8ac0ac3062ecdaad5656bf --- /dev/null +++ b/build-tools/api/@ohos.usb.d.ts @@ -0,0 +1,529 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare namespace usb { + /** + * Obtains the USB device list. + * + * @return Returns the {@link USBDevice} list. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function getDevices(): Array>; + /** + * Connects to the USB device based on the device information returned by {@link getDevices()}. + * + * @param device USB device on the device list returned by {@link getDevices()}. + * @return Returns the {@link USBDevicePipe} object for data transfer. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function connectDevice(device: USBDevice): Readonly; + /** + * Checks whether the application has the permission to access the device. + * + * @param deviceName Device name defined by {@link USBDevice.name}. + * @return Returns **true** if the user has the permission to access the device; return **false** otherwise. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function hasRight(deviceName: string): boolean; + /** + * Requests the temporary permission for a given application to access the USB device. + * + * @param deviceName Device name defined by {@link USBDevice.name}. + * @return Returns **true** if the temporary device access permissions are granted; return **false** otherwise. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function requestRight(deviceName: string): Promise; + /* usb pipe functions begin */ + /** + * Claims a USB interface. + * + * @param pipe Device pipe defined by {@link USBDevicePipe}, which is used to determine the bus number and device address. + * @param iface USB interface defined by {@link USBInterface}, which is used to determine the interface to claim. + * @param force Optional parameter that determines whether to forcibly claim the USB interface. + * @return Returns **0** if the USB interface is successfully claimed; returns an error code otherwise. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number; + /** + * Releases a USB interface. + * + * @param pipe Device pipe defined by {@link USBDevicePipe}, which is used to determine the bus number and device address. + * @param iface USB interface defined by {@link USBInterface}, which is used to determine the interface to release. + * @return Returns **0** if the USB interface is successfully released; returns an error code otherwise. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number; + /** + * Sets the device configuration. + * + * @param pipe Device pipe defined by {@link USBDevicePipe}, which is used to determine the bus number and device address. + * @param config Device configuration defined by {@link USBConfig}. + * @return Returns **0** if the device configuration is successfully set; returns an error code otherwise. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function setConfiguration(pipe: USBDevicePipe, config: USBConfig): number; + /** + * Sets a USB interface. + * + * @param pipe Device pipe defined by {@link USBDevicePipe}, which is used to determine the bus number and device address. + * @param iface USB interface defined by {@link USBInterface}, which is used to determine the interface to set. + * @return Returns **0** if the USB interface is successfully set; return an error code otherwise. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function setInterface(pipe: USBDevicePipe, iface: USBInterface): number; + /** + * Obtains the raw USB descriptor. + * + * @param pipe Device pipe defined by {@link USBDevicePipe}, which is used to determine the bus number and device address. + * @return Returns the raw descriptor data. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function getRawDescriptor(pipe: USBDevicePipe): Uint8Array; + /** + * Obtains the file descriptor. + * + * @param pipe Device pipe defined by {@link USBDevicePipe}, which is used to determine the USB device. + * @return Returns the file descriptor of the USB device. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function getFileDescriptor(pipe: USBDevicePipe): number; + /** + * Performs control transfer. + * + * @param pipe Device pipe defined by {@link USBDevicePipe}, which is used to determine the USB device. + * @param contrlparam Control transfer parameters. + * @param timeout Timeout duration. This parameter is optional. The default value is **0**, indicating no timeout. + * @return Returns the size of the transmitted or received data block if the control transfer is successful; return **-1** if an exception occurs. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise; + /** + * Performs bulk transfer. + * + * @param pipe Device pipe defined by {@link USBDevicePipe}, which is used to determine the USB device. + * @param endpoint USB endpoint defined by {@link USBEndpoint}, which is used to determine the USB port for data transfer. + * @param buffer Buffer for writing or reading data. + * @param timeout Timeout duration. This parameter is optional. The default value is **0**, indicating no timeout. + * @return Returns the size of the transmitted or received data block if the control transfer is successful; return **-1** if an exception occurs. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise; + /** + * Closes a USB device pipe. + * + * @param pipe Device pipe defined by {@link USBDevicePipe}, which is used to determine the USB device. + * @return Returns **0** if the USB device pipe is closed successfully; return an error code otherwise. + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + function closePipe(pipe: USBDevicePipe): number; + /** + * Represents the USB endpoint from which data is sent or received. You can obtain the USB endpoint through {@link USBInterface}. + * + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + interface USBEndpoint { + /** + * Endpoint address + * + * @since 8 + */ + address: number; + /** + * Endpoint attributes + * + * @since 8 + */ + attributes: number; + /** + * Endpoint interval + * + * @since 8 + */ + interval: number; + /** + * Maximum size of data packets on the endpoint + * + * @since 8 + */ + maxPacketSize: number; + /** + * Endpoint direction + * + * @since 8 + */ + direction: USBRequestDirection; + /** + * Endpoint number + * + * @since 8 + */ + number: number; + /** + * Endpoint type + * + * @since 8 + */ + type: number; + /** + * Unique ID defined by {@link USBInterface.id}, which indicates the interface to which the endpoint belongs + * + * @since 8 + */ + interfaceId: number; + } + /** + * Represents a USB interface. One USBconfig {@link USBConfig} can contain multiple **USBInterface** instances, each providing a specific function. + * + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + interface USBInterface { + /** + * Unique ID of the USB interface + * + * @since 8 + */ + id: number; + /** + * Interface protocol + * + * @since 8 + */ + protocol: number; + /** + * Device type + * + * @since 8 + */ + clazz: number; + /** + * Device subclass + * + * @since 8 + */ + subClass: number; + /** + * Alternating between descriptors of the same USB interface + * + * @since 8 + */ + alternateSetting: number; + /** + * Interface name + * + * @since 8 + */ + name: string; + /** + * {@link USBEndpoint} that belongs to the USB interface + * + * @since 8 + */ + endpoints: Array; + } + /** + * USB configuration. One {@link USBDevice} can contain multiple USBConfig instances. + * + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + interface USBConfig { + /** + * Unique ID of the USB configuration + * + * @since 8 + * + * + */ + id: number; + /** + * Configuration attributes + * + * @since 8 + */ + attributes: number; + /** + * Maximum power consumption, in mA + * + * @since 8 + */ + maxPower: number; + /** + * Configuration name, which can be left empty + * + * @since 8 + */ + name: string; + /** + * Support for remote wakeup + * + * @since 8 + */ + isRemoteWakeup: boolean; + /** + * Support for independent power supplies + * + * @since 8 + */ + isSelfPowered: boolean; + /** + * Supported interface attributes defined by {@link USBInterface} + * + * @since 8 + */ + interfaces: Array; + } + /** + * Represents a USB device. + * + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + interface USBDevice { + /** + * Bus address + * + * @since 8 + */ + busNum: number; + /** + * Device address + * + * @since 8 + */ + devAddress: number; + /** + * Device SN + * + * @since 8 + */ + serial: string; + /** + * Device name + * + * @since 8 + */ + name: string; + /** + * Device manufacturer + * + * @since 8 + */ + manufacturerName: string; + /** + * Product information + * + * @since 8 + */ + productName: string; + /** + * Product version + * + * @since 8 + */ + version: string; + /** + * Vendor ID + * + * @since 8 + */ + vendorId: number; + /** + * Product ID + * + * @since 8 + */ + productId: number; + /** + * Device class + * + * @since 8 + */ + clazz: number; + /** + * Device subclass + * + * @since 8 + */ + subClass: number; + /** + * Device protocol code + * + * @since 8 + */ + protocol: number; + /** + * Device configuration descriptor information defined by {@link USBConfig} + * + * @since 8 + */ + configs: Array; + } + /** + * Represents a USB device pipe, which is used to determine the USB device. + * + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + interface USBDevicePipe { + /** + * Bus address. + * + * @since 8 + */ + busNum: number; + /** + * Device address + * + * @since 8 + */ + devAddress: number; + } + /** + * Represents control transfer parameters. + * + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + interface USBControlParams { + /** + * Request type + * + * @since 8 + */ + request: number; + /** + * Request target type + * + * @since 8 + */ + target: USBRequestTargetType; + /** + * Control request type + * + * @since 8 + */ + reqType: USBControlRequestType; + /** + * Request parameter value + * + * @since 8 + */ + value: number; + /** + * Index of the parameter value + * + * @since 8 + */ + index: number; + /** + * Data written to or read from the buffer + * @since 8 + */ + data: Uint8Array; + } + /** + * Enumerates USB request target types. + * + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + export enum USBRequestTargetType { + /** + * USB device + * + * @since 8 + */ + USB_REQUEST_TARGET_DEVICE = 0, + /** + * USB interface + * + * @since 8 + */ + USB_REQUEST_TARGET_INTERFACE = 1, + /** + * Endpoint + * + * @since 8 + */ + USB_REQUEST_TARGET_ENDPOINT = 2, + /** + * Others + * + * @since 8 + */ + USB_REQUEST_TARGET_OTHER = 3 + } + /** + * Enumerates control request types. + * + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + export enum USBControlRequestType { + /** + * Standard + * + * @since 8 + */ + USB_REQUEST_TYPE_STANDARD = 0, + /** + * Class + * + * @since 8 + */ + USB_REQUEST_TYPE_CLASS = 1, + /** + * Vendor + * + * @since 8 + */ + USB_REQUEST_TYPE_VENDOR = 2 + } + /** + * Enumerates request directions. + * + * @syscap SystemCapability.USB.USBManager + * @since 8 + */ + export enum USBRequestDirection { + /** + * Request for writing data from the host to the device + * + * @since 8 + */ + USB_REQUEST_DIR_TO_DEVICE = 0, + /** + * Request for reading data from the device to the host + * + * @since 8 + */ + USB_REQUEST_DIR_FROM_DEVICE = 0x80 + } +} +export default usb; diff --git a/build-tools/api/@ohos.userIAM.userAuth.d.ts b/build-tools/api/@ohos.userIAM.userAuth.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..99a485576dd9bccb86aff767a1bea79e65e5d0bf --- /dev/null +++ b/build-tools/api/@ohos.userIAM.userAuth.d.ts @@ -0,0 +1,436 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * User authentication + * @since 6 + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @permission ohos.permission.ACCESS_BIOMETRIC + */ +declare namespace userAuth { + export enum AuthenticationResult { + /** + * Indicates that the device does not support authentication. + * @deprecated since 8 + */ + NO_SUPPORT = -1, + /** + * Indicates that authentication is success. + * @deprecated since 8 + */ + SUCCESS = 0, + /** + * Indicates the authenticator fails to identify user. + * @deprecated since 8 + */ + COMPARE_FAILURE = 1, + /** + * Indicates that authentication has been canceled. + * @deprecated since 8 + */ + CANCELED = 2, + /** + * Indicates that authentication has timed out. + * @deprecated since 8 + */ + TIMEOUT = 3, + /** + * Indicates a failure to open the camera. + * @deprecated since 8 + */ + CAMERA_FAIL = 4, + /** + * Indicates that the authentication task is busy. Wait for a few seconds and try again. + * @deprecated since 8 + */ + BUSY = 5, + /** + * Indicates incorrect parameters. + * @deprecated since 8 + */ + INVALID_PARAMETERS = 6, + /** + * Indicates that the authenticator is locked. + * @deprecated since 8 + */ + LOCKED = 7, + /** + * Indicates that the user has not enrolled the authenticator. + * @deprecated since 8 + */ + NOT_ENROLLED = 8, + /** + * Indicates other errors. + * @deprecated since 8 + */ + GENERAL_ERROR = 100 + } + /** + * Auth types + * @deprecated since 8 + */ + type AuthType = "ALL" | "FACE_ONLY"; + /** + * Secure levels + * @deprecated since 8 + */ + type SecureLevel = "S1" | "S2" | "S3" | "S4"; + interface Authenticator { + /** + * Execute authentication. + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @param type Indicates the authentication type. + * @param level Indicates the security level. + * @return Returns authentication result, which is specified by AuthenticationResult. + * @deprecated since 8 + */ + execute(type: AuthType, level: SecureLevel, callback: AsyncCallback): void; + execute(type: AuthType, level: SecureLevel): Promise; + } + /** + * Get Authenticator instance. + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @return Returns an Authenticator. + * @deprecated since 8 + */ + function getAuthenticator(): Authenticator; + /** + * User authentication. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + class UserAuth { + /** + * Constructor to get the UserAuth class instance. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @return Returns the UserAuth class instance. + */ + constructor(); + /** + * Get version information. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @return Returns version information. + */ + getVersion(): number; + /** + * Check whether the authentication capability is available. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @permission ohos.permission.ACCESS_BIOMETRIC + * @param authType Credential type for authentication. + * @param authTrustLevel Trust level of authentication result. + * @return Returns a check result, which is specified by getAvailableStatus. + */ + getAvailableStatus(authType: UserAuthType, authTrustLevel: AuthTrustLevel): number; + /** + * Executes authentication. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @permission ohos.permission.ACCESS_BIOMETRIC + * @param challenge pass in challenge value. + * @param authType type of authentication. + * @param authTrustLevel Trust level of authentication result. + * @param callback Return result and acquireinfo through callback. + * @return Returns ContextId for cancel. + */ + auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array; + /** + * Cancels authentication with ContextID. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @permission ohos.permission.ACCESS_BIOMETRIC + * @param contextID Cancel authentication and pass in ContextID. + * @return Returns a number value indicating whether Cancel authentication was successful. + */ + cancelAuth(contextID: Uint8Array): number; + } + interface IUserAuthCallback { + /** + * The authentication result code is returned through the callback. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @param result authentication result code. + * @param extraInfo pass the specific information for different situation. + * If the authentication is passed, the authentication token is returned in extrainfo, + * If the authentication fails, the remaining authentication times are returned in extrainfo, + * If the authentication executor is locked, the freezing time is returned in extrainfo. + */ + onResult: (result: number, extraInfo: AuthResult) => void; + /** + * During an authentication, the TipsCode is returned through the callback. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @param module the executor type for authentication. + * @param acquire the tip code for different authentication executor. + * @param extraInfo reserved parameter. + */ + onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; + } + /** + * Authentication result: authentication token, remaining authentication times, freezing time. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + * @param token pass the authentication result if the authentication is passed. + * @param remainTimes return the remaining authentication times if the authentication fails. + * @param freezingTime return the freezing time if the authectication executor is locked. + */ + interface AuthResult { + token?: Uint8Array; + remainTimes?: number; + freezingTime?: number; + } + /** + * Result code. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + enum ResultCode { + /** + * Indicates that the result is success or ability is supported. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + SUCCESS = 0, + /** + * Indicates the the result is failure or ability is not supported. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FAIL = 1, + /** + * Indicates other errors. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + GENERAL_ERROR = 2, + /** + * Indicates that this operation has been canceled. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + CANCELED = 3, + /** + * Indicates that this operation has timed out. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + TIMEOUT = 4, + /** + * Indicates that this authentication type is not supported. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + TYPE_NOT_SUPPORT = 5, + /** + * Indicates that the authentication trust level is not supported. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + TRUST_LEVEL_NOT_SUPPORT = 6, + /** + * Indicates that the authentication task is busy. Wait for a few seconds and try again. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + BUSY = 7, + /** + * Indicates incorrect parameters. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + INVALID_PARAMETERS = 8, + /** + * Indicates that the authenticator is locked. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + LOCKED = 9, + /** + * Indicates that the user has not enrolled the authenticator. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + NOT_ENROLLED = 10 + } + /** + * Indicates the enumeration of prompt codes in the process of face authentication. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + enum FaceTips { + /** + * Indicates that the obtained facial image is too bright due to high illumination. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_TOO_BRIGHT = 1, + /** + * Indicates that the obtained facial image is too dark due to low illumination. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_TOO_DARK = 2, + /** + * Indicates that the face is too close to the device. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_TOO_CLOSE = 3, + /** + * Indicates that the face is too far away from the device. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_TOO_FAR = 4, + /** + * Indicates that the device is too high, and that only the upper part of the face is captured. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_TOO_HIGH = 5, + /** + * Indicates that the device is too low, and that only the lower part of the face is captured. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_TOO_LOW = 6, + /** + * Indicates that the device is deviated to the right, and that only the right part of the face is captured. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_TOO_RIGHT = 7, + /** + * Indicates that the device is deviated to the left, and that only the left part of the face is captured. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_TOO_LEFT = 8, + /** + * Indicates that the face moves too fast during facial information collection. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_TOO_MUCH_MOTION = 9, + /** + * Indicates that the face is not facing the device. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_POOR_GAZE = 10, + /** + * Indicates that no face is detected. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE_AUTH_TIP_NOT_DETECTED = 11 + } + /** + * Indicates the enumeration of prompt codes in the process of fingerprint authentication. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + enum FingerprintTips { + /** + * Indicates that the image acquired is good. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FINGERPRINT_AUTH_TIP_GOOD = 0, + /** + * Indicates that the fingerprint image is too noisy due to suspected or detected dirt on sensor. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FINGERPRINT_AUTH_TIP_DIRTY = 1, + /** + * Indicates that the fingerprint image is too noisy to process due to a detected condition. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FINGERPRINT_AUTH_TIP_INSUFFICIENT = 2, + /** + * Indicates that only a partial fingerprint image is detected. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FINGERPRINT_AUTH_TIP_PARTIAL = 3, + /** + * Indicates that the fingerprint image is incomplete due to quick motion. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FINGERPRINT_AUTH_TIP_TOO_FAST = 4, + /** + * Indicates that the fingerprint image is unreadable due to lack of motion. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FINGERPRINT_AUTH_TIP_TOO_SLOW = 5 + } + /** + * Credential type for authentication. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + enum UserAuthType { + /** + * Authentication type face. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FACE = 2, + /** + * Authentication type fingerprint. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + FINGERPRINT = 4 + } + /** + * Trust level of authentication results. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + enum AuthTrustLevel { + /** + * Authentication result trusted level 1. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + ATL1 = 10000, + /** + * Authentication result trusted level 2. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + ATL2 = 20000, + /** + * Authentication result trusted level 3. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + ATL3 = 30000, + /** + * Authentication result trusted level 4. + * @since 8 + * @syscap SystemCapability.UserIAM.UserAuth.Core + */ + ATL4 = 40000 + } +} +export default userAuth; diff --git a/build-tools/api/@ohos.util.ArrayList.d.ts b/build-tools/api/@ohos.util.ArrayList.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..daa057ff476bb49e1aebfb1c07f7f237caa4ee35 --- /dev/null +++ b/build-tools/api/@ohos.util.ArrayList.d.ts @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class ArrayList { + /** + * A constructor used to create a ArrayList object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the ArrayList.This is a number one higher than the highest index in the arraylist. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Appends the specified element to the end of this arraylist. + * @param element to be appended to this arraylist + * @returns the boolean type, returns true if the addition is successful, and returns false if it fails. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(element: T): boolean; + /** + * Inserts the specified element at the specified position in this + * arraylist. Shifts the element currently at that position (if any) and + * any subsequent elements to the right (adds one to their index). + * @param index index at which the specified element is to be inserted + * @param element element to be inserted + * @throws If index is greater than or equal to length, or less than 0, an exception is thrown and cannot be inserted + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insert(element: T, index: number): void; + /** + * Check if arraylist contains the specified element + * @param element element to be contained + * @return the boolean type,if arraylist contains the specified element,return true,else return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(element: T): boolean; + /** + * Returns the index of the first occurrence of the specified element + * in this arraylist, or -1 if this arraylist does not contain the element. + * @param element element to be contained + * @return the number type ,returns the lowest index such that or -1 if there is no such index. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOf(element: T): number; + /** + * Find the corresponding element according to the index, + * delete the element, and move the index of all elements to the right of the element forward by one. + * @param index the index in the arraylist + * @return the T type ,returns undefined if arraylist is empty,If the index is + * out of bounds (greater than or equal to length or less than 0), throw an exception + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByIndex(index: number): T; + /** + * Removes the first occurrence of the specified element from this arraylist, + * if it is present. If the arraylist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(element: T): boolean; + /** + * Returns in the index of the last occurrence of the specified element in this arraylist , + * or -1 if the arraylist does not contain the element. + * @param element element to find + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastIndexOf(element: T): number; + /** + * Removes from this arraylist all of the elements whose index is between fromIndex,inclusive,and toIndex ,exclusive. + * @param fromIndex The starting position of the index, containing the value at that index position + * @param toIndex the end of the index, excluding the value at that index + * @throws If the fromIndex is out of range (greater than or equal to length or less than 0), + * or if toIndex is less than fromIndex, an IndexOutOfBoundException is thrown + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByRange(fromIndex: number, toIndex: number): void; + /** + * Replaces each element of this arraylist with the result of applying the operator to that element. + * @param callbackfn (required) A function that accepts up to four arguments.The function to be called for + * each element in the arraylist,Returns the result of an operation + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param arrlist (Optional) The arraylist object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + replaceAllElements(callbackfn: (value: T, index?: number, arrlist?: ArrayList) => T, thisArg?: Object): void; + /** + * Executes a provided function once for each value in the arraylist object. + * @param callbackfn (required) A function that accepts up to four arguments.The function to + * be called for each element in the arraylist + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param arrlist (Optional) The arraylist object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, arrlist?: ArrayList) => void, thisArg?: Object): void; + /** + * Sorts this arraylist according to the order induced by the specified comparator,without comparator this parameter, + * it will default to ASCII sorting + * @param comparator (Optional) A function that accepts up to two arguments.Specifies the sort order. + * Must be a function,return number type,If it returns firstValue minus secondValue, it returns an arraylist + * sorted in ascending order;If it returns secondValue minus firstValue, it returns an arraylist sorted in descending order; + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next elements + * If this parameter is empty, it will default to ASCII sorting + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + sort(comparator?: (firstValue: T, secondValue: T) => number): void; + /** + * Returns a view of the portion of this arraylist between the specified fromIndex,inclusize,and toIndex,exclusive + * @param fromIndex The starting position of the index, containing the value at that index position + * @param toIndex the end of the index, excluding the value at that index + * @throws If the fromIndex or toIndex index is out of range (greater than or equal to length or less than 0), + * or if toIndex is less than fromIndex, an IndexOutOfBoundException is thrown + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + subArrayList(fromIndex: number, toIndex: number): ArrayList; + /** + * Removes all of the elements from this arraylist.The arraylist will + * be empty after this call returns.length becomes 0 + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns a shallow copy of this instance. (The elements themselves are not copied.) + * @return this arraylist instance + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clone(): ArrayList; + /** + * returns the capacity of this arraylist + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getCapacity(): number; + /** + * convert arraylist to array + * @return the Array type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + convertToArray(): Array; + /** + * Determine whether arraylist is empty and whether there is an element + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * If the newCapacity provided by the user is greater than or equal to length, + * change the capacity of the arraylist to newCapacity, otherwise the capacity will not be changed + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + increaseCapacityTo(newCapacity: number): void; + /** + * Limit the capacity to the current length + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + trimToCurrentLength(): void; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} +export default ArrayList; diff --git a/build-tools/api/@ohos.util.Deque.d.ts b/build-tools/api/@ohos.util.Deque.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bd7b94bdf562bc67cc88d8287e51acb515dbe406 --- /dev/null +++ b/build-tools/api/@ohos.util.Deque.d.ts @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class Deque { + /** + * A constructor used to create a Deque object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the Deque.This is a number one higher than the highest index in the deque. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Inserts an element into the deque header. + * @param element to be appended to this deque + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insertFront(element: T): void; + /** + * Inserting an element at the end of a deque + * @param element to be appended to this deque + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insertEnd(element: T): void; + /** + * Check if deque contains the specified element + * @param element element to be contained + * @return the boolean type,if deque contains the specified element,return true,else return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(element: T): boolean; + /** + * Obtains the header element of a deque. + * @return the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirst(): T; + /** + * Obtains the end element of a deque. + * @return the T type + * @throws an exception if the queue is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLast(): T; + /** + * Obtains the header element of a deque and delete the element. + * @return the T type + * @throws an exception if the deque is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + popFirst(): T; + /** + * Obtains the end element of a deque and delete the element. + * @return the T type + * @throws an exception if the deque is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + popLast(): T; + /** + * Executes a provided function once for each value in the deque object. + * @param callbackfn (required) A function that accepts up to four arguments.The function to be called for each element in the deque + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param deque (Optional) The deque object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, deque?: Deque) => void, thisArg?: Object): void; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} +export default Deque; diff --git a/build-tools/api/@ohos.util.HashMap.d.ts b/build-tools/api/@ohos.util.HashMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f0591d3d6875cf32f4452429c24026a72f395f52 --- /dev/null +++ b/build-tools/api/@ohos.util.HashMap.d.ts @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class HashMap { + /** + * A constructor used to create a HashMap object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the hashmap. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Returns whether the Map object contains elements + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Returns whether a key is contained in this map + * @param key need to determine whether to include the key + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasKey(key: K): boolean; + /** + * Returns whether a value is contained in this map + * @param value need to determine whether to include the value + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasValue(value: V): boolean; + /** + * Returns a specified element in a Map object, or null if there is no corresponding element + * @param key the index in HashMap + * @return value or null + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(key: K): V; + /** + * Adds all element groups in one map to another map + * @param map the Map object to add members + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setAll(map: HashMap): void; + /** + * Adds or updates a(new) key-value pair with a key and value specified for the Map object + * @param key Added or updated targets + * @param value Added or updated value + * @returns the map object after set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(key: K, value: V): Object; + /** + * Remove a specified element from a Map object + * @param key Target to be deleted + * @return Target mapped value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(key: K): V; + /** + * Clear all element groups in the map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns a new Iterator object that contains the keys contained in this map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + keys(): IterableIterator; + /** + * Returns a new Iterator object that contains the values contained in this map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; + /** + * Replace the old value by new value corresponding to the specified key + * @param key Updated targets + * @param newValue Updated the target mapped value + * @returns the boolean type(Is there a target pointed to by the key) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + replace(key: K, newValue: V): boolean; + /** + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: V, key?: K, map?: HashMap) => void, thisArg?: Object): void; + /** + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[ + K, + V + ]>; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator<[ + K, + V + ]>; +} +export default HashMap; diff --git a/build-tools/api/@ohos.util.HashSet.d.ts b/build-tools/api/@ohos.util.HashSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..47bf96286c1a463eab350c3b39a62d985fbeb965 --- /dev/null +++ b/build-tools/api/@ohos.util.HashSet.d.ts @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class HashSet { + /** + * A constructor used to create a HashSet object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the hashset. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Returns whether the Set object contains elements + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Returns whether the Set object contain s the elements + * @param value need to determine whether to include the element + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(value: T): boolean; + /** + * If the set does not contain the element, the specified element is added + * @param value Added element + * @returns the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(value: T): boolean; + /** + * Remove a specified element from a Set object + * @param value Target to be deleted + * @return the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(value: T): boolean; + /** + * Clears all element groups in a set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Executes a provided function once for each value in the Set object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: T, key?: T, set?: HashSet) => void, thisArg?: Object): void; + /** + * Returns a new Iterator object that contains the values contained in this set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; + /** + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[ + T, + T + ]>; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} +export default HashSet; diff --git a/build-tools/api/@ohos.util.LightWeightMap.d.ts b/build-tools/api/@ohos.util.LightWeightMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e0d795bfc6b9ab8b647bfdb257710849c19f977 --- /dev/null +++ b/build-tools/api/@ohos.util.LightWeightMap.d.ts @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class LightWeightMap { + /** + * A constructor used to create a LightWeightMap object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the LightWeightMap. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Returns whether this map has all the object in a specified map + * @param map the Map object to compare + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasAll(map: LightWeightMap): boolean; + /** + * Returns whether a key is contained in this map + * @param key need to determine whether to include the key + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasKey(key: K): boolean; + /** + * Returns whether a value is contained in this map + * @param value need to determine whether to include the value + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasValue(value: V): boolean; + /** + * Ensures that the capacity of an LightWeightMap container is greater than or equal to a apecified value, + * and that the container has all the original objects after capacity expansion + * @param minimumCapacity Minimum capacity to be reserved + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + increaseCapacityTo(minimumCapacity: number): void; + /** + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[ + K, + V + ]>; + /** + * Returns the value to which the specified key is mapped, or undefined if this map contains no mapping for the key + * @param key the index in LightWeightMap + * @return value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(key: K): V; + /** + * Obtains the index of the key equal to a specified key in an LightWeightMap container + * @param key Looking for goals + * @return Subscript corresponding to target + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOfKey(key: K): number; + /** + * Obtains the index of the value equal to a specified value in an LightWeightMap container + * @param value Looking for goals + * @return Subscript corresponding to target + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOfValue(value: V): number; + /** + * Returns whether the Map object contains elements + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Obtains the key at the loaction identified by index in an LightWeightMap container + * @param index Target subscript for search + * @return the key of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getKeyAt(index: number): K; + /** + * Obtains a ES6 iterator that contains all the keys of an LightWeightMap container + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + keys(): IterableIterator; + /** + * Adds all element groups in one map to another map + * @param map the Map object to add members + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setAll(map: LightWeightMap): void; + /** + * Adds or updates a(new) key-value pair with a key and value specified for the Map object + * @param key Added or updated targets + * @param value Added or updated value + * @returns the map object after set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(key: K, value: V): Object; + /** + * Remove the mapping for this key from this map if present + * @param key Target to be deleted + * @return Target mapped value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(key: K): V; + /** + * Deletes a key-value pair at the loaction identified by index from an LightWeightMap container + * @param index Target subscript for search + * @return the boolean type(Is there a delete value) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeAt(index: number): boolean; + /** + * Removes all of the mapping from this map + * The map will be empty after this call returns + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Sets the value identified by index in an LightWeightMap container to a specified value + * @param index Target subscript for search + * @param value Updated the target mapped value + * @return the boolean type(Is there a value corresponding to the subscript) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setValueAt(index: number, newValue: V): boolean; + /** + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: V, key?: K, map?: LightWeightMap) => void, thisArg?: Object): void; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator<[ + K, + V + ]>; + /** + * Obtains a string that contains all the keys and values in an LightWeightMap container + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + toString(): String; + /** + * Obtains the value identified by index in an LightWeightMap container + * @param index Target subscript for search + * @return the value of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getValueAt(index: number): V; + /** + * Returns an iterator of the values contained in this map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; +} +export default LightWeightMap; diff --git a/build-tools/api/@ohos.util.LightWeightSet.d.ts b/build-tools/api/@ohos.util.LightWeightSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..acd53bc0ceed9f8bc7338a5afdb24749ff6c6fe8 --- /dev/null +++ b/build-tools/api/@ohos.util.LightWeightSet.d.ts @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class LightWeightSet { + /** + * A constructor used to create a LightWeightSet object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the LightWeightSet. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * If the set does not contain the element, the specified element is added + * @param value Added element + * @returns the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(obj: T): boolean; + /** + * Adds all the objects in a specified LightWeightSet container to the current LightWeightSet container + * @param set the Set object to provide the added element + * @returns the boolean type(Is there any new data added successfully) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + addAll(set: LightWeightSet): boolean; + /** + * Returns whether this set has all the object in a specified set + * @param set the Set object to compare + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasAll(set: LightWeightSet): boolean; + /** + * Checks whether an LightWeightSet container has a specified key + * @param key need to determine whether to include the key + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(key: T): boolean; + /** + * Checks whether an the objects of an LightWeighSet containeer are of the same type as a specified Object LightWeightSet + * @param obj need to determine whether to include the obj + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + equal(obj: Object): boolean; + /** + * Ensures that the capacity of an LightWeightSet container is greater than or equal to a apecified value, + * and that the container has all the original objects after capacity expansion + * @param minimumCapacity Minimum capacity to be reserved + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + increaseCapacityTo(minimumCapacity: number): void; + /** + * Obtains the index of s key of a specified Object type in an LightWeightSet container + * @param key Looking for goals + * @return Subscript corresponding to target + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOf(key: T): number; + /** + * Deletes an object of a specified Object type from an LightWeightSet container + * @param key Target to be deleted + * @return Target element + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(key: T): T; + /** + * Deletes an object at the loaction identified by index from an LightWeightSet container + * @param index Target subscript for search + * @return the boolean type(Is there a delete value) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeAt(index: number): boolean; + /** + * Removes all of the mapping from this map + * The map will be empty after this call returns + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: T, key?: T, set?: LightWeightSet) => void, thisArg?: Object): void; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; + /** + * Obtains a string that contains all the keys and values in an LightWeightSet container + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + toString(): String; + /** + * Obtains an Array that contains all the objects of an LightWeightSet container. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + toArray(): Array; + /** + * Obtains the object at the location identified by index in an LightWeightSet container + * @param index Target subscript for search + * @return the value of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getValueAt(index: number): T; + /** + * Returns a ES6 iterator of the values contained in this Set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; + /** + * Returns a Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[ + T, + T + ]>; + /** + * Returns whether the set object contains elements + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; +} +export default LightWeightSet; diff --git a/build-tools/api/@ohos.util.LinkedList.d.ts b/build-tools/api/@ohos.util.LinkedList.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..886405bbf9f08ca5530a8f82e88bbc5743c9538f --- /dev/null +++ b/build-tools/api/@ohos.util.LinkedList.d.ts @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class LinkedList { + /** + * A constructor used to create a LinkedList object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the LinkedList. This is a number one higher than the highest index in the linkedlist. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Appends the specified element to the end of this linkedlist. + * @param element to be appended to this linkedlist + * @returns the boolean type, returns true if the addition is successful, and returns false if it fails. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(element: T): boolean; + /** + * Inserts the specified element at the specified position in this linkedlist. + * @param index index at which the specified element is to be inserted + * @param element element to be inserted + * @throws If index is greater than or equal to length, or less than 0, an exception is thrown and cannot be inserted + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insert(index: number, element: T): void; + /** + * Returns the element at the specified position in this linkedlist, + * or returns undefined if this linkedlist is empty + * @param index specified position + * @return the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(index: number): T; + /** + * Inserts the specified element at the beginning of this LinkedList. + * @param element the element to add + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + addFirst(element: T): void; + /** + * Retrieves and removes the head (first element) of this linkedlist. + * @return the head of this list + * @throws NoSuchElementException if this linkedlist is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeFirst(): T; + /** + * Removes and returns the last element from this linkedlist. + * @return the head of this list + * @throws NoSuchElementException if this linkedlist is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + * + */ + removeLast(): T; + /** + * Check if linkedlist contains the specified element + * @param element element to be contained + * @return the boolean type,if linkedList contains the specified element,return true,else return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(element: T): boolean; + /** + * Returns the index of the first occurrence of the specified element + * in this linkedlist, or -1 if this linkedlist does not contain the element. + * @param element element to be contained + * @return the number type ,returns the lowest index such that or -1 if there is no such index. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOf(element: T): number; + /** + * Find the corresponding element according to the index, + * @param index the index in the linkedlist + * @return the T type ,returns undefined if linkedlist is empty,If the index is + * out of bounds (greater than or equal to length or less than 0), throw an exception + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByIndex(index: number): T; + /** + * Removes the first occurrence of the specified element from this linkedlist, + * if it is present. If the linkedlist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(element: T): boolean; + /** + * Removes the first occurrence of the specified element from this linkedlist, + * if it is present. If the linkedlist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeFirstFound(element: T): boolean; + /** + * Removes the last occurrence of the specified element from this linkedlist, + * if it is present. If the linkedlist does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeLastFound(element: T): boolean; + /** + * Returns in the index of the last occurrence of the specified element in this linkedlist , + * or -1 if the linkedlist does not contain the element. + * @param element element to find + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastIndexOf(element: T): number; + /** + * Returns the first element (the item at index 0) of this linkedlist. + * or returns undefined if linkedlist is empty + * @return the T type ,returns undefined if linkedList is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirst(): T; + /** + * Returns the Last element (the item at index length-1) of this linkedlist. + * or returns undefined if linkedlist is empty + * @return the T type ,returns undefined if linkedList is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLast(): T; + /** + * Replaces the element at the specified position in this Vector with the specified element + * @param element replaced element + * @param index index to find + * @return the T type ,returns undefined if linkedList is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(index: number, element: T): T; + /** + * Replaces each element of this linkedlist with the result of applying the operator to that element. + * @param callbackfn (required) A function that accepts up to four arguments. + * The function to be called for each element in the linkedlist,Returns the result of an operation + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param LinkedList (Optional) The linkedlist object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, LinkedList?: LinkedList) => void, thisArg?: Object): void; + /** + * Removes all of the elements from this linkedlist.The linkedlist will + * be empty after this call returns.length becomes 0 + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns a shallow copy of this instance. (The elements themselves are not copied.) + * @return this linkedlist instance + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clone(): LinkedList; + /** + * convert linkedlist to array + * @return the Array type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + convertToArray(): Array; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} +export default LinkedList; diff --git a/build-tools/api/@ohos.util.List.d.ts b/build-tools/api/@ohos.util.List.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5488de394696e2b67e0afad0a49c348ccd5a7ba9 --- /dev/null +++ b/build-tools/api/@ohos.util.List.d.ts @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class List { + /** + * A constructor used to create a List object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the List. This is a number one higher than the highest index in the list. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Appends the specified element to the end of this list. + * @param element to be appended to this list + * @returns the boolean type, returns true if the addition is successful, and returns false if it fails. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(element: T): boolean; + /** + * Inserts the specified element at the specified position in this list. + * @param index index at which the specified element is to be inserted + * @param element element to be inserted + * @throws If index is greater than or equal to length, or less than 0, an exception is thrown and cannot be inserted + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insert(element: T, index: number): void; + /** + * Returns the element at the specified position in this list, + * or returns undefined if this list is empty + * @param index specified position + * @return the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(index: number): T; + /** + * Check if list contains the specified element + * @param element element to be contained + * @return the boolean type,if list contains the specified element,return true,else return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(element: T): boolean; + /** + * Returns the index of the first occurrence of the specified element + * in this list, or -1 if this list does not contain the element. + * @param element element to be contained + * @return the number type ,returns the lowest index such that or -1 if there is no such index. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOf(element: T): number; + /** + * Find the corresponding element according to the index, + * @param index the index in the list + * @return the T type ,returns undefined if list is empty,If the index is + * out of bounds (greater than or equal to length or less than 0), throw an exception + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByIndex(index: number): T; + /** + * Removes the first occurrence of the specified element from this list, + * if it is present. If the list does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(element: T): boolean; + /** + * Returns in the index of the last occurrence of the specified element in this list , + * or -1 if the list does not contain the element. + * @param element element to find + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastIndexOf(element: T): number; + /** + * Returns the first element (the item at index 0) of this list. + * or returns undefined if list is empty + * @return the T type ,returns undefined if list is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirst(): T; + /** + * Returns the Last element (the item at index length-1) of this list. + * or returns undefined if list is empty + * @return the T type ,returns undefined if list is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLast(): T; + /** + * Replaces the element at the specified position in this List with the specified element + * @param element replaced element + * @param index index to find + * @return the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(index: number, element: T): T; + /** + * Compares the specified object with this list for equality.if the object are the same as this list + * return true, otherwise return false. + * @param obj Compare objects + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + equal(obj: Object): boolean; + /** + * Replaces each element of this list with the result of applying the operator to that element. + * @param callbackfn (required) A function that accepts up to four arguments. + * The function to be called for each element in the list,Returns the result of an operation + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param List (Optional) The list object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, List?: List) => void, thisArg?: Object): void; + /** + * Sorts this list according to the order induced by the specified comparator + * @param comparator (required) A function that accepts up to two arguments. + * Specifies the sort order. Must be a function,return number type,If it returns firstValue + * minus secondValue, it returns an list sorted in ascending order;If it returns secondValue + * minus firstValue, it returns an list sorted in descending order; + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next elements + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + sort(comparator: (firstValue: T, secondValue: T) => number): void; + /** + * Removes all of the elements from this list.The list will + * be empty after this call returns.length becomes 0 + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns a view of the portion of this list between the specified fromIndex,inclusize,and toIndex,exclusive + * @param fromIndex The starting position of the index, containing the value at that index position + * @param toIndex the end of the index, excluding the value at that index + * @throws If the fromIndex or toIndex index is out of range (greater than or equal to length or less than 0), + * or if toIndex is less than fromIndex, an IndexOutOfBoundException is thrown + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getSubList(fromIndex: number, toIndex: number): List; + /** + * Replaces each element of this list with the result of applying the operator to that element. + * @param callbackfn (required) A function that accepts up to four arguments. + * The function to be called for each element in the list,Returns the result of an operation + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param list (Optional) The list object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + replaceAllElements(callbackfn: (value: T, index?: number, list?: List) => T, thisArg?: Object): void; + /** + * convert list to array + * @return the Array type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + convertToArray(): Array; + /** + * Determine whether list is empty and whether there is an element + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} +export default List; diff --git a/build-tools/api/@ohos.util.PlainArray.d.ts b/build-tools/api/@ohos.util.PlainArray.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d3f8d5dbaff9f19d02b7bfdd4cc6bdd020b0e14 --- /dev/null +++ b/build-tools/api/@ohos.util.PlainArray.d.ts @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class PlainArray { + /** + * A constructor used to create a PlainArray object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the PlainArray. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Appends a key-value pair to PlainArray + * @param key Added the key of key-value + * @param value Added the value of key-value + * @throws Throws this exception if input is invaild + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(key: number, value: T): void; + /** + * Clears the current PlainArray object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Obtains a clone of the current PlainArray object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clone(): PlainArray; + /** + * Checks whether the current PlainArray object contains the specified key + * @param key need to determine whether to include the key + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(key: number): boolean; + /** + * Queries the value associated with the specified key + * @param key Looking for goals + * @return the value of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(key: number): T; + /** + * Queries the index for a specified key + * @param key Looking for goals + * @return Subscript corresponding to target + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOfKey(key: number): number; + /** + * Queries the index for a specified value + * @param value Looking for goals + * @return Subscript corresponding to target + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOfValue(value: T): number; + /** + * Checks whether the current PlainArray object is empty + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Queries the key at a specified index + * @param index Target subscript for search + * @return the key of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getKeyAt(index: number): number; + /** + * Remove the key-value pair based on a specified key if it exists and return the value + * @param key Target to be deleted + * @return Target mapped value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(key: number): T; + /** + * Remove the key-value pair at a specified index if it exists and return the value + * @param index Target subscript for search + * @return the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeAt(index: number): T; + /** + * Remove a group of key-value pairs from a specified index + * @param index remove start index + * @param size Expected deletion quantity + * @return Actual deleted quantity + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeRangeFrom(index: number, size: number): number; + /** + * Update value on specified index + * @param index Target subscript for search + * @param value Updated the target mapped value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setValueAt(index: number, value: T): void; + /** + * Obtains the string representation of the PlainArray object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + toString(): String; + /** + * Queries the value at a specified index + * @param index Target subscript for search + * @return the value of key-value pairs + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getValueAt(index: number): T; + /** + * Executes a provided function once for each value in the PlainArray object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, PlainArray?: PlainArray) => void, thisArg?: Object): void; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator<[ + number, + T + ]>; +} +export default PlainArray; diff --git a/build-tools/api/@ohos.util.Queue.d.ts b/build-tools/api/@ohos.util.Queue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..62858543400d6c125ebc510c3cb9017a070c66fe --- /dev/null +++ b/build-tools/api/@ohos.util.Queue.d.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class Queue { + /** + * A constructor used to create a Queue object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the Queue.This is a number one higher than the highest index in the queue. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Inserting specified element at the end of a queue if it is possible to do + * so immediately without violating capacity restrictions. + * @param element to be appended to this queue + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(element: T): boolean; + /** + * Obtains the header element of a queue. + * @return the T type + * @throws an exception if the queue is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirst(): T; + /** + * Retrieves and removes the head of this queue + * @return the T type + * @throws an exception if the queue is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + pop(): T; + /** + * Executes a provided function once for each value in the queue object. + * @param callbackfn (required) A function that accepts up to four arguments.The function to + * be called for each element in the queue + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param Queue (Optional) The queue object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, Queue?: Queue) => void, thisArg?: Object): void; + /** + * returns an iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} +export default Queue; diff --git a/build-tools/api/@ohos.util.Stack.d.ts b/build-tools/api/@ohos.util.Stack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..be5bcd6328ee0c221e76abf5d90c80ac16810b1c --- /dev/null +++ b/build-tools/api/@ohos.util.Stack.d.ts @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class Stack { + /** + * A constructor used to create a Stack object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the Stack. This is a number one higher than the highest index in the Stack. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Tests if this stack is empty + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Looks at the object at the top of this stack without removing it from the stack + * Return undfined if this stack is empty + * @return the top value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + peek(): T; + /** + * Removes the object at the top of this stack and returns that object as the value of this function + * an exception if the stack is empty + * @returns Stack top value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + pop(): T; + /** + * Pushes an item onto the top of this stack + * @param item to be appended to this Stack + * @returns the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + push(item: T): T; + /** + * Returns the 1-based position where an object is on this stack + * @param element Target to be deleted + * @returns the T type,If there is no such element, return -1 + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + locate(element: T): number; + /** + * Executes a provided function once for each value in the Stack object. + * @param callbackfn (required) A function that accepts up to four arguments.The function + * to be called for each element in the Stack + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param stack (Optional) The Stack object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, stack?: Stack) => void, thisArg?: Object): void; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} +export default Stack; diff --git a/build-tools/api/@ohos.util.TreeMap.d.ts b/build-tools/api/@ohos.util.TreeMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4ff80e912c4d5a8ad53d06afeb8039176fc409e5 --- /dev/null +++ b/build-tools/api/@ohos.util.TreeMap.d.ts @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class TreeMap { + /** + * A constructor used to create a TreeMap object. + * @param comparator (Optional) User-defined comparison functions + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next element + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(comparator?: (firstValue: K, secondValue: K) => boolean); + /** + * Gets the element number of the hashmap. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Returns whether the Map object contains elements + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Returns whether a key is contained in this map + * @param key need to determine whether to include the key + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasKey(key: K): boolean; + /** + * Returns whether a value is contained in this map + * @param value need to determine whether to include the value + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + hasValue(value: V): boolean; + /** + * Returns a specified element in a Map object, or null if there is no corresponding element + * @param key the index in TreeMap + * @return value or null + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(key: K): V; + /** + * Obtains the first sorted key in the treemap. + * Or returns undefined if tree map is empty + * @return value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirstKey(): K; + /** + * Obtains the last sorted key in the treemap. + * Or returns undefined if tree map is empty + * @return value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastKey(): K; + /** + * Adds all element groups in one map to another map + * @param map the Map object to add members + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setAll(map: TreeMap): void; + /** + * Adds or updates a(new) key-value pair with a key and value specified for the Map object + * @param key Added or updated targets + * @param value Added or updated value + * @returns the map object after set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(key: K, value: V): Object; + /** + * Remove a specified element from a Map object + * @param key Target to be deleted + * @return Target mapped value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(key: K): V; + /** + * Clear all element groups in the map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns the greatest element smaller than or equal to the specified key + * if the key does not exist, undefied is returned + * @param key Objective of comparison + * @return key or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLowerKey(key: K): K; + /** + * Returns the least element greater than or equal to the specified key + * if the key does not exist, undefied is returned + * @param key Objective of comparison + * @return key or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getHigherKey(key: K): K; + /** + * Returns a new Iterator object that contains the keys contained in this map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + keys(): IterableIterator; + /** + * Returns a new Iterator object that contains the values contained in this map + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; + /** + * Replace the old value by new value corresponding to the specified key + * @param key Updated targets + * @param value Updated the target mapped value + * @returns the boolean type(Is there a target pointed to by the key) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + replace(key: K, newValue: V): boolean; + /** + * Executes the given callback function once for each real key in the map. + * It does not perform functions on deleted keys + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: V, key?: K, map?: TreeMap) => void, thisArg?: Object): void; + /** + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[ + K, + V + ]>; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator<[ + K, + V + ]>; +} +export default TreeMap; diff --git a/build-tools/api/@ohos.util.TreeSet.d.ts b/build-tools/api/@ohos.util.TreeSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..104723e754d8b3269c421eb3e0acbfa5010c4304 --- /dev/null +++ b/build-tools/api/@ohos.util.TreeSet.d.ts @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class TreeSet { + /** + * A constructor used to create a TreeSet object. + * @param comparator (Optional) User-defined comparison functions + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next element + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(comparator?: (firstValue: T, secondValue: T) => boolean); + /** + * Gets the element number of the TreeSet. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Returns whether the Set object contains elements + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * Returns whether the Set object contain s the elements + * @param value need to determine whether to include the element + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(value: T): boolean; + /** + * If the set does not contain the element, the specified element is added + * @param value Added element + * @returns the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(value: T): boolean; + /** + * Remove a specified element from a Set object + * @param value Target to be deleted + * @return the boolean type(Is there contain this element) + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(value: T): boolean; + /** + * Clears all element groups in a set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Gets the first elements in a set + * @return value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirstValue(): T; + /** + * Gets the last elements in a set + * @return value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastValue(): T; + /** + * Returns the greatest element smaller than or equal to the specified key + * if the key does not exist, undefied is returned + * @param key Objective of comparison + * @return key or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLowerValue(key: T): T; + /** + * Returns the least element greater than or equal to the specified key + * if the key does not exist, undefied is returned + * @param key Objective of comparison + * @return key or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getHigherValue(key: T): T; + /** + * Return and delete the first element, returns undefined if tree set is empty + * @return first value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + popFirst(): T; + /** + * Return and delete the last element, returns undefined if tree set is empty + * @return last value or undefined + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + popLast(): T; + /** + * Executes a provided function once for each value in the Set object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value?: T, key?: T, set?: TreeSet) => void, thisArg?: Object): void; + /** + * Returns a new Iterator object that contains the values contained in this set + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + values(): IterableIterator; + /** + * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + entries(): IterableIterator<[ + T, + T + ]>; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} +export default TreeSet; diff --git a/build-tools/api/@ohos.util.Vector.d.ts b/build-tools/api/@ohos.util.Vector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d76cc3713b93d67cd8ae447021c3f2cb2496080c --- /dev/null +++ b/build-tools/api/@ohos.util.Vector.d.ts @@ -0,0 +1,281 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare class Vector { + /** + * A constructor used to create a Vector object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * Gets the element number of the Vector. This is a number one higher than the highest index in the vector. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + length: number; + /** + * Appends the specified element to the end of this vector. + * @param element to be appended to this vector + * @returns the boolean type, returns true if the addition is successful, and returns false if it fails. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + add(element: T): boolean; + /** + * Inserts the specified element at the specified position in this + * vector. Shifts the element currently at that position (if any) and + * any subsequent elements to the right (adds one to their index). + * @param index index at which the specified element is to be inserted + * @param element element to be inserted + * @throws If index is greater than or equal to length, or less than 0, an exception is thrown and cannot be inserted + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + insert(element: T, index: number): void; + /** + * Check if vector contains the specified element + * @param element element to be contained + * @return the boolean type,if vector contains the specified element,return true,else return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + has(element: T): boolean; + /** + * Returns the element at the specified position in this Vector,or returns undefined if vector is empty + * @param element element to be contained + * @return the number type ,returns the lowest index such that or -1 if there is no such index. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + get(index: number): T; + /** + * Returns the index of the first occurrence of the specified element + * in this vector, or -1 if this vector does not contain the element. + * @param element current index + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexOf(element: T): number; + /** + * Returns the first component (the item at index 0) of this vector. + * or returns undefined if vector is empty + * @return the T type ,returns undefined if vector is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getFirstElement(): T; + /** + * Returns the Last component (the item at index length-1) of this vector. + * or returns undefined if vector is empty + * @return the T type ,returns undefined if vector is empty + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastElement(): T; + /** + * Find the corresponding element according to the index, + * delete the element, and move the index of all elements to the right of the element forward by one. + * @param index the index in the vector + * @return the T type ,returns undefined if vector is empty,If the index is + * out of bounds (greater than or equal to length or less than 0), throw an exception + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByIndex(index: number): T; + /** + * Removes the first occurrence of the specified element from this vector, + * if it is present. If the vector does not contain the element, it is + * unchanged. More formally, removes the element with the lowest index + * @param element element to remove + * @return the boolean type ,If there is no such element, return false + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + remove(element: T): boolean; + /** + * Replaces the element at the specified position in this Vector with the specified element + * @param element replaced element + * @param index index to find + * @return the T type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + set(index: number, element: T): T; + /** + * Returns in the index of the last occurrence of the specified element in this vector , + * or -1 if the vector does not contain the element. + * @param element element to find + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastIndexOf(element: T): number; + /** + * Returns the index of the last occurrence of the specified element in this vector ,searching backwards from index, + * or returns -1 if the element is not found,or -1 if there is no such index + * @param element element to find + * @param index start index + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLastIndexFrom(element: T, index: number): number; + /** + * Returns the index of the first occurrence of the specified element in this vector ,searching forwards from index, + * or returns -1 if the element is not found,or -1 if there is no such index + * @param element element to find + * @param index start index + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getIndexFrom(element: T, index: number): number; + /** + * Removes from this vector all of the elements whose index is between fromIndex,inclusive,and toIndex ,exclusive. + * @param fromIndex The starting position of the index, containing the value at that index position + * @param toIndex the end of the index, excluding the value at that index + * @throws If the fromIndex is out of range (greater than or equal to length or less than 0), + * or if toIndex is less than fromIndex, an IndexOutOfBoundException is thrown + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + removeByRange(fromIndex: number, toIndex: number): void; + /** + * Replaces each element of this vector with the result of applying the operator to that element. + * @param callbackfn (required) A function that accepts up to four arguments.The function to be called + * for each element in the vector,Returns the result of an operation + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param vector (Optional) The vector object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + replaceAllElements(callbackfn: (value: T, index?: number, vector?: Vector) => T, thisArg?: Object): void; + /** + * Executes a provided function once for each value in the vector object. + * @param callbackfn (required) A function that accepts up to four arguments.The function to be + * called for each element in the vector + * @param Value (required) current element + * @param Index (Optional) The index value of the current element. + * @param vector (Optional) The vector object to which the current element belongs. + * @param thisArg (Optional) The value passed to the function generally uses the "this" value. + * If this parameter is empty, "undefined" will be passed to the "this" value + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + forEach(callbackfn: (value: T, index?: number, vector?: Vector) => void, thisArg?: Object): void; + /** + * Sorts this vector according to the order induced by the specified comparator,without comparator + * this parameter, it will default to ASCII sorting + * @param comparator (Optional) A function that accepts up to two arguments.Specifies the sort order. + * Must be a function,return number type,If it returns firstValue minus secondValue, it returns an vector sorted + * in ascending order;If it returns secondValue minus firstValue, it returns an vector sorted in descending order; + * @param firstValue (Optional) previous element + * @param secondValue (Optional) next elements + * If this parameter is empty, it will default to ASCII sorting + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + sort(comparator?: (firstValue: T, secondValue: T) => number): void; + /** + * Returns a view of the portion of this vector between the specified fromIndex,inclusize,and toIndex,exclusive + * @param fromIndex The starting position of the index, containing the value at that index position + * @param toIndex the end of the index, excluding the value at that index + * @throws If the fromIndex or toIndex index is out of range (greater than or equal to length or less than 0), + * or if toIndex is less than fromIndex, an IndexOutOfBoundException is thrown + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + subVector(fromIndex: number, toIndex: number): Vector; + /** + * Removes all of the elements from this vector.The vector will + * be empty after this call returns.length becomes 0 + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Returns a shallow copy of this instance. (The elements themselves are not copied.) + * @return this vector instance + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clone(): Vector; + /** + * Sets the length of this vector + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setLength(newSize: number): void; + /** + * returns the capacity of this vector + * @return the number type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getCapacity(): number; + /** + * convert vector to array + * @return the Array type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + convertToArray(): Array; + /** + * Determine whether vector is empty and whether there is an element + * @return the boolean type + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmpty(): boolean; + /** + * If the newCapacity provided by the user is greater than or equal to length, + * change the capacity of the vector to newCapacity, otherwise the capacity will not be changed + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + increaseCapacityTo(newCapacity: number): void; + /** + * Returns a string representation of this Vector, + * containing the String representation of each element + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + toString(): string; + /** + * Limit the capacity to the current length + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + trimToCurrentLength(): void; + /** + * Copies the components of this vector into the specified array, + * to overwrite elements of the same index + * @param Array replaced array + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + copyToArray(array: Array): void; + /** + * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + [Symbol.iterator](): IterableIterator; +} +export default Vector; diff --git a/build-tools/api/@ohos.util.d.ts b/build-tools/api/@ohos.util.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..153f0e7a25789d3f21f164aa7f637fab5ae396bf --- /dev/null +++ b/build-tools/api/@ohos.util.d.ts @@ -0,0 +1,921 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * TextDecoder support full encoding in ICU data utf-8 utf-16 iso8859 must support in all device, TextEncoder takes a + * stream of code points as input and emits a stream of UTF-8 bytes, and system help function. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @import import util from '@ohos.util'; + * @permission N/A + */ +declare namespace util { + /** + * %s: String will be used to convert all values except BigInt, Object and -0. BigInt values will be represented + * with an n and Objects that have no user defined toString function are inspected using util.inspect() with + * options { depth: 0, colors: false, compact: 3 }. + * %d: Number will be used to convert all values except BigInt and Symbol. + * %i: parseInt(value, 10) is used for all values except BigInt and Symbol. + * %f: parseFloat(value) is used for all values except Bigint and Symbol. + * %j: JSON. Replaced with the string '[Circular]' if the argument contains circular references. + * %o: Object. A string representation of an object with generic JavaScript object formatting.Similar to + * util.inspect() with options { showHidden: true, showProxy: true}. This will show the full object including + * non-enumerable properties and proxies. + * %O: Object. A string representation of an object with generic JavaScript object formatting. + * %O: Object. A string representation of an object with generic JavaScript object formatting.Similar to + * util.inspect() without options. This will show the full object not including non-enumerable properties and + * proxies. + * %c: CSS. This specifier is ignored and will skip any CSS passed in. + * %%: single percent sign ('%'). This does not consume an argument.Returns: The formatted string. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param format styled string + * @param args data to be formatted + * @return Return the character string formatted in a specific format + */ + function printf(format: string, ...args: Object[]): string; + /** + * Get the string name of the system errno. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param errno the error code generated by an error in the system + * @return return the string name of a system errno + */ + function getErrorString(errno: number): string; + /** + * Takes an async function (or a function that returns a Promise) and returns a function following the + * error-first callback style. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param original asynchronous function + */ + function callbackWrapper(original: Function): (err: Object, value: Object) => void; + /** + * Takes a function following the common error-first callback style, i.e taking an (err, value) => + * callback as the last argument, and return a function that returns promises. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param original asynchronous function + * @return return a function that returns promises + */ + function promisify(original: (err: Object, value: Object) => void): Function; + /** + * Takes a function following the common error-first callback style, i.e taking an (err, value) => + * callback as the last argument, and return a version that returns promises. + * @since 7 + * @deprecated since 9 + * @syscap SystemCapability.Utils.Lang + * @param original asynchronous function + * @return return a version that returns promises + */ + function promiseWrapper(original: (err: Object, value: Object) => void): Object; + class TextDecoder { + /** + * the source encoding's name, lowercased. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly encoding: string; + /** + * Returns `true` if error mode is "fatal", and `false` otherwise. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly fatal: boolean; + /** + * Returns `true` if ignore BOM flag is set, and `false` otherwise. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly ignoreBOM = false; + /** + * the textEncoder constructor. + * @param 7 + * @syscap SystemCapability.Utils.Lang + * @param encoding decoding format + */ + constructor(encoding?: string, options?: { + fatal?: boolean; + ignoreBOM?: boolean; + }); + /** + * Returns the result of running encoding's decoder. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param input decoded numbers in accordance with the format + * @return return decoded text + */ + decode(input: Uint8Array, options?: { + stream?: false; + }): string; + } + class TextEncoder { + /** + * Encoding format. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly encoding = "utf-8"; + /** + * the textEncoder constructor. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + /** + * the textEncoder constructor. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param encoding The string for encoding format. + */ + constructor(encoding?: string); + /** + * Returns the result of encoder. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param The string to be encoded. + * @return returns the encoded text. + */ + encode(input?: string): Uint8Array; + /** + * encode string, write the result to dest array. + * @since 7 + * @syscap SystemCapability.Utils.Lang + * @param input The string to be encoded. + * @param dest decoded numbers in accordance with the format + * @return returns Returns the object, where read represents + * the number of characters that have been encoded, and written + * represents the number of bytes occupied by the encoded characters. + */ + encodeInto(input: string, dest: Uint8Array): { + read: number; + written: number; + }; + } + class RationalNumber { + /** + * A constructor used to create a RationalNumber instance with a given numerator and denominator. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param numerator An integer number + * @param denominator An integer number + */ + constructor(numerator: number, denominator: number); + /** + * Creates a RationalNumber object based on a given string. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param String Expression of Rational Numbers + * @return Returns a RationalNumber object generated based on the given string. + */ + static createRationalFromString(rationalString: string): RationalNumber; + /** + * Compares the current RationalNumber object to the given object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param An object of other rational numbers + * @return Returns 0 or 1, or -1, depending on the comparison. + */ + compareTo(another: RationalNumber): number; + /** + * Compares two objects for equality. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param An object + * @return Returns true if the given object is the same as the current object; Otherwise, false is returned. + */ + equals(obj: Object): boolean; + /** + * Gets integer and floating-point values of a rational number object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the integer and floating-point values of a rational number object. + */ + valueOf(): number; + /** + * Get the greatest common divisor of two integers. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param number1 is an integer. + * @param number2 is an integer. + * @return Returns the greatest common divisor of two integers, integer type. + */ + static getCommonDivisor(number1: number, number2: number): number; + /** + * Gets the denominator of the current object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the denominator of the current object. + */ + getDenominator(): number; + /** + * Gets the numerator​ of the current object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the numerator​ of the current object. + */ + getNumerator(): number; + /** + * Checks whether the current RationalNumber object represents an infinite value. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return If the denominator is not 0, true is returned. Otherwise, false is returned. + */ + isFinite(): boolean; + /** + * Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return If both the denominator and numerator are 0, true is returned. Otherwise, false is returned. + */ + isNaN(): boolean; + /** + * Checks whether the current RationalNumber object represents the value 0. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return If the value represented by the current object is 0, true is returned. Otherwise, false is returned. + */ + isZero(): boolean; + /** + * Obtains a string representation of the current RationalNumber object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns a string representation of the current RationalNumber object. + */ + toString(): string; + } + class LruBuffer { + /** + * Default constructor used to create a new LruBuffer instance with the default capacity of 64. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param capacity Indicates the capacity to customize for the buffer. + */ + constructor(capacity?: number); + /** + * Updates the buffer capacity to a specified capacity. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param newCapacity Indicates the new capacity to set. + */ + updateCapacity(newCapacity: number): void; + /** + *Returns a string representation of the object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the string representation of the object and outputs the string representation of the object. + */ + toString(): string; + /** + * Obtains a list of all values in the current buffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the total number of values in the current buffer. + */ + length: number; + /** + * Obtains the capacity of the current buffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the capacity of the current buffer. + */ + getCapacity(): number; + /** + * Clears key-value pairs from the current buffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + clear(): void; + /** + * Obtains the number of times createDefault(Object) returned a value. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the number of times createDefault(java.lang.Object) returned a value. + */ + getCreateCount(): number; + /** + * Obtains the number of times that the queried values are not matched. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the number of times that the queried values are not matched. + */ + getMissCount(): number; + /** + * Obtains the number of times that values are evicted from the buffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the number of times that values are evicted from the buffer. + */ + getRemovalCount(): number; + /** + * Obtains the number of times that the queried values are successfully matched. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the number of times that the queried values are successfully matched. + */ + getMatchCount(): number; + /** + * Obtains the number of times that values are added to the buffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the number of times that values are added to the buffer. + */ + getPutCount(): number; + /** + * Checks whether the current buffer is empty. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns true if the current buffer contains no value. + */ + isEmpty(): boolean; + /** + * Obtains the value associated with a specified key. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param key Indicates the key to query. + * @return Returns the value associated with the key if the specified key is present in the buffer; returns null otherwise. + */ + get(key: K): V | undefined; + /** + * Adds a key-value pair to the buffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param key Indicates the key to add. + * @param value Indicates the value associated with the key to add. + * @return Returns the value associated with the added key; returns the original value if the key to add already exists. + */ + put(key: K, value: V): V; + /** + * Obtains a list of all values in the current buffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the list of all values in the current buffer in ascending order, from the most recently accessed to least recently accessed. + */ + values(): V[]; + /** + * Obtains a list of keys for the values in the current buffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns a list of keys sorted from most recently accessed to least recently accessed. + */ + keys(): K[]; + /** + * Deletes a specified key and its associated value from the current buffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param key Indicates the key to delete. + * @return Returns an Optional object containing the deleted key-value pair; returns an empty Optional object if the key does not exist. + */ + remove(key: K): V | undefined; + /** + * Executes subsequent operations after a value is deleted. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param isEvict The parameter value is true if this method is called due to insufficient capacity, and the parameter value is false in other cases. + * @param key Indicates the deleted key. + * @param value Indicates the deleted value. + * @param newValue The parameter value is the new value associated if the put(java.lang.Object,java.lang.Object) method is called and the key to add already exists. The parameter value is null in other cases. + */ + afterRemoval(isEvict: boolean, key: K, value: V, newValue: V): void; + /** + * Checks whether the current buffer contains a specified key. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param key Indicates the key to check. + * @return Returns true if the buffer contains the specified key. + */ + contains(key: K): boolean; + /** + * Executes subsequent operations if miss to compute a value for the specific key. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param key Indicates the missed key. + * @return Returns the value associated with the key. + */ + createDefault(key: K): V; + /** + * Returns an array of key-value pairs of enumeratable properties of a given object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns an array of key-value pairs for the enumeratable properties of the given object itself. + */ + entries(): IterableIterator<[ + K, + V + ]>; + /** + * Specifies the default iterator for an object. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns a two - dimensional array in the form of key - value pairs. + */ + [Symbol.iterator](): IterableIterator<[ + K, + V + ]>; + } + interface ScopeComparable { + /** + * The comparison function is used by the scope. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns whether the current object is greater than or equal to the input object. + */ + compareTo(other: ScopeComparable): boolean; + } + /** + * A type used to denote ScopeComparable or number. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + type ScopeType = ScopeComparable | number; + class Scope { + /** + * A constructor used to create a Scope instance with the lower and upper bounds specified. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param lowerObj A ScopeType value + * @param upperObj A ScopeType value + */ + constructor(lowerObj: ScopeType, upperObj: ScopeType); + /** + * Obtains a string representation of the current range. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns a string representation of the current range object. + */ + toString(): string; + /** + * Returns the intersection of a given range and the current range. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param range A Scope range object + * @return Returns the intersection of a given range and the current range. + */ + intersect(range: Scope): Scope; + /** + * Returns the intersection of the current range and the range specified by the given lower and upper bounds. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param lowerObj A ScopeType value + * @param upperObj A ScopeType value + * @return Returns the intersection of the current range and the range specified by the given lower and upper bounds. + */ + intersect(lowerObj: ScopeType, upperObj: ScopeType): Scope; + /** + * Obtains the upper bound of the current range. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the upper bound of the current range. + */ + getUpper(): ScopeType; + /** + * Obtains the lower bound of the current range. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @return Returns the lower bound of the current range. + */ + getLower(): ScopeType; + /** + * Creates the smallest range that includes the current range and the given lower and upper bounds. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param lowerObj A ScopeType value + * @param upperObj A ScopeType value + * @return Returns the smallest range that includes the current range and the given lower and upper bounds. + */ + expand(lowerObj: ScopeType, upperObj: ScopeType): Scope; + /** + * Creates the smallest range that includes the current range and a given range. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param range A Scope range object + * @return Returns the smallest range that includes the current range and a given range. + */ + expand(range: Scope): Scope; + /** + * Creates the smallest range that includes the current range and a given value. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A ScopeType value + * @return Returns the smallest range that includes the current range and a given value. + */ + expand(value: ScopeType): Scope; + /** + * Checks whether a given value is within the current range. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param range A ScopeType range + * @return If the value is within the current range return true,otherwise return false. + */ + contains(value: ScopeType): boolean; + /** + * Checks whether a given range is within the current range. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Scope value + * @return If the current range is within the given range return true,otherwise return false. + */ + contains(range: Scope): boolean; + /** + * Clamps a given value to the current range. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A ScopeType value + * @return Returns a ScopeType object that a given value is clamped to the current range.. + */ + clamp(value: ScopeType): ScopeType; + } + class Base64 { + /** + * Constructor for creating base64 encoding and decoding + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param No input parameter is required. + * @return No return value. + */ + constructor(); + /** + * Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Uint8Array value + * @return Return the encoded new Uint8Array. + */ + encodeSync(src: Uint8Array): Uint8Array; + /** + * Encodes the specified byte array into a String using the Base64 encoding scheme. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Uint8Array value + * @return Return the encoded string. + */ + encodeToStringSync(src: Uint8Array): string; + /** + * Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Uint8Array value or value A string value + * @return Return the decoded Uint8Array. + */ + decodeSync(src: Uint8Array | string): Uint8Array; + /** + * Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Uint8Array value + * @return Return the encodes asynchronous new Uint8Array. + */ + encode(src: Uint8Array): Promise; + /** + * Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Uint8Array value + * @return Returns the encoded asynchronous string. + */ + encodeToString(src: Uint8Array): Promise; + /** + * Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Uint8Array value or value A string value + * @return Return the decoded asynchronous Uint8Array. + */ + decode(src: Uint8Array | string): Promise; + } + class types { + /** + * The types constructor + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param No input parameter is required. + * @return No return value. + */ + constructor(); + /** + * Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A ArrayBuffer or SharedArrayBuffer value + * @Returns true if the value is a built-in ArrayBuffer or SharedArrayBuffer instance.. + */ + isAnyArrayBuffer(value: Object): boolean; + /** + * Check whether the type is included in the isAnyArrayBuffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A included in the isAnyArrayBuffer value + * @return Returns true if the value is an instance of one of the ArrayBuffer views, such as typed array objects or DataView. Equivalent to ArrayBuffer.isView(). + */ + isArrayBufferView(value: Object): boolean; + /** + * Check whether the entered value is an arguments object type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A arguments value + * @return Returns true if the value is an arguments object. + */ + isArgumentsObject(value: Object): boolean; + /** + * Check whether the entered value is of arraybuffer type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A arraybuffer value + * @return Returns true if the value is a built-in ArrayBuffer instance. This does not include SharedArrayBuffer instances. Usually, it is desirable to test for both; See isAnyArrayBuffer() for that. + */ + isArrayBuffer(value: Object): boolean; + /** + * Check whether the value entered is an asynchronous function type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A async function value + * @return Returns true if the value is an async function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used. + */ + isAsyncFunction(value: Object): boolean; + /** + * Check whether the entered value is of bigint64array array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A BigInt64Array value + * @return Returns true if the value is a BigInt64Array instance. + */ + isBigInt64Array(value: Object): boolean; + /** + * Check whether the entered value is of biguint64array array array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A BigUint64Array value + * @return Returns true if the value is a BigUint64Array instance. + */ + isBigUint64Array(value: Object): boolean; + /** + * Check whether the entered value is a Boolean object type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A boolean object value + * @return Returns true if the value is a boolean object, e.g. created by new Boolean(). + */ + isBooleanObject(value: Object): boolean; + /** + * Check whether the entered value is a Boolean or number or string or symbol object type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A boxed primitive object value + * @return Returns true if the value is any boxed primitive object, e.g. created by new Boolean(), new String() or Object(Symbol()). + */ + isBoxedPrimitive(value: Object): boolean; + /** + * Check whether the entered value is of DataView type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A DataView value + * @return Returns true if the value is a built-in DataView instance. + */ + isDataView(value: Object): boolean; + /** + * Check whether the entered value is of type date. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Date value + * @return Returns true if the value is a built-in Date instance. + */ + isDate(value: Object): boolean; + /** + * Check whether the entered value is a native external value type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A External value + * @return Returns true if the value is a native External value. + */ + isExternal(value: Object): boolean; + /** + * Check whether the entered value is of float32array array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Float32Array value + * @return Returns true if the value is a built-in Float32Array instance. + */ + isFloat32Array(value: Object): boolean; + /** + * Check whether the entered value is of float64array array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Float64Array value + * @return Returns true if the value is a built-in Float64Array instance. + */ + isFloat64Array(value: Object): boolean; + /** + * Check whether the input value is a generator function type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A generator function value + * @return Returns true if the value is a generator function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used. + */ + isGeneratorFunction(value: Object): boolean; + /** + * Check whether the entered value is a generator object type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A generator object value + * @return Returns true if the value is a generator object as returned from a built-in generator function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used. + */ + isGeneratorObject(value: Object): boolean; + /** + * Check whether the entered value is of int8array array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Int8Array value + * @return Returns true if the value is a built-in Int8Array instance. + */ + isInt8Array(value: Object): boolean; + /** + * Check whether the entered value is the int16array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Int16Array value + * @return Returns true if the value is a built-in Int16Array instance. + */ + isInt16Array(value: Object): boolean; + /** + * Check whether the entered value is the int32array array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Int32Array value + * @return Returns true if the value is a built-in Int32Array instance. + */ + isInt32Array(value: Object): boolean; + /** + * Check whether the entered value is of map type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Map value + * @return Returns true if the value is a built-in Map instance. + */ + isMap(value: Object): boolean; + /** + * Check whether the entered value is the iterator type of map. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Map iterator value + * @return Returns true if the value is an iterator returned for a built-in Map instance. + */ + isMapIterator(value: Object): boolean; + /** + * Check whether the entered value is the module namespace object object type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Module Namespace Object value + * @return Returns true if the value is an instance of a Module Namespace Object. + */ + isModuleNamespaceObject(value: Object): boolean; + /** + * Check whether the value entered is of type error. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Error value + * @return Returns true if the value is an instance of a built-in Error type. + */ + isNativeError(value: Object): boolean; + /** + * Check whether the entered value is of the number object type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A number object value + * @return Returns true if the value is a number object, e.g. created by new Number(). + */ + isNumberObject(value: Object): boolean; + /** + * Check whether the entered value is of promise type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Promise value + * @return Returns true if the value is a built-in Promise. + */ + isPromise(value: Object): boolean; + /** + * Check whether the value entered is of proxy type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Proxy value + * @return Returns true if the value is a Proxy instance. + */ + isProxy(value: Object): boolean; + /** + * Check whether the entered value is of type regexp. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A regular expression object value + * @return Returns true if the value is a regular expression object. + */ + isRegExp(value: Object): boolean; + /** + * Check whether the entered value is of type set. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Set instance value + * @return Returns true if the value is a built-in Set instance. + */ + isSet(value: Object): boolean; + /** + * Check whether the entered value is the iterator type of set. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Set iterator value + * @return Returns true if the value is an iterator returned for a built-in Set instance. + */ + isSetIterator(value: Object): boolean; + /** + * Check whether the entered value is of type sharedarraybuffer. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A SharedArrayBuffer instance value + * @return Returns true if the value is a built-in SharedArrayBuffer instance. This does not include ArrayBuffer instances. Usually, it is desirable to test for both; See isAnyArrayBuffer() for that. + */ + isSharedArrayBuffer(value: Object): boolean; + /** + * Check whether the entered value is a string object type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A String object value + * @return Returns true if the value is a string object, e.g. created by new String(). + */ + isStringObject(value: Object): boolean; + /** + * Check whether the entered value is a symbol object type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A symbol object value + * @return Returns true if the value is a symbol object, created by calling Object() on a Symbol primitive. + */ + isSymbolObject(value: Object): boolean; + /** + * Check whether the entered value is a type contained in typedarray. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A TypedArray instance value + * @return Returns true if the value is a built-in TypedArray instance. + */ + isTypedArray(value: Object): boolean; + /** + * Check whether the entered value is the uint8array array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Uint8Array value + * @return Returns true if the value is a built-in Uint8Array instance. + */ + isUint8Array(value: Object): boolean; + /** + * Check whether the entered value is the uint8clapedarray array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Uint8ClampedArray value + * @return Returns true if the value is a built-in Uint8ClampedArray instance. + */ + isUint8ClampedArray(value: Object): boolean; + /** + * Check whether the entered value is the uint16array array array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Uint16Array value + * @return Returns true if the value is a built-in Uint16Array instance. + */ + isUint16Array(value: Object): boolean; + /** + * Check whether the entered value is the uint32array array type. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A Uint32Array value + * @return Returns true if the value is a built-in Uint32Array instance. + */ + isUint32Array(value: Object): boolean; + /** + * Check whether the entered value is of type weakmap. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A WeakMap value + * @return Returns true if the value is a built-in WeakMap instance. + */ + isWeakMap(value: Object): boolean; + /** + * Check whether the entered value is of type weakset. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param value A WeakSet value + * @return Returns true if the value is a built-in WeakSet instance. + */ + isWeakSet(value: Object): boolean; + } +} +export default util; diff --git a/build-tools/api/@ohos.vibrator.d.ts b/build-tools/api/@ohos.vibrator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5b59ae843e5682a4caac7f9308a9fa3a34eadf90 --- /dev/null +++ b/build-tools/api/@ohos.vibrator.d.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * This module provides the capability to control motor vibration. + * + * @since 8 + * @syscap SystemCapability.Sensors.MiscDevice + * @import import vibrator from '@ohos.vibrator' + * @permission ohos.permission.VIBRATE + */ +/** + * This module provides the capability to control motor vibration. + * + * @since 9 + * @syscap SystemCapability.Sensors.MiscDevice + * @import import vibrator from '@ohos.vibrator' + */ +declare namespace vibrator { + /** + * The trigger motor vibrates for a specified length of time. + * @param duration Indicate the duration of the motor vibration. + * @syscap SystemCapability.Sensors.MiscDevice + * @permission ohos.permission.VIBRATE + * @since 8 + */ + function vibrate(duration: number, callback?: AsyncCallback): void; + function vibrate(duration: number): Promise; + /** + * The trigger motor vibrates for the specified effect of the preset. + * @param effectId Indicate the specified effect of the preset, {@code EffectId}. + * @syscap SystemCapability.Sensors.MiscDevice + * @permission ohos.permission.VIBRATE + * @since 8 + */ + function vibrate(effectId: EffectId): Promise; + function vibrate(effectId: EffectId, callback?: AsyncCallback): void; + /** + * Stop the motor from vibrating. + * @param stopMode Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}. + * @syscap SystemCapability.Sensors.MiscDevice + * @permission ohos.permission.VIBRATE + * @since 8 + */ + function stop(stopMode: VibratorStopMode): Promise; + function stop(stopMode: VibratorStopMode, callback?: AsyncCallback): void; + /** + * Preset vibration effect string. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 8 + */ + enum EffectId { + /* Describes the vibration effect of the vibrator when a user adjusts the timer.*/ + EFFECT_CLOCK_TIMER = "haptic.clock.timer" + } + /** + * Vibrator vibration stop mode. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 8 + */ + enum VibratorStopMode { + /* Indicates the mode of stopping a one-shot vibration effect.*/ + VIBRATOR_STOP_MODE_TIME = "time", + /* Indicates the mode of stopping a preset vibration effect.*/ + VIBRATOR_STOP_MODE_PRESET = "preset" + } +} +export default vibrator; diff --git a/build-tools/api/@ohos.wallpaper.d.ts b/build-tools/api/@ohos.wallpaper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..75d0147aa7d0ff4dd2322cbf825dd1b1b58dc5ab --- /dev/null +++ b/build-tools/api/@ohos.wallpaper.d.ts @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import image from './@ohos.multimedia.image'; +/** + * System wallpaper + * @syscap SystemCapability.MiscServices.Wallpaper + * @import import wallpaper from '@ohos.wallpaper'; + * @since 7 + */ +declare namespace wallpaper { + enum WallpaperType { + /** + * Indicates the home screen wallpaper. + */ + WALLPAPER_SYSTEM, + /** + * Indicates the lock screen wallpaper. + */ + WALLPAPER_LOCKSCREEN + } + /** + * Obtains the wallpaper colors for the wallpaper of the specified type. + * @param wallpaperType Indicates the wallpaper type. + * @return RgbaColor type of array callback function + */ + function getColors(wallpaperType: WallpaperType, callback: AsyncCallback>): void; + function getColors(wallpaperType: WallpaperType): Promise>; + /** + * Obtains the ID of the wallpaper of the specified type. + * @param wallpaperType Indicates the wallpaper type. + * @return an integer greater than or equal to {@code 0} representing the wallpaper ID + * if the specified type of wallpaper has been set; returns {@code -1} otherwise. + * The return value is an integer ranging from -1 to 2^31 - 1. + */ + function getId(wallpaperType: WallpaperType, callback: AsyncCallback): void; + function getId(wallpaperType: WallpaperType): Promise; + /** + * Obtains a file of the wallpaper of the specified type. + * @param wallpaperType Indicates the wallpaper type. + * @permission ohos.permission.GET_WALLPAPER. + * ohos.permission.READ_USER_STORAGE. + * @return the file descriptor. + * @since 8 + */ + function getFile(wallpaperType: WallpaperType, callback: AsyncCallback): void; + function getFile(wallpaperType: WallpaperType): Promise; + /** + * Obtains the minimum height of the wallpaper. + * @return the minimum height, in pixels; returns {@code 0} if no wallpaper has been set. + */ + function getMinHeight(callback: AsyncCallback): void; + function getMinHeight(): Promise; + /** + * Obtains the minimum width of the wallpaper. + * @return the minimum width, in pixels; returns {@code 0} if no wallpaper has been set. + */ + function getMinWidth(callback: AsyncCallback): void; + function getMinWidth(): Promise; + /** + * Checks whether to allow the application to change the wallpaper for the current user. + * @return true if the application is allowed to set a wallpaper for the current user; + */ + function isChangePermitted(callback: AsyncCallback): void; + function isChangePermitted(): Promise; + /** + * Checks whether a user is allowed to set wallpapers. + * @return true if a user is allowed to set wallpapers; returns false otherwise. + */ + function isOperationAllowed(callback: AsyncCallback): void; + function isOperationAllowed(): Promise; + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @permission ohos.permission.SET_WALLPAPER + */ + function reset(wallpaperType: WallpaperType, callback: AsyncCallback): void; + function reset(wallpaperType: WallpaperType): Promise; + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @permission ohos.permission.SET_WALLPAPER + */ + function setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + function setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; + /** + * Registers a listener for wallpaper color changes to receive notifications about the changes. + * @param type The incoming colorChange table open receiver pick a color change wallpaper wallpaper color changes + * @param callback Provides dominant colors of the wallpaper. + */ + function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; + /** + * Unregisters a listener for wallpaper color changes. + * @param type Incoming 'colorChange' table delete receiver to pick up a color change wallpaper wallpaper color changes + * @param callback Provides dominant colors of the wallpaper. + */ + function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + /** + * Said the red value, the range is 0 to 255. + */ + red: number; + /** + * Said the green value, the range is 0 to 255. + */ + green: number; + /** + * Said the blue value, the range is 0 to 255. + */ + blue: number; + /** + * Said the alpha value, the range is 0 to 255. + */ + alpha: number; + } +} +export default wallpaper; diff --git a/build-tools/api/@ohos.wantAgent.d.ts b/build-tools/api/@ohos.wantAgent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d4172860619f995c19a7c876c89db57c564b2d6 --- /dev/null +++ b/build-tools/api/@ohos.wantAgent.d.ts @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from './basic'; +import { WantAgentInfo } from './wantAgent/wantAgentInfo'; +import { TriggerInfo } from './wantAgent/triggerInfo'; +/** + * Provide the method obtain trigger, cancel, and compare and to obtain + * the bundle name, UID of an {@link WantAgent} object. + * + * @name wantAgent + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import wantAgent from '@ohos.wantAgent'; + * @permission N/A + */ +declare namespace wantAgent { + /** + * Obtains the bundle name of a WantAgent. + * + * @param WantAgent whose bundle name to obtain. + * @return Returns the bundle name of the {@link WantAgent} if any. + */ + function getBundleName(agent: WantAgent, callback: AsyncCallback): void; + function getBundleName(agent: WantAgent): Promise; + /** + * Obtains the UID of a WantAgent. + * + * @param WantAgent whose UID to obtain. + * @return Returns the UID of the {@link WantAgent} if any; returns {@code -1} otherwise. + */ + function getUid(agent: WantAgent, callback: AsyncCallback): void; + function getUid(agent: WantAgent): Promise; + /** + * Cancels a WantAgent. Only the application that creates the WantAgent can cancel it. + * + * @param WantAgent to cancel. + */ + function cancel(agent: WantAgent, callback: AsyncCallback): void; + function cancel(agent: WantAgent): Promise; + /** + * Triggers a WantAgent. + * + * @param WantAgent to trigger. + * @param Trigger parameters. + * @param callback Indicates the callback method to be called after the {@link WantAgent} is triggered. + */ + function trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback): void; + /** + * Checks whether two WantAgent objects are equal. + * + * @param WantAgent to compare. + * @param WantAgent to compare. + * @return Returns {@code true} If the two objects are the same; returns {@code false} otherwise. + */ + function equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback): void; + function equal(agent: WantAgent, otherAgent: WantAgent): Promise; + /** + * Obtains a WantAgent object. + * + * @param Information about the WantAgent object to obtain. + * @return Returns the created {@link WantAgent} object. + */ + function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void; + function getWantAgent(info: WantAgentInfo): Promise; + /** + * Obtains the {@link OperationType} of a {@link WantAgent}. + * + * @since 9 + * @param agent Indicates the {@link WantAgent} whose {@link OperationType} is to be obtained. + * @return Returns the {@link OperationType} of the {@link WantAgent}. + */ + function getOperationType(agent: WantAgent, callback: AsyncCallback): void; + function getOperationType(agent: WantAgent): Promise; + /** + * Enumerates flags for using a WantAgent. + */ + export enum WantAgentFlags { + /** + * Indicates that the WantAgent can be used only once. + * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. + */ + ONE_TIME_FLAG = 0, + /** + * Indicates that null is returned if the WantAgent does not exist. + * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. + */ + NO_BUILD_FLAG, + /** + * Indicates that the existing WantAgent should be canceled before a new object is generated. + * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. + */ + CANCEL_PRESENT_FLAG, + /** + * Indicates that the system only replaces the extra data of the existing WantAgent with that of the new object. + * This flag is valid only when OperationType is set to START_ABILITY, START_SERVICE, or SEND_COMMON_EVENT. + */ + UPDATE_PRESENT_FLAG, + /** + * Indicates that the created WantAgent should be immutable. + */ + CONSTANT_FLAG, + /** + * Indicates that the current value of element can be replaced when the WantAgent is triggered. + */ + REPLACE_ELEMENT, + /** + * Indicates that the current value of action can be replaced when the WantAgent is triggered. + */ + REPLACE_ACTION, + /** + * Indicates that the current value of uri can be replaced when the WantAgent is triggered. + */ + REPLACE_URI, + /** + * Indicates that the current value of entities can be replaced when the WantAgent is triggered. + */ + REPLACE_ENTITIES, + /** + * Indicates that the current value of packageName can be replaced when the WantAgent is triggered. + */ + REPLACE_BUNDLE + } + /** + * Identifies the operation for using a WantAgent, such as starting an ability or sending a common event. + */ + export enum OperationType { + /** + * Unknown operation. + */ + UNKNOWN_TYPE = 0, + /** + * Starts an ability with a UI. + */ + START_ABILITY, + /** + * Starts multiple abilities with a UI. + */ + START_ABILITIES, + /** + * Starts an ability without a UI. + */ + START_SERVICE, + /** + * Sends a common event. + */ + SEND_COMMON_EVENT + } + /** + * Describes the data returned by after wantAgent.trigger is called. + */ + export interface CompleteData { + /** + * Triggered WantAgent. + */ + info: WantAgent; + /** + * Existing Want that is triggered. + */ + want: Want; + /** + * Request code used to trigger the WantAgent. + */ + finalCode: number; + /** + * Final data collected by the common event. + */ + finalData: string; + /** + * Extra data collected by the common event. + */ + extraInfo?: { + [key: string]: any; + }; + } +} +/** + * WantAgent object. + */ +export type WantAgent = object; +export default wantAgent; diff --git a/build-tools/api/@ohos.web.d.ts b/build-tools/api/@ohos.web.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9b1000cd51990d49e5ada70d0bc9059fb203071 --- /dev/null +++ b/build-tools/api/@ohos.web.d.ts @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from "./basic"; +/** + * This module provides the capability to manage web modules. + * + * @since 9 + * @syscap SystemCapability.Web + */ +declare namespace web { + /** + * Provides basic information of web storage. + * @name WebStorageOrigin + * @since 9 + * @syscap SystemCapability.Web + */ + interface WebStorageOrigin { + origin: string; + usage: number; + quota: number; + } + /** + * Provides methods for managing web storage. + * @name WebStorage + * @since 9 + * @syscap SystemCapability.Web + */ + class WebStorage { + /** + * delete all the storage data. + * + * @since 9 + */ + static deleteAllData(): void; + /** + * delete the storage data with the origin. + * @param origin the origin which to be deleted. + * @since 9 + */ + static deleteOrigin(origin: string): void; + /** + * Get current all the web storage origins. + * + * @since 9 + */ + static getOrigins(): Promise>; + static getOrigins(callback: AsyncCallback>): void; + /** + * Get the web storage quota with the origin. + * @param origin the origin which to be inquired. + * @since 9 + */ + static getOriginQuota(origin: string): Promise; + static getOriginQuota(origin: string, callback: AsyncCallback): void; + /** + * Get the web storage quota with the origin. + * @param origin the origin which to be inquired. + * @since 9 + */ + static getOriginUsage(origin: string): Promise; + static getOriginUsage(origin: string, callback: AsyncCallback): void; + } + /** + * Provides methods for managing web database. + * @name WebDataBase + * @since 9 + * @syscap SystemCapability.Web + */ + class WebDataBase { + /** + * Get whether instances holds any http authentication credentials. + * @return true if instances saved any http authentication credentials otherwise false. + * + * @since 9 + */ + static existHttpAuthCredentials(): boolean; + /** + * delete all http authentication credentials. + * + * @since 9 + */ + static deleteHttpAuthCredentials(): void; + /** + * get http authentication credentials. + * @param host the host to which the credentials apply. + * @param realm the realm to which the credentials apply. + * @return Return an array containing username and password. + * @since 9 + */ + static getHttpAuthCredentials(host: string, realm: string): Array; + /** + * save http authentication credentials. + * @param host the host to which the credentials apply. + * @param realm the realm to which the credentials apply. + * @param username the username. + * @param password the password. + * + * @since 9 + */ + static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void; + } +} +export default web; diff --git a/build-tools/api/@ohos.wifi.d.ts b/build-tools/api/@ohos.wifi.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf5367705b483c55d4553ffa07f8b0c5eb714898 --- /dev/null +++ b/build-tools/api/@ohos.wifi.d.ts @@ -0,0 +1,781 @@ +/* + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback, Callback } from './basic'; +/** + * Provides methods to operate or manage Wi-Fi. + * + * @since 6 + * @import import wifi from '@ohos.wifi'; + */ +declare namespace wifi { + /** + * Queries the Wi-Fi status + * + * @return Returns {@code true} if the Wi-Fi is active, returns {@code false} otherwise. + * + * @since 6 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function isWifiActive(): boolean; + /** + * Scans Wi-Fi hotspots. + * + *

      This API works in asynchronous mode.

      + * + * @return Returns {@code true} if the scanning is successful, returns {@code false} otherwise. + * + * @since 6 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.LOCATION + */ + function scan(): boolean; + /** + * Obtains the hotspot information that scanned. + * + * @return Returns information about scanned Wi-Fi hotspots if any. + * + * @since 6 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION) + */ + function getScanInfos(): Promise>; + function getScanInfos(callback: AsyncCallback>): void; + /** + * Obtains the scanned results. + * + * @return Returns information about scanned Wi-Fi hotspots if any. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION) + */ + function getScanInfosSync(): Array; + /** + * Adds a specified untrusted hotspot configuration. + * + *

      This method adds one configuration at a time. After this configuration is added, + * your device will determine whether to connect to the hotspot. + * + * @return Returns {@code true} if the untrusted hotspot configuration is added, returns {@code false} otherwise. + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO + */ + function addUntrustedConfig(config: WifiDeviceConfig): Promise; + function addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback): void; + /** + * Removes a specified untrusted hotspot configuration. + * + *

      This method removes one configuration at a time. + * + * @return Returns {@code true} if the untrusted hotspot configuration is removed, returns {@code false} otherwise. + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO + */ + function removeUntrustedConfig(config: WifiDeviceConfig): Promise; + function removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback): void; + /** + * Adds a specified candidate hotspot configuration and returns the networkId. + * + *

      This method adds one configuration at a time. After this configuration is added, + * your device will determine whether to connect to the hotspot. + * + * @return Returns {@code networkId} if the configuration is added; returns {@code -1} otherwise. + * @since 9 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO + */ + function addCandidateConfig(config: WifiDeviceConfig): Promise; + function addCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback): void; + /** + * Removes a specified candidate hotspot configuration, only the configration which is added by ourself is allowed + * to be removed. + * + *

      This method removes one configuration at a time. + * + * @since 9 + * @throws {TypedError | Error} when failed to remove the hotspot configuration. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO + */ + function removeCandidateConfig(networkId: number): Promise; + function removeCandidateConfig(networkId: number, callback: AsyncCallback): void; + /** + * Obtains the list of all existing candidate Wi-Fi configurations which added by ourself. + * + *

      You can obtain only the Wi-Fi configurations you created on your own application. + * + * @return Returns the list of all existing Wi-Fi configurations you created on your application. + * @since 9 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + */ + function getCandidateConfigs(): Array; + /** + * Connect to a specified candidate hotspot configuration, only the configration which is added by ourself + * is allowed to be connected. + * + *

      This method connect to a configuration at a time. + * + * @param {number} networkId - Network ID which will be connected. + * @throws {TypedError | Error} when failed connect to the hotspot configuration + * @since 9 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO + */ + function connectToCandidateConfig(networkId: number): void; + /** + * Calculates the Wi-Fi signal level based on the Wi-Fi RSSI and frequency band. + * + * @param rssi Indicates the Wi-Fi RSSI. + * @band Indicates the Wi-Fi frequency band. + * @return Returns Wi-Fi signal level ranging from 0 to 4. + * + * @since 6 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function getSignalLevel(rssi: number, band: number): number; + /** + * Obtains information about a Wi-Fi connection. + * + * @return Returns the Wi-Fi connection information. + * @since 6 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function getLinkedInfo(): Promise; + function getLinkedInfo(callback: AsyncCallback): void; + /** + * Checks whether a Wi-Fi connection has been set up. + * + * @return Returns {@code true} if a Wi-Fi connection has been set up, returns {@code false} otherwise. + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function isConnected(): boolean; + /** + * Checks whether this device supports a specified feature. + * + * @param featureId Indicates the ID of the feature. + * @return Returns {@code true} if this device supports the specified feature, returns {@code false} otherwise. + * @since 7 + * @syscap SystemCapability.Communication.WiFi.Core + * @permission ohos.permission.GET_WIFI_INFO + */ + function isFeatureSupported(featureId: number): boolean; + /** + * Obtains the IP information of a Wi-Fi connection. + * + *

      The IP information includes the host IP address, gateway address, and DNS information. + * + * @return Returns the IP information of the Wi-Fi connection. + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function getIpInfo(): IpInfo; + /** + * Obtains the country code of this device. + * + * @return Returns the country code of this device. + * @since 7 + * @syscap SystemCapability.Communication.WiFi.Core + * @permission ohos.permission.GET_WIFI_INFO + */ + function getCountryCode(): string; + /** + * Obtains information about a P2P connection. + * + * @return Returns the P2P connection information. + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function getP2pLinkedInfo(): Promise; + function getP2pLinkedInfo(callback: AsyncCallback): void; + /** + * Obtains information about the current group. + * + * @return Returns the current group information. + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + */ + function getCurrentGroup(): Promise; + function getCurrentGroup(callback: AsyncCallback): void; + /** + * Obtains the information about the found devices. + * + * @return Returns the found devices list. + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + */ + function getP2pPeerDevices(): Promise; + function getP2pPeerDevices(callback: AsyncCallback): void; + /** + * Obtains the information about own device info. + * + *

      deviceAddress in the returned WifiP2pDevice will be set "00:00:00:00:00:00", + * if ohos.permission.GET_WIFI_LOCAL_MAC is not granted. + * + * @return Returns the information about own device info. + * @since 9 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG + */ + function getP2pLocalDevice(): Promise; + function getP2pLocalDevice(callback: AsyncCallback): void; + /** + * Creates a P2P group. + * + * @param config Indicates the configuration for creating a group. + * @return Returns {@code true} if the operation is successful, returns {@code false} otherwise. + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function createGroup(config: WifiP2PConfig): boolean; + /** + * Removes a P2P group. + * + * @return Returns {@code true} if the operation is successful, returns {@code false} otherwise. + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function removeGroup(): boolean; + /** + * Initiates a P2P connection to a device with the specified configuration. + * + * @param config Indicates the configuration for connecting to a specific group. + * @return Returns {@code true} if the operation is successful, returns {@code false} otherwise. + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + */ + function p2pConnect(config: WifiP2PConfig): boolean; + /** + * Canceling a P2P connection. + * + * @return Returns {@code true} if the operation is successful, returns {@code false} otherwise. + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function p2pCancelConnect(): boolean; + /** + * Discovers Wi-Fi P2P devices. + * + * @return Returns {@code true} if the operation is successful, returns {@code false} otherwise. + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + */ + function startDiscoverDevices(): boolean; + /** + * Stops discovering Wi-Fi P2P devices. + * + * @return Returns {@code true} if the operation is successful, returns {@code false} otherwise. + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function stopDiscoverDevices(): boolean; + /** + * Subscribe Wi-Fi status change events. + * + * @return Returns 0: inactive, 1: active, 2: activating, 3: deactivating + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "wifiStateChange", callback: Callback): void; + /** + * Unsubscribe Wi-Fi status change events. + * + *

      All callback functions will be deregistered If there is no specific callback parameter.

      + * + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "wifiStateChange", callback?: Callback): void; + /** + * Subscribe Wi-Fi connection change events. + * + * @return Returns 0: disconnected, 1: connected + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "wifiConnectionChange", callback: Callback): void; + /** + * Unsubscribe Wi-Fi connection change events. + * + *

      All callback functions will be deregistered If there is no specific callback parameter.

      + * + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "wifiConnectionChange", callback?: Callback): void; + /** + * Subscribe Wi-Fi scan status change events. + * + * @return Returns 0: scan fail, 1: scan success + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "wifiScanStateChange", callback: Callback): void; + /** + * Unsubscribe Wi-Fi scan status change events. + * + *

      All callback functions will be deregistered If there is no specific callback parameter.

      + * + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "wifiScanStateChange", callback?: Callback): void; + /** + * Subscribe Wi-Fi rssi change events. + * + * @return Returns RSSI value in dBm + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "wifiRssiChange", callback: Callback): void; + /** + * Unsubscribe Wi-Fi rssi change events. + * + *

      All callback functions will be deregistered If there is no specific callback parameter.

      + * + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "wifiRssiChange", callback?: Callback): void; + /** + * Subscribe Wi-Fi hotspot state change events. + * + * @return Returns 0: inactive, 1: active, 2: activating, 3: deactivating + * @since 7 + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "hotspotStateChange", callback: Callback): void; + /** + * Unsubscribe Wi-Fi hotspot state change events. + * + *

      All callback functions will be deregistered If there is no specific callback parameter.

      + * + * @since 7 + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "hotspotStateChange", callback?: Callback): void; + /** + * Subscribe P2P status change events. + * + * @return Returns 1: idle, 2: starting, 3:started, 4: closing, 5: closed + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "p2pStateChange", callback: Callback): void; + /** + * Unsubscribe P2P status change events. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "p2pStateChange", callback?: Callback): void; + /** + * Subscribe P2P connection change events. + * + * @return Returns WifiP2pLinkedInfo + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "p2pConnectionChange", callback: Callback): void; + /** + * Unsubscribe P2P connection change events. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "p2pConnectionChange", callback?: Callback): void; + /** + * Subscribe P2P local device change events. + * + * @return Returns WifiP2pDevice + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + */ + function on(type: "p2pDeviceChange", callback: Callback): void; + /** + * Unsubscribe P2P local device change events. + * + * @return Returns WifiP2pDevice + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.LOCATION + */ + function off(type: "p2pDeviceChange", callback?: Callback): void; + /** + * Subscribe P2P peer device change events. + * + * @return Returns WifiP2pDevice[] + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + */ + function on(type: "p2pPeerDeviceChange", callback: Callback): void; + /** + * Unsubscribe P2P peer device change events. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.LOCATION + */ + function off(type: "p2pPeerDeviceChange", callback?: Callback): void; + /** + * Subscribe P2P persistent group change events. + * + * @return Returns void + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "p2pPersistentGroupChange", callback: Callback): void; + /** + * Unsubscribe P2P persistent group change events. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "p2pPersistentGroupChange", callback?: Callback): void; + /** + * Subscribe P2P discovery events. + * + * @return Returns 0: initial state, 1: discovery succeeded + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "p2pDiscoveryChange", callback: Callback): void; + /** + * Unsubscribe P2P discovery events. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "p2pDiscoveryChange", callback?: Callback): void; + /** + * Wi-Fi device configuration information. + * + * @since 6 + * @syscap SystemCapability.Communication.WiFi.STA + */ + interface WifiDeviceConfig { + /** Wi-Fi SSID: the maximum length is 32 */ + ssid: string; + /** Wi-Fi bssid(MAC): the length is 6 */ + bssid: string; + /** Wi-Fi key: maximum length is 64 */ + preSharedKey: string; + /** Hide SSID or not, false(default): not hide */ + isHiddenSsid: boolean; + /** Security type: reference definition of WifiSecurityType */ + securityType: WifiSecurityType; + } + /** + * Describes the wifi channel width. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.STA + */ + enum WifiChannelWidth { + WIDTH_20MHZ = 0, + WIDTH_40MHZ = 1, + WIDTH_80MHZ = 2, + WIDTH_160MHZ = 3, + WIDTH_80MHZ_PLUS = 4, + WIDTH_INVALID + } + /** + * Describes the scanned Wi-Fi information. + * + * @since 6 + * @syscap SystemCapability.Communication.WiFi.STA + */ + interface WifiScanInfo { + /** Wi-Fi SSID: the maximum length is 32 */ + ssid: string; + /** Wi-Fi bssid(MAC): the length is 6 */ + bssid: string; + /** Hotspot capability */ + capabilities: string; + /** Security type: reference definition of WifiSecurityType */ + securityType: WifiSecurityType; + /** Received signal strength indicator (RSSI) */ + rssi: number; + /** Frequency band, 1: 2.4G, 2: 5G */ + band: number; + /** Frequency */ + frequency: number; + /** Channel width */ + channelWidth: number; + /** Center frequency */ + centerFrequency0: number; + /** Center frequency */ + centerFrequency1: number; + /** Time stamp */ + timestamp: number; + } + /** + * Describes the wifi security type. + * + * @since 6 + * @syscap SystemCapability.Communication.WiFi.Core + */ + enum WifiSecurityType { + /** Invalid security type */ + WIFI_SEC_TYPE_INVALID = 0, + /** Open */ + WIFI_SEC_TYPE_OPEN = 1, + /** Wired Equivalent Privacy (WEP) */ + WIFI_SEC_TYPE_WEP = 2, + /** Pre-shared key (PSK) */ + WIFI_SEC_TYPE_PSK = 3, + /** Simultaneous Authentication of Equals (SAE) */ + WIFI_SEC_TYPE_SAE = 4, + /** EAP authentication */ + WIFI_SEC_TYPE_EAP = 5, + /** SUITE_B_192 192 bit level */ + WIFI_SEC_TYPE_EAP_SUITE_B = 6, + /** Opportunististic Wireless Encryption */ + WIFI_SEC_TYPE_OWE = 7, + /** WAPI certificate to be specified */ + WIFI_SEC_TYPE_WAPI_CERT = 8, + /** WAPI pre-shared key to be specified */ + WIFI_SEC_TYPE_WAPI_PSK = 9 + } + /** + * Wi-Fi connection information. + * + * @since 6 + * @syscap SystemCapability.Communication.WiFi.STA + */ + interface WifiLinkedInfo { + /** The SSID of the Wi-Fi hotspot */ + ssid: string; + /** The BSSID of the Wi-Fi hotspot */ + bssid: string; + /** The RSSI(dBm) of a Wi-Fi access point. */ + rssi: number; + /** The frequency band of a Wi-Fi access point. */ + band: number; + /** The speed of a Wi-Fi access point. */ + linkSpeed: number; + /** The frequency of a Wi-Fi access point. */ + frequency: number; + /** Whether the SSID of the access point (AP) of this Wi-Fi connection is hidden. */ + isHidden: boolean; + /** Whether this Wi-Fi connection restricts the data volume. */ + isRestricted: boolean; + /** Type of macAddress: 0 - real mac, 1 - random mac. */ + macType: number; + /** The Wi-Fi MAC address of a device. */ + macAddress: string; + /** The IP address of this Wi-Fi connection. */ + ipAddress: number; + /** The state of this Wi-Fi connection. */ + connState: ConnState; + } + /** + * Wi-Fi IP information. + * + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + */ + interface IpInfo { + /** The IP address of the Wi-Fi connection */ + ipAddress: number; + /** The gateway of the Wi-Fi connection */ + gateway: number; + /** The network mask of the Wi-Fi connection */ + netmask: number; + /** The primary DNS server IP address of the Wi-Fi connection */ + primaryDns: number; + /** The secondary DNS server IP address of the Wi-Fi connection */ + secondDns: number; + /** The DHCP server IP address of the Wi-Fi connection */ + serverIp: number; + /** The IP address lease duration of the Wi-Fi connection */ + leaseDuration: number; + } + /** + * The state of Wi-Fi connection enumeration. + * + * @since 6 + * @syscap SystemCapability.Communication.WiFi.STA + */ + export enum ConnState { + /** The device is searching for an available AP. */ + SCANNING, + /** The Wi-Fi connection is being set up. */ + CONNECTING, + /** The Wi-Fi connection is being authenticated. */ + AUTHENTICATING, + /** The IP address of the Wi-Fi connection is being obtained. */ + OBTAINING_IPADDR, + /** The Wi-Fi connection has been set up. */ + CONNECTED, + /** The Wi-Fi connection is being torn down. */ + DISCONNECTING, + /** The Wi-Fi connection has been torn down. */ + DISCONNECTED, + /** Failed to set up the Wi-Fi connection. */ + UNKNOWN + } + /** + * P2P device information. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + */ + interface WifiP2pDevice { + /** Device name */ + deviceName: string; + /** Device mac address */ + deviceAddress: string; + /** Primary device type */ + primaryDeviceType: string; + /** Device status */ + deviceStatus: P2pDeviceStatus; + /** Device group capabilitys */ + groupCapabilitys: number; + } + /** + * P2P config. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + */ + interface WifiP2PConfig { + /** Device mac address */ + deviceAddress: string; + /** + * Group network ID. When creating a group, -1 indicates creates a temporary group, + * -2: indicates creates a persistent group + */ + netId: number; + /* The passphrase of this {@code WifiP2pConfig} instance */ + passphrase: string; + /** Group name */ + groupName: string; + /** Group owner band */ + goBand: GroupOwnerBand; + } + /** + * P2P group information. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + */ + interface WifiP2pGroupInfo { + /** Indicates whether it is group owner */ + isP2pGo: boolean; + /** Group owner information */ + ownerInfo: WifiP2pDevice; + /** The group passphrase */ + passphrase: string; + /** Interface name */ + interface: string; + /** Group name */ + groupName: string; + /** Network ID */ + networkId: number; + /** Frequency */ + frequency: number; + /** Client list */ + clientDevices: WifiP2pDevice[]; + /** Group owner IP address */ + goIpAddress: string; + } + /** + * P2P connection status. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + */ + enum P2pConnectState { + DISCONNECTED = 0, + CONNECTED = 1 + } + /** + * P2P linked information. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + */ + interface WifiP2pLinkedInfo { + /** Connection status */ + connectState: P2pConnectState; + /** Indicates whether it is group owner */ + isGroupOwner: boolean; + /** Group owner address */ + groupOwnerAddr: string; + } + /** + * P2P device status. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + */ + enum P2pDeviceStatus { + CONNECTED = 0, + INVITED = 1, + FAILED = 2, + AVAILABLE = 3, + UNAVAILABLE = 4 + } + /** + * P2P group owner band. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.P2P + */ + enum GroupOwnerBand { + GO_BAND_AUTO = 0, + GO_BAND_2GHZ = 1, + GO_BAND_5GHZ = 2 + } +} +export default wifi; diff --git a/build-tools/api/@ohos.wifiext.d.ts b/build-tools/api/@ohos.wifiext.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..648786e4ccaba0b856bd011675eced9e8d7b83cf --- /dev/null +++ b/build-tools/api/@ohos.wifiext.d.ts @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * Provides extended methods to operate or manage Wi-Fi. + * + *

      The APIs involved in this file are non-general APIs. + * These extended APIs are only used by some product types, such as routers. + * Common products should not use these APIs.

      + * + * @since 8 + * @import import wifiext from '@ohos.wifiext'; + */ +declare namespace wifiext { + /** + * Enables a Wi-Fi hotspot. + * + * @return Returns {@code true} if this method is called successfully; returns {@code false} otherwise. + * @since 8 + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + function enableHotspot(): boolean; + /** + * Disables a Wi-Fi hotspot. + * + * @return Returns {@code true} if this method is called successfully; returns {@code false} otherwise. + * @since 8 + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + function disableHotspot(): boolean; + /** + * Obtains the supported power model. + * + * @return Returns the array of supported power model. + * + * @since 8 + * @permission ohos.permission.GET_WIFI_INFO + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + function getSupportedPowerModel(): Promise>; + function getSupportedPowerModel(callback: AsyncCallback>): void; + /** + * Obtains the current Wi-Fi power mode. + * + * @return Returns the current Wi-Fi power mode. If a value less than zero is returned, it indicates a failure. + * + * @since 8 + * @permission ohos.permission.GET_WIFI_INFO + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + function getPowerModel(): Promise; + function getPowerModel(callback: AsyncCallback): void; + /** + * Set the current Wi-Fi power mode. + * + * @return Returns {@code true} if the Wi-Fi is active; returns {@code false} otherwise. + * + * @since 8 + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + function setPowerModel(model: PowerModel): boolean; + /** + * The power model enumeration. + * + * @since 8 + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + export enum PowerModel { + /** Sleeping model. */ + SLEEPING = 0, + /** General model. */ + GENERAL = 1, + /** Through wall model. */ + THROUGH_WALL = 2 + } +} +export default wifiext; diff --git a/build-tools/api/@ohos.window.d.ts b/build-tools/api/@ohos.window.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ab082a8547574d89591336a26259a0db6cb09e15 --- /dev/null +++ b/build-tools/api/@ohos.window.d.ts @@ -0,0 +1,839 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './basic'; +import { Context } from './application/BaseContext'; +/** + * Window manager. + * @syscap SystemCapability.WindowManager.WindowManager.Core + */ +declare namespace window { + /** + * The type of a window. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + enum WindowType { + /** + * App. + * @FAModelOnly + */ + TYPE_APP, + /** + * System alert. + */ + TYPE_SYSTEM_ALERT, + /** + * float. + * @permission ohos.permission.SYSTEM_FLOAT_WINDOW + * @since 9 + * @StageModelOnly + */ + TYPE_FLOAT + } + /** + * Describes the type of avoid area + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + enum AvoidAreaType { + /** + * Default area of the system + */ + TYPE_SYSTEM, + /** + * Notch + */ + TYPE_CUTOUT, + /** + * area for system gesture + * @since 9 + */ + TYPE_SYSTEM_GESTURE, + /** + * area for keyboard + * @since 9 + */ + TYPE_KEYBOARD + } + /** + * Properties of status bar and navigation bar, it couldn't update automatically + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + interface SystemBarProperties { + /** + * the color of the status bar. + * @since 6 + */ + statusBarColor?: string; + /** + * the light icon of the status bar. + * @since 7 + */ + isStatusBarLightIcon?: boolean; + /** + * the content color of the status bar + * @since 8 + */ + statusBarContentColor?: string; + /** + * the color of the navigation bar. + * @since 6 + */ + navigationBarColor?: string; + /** + * the light icon of the navigation bar. + * @since 7 + */ + isNavigationBarLightIcon?: boolean; + /** + * the content color of the navigation bar + * @since 8 + */ + navigationBarContentColor?: string; + } + /** + * Rectangle + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + interface Rect { + left: number; + top: number; + width: number; + height: number; + } + /** + * avoid area + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + interface AvoidArea { + /** + * Whether avoidArea is visible on screen + * @since 9 + */ + visible: boolean; + /** + * Rectangle on the left of the screen + */ + leftRect: Rect; + /** + * Rectangle on the top of the screen + */ + topRect: Rect; + /** + * Rectangle on the right of the screen + */ + rightRect: Rect; + /** + * Rectangle on the bottom of the screen + */ + bottomRect: Rect; + } + /** + * window size + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + interface Size { + /** + * the width of the window. + */ + width: number; + /** + * the height of the window. + */ + height: number; + } + /** + * Properties of window, it couldn't update automatically + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + interface WindowProperties { + /** + * the position and size of the window + * @since 7 + */ + windowRect: Rect; + /** + * window type + * @since 7 + */ + type: WindowType; + /** + * Whether the window is displayed in full screen mode. The default value is false. + * @since 6 + */ + isFullScreen: boolean; + /** + * Whether the window layout is in full screen mode(whether the window is immersive). The default value is false. + * @since 7 + */ + isLayoutFullScreen: boolean; + /** + * Whether the window can gain focus. The default value is true + * @since 7 + */ + focusable: boolean; + /** + * Whether the window is touchable. The default value is false + * @since 7 + */ + touchable: boolean; + /** + * Brightness value of window. + * @since 6 + */ + brightness: number; + /** + * The dimbehind value of window. + * @since 7 + * @deprecated since 9 + */ + dimBehindValue: number; + /** + * Whether keep screen on. + * @since 6 + */ + isKeepScreenOn: boolean; + /** + * Whether make window in privacy mode or not. + * @since 7 + */ + isPrivacyMode: boolean; + /** + * Whether is round corner or not. + * @since 7 + */ + isRoundCorner: boolean; + /** + * Whether is transparent or not. + * @since 7 + */ + isTransparent: boolean; + } + /** + * Type of allowing the specified of color space. + * @since 8 + */ + enum ColorSpace { + /** + * Default color space. + */ + DEFAULT, + /** + * Wide gamut color space. The specific wide color gamut depends on thr screen. + */ + WIDE_GAMUT + } + /** + * Create a sub window with a specific id and type, only support 7. + * @param id Indicates window id. + * @param type Indicates window type. + * @since 7 + * @FAModelOnly + */ + function create(id: string, type: WindowType, callback: AsyncCallback): void; + /** + * Create a sub window with a specific id and type, only support 7. + * @param id Indicates window id. + * @param type Indicates window type. + * @since 7 + * @FAModelOnly + */ + function create(id: string, type: WindowType): Promise; + /** + * Create a system or float window with a specific id and type. + * @param ctx Indicates the context on which the window depends + * @param id Indicates window id. + * @param type Indicates window type. + * @since 8 + */ + function create(ctx: Context, id: string, type: WindowType): Promise; + /** + * Create a system or float window with a specific id and type. + * @param ctx Indicates the context on which the window depends + * @param id Indicates window id. + * @param type Indicates window type. + * @since 8 + */ + function create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback): void; + /** + * Find the window by id. + * @param id Indicates window id. + * @since 7 + */ + function find(id: string, callback: AsyncCallback): void; + /** + * Find the window by id. + * @param id Indicates window id. + * @since 7 + */ + function find(id: string): Promise; + /** + * Get the final show window. + * @param id Indicates window id. + * @since 6 + * @FAModelOnly + */ + function getTopWindow(callback: AsyncCallback): void; + /** + * Get the final show window. + * @since 6 + * @FAModelOnly + */ + function getTopWindow(): Promise; + /** + * Get the final show window. + * @param ctx Indicates the context on which the window depends + * @since 8 + */ + function getTopWindow(ctx: Context): Promise; + /** + * Get the final show window. + * @param ctx Indicates the context on which the window depends + * @since 8 + */ + function getTopWindow(ctx: Context, callback: AsyncCallback): void; + /** + * display orientation + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + enum Orientation { + UNSPECIFIED = 0, + PORTRAIT = 1, + LANDSCAPE = 2, + PORTRAIT_INVERTED = 3, + LANDSCAPE_INVERTED = 4, + AUTO_ROTATION = 5, + AUTO_ROTATION_PORTRAIT = 6, + AUTO_ROTATION_LANDSCAPE = 7, + AUTO_ROTATION_RESTRICTED = 8, + AUTO_ROTATION_PORTRAIT_RESTRICTED = 9, + AUTO_ROTATION_LANDSCAPE_RESTRICTED = 10, + LOCKED = 11 + } + interface Window { + /** + * show window. + * @since 7 + */ + show(callback: AsyncCallback): void; + /** + * show window. + * @since 7 + */ + show(): Promise; + /** + * Destroy the window. + * @since 7 + */ + destroy(callback: AsyncCallback): void; + /** + * Destroy the window. + * @since 7 + */ + destroy(): Promise; + /** + * Set the position of a window. + * @param x Indicate the X-coordinate of the window. + * @param y Indicate the Y-coordinate of the window. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + moveTo(x: number, y: number): Promise; + /** + * Set the position of a window. + * @param x Indicate the X-coordinate of the window. + * @param y Indicate the Y-coordinate of the window. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + moveTo(x: number, y: number, callback: AsyncCallback): void; + /** + * Set the size of a window . + * @param width Indicates the width of the window. + * @param height Indicates the height of the window. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + resetSize(width: number, height: number): Promise; + /** + * Set the size of a window . + * @param width Indicates the width of the window. + * @param height Indicates the height of the window. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + resetSize(width: number, height: number, callback: AsyncCallback): void; + /** + * get the properties of current window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + getProperties(callback: AsyncCallback): void; + /** + * get the properties of current window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + getProperties(): Promise; + /** + * get the avoid area + * @param type Type of the area + * @since 7 + */ + getAvoidArea(type: AvoidAreaType, callback: AsyncCallback): void; + /** + * get the avoid area + * @param type Type of the area + * @since 7 + */ + getAvoidArea(type: AvoidAreaType): Promise; + /** + * set the flag of the window is shown full screen + * @param isFullScreen the flag of the window is shown full screen + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + setFullScreen(isFullScreen: boolean, callback: AsyncCallback): void; + /** + * set the flag of the window is shown full screen + * @param isFullScreen the flag of the window is shown full screen + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + setFullScreen(isFullScreen: boolean): Promise; + /** + * set the property of the window can layout in full screen + * @param isLayoutFullScreen the window can layout in full screen + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback): void; + /** + * set the property of the window can layout in full screen + * @param isLayoutFullScreen the window can layout in full screen + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + setLayoutFullScreen(isLayoutFullScreen: boolean): Promise; + /** + * set the system bar to have visible. + * @param names the set of system bar + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback): void; + /** + * set the system bar to have visible. + * @param names the set of system bar + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise; + /** + * set the background color of statusbar + * @param color the background color of statusbar + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback): void; + /** + * set the background color of statusbar + * @param color the background color of statusbar + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise; + /** + * Set the preferred orientation config of the window + * @param orientation the orientation config of the window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + setPreferredOrientation(orientation: Orientation): Promise; + /** + * Set the preferred orientation config of the window + * @param orientation the orientation config of the window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + setPreferredOrientation(orientation: Orientation, callback: AsyncCallback): void; + /** + * Loads content + * @param path path Path of the page to which the content will be loaded + * @param storage storage The data object shared within the content instance loaded by the window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @StageModelOnly + */ + loadContent(path: string, storage: LocalStorage, callback: AsyncCallback): void; + /** + * Loads content + * @param path path of the page to which the content will be loaded + * @param storage storage The data object shared within the content instance loaded by the window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @StageModelOnly + */ + loadContent(path: string, storage: LocalStorage): Promise; + /** + * Loads content + * @param path path of the page to which the content will be loaded + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + loadContent(path: string, callback: AsyncCallback): void; + /** + * Loads content + * @param path path of the page to which the content will be loaded + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + loadContent(path: string): Promise; + /** + * Checks whether the window is displayed + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + isShowing(callback: AsyncCallback): void; + /** + * Checks whether the window is displayed + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + isShowing(): Promise; + /** + * register the callback of windowSizeChange + * @param type: 'windowSizeChange' + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + on(type: 'windowSizeChange', callback: Callback): void; + /** + * unregister the callback of windowSizeChange + * @param type: 'windowSizeChange' + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + off(type: 'windowSizeChange', callback?: Callback): void; + /** + * register the callback of systemAvoidAreaChange + * @param type: 'systemAvoidAreaChange' + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + * @deprecated since 9, please use on_avoidAreaChange instead. + */ + on(type: 'systemAvoidAreaChange', callback: Callback): void; + /** + * unregister the callback of systemAvoidAreaChange + * @param type: 'systemAvoidAreaChange' + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + * @deprecated since 9, please use off_avoidAreaChange instead. + */ + off(type: 'systemAvoidAreaChange', callback?: Callback): void; + /** + * register the callback of avoidAreaChange + * @param type: 'avoidAreaChange' + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + on(type: 'avoidAreaChange', callback: Callback<{ + type: AvoidAreaType; + area: AvoidArea; + }>): void; + /** + * unregister the callback of avoidAreaChange + * @param type: 'avoidAreaChange' + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + off(type: 'avoidAreaChange', callback?: Callback<{ + type: AvoidAreaType; + area: AvoidArea; + }>): void; + /** + * register the callback of keyboardHeightChange + * @param type: 'keyboardHeightChange' + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + on(type: 'keyboardHeightChange', callback: Callback): void; + /** + * unregister the callback of keyboardHeightChange + * @param type: 'keyboardHeightChange' + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + off(type: 'keyboardHeightChange', callback?: Callback): void; + /** + * Whether the window supports thr wide gamut setting. + * @since 8 + */ + isSupportWideGamut(): Promise; + /** + * Whether the window supports thr wide gamut setting. + * @since 8 + */ + isSupportWideGamut(callback: AsyncCallback): void; + /** + * Sets the specified color space. + * @param colorSpace the specified color space. + * @since 8 + */ + setColorSpace(colorSpace: ColorSpace): Promise; + /** + * Sets the specified color space. + * @param colorSpace the specified color space. + * @since 8 + */ + setColorSpace(colorSpace: ColorSpace, callback: AsyncCallback): void; + /** + * Obtains thr set color space. + * @since 8 + */ + getColorSpace(): Promise; + /** + * Obtains thr set color space. + * @since 8 + */ + getColorSpace(callback: AsyncCallback): void; + /** + * Sets the background color of window. + * @param color the specified color. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + setBackgroundColor(color: string): Promise; + /** + * Sets the background color of window. + * @param color the specified color. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + setBackgroundColor(color: string, callback: AsyncCallback): void; + /** + * Sets the brightness of window. + * @param brightness the specified brightness value. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + setBrightness(brightness: number): Promise; + /** + * Sets the brightness of window. + * @param brightness the specified brightness value. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + setBrightness(brightness: number, callback: AsyncCallback): void; + /** + * Sets the dimBehind of window. + * @param dimBehindValue the specified dimBehind. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + * @deprecated since 9 + */ + setDimBehind(dimBehindValue: number, callback: AsyncCallback): void; + /** + * Sets the dimBehind of window. + * @param dimBehind the specified dimBehind. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + * @deprecated since 9 + */ + setDimBehind(dimBehindValue: number): Promise; + /** + * Sets whether focusable or not. + * @param isFocusable can be focus if true, or can not be focus if false. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + setFocusable(isFocusable: boolean): Promise; + /** + * Sets whether focusable or not. + * @param isFocusable can be focus if true, or can not be focus if false. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + setFocusable(isFocusable: boolean, callback: AsyncCallback): void; + /** + * Sets whether keep screen on or not. + * @param isKeepScreenOn keep screen on if true, or not if false. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + setKeepScreenOn(isKeepScreenOn: boolean): Promise; + /** + * Sets whether keep screen on or not. + * @param isKeepScreenOn keep screen on if true, or not if false. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 6 + */ + setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback): void; + /** + * Sets whether outside can be touch or not. + * @param touchable outside can be touch if true, or not if false. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + * @deprecated since 9 + */ + setOutsideTouchable(touchable: boolean): Promise; + /** + * Sets whether outside can be touch or not. + * @param touchable outside can be touch if true, or not if false. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + * @deprecated since 9 + */ + setOutsideTouchable(touchable: boolean, callback: AsyncCallback): void; + /** + * Sets whether is private mode or not. + * @param isPrivacyMode in private mode if true, or not if false. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + setPrivacyMode(isPrivacyMode: boolean): Promise; + /** + * Sets whether is private mode or not. + * @param isPrivacyMode in private mode if true, or not if false. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback): void; + /** + * Sets whether is touchable or not. + * @param isTouchable is touchable if true, or not if false. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + setTouchable(isTouchable: boolean): Promise; + /** + * Sets whether is touchable or not. + * @param isTouchable is touchable if true, or not if false. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + setTouchable(isTouchable: boolean, callback: AsyncCallback): void; + } + /** + * window stage callback event type + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @StageModelOnly + */ + enum WindowStageEventType { + FOREGROUND = 1, + ACTIVE, + INACTIVE, + BACKGROUND + } + /** + * WindowStage + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + interface WindowStage { + /** + * Get main window of the stage. + * @since 9 + * @StageModelOnly + */ + getMainWindow(): Promise; + /** + * Get main window of the stage. + * @since 9 + * @StageModelOnly + */ + getMainWindow(callback: AsyncCallback): void; + /** + * Create sub window of the stage. + * @param name window name of sub window + * @since 9 + * @StageModelOnly + */ + createSubWindow(name: string): Promise; + /** + * Create sub window of the stage. + * @param name window name of sub window + * @since 9 + * @StageModelOnly + */ + createSubWindow(name: string, callback: AsyncCallback): void; + /** + * Get sub window of the stage. + * @since 9 + * @StageModelOnly + */ + getSubWindow(): Promise>; + /** + * Get sub window of the stage. + * @since 9 + * @StageModelOnly + */ + getSubWindow(callback: AsyncCallback>): void; + /** + * Loads content + * @param path path Path of the page to which the content will be loaded + * @param storage storage The data object shared within the content instance loaded by the window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @StageModelOnly + */ + loadContent(path: string, storage: LocalStorage, callback: AsyncCallback): void; + /** + * Loads content + * @param path path of the page to which the content will be loaded + * @param storage storage The data object shared within the content instance loaded by the window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @StageModelOnly + */ + loadContent(path: string, storage?: LocalStorage): Promise; + /** + * Loads content + * @param path path of the page to which the content will be loaded + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @StageModelOnly + */ + loadContent(path: string, callback: AsyncCallback): void; + /** + * window stage event callback on. + * @since 9 + * @StageModelOnly + */ + on(eventType: 'windowStageEvent', callback: Callback): void; + /** + * window stage event callback off. + * @since 9 + * @StageModelOnly + */ + off(eventType: 'windowStageEvent', callback?: Callback): void; + /** + * Sets whether can show on lock screen or not + * @param showOnLockScreen can show on lock screen if true, or not if false + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @StageModelOnly + */ + setShowOnLockScreen(showOnLockScreen: boolean): void; + } +} +export default window; diff --git a/build-tools/api/@ohos.workScheduler.d.ts b/build-tools/api/@ohos.workScheduler.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7fc7417ebd2c4342cb14c376560aee686c1afd43 --- /dev/null +++ b/build-tools/api/@ohos.workScheduler.d.ts @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +/** + * Work scheduler interface. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + */ +declare namespace workScheduler { + /** + * The info of work. + * + * @name WorkInfo + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + */ + export interface WorkInfo { + /** + * The id of the current work. + */ + workId: number; + /** + * The bundle name of the current work. + */ + bundleName: string; + /** + * The ability name of the current work. + */ + abilityName: string; + /** + * Whether the current work will be saved. + */ + isPersisted?: boolean; + /** + * The network type of the current work. + */ + networkType?: NetworkType; + /** + * Whether a charging state has been set for triggering the work. + */ + isCharging?: boolean; + /** + * The charger type based on which the work is triggered. + */ + chargerType?: ChargingType; + /** + * The battery level for triggering a work. + */ + batteryLevel?: number; + /** + * The battery status for triggering a work. + */ + batteryStatus?: BatteryStatus; + /** + * Whether a storage state has been set for triggering the work. + */ + storageRequest?: StorageRequest; + /** + * The interval at which the work is repeated. + */ + repeatCycleTime?: number; + /** + * Whether the work has been set to repeat at the specified interval. + */ + isRepeat?: boolean; + /** + * The repeat of the current work. + */ + repeatCount?: number; + /** + * Whether the device deep idle state has been set for triggering the work. + */ + isDeepIdle?: boolean; + /** + * The idle wait time based on which the work is triggered. + */ + idleWaitTime?: number; + } + /** + * Add a work to the queue. A work can be executed only when it meets the preset triggering condition + * and complies with the rules of work scheduler manager. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param work The info of work. + * @return true if success, otherwise false. + */ + function startWork(work: WorkInfo): boolean; + /** + * Stop a work. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param work The info of work. + * @param needCancel True if need to be canceled after being stopped, otherwise false. + * @return true if success, otherwise false. + */ + function stopWork(work: WorkInfo, needCancel?: boolean): boolean; + /** + * Obtains the work info of the wordId. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param workId The id of work. + */ + function getWorkStatus(workId: number, callback: AsyncCallback): void; + function getWorkStatus(workId: number): Promise; + /** + * Get all works of the calling application. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @return the work info list. + */ + function obtainAllWorks(callback: AsyncCallback): Array; + function obtainAllWorks(): Promise>; + /** + * Stop all and clear all works of the calling application. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @return true if success, otherwise false. + */ + function stopAndClearWorks(): boolean; + /** + * Check whether last work running is timeout. The interface is for repeating work. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param workId The id of work. + * @return true if last work running is timeout, otherwise false. + */ + function isLastWorkTimeOut(workId: number, callback: AsyncCallback): boolean; + function isLastWorkTimeOut(workId: number): Promise; + /** + * Describes network type. + * + * @name NetworkType + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + */ + export enum NetworkType { + /** + * Describes any network connection. + */ + NETWORK_TYPE_ANY = 0, + /** + * Describes a mobile network connection. + */ + NETWORK_TYPE_MOBILE, + /** + * Describes a wifi network connection. + */ + NETWORK_TYPE_WIFI, + /** + * Describes a bluetooth network connection. + */ + NETWORK_TYPE_BLUETOOTH, + /** + * Describes a wifi p2p network connection. + */ + NETWORK_TYPE_WIFI_P2P, + /** + * Describes a wifi wire network connection. + */ + NETWORK_TYPE_ETHERNET + } + /** + * Describes charging type. + * + * @name ChargingType + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + */ + export enum ChargingType { + /** + * Describes any charger is connected. + */ + CHARGING_PLUGGED_ANY = 0, + /** + * Describes ac charger is connected. + */ + CHARGING_PLUGGED_AC, + /** + * Describes usb charger is connected. + */ + CHARGING_PLUGGED_USB, + /** + * Describes wireless charger is connected. + */ + CHARGING_PLUGGED_WIRELESS + } + /** + * Describes the battery status. + * + * @name BatteryStatus + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + */ + export enum BatteryStatus { + /** + * Describes battery status is to low. + */ + BATTERY_STATUS_LOW = 0, + /** + * Describes battery status is to ok. + */ + BATTERY_STATUS_OKAY, + /** + * Describes battery status is to low or ok. + */ + BATTERY_STATUS_LOW_OR_OKAY + } + /** + * Describes the storage request. + * + * @name StorageRequest + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + */ + export enum StorageRequest { + /** + * Describes storage is to low. + */ + STORAGE_LEVEL_LOW = 0, + /** + * Describes storage is to ok. + */ + STORAGE_LEVEL_OKAY, + /** + * Describes storage is to low or ok. + */ + STORAGE_LEVEL_LOW_OR_OKAY + } +} +export default workScheduler; diff --git a/build-tools/api/@ohos.worker.d.ts b/build-tools/api/@ohos.worker.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..95e4952910fc00173358741708ce5df2415afeea --- /dev/null +++ b/build-tools/api/@ohos.worker.d.ts @@ -0,0 +1,337 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** +* Provides options that can be set for the worker to create. +* @since 7 +* @syscap SystemCapability.Utils.Lang +*/ +export interface WorkerOptions { + /** + * Mode in which the worker executes the script. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + type?: "classic" | "module"; + /** + * Name of the worker. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + name?: string; + /** + * Whether the worker is shared. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + shared?: boolean; +} +/** + * Defines the event. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ +export interface Event { + /** + * Type of the Event. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly type: string; + /** + * Timestamp(accurate to millisecond) when the event is created. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly timeStamp: number; +} +/** + * Provides detailed information about the exception occurred during worker execution. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ +export interface ErrorEvent extends Event { + /** + * Information about the exception. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly message: string; + /** + * File where the exception is located. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly filename: string; + /** + * Number of the line where the exception is located. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly lineno: number; + /** + * Number of the column where the exception is located. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly colno: number; + /** + * Type of the exception. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly error: Object; +} +/** + * Holds the data transferred between worker threads. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ +export interface MessageEvent extends Event { + /** + * Data transferred when an exception occurs. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly data: T; +} +/** + * Specifies the object whose ownership need to be transferred during data transfer. + * The object must be ArrayBuffer. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ +export interface PostMessageOptions { + /** + * ArrayBuffer array used to transfer the ownership. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + transfer?: Object[]; +} +/** + * Implements evemt listening. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ +export interface EventListener { + /** + * Specifies the callback to invoke. + * @param evt Event class for the callback to invoke. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + (evt: Event): void | Promise; +} +/** + * Type of message, only "message" and "messageerror". + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ +type MessageType = "message" | "messageerror"; +/** + * Specific event features. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ +export interface EventTarget { + /** + * Adds an event listener to the worker. + * @param type Type of the event to listen for. + * @param listener Callback to invoke when an event of the specified type occurs. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + addEventListener(type: string, listener: EventListener): void; + /** + * Dispatches the event defined for the worker. + * @param event Event to dispatch. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + dispatchEvent(event: Event): boolean; + /** + * Removes an event defined for the worker. + * @param type Type of the event for which the event listener is removed. + * @param callback Callback of the event listener to remove. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + removeEventListener(type: string, callback?: EventListener): void; + /** + * Removes all event listeners for the worker. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + removeAllListener(): void; +} +/** + * Specifies the worker thread running environment, which is isolated from the host thread environment. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ +declare interface WorkerGlobalScope extends EventTarget { + /** + * Worker name specified when there is a new worker. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + readonly name: string; + /** + * The onerror attribute of parentPort specifies + * the event handler to be called when an exception occurs during worker execution. + * The event handler is executed in the worker thread. + * @param ev Error data. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + onerror?: (ev: ErrorEvent) => void; + readonly self: WorkerGlobalScope & typeof globalThis; +} +/** + * Specifies the worker thread running environment, which is isolated from the host thread environment + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ +export interface DedicatedWorkerGlobalScope extends WorkerGlobalScope { + /** + * The onmessage attribute of parentPort specifies the event handler + * to be called then the worker thread receives a message sent by + * the host thread through worker postMessage. + * The event handler is executed in the worker thread. + * @param ev Message received. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + onmessage?: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => void; + /** + * The onmessage attribute of parentPort specifies the event handler + * to be called then the worker receives a message that cannot be deserialized. + * The event handler is executed in the worker thread. + * @param ev Error data. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + onmessageerror?: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => void; + /** + * Close the worker thread to stop the worker from receiving messages + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + close(): void; + /** + * Send a message to be host thread from the worker + * @param messageObject Data to be sent to the worker + * @param transfer array cannot contain null. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + postMessage(messageObject: Object, transfer: Transferable[]): void; + postMessage(messageObject: Object, options?: PostMessageOptions): void; +} +/** + * JS cross-thread communication tool + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ +declare namespace worker { + class Worker extends EventTarget { + /** + * Creates a worker instance + * @param scriptURL URL of the script to be executed by the worker + * @param options Options that can be set for the worker + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + constructor(scriptURL: string, options?: WorkerOptions); + /** + * The onexit attribute of the worker specifies the event handler to be called + * when the worker exits. The handler is executed in the host thread. + * @param code Code indicating the worker exit state + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + onexit?: (code: number) => void; + /** + * The onerror attribute of the worker specifies the event handler to be called + * when an exception occurs during worker execution. + * The event handler is executed in the host thread. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + onerror?: (err: ErrorEvent) => void; + /** + * The onmessage attribute of the worker specifies the event handler + * to be called then the host thread receives a message created by itself + * and sent by the worker through the parentPort.postMessage. + * The event handler is executed in the host thread. + * @param event Message received. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + onmessage?: (event: MessageEvent) => void; + /** + * The onmessage attribute of the worker specifies the event handler + * when the worker receives a message that cannot be serialized. + * The event handler is executed in the host thread. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + onmessageerror?: (event: MessageEvent) => void; + /** + * Sends a message to the worker thread. + * The data is transferred using the structured clone algorithm. + * @param message Data to be sent to the worker + * @param transfer ArrayBuffer instance that can be transferred. + * The transferList array cannot contain null. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + postMessage(message: Object, transfer: ArrayBuffer[]): void; + postMessage(message: Object, options?: PostMessageOptions): void; + /** + * Adds an event listener to the worker. + * @param type Adds an event listener to the worker. + * @param listener Callback to invoke when an event of the specified type occurs. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + on(type: string, listener: EventListener): void; + /** + * Adds an event listener to the worker + * and removes the event listener automatically after it is invoked once. + * @param type Type of the event to listen for + * @param listener Callback to invoke when an event of the specified type occurs + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + once(type: string, listener: EventListener): void; + /** + * Removes an event listener to the worker. + * @param type Type of the event for which the event listener is removed. + * @param listener Callback of the event listener to remove. + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + off(type: string, listener?: EventListener): void; + /** + * Terminates the worker thread to stop the worker from receiving messages + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + terminate(): void; + } + const parentPort: DedicatedWorkerGlobalScope; +} +export default worker; diff --git a/build-tools/api/@ohos.xml.d.ts b/build-tools/api/@ohos.xml.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3eea94f58b3121c4ed368e8e53babcbb7451b6d7 --- /dev/null +++ b/build-tools/api/@ohos.xml.d.ts @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The xml module provides utilities for converting XML text to Javascript object, XML generation and parsing. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @import import xml from '@ohos.xml'; + * @permission N/A + */ +declare namespace xml { + class XmlSerializer { + /** + * A parameterized constructor used to create a new XmlSerializer instance. + * As the input parameter of the constructor function, init supports three types. + * The input parameter is an Arrarybuff. + * The input parameter is a DataView. + * The input parameter is an encoding format of string type. + */ + constructor(buffer: ArrayBuffer | DataView, encoding?: string); + /** + * Write an attribute. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param name Key name of the attribute. + * @param value Values of attribute. + */ + setAttributes(name: string, value: string): void; + /** + * Add an empty element. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param name Key name of the attribute. + * @param value Values of element. + */ + addEmptyElement(name: string): void; + /** + * Writes xml declaration with encoding. For example: . + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + setDeclaration(): void; + /** + * Writes a elemnet start tag with the given name. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param name name of the element. + */ + startElement(name: string): void; + /** + * Writes end tag of the element. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + endElement(): void; + /** + * Writes the namespace of the current element tag. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param prefix Values name of the prefix. + * @param namespace Values of namespace. + */ + setNamespace(prefix: string, namespace: string): void; + /** + * Writes the comment. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param text Values of comment. + */ + setComment(text: string): void; + /** + * Writes the CDATA. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param text Values of CDATA. + */ + setCDATA(text: string): void; + /** + * Writes the text. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param text Values of text. + */ + setText(text: string): void; + /** + * Writes the DOCTYPE. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param text Values of docType. + */ + setDocType(text: string): void; + } + enum EventType { + /** + * Start a document. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + START_DOCUMENT, + /** + * End a document. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + END_DOCUMENT, + /** + * Start a tag. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + START_TAG, + /** + * End a tag. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + END_TAG, + /** + * Character data. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + TEXT, + /** + * A CDATA sections. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + CDSECT, + /** + * An XML comment. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + COMMENT, + /** + * An XML document type declaration. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + DOCDECL, + /** + * An XML processing instruction declaration. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + INSTRUCTION, + /** + * An entity reference. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ENTITY_REFERENCE, + /** + * a whitespace. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + WHITESPACE + } + /** The current parse info. */ + interface ParseInfo { + /** + * The current column number, starting from 1. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getColumnNumber(): number; + /** + * The current depth of the element. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getDepth(): number; + /** + * The current line number, starting from 1. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getLineNumber(): number; + /** + * The current element's name. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getName(): string; + /** + * The current element's namespace. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getNamespace(): string; + /** + * The current element's prefix. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getPrefix(): string; + /** + * The text content of the current event as String. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getText(): string; + /** + * Returns true if the current element is empty. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isEmptyElementTag(): boolean; + /** + * Checks whether the current TEXT event contains only whitespace characters. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + isWhitespace(): boolean; + /** + * Returns the number of attributes of the current start tag. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + getAttributeCount(): number; + } + /** parse options for XmlPullParser. */ + interface ParseOptions { + /** + * Whether to parsing Doctype of the elements. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + supportDoctype?: boolean; + /** + * Whether to ignore parsing texts of the elements. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ + ignoreNameSpace?: boolean; + /** + * tag value callback function. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param name The current tag name. + * @param value The current tag value. + * @return Returns a Boolean variable for whether parse continually. + */ + tagValueCallbackFunction?: (name: string, value: string) => boolean; + /** + * attribute value callback function. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param name The current attribute name. + * @param value The current attribute value. + * @return Returns a Boolean variable for whether parse continually. + */ + attributeValueCallbackFunction?: (name: string, value: string) => boolean; + /** + * token value callback function. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param eventType The current token eventtype. + * @param value The current token parseinfo. + * @return Returns a Boolean variable for whether parse continually. + */ + tokenValueCallbackFunction?: (eventType: EventType, value: ParseInfo) => boolean; + } + class XmlPullParser { + /** + * A constructor used to create a new XmlPullParser instance. + */ + constructor(buffer: ArrayBuffer | DataView, encoding?: string); + /** + * Starts parsing the XML file. + * @since 8 + * @syscap SystemCapability.Utils.Lang + * @param option parse options for XmlPullParser, the interface including two Boolean variables and three callback functions. + */ + parse(option: ParseOptions): void; + } +} +export default xml; diff --git a/build-tools/api/@ohos.zlib.d.ts b/build-tools/api/@ohos.zlib.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ba2154d38f2601541d6cbff7e2a576f8fbb094e --- /dev/null +++ b/build-tools/api/@ohos.zlib.d.ts @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare namespace zlib { + /** + * @name ErrorCode + * @since 7 + * @syscap SystemCapability.BundleManager.Zlib + * @import NA + * @permission NA + */ + export enum ErrorCode { + ERROR_CODE_OK = 0, + ERROR_CODE_ERRNO = -1 + } + /** + * @name CompressLevel + * @since 7 + * @syscap SystemCapability.BundleManager.Zlib + * @import NA + * @permission NA + */ + export enum CompressLevel { + COMPRESS_LEVEL_NO_COMPRESSION = 0, + COMPRESS_LEVEL_BEST_SPEED = 1, + COMPRESS_LEVEL_BEST_COMPRESSION = 9, + COMPRESS_LEVEL_DEFAULT_COMPRESSION = -1 + } + /** + * @name CompressStrategy + * @since 7 + * @syscap SystemCapability.BundleManager.Zlib + * @import NA + * @permission NA + */ + export enum CompressStrategy { + COMPRESS_STRATEGY_DEFAULT_STRATEGY = 0, + COMPRESS_STRATEGY_FILTERED = 1, + COMPRESS_STRATEGY_HUFFMAN_ONLY = 2, + COMPRESS_STRATEGY_RLE = 3, + COMPRESS_STRATEGY_FIXED = 4 + } + /** + * @name MemLevel + * @since 7 + * @syscap SystemCapability.BundleManager.Zlib + * @import NA + * @permission NA + */ + export enum MemLevel { + MEM_LEVEL_MIN = 1, + MEM_LEVEL_MAX = 9, + MEM_LEVEL_DEFAULT = 8 + } + /** + * @name Options + * @since 7 + * @syscap SystemCapability.BundleManager.Zlib + * @import NA + * @permission NA + */ + interface Options { + level?: CompressLevel; + memLevel?: MemLevel; + strategy?: CompressStrategy; + } + /** + * Compress the specified file. + * + * @since 7 + * @syscap SystemCapability.BundleManager.Zlib + * @param inFile Indicates the path of the file to be compressed. + * @param outFile Indicates the path of the output compressed file. + * @return Returns error code. + */ + function zipFile(inFile: string, outFile: string, options: Options): Promise; + /** + * Decompress the specified file. + * + * @since 7 + * @syscap SystemCapability.BundleManager.Zlib + * @param inFile Indicates the path of the file to be decompressed. + * @param outFile Indicates the path of the decompressed file. + * @return Returns error code. + */ + function unzipFile(inFile: string, outFile: string, options: Options): Promise; +} +export default zlib; diff --git a/build-tools/api/@system.app.d.ts b/build-tools/api/@system.app.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..62c8effa91355b185b07ef1242cc7172890b9ec4 --- /dev/null +++ b/build-tools/api/@system.app.d.ts @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the AppResponse info. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ +export interface AppResponse { + /** + * Application bundleName. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + appID: string; + /** + * Application name. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + appName: string; + /** + * Application version name. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + versionName: string; + /** + * Application version. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + versionCode: number; +} +/** + * Defines the option of screenOnVisible interface. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export interface ScreenOnVisibleOptions { + /** + * Whether to keep the application visible. The default value is false. + * @since 3 + */ + visible?: boolean; + /** + * Called when the application always keeps visible. + * @since 3 + */ + success?: () => void; + /** + * Called when the application fails to keep visible. + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} +/** + * Defines the option of RequestFullWindow interface. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export interface RequestFullWindowOptions { + /** + * Defines the number of animation options. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + duration: number; +} +/** + * Defines the app class info. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ +export default class App { + /** + * Obtains the declared information in the config.json file of an application. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + static getInfo(): AppResponse; + /** + * Destroys the current ability. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + static terminate(): void; + /** + * Set image cache capacity of decoded image count. + * if not set, the application will not cache any decoded image. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param value capacity of decoded image count. + * @since 7 + */ + static setImageCacheCount(value: number): void; + /** + * Set image cache capacity of raw image data size in bytes before decode. + * if not set, the application will not cache any raw image data. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param value capacity of raw image data size in bytes. + * @since 7 + */ + static setImageRawDataCacheSize(value: number): void; + /** + * Set image file cache size in bytes on disk before decode. + * if not set, the application will cache 100MB image files on disk. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param value capacity of raw image data size in bytes. + * @since 7 + */ + static setImageFileCacheSize(value: number): void; +} diff --git a/build-tools/api/@system.battery.d.ts b/build-tools/api/@system.battery.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f607d91525ac02c66487d0b83ee99beb2464d260 --- /dev/null +++ b/build-tools/api/@system.battery.d.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 3 + */ +export interface BatteryResponse { + /** + * Whether the battery is being charged. + * @since 3 + */ + charging: boolean; + /** + * Current battery level, which ranges from 0.00 to 1.00. + * @since 3 + */ + level: number; +} +/** + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 3 + */ +export interface GetStatusOptions { + /** + * Called when the current charging state and battery level are obtained. + * @since 3 + */ + success?: (data: BatteryResponse) => void; + /** + * Called when the current charging state and battery level fail to be obtained. + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.PowerManager.BatteryManager.Core + * @since 3 + * @import battery from '@system.battery'; + */ +export default class Battery { + /** + * Obtains the current charging state and battery level. + * @param options Options. + * @since 3 + */ + static getStatus(options?: GetStatusOptions): void; +} diff --git a/build-tools/api/@system.bluetooth.d.ts b/build-tools/api/@system.bluetooth.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4fcdc6370db1ed2886264dd7b79175d3901f6c9d --- /dev/null +++ b/build-tools/api/@system.bluetooth.d.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @syscap SystemCapability.Communication.Bluetooth.Lite + * @since 6 + */ +export interface StartBLEScanOptions { + interval: number; + success: () => void; + fail: (data: string, code: number) => void; + complete: () => void; +} +/** + * @syscap SystemCapability.Communication.Bluetooth.Lite + * @since 6 + */ +export interface StopBLEScanOptions { + success: () => void; + fail: (data: string, code: number) => void; + complete: () => void; +} +/** + * @syscap SystemCapability.Communication.Bluetooth.Lite + * @since 6 + */ +export interface BluetoothDevice { + addrType: "public" | "random"; + addr: string; + rssi: number; + txpower: string; + data: string; +} +/** + * @syscap SystemCapability.Communication.Bluetooth.Lite + * @since 6 + */ +export interface BLEFoundResponse { + devices: Array; +} +/** + * @syscap SystemCapability.Communication.Bluetooth.Lite + * @since 6 + */ +export interface SubscribeBLEFoundOptions { + success: (data: BLEFoundResponse) => void; + fail: (data: string, code: number) => void; +} +/** + * Provides methods to manage BLE scan. + * @since 6 + * @import import bluetooth from '@system.bluetooth' + * @syscap SystemCapability.Communication.Bluetooth.Lite + */ +export default class Bluetooth { + /** + * Start BLE scan + * @param options Options + */ + static startBLEScan(options: StartBLEScanOptions): void; + /** + * Stop BLE scan + * @param options Options + */ + static stopBLEScan(options: StopBLEScanOptions): void; + /** + * Subscribe BLE found + * @param options Options + */ + static subscribeBLEFound(options: SubscribeBLEFoundOptions): void; + /** + * Stop the subscription of BLE found + */ + static unsubscribeBLEFound(): void; +} diff --git a/build-tools/api/@system.brightness.d.ts b/build-tools/api/@system.brightness.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..af1eb76c8223f9318fe5040e11cdf1545c078e19 --- /dev/null +++ b/build-tools/api/@system.brightness.d.ts @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface BrightnessResponse { + /** + * Screen brightness, which ranges from 1 to 100. + * @since 3 + */ + value: number; +} +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface GetBrightnessOptions { + /** + * Called when the current screen brightness is obtained. + * @since 3 + */ + success?: (data: BrightnessResponse) => void; + /** + * Called when the current screen brightness fails to be obtained. + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface SetBrightnessOptions { + /** + * Screen brightness. The value is an integer ranging from 1 to 100. + * If the value is less than or equal to 0, value 1 will be used. + * If the value is greater than 100, value 100 will be used. + * If the value contains decimals, the integral part of the value will be used. + * For example, if value is 8.1 is set, value 8 will be used. + * @since 3 + */ + value: number; + /** + * Called when the setting is successful. + * @since 3 + */ + success?: () => void; + /** + * Called when the setting fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface BrightnessModeResponse { + /** + * The value can be 0 or 1. + * 0: The screen brightness is manually adjusted. + * 1: The screen brightness is automatically adjusted. + * @since 3 + */ + mode: number; +} +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface GetBrightnessModeOptions { + /** + * Called when the screen brightness adjustment mode is obtained. + * @since 3 + */ + success?: (data: BrightnessModeResponse) => void; + /** + * Called when the screen brightness adjustment mode fails to be obtained. + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface SetBrightnessModeOptions { + /** + * The screen brightness mode. + * 0: The screen brightness is manually adjusted. + * 1: The screen brightness is automatically adjusted. + * @since 3 + */ + mode: number; + /** + * Called when the setting is successful. + * @since 3 + */ + success?: () => void; + /** + * Called when the setting fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + */ +export interface SetKeepScreenOnOptions { + /** + * Whether to always keep the screen on. + * @since 3 + */ + keepScreenOn: boolean; + /** + * Called when the setting is successful. + * @since 3 + */ + success?: () => void; + /** + * Called when the setting fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.PowerManager.DisplayPowerManager + * @since 3 + * @import brightness from '@system.brightness'; + */ +export default class Brightness { + /** + * Obtains the current screen brightness. + * @param options Options. + * @since 3 + */ + static getValue(options?: GetBrightnessOptions): void; + /** + * Sets the screen brightness. + * @param options Options. + * @since 3 + */ + static setValue(options?: SetBrightnessOptions): void; + /** + * Obtains the screen brightness adjustment mode. + * @param options Options. + * @since 3 + */ + static getMode(options?: GetBrightnessModeOptions): void; + /** + * Sets the screen brightness adjustment mode. + * @param options Options. + * @since 3 + */ + static setMode(options?: SetBrightnessModeOptions): void; + /** + * Sets whether to always keey the screen on. + * @param options Options. + * @since 3 + */ + static setKeepScreenOn(options?: SetKeepScreenOnOptions): void; +} diff --git a/build-tools/api/@system.cipher.d.ts b/build-tools/api/@system.cipher.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..10d1655808c1cbf617c9e88b9fb3aea6f127137a --- /dev/null +++ b/build-tools/api/@system.cipher.d.ts @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the cipher response. + * @since 3 + * @syscap SystemCapability.Security.Cipher + * @permission N/A + */ +export interface CipherResponse { + /** + * response text + * @since 3 + * @syscap SystemCapability.Security.Cipher + */ + text: string; +} +/** + * Defines the rsa cipher options. + * @since 3 + * @syscap SystemCapability.Security.Cipher + * @permission N/A + */ +export interface CipherRsaOptions { + /** + * Action type. + * The options are as follows: + * encrypt: Encrypts data. + * decrypt: Decrypts data. + * @since 3 + * @syscap SystemCapability.Security.Cipher + */ + action: string; + /** + * Text content to be encrypted or decrypted. + * The text to be encrypted must be a common text and cannot exceed the length calculated based on the formula (keySize/8 - 66). + * keySize indicates the key length. + * For example, if the key length is 1024 bytes, the text cannot exceed 62 bytes (1024/8 - 66 = 62). + * The text content to be decrypted must be a binary value encoded using Base64. + * The default format is used for Base64 encoding. + * @since 3 + * @syscap SystemCapability.Security.Cipher + */ + text: string; + /** + * Keys encrypted using RSA. + * During encryption, this parameter is a public key. + * During decryption, it is a private key. + * @since 3 + * @syscap SystemCapability.Security.Cipher + */ + key: string; + /** + * RSA algorithm padding. + * The default value is RSA/None/OAEPWithSHA256AndMGF1Padding. + * @since 3 + * @syscap SystemCapability.Security.Cipher + */ + transformation?: string; + /** + * Called when data is encrypted or decrypted successfully. + * @since 3 + * @syscap SystemCapability.Security.Cipher + */ + success: (data: CipherResponse) => void; + /** + * Called when data fails to be encrypted or decrypted. + * @since 3 + * @syscap SystemCapability.Security.Cipher + */ + fail: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + * @syscap SystemCapability.Security.Cipher + */ + complete: () => void; +} +/** + * Defines the aes cipher options. + * @since 3 + * @syscap SystemCapability.Security.Cipher + * @permission N/A + */ +export interface CipherAesOptions { + /** + * Action type. + * The options are as follows: + * encrypt: Encrypts data. + * decrypt: Decrypts data. + * @syscap SystemCapability.Security.Cipher + * @since 3 + */ + action: string; + /** + * Text content to be encrypted or decrypted. + * The text to be encrypted must be a common text. + * The text content to be decrypted must be a binary value encoded using Base64. + * The default format is used for Base64 encoding. + * @syscap SystemCapability.Security.Cipher + * @since 3 + */ + text: string; + /** + * Key used for encryption or decryption, which is a character string encrypted using Base64. + * @syscap SystemCapability.Security.Cipher + * @since 3 + */ + key: string; + /** + * Encryption mode and padding of the AES algorithm. + * The default value is AES/CBC/PKCS5Padding. + * @syscap SystemCapability.Security.Cipher + * @since 3 + */ + transformation?: string; + /** + * Initial vector for AES-based encryption and decryption. + * The value is a character string encoded using Base64. + * The default value is the key value. + * @syscap SystemCapability.Security.Cipher + * @since 3 + */ + iv?: string; + /** + * Offset of the initial vector for AES-based encryption and decryption. + * The default value is 0. + * @syscap SystemCapability.Security.Cipher + * @since 3 + */ + ivOffset?: string; + /** + * Length of the initial vector for AES-based encryption and decryption. + * The default value is 16. + * @syscap SystemCapability.Security.Cipher + * @since 3 + */ + ivLen?: string; + /** + * Called when data is encrypted or decrypted successfully. + * @syscap SystemCapability.Security.Cipher + * @since 3 + */ + success: (data: CipherResponse) => void; + /** + * Called when data fails to be encrypted or decrypted. + * @syscap SystemCapability.Security.Cipher + * @since 3 + */ + fail: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.Security.Cipher + * @since 3 + */ + complete: () => void; +} +/** + * Defines the cipher functions. + * @since 3 + * @syscap SystemCapability.Security.Cipher + * @permission N/A + */ +export default class Cipher { + /** + * Encrypts or decrypts data using RSA. + * @param options RSA options + * @syscap SystemCapability.Security.Cipher + */ + static rsa(options: CipherRsaOptions): void; + /** + * Encrypts or decrypts data using AES. + * @param options AES options + * @syscap SystemCapability.Security.Cipher + */ + static aes(options: CipherAesOptions): void; +} diff --git a/build-tools/api/@system.configuration.d.ts b/build-tools/api/@system.configuration.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..064ce7c5e2001e092c1d614a84766317a0004c8b --- /dev/null +++ b/build-tools/api/@system.configuration.d.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ +export interface LocaleResponse { + /** + * Current language of the application. Example: zh. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + language: string; + /** + * Country or region. Example: CN. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + countryOrRegion: string; + /** + * Text layout direction. Available values are as follows: + * ltr: The text direction is from left to right. + * rtl: The text direction is from right to left. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + dir: "ltr" | "rtl"; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ +export default class Configuration { + /** + * Obtains the current locale of the application, which is the same as the system locale. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + static getLocale(): LocaleResponse; +} diff --git a/build-tools/api/@system.device.d.ts b/build-tools/api/@system.device.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b37811dc415c73e7a20f6be7e1d3416c6da18117 --- /dev/null +++ b/build-tools/api/@system.device.d.ts @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @syscap SystemCapability.Startup.SystemInfo + */ +export interface DeviceResponse { + /** + * Brand. + * @syscap SystemCapability.Startup.SystemInfo + * @since 3 + */ + brand: string; + /** + * Manufacturer. + * @syscap SystemCapability.Startup.SystemInfo + * @since 3 + */ + manufacturer: string; + /** + * Model. + * @syscap SystemCapability.Startup.SystemInfo + * @since 3 + */ + model: string; + /** + * Product number. + * @syscap SystemCapability.Startup.SystemInfo + * @since 3 + */ + product: string; + /** + * System language. + * @syscap SystemCapability.Startup.SystemInfo + * @since 4 + */ + language: string; + /** + * System region. + * @syscap SystemCapability.Startup.SystemInfo + * @since 4 + */ + region: string; + /** + * Window width. + * @syscap SystemCapability.Startup.SystemInfo + * @since 3 + */ + windowWidth: number; + /** + * Window Height. + * @syscap SystemCapability.Startup.SystemInfo + * @since 3 + */ + windowHeight: number; + /** + * Screen density. + * @syscap SystemCapability.Startup.SystemInfo + * @since 4 + */ + screenDensity: number; + /** + * Screen shape. The options are as follows: + * rect: Rectangle screen. + * circle: Circle screen. + * @syscap SystemCapability.Startup.SystemInfo + * @since 4 + */ + screenShape: "rect" | "circle"; + /** + * API version. + * @syscap SystemCapability.Startup.SystemInfo + * @since 4 + */ + apiVersion: number; + /** + * Device type. The options are as follows: + * phone: smartphone + * tablet: tablet + * tv: smart TV + * wearable: wearable + * liteWearable: lite wearable + * ar: AR + * vr: virtual reality + * earphones: headset + * pc: personal computer + * speaker: speaker + * smartVision: smart visual device + * linkIoT: connection module + * @syscap SystemCapability.Startup.SystemInfo + * @since 4 + */ + deviceType: string; +} +export interface GetDeviceOptions { + /** + * Called when the device information is obtained. + * @syscap SystemCapability.Startup.SystemInfo + * @since 3 + */ + success?: (data: DeviceResponse) => void; + /** + * Called when the device information fails to be obtained. + * @syscap SystemCapability.Startup.SystemInfo + * @since 3 + */ + fail?: (data: any, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.Startup.SystemInfo + * @since 3 + */ + complete?: () => void; +} +/** + * getInfo interface + */ +export default class Device { + /** + * Obtains the device information. + * @syscap SystemCapability.Startup.SystemInfo + * @param options Options. + */ + static getInfo(options?: GetDeviceOptions): void; +} diff --git a/build-tools/api/@system.fetch.d.ts b/build-tools/api/@system.fetch.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..16abeee8eea64d3fadbf7ad0ea2c1fc6a35b8509 --- /dev/null +++ b/build-tools/api/@system.fetch.d.ts @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @import import fetch from '@system.fetch'; + * @since 3 + * @syscap SystemCapability.Communication.NetStack + */ +export interface FetchResponse { + /** + * Server status code. + * @since 3 + */ + code: number; + /** + * Data returned by the success function. + * @since 3 + */ + data: string | object; + /** + * All headers in the response from the server. + * @since 3 + */ + headers: Object; +} +/** + * @import import fetch from '@system.fetch'; + * @since 3 + * @syscap SystemCapability.Communication.NetStack + */ +export default class Fetch { + /** + * Obtains data through the network. + * @param options + */ + static fetch(options: { + /** + * Resource URL. + * @since 3 + */ + url: string; + /** + * Request parameter, which can be of the string type or a JSON object. + * @since 3 + */ + data?: string | object; + /** + * Request header, which accommodates all attributes of the request. + * @since 3 + */ + header?: Object; + /** + * Request methods available: OPTIONS, GET, HEAD, POST, PUT, DELETE and TRACE. The default value is GET. + * @since 3 + */ + method?: string; + /** + * The return type can be text, or JSON. By default, the return type is determined based on Content-Type in the header returned by the server. + * @since 3 + */ + responseType?: string; + /** + * Called when the network data is obtained successfully. + * @since 3 + */ + success?: (data: FetchResponse) => void; + /** + * Called when the network data fails to be obtained. + * @since 3 + */ + fail?: (data: any, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; + }): void; +} diff --git a/build-tools/api/@system.file.d.ts b/build-tools/api/@system.file.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..051d3aab5ecfb3bea518bea12a47173c015f15bb --- /dev/null +++ b/build-tools/api/@system.file.d.ts @@ -0,0 +1,668 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export interface FileResponse { + /** + * File URI. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * File size, in bytes. + * If type is dir, the length value is fixed to 0. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + length: number; + /** + * Timestamp when the file is stored, which is the number of milliseconds elapsed since 1970/01/01 00:00:00. + * For lite wearables, the value is fixed to 0, because this parameter is restricted by the underlying file system. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + lastModifiedTime: number; + /** + * File type. The values are as follows: + * dir: directory + * file: file + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + type: "dir" | "file"; + /** + * File list. When the recursive value is true and the type is dir, the file information under the subdirectory will be returned. + * Otherwise, no value will be returned. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + subFiles?: Array; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileMoveOption { + /** + * URI of the file to move. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + srcUri: string; + /** + * URI of the file moved to the target location. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + dstUri: string; + /** + * Called when the source file is moved to the specified location successfully. + * This function returns the URI of the file moved to the target location. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: (uri: string) => void; + /** + * Called when moving fails. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileListResponse { + /** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fileList: Array; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileListOption { + /** + * URI of the directory. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * Called when the list is obtained successfully. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: (data: FileListResponse) => void; + /** + * Called when the list fails to be obtained. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +export interface FileCopyOption { + /** + * URI of the file to copy. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + srcUri: string; + /** + * URI of the file moved to the target location. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + dstUri: string; + /** + * Called when the copy file is saved successful. + * This function returns the URI of the file saved to the target location. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: (uri: string) => void; + /** + * Called when the copy or save operation fails. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +export interface FileGetOption { + /** + * File URI, which cannot be an application resource path. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * Whether to recursively obtain the file list under a subdirectory. + * The default value is false. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + recursive?: boolean; + /** + * Called when file information is obtained successfully. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: (file: FileResponse) => void; + /** + * Called when file information fails to be obtained. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +export interface FileDeleteOption { + /** + * URI of the file to be deleted, which cannot be an application resource path. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * Called when local files are deleted successfully. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: () => void; + /** + * Called when the deletion fails. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileWriteTextOption { + /** + * URI of a local file. If it does not exist, a file will be created. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * Character string to write into the local file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + text: string; + /** + * Encoding format. The default format is UTF-8. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + encoding?: string; + /** + * Whether to enable the append mode. The default value is false. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + append?: boolean; + /** + * Called when texts are written into a file successfully. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: () => void; + /** + * Called when texts fail to be written into a file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileReadTextResponse { + /** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + text: string; +} +export interface FileReadTextOption { + /** + * URI of a local file. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * Encoding format. The default format is UTF-8. + * Currently, only UTF-8 is supported. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + encoding?: string; + /** + * Position where the reading starts. + * The default value is the start position of the file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + position?: number; + /** + * Position where the reading starts. + * The default value is the start position of the file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + length?: number; + /** + * Called when texts are read successfully. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: (data: FileReadTextResponse) => void; + /** + * Called when texts fail to be read. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileWriteArrayBufferOption { + /** + * URI of a local file. If it does not exist, a file will be created. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * Buffer from which the data is derived. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + buffer: Uint8Array; + /** + * Offset to the position where the writing starts. The default value is 0. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + position?: number; + /** + * Whether to enable the append mode. + * The default value is false. If the value is true, the position parameter will become invalid. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + append?: boolean; + /** + * Called when data from a buffer is written into a file successfully. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: () => void; + /** + * Called when data from a buffer fails to be written into a file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileReadArrayBufferResponse { + /** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + buffer: Uint8Array; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileReadArrayBufferOption { + /** + * URI of a local file. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * Position where the reading starts. + * The default value is the start position of the file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + position?: number; + /** + * Length of the content to read. + * If this parameter is not set, all content of the file will be read. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + length?: number; + /** + * Called when the buffer data is read successfully. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: (data: FileReadArrayBufferResponse) => void; + /** + * Called when the buffer data fails to be read. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileAccessOption { + /** + * URI of the directory or file. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * Called when the check result is obtained successfully. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: () => void; + /** + * Called when the check fails. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileMkdirOption { + /** + * URI of the directory. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * 3. A maximum of five recursions are allowed for creating the directory. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * Whether to create the directory after creating its upper-level directory recursively. + * The default value is false. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + recursive?: boolean; + /** + * Called when the directory is created successfully. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: () => void; + /** + * Called when the creation fails. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export interface FileRmdirOption { + /** + * URI of the directory. + * Restricted by the underlying file system of lite wearables, the value must meet the following requirements: + * 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * 2. The maximum number of characters allowed is 128. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + uri: string; + /** + * Whether to delete files and subdirectories recursively. + * The default value is false. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + recursive?: boolean; + /** + * Called when the directory is deleted successfully. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + success?: () => void; + /** + * Called when the deletion fails. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + */ +export default class File { + /** + * Moves the source file to a specified location. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static move(options: FileMoveOption): void; + /** + * Copies a source file and save the copy to a specified location. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static copy(options: FileCopyOption): void; + /** + * Obtains the list of files in a specified directory. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static list(options: FileListOption): void; + /** + * Obtains information about a local file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static get(options: FileGetOption): void; + /** + * Deletes local files. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static delete(options: FileDeleteOption): void; + /** + * Writes texts into a file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static writeText(options: FileWriteTextOption): void; + /** + * Reads texts from a file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static readText(options: FileReadTextOption): void; + /** + * Writes data from a buffer into a file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static writeArrayBuffer(options: FileWriteArrayBufferOption): void; + /** + * Reads buffer data from a file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static readArrayBuffer(options: FileReadArrayBufferOption): void; + /** + * Checks whether a file or directory exists. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static access(options: FileAccessOption): void; + /** + * Creates a directory. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static mkdir(options: FileMkdirOption): void; + /** + * Deletes a directory. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 3 + * @param options Options. + */ + static rmdir(options: FileRmdirOption): void; +} diff --git a/build-tools/api/@system.geolocation.d.ts b/build-tools/api/@system.geolocation.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3cf0af7da2eb37f20d71deb9da8309f198e40682 --- /dev/null +++ b/build-tools/api/@system.geolocation.d.ts @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @syscap SystemCapability.Location.Location.Lite + */ +export interface GeolocationResponse { + /** + * Longitude. + * @since 3 + */ + longitude: number; + /** + * Latitude. + * @since 3 + */ + latitude: number; + /** + * Altitude. + * @since 3 + */ + altitude: number; + /** + * Location accuracy. + * @since 3 + */ + accuracy: number; + /** + * Time when the location is obtained. + * @since 3 + */ + time: number; +} +/** + * @syscap SystemCapability.Location.Location.Lite + * @permission ohos.permission.LOCATION + */ +export interface GetLocationOption { + /** + * Timeout duration, in milliseconds. + * For the rich device, the default value is 30000. + * For the lite wearable device, the default value is 180000. + * The timeout duration is necessary in case no result is returned if the request to obtain the geographic location is rejected for the lack of the required permission, weak positioning signal, or incorrect location settings. After the timeout duration expires, the fail function will be called. + * The value is a 32-digit positive integer. + * If the value set is less than or equal to 0, the default value will be used. + * @since 3 + */ + timeout?: number; + /** + * Coordinate system type. Available types can be obtained using getSupportedCoordTypes. + * The default type is wgs84. + * @since 3 + */ + coordType?: string; + /** + * Called when the geographic location is obtained. + * @since 3 + */ + success?: (data: GeolocationResponse) => void; + /** + * Called when the location types fail to be obtained + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.Location.Location.Lite + */ +export interface GetLocationTypeResponse { + /** + * @since 3 + */ + types: Array; +} +/** + * @syscap SystemCapability.Location.Location.Lite + */ +export interface GetLocationTypeOption { + /** + * Called when the location types are obtained. + * @since 3 + */ + success?: (data: GetLocationTypeResponse) => void; + /** + * Called when the location types fail to be obtained. + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.Location.Location.Lite + * @permission ohos.permission.LOCATION + */ +export interface SubscribeLocationOption { + /** + * Coordinate system type. Available types can be obtained using getSupportedCoordTypes. + * The default type is wgs84. + * @since 3 + */ + coordType?: string; + /** + * Called whenever the geographical location changes. + * @since 3 + */ + success: (data: GeolocationResponse) => void; + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Location.Location.Lite + */ +export default class Geolocation { + /** + * Obtains the geographic location. + * @permission ohos.permission.LOCATION + * @param options Options. + */ + static getLocation(options?: GetLocationOption): void; + /** + * Obtains the location types supported by the system. + * @param options Options. + */ + static getLocationType(options?: GetLocationTypeOption): void; + /** + * Listens to the geographical location. If this method is called multiple times, the last call takes effect. + * @permission ohos.permission.LOCATION + * @param options Options. + */ + static subscribe(options: SubscribeLocationOption): void; + /** + * Cancels listening to the geographical location. + * @permission ohos.permission.LOCATION + */ + static unsubscribe(): void; + /** + * Obtains the supported coordinate system types. + * @returns A string array of the supported coordinate system types, for example, ['wgs84']. + */ + static getSupportedCoordTypes(): Array; +} diff --git a/build-tools/api/@system.mediaquery.d.ts b/build-tools/api/@system.mediaquery.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..50e383262386cca4c0bc8d45696ce02d64dcbd92 --- /dev/null +++ b/build-tools/api/@system.mediaquery.d.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the MediaQuery event. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export interface MediaQueryEvent { + /** + * The result of match result. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + matches: boolean; +} +/** + * Defines the MediaQuery list info. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export interface MediaQueryList { + /** + * Serialized media query condition. + * This parameter is read-only. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + media?: string; + /** + * Whether the query is successful. True if the query condition is matched successfully, false otherwise. + * This parameter is read-only. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + matches?: boolean; + /** + * Called when the matches value changes. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + onchange?: (matches: boolean) => void; + /** + * Adds a listening function to MediaQueryList. + * The listening function must be added before onShow is called, that is, added to the onInit or onReady function. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + addListener(callback: (event: MediaQueryEvent) => void): void; + /** + * Removes a listening function from MediaQueryList. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + removeListener(callback: (event: MediaQueryEvent) => void): void; +} +/** + * Defines the mediaqurey interface. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export default class MediaQuery { + /** + * Queries a media item and returns a MediaQueryList object. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + static matchMedia(condition: string): MediaQueryList; +} diff --git a/build-tools/api/@system.network.d.ts b/build-tools/api/@system.network.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8e3e8c62707f4008008e8fb22cef6584b9f1e3fe --- /dev/null +++ b/build-tools/api/@system.network.d.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @import import network from '@system.network'; + * @since 3 + * @syscap SystemCapability.Communication.NetManager.Core + */ +export interface NetworkResponse { + /** + * Network type. The values can be 2G, 3G, 4G, WiFi, or none. + * @since 3 + */ + type: string; + /** + * Whether the billing is based on the data volume. + * @since 3 + */ + metered: boolean; +} +/** + * @import import network from '@system.network'; + * @since 3 + * @syscap SystemCapability.Communication.NetManager.Core + */ +export default class Network { + /** + * Obtains the network type. + * @param options + */ + static getType(options?: { + /** + * Called when the network type is obtained. + * @since 3 + */ + success?: (data: NetworkResponse) => void; + /** + * Called when the network type fails to be obtained. + * @since 3 + */ + fail?: (data: any, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; + }): void; + /** + * Listens to the network connection state. If this method is called multiple times, the last call takes effect. + * @param options + */ + static subscribe(options?: { + /** + * Called when the network connection state changes. + * @since 3 + */ + success?: (data: NetworkResponse) => void; + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: any, code: number) => void; + }): void; + /** + * Cancels listening to the network connection state. + * @param options + */ + static unsubscribe(): void; +} diff --git a/build-tools/api/@system.notification.d.ts b/build-tools/api/@system.notification.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..216ca012840fff312c615c1397d03dfcbf63871f --- /dev/null +++ b/build-tools/api/@system.notification.d.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @name ActionResult + * @since 3 + * @syscap SystemCapability.Notification.Notification + */ +export interface ActionResult { + /** + * Bundle name of the application to be redirected to after the notification is clicked. + */ + bundleName: string; + /** + * Ability name of the application to be redirected to after the notification is clicked. + */ + abilityName: string; + /** + * URI of the page to be redirected to. The supported URI formats are as follows: + * 1. Absolute path of the page, which is provided by the pages list in the config.json file. Example: + * pages/index/index + * pages/detail/detail + * 2. Particular path. If the value is a slash (/), the home page is displayed. + */ + uri: string; +} +/** + * @name ShowNotificationOptions + * @since 3 + * @syscap SystemCapability.Notification.Notification + */ +export interface ShowNotificationOptions { + /** + * Notification title. + */ + contentTitle?: string; + /** + * Notification content. + */ + contentText?: string; + /** + * Action triggered after the notification is clicked. + */ + clickAction?: ActionResult; +} +/** + * @name Notification + * @since 3 + * @syscap SystemCapability.Notification.Notification + */ +export default class Notification { + /** + * Displays the notification. + * @param options Options. + */ + static show(options?: ShowNotificationOptions): void; +} diff --git a/build-tools/api/@system.package.d.ts b/build-tools/api/@system.package.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e8affd06c9d88897f869591dca5be626ba855bf --- /dev/null +++ b/build-tools/api/@system.package.d.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @syscap SystemCapability.BundleManager.BundleFramework + * @since 3 + */ +export interface CheckPackageHasInstalledResponse { + /** + * Whether the application exists, or whether the native application has been installed. + * @syscap SystemCapability.BundleManager.BundleFramework + * @since 3 + */ + result: boolean; +} +/** + * @syscap SystemCapability.BundleManager.BundleFramework + * @since 3 + */ +export interface CheckPackageHasInstalledOptions { + /** + * Application bundle name. + * @syscap SystemCapability.BundleManager.BundleFramework + * @since 3 + */ + bundleName: string; + /** + * Called when native applications are installed. + * @syscap SystemCapability.BundleManager.BundleFramework + * @since 3 + */ + success?: (data: CheckPackageHasInstalledResponse) => void; + /** + * Called when native applications fail to be installed. + * @syscap SystemCapability.BundleManager.BundleFramework + * @since 3 + */ + fail?: (data: any, code: number) => void; + /** + * Called when the excution is completed. + * @syscap SystemCapability.BundleManager.BundleFramework + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.BundleManager.BundleFramework + * @since 3 + * @import package from '@system.package'; + */ +export default class Package { + /** + * Checks whethers an application exists, or whether a native application has been installed. + * @param options Options + * @syscap SystemCapability.BundleManager.BundleFramework + */ + static hasInstalled(options: CheckPackageHasInstalledOptions): void; +} diff --git a/build-tools/api/@system.prompt.d.ts b/build-tools/api/@system.prompt.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..23d0cc9f767977b59474cb3b5e563486ada510f9 --- /dev/null +++ b/build-tools/api/@system.prompt.d.ts @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the options of ShowToast. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export interface ShowToastOptions { + /** + * Text to display. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + message: string; + /** + * Duration of toast dialog box. The default value is 1500. + * The recommended value ranges from 1500 ms to 10000ms. + * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000 ms. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + duration?: number; + /** + * The distance between toast dialog box and the bottom of screen. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 5 + */ + bottom?: string | number; +} +/** + * Defines the prompt info of button. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export interface Button { + /** + * Defines the button info. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + text: string; + /** + * Defines the color of button. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + color: string; +} +/** + * Defines the response of ShowDialog. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export interface ShowDialogSuccessResponse { + /** + * Defines the index of data. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + index: number; +} +/** + * Defines the option of show dialog. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export interface ShowDialogOptions { + /** + * Title of the text to display. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + title?: string; + /** + * Text body. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + message?: string; + /** + * Array of buttons in the dialog box. + * The array structure is {text:'button', color: '#666666'}. + * One to three buttons are supported. The first button is of the positiveButton type, the second is of the negativeButton type, and the third is of the neutralButton type. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + buttons?: [ + Button, + Button?, + Button? + ]; + /** + * Called when the dialog box is displayed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + success?: (data: ShowDialogSuccessResponse) => void; + /** + * Called when the operation is cancelled. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + cancel?: (data: string, code: string) => void; + /** + * Called when the dialog box is closed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + complete?: (data: string) => void; +} +/** + * Defines the option of ShowActionMenu. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ +export interface ShowActionMenuOptions { + /** + * Title of the text to display. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + title?: string; + /** + * Array of buttons in the dialog box. + * The array structure is {text:'button', color: '#666666'}. + * One to six buttons are supported. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + buttons: [ + Button, + Button?, + Button?, + Button?, + Button?, + Button? + ]; + /** + * Called when the dialog box is displayed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + success?: (tapIndex: number, errMsg: string) => void; + /** + * Called when the operation is cancelled. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + fail?: (errMsg: string) => void; + /** + * Called when the dialog box is closed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + complete?: () => void; +} +/** + * Defines the prompt interface. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export default class Prompt { + /** + * Displays the notification text. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param options Options. + * @since 3 + */ + static showToast(options: ShowToastOptions): void; + /** + * Displays the dialog box. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param options Options. + * @since 3 + */ + static showDialog(options: ShowDialogOptions): void; + /** + * Displays the menu. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param options Options. + * @since 6 + */ + static showActionMenu(options: ShowActionMenuOptions): void; +} diff --git a/build-tools/api/@system.request.d.ts b/build-tools/api/@system.request.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e69bc4d851de051f8819556041b88d7babc05873 --- /dev/null +++ b/build-tools/api/@system.request.d.ts @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @syscap SystemCapability.MiscServices.Upload + */ +export interface UploadResponse { + /** + * Status code returned by the server. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + code: number; + /** + * Content returned by the server. + * The value type is determined by the returned content. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + data: string; + /** + * Headers returned by the server. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + headers: Object; +} +/** + * @syscap SystemCapability.MiscServices.Download + */ +export interface DownloadResponse { + /** + * Download token, which is used to obtain the download status. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + token: string; +} +/** + * @syscap SystemCapability.MiscServices.Download + */ +export interface OnDownloadCompleteResponse { + /** + * URI of the download file. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + uri: string; +} +/** + * @syscap SystemCapability.MiscServices.Upload + */ +export interface RequestFile { + /** + * File name in the header when multipart is used. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + filename?: string; + /** + * Name of a form item when multipart is used. The default value is file. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + name?: string; + /** + * Local storage directory of a file. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + uri: string; + /** + * Type of the file content. + * By default, the type is obtained based on the suffix of the file name or URI. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + type?: string; +} +/** + * @syscap SystemCapability.MiscServices.Upload + */ +export interface RequestData { + /** + * Name of the form element. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + name: string; + /** + * Value of the form element. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + value: string; +} +/** + * @syscap SystemCapability.MiscServices.Upload + */ +export interface UploadRequestOptions { + /** + * Resource URL. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + url: string; + /** + * Form data in the request body. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + data?: Array; + /** + * List of files to upload, which is submitted through multipart/form-data. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + files: Array; + /** + * Request header. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + header?: Object; + /** + * Request methods available: POST and PUT. The default value is POST. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + method?: string; + /** + * Called when the files are uploaded successfully. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + success?: (data: UploadResponse) => void; + /** + * Called when uploading fails. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + fail?: (data: any, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.MiscServices.Upload + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.MiscServices.Download + */ +export interface DownloadRequestOptions { + /** + * Resource URL. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + url: string; + /** + * Name of the file to downloaded. + * The value is obtained from the current request or resource URL by default. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + filename?: string; + /** + * Request header. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + header?: string; + /** + * Download description. + * The default value is the file name. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + description?: string; + /** + * Called when the files are successfully downloaded. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + success?: (data: DownloadResponse) => void; + /** + * Called when downloading fails. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + fail?: (data: any, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.MiscServices.Download + */ +export interface OnDownloadCompleteOptions { + /** + * Token of the result returned by the download function. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + token: string; + /** + * Called when the downloads are successfully obtained + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + success?: (data: OnDownloadCompleteResponse) => void; + /** + * Called when the downloads fail to be obtained. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + fail?: (data: any, code: number) => void; + /** + * Called when the execution is completed. + * @syscap SystemCapability.MiscServices.Download + * @since 3 + */ + complete?: () => void; +} +export default class Request { + /** + * Upload files. + * @param options Options. + * @syscap SystemCapability.MiscServices.Upload + */ + static upload(options: UploadRequestOptions): void; + /** + * This API is used to download files. + * @param options Options. + * @syscap SystemCapability.MiscServices.Download + */ + static download(options: DownloadRequestOptions): void; + /** + * Listens to download task status. + * @param options Options. + * @syscap SystemCapability.MiscServices.Download + */ + static onDownloadComplete(options: OnDownloadCompleteOptions): void; +} diff --git a/build-tools/api/@system.router.d.ts b/build-tools/api/@system.router.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..257ef4dfb156c0c328442fc6b54ee5ee43548ab0 --- /dev/null +++ b/build-tools/api/@system.router.d.ts @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the option of router. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @deprecated since 8, please use @ohos.router instead. + * @since 3 + */ +export interface RouterOptions { + /** + * URI of the destination page, which supports the following formats: + * 1. Absolute path of the page, which is provided by the pages list in the config.json file. + * Example: + * pages/index/index + * pages/detail/detail + * 2. Particular path. If the URI is a slash (/), the home page is displayed. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + uri: string; + /** + * Data that needs to be passed to the destination page during navigation. + * After the destination page is displayed, the parameter can be directly used for the page. + * For example, this.data1 (data1 is the key value of the params used for page navigation.) + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 3 + */ + params?: Object; +} +/** + * Defines the option of router back. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @deprecated since 8, please use @ohos.router instead. + * @since 7 + */ +export interface BackRouterOptions { + /** + * Returns to the page of the specified path. + * If the page with the specified path does not exist in the page stack, router.back() is called by default. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 7 + */ + uri?: string; + /** + * Data that needs to be passed to the destination page during navigation. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @since 7 + */ + params?: Object; +} +/** + * Defines the state of router. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @deprecated since 8, please use @ohos.router instead. + * @since 3 + */ +export interface RouterState { + /** + * Index of the current page in the stack. + * NOTE: The index starts from 1 from the bottom to the top of the stack. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + index: number; + /** + * Name of the current page, that is, the file name. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + name: string; + /** + * Path of the current page. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + path: string; +} +/** + * Defines the option of EnableAlertBeforeBackPage. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @deprecated since 8, please use @ohos.router instead. + * @since 6 + */ +export interface EnableAlertBeforeBackPageOptions { + /** + * dialog context. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + message: string; + /** + * Called when the dialog box is displayed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + success?: (errMsg: string) => void; + /** + * Called when the operation is cancelled. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + cancel?: (errMsg: string) => void; + /** + * Called when the dialog box is closed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + complete?: () => void; +} +/** + * Defines the option of DisableAlertBeforeBackPage. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @deprecated since 8, please use @ohos.router instead. + * @since 6 + */ +export interface DisableAlertBeforeBackPageOptions { + /** + * Called when the dialog box is displayed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + success?: (errMsg: string) => void; + /** + * Called when the operation is cancelled. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + cancel?: (errMsg: string) => void; + /** + * Called when the dialog box is closed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ + complete?: () => void; +} +type ParamsInterface = { + [key: string]: Object; +}; +/** + * Defines the Router interface. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @deprecated since 8, please use @ohos.router instead. + * @since 3 + */ +export default class Router { + /** + * Navigates to a specified page in the application based on the page URL and parameters. + * @param options Options. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + static push(options: RouterOptions): void; + /** + * Replaces the current page with another one in the application. The current page is destroyed after replacement. + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @param options Options. + * @since 3 + */ + static replace(options: RouterOptions): void; + /** + * Returns to the previous page or a specified page. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param options Options. + * @since 3 + */ + static back(options?: BackRouterOptions): void; + /** + * Obtains information about the current page params. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @returns Page params. + * @since 7 + */ + static getParams(): ParamsInterface; + /** + * Clears all historical pages and retains only the current page at the top of the stack. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + static clear(): void; + /** + * Obtains the number of pages in the current stack. + * @returns Number of pages in the stack. The maximum value is 32. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ + static getLength(): string; + /** + * Obtains information about the current page state. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @returns Page state. + * @since 3 + */ + static getState(): RouterState; + /** + * Pop up dialog to ask whether to back + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param options Options. + * @since 6 + */ + static enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void; + /** + * cancel enableAlertBeforeBackPage + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param options Options. + * @since 6 + */ + static disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void; +} diff --git a/build-tools/api/@system.sensor.d.ts b/build-tools/api/@system.sensor.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3fbcca480562baadcfb4a1d805bd30f16bdd3d8 --- /dev/null +++ b/build-tools/api/@system.sensor.d.ts @@ -0,0 +1,602 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.ACCELEROMETER + * @since 3 + * @deprecated since 8 + */ +export interface AccelerometerResponse { + /** + * X-coordinate + * @since 3 + */ + x: number; + /** + * Y-coordinate + * @since 3 + */ + y: number; + /** + * Z-coordinate + * @since 3 + */ + z: number; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.ACCELEROMETER + * @since 3 + * @deprecated since 8 + */ +export interface subscribeAccelerometerOptions { + /** + * Execution frequency of the callback function for listening to acceleration sensor data. + * Available values are as follows: + * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. + * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. + * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. + * The default value is normal. + * @since 3 + */ + interval: string; + /** + * Called when acceleration sensor data changes. + * @since 3 + */ + success: (data: AccelerometerResponse) => void; + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface CompassResponse { + /** + * Direction of the device (in degrees). + * @since 3 + */ + direction: number; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeCompassOptions { + /** + * Called when compass sensor data changes. + * @since 3 + */ + success: (data: CompassResponse) => void; + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface ProximityResponse { + /** + * Distance between a visible object and the device screen + * @since 3 + */ + distance: number; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeProximityOptions { + /** + * Called when distance sensor data changes. + * @since 3 + */ + success: (data: ProximityResponse) => void; + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface LightResponse { + /** + * Light intensity, in lux. + * @since 3 + */ + intensity: number; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeLightOptions { + /** + * Called when ambient light sensor data changes. + * @since 3 + */ + success: (data: LightResponse) => void; + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.ACTIVITY_MOTION + * @since 3 + * @deprecated since 8 + */ +export interface StepCounterResponse { + /** + * Number of steps counted. + * Each time the device restarts, the value is recalculated from 0 in phone, tablet. + * @since 3 + */ + steps: number; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.ACTIVITY_MOTION + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeStepCounterOptions { + /** + * Called when step counter sensor data changes. + * @since 3 + */ + success: (data: StepCounterResponse) => void; + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface BarometerResponse { + /** + * Pressure, in pascal. + * @since 3 + */ + pressure: number; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeBarometerOptions { + /** + * Called when the barometer sensor data changes. + * @since 3 + */ + success: (data: BarometerResponse) => void; + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.READ_HEALTH_DATA + * @since 3 + * @deprecated since 8 + */ +export interface HeartRateResponse { + /** + * Heart rate. + * 255 indicates an invalid value in lite wearable. + * @since 3 + */ + heartRate: number; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.READ_HEALTH_DATA + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeHeartRateOptions { + /** + * Called when the heart rate sensor data changes. + * @since 3 + */ + success: (data: HeartRateResponse) => void; + /** + * Called when the listening fails + * @since 3 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface OnBodyStateResponse { + /** + * Whether the sensor is worn. + * @since 3 + */ + value: boolean; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface SubscribeOnBodyStateOptions { + /** + * Called when the wearing status changes. + * @since 3 + */ + success: (data: OnBodyStateResponse) => void; + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 3 + * @deprecated since 8 + */ +export interface GetOnBodyStateOptions { + /** + * Called when the sensor wearing state is obtained + * @since 3 + */ + success: (data: OnBodyStateResponse) => void; + /** + * Called when the sensor wearing state fails to be obtained + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 6 + * @deprecated since 8 + */ +export interface DeviceOrientationResponse { + /** + * alpha + * @since 6 + */ + alpha: number; + /** + * beta + * @since 6 + */ + beta: number; + /** + * gamma + * @since 6 + */ + gamma: number; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 6 + * @deprecated since 8 + */ +export interface SubscribeDeviceOrientationOptions { + /** + * Execution frequency of the callback function for listening to device orientation sensor data. + * Available values are as follows: + * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. + * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. + * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. + * The default value is normal. + * @since 6 + */ + interval: string; + /** + * Called when device orientation sensor data changes. + * @since 6 + */ + success: (data: DeviceOrientationResponse) => void; + /** + * Called when the listening fails. + * @since 6 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.GYROSCOPE + * @since 6 + * @deprecated since 8 + */ +export interface GyroscopeResponse { + /** + * X-coordinate + * @since 6 + */ + x: number; + /** + * Y-coordinate + * @since 6 + */ + y: number; + /** + * Z-coordinate + * @since 6 + */ + z: number; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @permission ohos.permission.GYROSCOPE + * @since 6 + * @deprecated since 8 + */ +export interface SubscribeGyroscopeOptions { + /** + * Execution frequency of the callback function for listening to gyroscope sensor data. + * Available values are as follows: + * 1. game: Extremely high frequency (20 ms per callback), which is applicable to gaming. + * 2. ui: High frequency (60 ms per callback), which is applicable to UI updating. + * 3. normal: Regular frequency (200 ms per callback), which is application to low power consumption. + * The default value is normal. + * @since 6 + */ + interval: string; + /** + * Called when gyroscope sensor data changes. + * @since 6 + */ + success: (data: GyroscopeResponse) => void; + /** + * Called when the listening fails. + * @since 6 + */ + fail?: (data: string, code: number) => void; +} +/** + * @syscap SystemCapability.Sensors.Sensor + * @import import sensor from '@system.sensor'; + * @since 6 + * @deprecated since 8 + */ +export default class Sensor { + /** + * Listens to acceleration sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 3 + * @deprecated since 8 + */ + static subscribeAccelerometer(options: subscribeAccelerometerOptions): void; + /** + * Cancels listening to acceleration sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACCELEROMETER + * @since 3 + * @deprecated since 8 + */ + static unsubscribeAccelerometer(): void; + /** + * Listens to compass sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static subscribeCompass(options: SubscribeCompassOptions): void; + /** + * Cancels listening to compass sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static unsubscribeCompass(): void; + /** + * Listens to distance sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static subscribeProximity(options: SubscribeProximityOptions): void; + /** + * Cancels listening to distance sensor data. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static unsubscribeProximity(): void; + /** + * Listens to ambient light sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static subscribeLight(options: SubscribeLightOptions): void; + /** + * Cancels listening to ambient light sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static unsubscribeLight(): void; + /** + * Listens to step counter sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 3 + * @deprecated since 8 + */ + static subscribeStepCounter(options: SubscribeStepCounterOptions): void; + /** + * Cancels listening to step counter sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.ACTIVITY_MOTION + * @since 3 + * @deprecated since 8 + */ + static unsubscribeStepCounter(): void; + /** + * Listens to barometer sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static subscribeBarometer(options: SubscribeBarometerOptions): void; + /** + * Cancels listening to barometer sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static unsubscribeBarometer(): void; + /** + * Listens to changes of heart rate sensor data. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.READ_HEALTH_DATA + * @since 3 + * @deprecated since 8 + */ + static subscribeHeartRate(options: SubscribeHeartRateOptions): void; + /** + * Cancels listening to heart rate sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.READ_HEALTH_DATA + * @since 3 + * @deprecated since 8 + */ + static unsubscribeHeartRate(): void; + /** + * Listens to whether a sensor is worn. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static subscribeOnBodyState(options: SubscribeOnBodyStateOptions): void; + /** + * Cancels listening to whether the sensor is worn. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static unsubscribeOnBodyState(): void; + /** + * Obtains the sensor wearing state. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 3 + * @deprecated since 8 + */ + static getOnBodyState(options: GetOnBodyStateOptions): void; + /** + * Listens to device orientation sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @since 6 + * @deprecated since 8 + */ + static subscribeDeviceOrientation(options: SubscribeDeviceOrientationOptions): void; + /** + * Cancels listening to device orientation sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @since 6 + * @deprecated since 8 + */ + static unsubscribeDeviceOrientation(): void; + /** + * Listens to gyroscope sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GYROSCOPE + * @since 6 + * @deprecated since 8 + */ + static subscribeGyroscope(options: SubscribeGyroscopeOptions): void; + /** + * Cancels listening to gyroscope sensor data. + * @syscap SystemCapability.Sensors.Sensor + * @permission ohos.permission.GYROSCOPE + * @since 6 + * @deprecated since 8 + */ + static unsubscribeGyroscope(): void; +} diff --git a/build-tools/api/@system.storage.d.ts b/build-tools/api/@system.storage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a350c90f2af378b635a26c03fba51d430436642e --- /dev/null +++ b/build-tools/api/@system.storage.d.ts @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @import import storage from '@system.storage'; + * @since 3 + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @deprecated since 6 + * @FAModelOnly + */ +export interface GetStorageOptions { + /** + * Content index. + * the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + key: string; + /** + * Default value returned when the key does not exist. + * If this parameter is not specified, an empty string is returned. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + default?: string; + /** + * Called when the stored content is read successfully. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + success?: (data: any) => void; + /** + * Called when the stored content fails to be read. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + complete?: () => void; +} +/** + * @import import storage from '@system.storage'; + * @since 3 + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @deprecated since 6 + * @FAModelOnly + */ +export interface SetStorageOptions { + /** + * Index of the stored content to be modified. + * the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + key: string; + /** + * Target storage content. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + value: string; + /** + * Called when the stored content is modified successfully. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + success?: () => void; + /** + * Called when the stored content fails to be modified. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + complete?: () => void; +} +/** + * @import import storage from '@system.storage'; + * @since 3 + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @deprecated since 6 + * @FAModelOnly + */ +export interface ClearStorageOptions { + /** + * Called when the stored content is cleared successfully. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + success?: () => void; + /** + * Called when the stored content fails to be cleared. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + complete?: () => void; +} +/** + * @import import storage from '@system.storage'; + * @since 3 + * @deprecated since 6 + * @FAModelOnly + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + */ +export interface DeleteStorageOptions { + /** + * Content index. + * the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + key: string; + /** + * Called when the stored content is deleted successfully. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + success?: () => void; + /** + * Called when the stored content fails to be deleted. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + * @deprecated since 6 + * @FAModelOnly + */ + complete?: () => void; +} +/** + * @import import storage from '@system.storage'; + * @since 3 + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @deprecated since 6 + * @FAModelOnly + */ +export default class Storage { + /** + * Reads the stored content. + * @param options Options. + * @deprecated since 6 + * @FAModelOnly + */ + static get(options: GetStorageOptions): void; + /** + * Modifies the stored content. + * @param options Options. + * @deprecated since 6 + * @FAModelOnly + */ + static set(options: SetStorageOptions): void; + /** + * Clears the stored content. + * @param options Options. + * @deprecated since 6 + * @FAModelOnly + */ + static clear(options?: ClearStorageOptions): void; + /** + * Deletes the stored content. + * @param options Options. + * @deprecated since 6 + * @FAModelOnly + */ + static delete(options: DeleteStorageOptions): void; +} diff --git a/build-tools/api/@system.vibrator.d.ts b/build-tools/api/@system.vibrator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cac4b6bac9ce7a8c8175cb535de2753e60058cf0 --- /dev/null +++ b/build-tools/api/@system.vibrator.d.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @syscap SystemCapability.Sensors.MiscDevice + * @import import vibrator from '@system.vibrator'; + * @permission ohos.permission.VIBRATE + * @since 3 + * @deprecated since 8 + */ +export interface VibrateOptions { + /** + * Vibration mode. The value long indicates long vibration, and short indicates short vibration. + * The default value is long. + * @since 3 + */ + mode?: "long" | "short"; + /** + * Called when success to trigger vibration. + * @since 3 + */ + success: () => void; + /** + * Called when fail to trigger vibration. + * @since 3 + */ + fail?: (data: string, code: number) => void; + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} +/** + * @syscap SystemCapability.Sensors.MiscDevice + * @import import vibrator from '@system.vibrator'; + * @permission ohos.permission.VIBRATE + * @since 3 + * @deprecated since 8 + */ +export default class Vibrator { + /** + * Triggers vibration. + * @param options Options. + * @permission ohos.permission.VIBRATE + * @since 3 + * @deprecated since 8 + */ + static vibrate(options?: VibrateOptions): void; +} diff --git a/build-tools/api/ability/abilityResult.d.ts b/build-tools/api/ability/abilityResult.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a62a2a94b94f40622f96c6d39d5cdb7983fb69ff --- /dev/null +++ b/build-tools/api/ability/abilityResult.d.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Want from '../@ohos.application.Want'; +/** + * @since 7 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ +export interface AbilityResult { + /** + * Indicates the result code returned after the ability is destroyed. You can define the result + * code to identify an error. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityBase + */ + resultCode: number; + /** + * Indicates the data returned after the ability is destroyed. You can define the data returned. + * This parameter can be null. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityBase + */ + want?: Want; +} diff --git a/build-tools/api/ability/connectOptions.d.ts b/build-tools/api/ability/connectOptions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..08f59fead9cc56a94945ddfba39388409743c053 --- /dev/null +++ b/build-tools/api/ability/connectOptions.d.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ElementName } from '../bundle/elementName'; +import rpc from './../@ohos.rpc'; +/** + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + */ +export interface ConnectOptions { + /** + * The callback interface was connect successfully. + * + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param elementName The element name of the service ability + * @param remote The remote object instance + */ + onConnect(elementName: ElementName, remote: rpc.IRemoteObject): void; + /** + * The callback interface was disconnect successfully. + * + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param elementName The element name of the service ability + */ + onDisconnect(elementName: ElementName): void; + /** + * The callback interface was connect failed. + * + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param code The error code of the failed. + */ + onFailed(code: number): void; +} diff --git a/build-tools/api/ability/dataAbilityHelper.d.ts b/build-tools/api/ability/dataAbilityHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..16f7e44260e609b28102ea6eab7633e1c5c5bef7 --- /dev/null +++ b/build-tools/api/ability/dataAbilityHelper.d.ts @@ -0,0 +1,240 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback } from '../basic'; +import { ResultSet } from '../data/rdb/resultSet'; +import { DataAbilityOperation } from './dataAbilityOperation'; +import { DataAbilityResult } from './dataAbilityResult'; +import dataAbility from '../@ohos.data.dataAbility'; +import rdb from '../@ohos.data.rdb'; +/** + * DataAbilityHelper + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * + * @since 7 + * @FAModelOnly + */ +export interface DataAbilityHelper { + /** + * Opens a file in a specified remote path. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the file to open. + * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access + * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing + * file, "wa" for write-only access to append to any existing data, "rw" for read and write access on + * any existing data, or "rwt" for read and write access that truncates any existing file. + * @param callback Indicates the callback when openfile success + * @return Returns the file descriptor. + * @FAModelOnly + */ + openFile(uri: string, mode: string, callback: AsyncCallback): void; + openFile(uri: string, mode: string): Promise; + /** + * Registers an observer to observe data specified by the given uri. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param type dataChange. + * @param uri Indicates the path of the data to operate. + * @param callback Indicates the callback when dataChange. + * @return - + * @FAModelOnly + */ + on(type: 'dataChange', uri: string, callback: AsyncCallback): void; + /** + * Deregisters all observers used for monitoring data specified by the given uri. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param type dataChange. + * @param uri Indicates the path of the data to operate. + * @param callback Indicates the registered callback. + * @return - + * @FAModelOnly + */ + off(type: 'dataChange', uri: string, callback?: AsyncCallback): void; + /** + * Obtains the MIME type of the date specified by the given URI. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the data to operate. + * @return Returns the MIME type that matches the data specified by uri. + * @FAModelOnly + */ + getType(uri: string, callback: AsyncCallback): void; + getType(uri: string): Promise; + /** + * Obtains the MIME types of files supported. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the files to obtain. + * @param mimeTypeFilter Indicates the MIME types of the files to obtain. + * @return Returns the matched MIME types Array. + * @FAModelOnly + */ + getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void; + getFileTypes(uri: string, mimeTypeFilter: string): Promise>; + /** + * Converts the given uri that refers to the Data ability into a normalized uri. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the uri object to normalize. + * @return Returns the normalized uri object if the Data ability supports URI normalization or null. + * @FAModelOnly + */ + normalizeUri(uri: string, callback: AsyncCallback): void; + normalizeUri(uri: string): Promise; + /** + * Converts the given normalized uri generated by normalizeUri(uri) into a denormalized one. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the uri object to normalize. + * @return Returns the denormalized uri object if the denormalization is successful. + * @FAModelOnly + */ + denormalizeUri(uri: string, callback: AsyncCallback): void; + denormalizeUri(uri: string): Promise; + /** + * Notifies the registered observers of a change to the data resource specified by uri. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the data to operate. + * @return - + * @FAModelOnly + */ + notifyChange(uri: string, callback: AsyncCallback): void; + notifyChange(uri: string): Promise; + /** + * Inserts a single data record into the database. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the data to insert. + * @param valuesBucket Indicates the data record to insert. If this parameter is null, a blank row will be inserted. + * @return Returns the index of the inserted data record. + * @FAModelOnly + */ + insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback): void; + insert(uri: string, valuesBucket: rdb.ValuesBucket): Promise; + /** + * Inserts multiple data records into the database. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the data to batchInsert. + * @param valuesBuckets Indicates the data records to insert. + * @return Returns the number of data records inserted. + * @FAModelOnly + */ + batchInsert(uri: string, valuesBuckets: Array, callback: AsyncCallback): void; + batchInsert(uri: string, valuesBuckets: Array): Promise; + /** + * Deletes one or more data records from the database. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of the data to delete. + * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. + * @return Returns the number of data records deleted. + * @FAModelOnly + */ + delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; + delete(uri: string, predicates?: dataAbility.DataAbilityPredicates): Promise; + delete(uri: string, callback: AsyncCallback): void; + /** + * Updates data records in the database. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of data to update. + * @param valuesBucket Indicates the data to update. + * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. + * @return Returns the number of data records updated. + * @FAModelOnly + */ + update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; + update(uri: string, valuesBucket: rdb.ValuesBucket, predicates?: dataAbility.DataAbilityPredicates): Promise; + update(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback): void; + /** + * Queries data in the database. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of data to query. + * @param columns Indicates the columns to query. If this parameter is null, all columns are queried. + * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. + * @return Returns the query result {@link ResultSet}. + * @FAModelOnly + */ + query(uri: string, columns: Array, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; + query(uri: string, callback: AsyncCallback): void; + query(uri: string, columns: Array, callback: AsyncCallback): void; + query(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; + query(uri: string, columns?: Array, predicates?: dataAbility.DataAbilityPredicates): Promise; + /** + * Calls the extended API of the DataAbility. This method uses a promise to return the result. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx" + * @param method Indicates the method to call. + * @param arg Indicates the parameter of the String type. + * @param extras Indicates the parameter of the PacMap type. + * If a custom Sequenceable object is put in the PacMap object and will be transferred across processes, + * you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. + * If the PacMap object is to be transferred to a non-OHOS process, + * values of primitive types are supported, but not custom Sequenceable objects. + * @return Returns the query result {@link PacMap}. + * @FAModelOnly + */ + call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCallback): void; + call(uri: string, method: string, arg: string, extras: PacMap): Promise; + /** + * Queries data in the database. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri Indicates the path of data to query. + * @param operations Indicates the data operation list, which can contain multiple operations on the database. + * @return Returns the result of each operation, in array {@link DataAbilityResult}. + */ + executeBatch(uri: string, operations: Array, callback: AsyncCallback>): void; + executeBatch(uri: string, operations: Array): Promise>; +} +/** + * Defines a PacMap object for storing a series of values. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ +export interface PacMap { + /** + * Indicates the parameter of the PacMap type. + * If a custom Sequenceable object is put in the PacMap object and will be transferred across processes, + * you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. + * If the PacMap object is to be transferred to a non-OHOS process, + * values of primitive types are supported, but not custom Sequenceable objects. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + [key: string]: number | string | boolean | Array | null; +} diff --git a/build-tools/api/ability/dataAbilityOperation.d.ts b/build-tools/api/ability/dataAbilityOperation.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..96b052d6d6034675e7103d78ef4be99d847176ca --- /dev/null +++ b/build-tools/api/ability/dataAbilityOperation.d.ts @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import featureAbility from '../@ohos.ability.featureAbility'; +import dataAbility from '../@ohos.data.dataAbility'; +import rdb from '../@ohos.data.rdb'; +/** +* @since 7 +* @syscap SystemCapability.Ability.AbilityRuntime.FAModel +* @permission N/A +*/ +export interface DataAbilityOperation { + /** + * Indicates the path of data to operate. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + uri: string; + /** + * Indicates a operation type. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + type: featureAbility.DataAbilityOperationType; + /** + * Indicates the data values to be set. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + valuesBucket?: rdb.ValuesBucket; + /** + * Indicates the valuesBucket object containing a set of key-value pairs. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + valueBackReferences?: rdb.ValuesBucket; + /** + * Indicates the filter criteria to set. If this parameter is null, all data records + * will be operated by default. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + predicates?: dataAbility.DataAbilityPredicates; + /** + * Indicates the back reference to be used as a filter criterion in predicates. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + predicatesBackReferences?: Map; + /** + * Specifies whether a batch operation can be interrupted. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + interrupted?: boolean; + /** + * Indicates the expected number of rows to update or delete. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + expectedCount?: number; +} diff --git a/build-tools/api/ability/dataAbilityResult.d.ts b/build-tools/api/ability/dataAbilityResult.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..44c70cc1f067f1511ca0270e1f06d79e4117c240 --- /dev/null +++ b/build-tools/api/ability/dataAbilityResult.d.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** +* @name DataAbilityResult +* @since 7 +* @syscap SystemCapability.Ability.AbilityRuntime.FAModel +* @permission N/A +*/ +export interface DataAbilityResult { + /** + * Indicates the path of data to operate. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + uri?: string; + /** + * Indicates the number of rows affected by the operation. + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + count?: number; +} diff --git a/build-tools/api/ability/startAbilityParameter.d.ts b/build-tools/api/ability/startAbilityParameter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d124aee17960e952b509b473472405535e156af --- /dev/null +++ b/build-tools/api/ability/startAbilityParameter.d.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Want from '../@ohos.application.Want'; +/** +* @since 6 +* @syscap SystemCapability.Ability.AbilityRuntime.FAModel +* @permission N/A +*/ +export interface StartAbilityParameter { + /** + * Indicates the Want containing information about the target ability to start. + * + * @default - + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + want: Want; + /** + * Indicates the special start setting used in starting ability. + * + * @default - + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + abilityStartSetting?: { + [key: string]: any; + }; +} diff --git a/build-tools/api/ability/want.d.ts b/build-tools/api/ability/want.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b65c603fcfd9c935396694d1130deadc154852a --- /dev/null +++ b/build-tools/api/ability/want.d.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Want is the basic communication component of the system. + * @name Want + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + * @permission N/A + */ +export declare interface Want { + /** + * device id + * @default - + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + */ + deviceId?: string; + /** + * bundle name + * @default - + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + */ + bundleName?: string; + /** + * ability name + * @default - + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + */ + abilityName?: string; + /** + * The description of a URI in a Want. + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + uri?: string; + /** + * The description of the type in this Want. + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + type?: string; + /** + * The options of the flags in this Want. + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + flags?: number; + /** + * The description of an action in an want. + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + action?: string; + /** + * The description of the WantParams object in an Want + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + parameters?: { + [key: string]: any; + }; + /** + * The description of a entities in a Want. + * @since 6 + * @syscap SystemCapability.Ability.AbilityBase + * @default - + */ + entities?: Array; +} diff --git a/build-tools/api/app/appVersionInfo.d.ts b/build-tools/api/app/appVersionInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..50e4c0323a2a5a7f40965a645e3468a19abbe15c --- /dev/null +++ b/build-tools/api/app/appVersionInfo.d.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines an AppVersionInfo object. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission NA + */ +export interface AppVersionInfo { + /** + * Application name. + * @default appName + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + readonly appName: string; + /** + * Application version number. + * @default versionCode + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + readonly versionCode: number; + /** + * Application version name. + * @default versionName + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + readonly versionName: string; +} diff --git a/build-tools/api/app/context.d.ts b/build-tools/api/app/context.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9995b89bfc813f1367d7460570479a1c152d129b --- /dev/null +++ b/build-tools/api/app/context.d.ts @@ -0,0 +1,289 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback } from '../basic'; +import { ApplicationInfo } from '../bundle/applicationInfo'; +import { ProcessInfo } from './processInfo'; +import { ElementName } from '../bundle/elementName'; +import BaseContext from '../application/BaseContext'; +import { HapModuleInfo } from '../bundle/hapModuleInfo'; +import { AppVersionInfo } from './appVersionInfo'; +import { AbilityInfo } from '../bundle/abilityInfo'; +import bundle from '../@ohos.bundle'; +/** + * The context of an ability or an application. It allows access to + * application-specific resources, request and verification permissions. + * Can only be obtained through the ability. + * + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import abilityManager from 'app/context' + * @permission N/A + * @FAModelOnly + */ +export interface Context extends BaseContext { + /** + * Get the local root dir of an app. If it is the first call, the dir + * will be created. + * @note If in the context of the ability, return the root dir of + * the ability; if in the context of the application, return the + * root dir of the application. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return the root dir + * @FAModelOnly + */ + getOrCreateLocalDir(): Promise; + getOrCreateLocalDir(callback: AsyncCallback): void; + /** + * Verify whether the specified permission is allowed for a particular + * pid and uid running in the system. + * @param permission The name of the specified permission + * @param pid process id + * @param uid user id + * @note Pid and uid are optional. If you do not pass in pid and uid, + * it will check your own permission. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return asynchronous callback with {@code 0} if the PID + * and UID have the permission; callback with {@code -1} otherwise. + * @FAModelOnly + */ + verifyPermission(permission: string, options?: PermissionOptions): Promise; + verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback): void; + verifyPermission(permission: string, callback: AsyncCallback): void; + /** + * Requests certain permissions from the system. + * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. + * @param requestCode Indicates the request code to be passed to the PermissionRequestResult + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + requestPermissionsFromUser(permissions: Array, requestCode: number, resultCallback: AsyncCallback): void; + requestPermissionsFromUser(permissions: Array, requestCode: number): Promise; + /** + * Obtains information about the current application. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getApplicationInfo(callback: AsyncCallback): void; + getApplicationInfo(): Promise; + /** + * Obtains the bundle name of the current ability. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getBundleName(callback: AsyncCallback): void; + getBundleName(): Promise; + /** + * Obtains the current display orientation of this ability. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + getDisplayOrientation(callback: AsyncCallback): void; + getDisplayOrientation(): Promise; + /** + * Sets the display orientation of the current ability. + * @param orientation Indicates the new orientation for the current ability. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCallback): void; + setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise; + /** + * Sets whether to show this ability on top of the lock screen whenever the lock screen is displayed, keeping the ability in the ACTIVE state. + * @param show Specifies whether to show this ability on top of the lock screen. The value true means to show it on the lock screen, and the value false means not. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + setShowOnLockScreen(show: boolean, callback: AsyncCallback): void; + setShowOnLockScreen(show: boolean): Promise; + /** + * Sets whether to wake up the screen when this ability is restored. + * @param wakeUp Specifies whether to wake up the screen. The value true means to wake it up, and the value false means not. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + setWakeUpScreen(wakeUp: boolean, callback: AsyncCallback): void; + setWakeUpScreen(wakeUp: boolean): Promise; + /** + * Obtains information about the current process, including the process ID and name. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getProcessInfo(callback: AsyncCallback): void; + getProcessInfo(): Promise; + /** + * Obtains the ohos.bundle.ElementName object of the current ability. This method is available only to Page abilities. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getElementName(callback: AsyncCallback): void; + getElementName(): Promise; + /** + * Obtains the name of the current process. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getProcessName(callback: AsyncCallback): void; + getProcessName(): Promise; + /** + * Obtains the bundle name of the ability that called the current ability. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getCallingBundle(callback: AsyncCallback): void; + getCallingBundle(): Promise; + /** + * Obtains the file directory of this application on the internal storage. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getFilesDir(callback: AsyncCallback): void; + getFilesDir(): Promise; + /** + * Obtains the cache directory of this application on the internal storage. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getCacheDir(callback: AsyncCallback): void; + getCacheDir(): Promise; + /** + * Obtains the distributed file path for storing ability or application data files. + * If the distributed file path does not exist, the system will create a path and return the created path. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getOrCreateDistributedDir(): Promise; + getOrCreateDistributedDir(callback: AsyncCallback): void; + /** + * Obtains the application type. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getAppType(callback: AsyncCallback): void; + getAppType(): Promise; + /** + * Obtains the ModuleInfo object for this application. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getHapModuleInfo(callback: AsyncCallback): void; + getHapModuleInfo(): Promise; + /** + * Obtains the application version information. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getAppVersionInfo(callback: AsyncCallback): void; + getAppVersionInfo(): Promise; + /** + * Obtains the context of this application. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getApplicationContext(): Context; + /** + * Checks the detailed information of this ability. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getAbilityInfo(callback: AsyncCallback): void; + getAbilityInfo(): Promise; + /** + * Checks whether the configuration of this ability is changing. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return true if the configuration of this ability is changing and false otherwise. + * @FAModelOnly + */ + isUpdatingConfigurations(callback: AsyncCallback): void; + isUpdatingConfigurations(): Promise; + /** + * Informs the system of the time required for drawing this Page ability. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + printDrawnCompleted(callback: AsyncCallback): void; + printDrawnCompleted(): Promise; +} +/** + * @name the result of requestPermissionsFromUser with asynchronous callback + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @FAModelOnly + */ +interface PermissionRequestResult { + /** + * @default The request code passed in by the user + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + requestCode: number; + /** + * @default The permissions passed in by the user + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + permissions: Array; + /** + * @default The results for the corresponding request permissions + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + authResults: Array; +} +/** + * @name PermissionOptions + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @FAModelOnly + */ +interface PermissionOptions { + /** + * @default The process id + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + pid?: number; + /** + * @default The user id + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + uid?: number; +} diff --git a/build-tools/api/app/processInfo.d.ts b/build-tools/api/app/processInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea58b3775eefb0f4af47c09179ec690420c5cdd8 --- /dev/null +++ b/build-tools/api/app/processInfo.d.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @name This class saves process information about an application + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import ProcessInfo from 'app/processInfo' + * @permission N/A + */ +export interface ProcessInfo { + /** + * The id of the current process + * + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + pid: number; + /** + * The name of the current process + * + * @default - + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + processName: string; +} diff --git a/build-tools/api/application/AbilityContext.d.ts b/build-tools/api/application/AbilityContext.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3eddb201b4624171a2b66c77b8840409efcf2eb3 --- /dev/null +++ b/build-tools/api/application/AbilityContext.d.ts @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityInfo } from "../bundle/abilityInfo"; +import { AbilityResult } from "../ability/abilityResult"; +import { AsyncCallback } from "../basic"; +import { HapModuleInfo } from "../bundle/hapModuleInfo"; +import Context from "./Context"; +import Want from "../@ohos.application.Want"; +import StartOptions from "../@ohos.application.StartOptions"; +import PermissionRequestResult from "./PermissionRequestResult"; +import { Configuration } from '../@ohos.application.Configuration'; +import Caller from '../@ohos.application.Ability'; +/** + * The context of an ability. It allows access to ability-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @StageModelOnly + */ +export default class AbilityContext extends Context { + /** + * Indicates configuration information about an ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + abilityInfo: AbilityInfo; + /** + * Indicates configuration information about an module. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + currentHapModuleInfo: HapModuleInfo; + /** + * Indicates configuration information. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + config: Configuration; + /** + * Starts a new ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want Indicates the ability to start. + * @param options Indicates the start options. + * @return - + * @StageModelOnly + */ + startAbility(want: Want, callback: AsyncCallback): void; + startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; + startAbility(want: Want, options?: StartOptions): Promise; + /** + * Get the caller object of the startup capability + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want Indicates the ability to start. + * @return Returns to the Caller interface on success Returns empty or undefined on failure + * @StageModelOnly + */ + startAbilityByCall(want: Want): Promise; + /** + * Starts an ability and returns the execution result when the ability is destroyed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want Indicates the ability to start. + * @param options Indicates the start options. + * @return Returns the {@link AbilityResult}. + * @StageModelOnly + */ + startAbilityForResult(want: Want, callback: AsyncCallback): void; + startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback): void; + startAbilityForResult(want: Want, options?: StartOptions): Promise; + /** + * Destroys this Page ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return - + * @StageModelOnly + */ + terminateSelf(callback: AsyncCallback): void; + terminateSelf(): Promise; + /** + * Sets the result code and data to be returned by this Page ability to the caller + * and destroys this Page ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param parameter Indicates the result to return. + * @return - + * @StageModelOnly + */ + terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback): void; + terminateSelfWithResult(parameter: AbilityResult): Promise; + /** + * Set mission label of current ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param label The label of ability that showed in recent missions. + * @StageModelOnly + */ + setMissionLabel(label: string, callback: AsyncCallback): void; + setMissionLabel(label: string): Promise; + /** + * Requests certain permissions from the system. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null or empty. + * @return Returns the {@link PermissionRequestResult}. + * @StageModelOnly + */ + requestPermissionsFromUser(permissions: Array, requestCallback: AsyncCallback): void; + requestPermissionsFromUser(permissions: Array): Promise; + /** + * Restore window stage data in ability continuation + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param LocalStorage the storage data used to restore window stage + * @StageModelOnly + */ + restoreWindowStage(localStorage: LocalStorage): void; + /** + * check to see ability is in terminating state. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return Returns true when ability is in terminating state, else returns false. + * @StageModelOnly + */ + isTerminating(): boolean; +} diff --git a/build-tools/api/application/AbilityStageContext.d.ts b/build-tools/api/application/AbilityStageContext.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..637bc92bd0caafc24af6873922a4f3401965311b --- /dev/null +++ b/build-tools/api/application/AbilityStageContext.d.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { HapModuleInfo } from "../bundle/hapModuleInfo"; +import { Configuration } from '../@ohos.application.Configuration'; +import Context from "./Context"; +/** + * The context of an abilityStage. It allows access to abilityStage-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @StageModelOnly + */ +export default class AbilityStageContext extends Context { + /** + * Indicates configuration information about an module. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + currentHapModuleInfo: HapModuleInfo; + /** + * Indicates configuration information. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + config: Configuration; +} diff --git a/build-tools/api/application/AccessibilityExtensionContext.d.ts b/build-tools/api/application/AccessibilityExtensionContext.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fbe1f5bb4f314f9835270d214ea2da926f52adeb --- /dev/null +++ b/build-tools/api/application/AccessibilityExtensionContext.d.ts @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Callback, AsyncCallback } from "../basic"; +import ExtensionContext from "./ExtensionContext"; +import accessibility from "../@ohos.accessibility"; +import { GesturePath } from "../@ohos.application.AccessibilityExtensionAbility"; +/** + * The accessibility extension context. Used to configure, query information, and inject gestures. + * + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +export default class AccessibilityExtensionContext extends ExtensionContext { + /** + * Set the accessibility event type which is wanted. + * @param type Indicates the type of event. + */ + setEventTypeFilter(type: Array): Promise; + setEventTypeFilter(type: Array, callback: AsyncCallback): boolean; + /** + * Set the name of the bundle name that is interested in sending the event. + * @param targetNames + */ + setTargetBundleName(targetNames: Array): Promise; + setTargetBundleName(targetNames: Array, callback: AsyncCallback): boolean; + /** + * Get focus element. + * @param isAccessibilityFocus Indicates whether the acquired element has an accessibility focus. + */ + getFocusElement(isAccessibilityFocus?: boolean): Promise; + getFocusElement(callback: AsyncCallback): void; + getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback): void; + /** + * Get window root element. + * @param windowId Indicates the window ID. + */ + getWindowRootElement(windowId?: number): Promise; + getWindowRootElement(callback: AsyncCallback): void; + getWindowRootElement(windowId: number, callback: AsyncCallback): void; + /** + * Get window list. + * @param displayId Indicates the display ID. + */ + getWindows(displayId?: number): Promise>; + getWindows(callback: AsyncCallback>): void; + getWindows(displayId: number, callback: AsyncCallback>): void; + /** + * Inject gesture path events. + * @param gesturePath Indicates the gesture path. + * @param listener It is used to receive the result of gesture injection, + * true means success, otherwise means failure. + */ + gestureInject(gesturePath: GesturePath, listener: Callback): Promise; + gestureInject(gesturePath: GesturePath, listener: Callback, callback: AsyncCallback): void; +} +/** + * Indicates an accessibility element. + * + * Supports querying element attributes, requesting execution actions, and finding child elements by condition. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +declare interface AccessibilityElement { + /** + * Get a list of attribute names. + */ + attributeNames(): Promise>; + attributeNames(callback: AsyncCallback>): void; + /** + * Get the value of an attribute. + * @param attributeName Indicates the attribute name. + */ + attributeValue(attributeName: T): Promise; + attributeValue(attributeName: T, callback: AsyncCallback): void; + /** + * Get a list of supported actions. + */ + actionNames(): Promise>; + actionNames(callback: AsyncCallback>): void; + /** + * Perform the specified action. + * @param actionName Indicates the action name. + * @param parameters Indicates the parameters needed to execute the action. + */ + performAction(actionName: string, parameters?: object): Promise; + performAction(actionName: string, callback: AsyncCallback): void; + performAction(actionName: string, parameters: object, callback: AsyncCallback): void; + /** + * Find elements that match the condition. + * @param type The type of query condition is content. + * @param condition Indicates the specific content to be queried. + */ + findElement(type: 'content', condition: string): Promise>; + findElement(type: 'content', condition: string, callback: AsyncCallback>): void; + /** + * Find elements that match the condition. + * @param type The type of query condition is focus type. + * @param condition Indicates the type of focus to query. + */ + findElement(type: 'focusType', condition: FocusType): Promise; + findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback): void; + /** + * Find elements that match the condition. + * @param type The type of query condition is focus direction. + * @param condition Indicates the direction of search focus to query. + */ + findElement(type: 'focusDirection', condition: FocusDirection): Promise; + findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback): void; +} +/** + * Indicates the possible attributes of the element and the type of the attribute value. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type ElementAttributeValues = { + /** + * Indicates the bundle name to which it belongs. + */ + 'bundleName': string; + /** + * Indicates whether the element is checkable. + */ + 'checkable': boolean; + /** + * Indicates whether the element is checked. + */ + 'checked': boolean; + /** + * Indicates all child elements. + */ + 'children': Array; + /** + * Indicates whether the element is clickable. + */ + 'clickable': boolean; + /** + * Indicates the component ID to which the element belongs. + */ + 'componentId': number; + /** + * Indicates the component type to which the element belongs. + */ + 'componentType': string; + /** + * Indicates the content. + */ + 'contents': Array; + /** + * Indicates the index of the current item. + */ + 'currentIndex': number; + /** + * Indicates the description of the element. + */ + 'description': string; + /** + * Indicates whether the element is editable. + */ + 'editable': boolean; + /** + * Indicates the list index of the last item displayed on the screen. + */ + 'endIndex': number; + /** + * Indicates whether the element is focusable. + */ + 'focusable': boolean; + /** + * Indicates the hint text. + */ + 'hintText': string; + /** + * Indicates the type of input text. + */ + 'inputType': number; + /** + * Indicates the inspector key. + */ + 'inspectorKey': string; + /** + * Indicates whether the element is active or not. + */ + 'isActive': boolean; + /** + * Indicates whether the element is enable or not. + */ + 'isEnable': boolean; + /** + * Indicates whether the element is focused or not. + */ + 'isFocused': boolean; + /** + * Indicates whether the element is password or not. + */ + 'isPassword': boolean; + /** + * Indicates whether the element is visible or not. + */ + 'isVisible': boolean; + /** + * Indicates the total count of the items. + */ + 'itemCount': number; + /** + * Indicates the last content. + */ + 'lastContent': string; + /** + * Indicates the display layer of the element. + */ + 'layer': number; + /** + * Indicates whether the element is long clickable. + */ + 'longClickable': boolean; + /** + * Indicates the parent of the element. + */ + 'parent': AccessibilityElement; + /** + * Indicates whether the element supports multiple lines of text. + */ + 'pluralLineSupported': boolean; + /** + * Indicates the area of the element. + */ + 'rect': Rect; + /** + * Indicates the resource name of the element. + */ + 'resourceName': string; + /** + * Indicates the root element of the window element. + */ + 'rootElement': AccessibilityElement; + /** + * Indicates the display area of the element. + */ + 'screenRect': Rect; + /** + * Indicates whether the element is scrollable. + */ + 'scrollable': boolean; + /** + * Indicates whether the element is selected. + */ + 'selected': boolean; + /** + * Indicates the list index of the first item displayed on the screen. + */ + 'startIndex': number; + /** + * Indicates the text of the element. + */ + 'text': string; + /** + * Indicates the maximum length limit of the element text. + */ + 'textLengthLimit': number; + /** + * Indicates the unit of movement of the element text as it is read. + */ + 'textMoveUnit': accessibility.TextMoveUnit; + /** + * Indicates the action that triggered the element event. + */ + 'triggerAction': accessibility.Action; + /** + * Indicates the window type of the element. + */ + 'type': WindowType; +}; +/** +* Indicates the direction of the search focus. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type FocusDirection = 'up' | 'down' | 'left' | 'right' | 'forward' | 'backward'; +/** + * Indicates the type of the focus. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type FocusType = 'accessibility' | 'normal'; +/** + * Indicates the type of the window. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +type WindowType = 'application' | 'system'; +/** + * Indicates rectangle. + * @since 9 + * @syscap SystemCapability.BarrierFree.Accessibility.Core + */ +interface Rect { + left: number; + top: number; + width: number; + height: number; +} diff --git a/build-tools/api/application/ApplicationContext.d.ts b/build-tools/api/application/ApplicationContext.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0e3e058e689966681961945046b9f4ab77af97f --- /dev/null +++ b/build-tools/api/application/ApplicationContext.d.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from "../basic"; +import Context from "./Context"; +import AbilityLifecycleCallback from "../@ohos.application.AbilityLifecycleCallback"; +import EnvironmentCallback from "../@ohos.application.EnvironmentCallback"; +/** + * The context of an application. It allows access to application-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @StageModelOnly + */ +export default class ApplicationContext extends Context { + /** + * Register ability lifecycle callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param callback The ability lifecycle callback. + * @return Returns the number code of the callback. + * @StageModelOnly + */ + registerAbilityLifecycleCallback(callback: AbilityLifecycleCallback): number; + /** + * Unregister ability lifecycle callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param callbackId Indicates the number code of the callback. + * @return - + * @StageModelOnly + */ + unregisterAbilityLifecycleCallback(callbackId: number, callback: AsyncCallback): void; + unregisterAbilityLifecycleCallback(callbackId: number): Promise; + /** + * Register environment callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param callback The environment callback. + * @return Returns the number code of the callback. + * @StageModelOnly + */ + registerEnvironmentCallback(callback: EnvironmentCallback): number; + /** + * Unregister environment callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param callbackId Indicates the number code of the callback. + * @return - + * @StageModelOnly + */ + unregisterEnvironmentCallback(callbackId: number, callback: AsyncCallback): void; + unregisterEnvironmentCallback(callbackId: number): Promise; +} diff --git a/build-tools/api/application/BaseContext.d.ts b/build-tools/api/application/BaseContext.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b27b8dd9de0ef753a0e54cf2d8ec39e3eaa4383c --- /dev/null +++ b/build-tools/api/application/BaseContext.d.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The base context of 'app.Context' for FA Mode or + * 'application.Context' for Stage Mode. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + */ +export default abstract class BaseContext { + /** + * Indicates the context is FA Mode or Stage Mode. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + stageMode: boolean; +} diff --git a/build-tools/api/application/Context.d.ts b/build-tools/api/application/Context.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c68818689c933353d061569a954c84b26508524d --- /dev/null +++ b/build-tools/api/application/Context.d.ts @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ApplicationInfo } from "../bundle/applicationInfo"; +import resmgr from "../@ohos.resourceManager"; +import BaseContext from "./BaseContext"; +import EventHub from "./EventHub"; +import ApplicationContext from "./ApplicationContext"; +/** + * The base context of an ability or an application. It allows access to + * application-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @StageModelOnly + */ +export default class Context extends BaseContext { + /** + * Indicates the capability of accessing application resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + resourceManager: resmgr.ResourceManager; + /** + * Indicates configuration information about an application. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + applicationInfo: ApplicationInfo; + /** + * Indicates app cache dir. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + cacheDir: string; + /** + * Indicates app temp dir. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + tempDir: string; + /** + * Indicates app files dir. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + filesDir: string; + /** + * Indicates app database dir. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + databaseDir: string; + /** + * Indicates app preferences dir. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + preferencesDir: string; + /** + * Indicates app bundle code dir. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + bundleCodeDir: string; + /** + * Indicates app distributed files dir. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + distributedFilesDir: string; + /** + * Indicates event hub. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + eventHub: EventHub; + /** + * Indicates file area. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + area: AreaMode; + /** + * Create a module context + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param moduleName Indicates the module name. + * @return application context + * @StageModelOnly + */ + createModuleContext(moduleName: string): Context; + /** + * Get application context + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return application context + * @StageModelOnly + */ + getApplicationContext(): ApplicationContext; +} +/** + * File area mode + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ +export enum AreaMode { + /** + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + EL1 = 0, + /** + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + EL2 = 1 +} diff --git a/build-tools/api/application/ErrorObserver.d.ts b/build-tools/api/application/ErrorObserver.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2e6afe4e2f9c34d0b4015063d2ca1fe36630c5ab --- /dev/null +++ b/build-tools/api/application/ErrorObserver.d.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The observer will be called by system when an error occurs. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + */ +export default class ErrorObserver { + /** + * Will be called when the js runtime throws an exception which doesn't caught by user. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param errMsg the message and error stacktrace about the exception. + * @return - + */ + onUnhandledException(errMsg: string): void; +} diff --git a/build-tools/api/application/EventHub.d.ts b/build-tools/api/application/EventHub.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4b0b34c13b0202e2ecd554a28a5b8125fede8785 --- /dev/null +++ b/build-tools/api/application/EventHub.d.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The event center of a context, support the subscription and publication of events. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @StageModelOnly + */ +export default class EventHub { + /** + * Subscribe to an event. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param event Indicates the event. + * @param callback Indicates the callback. + * @return - + * @StageModelOnly + */ + on(event: string, callback: Function): void; + /** + * Unsubscribe from an event. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param event Indicates the event. + * @param callback Indicates the callback. + * @return - + * @StageModelOnly + */ + off(event: string, callback?: Function): void; + /** + * Trigger the event callbacks. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param event Indicates the event. + * @param args Indicates the callback arguments. + * @return - + * @StageModelOnly + */ + emit(event: string, ...args: Object[]): void; +} diff --git a/build-tools/api/application/ExtensionContext.d.ts b/build-tools/api/application/ExtensionContext.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f6daa0c9f21ae37aa08cef4a5664c277cbdd3771 --- /dev/null +++ b/build-tools/api/application/ExtensionContext.d.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { HapModuleInfo } from "../bundle/hapModuleInfo"; +import { Configuration } from '../@ohos.application.Configuration'; +import Context from "./Context"; +import { ExtensionAbilityInfo } from "../bundle/extensionAbilityInfo"; +/** + * The context of an extension. It allows access to extension-specific resources. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @StageModelOnly + */ +export default class ExtensionContext extends Context { + /** + * Indicates configuration information about an module. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + currentHapModuleInfo: HapModuleInfo; + /** + * Indicates configuration information. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + config: Configuration; + /** + * Extension information. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + extensionAbilityInfo: ExtensionAbilityInfo; +} diff --git a/build-tools/api/application/PermissionRequestResult.d.ts b/build-tools/api/application/PermissionRequestResult.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fcf5a911ae114e5950ea9a6ffeeeb2d1e752f49f --- /dev/null +++ b/build-tools/api/application/PermissionRequestResult.d.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The result of requestPermissionsFromUser with asynchronous callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + * @StageModelOnly + */ +export default class PermissionRequestResult { + /** + * The permissions passed in by the user. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + permissions: Array; + /** + * The results for the corresponding request permissions. The value 0 indicates that a + * permission is granted, and the value -1 indicates not. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + authResults: Array; +} diff --git a/build-tools/api/application/ProcessRunningInfo.d.ts b/build-tools/api/application/ProcessRunningInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ceb1db6562382b0bf98e7635ef24baa8483a1f7 --- /dev/null +++ b/build-tools/api/application/ProcessRunningInfo.d.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The class of an process running information. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @permission N/A + * @deprecated since 9 + * @useinstead ProcessRunningInformation + */ +export interface ProcessRunningInfo { + /** + * @default process id + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @deprecated since 9 + * @useinstead ProcessRunningInformation.pid + */ + pid: number; + /** + * @default user id + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @deprecated since 9 + * @useinstead ProcessRunningInformation.uid + */ + uid: number; + /** + * @default the name of the process + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @deprecated since 9 + * @useinstead ProcessRunningInformation.processName + */ + processName: string; + /** + * @default an array of the bundleNames running in the process + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @deprecated since 9 + * @useinstead ProcessRunningInformation.bundleNames + */ + bundleNames: Array; +} diff --git a/build-tools/api/application/ProcessRunningInformation.d.ts b/build-tools/api/application/ProcessRunningInformation.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6d054c40fa289992ca55ce94262faad847ed3ba --- /dev/null +++ b/build-tools/api/application/ProcessRunningInformation.d.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * The class of an process running information. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ +export interface ProcessRunningInformation { + /** + * @default process id + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + pid: number; + /** + * @default user id + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + uid: number; + /** + * @default the name of the process + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + processName: string; + /** + * @default an array of the bundleNames running in the process + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + bundleNames: Array; +} diff --git a/build-tools/api/application/abilityDelegator.d.ts b/build-tools/api/application/abilityDelegator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5aca17b95bfbaf849b28e59725c1d592cbd11b44 --- /dev/null +++ b/build-tools/api/application/abilityDelegator.d.ts @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from '../basic'; +import Ability from '../@ohos.application.Ability'; +import { AbilityMonitor } from './abilityMonitor'; +import { Context } from './Context'; +import Want from "../@ohos.application.Want"; +import { ShellCmdResult } from './shellCmdResult'; +/** + * A global test utility interface used for adding AbilityMonitor objects and control lifecycle states of abilities. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import AbilityDelegator from 'application/abilityDelegator.d' + * @permission N/A + */ +export interface AbilityDelegator { + /** + * Add an AbilityMonitor object for monitoring the lifecycle state changes of the specified ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param monitor AbilityMonitor object + */ + addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; + addAbilityMonitor(monitor: AbilityMonitor): Promise; + /** + * Remove a specified AbilityMonitor object from the application memory. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param monitor AbilityMonitor object + */ + removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; + removeAbilityMonitor(monitor: AbilityMonitor): Promise; + /** + * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param monitor AbilityMonitor object + * @param timeout Maximum wait time, in milliseconds + * @return success: return the Ability object, failure: return null + */ + waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; + waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback): void; + waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise; + /** + * Obtain the application context. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return App Context + */ + getAppContext(): Context; + /** + * Obtain the lifecycle state of a specified ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param ability The Ability object + * @return The state of the Ability object. enum AbilityLifecycleState + */ + getAbilityState(ability: Ability): number; + /** + * Obtain the ability that is currently being displayed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return The top ability of the current application + */ + getCurrentTopAbility(callback: AsyncCallback): void; + getCurrentTopAbility(): Promise; + /** + * Start a new ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want Indicates the ability to start + * @return - + */ + startAbility(want: Want, callback: AsyncCallback): void; + startAbility(want: Want): Promise; + /** + * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param ability The ability object + * @return true: success false: failure + */ + doAbilityForeground(ability: Ability, callback: AsyncCallback): void; + doAbilityForeground(ability: Ability): Promise; + /** + * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param ability The ability object + * @return true: success false: failure + */ + doAbilityBackground(ability: Ability, callback: AsyncCallback): void; + doAbilityBackground(ability: Ability): Promise; + /** + * Prints log information to the unit testing console. + * The total length of the log information to be printed cannot exceed 1000 characters. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param msg Log information + */ + print(msg: string, callback: AsyncCallback): void; + print(msg: string): Promise; + /** + * Prints log information to the unit testing console. + * The total length of the log information to be printed cannot exceed 1000 characters. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param msg Log information + */ + printSync(msg: string): void; + /** + * Execute the given command in the aa tools side. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param cmd Shell command + * @param timeoutSecs Timeout, in seconds + * @return ShellCmdResult object + */ + executeShellCommand(cmd: string, callback: AsyncCallback): void; + executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback): void; + executeShellCommand(cmd: string, timeoutSecs?: number): Promise; + /** + * Finish the test and print log information to the unit testing console. + * The total length of the log information to be printed cannot exceed 1000 characters. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param msg Log information + * @param code Result code + */ + finishTest(msg: string, code: number, callback: AsyncCallback): void; + finishTest(msg: string, code: number): Promise; +} +export default AbilityDelegator; diff --git a/build-tools/api/application/abilityDelegatorArgs.d.ts b/build-tools/api/application/abilityDelegatorArgs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..741c8f7d59beeba3a399d2adc0c2ed42bd783434 --- /dev/null +++ b/build-tools/api/application/abilityDelegatorArgs.d.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Store unit testing-related parameters, including test case names, and test runner name. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import AbilityDelegatorArgs from 'application/abilityDelegatorArgs.d' + * @permission N/A + */ +export interface AbilityDelegatorArgs { + /** + * the bundle name of the application being tested. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + bundleName: string; + /** + * the parameters used for unit testing. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + parameters: { + [key: string]: string; + }; + /** + * the class names of all test cases. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + testCaseNames: string; + /** + * the class name of the test runner used to execute test cases. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + testRunnerClassName: string; +} +export default AbilityDelegatorArgs; diff --git a/build-tools/api/application/abilityMonitor.d.ts b/build-tools/api/application/abilityMonitor.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4adcf45dab8649eb0950bfbf2139b368824e750b --- /dev/null +++ b/build-tools/api/application/abilityMonitor.d.ts @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '../@ohos.application.Ability'; +/** + * Provide methods for matching monitored Ability objects that meet specified conditions. + * The most recently matched Ability objects will be saved in the AbilityMonitor object. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import AbilityMonitor from 'application/abilityMonitor.d' + * @permission N/A + */ +export interface AbilityMonitor { + /** + * The name of the ability to monitor. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + abilityName: string; + /** + * Called back when the ability is started for initialization. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + onAbilityCreate?: (data: Ability) => void; + /** + * Called back when the state of the ability changes to foreground. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + onAbilityForeground?: (data: Ability) => void; + /** + * Called back when the state of the ability changes to background. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + onAbilityBackground?: (data: Ability) => void; + /** + * Called back before the ability is destroyed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + onAbilityDestroy?: (data: Ability) => void; + /** + * Called back when an ability window stage is created. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + onWindowStageCreate?: (data: Ability) => void; + /** + * Called back when an ability window stage is restored. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + onWindowStageRestore?: (data: Ability) => void; + /** + * Called back when an ability window stage is destroyed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + onWindowStageDestroy?: (data: Ability) => void; +} +export default AbilityMonitor; diff --git a/build-tools/api/application/shellCmdResult.d.ts b/build-tools/api/application/shellCmdResult.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..56b2ada698e611d45eac02dbf2003843907c6343 --- /dev/null +++ b/build-tools/api/application/shellCmdResult.d.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * A object that records the result of shell command executes. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @import import ShellCmdResult from 'application/shellCmdResult.d' + * @permission N/A + */ +export interface ShellCmdResult { + /** + * the cmd standard result. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + stdResult: string; + /** + * shell cmd exec result. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + exitCode: number; +} +export default ShellCmdResult; diff --git a/build-tools/api/basic.d.ts b/build-tools/api/basic.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..93f298ae58bbd484e54ed09ba7f91e8b10d183d8 --- /dev/null +++ b/build-tools/api/basic.d.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Defines the basic callback. + * @since 6 + */ +export interface Callback { + /** + * Defines the callback info. + * @since 6 + */ + (data: T): void; +} +/** + * Defines the basic error callback. + * @since 6 + */ +export interface ErrorCallback { + /** + * Defines the basic error callback. + * @since 6 + */ + (err: T): void; +} +/** + * Defines the basic async callback. + * @since 6 + */ +export interface AsyncCallback { + /** + * Defines the callback data. + * @since 6 + */ + (err: BusinessError, data: T): void; +} +/** + * Defines the error interface. + * @since 6 + */ +export interface BusinessError extends Error { + /** + * Defines the basic error code. + * @since 6 + */ + code: number; +} diff --git a/build-tools/api/bundle/abilityInfo.d.ts b/build-tools/api/bundle/abilityInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..71bf1c2e316142181e1a9b03d0673a01f81dd6e8 --- /dev/null +++ b/build-tools/api/bundle/abilityInfo.d.ts @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ApplicationInfo } from './applicationInfo'; +import { CustomizeData } from './customizeData'; +import { Metadata } from './metadata'; +import bundle from './../@ohos.bundle'; +/** + * @name Obtains configuration information about an ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + */ +export interface AbilityInfo { + /** + * @default Indicates the name of the bundle containing the ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly bundleName: string; + /** + * @default Ability simplified class name + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly name: string; + /** + * @default Indicates the label of the ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly label: string; + /** + * @default Describes the ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly description: string; + /** + * @default Indicates the icon of the ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly icon: string; + /** + * @default Indicates the label id of the ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly labelId: number; + /** + * @default Indicates the description id of the ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly descriptionId: number; + /** + * @default Indicates the icon id of the ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly iconId: number; + /** + * @default Indicates the name of the .hap package to which the capability belongs + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly moduleName: string; + /** + * @default Process of ability, if user do not set it ,the value equal application process + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly process: string; + /** + * @default Info about which ability is this nick point to + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @FAModelOnly + */ + readonly targetAbility: string; + /** + * @default Indicates the background service addressing a specific usage scenario + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @FAModelOnly + */ + readonly backgroundModes: number; + /** + * @default Indicates whether an ability can be called by other abilities + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly isVisible: boolean; + /** + * @default Indicates whether the ability provides the embedded card capability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @FAModelOnly + */ + readonly formEnabled: boolean; + /** + * @default Enumerates types of templates that can be used by an ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @FAModelOnly + */ + readonly type: bundle.AbilityType; + /** + * @default Enumerates the subType of templates used by an ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @FAModelOnly + */ + readonly subType: bundle.AbilitySubType; + /** + * @default Enumerates ability display orientations + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly orientation: bundle.DisplayOrientation; + /** + * @default Enumerates ability launch modes + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly launchMode: bundle.LaunchMode; + /** + * @default The permissions that others need to launch this ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly permissions: Array; + /** + * @default The device types that this ability can run on + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly deviceTypes: Array; + /** + * @default The device capability that this ability needs + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly deviceCapabilities: Array; + /** + * @default Indicates the permission required for reading ability data + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @FAModelOnly + */ + readonly readPermission: string; + /** + * @default Indicates the permission required for writing data to the ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @FAModelOnly + */ + readonly writePermission: string; + /** + * @default Obtains configuration information about an application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly applicationInfo: ApplicationInfo; + /** + * @default Uri of ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @FAModelOnly + */ + readonly uri: string; + /** + * @default Indicates the metadata of ability + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly metaData: Array; + /** + * @default Indicates the metadata of ability + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * + */ + readonly metadata: Array; + /** + * @default Indicates whether the ability is enabled + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly enabled: boolean; + /** + * @default Indicates which window mode is supported + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly supportWindowMode: Array; + /** + * @default Indicates maximum ratio of width over height of window under free window status. + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly maxWindowRatio: number; + /** + * @default Indicates minimum ratio of width over height of window under free window status. + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly minWindowRatio: number; + /** + * @default Indicates maximum width of window under free window status. + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly maxWindowWidth: number; + /** + * @default Indicates minimum width of window under free window status. + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly minWindowWidth: number; + /** + * @default Indicates maximum height of window under free window status. + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly maxWindowHeight: number; + /** + * @default Indicates minimum height of window under free window status. + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly minWindowHeight: number; +} diff --git a/build-tools/api/bundle/applicationInfo.d.ts b/build-tools/api/bundle/applicationInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d07287a9227933c002731a7017b5fe1a22f22217 --- /dev/null +++ b/build-tools/api/bundle/applicationInfo.d.ts @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ModuleInfo } from './moduleInfo'; +import { CustomizeData } from './customizeData'; +import { Metadata } from './metadata'; +import { Resource } from './../global/resource'; +/** + * @name Obtains configuration information about an application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + * + */ +export interface ApplicationInfo { + /** + * @default Indicates the application name, which is the same as {@code bundleName} + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly name: string; + /** + * @default Description of application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly description: string; + /** + * @default Indicates the description id of the application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly descriptionId: number; + /** + * @default Indicates whether the application is a system application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly systemApp: boolean; + /** + * @default Indicates whether or not this application may be instantiated + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly enabled: boolean; + /** + * @default Indicates the label of the application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly label: string; + /** + * @default Indicates the label id of the application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly labelId: string; + /** + * @default Indicates the icon of the application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly icon: string; + /** + * @default Indicates the icon id of the application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly iconId: string; + /** + * @default Process of application, if user do not set it ,the value equal bundleName + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly process: string; + /** + * @default Indicates the running mode supported by the application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly supportedModes: number; + /** + * @default Indicates the path storing the module resources of the application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly moduleSourceDirs: Array; + /** + * @default Indicates the permissions required for accessing the application. + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly permissions: Array; + /** + * @default Indicates module information about an application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly moduleInfos: Array; + /** + * @default Indicates the path where the {@code Entry.hap} file of the application is saved + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly entryDir: string; + /** + * @default Indicates the application source code path + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly codePath: string; + /** + * @default Indicates the metadata of module + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly metaData: Map>; + /** + * @default Indicates the metadata of module + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly metadata: Map>; + /** + * @default Indicates whether or not this application may be removable + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly removable: boolean; + /** + * @default Indicates the access token of the application + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly accessTokenId: number; + /** + * @default Indicates the uid of the application + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly uid: number; + /** + * @default Indicates entity type of the application + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly entityType: string; + /** + * @default Indicates fingerprint of the certificate + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly fingerprint: string; + /** + * @default Indicates icon resource of the application + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly iconResource: Resource; + /** + * @default Indicates label resource of the application + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly labelResource: Resource; + /** + * @default Indicates description resource of the application + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly descriptionResource: Resource; + /** + * @default Indicates the appDistributionType of the application + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly appDistributionType: string; + /** + * @default Indicates the appProvisionType of the application + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly appProvisionType: string; +} diff --git a/build-tools/api/bundle/bundleInfo.d.ts b/build-tools/api/bundle/bundleInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5518020eee735e1eecb1ed7f9e1e37d7790c9258 --- /dev/null +++ b/build-tools/api/bundle/bundleInfo.d.ts @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityInfo } from './abilityInfo'; +import { ApplicationInfo } from './applicationInfo'; +import { ExtensionAbilityInfo } from './extensionAbilityInfo'; +import { HapModuleInfo } from './hapModuleInfo'; +/** + * @name The scene which is used + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + * + */ +export interface UsedScene { + /** + * @default Indicates the abilities that need the permission + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + abilities: Array; + /** + * @default Indicates the time when the permission is used + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + when: string; +} +/** + * @name Indicates the required permissions details defined in file config.json + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + * + */ +export interface ReqPermissionDetail { + /** + * @default Indicates the name of this required permissions + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + name: string; + /** + * @default Indicates the reason of this required permissions + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + reason: string; + /** + * @default Indicates the reason id of this required permissions + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + reasonId: number; + /** + * @default Indicates the used scene of this required permissions + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + usedScene: UsedScene; +} +/** + * @name Obtains configuration information about a bundle + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + * + */ +export interface BundleInfo { + /** + * @default Indicates the name of this bundle + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly name: string; + /** + * @default Indicates the name of this original bundle + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly type: string; + /** + * @default Indicates the ID of the application to which this bundle belongs + * The application ID uniquely identifies an application. It is determined by the bundle name and signature + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly appId: string; + /** + * @default Indicates the UID of the application to which this bundle belongs + * The UID uniquely identifies an application. It is determined by the process and user IDs of the application + * After an application is installed, its UID remains unchanged unless it is uninstalled and then reinstalled + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly uid: number; + /** + * @default Indicates the hap install time + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly installTime: number; + /** + * @default Indicates the hap update time + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly updateTime: number; + /** + * @default Obtains configuration information about an application + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly appInfo: ApplicationInfo; + /** + * @default Obtains configuration information about an ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly abilityInfos: Array; + /** + * @default Indicates the required permissions name defined in file config.json + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly reqPermissions: Array; + /** + * @default Indicates the required permissions details defined in file config.json + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly reqPermissionDetails: Array; + /** + * @default Describes the bundle vendor + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly vendor: string; + /** + * @default Indicates the version number of the bundle + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly versionCode: number; + /** + * @default Indicates the text description of the bundle version + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly versionName: string; + /** + * @default Indicates the compatible version number of the bundle + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly compatibleVersion: number; + /** + * @default Indicates the target version number of the bundle + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly targetVersion: number; + /** + * @default Indicates is compress native libs + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly isCompressNativeLibs: boolean; + /** + * @default Obtains configuration information about an module + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly hapModuleInfos: Array; + /** + * @default Indicates entry module name + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly entryModuleName: string; + /** + * @default Indicates the cpuAbi information of this bundle. + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly cpuAbi: string; + /** + * @default Indicates is silent installation + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly isSilentInstallation: string; + /** + * @default Indicates the earliest historical version compatible with the bundle + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly minCompatibleVersionCode: number; + /** + * @default Indicates whether free installation of the entry is supported + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly entryInstallationFree: boolean; + /** + * @default Indicates the grant status of required permissions + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly reqPermissionStates: Array; + /** + * @default Obtains configuration information about an ability + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly extensionAbilityInfo: Array; +} diff --git a/build-tools/api/bundle/customizeData.d.ts b/build-tools/api/bundle/customizeData.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..01406fad30e49fff3cefa14a26ef075932c2c883 --- /dev/null +++ b/build-tools/api/bundle/customizeData.d.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** +* @name Indicates the custom metadata +* @since 7 +* @syscap SystemCapability.BundleManager.BundleFramework +* @permission NA +* +*/ +export interface CustomizeData { + /** + * @default Indicates the custom metadata name + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + name: string; + /** + * @default Indicates the custom metadata value + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + value: string; + /** + * @default Indicates the custom metadata resource + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + extra: string; +} diff --git a/build-tools/api/bundle/elementName.d.ts b/build-tools/api/bundle/elementName.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1da093d69a0fbb84dd2fe32f09882e841a1601b9 --- /dev/null +++ b/build-tools/api/bundle/elementName.d.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Contains basic Ability information, which uniquely identifies an ability. + * You can use this class to obtain values of the fields set in an element, + * such as the device ID, bundle name, and ability name. + * @name Contains basic Ability information, which uniquely identifies an ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * + * @permission N/A + */ +export interface ElementName { + /** + * device id + * @default - + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + deviceId?: string; + /** + * bundle name + * @default - + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + bundleName: string; + /** + * ability name + * @default ability class name. + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + abilityName: string; + /** + * uri + * @default - + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + uri?: string; + /** + * shortName + * @default - + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + shortName?: string; + /** + * module name + * @default - + * + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + moduleName?: string; +} diff --git a/build-tools/api/bundle/extensionAbilityInfo.d.ts b/build-tools/api/bundle/extensionAbilityInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3bc4f67a9822fc681f5535ae409b7bacd65ca10a --- /dev/null +++ b/build-tools/api/bundle/extensionAbilityInfo.d.ts @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ApplicationInfo } from './applicationInfo'; +import { Metadata } from './metadata'; +import bundle from './../@ohos.bundle'; +/** + * @name Obtains extension information about a bundle + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + * + */ +export interface ExtensionAbilityInfo { + /** + * @default Indicates the name of the bundle + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly bundleName: string; + /** + * @default Indicates the name of the module + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly moduleName: string; + /** + * @default Indicates the name of the extension info + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly name: string; + /** + * @default Indicates the label id of the entension info + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly labelId: number; + /** + * @default Indicates the description id of the entension info + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly descriptionId: number; + /** + * @default Indicates the icon id of the entension info + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly iconId: number; + /** + * @default Indicates whether the entensionInfo can be visible or not + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly isVisible: boolean; + /** + * @default Enumerates types of the entension info + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly extensionAbilityType: bundle.ExtensionAbilityType; + /** + * @default The permissions that others need to use this extension info + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly permissions: Array; + /** + * @default Obtains configuration information about an application + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly applicationInfo: ApplicationInfo; + /** + * @default Indicates the metadata of bundle + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly metadata: Array; + /** + * @default Indicates the src language to express extension info + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly enabled: boolean; + /** + * @default Indicates the read permission extension ability info + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly readPermission: string; + /** + * @default Indicates the write permission of extension ability info + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly writePermission: string; +} diff --git a/build-tools/api/bundle/hapModuleInfo.d.ts b/build-tools/api/bundle/hapModuleInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2fd42caec024bd2a02804a0f58113a485d956e4d --- /dev/null +++ b/build-tools/api/bundle/hapModuleInfo.d.ts @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityInfo } from "./abilityInfo"; +import { ExtensionAbilityInfo } from "./extensionAbilityInfo"; +import { Metadata } from './metadata'; +/** + * @name Obtains configuration information about an module. + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + * + */ +export interface HapModuleInfo { + /** + * @default Indicates the name of this hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly name: string; + /** + * @default Describes the hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly description: string; + /** + * @default Indicates the description of this hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly descriptionId: number; + /** + * @default Indicates the icon of this hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly icon: string; + /** + * @default Indicates the label of this hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly label: string; + /** + * @default Indicates the label id of this hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly labelId: number; + /** + * @default Indicates the icon id of this hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly iconId: number; + /** + * @default Indicates the background img of this hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly backgroundImg: string; + /** + * @default Indicates the supported modes of this hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly supportedModes: number; + /** + * @default Indicates the req capabilities of this hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly reqCapabilities: Array; + /** + * @default The device types that this hapmodule can run on + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly deviceTypes: Array; + /** + * @default Obtains configuration information about ability + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly abilityInfo: Array; + /** + * @default Indicates the name of the .hap package to which the capability belongs + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly moduleName: string; + /** + * @default Indicates the main ability name of this hapmodule + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly mainAbilityName: string; + /** + * @default Indicates whether free installation of the hapmodule is supported + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly installationFree: boolean; + /** + * @default Indicates main elementName of the module + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly mainElementName: string; + /** + * @default Obtains configuration information about extension ability + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly extensionAbilityInfo: Array; + /** + * @default Indicates the metadata of ability + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * + */ + readonly metadata: Array; + /** + * @default Indicates the hash value of the module + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly hashValue: string; +} diff --git a/build-tools/api/bundle/metadata.d.ts b/build-tools/api/bundle/metadata.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f23781290a737d192f13cbc4b93e9118bc784b03 --- /dev/null +++ b/build-tools/api/bundle/metadata.d.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @name Indicates the Metadata + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + * + */ +export interface Metadata { + /** + * @default Indicates the metadata name + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + name: string; + /** + * @default Indicates the metadata value + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + value: string; + /** + * @default Indicates the metadata resource + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + resource: string; +} diff --git a/build-tools/api/bundle/moduleInfo.d.ts b/build-tools/api/bundle/moduleInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..51aa023584be278289a0cd714e057e7bfec3a92f --- /dev/null +++ b/build-tools/api/bundle/moduleInfo.d.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @name Stores module information about an application. + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + * + */ +export interface ModuleInfo { + /** + * The module name. + * + * @default Indicates the name of the .hap package to which the capability belongs + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly moduleName: string; + /** + * The module source path. + * + * @default Indicates the module source dir of this module + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly moduleSourceDir: string; +} diff --git a/build-tools/api/bundle/shortcutInfo.d.ts b/build-tools/api/bundle/shortcutInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c346fd0982273d5d1ffdeeacc61c7e5033f4f16 --- /dev/null +++ b/build-tools/api/bundle/shortcutInfo.d.ts @@ -0,0 +1,81 @@ +/** + * @name Provides information about a shortcut, including the shortcut ID and label. + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @permission NA + * + */ +export interface ShortcutInfo { + /** + * @default Indicates the ID of the application to which this shortcut belongs + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly id: string; + /** + * @default Indicates the name of the bundle containing the shortcut + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly bundleName: string; + /** + * @default Indicates the host ability of the shortcut + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly hostAbility: string; + /** + * @default Indicates the icon of the shortcut + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly icon: string; + /** + * @default Indicate s the icon id of the shortcut + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly iconId: number; + /** + * @default Indicates the label of the shortcut + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly label: string; + /** + * @default Indicates the label id of the shortcut + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly labelId: number; + /** + * @default Indicates the disableMessage of the shortcut + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly disableMessage: string; + /** + * @default Indicates whether the shortcut is static + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly isStatic?: boolean; + /** + * @default Indicates whether the shortcut is homeshortcut + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly isHomeShortcut?: boolean; + /** + * @default Indicates whether the shortcut is enabled + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly isEnabled?: boolean; + /** + * @default Indicates the moduleName of the shortcut + * @since 9 + * @syscap SystemCapability.BundleManager.BundleFramework + */ + readonly moduleName?: string; +} diff --git a/build-tools/api/common/full/console.d.ts b/build-tools/api/common/full/console.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9f0a0f3ed6f82c50389530431b891a72d66a1899 --- /dev/null +++ b/build-tools/api/common/full/console.d.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** +* @syscap SystemCapability.ArkUI.ArkUI.Full +* @since 3 +*/ +export declare class console { + /** + * Prints "debug" logs. + * @param message Text to print. + */ + static debug(message: string, ...arguments: any[]): void; + /** + * Prints "log" logs. + * @param message Text to print. + */ + static log(message: string, ...arguments: any[]): void; + /** + * Prints "info" logs. + * @param message Text to print. + */ + static info(message: string, ...arguments: any[]): void; + /** + * Prints "warn" logs. + * @param message Text to print. + */ + static warn(message: string, ...arguments: any[]): void; + /** + * Prints "error" logs. + * @param message Text to print. + */ + static error(message: string, ...arguments: any[]): void; +} diff --git a/build-tools/api/common/full/dom.d.ts b/build-tools/api/common/full/dom.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a2c40ffbf36f69b8eecf22d8d10f67d5bf5a3849 --- /dev/null +++ b/build-tools/api/common/full/dom.d.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { Element } from './viewmodel'; +/** + * global dom + * @since 8 + */ +export declare class dom { + /** + * create a dynamic dom by tag, rturn element + * @param tag dom tag + * @since 8 + */ + static createElement(tag: string): Element; +} diff --git a/build-tools/api/common/full/featureability.d.ts b/build-tools/api/common/full/featureability.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39e2325d6a21c817c19e8d31e1814ed1e504ad1f --- /dev/null +++ b/build-tools/api/common/full/featureability.d.ts @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @since 5 + * @deprecated since 8 + */ +export interface Result { + /** + * Result code. + * @since 5 + */ + code: number; + /** + * Returned data. + * @since 5 + */ + data: object; +} +/** + * @since 5 + * @deprecated since 8 + */ +export interface CallAbilityParam { + /** + * Name of the bundle where the ability locates. The name is case sensitive and must be the same as that on the AA side. + * @since 5 + */ + bundleName: string; + /** + * Ability name, which is case sensitive and must be the same as that on the AA side. + * @since 5 + */ + abilityName: string; + /** + * Ability operation code, which defines the service function of an AA and must be consistent with the AA side. + * @since 5 + */ + messageCode: number; + /** + * Ability type. Different types of abilities have different implementation on the AA side. + * 0: Ability, which has an independent lifecycle. The FA starts and requests an AA through an RPC. Such type of abilities are used to provide basic services for multiple FAs to call or are used when the abilities should run in the background. + * 1: Internal ability, which shares the same process with the FA and communicates with it by calling internal functions. Such type of abilities are used in scenarios that require low response latency and cannot be called by other FAs. + * @since 5 + */ + abilityType: number; + /** + * Data sent to the ability. The data to carry differs depending on the service to be processed and its field name must be consistent with the AA side. + * @since 5 + */ + data?: object; + /** + * Whether the request is synchronous or asynchronous. The synchronous mode is used by default. Currently, the asynchronous mode is available only for internal abilities. + * 0: Synchronous mode (default value) + * 1: Asynchronous mode + * @since 5 + */ + syncOption?: number; +} +/** + * @since 5 + * @deprecated since 8 + */ +export interface SubscribeAbilityEventParam { + /** + * Name of the bundle where the ability locates. The name is case sensitive and must be the same as that on the AA side. + * @since 5 + */ + bundleName: string; + /** + * Ability name, which is case sensitive and must be the same as that on the AA side. + * @since 5 + */ + abilityName: string; + /** + * Ability operation code, which defines the service function of an AA and must be consistent with the AA side. + * @since 5 + */ + messageCode: number; + /** + * Ability type. Different types of abilities have different implementation on the AA side. + * 0: Ability, which has an independent lifecycle. The FA starts and requests an AA through an RPC. Such type of abilities are used to provide basic services for multiple FAs to call or are used when the abilities should run in the background. + * 1: Internal ability, which shares the same process with the FA and communicates with it by calling internal functions. Such type of abilities are used in scenarios that require low response latency and cannot be called by other FAs. + * @since 5 + */ + abilityType: number; + /** + * Whether the request is synchronous or asynchronous. The synchronous mode is used by default. Currently, the asynchronous mode is available only for internal abilities. + * 0: Synchronous mode (default value) + * 1: Asynchronous mode + * @since 5 + */ + syncOption?: number; +} +/** + * @since 5 + * @deprecated since 8 + */ +export interface RequestParams { + /** + * The name of the bundle to start. It should be used with abilityname and case sensitive. + * @since 5 + */ + bundleName?: string; + /** + * Ability name, which is case sensitive. + * @since 5 + */ + abilityName?: string; + /** + * The list of entities to which the FA to be called. If it is not filled in, all entity lists will be found by default. It should be used with action. + * @since 5 + */ + entities?: Array; + /** + * Without specifying the bundle name and ability name, you can start the application according to other properties with action. + * @since 5 + */ + action?: string; + /** + * If more than one FA meets the conditions, the user can select the device from the popup. + * 0: Default. Select the FA to start from the local and remote devices. + * 1: start FA from the local device. + * @since 5 + */ + deviceType?: number; + /** + * Data sent to the ability which need to be serializable. + * @since 5 + */ + data?: object; + /** + * Configuration switch when start FA. + * @since 5 + */ + flag?: number; + /** + * Specify the url of the page which the FA to be called. Use home page directly by default. + * @since 5 + */ + url?: string; +} +/** + * @since 5 + * @deprecated since 8 + */ +export interface FinishWithResultParams { + /** + * Result code. + * @since 5 + */ + code: number; + /** + * Returned data. + * @since 5 + */ + result: object; +} +/** + * @since 5 + * @deprecated since 8 + */ +export declare class FeatureAbility { + /** + * Start a FA without callback result. + * @param request Indicates the request param. + * @returns A Promise object is returned, which contains the result of whether to call Ability's interface successfully. + * @since 5 + * @deprecated since 8 + */ + static startAbility(request: RequestParams): Promise; + /** + * Start a FA with callback result. + * @param request Indicates the request param. + * @returns A Promise object is returned, which contains the result of the data FA returned. + * @since 5 + * @deprecated since 8 + */ + static startAbilityForResult(request: RequestParams): Promise; + /** + * FA call the interface to destory itself and set the result as parameters. + * @param request Indicates the request param. + * @returns A Promise object is returned, which contains the result whether to callback successfully. + * @since 5 + * @deprecated since 8 + */ + static finishWithResult(param: FinishWithResultParams): Promise; + /** + + * Get device information list. + * @param flag Default 0, get the information list of all devices in the network. + * @returns A Promise object is returned, which contains the result whether the device information list is obtained successfully. + * @since 5 + * @deprecated since 8 + */ + static getDeviceList(flag: number): Promise; + /** + + * Calls an AA. + * @param param Indicates the request param. + * @returns A Promise object is returned, which contains the result data returned by the AA. The result is a JSON string. + * @since 5 + * @deprecated since 8 + */ + static callAbility(param: CallAbilityParam): Promise; + /** + * Start FA migration. + * @returns A Promise object is returned, which contains the result data returned by the AA. The result is a JSON string. + * @since 5 + * @deprecated since 8 + */ + static continueAbility(): Promise; + /** + * Subscribes to events of an AA. + * @param param Indicates the request param. + * @param func Indicates the event reporting callback. + * @returns A Promise object is returned, which contains the result data returned by the AA. The result is a JSON string. + * @since 5 + * @deprecated since 8 + */ + static subscribeAbilityEvent(param: SubscribeAbilityEventParam, func: Function): Promise; + /** + * Unsubscribes from events of an AA. + * @param param Indicates the request param. + * @returns A Promise object is returned, which contains the result data returned by the AA. The result is a JSON string. + * @since 5 + * @deprecated since 8 + */ + static unsubscribeAbilityEvent(param: SubscribeAbilityEventParam): Promise; +} diff --git a/build-tools/api/common/full/global.d.ts b/build-tools/api/common/full/global.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b1ae4c29df5e0c8a83ed529c276fef300532b122 --- /dev/null +++ b/build-tools/api/common/full/global.d.ts @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Sets the interval for repeatedly calling a function. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param handler Indicates the function to be called after the timer goes off. For devices of "tv", "phone, tablet", and "wearable" types, this parameter can be a function or string. For devices of "lite wearable" and "smartVision" types, this parameter must be a function. + * @param delay Indicates the interval between each two calls, in milliseconds. The function will be called after this delay. + * @param arguments Indicates additional arguments to pass to "handler" when the timer goes off. + * @returns Returns the timer ID. + * @since 3 + */ +export declare function setInterval(handler: Function | string, delay: number, ...arguments: any[]): number; +/** + * Sets a timer after which a function will be executed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param handler Indicates the function to be called after the timer goes off. For devices of "tv", "phone, tablet", and "wearable" types, this parameter can be a function or string. For devices of "lite wearable" and "smartVision" types, this parameter must be a function. + * @param delay Indicates the delay (in milliseconds) after which the function will be called. If this parameter is left empty, default value "0" will be used, which means that the function will be called immediately or as soon as possible. + * @param arguments Indicates additional arguments to pass to "handler" when the timer goes off. + * @returns Returns the timer ID. + * @since 3 + */ +export declare function setTimeout(handler: Function | string, delay?: number, ...arguments: any[]): number; +/** + * Sets a vsync after which a function will be executed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param handler Indicates the function to be called when the vsync trigger. + * @since 3 + */ +export declare function requestAnimationFrame(handler: Function): number; +/** + * Cancels the vsync callback set by "requestAnimationFrame()". + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param requestId Indicates the vsync callback ID returned by "requestAnimationFrame()". + * @since 3 + */ +export declare function cancelAnimationFrame(requestId: number): void; +/** + * Cancels the interval set by " setInterval()". + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param intervalID Indicates the timer ID returned by "setInterval()". + * @since 3 + */ +export declare function clearInterval(intervalID?: number): void; +/** + * Cancels the timer set by "setTimeout()". + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @param timeoutID Indicates the timer ID returned by "setTimeout()". + * @since 3 + */ +export declare function clearTimeout(timeoutID?: number): void; +/** + * Get the java interface instance. The java instance needs to register, otherwise it cannot be obtained. + * After obtaining the instance, you can call the function with the same name on the Java side. + * @param name Java interface name, including package path, such as com.example.test.timeinterfaceimpl. + * @returns A promise object is returned. The resolve callback is the object of PA. The reject callback returns the object containing code and error data. + * @since 5 + * @deprecated since 8 + */ +export declare function createLocalParticleAbility(name?: string): any; +/** + * Defining syscap function. + * @since 8 + */ +export declare function canIUse(syscap: string): boolean; +/** + * Obtain the objects exposed in app.js + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ +export declare function getApp(): object; +/** + * You can create an Image object by calling new Image(). + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export declare class Image { + /** + * Network address or local resource. The internal URI is supported. + * @since 4 + */ + src: string; + /** + * Image width. + * @since 4 + */ + width?: number; + /** + * Image height. + * @since 4 + */ + height?: number; + /** + * Called when an image is successfully loaded. This function has no parameter. + * @since 4 + */ + onload?: () => void; + /** + * Called when an image fails to be loaded. This function has no parameter. + * @since 4 + */ + onerror?: () => void; +} +/** + * An ImageData object is a common object that stores the actual pixel data of a Canvas object. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export declare class ImageData { + /** + * Actual width of the ImageData object, in pixels. + * @since 4 + */ + width: number; + /** + * Actual height of the ImageData object, in pixels. + * @since 4 + */ + height: number; + /** + * A one-dimensional array of color values. The color values are sorted in the RGBA order and represented by integers from 0 to 255. + * @since 4 + */ + data: Uint8ClampedArray; +} +/** + * OffscreenCanvas provides a Canvas object that can be rendered off-screen. + * It works in both window and Web worker environments. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 7 + */ +export declare class OffscreenCanvas { + /** + * The width of the offScreen Canvas object + * The height of the offScreen Canvas object + * @since 7 + */ + constructor(width: number, height: number); + /** + * The width of the offScreen Canvas object + * @since 7 + */ + width: number; + /** + * The height of the offScreen Canvas object + * @since 7 + */ + height: number; + /** + * Gets the context object for off-screen drawing. + * @param contextId creates a CanvasRenderingContext2D object representing a two-dimensional rendering context. + * @param options object representing a three-dimensional rendering context. + * @returns a render canvas for the offScreen Canvas object. + * @since 7 + */ + getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings): OffscreenCanvasRenderingContext2D; + /** + * Converts the draw contents of the current off-screen draw object to a string in the form of a Blob. + * @param type indicating the image format. + * @param quality between 0 and 1 indicating image quality if the type option is image/jpeg or image/webp. + * @returns A Promise returning a Blob object representing the image contained in the canvas. + * @since 7 + */ + toDataURL(type?: string, quality?: number): string; + /** + * Converts the draw content in the current off-screen draw object to a Bitmap object. + * @returns Returns An ImageBitmap object. + * @since 7 + */ + transferToImageBitmap(): ImageBitmap; +} +/** + * Defines the ImageBitmap. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 7 + */ +export declare class ImageBitmap { + /** + * The height of the Image Bitmap object. + * @since 7 + */ + readonly height: number; + /** + * The width of the Image Bitmap object. + * @since 7 + */ + readonly width: number; +} diff --git a/build-tools/api/common/full/index.d.ts b/build-tools/api/common/full/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bf0d9d698050330afd95c68c2eb2e63449d31c5a --- /dev/null +++ b/build-tools/api/common/full/index.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export * from './viewmodel'; +export * from './featureability'; +export * from './console'; +export * from './global'; +export * from './dom'; diff --git a/build-tools/api/common/full/viewmodel.d.ts b/build-tools/api/common/full/viewmodel.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fee584d6f6a7a2d9496ef5755e938d38d3ea934c --- /dev/null +++ b/build-tools/api/common/full/viewmodel.d.ts @@ -0,0 +1,2481 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Image, ImageData } from "./global"; +import { WebGLContextAttributes, WebGLRenderingContext } from "../../webgl/webgl"; +import { WebGL2RenderingContext } from "../../webgl/webgl2"; +import { PixelMap } from "../../@ohos.multimedia.image"; +/** + * Defines the foucs param. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 3 + */ +export interface FocusParamObj { + /** + * Whether needs to focus. + * @since 3 + */ + focus: boolean; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ +export interface RectObj { + /** + * @since 6 + */ + width: number; + /** + * @since 6 + */ + height: number; + /** + * @since 6 + */ + left: number; + /** + * @since 6 + */ + top: number; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ +export interface ContextAttrOptions { + /** + * @since 6 + */ + antialias: boolean; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface AnimateStyle { + /** + * Width value applied to the component after the animation is executed. + * @since 4 + */ + width: number; + /** + * Height value applied to the component after the animation is executed. + * @since 4 + */ + height: number; + /** + * left offset applied to the component after the animation is executed. + * @since 4 + */ + left: number; + /** + * top offset applied to the component after the animation is executed. + * @since 4 + */ + top: number; + /** + * right offset applied to the component after the animation is executed. + * @since 4 + */ + right: number; + /** + * bottom offset applied to the component after the animation is executed. + * @since 4 + */ + bottom: number; + /** + * Background color applied to the component after the animation is executed. + * The default value is none. + * @since 4 + */ + backgroundColor: string; + /** + * Opacity applied to the component. The value ranges from 0 to 1. + * The default value is 1. + * @since 4 + */ + opacity: number; + /** + * The value format is "x y", in percentage or pixels. + * The first value indicates the horizontal position, and the second value indicates the vertical position. + * If only one value is specified, the other value is 50% by default. + * @since 4 + */ + backgroundPosition: string; + /** + * Origin position of the transformed element. + * The first value indicates the x-axis position. The value can be left, center, right, a length, or percentage. + * The second value indicates the y-axis position. The value can be top, center, bottom, a length, or a percentage. + * @since 4 + */ + transformOrigin: string; + /** + * Transformation type applied to an element. + * @since 4 + */ + transform: "none" | TransformObject; + /** + * The value of offset must be within (0.0,1.0] and sorted in ascending order if it is provided. + * If there are only two frames, offset can be left empty. + * If there are more than two frames, offset is mandatory. + * @since 4 + */ + offset?: number; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface TransformObject { + /** + * Defines a 2D transformation, using a matrix of six values.. + * @param scaleX the scale value for x-axis + * @param skewX the skew value for y-axis + * @param skewY the skew value for x-axis + * @param scaleY the scale value for y-axis + * @param translateX the translate value for x-axis + * @param translateY the translate value for y-axis + * @since 6 + */ + matrix(scaleX: number, skewX: number, skewY: number, scaleY: number, translateX: number, translateY: number): void; + /** + * Defines a 3D transformation using a 4x4 matrix of 16 values. + * @param n00 the value of the 0 row and 0 column of the 4x4 matrix + * @param n01 the value of the 0 row and 1 column of the 4x4 matrix + * @param n02 the value of the 0 row and 2 column of the 4x4 matrix + * @param n03 the value of the 0 row and 3 column of the 4x4 matrix + * @param n10 the value of the 1 row and 0 column of the 4x4 matrix + * @param n11 the value of the 1 row and 1 column of the 4x4 matrix + * @param n12 the value of the 1 row and 2 column of the 4x4 matrix + * @param n13 the value of the 1 row and 3 column of the 4x4 matrix + * @param n20 the value of the 2 row and 0 column of the 4x4 matrix + * @param n21 the value of the 2 row and 1 column of the 4x4 matrix + * @param n22 the value of the 2 row and 2 column of the 4x4 matrix + * @param n23 the value of the 2 row and 3 column of the 4x4 matrix + * @param n30 the value of the 3 row and 0 column of the 4x4 matrix + * @param n31 the value of the 3 row and 1 column of the 4x4 matrix + * @param n32 the value of the 3 row and 2 column of the 4x4 matrix + * @param n33 the value of the 3 row and 3 column of the 4x4 matrix + * @since 6 + */ + matrix3d(n00: number, n01: number, n02: number, n03: number, n10: number, n11: number, n12: number, n13: number, n20: number, n21: number, n22: number, n23: number, n30: number, n31: number, n32: number, n33: number): void; + /** + * Defines 2D transformations for translation of the X and Y axes + * @param x the translate value for x-axis + * @param y the translate value for y-axis + * @since 4 + */ + translate(x: number, y: number): void; + /** + * Defines 3D transformations for translation of the X / Y / Z axes + * @param x the translate value for x-axis + * @param y the translate value for y-axis + * @param z the translate value for z-axis + * @since 6 + */ + translate3d(x: number, y: number, z: number): void; + /** + * Defines 2D transformations for translation of the X axes + * @param x the translate value for x-axis + * @since 4 + */ + translateX(x: number): void; + /** + * Defines 2D transformations for translation of the Y axes + * @param y the translate value for y-axis + * @since 4 + */ + translateY(y: number): void; + /** + * Defines 3D transformations for translation of the Z axes + * @param z the translate value for z-axis + * @since 6 + */ + translateZ(z: number): void; + /** + * Defines 2D transformations for scaling of the X and Y axes + * @param x the scale value for x-axis + * @param y the scale value for y-axis + * @since 4 + */ + scale(x: number, y: number): void; + /** + * Defines 3D transformations for scaling of the X / Y / Z axes + * @param x the scale value for x-axis + * @param y the scale value for y-axis + * @param z the scale value for z-axis + * @since 6 + */ + scale3d(x: number, y: number, z: number): void; + /** + * Defines 2D transformations for scaling of the X axes + * @param x the scale value for x-axis + * @since 4 + */ + scaleX(x: number): void; + /** + * Defines 2D transformations for scaling of the Y axes + * @param y the scale value for y-axis + * @since 4 + */ + scaleY(y: number): void; + /** + * Defines 3D transformations for scaling of the Z axes + * @param z the scale value for z-axis + * @since 6 + */ + scaleZ(z: number): void; + /** + * Define the 2D rotation and specify the angle in the parameters. + * @param angle the rotate value for z-axis + * @since 4 + */ + rotate(angle: number): void; + /** + * Defines a 3D transformation for rotating the X / Y / Z axes. + * @param x the vector value of the x-axis + * @param y the vector value of the y-axis + * @param z the vector value of the z-axis + * @param angle the rotate value for x&y&z vector. + * @since 6 + */ + rotate3d(x: number, y: number, z: number, angle: number): void; + /** + * Defines 3D transformations for rotating of the X axes. + * @param x the scale value for x-axis + * @since 4 + */ + rotateX(angle: number): void; + /** + * Defines 3D transformations for rotating of the Y axes. + * @param y the scale value for y-axis + * @since 4 + */ + rotateY(angle: number): void; + /** + * Defines 3D transformations for rotating of the Z axes. + * @param z the scale value for z-axis + * @since 6 + */ + rotateZ(angle: number): void; + /** + * Defines the 2D skew transition along the X and Y axes. + * @param xAngle the angle of inclination along the x axis. + * @param yAngle the angle of inclination along the y axis. + * @since 6 + */ + skew(xAngle: number, yAngle: number): void; + /** + * Defines the 2D skew transition along the X axes. + * @param angle the angle of inclination along the x axis. + * @since 6 + */ + skewX(angle: number): void; + /** + * Defines the 2D skew transition along the Y axes. + * @param angle the angle of inclination along the y axis. + * @since 6 + */ + skewY(angle: number): void; + /** + * Defines a perspective view for the 3D transformation element. + * @param n the vertical distance from the observation point to the component plane. + * @since 6 + */ + perspective(verticalDistance: number): void; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface AnimateOptions { + /** + * Duration of the animation, in milliseconds. + * The default value is 0. + * @since 4 + */ + duration: number; + /** + * Time curve of the animation. For details about the supported types. + * linear The animation speed keeps unchanged. + * ease The animation starts and ends at a low speed, cubic-bezier(0.25, 0.1, 0.25, 1.0). + * ease-in The animation starts at a low speed, cubic-bezier(0.42, 0.0, 1.0, 1.0). + * ease-out The animation ends at a low speed, cubic-bezier(0.0, 0.0, 0.58, 1.0). + * ease-in-out The animation starts and ends at a low speed, cubic-bezier(0.42, 0.0, 0.58, 1.0). + * fast-out-slow-in Standard curve, cubic-bezier(0.4, 0.0, 0.2, 1.0). + * linear-out-slow-in Deceleration curve, cubic-bezier(0.0, 0.0, 0.2, 1.0). + * fast-out-linear-in Acceleration curve, cubic-bezier(0.4, 0.0, 1.0, 1.0). + * friction Damping curve, cubic-bezier(0.2, 0.0, 0.2, 1.0). + * extreme-deceleration Extreme deceleration curve, cubic-bezier(0.0, 0.0, 0.0, 1.0). + * sharp Sharp curve, cubic-bezier(0.33, 0.0, 0.67, 1.0). + * rhythm Rhythm curve, cubic-bezier(0.7, 0.0, 0.2, 1.0). + * smooth Smooth curve, cubic-bezier(0.4, 0.0, 0.4, 1.0). + * cubic-bezier(x1, y1, x2, y2) You can customize an animation speed curve in the cubic-bezier() function. The x and y values of each input parameter must be between 0 and 1. + * Step curve. The number must be set and only an integer is supported, step-position is optional. It can be set to start or end. The default value is end. + * The default value is ease. + * @since 4 + */ + easing: string; + /** + * Delay for the animation start. The default value indicates no delay. + * The default value is 0. + * @since 4 + */ + delay: number; + /** + * Number of times the animation will be played. number indicates a fixed number of playback operations, and Infinity indicates an unlimited number of playback operations. + * The default value is 1. + * @since 4 + */ + iterations: number | string; + /** + * The animation playback mode. + * The default value is "normal". + * @since 6 + */ + direction: "normal" | "reverse" | "alternate" | "alternate-reverse"; + /** + * Whether to resume to the initial state after the animation is executed. + * none: The initial state is restored after the animation is executed. + * forwards: The state at the end of the animation (defined in the last key frame) is retained after the animation is executed. + * @since 4 + */ + fill: "none" | "forwards" | "backwards" | "both"; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface AnimationResult { + /** + * Read-only attribute, which indicates whether the animation playback is complete. + * @since 4 + */ + finished: boolean; + /** + * Read-only attribute, which indicates whether an animation is waiting for the completion of other asynchronous operations (for example, start an animation with a delay). + * @since 4 + */ + pending: boolean; + /** + * Animation running state: + * idle: The animation is not running (playback ended or not started). + * running: The animation is running. + * paused: The animation is paused. + * finished: Animation playback ends. + * @since 4 + */ + playstate: string; + /** + * Animation start time. This attribute is similar to that of delay in the options parameters. + * @since 4 + */ + startTime: number; + /** + * Starts the animation. + * @since 4 + */ + play(): void; + /** + * Ends the animation. + * @since 4 + */ + finish(): void; + /** + * Pauses the animation. + * @since 4 + */ + pause(): void; + /** + * Cancels the animation. + * @since 4 + */ + cancel(): void; + /** + * Plays the animation in reverse direction. + * @since 4 + */ + reverse(): void; + /** + * The animation is started. + * @since 4 + */ + onstart: () => void; + /** + * The animation is finished. + * @since 4 + */ + onfinish: () => void; + /** + * The animation is canceled. + * @since 4 + */ + oncancel: () => void; + /** + * The animation is repeated. + * @since 4 + */ + onrepeat: () => void; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface Element { + /** + * Requests or cancels the focus for a component. + * If focus is set to true, the focus is requested for the component. + * If focus is set to false, the focus is canceled for the component. + * This attribute can be defaulted to true. + * @param obj { focus: true | false } + * @since 4 + */ + focus(obj?: FocusParamObj): void; + /** + * Requests or cancels the crown rotation focus for a component. + * If focus is set to true, the crown event focus is requested. + * If focus is set to false, the crown event focus is canceled. + * This attribute can be defaulted to true. + * @param obj { focus: true | false } + * @since 4 + */ + rotation(obj?: FocusParamObj): void; + /** + * Creates and runs an animation shortcut on the component. Specify the keyframes and options required for the animation. + * @param keyframes keyframes is used to describe key frame parameters of the animation. + * @param options Options. is used to describe animation parameters. + * @returns This method returns the animation object. + * @since 4 + */ + animate(keyframes: Array, options: AnimateOptions): AnimationResult; + /** + * Obtains the size and position of the element. + * @returns RectObj the size position of the element. + * @since 6 + */ + getBoundingClientRect(): RectObj; + /** + * If 0.5 is returned, 50% of the current component is visible. + * @param radios Scope of Monitoring components. + * @since 6 + */ + createIntersectionObserver(param: { + ratios: Array; + }): observer; + /** + * Adds a node to the end of the child node list of the current node. + * @param child Subnode object to be added + * @since 8 + */ + addChild(child: Element): void; + /** + * Sets the value of an attribute on a specified element. If the attribute already exists, update the value. Otherwise, a new attribute is added with the specified name and value. + * @param name attribute name + * @param value attribute value¡¢ + * @since 8 + */ + setAttribute(name: string, value: string): void; + /** + * Sets a style value on a specified element. If the style exists and the style value is valid, the setting is successful. Otherwise, the setting is invalid. + * @param name style name + * @param value style value + * @returns If the setting is successful, true is returned. If the setting fails, false is returned. + * @since 8 + */ + setStyle(name: string, value: string): boolean; +} +/** + * Defines the observer interface. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ +export interface observer { + /** + * Turn on the listener. + * @since 6 + */ + observe(callback: string): void; + /** + * Turn off the listenerr. + * @since 6 + */ + unobserve(): void; +} +/** + * animation element + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface AnimationElement extends Element { + /** + * Starts the animation. + * @since 4 + */ + play(): void; + /** + * Ends the animation. + * @since 4 + */ + finish(): void; + /** + * Pauses the animation. + * @since 4 + */ + pause(): void; + /** + * Cancels the animation. + * @since 4 + */ + cancel(): void; + /** + * Plays the animation in reverse direction. + * @since 4 + */ + reverse(): void; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface ScrollParam { + /** + * Offset for scrolling in the horizontal direction, in px. + * @since 4 + */ + dx?: number; + /** + * Offset for scrolling in the vertical direction, in px. + * @since 4 + */ + dy?: number; + /** + * Whether a sliding animation is displayed when scroll position is changed. + * @since 4 + */ + smooth?: boolean; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface CurrentOffsetResultValue { + /** + * Scrolling offset in the x-axis, in px. + * @since 4 + */ + x: number; + /** + * Scrolling offset in the y-axis, in px. + * @since 4 + */ + y: number; +} +/** + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface ListScrollToOptions { + /** + * specified position. + * @since 4 + */ + index: number; +} +/** + * The component provides a list container. + * @syscap SystemCapability.ArkUI.ArkUI.Full + */ +export interface ListElement extends Element { + /** + * Scrolls the list to the position of the item at the specified index. + * @since 4 + */ + scrollTo(position: ListScrollToOptions): void; + /** + * Scrolls the list for a certain distance. + * This method applies only to smart TVs. + * @since 4 + */ + scrollBy(data: ScrollParam): void; + /** + * If smooth is set to false (default value), the list is directly scrolled to the top. + * If smooth is set to true, the list is smoothly scrolled to the top. + * @param param + * @since 4 + */ + scrollTop(param: { + smooth: boolean; + }): void; + /** + * If smooth is set to false (default value), the list is directly scrolled to the bottom. + * If smooth is set to true, the list is smoothly scrolled to the bottom. + * @param param + * @since 4 + */ + scrollBottom(param: { + smooth: boolean; + }): void; + /** + * If reverse is set to false (default value), the next page is displayed. If there is no next page, the list scrolls to the bottom. + * If reverse is set to true, the previous page is displayed. If there is no previous page, the list scrolls to the top. + * If smooth is set to false (default value), the list is directly scrolled to another page. + * If smooth is set to true, the list is smoothly scrolled to another page. + * @param params + * @since 4 + */ + scrollPage(params: { + reverse: boolean; + smooth: boolean; + }): void; + /** + * If reverse is set to false (default value), the list scrolls towards the bottom for a certain distance. If there is no sufficient distance, the list scrolls to the bottom. + * If reverse is set to true, the list scrolls towards the top for a certain distance. If there is no sufficient distance, the list scrolls to the top. + * If smooth is set to false (default value), the list is directly scrolled. + * If smooth is set to true, the list is smoothly scrolled. + * @param params + * @since 4 + */ + scrollArrow(params: { + reverse: boolean; + smooth: boolean; + }): void; + /** + * Collapses a group. + * @param param + * @since 4 + */ + collapseGroup(param: { + /** + * groupid: ID of the group to collapse. + * All groups are collapsed when groupid is not specified. + */ + groupid: string; + }): void; + /** + * Expands a group. + * @param param + * @since 4 + */ + expandGroup(param: { + /** + * groupid: ID of the group to expand. + * All groups are expanded when groupid is not specified. + */ + groupid: string; + }): void; + /** + * Returns the offset of the current scrolling. The return value type is Object. + * @since 4 + */ + currentOffset(): CurrentOffsetResultValue; +} +/** + * The component provides a swiper container. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface SwiperElement extends Element { + /** + * Scrolls the child component to the position at the specified index. + * @since 4 + */ + swipeTo(position: { + /** + * specified position. + */ + index: number; + }): void; + /** + * Shows the next child component. + * @since 4 + */ + showNext(): void; + /** + * Shows the previous child component. + * @since 4 + */ + showPrevious(): void; +} +/** + * @since 6 + * @syscap SystemCapability.ArkUI.ArkUI.Full + */ +export interface CameraTakePhotoOptions { + /** + * Picture quality. + * @since 6 + */ + quality: "high" | "normal" | "low"; + /** + * Callback function for successful interface invocation. + * @param result the request execution result. + * @since 6 + */ + success?: (result: Object) => void; + /** + * Callback function for interface invocation failure. + * @param result the request execution result. + * @since 6 + */ + fail?: (result: Object) => void; + /** + * Callback function at the end of the interface invoking (executed both successfully and unsuccessfully). + * @param result the request execution result. + * @since 6 + */ + complete?: (result: Object) => void; +} +/** + * The component provides preview and photographing functions. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ +export interface CameraElement extends Element { + /** + * Take photos with specified parameters. + * @param options the parameters of camera. + * @since 6 + */ + takePhoto(options: CameraTakePhotoOptions): void; +} +/** + * The component is a container for displaying web page content. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 6 + */ +export interface WebElement extends Element { + /** + * Reload the web page content + * @since 6 + */ + reload(): void; +} +/** + * The component is a custom pop-up container. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface DialogElement extends Element { + /** + * Shows a dialog box. + * @since 4 + */ + show(): void; + /** + * Closes a dialog box. + * @since 4 + */ + close(): void; +} +/** + * The component is used to provide an image frame animator. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface ImageAnimatorElement extends Element { + /** + * Starts to play the frame animation of an image. If this method is called again, the playback starts from the first frame. + * @since 4 + */ + start(): void; + /** + * Pauses the frame animation playback of an image. + * @since 4 + */ + pause(): void; + /** + * Stops the frame animation playback of an image. + * @since 4 + */ + stop(): void; + /** + * Resumes the frame animation playback of an image. + * @since 4 + */ + resume(): void; + /** + * Obtains the playback state. Available values are as follows: + * Playing + * Paused + * Stopped + * @since 4 + */ + getState(): "Playing" | "Paused" | "Stopped"; +} +/** + * The component inserts scrolling text, which is displayed in a single line by default. + * When the text length exceeds the display area of the component, the marquee effect is displayed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface MarqueeElement extends Element { + /** + * Starts scrolling. + * @since 4 + */ + start(): void; + /** + * Stops scrolling. + * @since 4 + */ + stop(): void; +} +/** + * The component provides menus as temporary pop-up windows to display operations that can be performed by users. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface MenuElement extends Element { + /** + * Displays the menu. + * x and y specify the position of the displayed menu. + * x indicates the X-axis coordinate from the left edge of the visible area, and does not include any scrolling offset. + * y indicates the Y-axis coordinate from the upper edge of the visible area, and does not include any scrolling offset or a status bar. + * The menu is preferentially displayed in the lower right corner. + * When the visible space on the right is insufficient, the menu is moved leftward. + * When the visible space in the lower part is insufficient, the menu is moved upward. + * @param position + * @since 4 + */ + show(position: { + x: number; + y: number; + }): void; +} +/** + * The component displays line charts, gauge charts, and bar charts. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface ChartElement extends Element { + /** + * Data is dynamically added to an existing data sequence. + * The target sequence is specified based on serial, which is the subscript of the datasets array and starts from 0. + * datasets[index].data is not updated. Only line charts support this attribute. + * The value is incremented by 1 based on the horizontal coordinate and is related to the xAxis min/max setting. + * @since 4 + */ + append(params: { + /** + * Set the data subscript of the line chart to be updated. + */ + serial: number; + /** + * Set the new data. + */ + data: Array; + }): void; +} +/** + * The component provides an interactive interface to receive user input, which is displayed in a single line by default. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 4 + */ +export interface InputElement extends Element { + /** + * Obtains or loses the focus of a component. + * When the component type is set to text, email, date, time, number, or password, the input method can be displayed or collapsed. + * @param param If focus is not passed, the default value true is used. + * @since 4 + */ + focus(param: { + focus: boolean; + }): void; + /** + * Displays the error message. + * This attribute is available when the component type is set to text, email, date, time, number, or password. + * @param param + * @since 4 + */ + showError(param: { + error: string; + }): void; + /** + * Deletes the previous character at the cursor position. + * @since 6 + */ + delete(): void; +} +/** + * The